777 lines
33 KiB
Zig
777 lines
33 KiB
Zig
const std = @import("std");
|
|
pub const c = @import("c.zig").c;
|
|
|
|
pub const PenID = u32;
|
|
|
|
pub const WindowID = u32;
|
|
|
|
pub const AudioDeviceID = u32;
|
|
|
|
pub const DisplayID = u32;
|
|
|
|
pub const CameraID = u32;
|
|
|
|
pub const PenInputFlags = packed struct(u32) {
|
|
penInputDown: bool = false, // pen is pressed down
|
|
penInputButton1: bool = false, // button 1 is pressed
|
|
penInputButton2: bool = false, // button 2 is pressed
|
|
penInputButton3: bool = false, // button 3 is pressed
|
|
penInputButton4: bool = false, // button 4 is pressed
|
|
penInputButton5: bool = false, // button 5 is pressed
|
|
penInputEraserTip: bool = false, // eraser tip is used
|
|
pad0: u24 = 0,
|
|
rsvd: bool = false,
|
|
|
|
pub const None = PenInputFlags{};
|
|
};
|
|
|
|
pub const MouseButtonFlags = packed struct(u32) {
|
|
buttonLeft: bool = false,
|
|
buttonMiddle: bool = false,
|
|
buttonX1: bool = false,
|
|
pad0: u28 = 0,
|
|
rsvd: bool = false,
|
|
|
|
pub const None = MouseButtonFlags{};
|
|
pub const ButtonRight: MouseButtonFlags = @bitCast(@as(u32, 3));
|
|
pub const ButtonX2: MouseButtonFlags = @bitCast(@as(u32, 5));
|
|
};
|
|
|
|
pub const Scancode = enum(c_int) {
|
|
scancodeBackslash = 49,
|
|
scancodeNonushash = 50,
|
|
scancodeGrave = 53,
|
|
scancodeInsert = 73,
|
|
scancodeNumlockclear = 83,
|
|
scancodeNonusbackslash = 100,
|
|
scancodeApplication = 101, //windows contextual menu, compose
|
|
scancodePower = 102,
|
|
scancodeHelp = 117, //AL Integrated Help Center
|
|
scancodeMenu = 118, //Menu (show menu)
|
|
scancodeStop = 120, //AC Stop
|
|
scancodeAgain = 121, //AC Redo/Repeat
|
|
scancodeUndo = 122, //AC Undo
|
|
scancodeCut = 123, //AC Cut
|
|
scancodeCopy = 124, //AC Copy
|
|
scancodePaste = 125, //AC Paste
|
|
scancodeFind = 126, //AC Find
|
|
scancodeInternational1 = 135,
|
|
scancodeInternational3 = 137, //Yen
|
|
scancodeLang1 = 144, //Hangul/English toggle
|
|
scancodeLang2 = 145, //Hanja conversion
|
|
scancodeLang3 = 146, //Katakana
|
|
scancodeLang4 = 147, //Hiragana
|
|
scancodeLang5 = 148, //Zenkaku/Hankaku
|
|
scancodeLang6 = 149, //reserved
|
|
scancodeLang7 = 150, //reserved
|
|
scancodeLang8 = 151, //reserved
|
|
scancodeLang9 = 152, //reserved
|
|
scancodeAlterase = 153, //Erase-Eaze
|
|
scancodeCancel = 155, //AC Cancel
|
|
scancodeLalt = 226, //alt, option
|
|
scancodeLgui = 227, //windows, command (apple), meta
|
|
scancodeRalt = 230, //alt gr, option
|
|
scancodeRgui = 231, //windows, command (apple), meta
|
|
scancodeMode = 257,
|
|
scancodeSleep = 258, //Sleep
|
|
scancodeWake = 259, //Wake
|
|
scancodeChannelIncrement = 260, //Channel Increment
|
|
scancodeChannelDecrement = 261, //Channel Decrement
|
|
scancodeMediaPlay = 262, //Play
|
|
scancodeMediaPause = 263, //Pause
|
|
scancodeMediaRecord = 264, //Record
|
|
scancodeMediaFastForward = 265, //Fast Forward
|
|
scancodeMediaRewind = 266, //Rewind
|
|
scancodeMediaNextTrack = 267, //Next Track
|
|
scancodeMediaPreviousTrack = 268, //Previous Track
|
|
scancodeMediaStop = 269, //Stop
|
|
scancodeMediaEject = 270, //Eject
|
|
scancodeMediaPlayPause = 271, //Play / Pause
|
|
scancodeMediaSelect = 272,
|
|
scancodeAcNew = 273, //AC New
|
|
scancodeAcOpen = 274, //AC Open
|
|
scancodeAcClose = 275, //AC Close
|
|
scancodeAcExit = 276, //AC Exit
|
|
scancodeAcSave = 277, //AC Save
|
|
scancodeAcPrint = 278, //AC Print
|
|
scancodeAcProperties = 279, //AC Properties
|
|
scancodeAcSearch = 280, //AC Search
|
|
scancodeAcHome = 281, //AC Home
|
|
scancodeAcBack = 282, //AC Back
|
|
scancodeAcForward = 283, //AC Forward
|
|
scancodeAcStop = 284, //AC Stop
|
|
scancodeAcRefresh = 285, //AC Refresh
|
|
scancodeAcBookmarks = 286, //AC Bookmarks
|
|
scancodeSoftleft = 287,
|
|
scancodeSoftright = 288,
|
|
scancodeCall = 289, //Used for accepting phone calls.
|
|
scancodeEndcall = 290, //Used for rejecting phone calls.
|
|
scancodeReserved = 400, //400-500 reserved for dynamic keycodes
|
|
scancodeCount = 512,
|
|
};
|
|
|
|
pub const TouchID = u64;
|
|
|
|
pub const KeyboardID = u32;
|
|
|
|
pub const PenAxis = enum(c_int) {
|
|
penAxisPressure, //Pen pressure. Unidirectional: 0 to 1.0
|
|
penAxisXtilt, //Pen horizontal tilt angle. Bidirectional: -90.0 to 90.0 (left-to-right).
|
|
penAxisYtilt, //Pen vertical tilt angle. Bidirectional: -90.0 to 90.0 (top-to-down).
|
|
penAxisDistance, //Pen distance to drawing surface. Unidirectional: 0.0 to 1.0
|
|
penAxisRotation, //Pen barrel rotation. Bidirectional: -180 to 179.9 (clockwise, 0 is facing up, -180.0 is facing down).
|
|
penAxisSlider, //Pen finger wheel or slider (e.g., Airbrush Pen). Unidirectional: 0 to 1.0
|
|
penAxisTangentialPressure, //Pressure from squeezing the pen ("barrel pressure").
|
|
penAxisCount, //Total known pen axis types in this version of SDL. This number may grow in future releases!
|
|
};
|
|
|
|
pub const MouseID = u32;
|
|
|
|
pub const MouseWheelDirection = enum(c_int) {
|
|
mousewheelNormal, //The scroll direction is normal
|
|
mousewheelFlipped, //The scroll direction is flipped / natural
|
|
};
|
|
|
|
pub const PowerState = enum(c_int) {
|
|
powerstateError = -1, //error determining power status
|
|
powerstateUnknown, //cannot determine power status
|
|
powerstateOnBattery, //Not plugged in, running on the battery
|
|
powerstateNoBattery, //Plugged in, no battery available
|
|
powerstateCharging, //Plugged in, charging battery
|
|
powerstateCharged,
|
|
};
|
|
|
|
pub const Window = opaque {};
|
|
|
|
pub const FingerID = u64;
|
|
|
|
pub const Keycode = u32;
|
|
|
|
pub const SensorID = u32;
|
|
|
|
pub const JoystickID = u32;
|
|
|
|
pub const Keymod = u16;
|
|
|
|
pub const EventType = enum(c_int) {
|
|
eventFirst = 0, //Unused (do not remove)
|
|
eventQuit = 0x100, //User-requested quit
|
|
eventTerminating,
|
|
eventLowMemory,
|
|
eventWillEnterBackground,
|
|
eventDidEnterBackground,
|
|
eventWillEnterForeground,
|
|
eventDidEnterForeground,
|
|
eventLocaleChanged, //The user's locale preferences have changed.
|
|
eventSystemThemeChanged, //The system theme changed
|
|
eventDisplayOrientation = 0x151, //Display orientation has changed to data1
|
|
eventDisplayAdded, //Display has been added to the system
|
|
eventDisplayRemoved, //Display has been removed from the system
|
|
eventDisplayMoved, //Display has changed position
|
|
eventDisplayDesktopModeChanged, //Display has changed desktop mode
|
|
eventDisplayCurrentModeChanged, //Display has changed current mode
|
|
eventDisplayContentScaleChanged, //Display has changed content scale
|
|
eventWindowShown = 0x202, //Window has been shown
|
|
eventWindowHidden, //Window has been hidden
|
|
eventWindowExposed, //Window has been exposed and should be redrawn, and can be redrawn directly from event watchers for this event
|
|
eventWindowMoved, //Window has been moved to data1, data2
|
|
eventWindowResized, //Window has been resized to data1xdata2
|
|
eventWindowPixelSizeChanged, //The pixel size of the window has changed to data1xdata2
|
|
eventWindowMetalViewResized, //The pixel size of a Metal view associated with the window has changed
|
|
eventWindowMinimized, //Window has been minimized
|
|
eventWindowMaximized, //Window has been maximized
|
|
eventWindowRestored, //Window has been restored to normal size and position
|
|
eventWindowMouseEnter, //Window has gained mouse focus
|
|
eventWindowMouseLeave, //Window has lost mouse focus
|
|
eventWindowFocusGained, //Window has gained keyboard focus
|
|
eventWindowFocusLost, //Window has lost keyboard focus
|
|
eventWindowCloseRequested, //The window manager requests that the window be closed
|
|
eventWindowHitTest, //Window had a hit test that wasn't SDL_HITTEST_NORMAL
|
|
eventWindowIccprofChanged, //The ICC profile of the window's display has changed
|
|
eventWindowDisplayChanged, //Window has been moved to display data1
|
|
eventWindowDisplayScaleChanged, //Window display scale has been changed
|
|
eventWindowSafeAreaChanged, //The window safe area has been changed
|
|
eventWindowOccluded, //The window has been occluded
|
|
eventWindowEnterFullscreen, //The window has entered fullscreen mode
|
|
eventWindowLeaveFullscreen, //The window has left fullscreen mode
|
|
eventWindowDestroyed,
|
|
eventWindowHdrStateChanged, //Window HDR properties have changed
|
|
eventKeyDown = 0x300, //Key pressed
|
|
eventKeyUp, //Key released
|
|
eventTextEditing, //Keyboard text editing (composition)
|
|
eventTextInput, //Keyboard text input
|
|
eventKeymapChanged,
|
|
eventKeyboardAdded, //A new keyboard has been inserted into the system
|
|
eventKeyboardRemoved, //A keyboard has been removed
|
|
eventTextEditingCandidates, //Keyboard text editing candidates
|
|
eventMouseMotion = 0x400, //Mouse moved
|
|
eventMouseButtonDown, //Mouse button pressed
|
|
eventMouseButtonUp, //Mouse button released
|
|
eventMouseWheel, //Mouse wheel motion
|
|
eventMouseAdded, //A new mouse has been inserted into the system
|
|
eventMouseRemoved, //A mouse has been removed
|
|
eventJoystickAxisMotion = 0x600, //Joystick axis motion
|
|
eventJoystickBallMotion, //Joystick trackball motion
|
|
eventJoystickHatMotion, //Joystick hat position change
|
|
eventJoystickButtonDown, //Joystick button pressed
|
|
eventJoystickButtonUp, //Joystick button released
|
|
eventJoystickAdded, //A new joystick has been inserted into the system
|
|
eventJoystickRemoved, //An opened joystick has been removed
|
|
eventJoystickBatteryUpdated, //Joystick battery level change
|
|
eventJoystickUpdateComplete, //Joystick update is complete
|
|
eventGamepadAxisMotion = 0x650, //Gamepad axis motion
|
|
eventGamepadButtonDown, //Gamepad button pressed
|
|
eventGamepadButtonUp, //Gamepad button released
|
|
eventGamepadAdded, //A new gamepad has been inserted into the system
|
|
eventGamepadRemoved, //A gamepad has been removed
|
|
eventGamepadRemapped, //The gamepad mapping was updated
|
|
eventGamepadTouchpadDown, //Gamepad touchpad was touched
|
|
eventGamepadTouchpadMotion, //Gamepad touchpad finger was moved
|
|
eventGamepadTouchpadUp, //Gamepad touchpad finger was lifted
|
|
eventGamepadSensorUpdate, //Gamepad sensor was updated
|
|
eventGamepadUpdateComplete, //Gamepad update is complete
|
|
eventGamepadSteamHandleUpdated, //Gamepad Steam handle has changed
|
|
eventFingerUp,
|
|
eventFingerMotion,
|
|
eventFingerCanceled,
|
|
eventClipboardUpdate = 0x900, //The clipboard or primary selection changed
|
|
eventDropFile = 0x1000, //The system requests a file open
|
|
eventDropText, //text/plain drag-and-drop event
|
|
eventDropBegin, //A new set of drops is beginning (NULL filename)
|
|
eventDropComplete, //Current set of drops is now complete (NULL filename)
|
|
eventDropPosition, //Position while moving over the window
|
|
eventAudioDeviceAdded = 0x1100, //A new audio device is available
|
|
eventAudioDeviceRemoved, //An audio device has been removed.
|
|
eventAudioDeviceFormatChanged, //An audio device's format has been changed by the system.
|
|
eventSensorUpdate = 0x1200, //A sensor was updated
|
|
eventPenProximityIn = 0x1300, //Pressure-sensitive pen has become available
|
|
eventPenProximityOut, //Pressure-sensitive pen has become unavailable
|
|
eventPenDown, //Pressure-sensitive pen touched drawing surface
|
|
eventPenUp, //Pressure-sensitive pen stopped touching drawing surface
|
|
eventPenButtonDown, //Pressure-sensitive pen button pressed
|
|
eventPenButtonUp, //Pressure-sensitive pen button released
|
|
eventPenMotion, //Pressure-sensitive pen is moving on the tablet
|
|
eventPenAxis, //Pressure-sensitive pen angle/pressure/etc changed
|
|
eventCameraDeviceAdded = 0x1400, //A new camera device is available
|
|
eventCameraDeviceRemoved, //A camera device has been removed.
|
|
eventCameraDeviceApproved, //A camera device has been approved for use by the user.
|
|
eventCameraDeviceDenied, //A camera device has been denied for use by the user.
|
|
eventRenderTargetsReset = 0x2000, //The render targets have been reset and their contents need to be updated
|
|
eventRenderDeviceReset, //The device has been reset and all textures need to be recreated
|
|
eventRenderDeviceLost, //The device has been lost and can't be recovered.
|
|
eventPrivate1,
|
|
eventPrivate2,
|
|
eventPrivate3,
|
|
eventPollSentinel = 0x7F00, //Signals the end of an event poll cycle
|
|
};
|
|
|
|
pub const CommonEvent = extern struct {
|
|
_type: u32, // Event type, shared with all events, Uint32 to cover user events which are not in the SDL_EventType enumeration
|
|
reserved: u32,
|
|
timestamp: u64, // In nanoseconds, populated using SDL_GetTicksNS()
|
|
};
|
|
|
|
pub const DisplayEvent = extern struct {
|
|
_type: EventType, // SDL_DISPLAYEVENT_*
|
|
reserved: u32,
|
|
timestamp: u64, // In nanoseconds, populated using SDL_GetTicksNS()
|
|
displayID: DisplayID, // The associated display
|
|
data1: i32, // event dependent data
|
|
data2: i32, // event dependent data
|
|
};
|
|
|
|
pub const WindowEvent = extern struct {
|
|
_type: EventType, // SDL_EVENT_WINDOW_*
|
|
reserved: u32,
|
|
timestamp: u64, // In nanoseconds, populated using SDL_GetTicksNS()
|
|
windowID: WindowID, // The associated window
|
|
data1: i32, // event dependent data
|
|
data2: i32, // event dependent data
|
|
};
|
|
|
|
pub const KeyboardDeviceEvent = extern struct {
|
|
_type: EventType, // SDL_EVENT_KEYBOARD_ADDED or SDL_EVENT_KEYBOARD_REMOVED
|
|
reserved: u32,
|
|
timestamp: u64, // In nanoseconds, populated using SDL_GetTicksNS()
|
|
which: KeyboardID, // The keyboard instance id
|
|
};
|
|
|
|
pub const KeyboardEvent = extern struct {
|
|
_type: EventType, // SDL_EVENT_KEY_DOWN or SDL_EVENT_KEY_UP
|
|
reserved: u32,
|
|
timestamp: u64, // In nanoseconds, populated using SDL_GetTicksNS()
|
|
windowID: WindowID, // The window with keyboard focus, if any
|
|
which: KeyboardID, // The keyboard instance id, or 0 if unknown or virtual
|
|
scancode: Scancode, // SDL physical key code
|
|
key: Keycode, // SDL virtual key code
|
|
mod: Keymod, // current key modifiers
|
|
raw: u16, // The platform dependent scancode for this event
|
|
down: bool, // true if the key is pressed
|
|
repeat: bool, // true if this is a key repeat
|
|
};
|
|
|
|
pub const TextEditingEvent = extern struct {
|
|
_type: EventType, // SDL_EVENT_TEXT_EDITING
|
|
reserved: u32,
|
|
timestamp: u64, // In nanoseconds, populated using SDL_GetTicksNS()
|
|
windowID: WindowID, // The window with keyboard focus, if any
|
|
text: [*c]const u8, // The editing text
|
|
start: i32, // The start cursor of selected editing text, or -1 if not set
|
|
length: i32, // The length of selected editing text, or -1 if not set
|
|
};
|
|
|
|
pub const TextEditingCandidatesEvent = extern struct {
|
|
_type: EventType, // SDL_EVENT_TEXT_EDITING_CANDIDATES
|
|
reserved: u32,
|
|
timestamp: u64, // In nanoseconds, populated using SDL_GetTicksNS()
|
|
windowID: WindowID, // The window with keyboard focus, if any
|
|
candidates: [*c]const [*c]const u8, // The list of candidates, or NULL if there are no candidates available
|
|
num_candidates: i32, // The number of strings in `candidates`
|
|
selected_candidate: i32, // The index of the selected candidate, or -1 if no candidate is selected
|
|
horizontal: bool, // true if the list is horizontal, false if it's vertical
|
|
padding1: u8,
|
|
padding2: u8,
|
|
padding3: u8,
|
|
};
|
|
|
|
pub const TextInputEvent = extern struct {
|
|
_type: EventType, // SDL_EVENT_TEXT_INPUT
|
|
reserved: u32,
|
|
timestamp: u64, // In nanoseconds, populated using SDL_GetTicksNS()
|
|
windowID: WindowID, // The window with keyboard focus, if any
|
|
text: [*c]const u8, // The input text, UTF-8 encoded
|
|
};
|
|
|
|
pub const MouseDeviceEvent = extern struct {
|
|
_type: EventType, // SDL_EVENT_MOUSE_ADDED or SDL_EVENT_MOUSE_REMOVED
|
|
reserved: u32,
|
|
timestamp: u64, // In nanoseconds, populated using SDL_GetTicksNS()
|
|
which: MouseID, // The mouse instance id
|
|
};
|
|
|
|
pub const MouseMotionEvent = extern struct {
|
|
_type: EventType, // SDL_EVENT_MOUSE_MOTION
|
|
reserved: u32,
|
|
timestamp: u64, // In nanoseconds, populated using SDL_GetTicksNS()
|
|
windowID: WindowID, // The window with mouse focus, if any
|
|
which: MouseID, // The mouse instance id in relative mode, SDL_TOUCH_MOUSEID for touch events, or 0
|
|
state: MouseButtonFlags, // The current button state
|
|
x: f32, // X coordinate, relative to window
|
|
y: f32, // Y coordinate, relative to window
|
|
xrel: f32, // The relative motion in the X direction
|
|
yrel: f32, // The relative motion in the Y direction
|
|
};
|
|
|
|
pub const MouseButtonEvent = extern struct {
|
|
_type: EventType, // SDL_EVENT_MOUSE_BUTTON_DOWN or SDL_EVENT_MOUSE_BUTTON_UP
|
|
reserved: u32,
|
|
timestamp: u64, // In nanoseconds, populated using SDL_GetTicksNS()
|
|
windowID: WindowID, // The window with mouse focus, if any
|
|
which: MouseID, // The mouse instance id in relative mode, SDL_TOUCH_MOUSEID for touch events, or 0
|
|
button: u8, // The mouse button index
|
|
down: bool, // true if the button is pressed
|
|
clicks: u8, // 1 for single-click, 2 for double-click, etc.
|
|
padding: u8,
|
|
x: f32, // X coordinate, relative to window
|
|
y: f32, // Y coordinate, relative to window
|
|
};
|
|
|
|
pub const MouseWheelEvent = extern struct {
|
|
_type: EventType, // SDL_EVENT_MOUSE_WHEEL
|
|
reserved: u32,
|
|
timestamp: u64, // In nanoseconds, populated using SDL_GetTicksNS()
|
|
windowID: WindowID, // The window with mouse focus, if any
|
|
which: MouseID, // The mouse instance id in relative mode or 0
|
|
x: f32, // The amount scrolled horizontally, positive to the right and negative to the left
|
|
y: f32, // The amount scrolled vertically, positive away from the user and negative toward the user
|
|
direction: MouseWheelDirection, // Set to one of the SDL_MOUSEWHEEL_* defines. When FLIPPED the values in X and Y will be opposite. Multiply by -1 to change them back
|
|
mouse_x: f32, // X coordinate, relative to window
|
|
mouse_y: f32, // Y coordinate, relative to window
|
|
integer_x: i32, // The amount scrolled horizontally, accumulated to whole scroll "ticks" (added in 3.2.12)
|
|
integer_y: i32, // The amount scrolled vertically, accumulated to whole scroll "ticks" (added in 3.2.12)
|
|
};
|
|
|
|
pub const JoyAxisEvent = extern struct {
|
|
_type: EventType, // SDL_EVENT_JOYSTICK_AXIS_MOTION
|
|
reserved: u32,
|
|
timestamp: u64, // In nanoseconds, populated using SDL_GetTicksNS()
|
|
which: JoystickID, // The joystick instance id
|
|
axis: u8, // The joystick axis index
|
|
padding1: u8,
|
|
padding2: u8,
|
|
padding3: u8,
|
|
value: i16, // The axis value (range: -32768 to 32767)
|
|
padding4: u16,
|
|
};
|
|
|
|
pub const JoyBallEvent = extern struct {
|
|
_type: EventType, // SDL_EVENT_JOYSTICK_BALL_MOTION
|
|
reserved: u32,
|
|
timestamp: u64, // In nanoseconds, populated using SDL_GetTicksNS()
|
|
which: JoystickID, // The joystick instance id
|
|
ball: u8, // The joystick trackball index
|
|
padding1: u8,
|
|
padding2: u8,
|
|
padding3: u8,
|
|
xrel: i16, // The relative motion in the X direction
|
|
yrel: i16, // The relative motion in the Y direction
|
|
};
|
|
|
|
pub const JoyHatEvent = extern struct {
|
|
_type: EventType, // SDL_EVENT_JOYSTICK_HAT_MOTION
|
|
reserved: u32,
|
|
timestamp: u64, // In nanoseconds, populated using SDL_GetTicksNS()
|
|
which: JoystickID, // The joystick instance id
|
|
hat: u8, // The joystick hat index
|
|
padding1: u8,
|
|
padding2: u8,
|
|
};
|
|
|
|
pub const JoyButtonEvent = extern struct {
|
|
_type: EventType, // SDL_EVENT_JOYSTICK_BUTTON_DOWN or SDL_EVENT_JOYSTICK_BUTTON_UP
|
|
reserved: u32,
|
|
timestamp: u64, // In nanoseconds, populated using SDL_GetTicksNS()
|
|
which: JoystickID, // The joystick instance id
|
|
button: u8, // The joystick button index
|
|
down: bool, // true if the button is pressed
|
|
padding1: u8,
|
|
padding2: u8,
|
|
};
|
|
|
|
pub const JoyDeviceEvent = extern struct {
|
|
_type: EventType, // SDL_EVENT_JOYSTICK_ADDED or SDL_EVENT_JOYSTICK_REMOVED or SDL_EVENT_JOYSTICK_UPDATE_COMPLETE
|
|
reserved: u32,
|
|
timestamp: u64, // In nanoseconds, populated using SDL_GetTicksNS()
|
|
which: JoystickID, // The joystick instance id
|
|
};
|
|
|
|
pub const JoyBatteryEvent = extern struct {
|
|
_type: EventType, // SDL_EVENT_JOYSTICK_BATTERY_UPDATED
|
|
reserved: u32,
|
|
timestamp: u64, // In nanoseconds, populated using SDL_GetTicksNS()
|
|
which: JoystickID, // The joystick instance id
|
|
state: PowerState, // The joystick battery state
|
|
percent: c_int, // The joystick battery percent charge remaining
|
|
};
|
|
|
|
pub const GamepadAxisEvent = extern struct {
|
|
_type: EventType, // SDL_EVENT_GAMEPAD_AXIS_MOTION
|
|
reserved: u32,
|
|
timestamp: u64, // In nanoseconds, populated using SDL_GetTicksNS()
|
|
which: JoystickID, // The joystick instance id
|
|
axis: u8, // The gamepad axis (SDL_GamepadAxis)
|
|
padding1: u8,
|
|
padding2: u8,
|
|
padding3: u8,
|
|
value: i16, // The axis value (range: -32768 to 32767)
|
|
padding4: u16,
|
|
};
|
|
|
|
pub const GamepadButtonEvent = extern struct {
|
|
_type: EventType, // SDL_EVENT_GAMEPAD_BUTTON_DOWN or SDL_EVENT_GAMEPAD_BUTTON_UP
|
|
reserved: u32,
|
|
timestamp: u64, // In nanoseconds, populated using SDL_GetTicksNS()
|
|
which: JoystickID, // The joystick instance id
|
|
button: u8, // The gamepad button (SDL_GamepadButton)
|
|
down: bool, // true if the button is pressed
|
|
padding1: u8,
|
|
padding2: u8,
|
|
};
|
|
|
|
pub const GamepadDeviceEvent = extern struct {
|
|
_type: EventType, // SDL_EVENT_GAMEPAD_ADDED, SDL_EVENT_GAMEPAD_REMOVED, or SDL_EVENT_GAMEPAD_REMAPPED, SDL_EVENT_GAMEPAD_UPDATE_COMPLETE or SDL_EVENT_GAMEPAD_STEAM_HANDLE_UPDATED
|
|
reserved: u32,
|
|
timestamp: u64, // In nanoseconds, populated using SDL_GetTicksNS()
|
|
which: JoystickID, // The joystick instance id
|
|
};
|
|
|
|
pub const GamepadTouchpadEvent = extern struct {
|
|
_type: EventType, // SDL_EVENT_GAMEPAD_TOUCHPAD_DOWN or SDL_EVENT_GAMEPAD_TOUCHPAD_MOTION or SDL_EVENT_GAMEPAD_TOUCHPAD_UP
|
|
reserved: u32,
|
|
timestamp: u64, // In nanoseconds, populated using SDL_GetTicksNS()
|
|
which: JoystickID, // The joystick instance id
|
|
touchpad: i32, // The index of the touchpad
|
|
finger: i32, // The index of the finger on the touchpad
|
|
x: f32, // Normalized in the range 0...1 with 0 being on the left
|
|
y: f32, // Normalized in the range 0...1 with 0 being at the top
|
|
pressure: f32, // Normalized in the range 0...1
|
|
};
|
|
|
|
pub const GamepadSensorEvent = extern struct {
|
|
_type: EventType, // SDL_EVENT_GAMEPAD_SENSOR_UPDATE
|
|
reserved: u32,
|
|
timestamp: u64, // In nanoseconds, populated using SDL_GetTicksNS()
|
|
which: JoystickID, // The joystick instance id
|
|
sensor: i32, // The type of the sensor, one of the values of SDL_SensorType
|
|
data: [3]f32, // Up to 3 values from the sensor, as defined in SDL_sensor.h
|
|
sensor_timestamp: u64, // The timestamp of the sensor reading in nanoseconds, not necessarily synchronized with the system clock
|
|
};
|
|
|
|
pub const AudioDeviceEvent = extern struct {
|
|
_type: EventType, // SDL_EVENT_AUDIO_DEVICE_ADDED, or SDL_EVENT_AUDIO_DEVICE_REMOVED, or SDL_EVENT_AUDIO_DEVICE_FORMAT_CHANGED
|
|
reserved: u32,
|
|
timestamp: u64, // In nanoseconds, populated using SDL_GetTicksNS()
|
|
which: AudioDeviceID, // SDL_AudioDeviceID for the device being added or removed or changing
|
|
recording: bool, // false if a playback device, true if a recording device.
|
|
padding1: u8,
|
|
padding2: u8,
|
|
padding3: u8,
|
|
};
|
|
|
|
pub const CameraDeviceEvent = extern struct {
|
|
_type: EventType, // SDL_EVENT_CAMERA_DEVICE_ADDED, SDL_EVENT_CAMERA_DEVICE_REMOVED, SDL_EVENT_CAMERA_DEVICE_APPROVED, SDL_EVENT_CAMERA_DEVICE_DENIED
|
|
reserved: u32,
|
|
timestamp: u64, // In nanoseconds, populated using SDL_GetTicksNS()
|
|
which: CameraID, // SDL_CameraID for the device being added or removed or changing
|
|
};
|
|
|
|
pub const RenderEvent = extern struct {
|
|
_type: EventType, // SDL_EVENT_RENDER_TARGETS_RESET, SDL_EVENT_RENDER_DEVICE_RESET, SDL_EVENT_RENDER_DEVICE_LOST
|
|
reserved: u32,
|
|
timestamp: u64, // In nanoseconds, populated using SDL_GetTicksNS()
|
|
windowID: WindowID, // The window containing the renderer in question.
|
|
};
|
|
|
|
pub const TouchFingerEvent = extern struct {
|
|
_type: EventType, // SDL_EVENT_FINGER_DOWN, SDL_EVENT_FINGER_UP, SDL_EVENT_FINGER_MOTION, or SDL_EVENT_FINGER_CANCELED
|
|
reserved: u32,
|
|
timestamp: u64, // In nanoseconds, populated using SDL_GetTicksNS()
|
|
touchID: TouchID, // The touch device id
|
|
fingerID: FingerID,
|
|
x: f32, // Normalized in the range 0...1
|
|
y: f32, // Normalized in the range 0...1
|
|
dx: f32, // Normalized in the range -1...1
|
|
dy: f32, // Normalized in the range -1...1
|
|
pressure: f32, // Normalized in the range 0...1
|
|
windowID: WindowID, // The window underneath the finger, if any
|
|
};
|
|
|
|
pub const PenProximityEvent = extern struct {
|
|
_type: EventType, // SDL_EVENT_PEN_PROXIMITY_IN or SDL_EVENT_PEN_PROXIMITY_OUT
|
|
reserved: u32,
|
|
timestamp: u64, // In nanoseconds, populated using SDL_GetTicksNS()
|
|
windowID: WindowID, // The window with pen focus, if any
|
|
which: PenID, // The pen instance id
|
|
};
|
|
|
|
pub const PenMotionEvent = extern struct {
|
|
_type: EventType, // SDL_EVENT_PEN_MOTION
|
|
reserved: u32,
|
|
timestamp: u64, // In nanoseconds, populated using SDL_GetTicksNS()
|
|
windowID: WindowID, // The window with pen focus, if any
|
|
which: PenID, // The pen instance id
|
|
pen_state: PenInputFlags, // Complete pen input state at time of event
|
|
x: f32, // X coordinate, relative to window
|
|
y: f32, // Y coordinate, relative to window
|
|
};
|
|
|
|
pub const PenTouchEvent = extern struct {
|
|
_type: EventType, // SDL_EVENT_PEN_DOWN or SDL_EVENT_PEN_UP
|
|
reserved: u32,
|
|
timestamp: u64, // In nanoseconds, populated using SDL_GetTicksNS()
|
|
windowID: WindowID, // The window with pen focus, if any
|
|
which: PenID, // The pen instance id
|
|
pen_state: PenInputFlags, // Complete pen input state at time of event
|
|
x: f32, // X coordinate, relative to window
|
|
y: f32, // Y coordinate, relative to window
|
|
eraser: bool, // true if eraser end is used (not all pens support this).
|
|
down: bool, // true if the pen is touching or false if the pen is lifted off
|
|
};
|
|
|
|
pub const PenButtonEvent = extern struct {
|
|
_type: EventType, // SDL_EVENT_PEN_BUTTON_DOWN or SDL_EVENT_PEN_BUTTON_UP
|
|
reserved: u32,
|
|
timestamp: u64, // In nanoseconds, populated using SDL_GetTicksNS()
|
|
windowID: WindowID, // The window with mouse focus, if any
|
|
which: PenID, // The pen instance id
|
|
pen_state: PenInputFlags, // Complete pen input state at time of event
|
|
x: f32, // X coordinate, relative to window
|
|
y: f32, // Y coordinate, relative to window
|
|
button: u8, // The pen button index (first button is 1).
|
|
down: bool, // true if the button is pressed
|
|
};
|
|
|
|
pub const PenAxisEvent = extern struct {
|
|
_type: EventType, // SDL_EVENT_PEN_AXIS
|
|
reserved: u32,
|
|
timestamp: u64, // In nanoseconds, populated using SDL_GetTicksNS()
|
|
windowID: WindowID, // The window with pen focus, if any
|
|
which: PenID, // The pen instance id
|
|
pen_state: PenInputFlags, // Complete pen input state at time of event
|
|
x: f32, // X coordinate, relative to window
|
|
y: f32, // Y coordinate, relative to window
|
|
axis: PenAxis, // Axis that has changed
|
|
value: f32, // New value of axis
|
|
};
|
|
|
|
pub const DropEvent = extern struct {
|
|
_type: EventType, // SDL_EVENT_DROP_BEGIN or SDL_EVENT_DROP_FILE or SDL_EVENT_DROP_TEXT or SDL_EVENT_DROP_COMPLETE or SDL_EVENT_DROP_POSITION
|
|
reserved: u32,
|
|
timestamp: u64, // In nanoseconds, populated using SDL_GetTicksNS()
|
|
windowID: WindowID, // The window that was dropped on, if any
|
|
x: f32, // X coordinate, relative to window (not on begin)
|
|
y: f32, // Y coordinate, relative to window (not on begin)
|
|
source: [*c]const u8, // The source app that sent this drop event, or NULL if that isn't available
|
|
data: [*c]const u8, // The text for SDL_EVENT_DROP_TEXT and the file name for SDL_EVENT_DROP_FILE, NULL for other events
|
|
};
|
|
|
|
pub const ClipboardEvent = extern struct {
|
|
_type: EventType, // SDL_EVENT_CLIPBOARD_UPDATE
|
|
reserved: u32,
|
|
timestamp: u64, // In nanoseconds, populated using SDL_GetTicksNS()
|
|
owner: bool, // are we owning the clipboard (internal update)
|
|
num_mime_types: i32, // number of mime types
|
|
mime_types: [*c][*c]const u8, // current mime types
|
|
};
|
|
|
|
pub const SensorEvent = extern struct {
|
|
_type: EventType, // SDL_EVENT_SENSOR_UPDATE
|
|
reserved: u32,
|
|
timestamp: u64, // In nanoseconds, populated using SDL_GetTicksNS()
|
|
which: SensorID, // The instance ID of the sensor
|
|
data: [6]f32, // Up to 6 values from the sensor - additional values can be queried using SDL_GetSensorData()
|
|
sensor_timestamp: u64, // The timestamp of the sensor reading in nanoseconds, not necessarily synchronized with the system clock
|
|
};
|
|
|
|
pub const QuitEvent = extern struct {
|
|
_type: EventType, // SDL_EVENT_QUIT
|
|
reserved: u32,
|
|
timestamp: u64, // In nanoseconds, populated using SDL_GetTicksNS()
|
|
};
|
|
|
|
pub const UserEvent = extern struct {
|
|
_type: u32, // SDL_EVENT_USER through SDL_EVENT_LAST-1, Uint32 because these are not in the SDL_EventType enumeration
|
|
reserved: u32,
|
|
timestamp: u64, // In nanoseconds, populated using SDL_GetTicksNS()
|
|
windowID: WindowID, // The associated window if any
|
|
code: i32, // User defined event code
|
|
data1: ?*anyopaque, // User defined data pointer
|
|
data2: ?*anyopaque, // User defined data pointer
|
|
};
|
|
|
|
pub const Event = extern union {
|
|
_type: u32, // Event type, shared with all events, Uint32 to cover user events which are not in the SDL_EventType enumeration
|
|
common: CommonEvent, // Common event data
|
|
display: DisplayEvent, // Display event data
|
|
window: WindowEvent, // Window event data
|
|
kdevice: KeyboardDeviceEvent, // Keyboard device change event data
|
|
key: KeyboardEvent, // Keyboard event data
|
|
edit: TextEditingEvent, // Text editing event data
|
|
edit_candidates: TextEditingCandidatesEvent, // Text editing candidates event data
|
|
text: TextInputEvent, // Text input event data
|
|
mdevice: MouseDeviceEvent, // Mouse device change event data
|
|
motion: MouseMotionEvent, // Mouse motion event data
|
|
button: MouseButtonEvent, // Mouse button event data
|
|
wheel: MouseWheelEvent, // Mouse wheel event data
|
|
jdevice: JoyDeviceEvent, // Joystick device change event data
|
|
jaxis: JoyAxisEvent, // Joystick axis event data
|
|
jball: JoyBallEvent, // Joystick ball event data
|
|
jhat: JoyHatEvent, // Joystick hat event data
|
|
jbutton: JoyButtonEvent, // Joystick button event data
|
|
jbattery: JoyBatteryEvent, // Joystick battery event data
|
|
gdevice: GamepadDeviceEvent, // Gamepad device event data
|
|
gaxis: GamepadAxisEvent, // Gamepad axis event data
|
|
gbutton: GamepadButtonEvent, // Gamepad button event data
|
|
gtouchpad: GamepadTouchpadEvent, // Gamepad touchpad event data
|
|
gsensor: GamepadSensorEvent, // Gamepad sensor event data
|
|
adevice: AudioDeviceEvent, // Audio device event data
|
|
cdevice: CameraDeviceEvent, // Camera device event data
|
|
sensor: SensorEvent, // Sensor event data
|
|
quit: QuitEvent, // Quit request event data
|
|
user: UserEvent, // Custom event data
|
|
tfinger: TouchFingerEvent, // Touch finger event data
|
|
pproximity: PenProximityEvent, // Pen proximity event data
|
|
ptouch: PenTouchEvent, // Pen tip touching event data
|
|
pmotion: PenMotionEvent, // Pen motion event data
|
|
pbutton: PenButtonEvent, // Pen button event data
|
|
paxis: PenAxisEvent, // Pen axis event data
|
|
render: RenderEvent, // Render event data
|
|
drop: DropEvent, // Drag and drop event data
|
|
clipboard: ClipboardEvent, // Clipboard event data
|
|
padding: [128]u8,
|
|
};
|
|
|
|
pub inline fn pumpEvents() void {
|
|
return c.SDL_PumpEvents();
|
|
}
|
|
|
|
pub const EventAction = enum(c_int) {
|
|
addevent, //Add events to the back of the queue.
|
|
peekevent, //Check but don't remove events from the queue front.
|
|
getevent, //Retrieve/remove events from the front of the queue.
|
|
};
|
|
|
|
pub inline fn peepEvents(events: ?*Event, numevents: c_int, action: EventAction, minType: u32, maxType: u32) c_int {
|
|
return c.SDL_PeepEvents(@ptrCast(events), numevents, action, minType, maxType);
|
|
}
|
|
|
|
pub inline fn hasEvent(_type: u32) bool {
|
|
return @bitCast(c.SDL_HasEvent(_type));
|
|
}
|
|
|
|
pub inline fn hasEvents(minType: u32, maxType: u32) bool {
|
|
return @bitCast(c.SDL_HasEvents(minType, maxType));
|
|
}
|
|
|
|
pub inline fn flushEvent(_type: u32) void {
|
|
return c.SDL_FlushEvent(_type);
|
|
}
|
|
|
|
pub inline fn flushEvents(minType: u32, maxType: u32) void {
|
|
return c.SDL_FlushEvents(minType, maxType);
|
|
}
|
|
|
|
pub inline fn pollEvent(event: ?*Event) bool {
|
|
return @bitCast(c.SDL_PollEvent(@ptrCast(event)));
|
|
}
|
|
|
|
pub inline fn waitEvent(event: ?*Event) bool {
|
|
return @bitCast(c.SDL_WaitEvent(@ptrCast(event)));
|
|
}
|
|
|
|
pub inline fn waitEventTimeout(event: ?*Event, timeoutMS: i32) bool {
|
|
return @bitCast(c.SDL_WaitEventTimeout(@ptrCast(event), timeoutMS));
|
|
}
|
|
|
|
pub inline fn pushEvent(event: ?*Event) bool {
|
|
return @bitCast(c.SDL_PushEvent(@ptrCast(event)));
|
|
}
|
|
|
|
pub const EventFilter = c.SDL_EventFilter;
|
|
|
|
pub inline fn setEventFilter(filter: EventFilter, userdata: ?*anyopaque) void {
|
|
return c.SDL_SetEventFilter(filter, userdata);
|
|
}
|
|
|
|
pub inline fn getEventFilter(filter: ?*EventFilter, userdata: [*c]?*anyopaque) bool {
|
|
return @bitCast(c.SDL_GetEventFilter(@ptrCast(filter), userdata));
|
|
}
|
|
|
|
pub inline fn addEventWatch(filter: EventFilter, userdata: ?*anyopaque) bool {
|
|
return @bitCast(c.SDL_AddEventWatch(filter, userdata));
|
|
}
|
|
|
|
pub inline fn removeEventWatch(filter: EventFilter, userdata: ?*anyopaque) void {
|
|
return c.SDL_RemoveEventWatch(filter, userdata);
|
|
}
|
|
|
|
pub inline fn filterEvents(filter: EventFilter, userdata: ?*anyopaque) void {
|
|
return c.SDL_FilterEvents(filter, userdata);
|
|
}
|
|
|
|
pub inline fn setEventEnabled(_type: u32, enabled: bool) void {
|
|
return c.SDL_SetEventEnabled(_type, @bitCast(enabled));
|
|
}
|
|
|
|
pub inline fn eventEnabled(_type: u32) bool {
|
|
return @bitCast(c.SDL_EventEnabled(_type));
|
|
}
|
|
|
|
pub inline fn registerEvents(numevents: c_int) u32 {
|
|
return c.SDL_RegisterEvents(numevents);
|
|
}
|
|
|
|
pub inline fn getWindowFromEvent(event: ?*const Event) ?*Window {
|
|
return @ptrCast(c.SDL_GetWindowFromEvent(@ptrCast(event)));
|
|
}
|