sdlparser-scrap/api/events.zig

677 lines
30 KiB
Zig

const std = @import("std");
pub const c = @import("c.zig").c;
const pen_api = @import("pen.zig");
const video_api = @import("video.zig");
const audio_api = @import("audio.zig");
const camera_api = @import("camera.zig");
const mouse_api = @import("mouse.zig");
const scancode_api = @import("scancode.zig");
const touch_api = @import("touch.zig");
const keyboard_api = @import("keyboard.zig");
const power_api = @import("power.zig");
const keycode_api = @import("keycode.zig");
const sensor_api = @import("sensor.zig");
const joystick_api = @import("joystick.zig");
pub const PenID = pen_api.PenID;
pub const WindowID = video_api.WindowID;
pub const AudioDeviceID = audio_api.AudioDeviceID;
pub const DisplayID = video_api.DisplayID;
pub const CameraID = camera_api.CameraID;
pub const PenInputFlags = pen_api.PenInputFlags;
pub const MouseButtonFlags = mouse_api.MouseButtonFlags;
pub const Scancode = scancode_api.Scancode;
pub const TouchID = touch_api.TouchID;
pub const KeyboardID = keyboard_api.KeyboardID;
pub const PenAxis = pen_api.PenAxis;
pub const MouseID = mouse_api.MouseID;
pub const MouseWheelDirection = mouse_api.MouseWheelDirection;
pub const PowerState = power_api.PowerState;
pub const Window = video_api.Window;
pub const FingerID = touch_api.FingerID;
pub const Keycode = keycode_api.Keycode;
pub const SensorID = sensor_api.SensorID;
pub const JoystickID = joystick_api.JoystickID;
pub const Keymod = keycode_api.Keymod;
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
eventDisplayUsableBoundsChanged, //Display has changed usable bounds
eventWindowShown = 0x202, //Window has been shown
eventWindowHidden, //Window has been hidden
eventWindowExposed,
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
eventScreenKeyboardShown, //The on-screen keyboard has been shown
eventScreenKeyboardHidden, //The on-screen keyboard has been hidden
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,
eventPinchBegin = 0x710, //Pinch gesture started
eventPinchUpdate, //Pinch gesture updated
eventPinchEnd, //Pinch gesture ended
eventClipboardUpdate = 0x900, //The clipboard 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_EVENT_DISPLAY_*
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 PinchFingerEvent = extern struct {
_type: EventType, // ::SDL_EVENT_PINCH_BEGIN or ::SDL_EVENT_PINCH_UPDATE or ::SDL_EVENT_PINCH_END
reserved: u32,
timestamp: u64, // In nanoseconds, populated using SDL_GetTicksNS()
scale: f32, // The scale change since the last SDL_EVENT_PINCH_UPDATE. Scale < 1 is "zoom out". Scale > 1 is "zoom in".
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, 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
pinch: PinchFingerEvent, // Pinch 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)));
}
pub inline fn getEventDescription(event: ?*const Event, buf: [*c]u8, buflen: c_int) c_int {
return c.SDL_GetEventDescription(@ptrCast(event), buf, buflen);
}