pub use crate::{
c_long, error::*, gamecontroller::*, gesture::*, joystick::*, keyboard::*,
mouse::*, stdinc::*, syswm::*, touch::*, version::*, video::*,
};
pub const SDL_RELEASED: u8 = 0;
pub const SDL_PRESSED: u8 = 1;
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[repr(transparent)]
pub struct SDL_EventType(pub i32);
pub const SDL_FIRSTEVENT: SDL_EventType = SDL_EventType(0);
pub const SDL_QUIT: SDL_EventType = SDL_EventType(0x100);
pub const SDL_APP_TERMINATING: SDL_EventType = SDL_EventType(0x100 + 1);
pub const SDL_APP_LOWMEMORY: SDL_EventType = SDL_EventType(0x100 + 2);
pub const SDL_APP_WILLENTERBACKGROUND: SDL_EventType = SDL_EventType(0x100 + 3);
pub const SDL_APP_DIDENTERBACKGROUND: SDL_EventType = SDL_EventType(0x100 + 4);
pub const SDL_APP_WILLENTERFOREGROUND: SDL_EventType = SDL_EventType(0x100 + 5);
pub const SDL_APP_DIDENTERFOREGROUND: SDL_EventType = SDL_EventType(0x100 + 6);
pub const SDL_DISPLAYEVENT: SDL_EventType = SDL_EventType(0x150);
pub const SDL_WINDOWEVENT: SDL_EventType = SDL_EventType(0x200);
pub const SDL_SYSWMEVENT: SDL_EventType = SDL_EventType(0x200 + 1);
pub const SDL_KEYDOWN: SDL_EventType = SDL_EventType(0x300);
pub const SDL_KEYUP: SDL_EventType = SDL_EventType(0x300 + 1);
pub const SDL_TEXTEDITING: SDL_EventType = SDL_EventType(0x300 + 2);
pub const SDL_TEXTINPUT: SDL_EventType = SDL_EventType(0x300 + 3);
pub const SDL_KEYMAPCHANGED: SDL_EventType = SDL_EventType(0x300 + 4);
pub const SDL_MOUSEMOTION: SDL_EventType = SDL_EventType(0x400);
pub const SDL_MOUSEBUTTONDOWN: SDL_EventType = SDL_EventType(0x400 + 1);
pub const SDL_MOUSEBUTTONUP: SDL_EventType = SDL_EventType(0x400 + 2);
pub const SDL_MOUSEWHEEL: SDL_EventType = SDL_EventType(0x400 + 3);
pub const SDL_JOYAXISMOTION: SDL_EventType = SDL_EventType(0x600);
pub const SDL_JOYBALLMOTION: SDL_EventType = SDL_EventType(0x600 + 1);
pub const SDL_JOYHATMOTION: SDL_EventType = SDL_EventType(0x600 + 2);
pub const SDL_JOYBUTTONDOWN: SDL_EventType = SDL_EventType(0x600 + 3);
pub const SDL_JOYBUTTONUP: SDL_EventType = SDL_EventType(0x600 + 4);
pub const SDL_JOYDEVICEADDED: SDL_EventType = SDL_EventType(0x600 + 5);
pub const SDL_JOYDEVICEREMOVED: SDL_EventType = SDL_EventType(0x600 + 6);
pub const SDL_CONTROLLERAXISMOTION: SDL_EventType = SDL_EventType(0x650);
pub const SDL_CONTROLLERBUTTONDOWN: SDL_EventType = SDL_EventType(0x650 + 1);
pub const SDL_CONTROLLERBUTTONUP: SDL_EventType = SDL_EventType(0x650 + 2);
pub const SDL_CONTROLLERDEVICEADDED: SDL_EventType = SDL_EventType(0x650 + 3);
pub const SDL_CONTROLLERDEVICEREMOVED: SDL_EventType = SDL_EventType(0x650 + 4);
pub const SDL_CONTROLLERDEVICEREMAPPED: SDL_EventType =
SDL_EventType(0x650 + 5);
#[allow(missing_docs)]
pub const SDL_FINGERDOWN: SDL_EventType = SDL_EventType(0x700);
#[allow(missing_docs)]
pub const SDL_FINGERUP: SDL_EventType = SDL_EventType(0x700 + 1);
#[allow(missing_docs)]
pub const SDL_FINGERMOTION: SDL_EventType = SDL_EventType(0x700 + 2);
#[allow(missing_docs)]
pub const SDL_DOLLARGESTURE: SDL_EventType = SDL_EventType(0x800);
#[allow(missing_docs)]
pub const SDL_DOLLARRECORD: SDL_EventType = SDL_EventType(0x800 + 1);
#[allow(missing_docs)]
pub const SDL_MULTIGESTURE: SDL_EventType = SDL_EventType(0x800 + 2);
pub const SDL_CLIPBOARDUPDATE: SDL_EventType = SDL_EventType(0x900);
pub const SDL_DROPFILE: SDL_EventType = SDL_EventType(0x1000);
pub const SDL_DROPTEXT: SDL_EventType = SDL_EventType(0x1000 + 1);
pub const SDL_DROPBEGIN: SDL_EventType = SDL_EventType(0x1000 + 2);
pub const SDL_DROPCOMPLETE: SDL_EventType = SDL_EventType(0x1000 + 3);
pub const SDL_AUDIODEVICEADDED: SDL_EventType = SDL_EventType(0x1100);
pub const SDL_AUDIODEVICEREMOVED: SDL_EventType = SDL_EventType(0x1100 + 1);
pub const SDL_SENSORUPDATE: SDL_EventType = SDL_EventType(0x1200);
pub const SDL_RENDER_TARGETS_RESET: SDL_EventType = SDL_EventType(0x2000);
pub const SDL_RENDER_DEVICE_RESET: SDL_EventType = SDL_EventType(0x2000 + 1);
pub const SDL_USEREVENT: SDL_EventType = SDL_EventType(0x8000);
pub const SDL_LASTEVENT: SDL_EventType = SDL_EventType(0xFFFF);
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[repr(C)]
#[allow(missing_docs)]
pub struct SDL_CommonEvent {
pub type_: SDL_EventType,
pub timestamp: Uint32,
}
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[repr(C)]
#[allow(missing_docs)]
pub struct SDL_DisplayEvent {
pub type_: SDL_EventType,
pub timestamp: Uint32,
pub display: Uint32,
pub event: SDL_DisplayEventID,
pub padding1: Uint8,
pub padding2: Uint8,
pub padding3: Uint8,
pub data1: Sint32,
}
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[repr(C)]
#[allow(missing_docs)]
pub struct SDL_WindowEvent {
pub type_: SDL_EventType,
pub timestamp: Uint32,
pub windowID: Uint32,
pub event: SDL_WindowEventID,
pub padding1: Uint8,
pub padding2: Uint8,
pub padding3: Uint8,
pub data1: Sint32,
pub data2: Sint32,
}
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[repr(C)]
#[allow(missing_docs)]
pub struct SDL_KeyboardEvent {
pub type_: SDL_EventType,
pub timestamp: Uint32,
pub windowID: Uint32,
pub state: Uint8,
pub repeat: Uint8,
pub padding2: Uint8,
pub padding3: Uint8,
pub keysym: SDL_Keysym,
}
pub const SDL_TEXTEDITINGEVENT_TEXT_SIZE: usize = 32;
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[repr(C)]
#[allow(missing_docs)]
pub struct SDL_TextEditingEvent {
pub type_: SDL_EventType,
pub timestamp: Uint32,
pub windowID: Uint32,
pub text: [c_char; SDL_TEXTEDITINGEVENT_TEXT_SIZE],
pub start: Sint32,
pub length: Sint32,
}
pub const SDL_TEXTINPUTEVENT_TEXT_SIZE: usize = 32;
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[repr(C)]
#[allow(missing_docs)]
pub struct SDL_TextInputEvent {
pub type_: SDL_EventType,
pub timestamp: Uint32,
pub windowID: Uint32,
pub text: [c_char; SDL_TEXTINPUTEVENT_TEXT_SIZE],
}
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[repr(C)]
#[allow(missing_docs)]
pub struct SDL_MouseMotionEvent {
pub type_: SDL_EventType,
pub timestamp: Uint32,
pub windowID: Uint32,
pub which: Uint32,
pub state: Uint32,
pub x: Sint32,
pub y: Sint32,
pub xrel: Sint32,
pub yrel: Sint32,
}
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[repr(C)]
#[allow(missing_docs)]
pub struct SDL_MouseButtonEvent {
pub type_: SDL_EventType,
pub timestamp: Uint32,
pub windowID: Uint32,
pub which: Uint32,
pub button: Uint8,
pub state: Uint8,
pub clicks: Uint8,
pub padding1: Uint8,
pub x: Sint32,
pub y: Sint32,
}
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[repr(C)]
#[allow(missing_docs)]
pub struct SDL_MouseWheelEvent {
pub type_: SDL_EventType,
pub timestamp: Uint32,
pub windowID: Uint32,
pub which: Uint32,
pub x: Sint32,
pub y: Sint32,
pub direction: SDL_MouseWheelDirection,
}
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[repr(C)]
#[allow(missing_docs)]
pub struct SDL_JoyAxisEvent {
pub type_: SDL_EventType,
pub timestamp: Uint32,
pub which: SDL_JoystickID,
pub axis: Uint8,
pub padding1: Uint8,
pub padding2: Uint8,
pub padding3: Uint8,
pub value: Sint16,
pub padding4: Uint16,
}
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[repr(C)]
#[allow(missing_docs)]
pub struct SDL_JoyBallEvent {
pub type_: SDL_EventType,
pub timestamp: Uint32,
pub which: SDL_JoystickID,
pub ball: Uint8,
pub padding1: Uint8,
pub padding2: Uint8,
pub padding3: Uint8,
pub xrel: Sint16,
pub yrel: Sint16,
}
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[repr(C)]
#[allow(missing_docs)]
pub struct SDL_JoyHatEvent {
pub type_: SDL_EventType,
pub timestamp: Uint32,
pub which: SDL_JoystickID,
pub hat: Uint8,
pub value: Uint8,
pub padding1: Uint8,
pub padding2: Uint8,
}
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[repr(C)]
#[allow(missing_docs)]
pub struct SDL_JoyButtonEvent {
pub type_: SDL_EventType,
pub timestamp: Uint32,
pub which: SDL_JoystickID,
pub button: Uint8,
pub state: Uint8,
pub padding1: Uint8,
pub padding2: Uint8,
}
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[repr(C)]
#[allow(missing_docs)]
pub struct SDL_JoyDeviceEvent {
pub type_: SDL_EventType,
pub timestamp: Uint32,
pub which: Sint32,
}
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[repr(C)]
#[allow(missing_docs)]
pub struct SDL_ControllerAxisEvent {
pub type_: SDL_EventType,
pub timestamp: Uint32,
pub which: SDL_JoystickID,
pub axis: Uint8,
pub padding1: Uint8,
pub padding2: Uint8,
pub padding3: Uint8,
pub value: Sint16,
pub padding4: Uint16,
}
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[repr(C)]
#[allow(missing_docs)]
pub struct SDL_ControllerButtonEvent {
pub type_: SDL_EventType,
pub timestamp: Uint32,
pub which: SDL_JoystickID,
pub button: Uint8,
pub state: Uint8,
pub padding1: Uint8,
pub padding2: Uint8,
}
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[repr(C)]
#[allow(missing_docs)]
pub struct SDL_ControllerDeviceEvent {
pub type_: SDL_EventType,
pub timestamp: Uint32,
pub which: Sint32,
}
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[repr(C)]
#[allow(missing_docs)]
pub struct SDL_AudioDeviceEvent {
pub type_: SDL_EventType,
pub timestamp: Uint32,
pub which: Uint32,
pub iscapture: Uint8,
pub padding1: Uint8,
pub padding2: Uint8,
pub padding3: Uint8,
}
#[derive(Debug, Clone, Copy, Default, PartialEq, PartialOrd)]
#[repr(C)]
#[allow(missing_docs)]
pub struct SDL_TouchFingerEvent {
pub type_: SDL_EventType,
pub timestamp: Uint32,
pub touchId: SDL_TouchID,
pub fingerId: SDL_FingerID,
pub x: c_float,
pub y: c_float,
pub dx: c_float,
pub dy: c_float,
pub pressure: c_float,
pub windowID: Uint32,
}
#[derive(Debug, Clone, Copy, Default, PartialEq, PartialOrd)]
#[repr(C)]
#[allow(missing_docs)]
pub struct SDL_MultiGestureEvent {
pub type_: SDL_EventType,
pub timestamp: Uint32,
pub touchId: SDL_TouchID,
pub dTheta: c_float,
pub dDist: c_float,
pub x: c_float,
pub y: c_float,
pub numFingers: Uint16,
pub padding: Uint16,
}
#[derive(Debug, Clone, Copy, Default, PartialEq, PartialOrd)]
#[repr(C)]
#[allow(missing_docs)]
pub struct SDL_DollarGestureEvent {
pub type_: SDL_EventType,
pub timestamp: Uint32,
pub touchId: SDL_TouchID,
pub gestureId: SDL_GestureID,
pub numFingers: Uint32,
pub error: c_float,
pub x: c_float,
pub y: c_float,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[repr(C)]
#[allow(missing_docs)]
pub struct SDL_DropEvent {
pub type_: SDL_EventType,
pub timestamp: Uint32,
pub file: *const c_char,
pub windowID: Uint32,
}
impl Default for SDL_DropEvent {
fn default() -> Self {
unsafe { core::mem::zeroed() }
}
}
#[derive(Debug, Clone, Copy, Default, PartialEq, PartialOrd)]
#[repr(C)]
#[allow(missing_docs)]
pub struct SDL_SensorEvent {
pub type_: SDL_EventType,
pub timestamp: Uint32,
pub which: Sint32,
pub data: [c_float; 6],
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[repr(C)]
#[allow(missing_docs)]
pub struct SDL_QuitEvent {
pub type_: SDL_EventType,
pub timestamp: Uint32,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[repr(C)]
#[allow(missing_docs)]
pub struct SDL_OSEvent {
pub type_: SDL_EventType,
pub timestamp: Uint32,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[repr(C)]
#[allow(missing_docs)]
pub struct SDL_UserEvent {
pub type_: SDL_EventType,
pub timestamp: Uint32,
pub windowID: Uint32,
pub code: Sint32,
pub data1: *mut c_void,
pub data2: *mut c_void,
}
impl Default for SDL_UserEvent {
fn default() -> Self {
unsafe { core::mem::zeroed() }
}
}
#[derive(Clone, Copy)]
#[repr(C)]
#[allow(missing_docs)]
pub struct SDL_SysWMmsg_windows {
pub hwnd: *mut c_void,
pub msg: c_uint,
pub wParam: usize,
pub lParam: isize,
}
#[derive(Clone, Copy)]
#[repr(C)]
#[allow(missing_docs)]
pub union SDL_SysWMmsg_union {
pub win: SDL_SysWMmsg_windows,
pub x11_event: [c_long; 24],
pub dfb: c_uint,
}
#[derive(Clone, Copy)]
#[repr(C)]
#[allow(missing_docs)]
pub struct SDL_SysWMmsg {
pub version: SDL_version,
pub subsystem: SDL_SYSWM_TYPE,
pub msg: SDL_SysWMmsg_union,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[repr(C)]
#[allow(missing_docs)]
pub struct SDL_SysWMEvent {
pub type_: SDL_EventType,
pub timestamp: Uint32,
pub msg: *mut SDL_SysWMmsg,
}
impl Default for SDL_SysWMEvent {
fn default() -> Self {
unsafe { core::mem::zeroed() }
}
}
#[derive(Clone, Copy)]
#[repr(C)]
#[allow(missing_docs)]
pub union SDL_Event {
pub type_: SDL_EventType,
pub common: SDL_CommonEvent,
pub display: SDL_DisplayEvent,
pub window: SDL_WindowEvent,
pub key: SDL_KeyboardEvent,
pub edit: SDL_TextEditingEvent,
pub text: SDL_TextInputEvent,
pub motion: SDL_MouseMotionEvent,
pub button: SDL_MouseButtonEvent,
pub wheel: SDL_MouseWheelEvent,
pub jaxis: SDL_JoyAxisEvent,
pub jball: SDL_JoyBallEvent,
pub jhat: SDL_JoyHatEvent,
pub jbutton: SDL_JoyButtonEvent,
pub jdevice: SDL_JoyDeviceEvent,
pub caxis: SDL_ControllerAxisEvent,
pub cbutton: SDL_ControllerButtonEvent,
pub cdevice: SDL_ControllerDeviceEvent,
pub adevice: SDL_AudioDeviceEvent,
pub sensor: SDL_SensorEvent,
pub quit: SDL_QuitEvent,
pub user: SDL_UserEvent,
pub syswm: SDL_SysWMEvent,
pub tfinger: SDL_TouchFingerEvent,
pub mgesture: SDL_MultiGestureEvent,
pub dgesture: SDL_DollarGestureEvent,
pub drop: SDL_DropEvent,
pub padding: [Uint8; 56],
pub force_align: [u64; 7],
}
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[repr(transparent)]
pub struct SDL_eventaction(pub i32);
#[allow(missing_docs)]
pub const SDL_ADDEVENT: SDL_eventaction = SDL_eventaction(0);
#[allow(missing_docs)]
pub const SDL_PEEKEVENT: SDL_eventaction = SDL_eventaction(1);
#[allow(missing_docs)]
pub const SDL_GETEVENT: SDL_eventaction = SDL_eventaction(2);
pub type SDL_EventFilter = Option<
unsafe extern "C" fn(userdata: *mut c_void, event: *mut SDL_Event) -> c_int,
>;
extern "C" {
pub fn SDL_PumpEvents();
pub fn SDL_PeepEvents(
events: *mut SDL_Event, numevents: c_int, action: SDL_eventaction,
minType: SDL_EventType, maxType: SDL_EventType,
) -> c_int;
pub fn SDL_HasEvent(type_: SDL_EventType) -> SDL_bool;
pub fn SDL_HasEvents(
minType: SDL_EventType, maxType: SDL_EventType,
) -> SDL_bool;
pub fn SDL_FlushEvent(type_: SDL_EventType);
pub fn SDL_FlushEvents(minType: SDL_EventType, maxType: SDL_EventType);
pub fn SDL_PollEvent(event: *mut SDL_Event) -> c_int;
pub fn SDL_WaitEvent(event: *mut SDL_Event) -> c_int;
pub fn SDL_WaitEventTimeout(event: *mut SDL_Event, timeout: c_int) -> c_int;
pub fn SDL_PushEvent(event: *mut SDL_Event) -> c_int;
pub fn SDL_SetEventFilter(filter: SDL_EventFilter, userdata: *mut c_void);
pub fn SDL_GetEventFilter(
filter: *mut SDL_EventFilter, userdata: *mut *mut c_void,
) -> SDL_bool;
pub fn SDL_AddEventWatch(filter: SDL_EventFilter, userdata: *mut c_void);
pub fn SDL_DelEventWatch(filter: SDL_EventFilter, userdata: *mut c_void);
pub fn SDL_FilterEvents(filter: SDL_EventFilter, userdata: *mut c_void);
pub fn SDL_EventState(type_: SDL_EventType, state: c_int) -> Uint8;
pub fn SDL_RegisterEvents(numevents: c_int) -> Uint32;
}
pub const SDL_QUERY: i32 = -1;
pub const SDL_IGNORE: i32 = 0;
pub const SDL_DISABLE: i32 = 0;
pub const SDL_ENABLE: i32 = 1;
pub unsafe fn SDL_GetEventState(type_: SDL_EventType) -> Uint8 {
SDL_EventState(type_, SDL_QUERY)
}