From 903b9f3965d5c9391a799499c6943795298ce260 Mon Sep 17 00:00:00 2001 From: Naum Azeredo Date: Sat, 20 Apr 2024 14:43:59 -0700 Subject: [PATCH 1/7] Update SDL to 2.30.2 --- sdl2-sys/SDL | 2 +- sdl2-sys/sdl_bindings.rs | 1749 +++++++++++++++++++++++++++++++++----- src/sdl2/event.rs | 19 + 3 files changed, 1574 insertions(+), 196 deletions(-) diff --git a/sdl2-sys/SDL b/sdl2-sys/SDL index 07d0f51fa2..f461d91cd2 160000 --- a/sdl2-sys/SDL +++ b/sdl2-sys/SDL @@ -1 +1 @@ -Subproject commit 07d0f51fa292895443f563f0cbde4cb3802d87fa +Subproject commit f461d91cd265d7b9a44b4d472b1df0c0ad2855a0 diff --git a/sdl2-sys/sdl_bindings.rs b/sdl2-sys/sdl_bindings.rs index b2bc6ca8ea..0da632fba7 100644 --- a/sdl2-sys/sdl_bindings.rs +++ b/sdl2-sys/sdl_bindings.rs @@ -111,6 +111,7 @@ pub const SIG_ATOMIC_MAX: u32 = 2147483647; pub const SIZE_MAX: i32 = -1; pub const WINT_MIN: u32 = 0; pub const WINT_MAX: u32 = 4294967295; +pub const SDL_SIZE_MAX: i32 = -1; pub const SDL_PRIs64: &'static [u8; 3usize] = b"ld\0"; pub const SDL_PRIu64: &'static [u8; 3usize] = b"lu\0"; pub const SDL_PRIx64: &'static [u8; 3usize] = b"lx\0"; @@ -139,6 +140,7 @@ pub const BYTE_ORDER: u32 = 1234; pub const _BITS_BYTESWAP_H: u32 = 1; pub const _BITS_UINTN_IDENTITY_H: u32 = 1; pub const SDL_BYTEORDER: u32 = 1234; +pub const SDL_FLOATWORDORDER: u32 = 1234; pub const SDL_MUTEX_TIMEDOUT: u32 = 1; pub const SDL_RWOPS_UNKNOWN: u32 = 0; pub const SDL_RWOPS_WINFILE: u32 = 1; @@ -286,6 +288,7 @@ pub const SDL_BUTTON_RIGHT: u32 = 3; pub const SDL_BUTTON_X1: u32 = 4; pub const SDL_BUTTON_X2: u32 = 5; pub const SDL_IPHONE_MAX_GFORCE: f64 = 5.0; +pub const SDL_VIRTUAL_JOYSTICK_DESC_VERSION: u32 = 1; pub const SDL_JOYSTICK_AXIS_MAX: u32 = 32767; pub const SDL_JOYSTICK_AXIS_MIN: i32 = -32768; pub const SDL_HAT_CENTERED: u32 = 0; @@ -360,9 +363,11 @@ pub const SDL_HINT_DISPLAY_USABLE_BOUNDS: &'static [u8; 26usize] = b"SDL_DISPLAY pub const SDL_HINT_EMSCRIPTEN_ASYNCIFY: &'static [u8; 24usize] = b"SDL_EMSCRIPTEN_ASYNCIFY\0"; pub const SDL_HINT_EMSCRIPTEN_KEYBOARD_ELEMENT: &'static [u8; 32usize] = b"SDL_EMSCRIPTEN_KEYBOARD_ELEMENT\0"; +pub const SDL_HINT_ENABLE_SCREEN_KEYBOARD: &'static [u8; 27usize] = b"SDL_ENABLE_SCREEN_KEYBOARD\0"; pub const SDL_HINT_ENABLE_STEAM_CONTROLLERS: &'static [u8; 29usize] = b"SDL_ENABLE_STEAM_CONTROLLERS\0"; pub const SDL_HINT_EVENT_LOGGING: &'static [u8; 18usize] = b"SDL_EVENT_LOGGING\0"; +pub const SDL_HINT_FORCE_RAISEWINDOW: &'static [u8; 27usize] = b"SDL_HINT_FORCE_RAISEWINDOW\0"; pub const SDL_HINT_FRAMEBUFFER_ACCELERATION: &'static [u8; 29usize] = b"SDL_FRAMEBUFFER_ACCELERATION\0"; pub const SDL_HINT_GAMECONTROLLERCONFIG: &'static [u8; 25usize] = b"SDL_GAMECONTROLLERCONFIG\0"; @@ -376,19 +381,48 @@ pub const SDL_HINT_GAMECONTROLLER_IGNORE_DEVICES_EXCEPT: &'static [u8; 41usize] pub const SDL_HINT_GAMECONTROLLER_USE_BUTTON_LABELS: &'static [u8; 37usize] = b"SDL_GAMECONTROLLER_USE_BUTTON_LABELS\0"; pub const SDL_HINT_GRAB_KEYBOARD: &'static [u8; 18usize] = b"SDL_GRAB_KEYBOARD\0"; +pub const SDL_HINT_HIDAPI_IGNORE_DEVICES: &'static [u8; 26usize] = b"SDL_HIDAPI_IGNORE_DEVICES\0"; pub const SDL_HINT_IDLE_TIMER_DISABLED: &'static [u8; 28usize] = b"SDL_IOS_IDLE_TIMER_DISABLED\0"; pub const SDL_HINT_IME_INTERNAL_EDITING: &'static [u8; 25usize] = b"SDL_IME_INTERNAL_EDITING\0"; pub const SDL_HINT_IME_SHOW_UI: &'static [u8; 16usize] = b"SDL_IME_SHOW_UI\0"; +pub const SDL_HINT_IME_SUPPORT_EXTENDED_TEXT: &'static [u8; 30usize] = + b"SDL_IME_SUPPORT_EXTENDED_TEXT\0"; pub const SDL_HINT_IOS_HIDE_HOME_INDICATOR: &'static [u8; 28usize] = b"SDL_IOS_HIDE_HOME_INDICATOR\0"; pub const SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS: &'static [u8; 37usize] = b"SDL_JOYSTICK_ALLOW_BACKGROUND_EVENTS\0"; +pub const SDL_HINT_JOYSTICK_ARCADESTICK_DEVICES: &'static [u8; 33usize] = + b"SDL_JOYSTICK_ARCADESTICK_DEVICES\0"; +pub const SDL_HINT_JOYSTICK_ARCADESTICK_DEVICES_EXCLUDED: &'static [u8; 42usize] = + b"SDL_JOYSTICK_ARCADESTICK_DEVICES_EXCLUDED\0"; +pub const SDL_HINT_JOYSTICK_BLACKLIST_DEVICES: &'static [u8; 31usize] = + b"SDL_JOYSTICK_BLACKLIST_DEVICES\0"; +pub const SDL_HINT_JOYSTICK_BLACKLIST_DEVICES_EXCLUDED: &'static [u8; 40usize] = + b"SDL_JOYSTICK_BLACKLIST_DEVICES_EXCLUDED\0"; +pub const SDL_HINT_JOYSTICK_FLIGHTSTICK_DEVICES: &'static [u8; 33usize] = + b"SDL_JOYSTICK_FLIGHTSTICK_DEVICES\0"; +pub const SDL_HINT_JOYSTICK_FLIGHTSTICK_DEVICES_EXCLUDED: &'static [u8; 42usize] = + b"SDL_JOYSTICK_FLIGHTSTICK_DEVICES_EXCLUDED\0"; +pub const SDL_HINT_JOYSTICK_GAMECUBE_DEVICES: &'static [u8; 30usize] = + b"SDL_JOYSTICK_GAMECUBE_DEVICES\0"; +pub const SDL_HINT_JOYSTICK_GAMECUBE_DEVICES_EXCLUDED: &'static [u8; 39usize] = + b"SDL_JOYSTICK_GAMECUBE_DEVICES_EXCLUDED\0"; pub const SDL_HINT_JOYSTICK_HIDAPI: &'static [u8; 20usize] = b"SDL_JOYSTICK_HIDAPI\0"; pub const SDL_HINT_JOYSTICK_HIDAPI_GAMECUBE: &'static [u8; 29usize] = b"SDL_JOYSTICK_HIDAPI_GAMECUBE\0"; +pub const SDL_HINT_JOYSTICK_GAMECUBE_RUMBLE_BRAKE: &'static [u8; 35usize] = + b"SDL_JOYSTICK_GAMECUBE_RUMBLE_BRAKE\0"; pub const SDL_HINT_JOYSTICK_HIDAPI_JOY_CONS: &'static [u8; 29usize] = b"SDL_JOYSTICK_HIDAPI_JOY_CONS\0"; +pub const SDL_HINT_JOYSTICK_HIDAPI_COMBINE_JOY_CONS: &'static [u8; 37usize] = + b"SDL_JOYSTICK_HIDAPI_COMBINE_JOY_CONS\0"; +pub const SDL_HINT_JOYSTICK_HIDAPI_VERTICAL_JOY_CONS: &'static [u8; 38usize] = + b"SDL_JOYSTICK_HIDAPI_VERTICAL_JOY_CONS\0"; pub const SDL_HINT_JOYSTICK_HIDAPI_LUNA: &'static [u8; 25usize] = b"SDL_JOYSTICK_HIDAPI_LUNA\0"; +pub const SDL_HINT_JOYSTICK_HIDAPI_NINTENDO_CLASSIC: &'static [u8; 37usize] = + b"SDL_JOYSTICK_HIDAPI_NINTENDO_CLASSIC\0"; +pub const SDL_HINT_JOYSTICK_HIDAPI_SHIELD: &'static [u8; 27usize] = b"SDL_JOYSTICK_HIDAPI_SHIELD\0"; +pub const SDL_HINT_JOYSTICK_HIDAPI_PS3: &'static [u8; 24usize] = b"SDL_JOYSTICK_HIDAPI_PS3\0"; pub const SDL_HINT_JOYSTICK_HIDAPI_PS4: &'static [u8; 24usize] = b"SDL_JOYSTICK_HIDAPI_PS4\0"; pub const SDL_HINT_JOYSTICK_HIDAPI_PS4_RUMBLE: &'static [u8; 31usize] = b"SDL_JOYSTICK_HIDAPI_PS4_RUMBLE\0"; @@ -399,23 +433,60 @@ pub const SDL_HINT_JOYSTICK_HIDAPI_PS5_RUMBLE: &'static [u8; 31usize] = b"SDL_JOYSTICK_HIDAPI_PS5_RUMBLE\0"; pub const SDL_HINT_JOYSTICK_HIDAPI_STADIA: &'static [u8; 27usize] = b"SDL_JOYSTICK_HIDAPI_STADIA\0"; pub const SDL_HINT_JOYSTICK_HIDAPI_STEAM: &'static [u8; 26usize] = b"SDL_JOYSTICK_HIDAPI_STEAM\0"; +pub const SDL_HINT_JOYSTICK_HIDAPI_STEAMDECK: &'static [u8; 30usize] = + b"SDL_JOYSTICK_HIDAPI_STEAMDECK\0"; pub const SDL_HINT_JOYSTICK_HIDAPI_SWITCH: &'static [u8; 27usize] = b"SDL_JOYSTICK_HIDAPI_SWITCH\0"; pub const SDL_HINT_JOYSTICK_HIDAPI_SWITCH_HOME_LED: &'static [u8; 36usize] = b"SDL_JOYSTICK_HIDAPI_SWITCH_HOME_LED\0"; +pub const SDL_HINT_JOYSTICK_HIDAPI_JOYCON_HOME_LED: &'static [u8; 36usize] = + b"SDL_JOYSTICK_HIDAPI_JOYCON_HOME_LED\0"; +pub const SDL_HINT_JOYSTICK_HIDAPI_SWITCH_PLAYER_LED: &'static [u8; 38usize] = + b"SDL_JOYSTICK_HIDAPI_SWITCH_PLAYER_LED\0"; +pub const SDL_HINT_JOYSTICK_HIDAPI_WII: &'static [u8; 24usize] = b"SDL_JOYSTICK_HIDAPI_WII\0"; +pub const SDL_HINT_JOYSTICK_HIDAPI_WII_PLAYER_LED: &'static [u8; 35usize] = + b"SDL_JOYSTICK_HIDAPI_WII_PLAYER_LED\0"; pub const SDL_HINT_JOYSTICK_HIDAPI_XBOX: &'static [u8; 25usize] = b"SDL_JOYSTICK_HIDAPI_XBOX\0"; +pub const SDL_HINT_JOYSTICK_HIDAPI_XBOX_360: &'static [u8; 29usize] = + b"SDL_JOYSTICK_HIDAPI_XBOX_360\0"; +pub const SDL_HINT_JOYSTICK_HIDAPI_XBOX_360_PLAYER_LED: &'static [u8; 40usize] = + b"SDL_JOYSTICK_HIDAPI_XBOX_360_PLAYER_LED\0"; +pub const SDL_HINT_JOYSTICK_HIDAPI_XBOX_360_WIRELESS: &'static [u8; 38usize] = + b"SDL_JOYSTICK_HIDAPI_XBOX_360_WIRELESS\0"; +pub const SDL_HINT_JOYSTICK_HIDAPI_XBOX_ONE: &'static [u8; 29usize] = + b"SDL_JOYSTICK_HIDAPI_XBOX_ONE\0"; +pub const SDL_HINT_JOYSTICK_HIDAPI_XBOX_ONE_HOME_LED: &'static [u8; 38usize] = + b"SDL_JOYSTICK_HIDAPI_XBOX_ONE_HOME_LED\0"; +pub const SDL_HINT_JOYSTICK_IOKIT: &'static [u8; 19usize] = b"SDL_JOYSTICK_IOKIT\0"; +pub const SDL_HINT_JOYSTICK_MFI: &'static [u8; 17usize] = b"SDL_JOYSTICK_MFI\0"; pub const SDL_HINT_JOYSTICK_RAWINPUT: &'static [u8; 22usize] = b"SDL_JOYSTICK_RAWINPUT\0"; pub const SDL_HINT_JOYSTICK_RAWINPUT_CORRELATE_XINPUT: &'static [u8; 39usize] = b"SDL_JOYSTICK_RAWINPUT_CORRELATE_XINPUT\0"; +pub const SDL_HINT_JOYSTICK_ROG_CHAKRAM: &'static [u8; 25usize] = b"SDL_JOYSTICK_ROG_CHAKRAM\0"; pub const SDL_HINT_JOYSTICK_THREAD: &'static [u8; 20usize] = b"SDL_JOYSTICK_THREAD\0"; +pub const SDL_HINT_JOYSTICK_THROTTLE_DEVICES: &'static [u8; 30usize] = + b"SDL_JOYSTICK_THROTTLE_DEVICES\0"; +pub const SDL_HINT_JOYSTICK_THROTTLE_DEVICES_EXCLUDED: &'static [u8; 39usize] = + b"SDL_JOYSTICK_THROTTLE_DEVICES_EXCLUDED\0"; +pub const SDL_HINT_JOYSTICK_WGI: &'static [u8; 17usize] = b"SDL_JOYSTICK_WGI\0"; +pub const SDL_HINT_JOYSTICK_WHEEL_DEVICES: &'static [u8; 27usize] = b"SDL_JOYSTICK_WHEEL_DEVICES\0"; +pub const SDL_HINT_JOYSTICK_WHEEL_DEVICES_EXCLUDED: &'static [u8; 36usize] = + b"SDL_JOYSTICK_WHEEL_DEVICES_EXCLUDED\0"; +pub const SDL_HINT_JOYSTICK_ZERO_CENTERED_DEVICES: &'static [u8; 35usize] = + b"SDL_JOYSTICK_ZERO_CENTERED_DEVICES\0"; pub const SDL_HINT_KMSDRM_REQUIRE_DRM_MASTER: &'static [u8; 30usize] = b"SDL_KMSDRM_REQUIRE_DRM_MASTER\0"; pub const SDL_HINT_JOYSTICK_DEVICE: &'static [u8; 20usize] = b"SDL_JOYSTICK_DEVICE\0"; +pub const SDL_HINT_LINUX_DIGITAL_HATS: &'static [u8; 23usize] = b"SDL_LINUX_DIGITAL_HATS\0"; +pub const SDL_HINT_LINUX_HAT_DEADZONES: &'static [u8; 24usize] = b"SDL_LINUX_HAT_DEADZONES\0"; pub const SDL_HINT_LINUX_JOYSTICK_CLASSIC: &'static [u8; 27usize] = b"SDL_LINUX_JOYSTICK_CLASSIC\0"; pub const SDL_HINT_LINUX_JOYSTICK_DEADZONES: &'static [u8; 29usize] = b"SDL_LINUX_JOYSTICK_DEADZONES\0"; +pub const SDL_HINT_LOGGING: &'static [u8; 12usize] = b"SDL_LOGGING\0"; pub const SDL_HINT_MAC_BACKGROUND_APP: &'static [u8; 23usize] = b"SDL_MAC_BACKGROUND_APP\0"; pub const SDL_HINT_MAC_CTRL_CLICK_EMULATE_RIGHT_CLICK: &'static [u8; 39usize] = b"SDL_MAC_CTRL_CLICK_EMULATE_RIGHT_CLICK\0"; +pub const SDL_HINT_MAC_OPENGL_ASYNC_DISPATCH: &'static [u8; 30usize] = + b"SDL_MAC_OPENGL_ASYNC_DISPATCH\0"; pub const SDL_HINT_MOUSE_DOUBLE_CLICK_RADIUS: &'static [u8; 30usize] = b"SDL_MOUSE_DOUBLE_CLICK_RADIUS\0"; pub const SDL_HINT_MOUSE_DOUBLE_CLICK_TIME: &'static [u8; 28usize] = @@ -424,12 +495,19 @@ pub const SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH: &'static [u8; 29usize] = b"SDL_MOUSE_FOCUS_CLICKTHROUGH\0"; pub const SDL_HINT_MOUSE_NORMAL_SPEED_SCALE: &'static [u8; 29usize] = b"SDL_MOUSE_NORMAL_SPEED_SCALE\0"; +pub const SDL_HINT_MOUSE_RELATIVE_MODE_CENTER: &'static [u8; 31usize] = + b"SDL_MOUSE_RELATIVE_MODE_CENTER\0"; pub const SDL_HINT_MOUSE_RELATIVE_MODE_WARP: &'static [u8; 29usize] = b"SDL_MOUSE_RELATIVE_MODE_WARP\0"; pub const SDL_HINT_MOUSE_RELATIVE_SCALING: &'static [u8; 27usize] = b"SDL_MOUSE_RELATIVE_SCALING\0"; pub const SDL_HINT_MOUSE_RELATIVE_SPEED_SCALE: &'static [u8; 31usize] = b"SDL_MOUSE_RELATIVE_SPEED_SCALE\0"; +pub const SDL_HINT_MOUSE_RELATIVE_SYSTEM_SCALE: &'static [u8; 32usize] = + b"SDL_MOUSE_RELATIVE_SYSTEM_SCALE\0"; +pub const SDL_HINT_MOUSE_RELATIVE_WARP_MOTION: &'static [u8; 31usize] = + b"SDL_MOUSE_RELATIVE_WARP_MOTION\0"; pub const SDL_HINT_MOUSE_TOUCH_EVENTS: &'static [u8; 23usize] = b"SDL_MOUSE_TOUCH_EVENTS\0"; +pub const SDL_HINT_MOUSE_AUTO_CAPTURE: &'static [u8; 23usize] = b"SDL_MOUSE_AUTO_CAPTURE\0"; pub const SDL_HINT_NO_SIGNAL_HANDLERS: &'static [u8; 23usize] = b"SDL_NO_SIGNAL_HANDLERS\0"; pub const SDL_HINT_OPENGL_ES_DRIVER: &'static [u8; 21usize] = b"SDL_OPENGL_ES_DRIVER\0"; pub const SDL_HINT_ORIENTATIONS: &'static [u8; 21usize] = b"SDL_IOS_ORIENTATIONS\0"; @@ -450,6 +528,12 @@ pub const SDL_HINT_RENDER_LOGICAL_SIZE_MODE: &'static [u8; 29usize] = pub const SDL_HINT_RENDER_OPENGL_SHADERS: &'static [u8; 26usize] = b"SDL_RENDER_OPENGL_SHADERS\0"; pub const SDL_HINT_RENDER_SCALE_QUALITY: &'static [u8; 25usize] = b"SDL_RENDER_SCALE_QUALITY\0"; pub const SDL_HINT_RENDER_VSYNC: &'static [u8; 17usize] = b"SDL_RENDER_VSYNC\0"; +pub const SDL_HINT_RENDER_METAL_PREFER_LOW_POWER_DEVICE: &'static [u8; 41usize] = + b"SDL_RENDER_METAL_PREFER_LOW_POWER_DEVICE\0"; +pub const SDL_HINT_ROG_GAMEPAD_MICE: &'static [u8; 21usize] = b"SDL_ROG_GAMEPAD_MICE\0"; +pub const SDL_HINT_ROG_GAMEPAD_MICE_EXCLUDED: &'static [u8; 30usize] = + b"SDL_ROG_GAMEPAD_MICE_EXCLUDED\0"; +pub const SDL_HINT_PS2_DYNAMIC_VSYNC: &'static [u8; 22usize] = b"SDL_PS2_DYNAMIC_VSYNC\0"; pub const SDL_HINT_RETURN_KEY_HIDES_IME: &'static [u8; 25usize] = b"SDL_RETURN_KEY_HIDES_IME\0"; pub const SDL_HINT_RPI_VIDEO_LAYER: &'static [u8; 20usize] = b"SDL_RPI_VIDEO_LAYER\0"; pub const SDL_HINT_SCREENSAVER_INHIBIT_ACTIVITY_NAME: &'static [u8; 38usize] = @@ -460,6 +544,8 @@ pub const SDL_HINT_THREAD_PRIORITY_POLICY: &'static [u8; 27usize] = b"SDL_THREAD pub const SDL_HINT_THREAD_STACK_SIZE: &'static [u8; 22usize] = b"SDL_THREAD_STACK_SIZE\0"; pub const SDL_HINT_TIMER_RESOLUTION: &'static [u8; 21usize] = b"SDL_TIMER_RESOLUTION\0"; pub const SDL_HINT_TOUCH_MOUSE_EVENTS: &'static [u8; 23usize] = b"SDL_TOUCH_MOUSE_EVENTS\0"; +pub const SDL_HINT_VITA_TOUCH_MOUSE_DEVICE: &'static [u8; 33usize] = + b"SDL_HINT_VITA_TOUCH_MOUSE_DEVICE\0"; pub const SDL_HINT_TV_REMOTE_AS_JOYSTICK: &'static [u8; 26usize] = b"SDL_TV_REMOTE_AS_JOYSTICK\0"; pub const SDL_HINT_VIDEO_ALLOW_SCREENSAVER: &'static [u8; 28usize] = b"SDL_VIDEO_ALLOW_SCREENSAVER\0"; @@ -474,8 +560,18 @@ pub const SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS: &'static [u8; 33usize] = b"SDL_VIDEO_MINIMIZE_ON_FOCUS_LOSS\0"; pub const SDL_HINT_VIDEO_WAYLAND_ALLOW_LIBDECOR: &'static [u8; 33usize] = b"SDL_VIDEO_WAYLAND_ALLOW_LIBDECOR\0"; +pub const SDL_HINT_VIDEO_WAYLAND_PREFER_LIBDECOR: &'static [u8; 34usize] = + b"SDL_VIDEO_WAYLAND_PREFER_LIBDECOR\0"; +pub const SDL_HINT_VIDEO_WAYLAND_MODE_EMULATION: &'static [u8; 33usize] = + b"SDL_VIDEO_WAYLAND_MODE_EMULATION\0"; +pub const SDL_HINT_VIDEO_WAYLAND_EMULATE_MOUSE_WARP: &'static [u8; 37usize] = + b"SDL_VIDEO_WAYLAND_EMULATE_MOUSE_WARP\0"; pub const SDL_HINT_VIDEO_WINDOW_SHARE_PIXEL_FORMAT: &'static [u8; 36usize] = b"SDL_VIDEO_WINDOW_SHARE_PIXEL_FORMAT\0"; +pub const SDL_HINT_VIDEO_FOREIGN_WINDOW_OPENGL: &'static [u8; 32usize] = + b"SDL_VIDEO_FOREIGN_WINDOW_OPENGL\0"; +pub const SDL_HINT_VIDEO_FOREIGN_WINDOW_VULKAN: &'static [u8; 32usize] = + b"SDL_VIDEO_FOREIGN_WINDOW_VULKAN\0"; pub const SDL_HINT_VIDEO_WIN_D3DCOMPILER: &'static [u8; 26usize] = b"SDL_VIDEO_WIN_D3DCOMPILER\0"; pub const SDL_HINT_VIDEO_X11_FORCE_EGL: &'static [u8; 24usize] = b"SDL_VIDEO_X11_FORCE_EGL\0"; pub const SDL_HINT_VIDEO_X11_NET_WM_BYPASS_COMPOSITOR: &'static [u8; 39usize] = @@ -491,6 +587,8 @@ pub const SDL_HINT_WAVE_RIFF_CHUNK_SIZE: &'static [u8; 25usize] = b"SDL_WAVE_RIF pub const SDL_HINT_WAVE_TRUNCATION: &'static [u8; 20usize] = b"SDL_WAVE_TRUNCATION\0"; pub const SDL_HINT_WINDOWS_DISABLE_THREAD_NAMING: &'static [u8; 34usize] = b"SDL_WINDOWS_DISABLE_THREAD_NAMING\0"; +pub const SDL_HINT_WINDOWS_ENABLE_MENU_MNEMONICS: &'static [u8; 34usize] = + b"SDL_WINDOWS_ENABLE_MENU_MNEMONICS\0"; pub const SDL_HINT_WINDOWS_ENABLE_MESSAGELOOP: &'static [u8; 31usize] = b"SDL_WINDOWS_ENABLE_MESSAGELOOP\0"; pub const SDL_HINT_WINDOWS_FORCE_MUTEX_CRITICAL_SECTIONS: &'static [u8; 42usize] = @@ -504,6 +602,8 @@ pub const SDL_HINT_WINDOWS_INTRESOURCE_ICON_SMALL: &'static [u8; 35usize] = pub const SDL_HINT_WINDOWS_NO_CLOSE_ON_ALT_F4: &'static [u8; 31usize] = b"SDL_WINDOWS_NO_CLOSE_ON_ALT_F4\0"; pub const SDL_HINT_WINDOWS_USE_D3D9EX: &'static [u8; 23usize] = b"SDL_WINDOWS_USE_D3D9EX\0"; +pub const SDL_HINT_WINDOWS_DPI_AWARENESS: &'static [u8; 26usize] = b"SDL_WINDOWS_DPI_AWARENESS\0"; +pub const SDL_HINT_WINDOWS_DPI_SCALING: &'static [u8; 24usize] = b"SDL_WINDOWS_DPI_SCALING\0"; pub const SDL_HINT_WINDOW_FRAME_USABLE_WHILE_CURSOR_HIDDEN: &'static [u8; 44usize] = b"SDL_WINDOW_FRAME_USABLE_WHILE_CURSOR_HIDDEN\0"; pub const SDL_HINT_WINDOW_NO_ACTIVATION_WHEN_SHOWN: &'static [u8; 36usize] = @@ -517,16 +617,25 @@ pub const SDL_HINT_WINRT_PRIVACY_POLICY_URL: &'static [u8; 29usize] = pub const SDL_HINT_X11_FORCE_OVERRIDE_REDIRECT: &'static [u8; 32usize] = b"SDL_X11_FORCE_OVERRIDE_REDIRECT\0"; pub const SDL_HINT_XINPUT_ENABLED: &'static [u8; 19usize] = b"SDL_XINPUT_ENABLED\0"; +pub const SDL_HINT_DIRECTINPUT_ENABLED: &'static [u8; 24usize] = b"SDL_DIRECTINPUT_ENABLED\0"; pub const SDL_HINT_XINPUT_USE_OLD_JOYSTICK_MAPPING: &'static [u8; 36usize] = b"SDL_XINPUT_USE_OLD_JOYSTICK_MAPPING\0"; pub const SDL_HINT_AUDIO_INCLUDE_MONITORS: &'static [u8; 27usize] = b"SDL_AUDIO_INCLUDE_MONITORS\0"; +pub const SDL_HINT_X11_WINDOW_TYPE: &'static [u8; 20usize] = b"SDL_X11_WINDOW_TYPE\0"; +pub const SDL_HINT_QUIT_ON_LAST_WINDOW_CLOSE: &'static [u8; 30usize] = + b"SDL_QUIT_ON_LAST_WINDOW_CLOSE\0"; +pub const SDL_HINT_VIDEODRIVER: &'static [u8; 16usize] = b"SDL_VIDEODRIVER\0"; +pub const SDL_HINT_AUDIODRIVER: &'static [u8; 16usize] = b"SDL_AUDIODRIVER\0"; +pub const SDL_HINT_KMSDRM_DEVICE_INDEX: &'static [u8; 24usize] = b"SDL_KMSDRM_DEVICE_INDEX\0"; +pub const SDL_HINT_TRACKPAD_IS_TOUCH_ONLY: &'static [u8; 27usize] = b"SDL_TRACKPAD_IS_TOUCH_ONLY\0"; +pub const SDL_HINT_SHUTDOWN_DBUS_ON_QUIT: &'static [u8; 26usize] = b"SDL_SHUTDOWN_DBUS_ON_QUIT\0"; pub const SDL_MAX_LOG_MESSAGE: u32 = 4096; pub const SDL_NONSHAPEABLE_WINDOW: i32 = -1; pub const SDL_INVALID_SHAPE_ARGUMENT: i32 = -2; pub const SDL_WINDOW_LACKS_SHAPE: i32 = -3; pub const SDL_MAJOR_VERSION: u32 = 2; -pub const SDL_MINOR_VERSION: u32 = 0; -pub const SDL_PATCHLEVEL: u32 = 20; +pub const SDL_MINOR_VERSION: u32 = 30; +pub const SDL_PATCHLEVEL: u32 = 2; pub const SDL_INIT_TIMER: u32 = 1; pub const SDL_INIT_AUDIO: u32 = 16; pub const SDL_INIT_VIDEO: u32 = 32; @@ -1178,20 +1287,11 @@ pub type Sint32 = i32; pub type Uint32 = u32; pub type Sint64 = i64; pub type Uint64 = u64; -pub type SDL_compile_time_assert_uint8 = [libc::c_int; 1usize]; -pub type SDL_compile_time_assert_sint8 = [libc::c_int; 1usize]; -pub type SDL_compile_time_assert_uint16 = [libc::c_int; 1usize]; -pub type SDL_compile_time_assert_sint16 = [libc::c_int; 1usize]; -pub type SDL_compile_time_assert_uint32 = [libc::c_int; 1usize]; -pub type SDL_compile_time_assert_sint32 = [libc::c_int; 1usize]; -pub type SDL_compile_time_assert_uint64 = [libc::c_int; 1usize]; -pub type SDL_compile_time_assert_sint64 = [libc::c_int; 1usize]; #[repr(u32)] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub enum SDL_DUMMY_ENUM { DUMMY_ENUM_VALUE = 0, } -pub type SDL_compile_time_assert_enum = [libc::c_int; 1usize]; extern "C" { pub fn SDL_malloc(size: size_t) -> *mut libc::c_void; } @@ -1212,6 +1312,17 @@ pub type SDL_realloc_func = ::core::option::Option< unsafe extern "C" fn(mem: *mut libc::c_void, size: size_t) -> *mut libc::c_void, >; pub type SDL_free_func = ::core::option::Option; +extern "C" { + #[doc = " Get the original set of SDL memory functions"] + #[doc = ""] + #[doc = " \\since This function is available since SDL 2.24.0."] + pub fn SDL_GetOriginalMemoryFunctions( + malloc_func: *mut SDL_malloc_func, + calloc_func: *mut SDL_calloc_func, + realloc_func: *mut SDL_realloc_func, + free_func: *mut SDL_free_func, + ); +} extern "C" { #[doc = " Get the current set of SDL memory functions"] #[doc = ""] @@ -1263,6 +1374,20 @@ extern "C" { >, ); } +extern "C" { + pub fn SDL_bsearch( + key: *const libc::c_void, + base: *const libc::c_void, + nmemb: size_t, + size: size_t, + compare: ::core::option::Option< + unsafe extern "C" fn( + arg1: *const libc::c_void, + arg2: *const libc::c_void, + ) -> libc::c_int, + >, + ) -> *mut libc::c_void; +} extern "C" { pub fn SDL_abs(x: libc::c_int) -> libc::c_int; } @@ -1308,6 +1433,9 @@ extern "C" { extern "C" { pub fn SDL_tolower(x: libc::c_int) -> libc::c_int; } +extern "C" { + pub fn SDL_crc16(crc: Uint16, data: *const libc::c_void, len: size_t) -> Uint16; +} extern "C" { pub fn SDL_crc32(crc: Uint32, data: *const libc::c_void, len: size_t) -> Uint32; } @@ -1399,6 +1527,12 @@ extern "C" { needle: *const libc::c_char, ) -> *mut libc::c_char; } +extern "C" { + pub fn SDL_strcasestr( + haystack: *const libc::c_char, + needle: *const libc::c_char, + ) -> *mut libc::c_char; +} extern "C" { pub fn SDL_strtokr( s1: *mut libc::c_char, @@ -1409,6 +1543,9 @@ extern "C" { extern "C" { pub fn SDL_utf8strlen(str: *const libc::c_char) -> size_t; } +extern "C" { + pub fn SDL_utf8strnlen(str: *const libc::c_char, bytes: size_t) -> size_t; +} extern "C" { pub fn SDL_itoa( value: libc::c_int, @@ -1708,8 +1845,8 @@ extern "C" { ) -> size_t; } extern "C" { - #[doc = " This function converts a string between encodings in one pass, returning a"] - #[doc = " string that must be freed with SDL_free() or NULL on error."] + #[doc = " This function converts a buffer or string between encodings in one pass,"] + #[doc = " returning a string that must be freed with SDL_free() or NULL on error."] #[doc = ""] #[doc = " \\since This function is available since SDL 2.0.0."] pub fn SDL_iconv_string( @@ -2499,7 +2636,7 @@ extern "C" { #[doc = " successful it will atomically decrement the semaphore value."] #[doc = ""] #[doc = " \\param sem the semaphore to wait on"] - #[doc = " \\param ms the length of the timeout, in milliseconds"] + #[doc = " \\param timeout the length of the timeout, in milliseconds"] #[doc = " \\returns 0 if the wait succeeds, `SDL_MUTEX_TIMEDOUT` if the wait does not"] #[doc = " succeed in the allotted time, or a negative error code on failure;"] #[doc = " call SDL_GetError() for more information."] @@ -2512,7 +2649,7 @@ extern "C" { #[doc = " \\sa SDL_SemTryWait"] #[doc = " \\sa SDL_SemValue"] #[doc = " \\sa SDL_SemWait"] - pub fn SDL_SemWaitTimeout(sem: *mut SDL_sem, ms: Uint32) -> libc::c_int; + pub fn SDL_SemWaitTimeout(sem: *mut SDL_sem, timeout: Uint32) -> libc::c_int; } extern "C" { #[doc = " Atomically increment a semaphore's value and wake waiting threads."] @@ -3923,13 +4060,13 @@ pub type SDL_AudioCallback = ::core::option::Option< #[doc = " The calculated values in this structure are calculated by SDL_OpenAudio()."] #[doc = ""] #[doc = " For multi-channel audio, the default SDL channel mapping is:"] -#[doc = " 2: FL FR (stereo)"] -#[doc = " 3: FL FR LFE (2.1 surround)"] -#[doc = " 4: FL FR BL BR (quad)"] -#[doc = " 5: FL FR FC BL BR (quad + center)"] -#[doc = " 6: FL FR FC LFE SL SR (5.1 surround - last two can also be BL BR)"] -#[doc = " 7: FL FR FC LFE BC SL SR (6.1 surround)"] -#[doc = " 8: FL FR FC LFE BL BR SL SR (7.1 surround)"] +#[doc = " 2: FL FR (stereo)"] +#[doc = " 3: FL FR LFE (2.1 surround)"] +#[doc = " 4: FL FR BL BR (quad)"] +#[doc = " 5: FL FR LFE BL BR (4.1 surround)"] +#[doc = " 6: FL FR FC LFE SL SR (5.1 surround - last two can also be BL BR)"] +#[doc = " 7: FL FR FC LFE BC SL SR (6.1 surround)"] +#[doc = " 8: FL FR FC LFE BL BR SL SR (7.1 surround)"] #[repr(C)] #[derive(Copy, Clone)] pub struct SDL_AudioSpec { @@ -4417,6 +4554,7 @@ extern "C" { #[doc = " \\since This function is available since SDL 2.0.0."] #[doc = ""] #[doc = " \\sa SDL_GetNumAudioDevices"] + #[doc = " \\sa SDL_GetDefaultAudioInfo"] pub fn SDL_GetAudioDeviceName( index: libc::c_int, iscapture: libc::c_int, @@ -4431,9 +4569,7 @@ extern "C" { #[doc = " hardware."] #[doc = ""] #[doc = " `spec` will be filled with the sample rate, sample format, and channel"] - #[doc = " count. All other values in the structure are filled with 0. When the"] - #[doc = " supported struct members are 0, SDL was unable to get the property from the"] - #[doc = " backend."] + #[doc = " count."] #[doc = ""] #[doc = " \\param index the index of the audio device; valid values range from 0 to"] #[doc = " SDL_GetNumAudioDevices() - 1"] @@ -4445,12 +4581,48 @@ extern "C" { #[doc = " \\since This function is available since SDL 2.0.16."] #[doc = ""] #[doc = " \\sa SDL_GetNumAudioDevices"] + #[doc = " \\sa SDL_GetDefaultAudioInfo"] pub fn SDL_GetAudioDeviceSpec( index: libc::c_int, iscapture: libc::c_int, spec: *mut SDL_AudioSpec, ) -> libc::c_int; } +extern "C" { + #[doc = " Get the name and preferred format of the default audio device."] + #[doc = ""] + #[doc = " Some (but not all!) platforms have an isolated mechanism to get information"] + #[doc = " about the \"default\" device. This can actually be a completely different"] + #[doc = " device that's not in the list you get from SDL_GetAudioDeviceSpec(). It can"] + #[doc = " even be a network address! (This is discussed in SDL_OpenAudioDevice().)"] + #[doc = ""] + #[doc = " As a result, this call is not guaranteed to be performant, as it can query"] + #[doc = " the sound server directly every time, unlike the other query functions. You"] + #[doc = " should call this function sparingly!"] + #[doc = ""] + #[doc = " `spec` will be filled with the sample rate, sample format, and channel"] + #[doc = " count, if a default device exists on the system. If `name` is provided,"] + #[doc = " will be filled with either a dynamically-allocated UTF-8 string or NULL."] + #[doc = ""] + #[doc = " \\param name A pointer to be filled with the name of the default device (can"] + #[doc = " be NULL). Please call SDL_free() when you are done with this"] + #[doc = " pointer!"] + #[doc = " \\param spec The SDL_AudioSpec to be initialized by this function."] + #[doc = " \\param iscapture non-zero to query the default recording device, zero to"] + #[doc = " query the default output device."] + #[doc = " \\returns 0 on success, nonzero on error"] + #[doc = ""] + #[doc = " \\since This function is available since SDL 2.24.0."] + #[doc = ""] + #[doc = " \\sa SDL_GetAudioDeviceName"] + #[doc = " \\sa SDL_GetAudioDeviceSpec"] + #[doc = " \\sa SDL_OpenAudioDevice"] + pub fn SDL_GetDefaultAudioInfo( + name: *mut *mut libc::c_char, + spec: *mut SDL_AudioSpec, + iscapture: libc::c_int, + ) -> libc::c_int; +} extern "C" { #[doc = " Open a specific audio device."] #[doc = ""] @@ -4517,6 +4689,7 @@ extern "C" { #[doc = " - `SDL_AUDIO_ALLOW_FREQUENCY_CHANGE`"] #[doc = " - `SDL_AUDIO_ALLOW_FORMAT_CHANGE`"] #[doc = " - `SDL_AUDIO_ALLOW_CHANNELS_CHANGE`"] + #[doc = " - `SDL_AUDIO_ALLOW_SAMPLES_CHANGE`"] #[doc = " - `SDL_AUDIO_ALLOW_ANY_CHANGE`"] #[doc = ""] #[doc = " These flags specify how SDL should behave when a device cannot offer a"] @@ -5374,46 +5547,45 @@ extern "C" { extern "C" { #[doc = " Put UTF-8 text into the primary selection."] #[doc = ""] - #[doc = "\\param text the text to store in the primary selection"] - #[doc = "\\returns 0 on success or a negative error code on failure; call"] - #[doc = " SDL_GetError() for more information."] + #[doc = " \\param text the text to store in the primary selection"] + #[doc = " \\returns 0 on success or a negative error code on failure; call"] + #[doc = " SDL_GetError() for more information."] #[doc = ""] - #[doc = "\\since This function is available since SDL 2.26.0."] + #[doc = " \\since This function is available since SDL 2.26.0."] #[doc = ""] - #[doc = "\\sa SDL_GetPrimarySelectionText"] - #[doc = "\\sa SDL_HasPrimarySelectionText"] + #[doc = " \\sa SDL_GetPrimarySelectionText"] + #[doc = " \\sa SDL_HasPrimarySelectionText"] pub fn SDL_SetPrimarySelectionText(text: *const libc::c_char) -> libc::c_int; } extern "C" { #[doc = " Get UTF-8 text from the primary selection, which must be freed with"] - #[doc = "SDL_free()."] + #[doc = " SDL_free()."] #[doc = ""] - #[doc = "This functions returns empty string if there was not enough memory left for"] - #[doc = "a copy of the primary selection's content."] + #[doc = " This functions returns empty string if there was not enough memory left for"] + #[doc = " a copy of the primary selection's content."] #[doc = ""] - #[doc = "\\returns the primary selection text on success or an empty string on"] - #[doc = " failure; call SDL_GetError() for more information. Caller must"] - #[doc = " call SDL_free() on the returned pointer when done with it (even if"] - #[doc = " there was an error)."] + #[doc = " \\returns the primary selection text on success or an empty string on"] + #[doc = " failure; call SDL_GetError() for more information. Caller must"] + #[doc = " call SDL_free() on the returned pointer when done with it (even if"] + #[doc = " there was an error)."] #[doc = ""] - #[doc = "\\since This function is available since SDL 2.26.0."] + #[doc = " \\since This function is available since SDL 2.26.0."] #[doc = ""] - #[doc = "\\sa SDL_HasPrimarySelectionText"] - #[doc = "\\sa SDL_SetPrimarySelectionText"] + #[doc = " \\sa SDL_HasPrimarySelectionText"] + #[doc = " \\sa SDL_SetPrimarySelectionText"] pub fn SDL_GetPrimarySelectionText() -> *mut libc::c_char; } extern "C" { - - #[doc = "Query whether the primary selection exists and contains a non-empty text"] - #[doc = "string."] + #[doc = " Query whether the primary selection exists and contains a non-empty text"] + #[doc = " string."] #[doc = ""] - #[doc = "\\returns SDL_TRUE if the primary selection has text, or SDL_FALSE if it"] - #[doc = " does not."] + #[doc = " \\returns SDL_TRUE if the primary selection has text, or SDL_FALSE if it"] + #[doc = " does not."] #[doc = ""] - #[doc = "\\since This function is available since SDL 2.26.0."] + #[doc = " \\since This function is available since SDL 2.26.0."] #[doc = ""] - #[doc = "\\sa SDL_GetPrimarySelectionText"] - #[doc = "\\sa SDL_SetPrimarySelectionText"] + #[doc = " \\sa SDL_GetPrimarySelectionText"] + #[doc = " \\sa SDL_SetPrimarySelectionText"] pub fn SDL_HasPrimarySelectionText() -> SDL_bool; } pub type __m64 = [libc::c_longlong; 1usize]; @@ -7617,10 +7789,34 @@ extern "C" { #[doc = " \\since This function is available since SDL 2.0.6."] pub fn SDL_HasNEON() -> SDL_bool; } +extern "C" { + #[doc = " Determine whether the CPU has LSX (LOONGARCH SIMD) features."] + #[doc = ""] + #[doc = " This always returns false on CPUs that aren't using LOONGARCH instruction"] + #[doc = " sets."] + #[doc = ""] + #[doc = " \\returns SDL_TRUE if the CPU has LOONGARCH LSX features or SDL_FALSE if"] + #[doc = " not."] + #[doc = ""] + #[doc = " \\since This function is available since SDL 2.24.0."] + pub fn SDL_HasLSX() -> SDL_bool; +} +extern "C" { + #[doc = " Determine whether the CPU has LASX (LOONGARCH SIMD) features."] + #[doc = ""] + #[doc = " This always returns false on CPUs that aren't using LOONGARCH instruction"] + #[doc = " sets."] + #[doc = ""] + #[doc = " \\returns SDL_TRUE if the CPU has LOONGARCH LASX features or SDL_FALSE if"] + #[doc = " not."] + #[doc = ""] + #[doc = " \\since This function is available since SDL 2.24.0."] + pub fn SDL_HasLASX() -> SDL_bool; +} extern "C" { #[doc = " Get the amount of RAM configured in the system."] #[doc = ""] - #[doc = " \\returns the amount of RAM configured in the system in MB."] + #[doc = " \\returns the amount of RAM configured in the system in MiB."] #[doc = ""] #[doc = " \\since This function is available since SDL 2.0.1."] pub fn SDL_GetSystemRAM() -> libc::c_int; @@ -7676,7 +7872,7 @@ extern "C" { #[doc = ""] #[doc = " \\since This function is available since SDL 2.0.10."] #[doc = ""] - #[doc = " \\sa SDL_SIMDAlignment"] + #[doc = " \\sa SDL_SIMDGetAlignment"] #[doc = " \\sa SDL_SIMDRealloc"] #[doc = " \\sa SDL_SIMDFree"] pub fn SDL_SIMDAlloc(len: size_t) -> *mut libc::c_void; @@ -7699,7 +7895,7 @@ extern "C" { #[doc = ""] #[doc = " \\since This function is available since SDL 2.0.14."] #[doc = ""] - #[doc = " \\sa SDL_SIMDAlignment"] + #[doc = " \\sa SDL_SIMDGetAlignment"] #[doc = " \\sa SDL_SIMDAlloc"] #[doc = " \\sa SDL_SIMDFree"] pub fn SDL_SIMDRealloc(mem: *mut libc::c_void, len: size_t) -> *mut libc::c_void; @@ -7743,6 +7939,7 @@ pub enum SDL_PixelType { SDL_PIXELTYPE_ARRAYU32 = 9, SDL_PIXELTYPE_ARRAYF16 = 10, SDL_PIXELTYPE_ARRAYF32 = 11, + SDL_PIXELTYPE_INDEX2 = 12, } #[repr(u32)] #[doc = " Bitmap pixel order, high bit -> low bit."] @@ -7832,12 +8029,30 @@ impl SDL_PixelFormatEnum { pub const SDL_PIXELFORMAT_ABGR32: SDL_PixelFormatEnum = SDL_PixelFormatEnum::SDL_PIXELFORMAT_RGBA8888; } +impl SDL_PixelFormatEnum { + pub const SDL_PIXELFORMAT_RGBX32: SDL_PixelFormatEnum = + SDL_PixelFormatEnum::SDL_PIXELFORMAT_XBGR8888; +} +impl SDL_PixelFormatEnum { + pub const SDL_PIXELFORMAT_XRGB32: SDL_PixelFormatEnum = + SDL_PixelFormatEnum::SDL_PIXELFORMAT_BGRX8888; +} +impl SDL_PixelFormatEnum { + pub const SDL_PIXELFORMAT_BGRX32: SDL_PixelFormatEnum = + SDL_PixelFormatEnum::SDL_PIXELFORMAT_XRGB8888; +} +impl SDL_PixelFormatEnum { + pub const SDL_PIXELFORMAT_XBGR32: SDL_PixelFormatEnum = + SDL_PixelFormatEnum::SDL_PIXELFORMAT_RGBX8888; +} #[repr(u32)] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub enum SDL_PixelFormatEnum { SDL_PIXELFORMAT_UNKNOWN = 0, SDL_PIXELFORMAT_INDEX1LSB = 286261504, SDL_PIXELFORMAT_INDEX1MSB = 287310080, + SDL_PIXELFORMAT_INDEX2LSB = 470811136, + SDL_PIXELFORMAT_INDEX2MSB = 471859712, SDL_PIXELFORMAT_INDEX4LSB = 303039488, SDL_PIXELFORMAT_INDEX4MSB = 304088064, SDL_PIXELFORMAT_INDEX8 = 318769153, @@ -8570,8 +8785,8 @@ fn bindgen_test_layout_SDL_Point() { } #[doc = " The structure that defines a point (floating point)"] #[doc = ""] -#[doc = " \\sa SDL_EnclosePoints"] -#[doc = " \\sa SDL_PointInRect"] +#[doc = " \\sa SDL_EncloseFPoints"] +#[doc = " \\sa SDL_PointInFRect"] #[repr(C)] #[derive(Copy, Clone)] pub struct SDL_FPoint { @@ -8617,6 +8832,7 @@ fn bindgen_test_layout_SDL_FPoint() { #[doc = " \\sa SDL_RectEquals"] #[doc = " \\sa SDL_HasIntersection"] #[doc = " \\sa SDL_IntersectRect"] +#[doc = " \\sa SDL_IntersectRectAndLine"] #[doc = " \\sa SDL_UnionRect"] #[doc = " \\sa SDL_EnclosePoints"] #[repr(C)] @@ -8681,6 +8897,16 @@ fn bindgen_test_layout_SDL_Rect() { ); } #[doc = " A rectangle, with the origin at the upper left (floating point)."] +#[doc = ""] +#[doc = " \\sa SDL_FRectEmpty"] +#[doc = " \\sa SDL_FRectEquals"] +#[doc = " \\sa SDL_FRectEqualsEpsilon"] +#[doc = " \\sa SDL_HasIntersectionF"] +#[doc = " \\sa SDL_IntersectFRect"] +#[doc = " \\sa SDL_IntersectFRectAndLine"] +#[doc = " \\sa SDL_UnionFRect"] +#[doc = " \\sa SDL_EncloseFPoints"] +#[doc = " \\sa SDL_PointInFRect"] #[repr(C)] #[derive(Copy, Clone)] pub struct SDL_FRect { @@ -8835,6 +9061,101 @@ extern "C" { Y2: *mut libc::c_int, ) -> SDL_bool; } +extern "C" { + #[doc = " Determine whether two rectangles intersect with float precision."] + #[doc = ""] + #[doc = " If either pointer is NULL the function will return SDL_FALSE."] + #[doc = ""] + #[doc = " \\param A an SDL_FRect structure representing the first rectangle"] + #[doc = " \\param B an SDL_FRect structure representing the second rectangle"] + #[doc = " \\returns SDL_TRUE if there is an intersection, SDL_FALSE otherwise."] + #[doc = ""] + #[doc = " \\since This function is available since SDL 2.0.22."] + #[doc = ""] + #[doc = " \\sa SDL_IntersectRect"] + pub fn SDL_HasIntersectionF(A: *const SDL_FRect, B: *const SDL_FRect) -> SDL_bool; +} +extern "C" { + #[doc = " Calculate the intersection of two rectangles with float precision."] + #[doc = ""] + #[doc = " If `result` is NULL then this function will return SDL_FALSE."] + #[doc = ""] + #[doc = " \\param A an SDL_FRect structure representing the first rectangle"] + #[doc = " \\param B an SDL_FRect structure representing the second rectangle"] + #[doc = " \\param result an SDL_FRect structure filled in with the intersection of"] + #[doc = " rectangles `A` and `B`"] + #[doc = " \\returns SDL_TRUE if there is an intersection, SDL_FALSE otherwise."] + #[doc = ""] + #[doc = " \\since This function is available since SDL 2.0.22."] + #[doc = ""] + #[doc = " \\sa SDL_HasIntersectionF"] + pub fn SDL_IntersectFRect( + A: *const SDL_FRect, + B: *const SDL_FRect, + result: *mut SDL_FRect, + ) -> SDL_bool; +} +extern "C" { + #[doc = " Calculate the union of two rectangles with float precision."] + #[doc = ""] + #[doc = " \\param A an SDL_FRect structure representing the first rectangle"] + #[doc = " \\param B an SDL_FRect structure representing the second rectangle"] + #[doc = " \\param result an SDL_FRect structure filled in with the union of rectangles"] + #[doc = " `A` and `B`"] + #[doc = ""] + #[doc = " \\since This function is available since SDL 2.0.22."] + pub fn SDL_UnionFRect(A: *const SDL_FRect, B: *const SDL_FRect, result: *mut SDL_FRect); +} +extern "C" { + #[doc = " Calculate a minimal rectangle enclosing a set of points with float"] + #[doc = " precision."] + #[doc = ""] + #[doc = " If `clip` is not NULL then only points inside of the clipping rectangle are"] + #[doc = " considered."] + #[doc = ""] + #[doc = " \\param points an array of SDL_FPoint structures representing points to be"] + #[doc = " enclosed"] + #[doc = " \\param count the number of structures in the `points` array"] + #[doc = " \\param clip an SDL_FRect used for clipping or NULL to enclose all points"] + #[doc = " \\param result an SDL_FRect structure filled in with the minimal enclosing"] + #[doc = " rectangle"] + #[doc = " \\returns SDL_TRUE if any points were enclosed or SDL_FALSE if all the"] + #[doc = " points were outside of the clipping rectangle."] + #[doc = ""] + #[doc = " \\since This function is available since SDL 2.0.22."] + pub fn SDL_EncloseFPoints( + points: *const SDL_FPoint, + count: libc::c_int, + clip: *const SDL_FRect, + result: *mut SDL_FRect, + ) -> SDL_bool; +} +extern "C" { + #[doc = " Calculate the intersection of a rectangle and line segment with float"] + #[doc = " precision."] + #[doc = ""] + #[doc = " This function is used to clip a line segment to a rectangle. A line segment"] + #[doc = " contained entirely within the rectangle or that does not intersect will"] + #[doc = " remain unchanged. A line segment that crosses the rectangle at either or"] + #[doc = " both ends will be clipped to the boundary of the rectangle and the new"] + #[doc = " coordinates saved in `X1`, `Y1`, `X2`, and/or `Y2` as necessary."] + #[doc = ""] + #[doc = " \\param rect an SDL_FRect structure representing the rectangle to intersect"] + #[doc = " \\param X1 a pointer to the starting X-coordinate of the line"] + #[doc = " \\param Y1 a pointer to the starting Y-coordinate of the line"] + #[doc = " \\param X2 a pointer to the ending X-coordinate of the line"] + #[doc = " \\param Y2 a pointer to the ending Y-coordinate of the line"] + #[doc = " \\returns SDL_TRUE if there is an intersection, SDL_FALSE otherwise."] + #[doc = ""] + #[doc = " \\since This function is available since SDL 2.0.22."] + pub fn SDL_IntersectFRectAndLine( + rect: *const SDL_FRect, + X1: *mut f32, + Y1: *mut f32, + X2: *mut f32, + Y2: *mut f32, + ) -> SDL_bool; +} #[repr(u32)] #[doc = " \\brief The blend mode used in SDL_RenderCopy() and drawing operations."] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] @@ -8856,7 +9177,7 @@ pub enum SDL_BlendMode { SDL_BLENDMODE_MOD = 4, #[doc = "< color multiply"] #[doc = "dstRGB = (srcRGB * dstRGB) + (dstRGB * (1-srcA))"] - #[doc = "dstA = (srcA * dstA) + (dstA * (1-srcA))"] + #[doc = "dstA = dstA"] SDL_BLENDMODE_MUL = 8, SDL_BLENDMODE_INVALID = 2147483647, } @@ -8866,13 +9187,13 @@ pub enum SDL_BlendMode { pub enum SDL_BlendOperation { #[doc = "< dst + src: supported by all renderers"] SDL_BLENDOPERATION_ADD = 1, - #[doc = "< dst - src : supported by D3D9, D3D11, OpenGL, OpenGLES"] - SDL_BLENDOPERATION_SUBTRACT = 2, #[doc = "< src - dst : supported by D3D9, D3D11, OpenGL, OpenGLES"] + SDL_BLENDOPERATION_SUBTRACT = 2, + #[doc = "< dst - src : supported by D3D9, D3D11, OpenGL, OpenGLES"] SDL_BLENDOPERATION_REV_SUBTRACT = 3, - #[doc = "< min(dst, src) : supported by D3D11"] + #[doc = "< min(dst, src) : supported by D3D9, D3D11"] SDL_BLENDOPERATION_MINIMUM = 4, - #[doc = "< max(dst, src) : supported by D3D11"] + #[doc = "< max(dst, src) : supported by D3D9, D3D11"] SDL_BLENDOPERATION_MAXIMUM = 5, } #[repr(u32)] @@ -8945,10 +9266,10 @@ extern "C" { #[doc = " SDL 2.0.6. All renderers support the four blend modes listed in the"] #[doc = " SDL_BlendMode enumeration."] #[doc = ""] - #[doc = " - **direct3d**: Supports `SDL_BLENDOPERATION_ADD` with all factors."] - #[doc = " - **direct3d11**: Supports all operations with all factors. However, some"] + #[doc = " - **direct3d**: Supports all operations with all factors. However, some"] #[doc = " factors produce unexpected results with `SDL_BLENDOPERATION_MINIMUM` and"] #[doc = " `SDL_BLENDOPERATION_MAXIMUM`."] + #[doc = " - **direct3d11**: Same as Direct3D 9."] #[doc = " - **opengl**: Supports the `SDL_BLENDOPERATION_ADD` operation with all"] #[doc = " factors. OpenGL versions 1.1, 1.2, and 1.3 do not work correctly with SDL"] #[doc = " 2.0.6."] @@ -9000,6 +9321,11 @@ extern "C" { alphaOperation: SDL_BlendOperation, ) -> SDL_BlendMode; } +#[repr(C)] +#[derive(Copy, Clone)] +pub struct SDL_BlitMap { + _unused: [u8; 0], +} #[doc = " \\brief A collection of pixels used in software blitting."] #[doc = ""] #[doc = " \\note This structure should be treated as read-only, except for \\c pixels,"] @@ -10207,6 +10533,8 @@ pub enum SDL_DisplayEventID { SDL_DISPLAYEVENT_CONNECTED = 2, #[doc = "< Display has been removed from the system"] SDL_DISPLAYEVENT_DISCONNECTED = 3, + #[doc = "< Display has changed position"] + SDL_DISPLAYEVENT_MOVED = 4, } #[repr(u32)] #[doc = " \\brief Display orientation"] @@ -10267,6 +10595,7 @@ pub enum SDL_GLattr { SDL_GL_CONTEXT_RELEASE_BEHAVIOR = 24, SDL_GL_CONTEXT_RESET_NOTIFICATION = 25, SDL_GL_CONTEXT_NO_ERROR = 26, + SDL_GL_FLOATBUFFERS = 27, } #[repr(u32)] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] @@ -10454,6 +10783,15 @@ extern "C" { #[doc = " A failure of this function usually means that either no DPI information is"] #[doc = " available or the `displayIndex` is out of range."] #[doc = ""] + #[doc = " **WARNING**: This reports the DPI that the hardware reports, and it is not"] + #[doc = " always reliable! It is almost always better to use SDL_GetWindowSize() to"] + #[doc = " find the window size, which might be in logical points instead of pixels,"] + #[doc = " and then SDL_GL_GetDrawableSize(), SDL_Vulkan_GetDrawableSize(),"] + #[doc = " SDL_Metal_GetDrawableSize(), or SDL_GetRendererOutputSize(), and compare"] + #[doc = " the two values to get an actual scaling value between the two. We will be"] + #[doc = " rethinking how high-dpi details should be managed in SDL3 to make things"] + #[doc = " more consistent, reliable, and clear."] + #[doc = ""] #[doc = " \\param displayIndex the index of the display from which DPI information"] #[doc = " should be queried"] #[doc = " \\param ddpi a pointer filled in with the diagonal DPI of the display; may"] @@ -10607,6 +10945,33 @@ extern "C" { closest: *mut SDL_DisplayMode, ) -> *mut SDL_DisplayMode; } +extern "C" { + #[doc = " Get the index of the display containing a point"] + #[doc = ""] + #[doc = " \\param point the point to query"] + #[doc = " \\returns the index of the display containing the point or a negative error"] + #[doc = " code on failure; call SDL_GetError() for more information."] + #[doc = ""] + #[doc = " \\since This function is available since SDL 2.24.0."] + #[doc = ""] + #[doc = " \\sa SDL_GetDisplayBounds"] + #[doc = " \\sa SDL_GetNumVideoDisplays"] + pub fn SDL_GetPointDisplayIndex(point: *const SDL_Point) -> libc::c_int; +} +extern "C" { + #[doc = " Get the index of the display primarily containing a rect"] + #[doc = ""] + #[doc = " \\param rect the rect to query"] + #[doc = " \\returns the index of the display entirely containing the rect or closest"] + #[doc = " to the center of the rect on success or a negative error code on"] + #[doc = " failure; call SDL_GetError() for more information."] + #[doc = ""] + #[doc = " \\since This function is available since SDL 2.24.0."] + #[doc = ""] + #[doc = " \\sa SDL_GetDisplayBounds"] + #[doc = " \\sa SDL_GetNumVideoDisplays"] + pub fn SDL_GetRectDisplayIndex(rect: *const SDL_Rect) -> libc::c_int; +} extern "C" { #[doc = " Get the index of the display associated with a window."] #[doc = ""] @@ -10717,7 +11082,10 @@ extern "C" { #[doc = " in pixels may differ from its size in screen coordinates on platforms with"] #[doc = " high-DPI support (e.g. iOS and macOS). Use SDL_GetWindowSize() to query the"] #[doc = " client area's size in screen coordinates, and SDL_GL_GetDrawableSize() or"] - #[doc = " SDL_GetRendererOutputSize() to query the drawable size in pixels."] + #[doc = " SDL_GetRendererOutputSize() to query the drawable size in pixels. Note that"] + #[doc = " when this flag is set, the drawable size can vary after the window is"] + #[doc = " created and should be queried after major window events such as when the"] + #[doc = " window is resized or moved between displays."] #[doc = ""] #[doc = " If the window is set fullscreen, the width and height parameters `w` and"] #[doc = " `h` will not be used. However, invalid size parameters (e.g. too large) may"] @@ -11016,6 +11384,29 @@ extern "C" { right: *mut libc::c_int, ) -> libc::c_int; } +extern "C" { + #[doc = " Get the size of a window in pixels."] + #[doc = ""] + #[doc = " This may differ from SDL_GetWindowSize() if we're rendering to a high-DPI"] + #[doc = " drawable, i.e. the window was created with `SDL_WINDOW_ALLOW_HIGHDPI` on a"] + #[doc = " platform with high-DPI support (Apple calls this \"Retina\"), and not"] + #[doc = " disabled by the `SDL_HINT_VIDEO_HIGHDPI_DISABLED` hint."] + #[doc = ""] + #[doc = " \\param window the window from which the drawable size should be queried"] + #[doc = " \\param w a pointer to variable for storing the width in pixels, may be NULL"] + #[doc = " \\param h a pointer to variable for storing the height in pixels, may be"] + #[doc = " NULL"] + #[doc = ""] + #[doc = " \\since This function is available since SDL 2.26.0."] + #[doc = ""] + #[doc = " \\sa SDL_CreateWindow"] + #[doc = " \\sa SDL_GetWindowSize"] + pub fn SDL_GetWindowSizeInPixels( + window: *mut SDL_Window, + w: *mut libc::c_int, + h: *mut libc::c_int, + ); +} extern "C" { #[doc = " Set the minimum size of a window's client area."] #[doc = ""] @@ -11217,6 +11608,17 @@ extern "C" { #[doc = " \\sa SDL_SetWindowDisplayMode"] pub fn SDL_SetWindowFullscreen(window: *mut SDL_Window, flags: Uint32) -> libc::c_int; } +extern "C" { + #[doc = " Return whether the window has a surface associated with it."] + #[doc = ""] + #[doc = " \\returns SDL_TRUE if there is a surface associated with the window, or"] + #[doc = " SDL_FALSE otherwise."] + #[doc = ""] + #[doc = " \\since This function is available since SDL 2.28.0."] + #[doc = ""] + #[doc = " \\sa SDL_GetWindowSurface"] + pub fn SDL_HasWindowSurface(window: *mut SDL_Window) -> SDL_bool; +} extern "C" { #[doc = " Get the SDL surface associated with the window."] #[doc = ""] @@ -11237,6 +11639,8 @@ extern "C" { #[doc = ""] #[doc = " \\since This function is available since SDL 2.0.0."] #[doc = ""] + #[doc = " \\sa SDL_DestroyWindowSurface"] + #[doc = " \\sa SDL_HasWindowSurface"] #[doc = " \\sa SDL_UpdateWindowSurface"] #[doc = " \\sa SDL_UpdateWindowSurfaceRects"] pub fn SDL_GetWindowSurface(window: *mut SDL_Window) -> *mut SDL_Surface; @@ -11267,9 +11671,14 @@ extern "C" { #[doc = ""] #[doc = " This function is equivalent to the SDL 1.2 API SDL_UpdateRects()."] #[doc = ""] + #[doc = " Note that this function will update _at least_ the rectangles specified,"] + #[doc = " but this is only intended as an optimization; in practice, this might"] + #[doc = " update more of the screen (or all of the screen!), depending on what"] + #[doc = " method SDL uses to send pixels to the system."] + #[doc = ""] #[doc = " \\param window the window to update"] #[doc = " \\param rects an array of SDL_Rect structures representing areas of the"] - #[doc = " surface to copy"] + #[doc = " surface to copy, in pixels"] #[doc = " \\param numrects the number of rectangles"] #[doc = " \\returns 0 on success or a negative error code on failure; call"] #[doc = " SDL_GetError() for more information."] @@ -11284,6 +11693,19 @@ extern "C" { numrects: libc::c_int, ) -> libc::c_int; } +extern "C" { + #[doc = " Destroy the surface associated with the window."] + #[doc = ""] + #[doc = " \\param window the window to update"] + #[doc = " \\returns 0 on success or a negative error code on failure; call"] + #[doc = " SDL_GetError() for more information."] + #[doc = ""] + #[doc = " \\since This function is available since SDL 2.28.0."] + #[doc = ""] + #[doc = " \\sa SDL_GetWindowSurface"] + #[doc = " \\sa SDL_HasWindowSurface"] + pub fn SDL_DestroyWindowSurface(window: *mut SDL_Window) -> libc::c_int; +} extern "C" { #[doc = " Set a window's input grab mode."] #[doc = ""] @@ -11338,6 +11760,7 @@ extern "C" { #[doc = " Mouse grab confines the mouse cursor to the window."] #[doc = ""] #[doc = " \\param window The window for which the mouse grab mode should be set."] + #[doc = " \\param grabbed This is SDL_TRUE to grab mouse, and SDL_FALSE to release."] #[doc = ""] #[doc = " \\since This function is available since SDL 2.0.16."] #[doc = ""] @@ -11736,6 +12159,9 @@ extern "C" { #[doc = " If you disable the screensaver, it is automatically re-enabled when SDL"] #[doc = " quits."] #[doc = ""] + #[doc = " The screensaver is disabled by default since SDL 2.0.2. Before SDL 2.0.2"] + #[doc = " the screensaver was enabled by default."] + #[doc = ""] #[doc = " \\since This function is available since SDL 2.0.0."] #[doc = ""] #[doc = " \\sa SDL_EnableScreenSaver"] @@ -11978,13 +12404,8 @@ extern "C" { #[doc = " retry the call with 1 for the interval."] #[doc = ""] #[doc = " Adaptive vsync is implemented for some glX drivers with"] - #[doc = " GLX_EXT_swap_control_tear:"] - #[doc = ""] - #[doc = " https://www.opengl.org/registry/specs/EXT/glx_swap_control_tear.txt"] - #[doc = ""] - #[doc = " and for some Windows drivers with WGL_EXT_swap_control_tear:"] - #[doc = ""] - #[doc = " https://www.opengl.org/registry/specs/EXT/wgl_swap_control_tear.txt"] + #[doc = " GLX_EXT_swap_control_tear, and for some Windows drivers with"] + #[doc = " WGL_EXT_swap_control_tear."] #[doc = ""] #[doc = " Read more on the Khronos wiki:"] #[doc = " https://www.khronos.org/opengl/wiki/Swap_Interval#Adaptive_Vsync"] @@ -12222,16 +12643,24 @@ pub enum SDL_Scancode { SDL_SCANCODE_F23 = 114, SDL_SCANCODE_F24 = 115, SDL_SCANCODE_EXECUTE = 116, + #[doc = "< AL Integrated Help Center"] SDL_SCANCODE_HELP = 117, + #[doc = "< Menu (show menu)"] SDL_SCANCODE_MENU = 118, SDL_SCANCODE_SELECT = 119, + #[doc = "< AC Stop"] SDL_SCANCODE_STOP = 120, - #[doc = "< redo"] + #[doc = "< AC Redo/Repeat"] SDL_SCANCODE_AGAIN = 121, + #[doc = "< AC Undo"] SDL_SCANCODE_UNDO = 122, + #[doc = "< AC Cut"] SDL_SCANCODE_CUT = 123, + #[doc = "< AC Copy"] SDL_SCANCODE_COPY = 124, + #[doc = "< AC Paste"] SDL_SCANCODE_PASTE = 125, + #[doc = "< AC Find"] SDL_SCANCODE_FIND = 126, SDL_SCANCODE_MUTE = 127, SDL_SCANCODE_VOLUMEUP = 128, @@ -12271,6 +12700,7 @@ pub enum SDL_Scancode { #[doc = "< Erase-Eaze"] SDL_SCANCODE_ALTERASE = 153, SDL_SCANCODE_SYSREQ = 154, + #[doc = "< AC Cancel"] SDL_SCANCODE_CANCEL = 155, SDL_SCANCODE_CLEAR = 156, SDL_SCANCODE_PRIOR = 157, @@ -12349,16 +12779,25 @@ pub enum SDL_Scancode { SDL_SCANCODE_AUDIOPLAY = 261, SDL_SCANCODE_AUDIOMUTE = 262, SDL_SCANCODE_MEDIASELECT = 263, + #[doc = "< AL Internet Browser"] SDL_SCANCODE_WWW = 264, SDL_SCANCODE_MAIL = 265, + #[doc = "< AL Calculator"] SDL_SCANCODE_CALCULATOR = 266, SDL_SCANCODE_COMPUTER = 267, + #[doc = "< AC Search"] SDL_SCANCODE_AC_SEARCH = 268, + #[doc = "< AC Home"] SDL_SCANCODE_AC_HOME = 269, + #[doc = "< AC Back"] SDL_SCANCODE_AC_BACK = 270, + #[doc = "< AC Forward"] SDL_SCANCODE_AC_FORWARD = 271, + #[doc = "< AC Stop"] SDL_SCANCODE_AC_STOP = 272, + #[doc = "< AC Refresh"] SDL_SCANCODE_AC_REFRESH = 273, + #[doc = "< AC Bookmarks"] SDL_SCANCODE_AC_BOOKMARKS = 274, SDL_SCANCODE_BRIGHTNESSDOWN = 275, SDL_SCANCODE_BRIGHTNESSUP = 276, @@ -12369,11 +12808,26 @@ pub enum SDL_Scancode { SDL_SCANCODE_KBDILLUMDOWN = 279, SDL_SCANCODE_KBDILLUMUP = 280, SDL_SCANCODE_EJECT = 281, + #[doc = "< SC System Sleep"] SDL_SCANCODE_SLEEP = 282, SDL_SCANCODE_APP1 = 283, SDL_SCANCODE_APP2 = 284, SDL_SCANCODE_AUDIOREWIND = 285, SDL_SCANCODE_AUDIOFASTFORWARD = 286, + #[doc = "< Usually situated below the display on phones and"] + #[doc = "used as a multi-function feature key for selecting"] + #[doc = "a software defined function shown on the bottom left"] + #[doc = "of the display."] + SDL_SCANCODE_SOFTLEFT = 287, + #[doc = "< Usually situated below the display on phones and"] + #[doc = "used as a multi-function feature key for selecting"] + #[doc = "a software defined function shown on the bottom right"] + #[doc = "of the display."] + SDL_SCANCODE_SOFTRIGHT = 288, + #[doc = "< Used for accepting phone calls."] + SDL_SCANCODE_CALL = 289, + #[doc = "< Used for rejecting phone calls."] + SDL_SCANCODE_ENDCALL = 290, #[doc = "< not a key, just marks the number of scancodes"] #[doc = "for array bounds"] SDL_NUM_SCANCODES = 512, @@ -12386,7 +12840,7 @@ pub enum SDL_Scancode { #[doc = " an SDLK_* constant for those keys that do not generate characters."] #[doc = ""] #[doc = " A special exception is the number keys at the top of the keyboard which"] -#[doc = " always map to SDLK_0...SDLK_9, regardless of layout."] +#[doc = " map to SDLK_0...SDLK_9 on AZERTY layouts."] pub type SDL_Keycode = Sint32; #[repr(u32)] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] @@ -12631,6 +13085,10 @@ pub enum SDL_KeyCode { SDLK_APP2 = 1073742108, SDLK_AUDIOREWIND = 1073742109, SDLK_AUDIOFASTFORWARD = 1073742110, + SDLK_SOFTLEFT = 1073742111, + SDLK_SOFTRIGHT = 1073742112, + SDLK_CALL = 1073742113, + SDLK_ENDCALL = 1073742114, } impl SDL_Keymod { pub const KMOD_RESERVED: SDL_Keymod = SDL_Keymod::KMOD_SCROLL; @@ -12759,8 +13217,19 @@ extern "C" { #[doc = " \\since This function is available since SDL 2.0.0."] #[doc = ""] #[doc = " \\sa SDL_PumpEvents"] + #[doc = " \\sa SDL_ResetKeyboard"] pub fn SDL_GetKeyboardState(numkeys: *mut libc::c_int) -> *const Uint8; } +extern "C" { + #[doc = " Clear the state of the keyboard"] + #[doc = ""] + #[doc = " This function will generate key up events for all pressed keys."] + #[doc = ""] + #[doc = " \\since This function is available since SDL 2.24.0."] + #[doc = ""] + #[doc = " \\sa SDL_GetKeyboardState"] + pub fn SDL_ResetKeyboard(); +} extern "C" { #[doc = " Get the current key modifier state for the keyboard."] #[doc = ""] @@ -12926,7 +13395,32 @@ extern "C" { pub fn SDL_StopTextInput(); } extern "C" { - #[doc = " Set the rectangle used to type Unicode text inputs."] + #[doc = " Dismiss the composition window/IME without disabling the subsystem."] + #[doc = ""] + #[doc = " \\since This function is available since SDL 2.0.22."] + #[doc = ""] + #[doc = " \\sa SDL_StartTextInput"] + #[doc = " \\sa SDL_StopTextInput"] + pub fn SDL_ClearComposition(); +} +extern "C" { + #[doc = " Returns if an IME Composite or Candidate window is currently shown."] + #[doc = ""] + #[doc = " \\since This function is available since SDL 2.0.22."] + pub fn SDL_IsTextInputShown() -> SDL_bool; +} +extern "C" { + #[doc = " Set the rectangle used to type Unicode text inputs. Native input methods"] + #[doc = " will place a window with word suggestions near it, without covering the"] + #[doc = " text being inputted."] + #[doc = ""] + #[doc = " To start text input in a given location, this function is intended to be"] + #[doc = " called before SDL_StartTextInput, although some platforms support moving"] + #[doc = " the rectangle even while text input (and a composition) is active."] + #[doc = ""] + #[doc = " Note: If you want to use the system native IME window, try setting hint"] + #[doc = " **SDL_HINT_IME_SHOW_UI** to **1**, otherwise this function won't give you"] + #[doc = " any feedback."] #[doc = ""] #[doc = " \\param rect the SDL_Rect structure representing the rectangle to receive"] #[doc = " text (ignored if NULL)"] @@ -12934,7 +13428,7 @@ extern "C" { #[doc = " \\since This function is available since SDL 2.0.0."] #[doc = ""] #[doc = " \\sa SDL_StartTextInput"] - pub fn SDL_SetTextInputRect(rect: *mut SDL_Rect); + pub fn SDL_SetTextInputRect(rect: *const SDL_Rect); } extern "C" { #[doc = " Check whether the platform has screen keyboard support."] @@ -13082,7 +13576,9 @@ extern "C" { extern "C" { #[doc = " Move the mouse cursor to the given position within the window."] #[doc = ""] - #[doc = " This function generates a mouse motion event."] + #[doc = " This function generates a mouse motion event if relative mode is not"] + #[doc = " enabled. If relative mode is enabled, you can force mouse events for the"] + #[doc = " warp by setting the SDL_HINT_MOUSE_RELATIVE_WARP_MOTION hint."] #[doc = ""] #[doc = " Note that this function will appear to succeed, but not actually move the"] #[doc = " mouse when used over Microsoft Remote Desktop."] @@ -13121,13 +13617,9 @@ extern "C" { extern "C" { #[doc = " Set relative mouse mode."] #[doc = ""] - #[doc = " While the mouse is in relative mode, the cursor is hidden, and the driver"] - #[doc = " will try to report continuous motion in the current window. Only relative"] - #[doc = " motion events will be delivered, the mouse position will not change."] - #[doc = ""] - #[doc = " Note that this function will not be able to provide continuous relative"] - #[doc = " motion when used over Microsoft Remote Desktop, instead motion is limited"] - #[doc = " to the bounds of the screen."] + #[doc = " While the mouse is in relative mode, the cursor is hidden, the mouse"] + #[doc = " position is constrained to the window, and SDL will report continuous"] + #[doc = " relative mouse motion even if the mouse is at the edge of the window."] #[doc = ""] #[doc = " This function will flush any pending mouse motion."] #[doc = ""] @@ -13169,6 +13661,15 @@ extern "C" { #[doc = " While capturing is enabled, the current window will have the"] #[doc = " `SDL_WINDOW_MOUSE_CAPTURE` flag set."] #[doc = ""] + #[doc = " Please note that as of SDL 2.0.22, SDL will attempt to \"auto capture\" the"] + #[doc = " mouse while the user is pressing a button; this is to try and make mouse"] + #[doc = " behavior more consistent between platforms, and deal with the common case"] + #[doc = " of a user dragging the mouse outside of the window. This means that if you"] + #[doc = " are calling SDL_CaptureMouse() only to deal with this situation, you no"] + #[doc = " longer have to (although it is safe to do so). If this causes problems for"] + #[doc = " your app, you can disable auto capture by setting the"] + #[doc = " `SDL_HINT_MOUSE_AUTO_CAPTURE` hint to zero."] + #[doc = ""] #[doc = " \\param enabled SDL_TRUE to enable capturing, SDL_FALSE to disable."] #[doc = " \\returns 0 on success or -1 if not supported; call SDL_GetError() for more"] #[doc = " information."] @@ -13301,6 +13802,9 @@ extern "C" { extern "C" { #[doc = " Get the default cursor."] #[doc = ""] + #[doc = " You do not have to call SDL_FreeCursor() on the return value, but it is"] + #[doc = " safe to do so."] + #[doc = ""] #[doc = " \\returns the default cursor on success or NULL on failure."] #[doc = ""] #[doc = " \\since This function is available since SDL 2.0.0."] @@ -13344,41 +13848,83 @@ extern "C" { #[doc = " \\sa SDL_SetCursor"] pub fn SDL_ShowCursor(toggle: libc::c_int) -> libc::c_int; } -#[doc = " The joystick structure used to identify an SDL joystick"] -#[repr(C)] -#[derive(Copy, Clone)] -pub struct _SDL_Joystick { - _unused: [u8; 0], -} -pub type SDL_Joystick = _SDL_Joystick; +#[doc = " An SDL_GUID is a 128-bit identifier for an input device that"] +#[doc = " identifies that device across runs of SDL programs on the same"] +#[doc = " platform. If the device is detached and then re-attached to a"] +#[doc = " different port, or if the base system is rebooted, the device"] +#[doc = " should still report the same GUID."] +#[doc = ""] +#[doc = " GUIDs are as precise as possible but are not guaranteed to"] +#[doc = " distinguish physically distinct but equivalent devices. For"] +#[doc = " example, two game controllers from the same vendor with the same"] +#[doc = " product ID and revision may have the same GUID."] +#[doc = ""] +#[doc = " GUIDs may be platform-dependent (i.e., the same device may report"] +#[doc = " different GUIDs on different operating systems)."] #[repr(C)] #[derive(Copy, Clone)] -pub struct SDL_JoystickGUID { +pub struct SDL_GUID { pub data: [Uint8; 16usize], } #[test] -fn bindgen_test_layout_SDL_JoystickGUID() { +fn bindgen_test_layout_SDL_GUID() { assert_eq!( - ::core::mem::size_of::(), + ::core::mem::size_of::(), 16usize, - concat!("Size of: ", stringify!(SDL_JoystickGUID)) + concat!("Size of: ", stringify!(SDL_GUID)) ); assert_eq!( - ::core::mem::align_of::(), + ::core::mem::align_of::(), 1usize, - concat!("Alignment of ", stringify!(SDL_JoystickGUID)) + concat!("Alignment of ", stringify!(SDL_GUID)) ); assert_eq!( - unsafe { &(*(::core::ptr::null::())).data as *const _ as usize }, + unsafe { &(*(::core::ptr::null::())).data as *const _ as usize }, 0usize, concat!( "Offset of field: ", - stringify!(SDL_JoystickGUID), + stringify!(SDL_GUID), "::", stringify!(data) ) ); } +extern "C" { + #[doc = " Get an ASCII string representation for a given ::SDL_GUID."] + #[doc = ""] + #[doc = " You should supply at least 33 bytes for pszGUID."] + #[doc = ""] + #[doc = " \\param guid the ::SDL_GUID you wish to convert to string"] + #[doc = " \\param pszGUID buffer in which to write the ASCII string"] + #[doc = " \\param cbGUID the size of pszGUID"] + #[doc = ""] + #[doc = " \\since This function is available since SDL 2.24.0."] + #[doc = ""] + #[doc = " \\sa SDL_GUIDFromString"] + pub fn SDL_GUIDToString(guid: SDL_GUID, pszGUID: *mut libc::c_char, cbGUID: libc::c_int); +} +extern "C" { + #[doc = " Convert a GUID string into a ::SDL_GUID structure."] + #[doc = ""] + #[doc = " Performs no error checking. If this function is given a string containing"] + #[doc = " an invalid GUID, the function will silently succeed, but the GUID generated"] + #[doc = " will not be useful."] + #[doc = ""] + #[doc = " \\param pchGUID string containing an ASCII representation of a GUID"] + #[doc = " \\returns a ::SDL_GUID structure."] + #[doc = ""] + #[doc = " \\since This function is available since SDL 2.24.0."] + #[doc = ""] + #[doc = " \\sa SDL_GUIDToString"] + pub fn SDL_GUIDFromString(pchGUID: *const libc::c_char) -> SDL_GUID; +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct _SDL_Joystick { + _unused: [u8; 0], +} +pub type SDL_Joystick = _SDL_Joystick; +pub type SDL_JoystickGUID = SDL_GUID; #[doc = " This is a unique ID for a joystick for the time it is connected to the system,"] #[doc = " and is never reused for the lifetime of the application. If the joystick is"] #[doc = " disconnected and reconnected, it will get a new ID."] @@ -13420,6 +13966,11 @@ extern "C" { #[doc = " the API functions that take a joystick index will be valid, and joystick"] #[doc = " and game controller events will not be delivered."] #[doc = ""] + #[doc = " As of SDL 2.26.0, you can take the joystick lock around reinitializing the"] + #[doc = " joystick subsystem, to prevent other threads from seeing joysticks in an"] + #[doc = " uninitialized state. However, all open joysticks will be closed and SDL"] + #[doc = " functions called with them will fail."] + #[doc = ""] #[doc = " \\since This function is available since SDL 2.0.7."] pub fn SDL_LockJoysticks(); } @@ -13445,6 +13996,7 @@ extern "C" { #[doc = " \\since This function is available since SDL 2.0.0."] #[doc = ""] #[doc = " \\sa SDL_JoystickName"] + #[doc = " \\sa SDL_JoystickPath"] #[doc = " \\sa SDL_JoystickOpen"] pub fn SDL_NumJoysticks() -> libc::c_int; } @@ -13464,6 +14016,22 @@ extern "C" { #[doc = " \\sa SDL_JoystickOpen"] pub fn SDL_JoystickNameForIndex(device_index: libc::c_int) -> *const libc::c_char; } +extern "C" { + #[doc = " Get the implementation dependent path of a joystick."] + #[doc = ""] + #[doc = " This can be called before any joysticks are opened."] + #[doc = ""] + #[doc = " \\param device_index the index of the joystick to query (the N'th joystick"] + #[doc = " on the system)"] + #[doc = " \\returns the path of the selected joystick. If no path can be found, this"] + #[doc = " function returns NULL; call SDL_GetError() for more information."] + #[doc = ""] + #[doc = " \\since This function is available since SDL 2.24.0."] + #[doc = ""] + #[doc = " \\sa SDL_JoystickPath"] + #[doc = " \\sa SDL_JoystickOpen"] + pub fn SDL_JoystickPathForIndex(device_index: libc::c_int) -> *const libc::c_char; +} extern "C" { #[doc = " Get the player index of a joystick, or -1 if it's not available This can be"] #[doc = " called before any joysticks are opened."] @@ -13546,13 +14114,12 @@ extern "C" { extern "C" { #[doc = " Get the instance ID of a joystick."] #[doc = ""] - #[doc = " This can be called before any joysticks are opened. If the index is out of"] - #[doc = " range, this function will return -1."] + #[doc = " This can be called before any joysticks are opened."] #[doc = ""] #[doc = " \\param device_index the index of the joystick to query (the N'th joystick"] #[doc = " on the system"] #[doc = " \\returns the instance id of the selected joystick. If called on an invalid"] - #[doc = " index, this function returns zero"] + #[doc = " index, this function returns -1."] #[doc = ""] #[doc = " \\since This function is available since SDL 2.0.6."] pub fn SDL_JoystickGetDeviceInstanceID(device_index: libc::c_int) -> SDL_JoystickID; @@ -13611,6 +14178,304 @@ extern "C" { nhats: libc::c_int, ) -> libc::c_int; } +#[doc = " The structure that defines an extended virtual joystick description"] +#[doc = ""] +#[doc = " The caller must zero the structure and then initialize the version with `SDL_VIRTUAL_JOYSTICK_DESC_VERSION` before passing it to SDL_JoystickAttachVirtualEx()"] +#[doc = " All other elements of this structure are optional and can be left 0."] +#[doc = ""] +#[doc = " \\sa SDL_JoystickAttachVirtualEx"] +#[repr(C)] +#[derive(Copy, Clone)] +pub struct SDL_VirtualJoystickDesc { + #[doc = "< `SDL_VIRTUAL_JOYSTICK_DESC_VERSION`"] + pub version: Uint16, + #[doc = "< `SDL_JoystickType`"] + pub type_: Uint16, + #[doc = "< the number of axes on this joystick"] + pub naxes: Uint16, + #[doc = "< the number of buttons on this joystick"] + pub nbuttons: Uint16, + #[doc = "< the number of hats on this joystick"] + pub nhats: Uint16, + #[doc = "< the USB vendor ID of this joystick"] + pub vendor_id: Uint16, + #[doc = "< the USB product ID of this joystick"] + pub product_id: Uint16, + #[doc = "< unused"] + pub padding: Uint16, + #[doc = "< A mask of which buttons are valid for this controller"] + #[doc = "e.g. (1 << SDL_CONTROLLER_BUTTON_A)"] + pub button_mask: Uint32, + #[doc = "< A mask of which axes are valid for this controller"] + #[doc = "e.g. (1 << SDL_CONTROLLER_AXIS_LEFTX)"] + pub axis_mask: Uint32, + #[doc = "< the name of the joystick"] + pub name: *const libc::c_char, + #[doc = "< User data pointer passed to callbacks"] + pub userdata: *mut libc::c_void, + #[doc = "< Called when the joystick state should be updated"] + pub Update: ::core::option::Option, + #[doc = "< Called when the player index is set"] + pub SetPlayerIndex: ::core::option::Option< + unsafe extern "C" fn(userdata: *mut libc::c_void, player_index: libc::c_int), + >, + #[doc = "< Implements SDL_JoystickRumble()"] + pub Rumble: ::core::option::Option< + unsafe extern "C" fn( + userdata: *mut libc::c_void, + low_frequency_rumble: Uint16, + high_frequency_rumble: Uint16, + ) -> libc::c_int, + >, + #[doc = "< Implements SDL_JoystickRumbleTriggers()"] + pub RumbleTriggers: ::core::option::Option< + unsafe extern "C" fn( + userdata: *mut libc::c_void, + left_rumble: Uint16, + right_rumble: Uint16, + ) -> libc::c_int, + >, + #[doc = "< Implements SDL_JoystickSetLED()"] + pub SetLED: ::core::option::Option< + unsafe extern "C" fn( + userdata: *mut libc::c_void, + red: Uint8, + green: Uint8, + blue: Uint8, + ) -> libc::c_int, + >, + #[doc = "< Implements SDL_JoystickSendEffect()"] + pub SendEffect: ::core::option::Option< + unsafe extern "C" fn( + userdata: *mut libc::c_void, + data: *const libc::c_void, + size: libc::c_int, + ) -> libc::c_int, + >, +} +#[test] +fn bindgen_test_layout_SDL_VirtualJoystickDesc() { + assert_eq!( + ::core::mem::size_of::(), + 88usize, + concat!("Size of: ", stringify!(SDL_VirtualJoystickDesc)) + ); + assert_eq!( + ::core::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(SDL_VirtualJoystickDesc)) + ); + assert_eq!( + unsafe { + &(*(::core::ptr::null::())).version as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(SDL_VirtualJoystickDesc), + "::", + stringify!(version) + ) + ); + assert_eq!( + unsafe { &(*(::core::ptr::null::())).type_ as *const _ as usize }, + 2usize, + concat!( + "Offset of field: ", + stringify!(SDL_VirtualJoystickDesc), + "::", + stringify!(type_) + ) + ); + assert_eq!( + unsafe { &(*(::core::ptr::null::())).naxes as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(SDL_VirtualJoystickDesc), + "::", + stringify!(naxes) + ) + ); + assert_eq!( + unsafe { + &(*(::core::ptr::null::())).nbuttons as *const _ as usize + }, + 6usize, + concat!( + "Offset of field: ", + stringify!(SDL_VirtualJoystickDesc), + "::", + stringify!(nbuttons) + ) + ); + assert_eq!( + unsafe { &(*(::core::ptr::null::())).nhats as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(SDL_VirtualJoystickDesc), + "::", + stringify!(nhats) + ) + ); + assert_eq!( + unsafe { + &(*(::core::ptr::null::())).vendor_id as *const _ as usize + }, + 10usize, + concat!( + "Offset of field: ", + stringify!(SDL_VirtualJoystickDesc), + "::", + stringify!(vendor_id) + ) + ); + assert_eq!( + unsafe { + &(*(::core::ptr::null::())).product_id as *const _ as usize + }, + 12usize, + concat!( + "Offset of field: ", + stringify!(SDL_VirtualJoystickDesc), + "::", + stringify!(product_id) + ) + ); + assert_eq!( + unsafe { + &(*(::core::ptr::null::())).padding as *const _ as usize + }, + 14usize, + concat!( + "Offset of field: ", + stringify!(SDL_VirtualJoystickDesc), + "::", + stringify!(padding) + ) + ); + assert_eq!( + unsafe { + &(*(::core::ptr::null::())).button_mask as *const _ as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(SDL_VirtualJoystickDesc), + "::", + stringify!(button_mask) + ) + ); + assert_eq!( + unsafe { + &(*(::core::ptr::null::())).axis_mask as *const _ as usize + }, + 20usize, + concat!( + "Offset of field: ", + stringify!(SDL_VirtualJoystickDesc), + "::", + stringify!(axis_mask) + ) + ); + assert_eq!( + unsafe { &(*(::core::ptr::null::())).name as *const _ as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(SDL_VirtualJoystickDesc), + "::", + stringify!(name) + ) + ); + assert_eq!( + unsafe { + &(*(::core::ptr::null::())).userdata as *const _ as usize + }, + 32usize, + concat!( + "Offset of field: ", + stringify!(SDL_VirtualJoystickDesc), + "::", + stringify!(userdata) + ) + ); + assert_eq!( + unsafe { &(*(::core::ptr::null::())).Update as *const _ as usize }, + 40usize, + concat!( + "Offset of field: ", + stringify!(SDL_VirtualJoystickDesc), + "::", + stringify!(Update) + ) + ); + assert_eq!( + unsafe { + &(*(::core::ptr::null::())).SetPlayerIndex as *const _ as usize + }, + 48usize, + concat!( + "Offset of field: ", + stringify!(SDL_VirtualJoystickDesc), + "::", + stringify!(SetPlayerIndex) + ) + ); + assert_eq!( + unsafe { &(*(::core::ptr::null::())).Rumble as *const _ as usize }, + 56usize, + concat!( + "Offset of field: ", + stringify!(SDL_VirtualJoystickDesc), + "::", + stringify!(Rumble) + ) + ); + assert_eq!( + unsafe { + &(*(::core::ptr::null::())).RumbleTriggers as *const _ as usize + }, + 64usize, + concat!( + "Offset of field: ", + stringify!(SDL_VirtualJoystickDesc), + "::", + stringify!(RumbleTriggers) + ) + ); + assert_eq!( + unsafe { &(*(::core::ptr::null::())).SetLED as *const _ as usize }, + 72usize, + concat!( + "Offset of field: ", + stringify!(SDL_VirtualJoystickDesc), + "::", + stringify!(SetLED) + ) + ); + assert_eq!( + unsafe { + &(*(::core::ptr::null::())).SendEffect as *const _ as usize + }, + 80usize, + concat!( + "Offset of field: ", + stringify!(SDL_VirtualJoystickDesc), + "::", + stringify!(SendEffect) + ) + ); +} +extern "C" { + #[doc = " Attach a new virtual joystick with extended properties."] + #[doc = ""] + #[doc = " \\returns the joystick's device index, or -1 if an error occurred."] + #[doc = ""] + #[doc = " \\since This function is available since SDL 2.24.0."] + pub fn SDL_JoystickAttachVirtualEx(desc: *const SDL_VirtualJoystickDesc) -> libc::c_int; +} extern "C" { #[doc = " Detach a virtual joystick."] #[doc = ""] @@ -13639,6 +14504,10 @@ extern "C" { #[doc = " the following: SDL_PollEvent, SDL_PumpEvents, SDL_WaitEventTimeout,"] #[doc = " SDL_WaitEvent."] #[doc = ""] + #[doc = " Note that when sending trigger axes, you should scale the value to the full"] + #[doc = " range of Sint16. For example, a trigger at rest would have the value of"] + #[doc = " `SDL_JOYSTICK_AXIS_MIN`."] + #[doc = ""] #[doc = " \\param joystick the virtual joystick on which to set state."] #[doc = " \\param axis the specific axis on the virtual joystick to set."] #[doc = " \\param value the new value for the specified axis."] @@ -13706,6 +14575,18 @@ extern "C" { #[doc = " \\sa SDL_JoystickOpen"] pub fn SDL_JoystickName(joystick: *mut SDL_Joystick) -> *const libc::c_char; } +extern "C" { + #[doc = " Get the implementation dependent path of a joystick."] + #[doc = ""] + #[doc = " \\param joystick the SDL_Joystick obtained from SDL_JoystickOpen()"] + #[doc = " \\returns the path of the selected joystick. If no path can be found, this"] + #[doc = " function returns NULL; call SDL_GetError() for more information."] + #[doc = ""] + #[doc = " \\since This function is available since SDL 2.24.0."] + #[doc = ""] + #[doc = " \\sa SDL_JoystickPathForIndex"] + pub fn SDL_JoystickPath(joystick: *mut SDL_Joystick) -> *const libc::c_char; +} extern "C" { #[doc = " Get the player index of an opened joystick."] #[doc = ""] @@ -13722,7 +14603,8 @@ extern "C" { #[doc = " Set the player index of an opened joystick."] #[doc = ""] #[doc = " \\param joystick the SDL_Joystick obtained from SDL_JoystickOpen()"] - #[doc = " \\param player_index the player index to set."] + #[doc = " \\param player_index Player index to assign to this joystick, or -1 to clear"] + #[doc = " the player index and turn off player LEDs."] #[doc = ""] #[doc = " \\since This function is available since SDL 2.0.12."] pub fn SDL_JoystickSetPlayerIndex(joystick: *mut SDL_Joystick, player_index: libc::c_int); @@ -13776,6 +14658,18 @@ extern "C" { #[doc = " \\since This function is available since SDL 2.0.6."] pub fn SDL_JoystickGetProductVersion(joystick: *mut SDL_Joystick) -> Uint16; } +extern "C" { + #[doc = " Get the firmware version of an opened joystick, if available."] + #[doc = ""] + #[doc = " If the firmware version isn't available this function returns 0."] + #[doc = ""] + #[doc = " \\param joystick the SDL_Joystick obtained from SDL_JoystickOpen()"] + #[doc = " \\returns the firmware version of the selected joystick, or 0 if"] + #[doc = " unavailable."] + #[doc = ""] + #[doc = " \\since This function is available since SDL 2.24.0."] + pub fn SDL_JoystickGetFirmwareVersion(joystick: *mut SDL_Joystick) -> Uint16; +} extern "C" { #[doc = " Get the serial number of an opened joystick, if available."] #[doc = ""] @@ -13832,6 +14726,30 @@ extern "C" { #[doc = " \\sa SDL_JoystickGetGUIDString"] pub fn SDL_JoystickGetGUIDFromString(pchGUID: *const libc::c_char) -> SDL_JoystickGUID; } +extern "C" { + #[doc = " Get the device information encoded in a SDL_JoystickGUID structure"] + #[doc = ""] + #[doc = " \\param guid the SDL_JoystickGUID you wish to get info about"] + #[doc = " \\param vendor A pointer filled in with the device VID, or 0 if not"] + #[doc = " available"] + #[doc = " \\param product A pointer filled in with the device PID, or 0 if not"] + #[doc = " available"] + #[doc = " \\param version A pointer filled in with the device version, or 0 if not"] + #[doc = " available"] + #[doc = " \\param crc16 A pointer filled in with a CRC used to distinguish different"] + #[doc = " products with the same VID/PID, or 0 if not available"] + #[doc = ""] + #[doc = " \\since This function is available since SDL 2.26.0."] + #[doc = ""] + #[doc = " \\sa SDL_JoystickGetDeviceGUID"] + pub fn SDL_GetJoystickGUIDInfo( + guid: SDL_JoystickGUID, + vendor: *mut Uint16, + product: *mut Uint16, + version: *mut Uint16, + crc16: *mut Uint16, + ); +} extern "C" { #[doc = " Get the status of a specified joystick."] #[doc = ""] @@ -14087,9 +15005,9 @@ extern "C" { #[doc = " Each call to this function cancels any previous trigger rumble effect, and"] #[doc = " calling it with 0 intensity stops any rumbling."] #[doc = ""] - #[doc = " Note that this function is for _trigger_ rumble; the first joystick to"] - #[doc = " support this was the PlayStation 5's DualShock 5 controller. If you want"] - #[doc = " the (more common) whole-controller rumble, use SDL_JoystickRumble()"] + #[doc = " Note that this is rumbling of the _triggers_ and not the game controller as"] + #[doc = " a whole. This is currently only supported on Xbox One controllers. If you"] + #[doc = " want the (more common) whole-controller rumble, use SDL_JoystickRumble()"] #[doc = " instead."] #[doc = ""] #[doc = " \\param joystick The joystick to vibrate"] @@ -14226,6 +15144,14 @@ pub enum SDL_SensorType { SDL_SENSOR_ACCEL = 1, #[doc = "< Gyroscope"] SDL_SENSOR_GYRO = 2, + #[doc = "< Accelerometer for left Joy-Con controller and Wii nunchuk"] + SDL_SENSOR_ACCEL_L = 3, + #[doc = "< Gyroscope for left Joy-Con controller"] + SDL_SENSOR_GYRO_L = 4, + #[doc = "< Accelerometer for right Joy-Con controller"] + SDL_SENSOR_ACCEL_R = 5, + #[doc = "< Gyroscope for right Joy-Con controller"] + SDL_SENSOR_GYRO_R = 6, } extern "C" { #[doc = " Locking for multi-threaded access to the sensor API"] @@ -14361,6 +15287,27 @@ extern "C" { num_values: libc::c_int, ) -> libc::c_int; } +extern "C" { + #[doc = " Get the current state of an opened sensor with the timestamp of the last"] + #[doc = " update."] + #[doc = ""] + #[doc = " The number of values and interpretation of the data is sensor dependent."] + #[doc = ""] + #[doc = " \\param sensor The SDL_Sensor object to query"] + #[doc = " \\param timestamp A pointer filled with the timestamp in microseconds of the"] + #[doc = " current sensor reading if available, or 0 if not"] + #[doc = " \\param data A pointer filled with the current sensor state"] + #[doc = " \\param num_values The number of values to write to data"] + #[doc = " \\returns 0 or -1 if an error occurred."] + #[doc = ""] + #[doc = " \\since This function is available since SDL 2.26.0."] + pub fn SDL_SensorGetDataWithTimestamp( + sensor: *mut SDL_Sensor, + timestamp: *mut Uint64, + data: *mut f32, + num_values: libc::c_int, + ) -> libc::c_int; +} extern "C" { #[doc = " Close a sensor previously opened with SDL_SensorOpen()."] #[doc = ""] @@ -14401,6 +15348,11 @@ pub enum SDL_GameControllerType { SDL_CONTROLLER_TYPE_PS5 = 7, SDL_CONTROLLER_TYPE_AMAZON_LUNA = 8, SDL_CONTROLLER_TYPE_GOOGLE_STADIA = 9, + SDL_CONTROLLER_TYPE_NVIDIA_SHIELD = 10, + SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_JOYCON_LEFT = 11, + SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_JOYCON_RIGHT = 12, + SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_JOYCON_PAIR = 13, + SDL_CONTROLLER_TYPE_MAX = 14, } #[repr(u32)] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] @@ -14718,6 +15670,24 @@ extern "C" { #[doc = " \\sa SDL_IsGameController"] pub fn SDL_GameControllerNameForIndex(joystick_index: libc::c_int) -> *const libc::c_char; } +extern "C" { + #[doc = " Get the implementation dependent path for the game controller."] + #[doc = ""] + #[doc = " This function can be called before any controllers are opened."] + #[doc = ""] + #[doc = " `joystick_index` is the same as the `device_index` passed to"] + #[doc = " SDL_JoystickOpen()."] + #[doc = ""] + #[doc = " \\param joystick_index the device_index of a device, from zero to"] + #[doc = " SDL_NumJoysticks()-1"] + #[doc = " \\returns the implementation-dependent path for the game controller, or NULL"] + #[doc = " if there is no path or the index is invalid."] + #[doc = ""] + #[doc = " \\since This function is available since SDL 2.24.0."] + #[doc = ""] + #[doc = " \\sa SDL_GameControllerPath"] + pub fn SDL_GameControllerPathForIndex(joystick_index: libc::c_int) -> *const libc::c_char; +} extern "C" { #[doc = " Get the type of a game controller."] #[doc = ""] @@ -14811,6 +15781,22 @@ extern "C" { #[doc = " \\sa SDL_GameControllerOpen"] pub fn SDL_GameControllerName(gamecontroller: *mut SDL_GameController) -> *const libc::c_char; } +extern "C" { + #[doc = " Get the implementation-dependent path for an opened game controller."] + #[doc = ""] + #[doc = " This is the same path as returned by SDL_GameControllerNameForIndex(), but"] + #[doc = " it takes a controller identifier instead of the (unstable) device index."] + #[doc = ""] + #[doc = " \\param gamecontroller a game controller identifier previously returned by"] + #[doc = " SDL_GameControllerOpen()"] + #[doc = " \\returns the implementation dependent path for the game controller, or NULL"] + #[doc = " if there is no path or the identifier passed is invalid."] + #[doc = ""] + #[doc = " \\since This function is available since SDL 2.24.0."] + #[doc = ""] + #[doc = " \\sa SDL_GameControllerPathForIndex"] + pub fn SDL_GameControllerPath(gamecontroller: *mut SDL_GameController) -> *const libc::c_char; +} extern "C" { #[doc = " Get the type of this currently opened controller"] #[doc = ""] @@ -14841,7 +15827,8 @@ extern "C" { #[doc = " Set the player index of an opened game controller."] #[doc = ""] #[doc = " \\param gamecontroller the game controller object to adjust."] - #[doc = " \\param player_index Player index to assign to this controller."] + #[doc = " \\param player_index Player index to assign to this controller, or -1 to"] + #[doc = " clear the player index and turn off player LEDs."] #[doc = ""] #[doc = " \\since This function is available since SDL 2.0.12."] pub fn SDL_GameControllerSetPlayerIndex( @@ -14882,6 +15869,17 @@ extern "C" { #[doc = " \\since This function is available since SDL 2.0.6."] pub fn SDL_GameControllerGetProductVersion(gamecontroller: *mut SDL_GameController) -> Uint16; } +extern "C" { + #[doc = " Get the firmware version of an opened controller, if available."] + #[doc = ""] + #[doc = " If the firmware version isn't available this function returns 0."] + #[doc = ""] + #[doc = " \\param gamecontroller the game controller object to query."] + #[doc = " \\return the controller firmware version, or zero if unavailable."] + #[doc = ""] + #[doc = " \\since This function is available since SDL 2.24.0."] + pub fn SDL_GameControllerGetFirmwareVersion(gamecontroller: *mut SDL_GameController) -> Uint16; +} extern "C" { #[doc = " Get the serial number of an opened controller, if available."] #[doc = ""] @@ -14896,6 +15894,18 @@ extern "C" { gamecontroller: *mut SDL_GameController, ) -> *const libc::c_char; } +extern "C" { + #[doc = " Get the Steam Input handle of an opened controller, if available."] + #[doc = ""] + #[doc = " Returns an InputHandle_t for the controller that can be used with Steam Input API:"] + #[doc = " https://partner.steamgames.com/doc/api/ISteamInput"] + #[doc = ""] + #[doc = " \\param gamecontroller the game controller object to query."] + #[doc = " \\returns the gamepad handle, or 0 if unavailable."] + #[doc = ""] + #[doc = " \\since This function is available since SDL 2.30.0."] + pub fn SDL_GameControllerGetSteamHandle(gamecontroller: *mut SDL_GameController) -> Uint64; +} extern "C" { #[doc = " Check if a controller has been opened and is currently connected."] #[doc = ""] @@ -14968,7 +15978,9 @@ extern "C" { #[doc = " and are centered within ~8000 of zero, though advanced UI will allow users to set"] #[doc = " or autodetect the dead zone, which varies between controllers."] #[doc = ""] -#[doc = " Trigger axis values range from 0 to SDL_JOYSTICK_AXIS_MAX."] +#[doc = " Trigger axis values range from 0 (released) to SDL_JOYSTICK_AXIS_MAX"] +#[doc = " (fully pressed) when reported by SDL_GameControllerGetAxis(). Note that this is not the"] +#[doc = " same range that will be reported by the lower-level SDL_GetJoystickAxis()."] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub enum SDL_GameControllerAxis { SDL_CONTROLLER_AXIS_INVALID = -1, @@ -15054,8 +16066,13 @@ extern "C" { #[doc = ""] #[doc = " The axis indices start at index 0."] #[doc = ""] - #[doc = " The state is a value ranging from -32768 to 32767. Triggers, however, range"] - #[doc = " from 0 to 32767 (they never return a negative value)."] + #[doc = " For thumbsticks, the state is a value ranging from -32768 (up/left)"] + #[doc = " to 32767 (down/right)."] + #[doc = ""] + #[doc = " Triggers range from 0 when released to 32767 when fully pressed, and"] + #[doc = " never return a negative value. Note that this differs from the value"] + #[doc = " reported by the lower-level SDL_GetJoystickAxis(), which normally uses"] + #[doc = " the full range."] #[doc = ""] #[doc = " \\param gamecontroller a game controller"] #[doc = " \\param axis an axis index (one of the SDL_GameControllerAxis values)"] @@ -15121,7 +16138,7 @@ extern "C" { #[doc = " The caller should not SDL_free() the returned string."] #[doc = ""] #[doc = " \\param button an enum value for a given SDL_GameControllerButton"] - #[doc = " \\returns a string for the given button, or NULL if an invalid axis is"] + #[doc = " \\returns a string for the given button, or NULL if an invalid button is"] #[doc = " specified. The string returned is of the format used by"] #[doc = " SDL_GameController mapping strings."] #[doc = ""] @@ -15288,6 +16305,30 @@ extern "C" { num_values: libc::c_int, ) -> libc::c_int; } +extern "C" { + #[doc = " Get the current state of a game controller sensor with the timestamp of the"] + #[doc = " last update."] + #[doc = ""] + #[doc = " The number of values and interpretation of the data is sensor dependent."] + #[doc = " See SDL_sensor.h for the details for each type of sensor."] + #[doc = ""] + #[doc = " \\param gamecontroller The controller to query"] + #[doc = " \\param type The type of sensor to query"] + #[doc = " \\param timestamp A pointer filled with the timestamp in microseconds of the"] + #[doc = " current sensor reading if available, or 0 if not"] + #[doc = " \\param data A pointer filled with the current sensor state"] + #[doc = " \\param num_values The number of values to write to data"] + #[doc = " \\return 0 or -1 if an error occurred."] + #[doc = ""] + #[doc = " \\since This function is available since SDL 2.26.0."] + pub fn SDL_GameControllerGetSensorDataWithTimestamp( + gamecontroller: *mut SDL_GameController, + type_: SDL_SensorType, + timestamp: *mut Uint64, + data: *mut f32, + num_values: libc::c_int, + ) -> libc::c_int; +} extern "C" { #[doc = " Start a rumble effect on a game controller."] #[doc = ""] @@ -15319,8 +16360,9 @@ extern "C" { #[doc = " calling it with 0 intensity stops any rumbling."] #[doc = ""] #[doc = " Note that this is rumbling of the _triggers_ and not the game controller as"] - #[doc = " a whole. The first controller to offer this feature was the PlayStation 5's"] - #[doc = " DualShock 5."] + #[doc = " a whole. This is currently only supported on Xbox One controllers. If you"] + #[doc = " want the (more common) whole-controller rumble, use"] + #[doc = " SDL_GameControllerRumble() instead."] #[doc = ""] #[doc = " \\param gamecontroller The controller to vibrate"] #[doc = " \\param left_rumble The intensity of the left trigger rumble motor, from 0"] @@ -15551,6 +16593,13 @@ extern "C" { #[doc = " \\sa SDL_GetNumTouchDevices"] pub fn SDL_GetTouchDevice(index: libc::c_int) -> SDL_TouchID; } +extern "C" { + #[doc = " Get the touch device name as reported from the driver or NULL if the index"] + #[doc = " is invalid."] + #[doc = ""] + #[doc = " \\since This function is available since SDL 2.0.22."] + pub fn SDL_GetTouchName(index: libc::c_int) -> *const libc::c_char; +} extern "C" { #[doc = " Get the type of the given touch device."] #[doc = ""] @@ -15691,6 +16740,8 @@ pub enum SDL_EventType { #[doc = "< Keymap changed due to a system event such as an"] #[doc = "input language or keyboard layout change."] SDL_KEYMAPCHANGED = 772, + #[doc = "< Extended keyboard text editing (composition)"] + SDL_TEXTEDITING_EXT = 773, #[doc = "< Mouse moved"] SDL_MOUSEMOTION = 1024, #[doc = "< Mouse button pressed"] @@ -15713,6 +16764,8 @@ pub enum SDL_EventType { SDL_JOYDEVICEADDED = 1541, #[doc = "< An opened joystick has been removed"] SDL_JOYDEVICEREMOVED = 1542, + #[doc = "< Joystick battery level change"] + SDL_JOYBATTERYUPDATED = 1543, #[doc = "< Game controller axis motion"] SDL_CONTROLLERAXISMOTION = 1616, #[doc = "< Game controller button pressed"] @@ -15733,13 +16786,16 @@ pub enum SDL_EventType { SDL_CONTROLLERTOUCHPADUP = 1624, #[doc = "< Game controller sensor was updated"] SDL_CONTROLLERSENSORUPDATE = 1625, + SDL_CONTROLLERUPDATECOMPLETE_RESERVED_FOR_SDL3 = 1626, + #[doc = "< Game controller Steam handle has changed"] + SDL_CONTROLLERSTEAMHANDLEUPDATED = 1627, SDL_FINGERDOWN = 1792, SDL_FINGERUP = 1793, SDL_FINGERMOTION = 1794, SDL_DOLLARGESTURE = 2048, SDL_DOLLARRECORD = 2049, SDL_MULTIGESTURE = 2050, - #[doc = "< The clipboard changed"] + #[doc = "< The clipboard or primary selection changed"] SDL_CLIPBOARDUPDATE = 2304, #[doc = "< The system requests a file open"] SDL_DROPFILE = 4096, @@ -16244,6 +17300,101 @@ fn bindgen_test_layout_SDL_TextEditingEvent() { ) ); } +#[doc = " \\brief Extended keyboard text editing event structure (event.editExt.*) when text would be"] +#[doc = " truncated if stored in the text buffer SDL_TextEditingEvent"] +#[repr(C)] +#[derive(Copy, Clone)] +pub struct SDL_TextEditingExtEvent { + #[doc = "< ::SDL_TEXTEDITING_EXT"] + pub type_: Uint32, + #[doc = "< In milliseconds, populated using SDL_GetTicks()"] + pub timestamp: Uint32, + #[doc = "< The window with keyboard focus, if any"] + pub windowID: Uint32, + #[doc = "< The editing text, which should be freed with SDL_free(), and will not be NULL"] + pub text: *mut libc::c_char, + #[doc = "< The start cursor of selected editing text"] + pub start: Sint32, + #[doc = "< The length of selected editing text"] + pub length: Sint32, +} +#[test] +fn bindgen_test_layout_SDL_TextEditingExtEvent() { + assert_eq!( + ::core::mem::size_of::(), + 32usize, + concat!("Size of: ", stringify!(SDL_TextEditingExtEvent)) + ); + assert_eq!( + ::core::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(SDL_TextEditingExtEvent)) + ); + assert_eq!( + unsafe { &(*(::core::ptr::null::())).type_ as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(SDL_TextEditingExtEvent), + "::", + stringify!(type_) + ) + ); + assert_eq!( + unsafe { + &(*(::core::ptr::null::())).timestamp as *const _ as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(SDL_TextEditingExtEvent), + "::", + stringify!(timestamp) + ) + ); + assert_eq!( + unsafe { + &(*(::core::ptr::null::())).windowID as *const _ as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(SDL_TextEditingExtEvent), + "::", + stringify!(windowID) + ) + ); + assert_eq!( + unsafe { &(*(::core::ptr::null::())).text as *const _ as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(SDL_TextEditingExtEvent), + "::", + stringify!(text) + ) + ); + assert_eq!( + unsafe { &(*(::core::ptr::null::())).start as *const _ as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(SDL_TextEditingExtEvent), + "::", + stringify!(start) + ) + ); + assert_eq!( + unsafe { &(*(::core::ptr::null::())).length as *const _ as usize }, + 28usize, + concat!( + "Offset of field: ", + stringify!(SDL_TextEditingExtEvent), + "::", + stringify!(length) + ) + ); +} #[doc = " \\brief Keyboard text input event structure (event.text.*)"] #[repr(C)] #[derive(Copy, Clone)] @@ -16595,12 +17746,16 @@ pub struct SDL_MouseWheelEvent { pub preciseX: f32, #[doc = "< The amount scrolled vertically, positive away from the user and negative toward the user, with float precision (added in 2.0.18)"] pub preciseY: f32, + #[doc = "< X coordinate, relative to window (added in 2.26.0)"] + pub mouseX: Sint32, + #[doc = "< Y coordinate, relative to window (added in 2.26.0)"] + pub mouseY: Sint32, } #[test] fn bindgen_test_layout_SDL_MouseWheelEvent() { assert_eq!( ::core::mem::size_of::(), - 36usize, + 44usize, concat!("Size of: ", stringify!(SDL_MouseWheelEvent)) ); assert_eq!( @@ -16698,6 +17853,26 @@ fn bindgen_test_layout_SDL_MouseWheelEvent() { stringify!(preciseY) ) ); + assert_eq!( + unsafe { &(*(::core::ptr::null::())).mouseX as *const _ as usize }, + 36usize, + concat!( + "Offset of field: ", + stringify!(SDL_MouseWheelEvent), + "::", + stringify!(mouseX) + ) + ); + assert_eq!( + unsafe { &(*(::core::ptr::null::())).mouseY as *const _ as usize }, + 40usize, + concat!( + "Offset of field: ", + stringify!(SDL_MouseWheelEvent), + "::", + stringify!(mouseY) + ) + ); } #[doc = " \\brief Joystick axis motion event structure (event.jaxis.*)"] #[repr(C)] @@ -17203,6 +18378,72 @@ fn bindgen_test_layout_SDL_JoyDeviceEvent() { ) ); } +#[doc = " \\brief Joysick battery level change event structure (event.jbattery.*)"] +#[repr(C)] +#[derive(Copy, Clone)] +pub struct SDL_JoyBatteryEvent { + #[doc = "< ::SDL_JOYBATTERYUPDATED"] + pub type_: Uint32, + #[doc = "< In milliseconds, populated using SDL_GetTicks()"] + pub timestamp: Uint32, + #[doc = "< The joystick instance id"] + pub which: SDL_JoystickID, + #[doc = "< The joystick battery level"] + pub level: SDL_JoystickPowerLevel, +} +#[test] +fn bindgen_test_layout_SDL_JoyBatteryEvent() { + assert_eq!( + ::core::mem::size_of::(), + 16usize, + concat!("Size of: ", stringify!(SDL_JoyBatteryEvent)) + ); + assert_eq!( + ::core::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(SDL_JoyBatteryEvent)) + ); + assert_eq!( + unsafe { &(*(::core::ptr::null::())).type_ as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(SDL_JoyBatteryEvent), + "::", + stringify!(type_) + ) + ); + assert_eq!( + unsafe { &(*(::core::ptr::null::())).timestamp as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(SDL_JoyBatteryEvent), + "::", + stringify!(timestamp) + ) + ); + assert_eq!( + unsafe { &(*(::core::ptr::null::())).which as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(SDL_JoyBatteryEvent), + "::", + stringify!(which) + ) + ); + assert_eq!( + unsafe { &(*(::core::ptr::null::())).level as *const _ as usize }, + 12usize, + concat!( + "Offset of field: ", + stringify!(SDL_JoyBatteryEvent), + "::", + stringify!(level) + ) + ); +} #[doc = " \\brief Game controller axis motion event structure (event.caxis.*)"] #[repr(C)] #[derive(Copy, Clone)] @@ -17453,7 +18694,7 @@ fn bindgen_test_layout_SDL_ControllerButtonEvent() { #[repr(C)] #[derive(Copy, Clone)] pub struct SDL_ControllerDeviceEvent { - #[doc = "< ::SDL_CONTROLLERDEVICEADDED, ::SDL_CONTROLLERDEVICEREMOVED, or ::SDL_CONTROLLERDEVICEREMAPPED"] + #[doc = "< ::SDL_CONTROLLERDEVICEADDED, ::SDL_CONTROLLERDEVICEREMOVED, ::SDL_CONTROLLERDEVICEREMAPPED, or ::SDL_CONTROLLERSTEAMHANDLEUPDATED"] pub type_: Uint32, #[doc = "< In milliseconds, populated using SDL_GetTicks()"] pub timestamp: Uint32, @@ -17649,17 +18890,19 @@ pub struct SDL_ControllerSensorEvent { pub sensor: Sint32, #[doc = "< Up to 3 values from the sensor, as defined in SDL_sensor.h"] pub data: [f32; 3usize], + #[doc = "< The timestamp of the sensor reading in microseconds, if the hardware provides this information."] + pub timestamp_us: Uint64, } #[test] fn bindgen_test_layout_SDL_ControllerSensorEvent() { assert_eq!( ::core::mem::size_of::(), - 28usize, + 40usize, concat!("Size of: ", stringify!(SDL_ControllerSensorEvent)) ); assert_eq!( ::core::mem::align_of::(), - 4usize, + 8usize, concat!("Alignment of ", stringify!(SDL_ControllerSensorEvent)) ); assert_eq!( @@ -17720,6 +18963,18 @@ fn bindgen_test_layout_SDL_ControllerSensorEvent() { stringify!(data) ) ); + assert_eq!( + unsafe { + &(*(::core::ptr::null::())).timestamp_us as *const _ as usize + }, + 32usize, + concat!( + "Offset of field: ", + stringify!(SDL_ControllerSensorEvent), + "::", + stringify!(timestamp_us) + ) + ); } #[doc = " \\brief Audio device event structure (event.adevice.*)"] #[repr(C)] @@ -18278,17 +19533,19 @@ pub struct SDL_SensorEvent { pub which: Sint32, #[doc = "< Up to 6 values from the sensor - additional values can be queried using SDL_SensorGetData()"] pub data: [f32; 6usize], + #[doc = "< The timestamp of the sensor reading in microseconds, if the hardware provides this information."] + pub timestamp_us: Uint64, } #[test] fn bindgen_test_layout_SDL_SensorEvent() { assert_eq!( ::core::mem::size_of::(), - 36usize, + 48usize, concat!("Size of: ", stringify!(SDL_SensorEvent)) ); assert_eq!( ::core::mem::align_of::(), - 4usize, + 8usize, concat!("Alignment of ", stringify!(SDL_SensorEvent)) ); assert_eq!( @@ -18331,6 +19588,16 @@ fn bindgen_test_layout_SDL_SensorEvent() { stringify!(data) ) ); + assert_eq!( + unsafe { &(*(::core::ptr::null::())).timestamp_us as *const _ as usize }, + 40usize, + concat!( + "Offset of field: ", + stringify!(SDL_SensorEvent), + "::", + stringify!(timestamp_us) + ) + ); } #[doc = " \\brief The \"quit requested\" event"] #[repr(C)] @@ -18374,48 +19641,6 @@ fn bindgen_test_layout_SDL_QuitEvent() { ) ); } -#[doc = " \\brief OS Specific event"] -#[repr(C)] -#[derive(Copy, Clone)] -pub struct SDL_OSEvent { - #[doc = "< ::SDL_QUIT"] - pub type_: Uint32, - #[doc = "< In milliseconds, populated using SDL_GetTicks()"] - pub timestamp: Uint32, -} -#[test] -fn bindgen_test_layout_SDL_OSEvent() { - assert_eq!( - ::core::mem::size_of::(), - 8usize, - concat!("Size of: ", stringify!(SDL_OSEvent)) - ); - assert_eq!( - ::core::mem::align_of::(), - 4usize, - concat!("Alignment of ", stringify!(SDL_OSEvent)) - ); - assert_eq!( - unsafe { &(*(::core::ptr::null::())).type_ as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(SDL_OSEvent), - "::", - stringify!(type_) - ) - ); - assert_eq!( - unsafe { &(*(::core::ptr::null::())).timestamp as *const _ as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(SDL_OSEvent), - "::", - stringify!(timestamp) - ) - ); -} #[doc = " \\brief A user-defined event type (event.user.*)"] #[repr(C)] #[derive(Copy, Clone)] @@ -18579,6 +19804,8 @@ pub union SDL_Event { pub key: SDL_KeyboardEvent, #[doc = "< Text editing event data"] pub edit: SDL_TextEditingEvent, + #[doc = "< Extended text editing event data"] + pub editExt: SDL_TextEditingExtEvent, #[doc = "< Text input event data"] pub text: SDL_TextInputEvent, #[doc = "< Mouse motion event data"] @@ -18597,6 +19824,8 @@ pub union SDL_Event { pub jbutton: SDL_JoyButtonEvent, #[doc = "< Joystick device change event data"] pub jdevice: SDL_JoyDeviceEvent, + #[doc = "< Joystick battery event data"] + pub jbattery: SDL_JoyBatteryEvent, #[doc = "< Game Controller axis event data"] pub caxis: SDL_ControllerAxisEvent, #[doc = "< Game Controller button event data"] @@ -18700,6 +19929,16 @@ fn bindgen_test_layout_SDL_Event() { stringify!(edit) ) ); + assert_eq!( + unsafe { &(*(::core::ptr::null::())).editExt as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(SDL_Event), + "::", + stringify!(editExt) + ) + ); assert_eq!( unsafe { &(*(::core::ptr::null::())).text as *const _ as usize }, 0usize, @@ -18790,6 +20029,16 @@ fn bindgen_test_layout_SDL_Event() { stringify!(jdevice) ) ); + assert_eq!( + unsafe { &(*(::core::ptr::null::())).jbattery as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(SDL_Event), + "::", + stringify!(jbattery) + ) + ); assert_eq!( unsafe { &(*(::core::ptr::null::())).caxis as *const _ as usize }, 0usize, @@ -18941,7 +20190,6 @@ fn bindgen_test_layout_SDL_Event() { ) ); } -pub type SDL_compile_time_assert_SDL_Event = [libc::c_int; 1usize]; extern "C" { #[doc = " Pump the event loop, gathering events from the input devices."] #[doc = ""] @@ -19414,7 +20662,11 @@ extern "C" { #[doc = " - `parent`: the containing directory of the bundle. For example:"] #[doc = " `/Applications/SDLApp/`"] #[doc = ""] - #[doc = " The returned path is guaranteed to end with a path separator ('\\' on"] + #[doc = " **Nintendo 3DS Specific Functionality**: This function returns \"romfs\""] + #[doc = " directory of the application as it is uncommon to store resources outside"] + #[doc = " the executable. As such it is not a writable directory."] + #[doc = ""] + #[doc = " The returned path is guaranteed to end with a path separator ('\\\\' on"] #[doc = " Windows, '/' on most other platforms)."] #[doc = ""] #[doc = " The pointer returned is owned by the caller. Please call SDL_free() on the"] @@ -19445,7 +20697,7 @@ extern "C" { #[doc = ""] #[doc = " `C:\\\\Users\\\\bob\\\\AppData\\\\Roaming\\\\My Company\\\\My Program Name\\\\`"] #[doc = ""] - #[doc = " On Linux, the string might look like\""] + #[doc = " On Linux, the string might look like:"] #[doc = ""] #[doc = " `/home/bob/.local/share/My Program Name/`"] #[doc = ""] @@ -19469,7 +20721,7 @@ extern "C" { #[doc = " - ...only use letters, numbers, and spaces. Avoid punctuation like \"Game"] #[doc = " Name 2: Bad Guy's Revenge!\" ... \"Game Name 2\" is sufficient."] #[doc = ""] - #[doc = " The returned path is guaranteed to end with a path separator ('\\' on"] + #[doc = " The returned path is guaranteed to end with a path separator ('\\\\' on"] #[doc = " Windows, '/' on most other platforms)."] #[doc = ""] #[doc = " The pointer returned is owned by the caller. Please call SDL_free() on the"] @@ -21936,6 +23188,36 @@ extern "C" { #[doc = " \\sa SDL_SetHintWithPriority"] pub fn SDL_SetHint(name: *const libc::c_char, value: *const libc::c_char) -> SDL_bool; } +extern "C" { + #[doc = " Reset a hint to the default value."] + #[doc = ""] + #[doc = " This will reset a hint to the value of the environment variable, or NULL if"] + #[doc = " the environment isn't set. Callbacks will be called normally with this"] + #[doc = " change."] + #[doc = ""] + #[doc = " \\param name the hint to set"] + #[doc = " \\returns SDL_TRUE if the hint was set, SDL_FALSE otherwise."] + #[doc = ""] + #[doc = " \\since This function is available since SDL 2.24.0."] + #[doc = ""] + #[doc = " \\sa SDL_GetHint"] + #[doc = " \\sa SDL_SetHint"] + pub fn SDL_ResetHint(name: *const libc::c_char) -> SDL_bool; +} +extern "C" { + #[doc = " Reset all hints to the default values."] + #[doc = ""] + #[doc = " This will reset all hints to the value of the associated environment"] + #[doc = " variable, or NULL if the environment isn't set. Callbacks will be called"] + #[doc = " normally with this change."] + #[doc = ""] + #[doc = " \\since This function is available since SDL 2.26.0."] + #[doc = ""] + #[doc = " \\sa SDL_GetHint"] + #[doc = " \\sa SDL_SetHint"] + #[doc = " \\sa SDL_ResetHint"] + pub fn SDL_ResetHints(); +} extern "C" { #[doc = " Get the value of a hint."] #[doc = ""] @@ -22013,9 +23295,16 @@ extern "C" { extern "C" { #[doc = " Clear all hints."] #[doc = ""] - #[doc = " This function is automatically called during SDL_Quit()."] + #[doc = " This function is automatically called during SDL_Quit(), and deletes all"] + #[doc = " callbacks without calling them and frees all memory associated with hints."] + #[doc = " If you're calling this from application code you probably want to call"] + #[doc = " SDL_ResetHints() instead."] + #[doc = ""] + #[doc = " This function will be removed from the API the next time we rev the ABI."] #[doc = ""] #[doc = " \\since This function is available since SDL 2.0.0."] + #[doc = ""] + #[doc = " \\sa SDL_ResetHints"] pub fn SDL_ClearHints(); } extern "C" { @@ -22077,7 +23366,7 @@ extern "C" { #[doc = " By default the application category is enabled at the INFO level,"] #[doc = " the assert category is enabled at the WARN level, test is enabled"] #[doc = " at the VERBOSE level and all other categories are enabled at the"] -#[doc = " CRITICAL level."] +#[doc = " ERROR level."] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub enum SDL_LogCategory { SDL_LOG_CATEGORY_APPLICATION = 0, @@ -22782,7 +24071,7 @@ extern "C" { #[doc = ""] #[doc = " \\since This function is available since SDL 2.0.14."] #[doc = ""] - #[doc = " \\sa SDL_MetalCreateView"] + #[doc = " \\sa SDL_Metal_CreateView"] pub fn SDL_Metal_GetLayer(view: SDL_MetalView) -> *mut libc::c_void; } extern "C" { @@ -22791,6 +24080,7 @@ extern "C" { #[doc = ""] #[doc = " \\param window SDL_Window from which the drawable size should be queried"] #[doc = " \\param w Pointer to variable for storing the width in pixels, may be NULL"] + #[doc = " \\param h Pointer to variable for storing the height in pixels, may be NULL"] #[doc = ""] #[doc = " \\since This function is available since SDL 2.0.14."] #[doc = ""] @@ -22833,16 +24123,17 @@ extern "C" { #[doc = " It's possible a platform can only report battery percentage or time left"] #[doc = " but not both."] #[doc = ""] - #[doc = " \\param secs seconds of battery life left, you can pass a NULL here if you"] - #[doc = " don't care, will return -1 if we can't determine a value, or"] - #[doc = " we're not running on a battery"] - #[doc = " \\param pct percentage of battery life left, between 0 and 100, you can pass"] - #[doc = " a NULL here if you don't care, will return -1 if we can't"] - #[doc = " determine a value, or we're not running on a battery"] + #[doc = " \\param seconds seconds of battery life left, you can pass a NULL here if"] + #[doc = " you don't care, will return -1 if we can't determine a"] + #[doc = " value, or we're not running on a battery"] + #[doc = " \\param percent percentage of battery life left, between 0 and 100, you can"] + #[doc = " pass a NULL here if you don't care, will return -1 if we"] + #[doc = " can't determine a value, or we're not running on a battery"] #[doc = " \\returns an SDL_PowerState enum representing the current battery state."] #[doc = ""] #[doc = " \\since This function is available since SDL 2.0.0."] - pub fn SDL_GetPowerInfo(secs: *mut libc::c_int, pct: *mut libc::c_int) -> SDL_PowerState; + pub fn SDL_GetPowerInfo(seconds: *mut libc::c_int, percent: *mut libc::c_int) + -> SDL_PowerState; } #[repr(u32)] #[doc = " Flags used when creating a rendering context"] @@ -23179,6 +24470,16 @@ extern "C" { #[doc = " \\sa SDL_CreateRenderer"] pub fn SDL_GetRenderer(window: *mut SDL_Window) -> *mut SDL_Renderer; } +extern "C" { + #[doc = " Get the window associated with a renderer."] + #[doc = ""] + #[doc = " \\param renderer the renderer to query"] + #[doc = " \\returns the window on success or NULL on failure; call SDL_GetError() for"] + #[doc = " more information."] + #[doc = ""] + #[doc = " \\since This function is available since SDL 2.0.22."] + pub fn SDL_RenderGetWindow(renderer: *mut SDL_Renderer) -> *mut SDL_Window; +} extern "C" { #[doc = " Get information about a rendering context."] #[doc = ""] @@ -23281,11 +24582,15 @@ extern "C" { #[doc = " \\param texture the texture to query"] #[doc = " \\param format a pointer filled in with the raw format of the texture; the"] #[doc = " actual format may differ, but pixel transfers will use this"] - #[doc = " format (one of the SDL_PixelFormatEnum values)"] + #[doc = " format (one of the SDL_PixelFormatEnum values). This argument"] + #[doc = " can be NULL if you don't need this information."] #[doc = " \\param access a pointer filled in with the actual access to the texture"] - #[doc = " (one of the SDL_TextureAccess values)"] - #[doc = " \\param w a pointer filled in with the width of the texture in pixels"] - #[doc = " \\param h a pointer filled in with the height of the texture in pixels"] + #[doc = " (one of the SDL_TextureAccess values). This argument can be"] + #[doc = " NULL if you don't need this information."] + #[doc = " \\param w a pointer filled in with the width of the texture in pixels. This"] + #[doc = " argument can be NULL if you don't need this information."] + #[doc = " \\param h a pointer filled in with the height of the texture in pixels. This"] + #[doc = " argument can be NULL if you don't need this information."] #[doc = " \\returns 0 on success or a negative error code on failure; call"] #[doc = " SDL_GetError() for more information."] #[doc = ""] @@ -23755,9 +25060,13 @@ extern "C" { extern "C" { #[doc = " Get device independent resolution for rendering."] #[doc = ""] - #[doc = " This may return 0 for `w` and `h` if the SDL_Renderer has never had its"] - #[doc = " logical size set by SDL_RenderSetLogicalSize() and never had a render"] - #[doc = " target set."] + #[doc = " When using the main rendering target (eg no target texture is set): this"] + #[doc = " may return 0 for `w` and `h` if the SDL_Renderer has never had its logical"] + #[doc = " size set by SDL_RenderSetLogicalSize(). Otherwise it returns the logical"] + #[doc = " width and height."] + #[doc = ""] + #[doc = " When using a target texture: Never return 0 for `w` and `h` at first. Then"] + #[doc = " it returns the logical width and height that are set."] #[doc = ""] #[doc = " \\param renderer a rendering context"] #[doc = " \\param w an int to be filled with the width"] @@ -23919,7 +25228,7 @@ extern "C" { #[doc = " and logical renderer size set"] #[doc = ""] #[doc = " \\param renderer the renderer from which the logical coordinates should be"] - #[doc = " calcualted"] + #[doc = " calculated"] #[doc = " \\param windowX the real X coordinate in the window"] #[doc = " \\param windowY the real Y coordinate in the window"] #[doc = " \\param logicalX the pointer filled with the logical x coordinate"] @@ -23940,16 +25249,19 @@ extern "C" { ); } extern "C" { - #[doc = " Get real coordinates of point in window when given logical coordinates of point in renderer."] - #[doc = " Logical coordinates will differ from real coordinates when render is scaled and logical renderer size set"] + #[doc = " Get real coordinates of point in window when given logical coordinates of"] + #[doc = " point in renderer."] #[doc = ""] - #[doc = " \\param renderer the renderer from which the window coordinates should be calculated"] + #[doc = " Logical coordinates will differ from real coordinates when render is scaled"] + #[doc = " and logical renderer size set"] + #[doc = ""] + #[doc = " \\param renderer the renderer from which the window coordinates should be"] + #[doc = " calculated"] #[doc = " \\param logicalX the logical x coordinate"] #[doc = " \\param logicalY the logical y coordinate"] #[doc = " \\param windowX the pointer filled with the real X coordinate in the window"] #[doc = " \\param windowY the pointer filled with the real Y coordinate in the window"] #[doc = ""] - #[doc = ""] #[doc = " \\since This function is available since SDL 2.0.18."] #[doc = ""] #[doc = " \\sa SDL_RenderGetScale"] @@ -24561,6 +25873,7 @@ extern "C" { #[doc = " vertex array Color and alpha modulation is done per vertex"] #[doc = " (SDL_SetTextureColorMod and SDL_SetTextureAlphaMod are ignored)."] #[doc = ""] + #[doc = " \\param renderer The rendering context."] #[doc = " \\param texture (optional) The SDL texture to use."] #[doc = " \\param vertices Vertices."] #[doc = " \\param num_vertices Number of vertices."] @@ -24588,6 +25901,7 @@ extern "C" { #[doc = " vertex arrays Color and alpha modulation is done per vertex"] #[doc = " (SDL_SetTextureColorMod and SDL_SetTextureAlphaMod are ignored)."] #[doc = ""] + #[doc = " \\param renderer The rendering context."] #[doc = " \\param texture (optional) The SDL texture to use."] #[doc = " \\param xy Vertex positions"] #[doc = " \\param xy_stride Byte size to move from one element to the next element"] @@ -24625,7 +25939,8 @@ extern "C" { #[doc = " Read pixels from the current rendering target to an array of pixels."] #[doc = ""] #[doc = " **WARNING**: This is a very slow operation, and should not be used"] - #[doc = " frequently."] + #[doc = " frequently. If you're using this on the main rendering target, it should be"] + #[doc = " called after rendering and before SDL_RenderPresent()."] #[doc = ""] #[doc = " `pitch` specifies the number of bytes between rows in the destination"] #[doc = " `pixels` data. This allows you to write to a subrectangle or have padded"] @@ -24674,6 +25989,11 @@ extern "C" { #[doc = ""] #[doc = " \\param renderer the rendering context"] #[doc = ""] + #[doc = " \\threadsafety You may only call this function on the main thread. If this"] + #[doc = " happens to work on a background thread on any given platform"] + #[doc = " or backend, it's purely by luck and you should not rely on it"] + #[doc = " to work next time."] + #[doc = ""] #[doc = " \\since This function is available since SDL 2.0.0."] #[doc = ""] #[doc = " \\sa SDL_RenderClear"] @@ -24706,6 +26026,9 @@ extern "C" { extern "C" { #[doc = " Destroy the rendering context for a window and free associated textures."] #[doc = ""] + #[doc = " If `renderer` is NULL, this function will return immediately after setting"] + #[doc = " the SDL error message to \"Invalid renderer\". See SDL_GetError()."] + #[doc = ""] #[doc = " \\param renderer the rendering context"] #[doc = ""] #[doc = " \\since This function is available since SDL 2.0.0."] @@ -24821,7 +26144,7 @@ extern "C" { #[doc = " Note that as of SDL 2.0.18, this will return NULL if Metal refuses to give"] #[doc = " SDL a drawable to render to, which might happen if the window is"] #[doc = " hidden/minimized/offscreen. This doesn't apply to command encoders for"] - #[doc = " render targets, just the window's backbacker. Check your return values!"] + #[doc = " render targets, just the window's backbuffer. Check your return values!"] #[doc = ""] #[doc = " \\param renderer The renderer to query"] #[doc = " \\returns an `id` on success, or NULL if the"] @@ -37494,12 +38817,16 @@ pub struct SDL_SysWMinfo__bindgen_ty_1__bindgen_ty_2 { pub xdg_surface: *mut xdg_surface, #[doc = "< Wayland xdg toplevel role"] pub xdg_toplevel: *mut xdg_toplevel, + #[doc = "< Wayland xdg popup role"] + pub xdg_popup: *mut xdg_popup, + #[doc = "< Wayland xdg positioner, for popup"] + pub xdg_positioner: *mut xdg_positioner, } #[test] fn bindgen_test_layout_SDL_SysWMinfo__bindgen_ty_1__bindgen_ty_2() { assert_eq!( ::core::mem::size_of::(), - 48usize, + 64usize, concat!( "Size of: ", stringify!(SDL_SysWMinfo__bindgen_ty_1__bindgen_ty_2) @@ -37591,6 +38918,32 @@ fn bindgen_test_layout_SDL_SysWMinfo__bindgen_ty_1__bindgen_ty_2() { stringify!(xdg_toplevel) ) ); + assert_eq!( + unsafe { + &(*(::core::ptr::null::())).xdg_popup + as *const _ as usize + }, + 48usize, + concat!( + "Offset of field: ", + stringify!(SDL_SysWMinfo__bindgen_ty_1__bindgen_ty_2), + "::", + stringify!(xdg_popup) + ) + ); + assert_eq!( + unsafe { + &(*(::core::ptr::null::())).xdg_positioner + as *const _ as usize + }, + 56usize, + concat!( + "Offset of field: ", + stringify!(SDL_SysWMinfo__bindgen_ty_1__bindgen_ty_2), + "::", + stringify!(xdg_positioner) + ) + ); } #[test] fn bindgen_test_layout_SDL_SysWMinfo__bindgen_ty_1() { @@ -37920,12 +39273,6 @@ fn bindgen_test_layout___va_list_tag() { ) ); } -#[doc = "< Private"] -#[repr(C)] -#[derive(Copy, Clone)] -pub struct SDL_BlitMap { - pub _address: u8, -} #[doc = "< Wayland display"] #[repr(C)] #[derive(Copy, Clone)] @@ -37956,3 +39303,15 @@ pub struct xdg_surface { pub struct xdg_toplevel { pub _address: u8, } +#[doc = "< Wayland xdg popup role"] +#[repr(C)] +#[derive(Copy, Clone)] +pub struct xdg_popup { + pub _address: u8, +} +#[doc = "< Wayland xdg positioner, for popup"] +#[repr(C)] +#[derive(Copy, Clone)] +pub struct xdg_positioner { + pub _address: u8, +} diff --git a/src/sdl2/event.rs b/src/sdl2/event.rs index 1af80dd94e..55aed434ef 100644 --- a/src/sdl2/event.rs +++ b/src/sdl2/event.rs @@ -414,6 +414,7 @@ pub enum DisplayEvent { Orientation(Orientation), Connected, Disconnected, + Moved, } impl DisplayEvent { @@ -436,6 +437,7 @@ impl DisplayEvent { } sys::SDL_DisplayEventID::SDL_DISPLAYEVENT_CONNECTED => DisplayEvent::Connected, sys::SDL_DisplayEventID::SDL_DISPLAYEVENT_DISCONNECTED => DisplayEvent::Disconnected, + sys::SDL_DisplayEventID::SDL_DISPLAYEVENT_MOVED => DisplayEvent::Moved, } } @@ -453,6 +455,10 @@ impl DisplayEvent { sys::SDL_DisplayEventID::SDL_DISPLAYEVENT_DISCONNECTED as u8, 0, ), + DisplayEvent::Moved => ( + sys::SDL_DisplayEventID::SDL_DISPLAYEVENT_MOVED as u8, + 0, + ), } } @@ -462,6 +468,7 @@ impl DisplayEvent { | (Self::Orientation(_), Self::Orientation(_)) | (Self::Connected, Self::Connected) | (Self::Disconnected, Self::Disconnected) => true, + | (Self::Moved, Self::Moved) => true, _ => false, } } @@ -674,6 +681,8 @@ pub enum Event { direction: MouseWheelDirection, precise_x: f32, precise_y: f32, + mouse_x: i32, + mouse_y: i32, }, JoyAxisMotion { @@ -1205,6 +1214,8 @@ impl Event { direction, precise_x, precise_y, + mouse_x, + mouse_y, } => { let event = sys::SDL_MouseWheelEvent { type_: SDL_EventType::SDL_MOUSEWHEEL as u32, @@ -1216,6 +1227,8 @@ impl Event { direction: direction.to_ll(), preciseX: precise_x, preciseY: precise_y, + mouseX: mouse_x, + mouseY: mouse_y, }; unsafe { ptr::copy(&event, ret.as_mut_ptr() as *mut sys::SDL_MouseWheelEvent, 1); @@ -1680,6 +1693,8 @@ impl Event { direction: mouse::MouseWheelDirection::from_ll(event.direction), precise_x: event.preciseX, precise_y: event.preciseY, + mouse_x: event.mouseX, + mouse_y: event.mouseY, } } @@ -2357,6 +2372,8 @@ impl Event { /// x: 0, /// y: 0, /// direction: MouseWheelDirection::Normal, + /// mouse_x: 0, + /// mouse_y: 0, /// }; /// assert!(ev.is_mouse()); /// @@ -2925,6 +2942,8 @@ mod test { direction: MouseWheelDirection::Flipped, precise_x: 1.6, precise_y: 2.7, + mouse_x: 24, + mouse_y: 92, }; let e2 = Event::from_ll(e.clone().to_ll().unwrap()); assert_eq!(e, e2); From cf98f195828954cb0c195f79c3e723c5872d5780 Mon Sep 17 00:00:00 2001 From: Naum Azeredo Date: Sat, 20 Apr 2024 15:59:24 -0700 Subject: [PATCH 2/7] Remove unneeded clones in sdl2-sys/build.rs --- sdl2-sys/build.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/sdl2-sys/build.rs b/sdl2-sys/build.rs index 633ad9526d..b886ef77de 100644 --- a/sdl2-sys/build.rs +++ b/sdl2-sys/build.rs @@ -36,7 +36,7 @@ fn init_submodule(sdl_path: &Path) { if !sdl_path.join("CMakeLists.txt").exists() { Command::new("git") .args(&["submodule", "update", "--init"]) - .current_dir(sdl_path.clone()) + .current_dir(sdl_path) .status() .expect("Git is needed to retrieve the SDL source files"); } @@ -650,35 +650,35 @@ fn generate_bindings(target: &str, host: &str, headers_paths: &[String]) { // Set correct target triple for bindgen when cross-compiling if target != host { bindings = bindings.clang_arg("-target"); - bindings = bindings.clang_arg(target.clone()); + bindings = bindings.clang_arg(target); if cfg!(feature = "image") { image_bindings = image_bindings.clang_arg("-target"); - image_bindings = image_bindings.clang_arg(target.clone()); + image_bindings = image_bindings.clang_arg(target); } if cfg!(feature = "ttf") { ttf_bindings = ttf_bindings.clang_arg("-target"); - ttf_bindings = ttf_bindings.clang_arg(target.clone()); + ttf_bindings = ttf_bindings.clang_arg(target); } if cfg!(feature = "mixer") { mixer_bindings = mixer_bindings.clang_arg("-target"); - mixer_bindings = mixer_bindings.clang_arg(target.clone()); + mixer_bindings = mixer_bindings.clang_arg(target); } if cfg!(feature = "gfx") { gfx_framerate_bindings = gfx_framerate_bindings.clang_arg("-target"); - gfx_framerate_bindings = gfx_framerate_bindings.clang_arg(target.clone()); + gfx_framerate_bindings = gfx_framerate_bindings.clang_arg(target); gfx_primitives_bindings = gfx_primitives_bindings.clang_arg("-target"); - gfx_primitives_bindings = gfx_primitives_bindings.clang_arg(target.clone()); + gfx_primitives_bindings = gfx_primitives_bindings.clang_arg(target); gfx_imagefilter_bindings = gfx_imagefilter_bindings.clang_arg("-target"); - gfx_imagefilter_bindings = gfx_imagefilter_bindings.clang_arg(target.clone()); + gfx_imagefilter_bindings = gfx_imagefilter_bindings.clang_arg(target); gfx_rotozoom_bindings = gfx_rotozoom_bindings.clang_arg("-target"); - gfx_rotozoom_bindings = gfx_rotozoom_bindings.clang_arg(target.clone()); + gfx_rotozoom_bindings = gfx_rotozoom_bindings.clang_arg(target); } } From d33c01a6d589a73701ddd9338c222dc3401f6782 Mon Sep 17 00:00:00 2001 From: Naum Azeredo Date: Sat, 20 Apr 2024 15:59:38 -0700 Subject: [PATCH 3/7] Add GameControllerType --- src/sdl2/controller.rs | 76 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) diff --git a/src/sdl2/controller.rs b/src/sdl2/controller.rs index 508387d387..2186f99d8d 100644 --- a/src/sdl2/controller.rs +++ b/src/sdl2/controller.rs @@ -116,6 +116,14 @@ impl GameControllerSubsystem { } } + /// Return the type of the controller at index `joystick_index`. + #[doc(alias = "SDL_GameControllerTypeForIndex")] + pub fn type_for_index(&self, joystick_index: u32) -> Result { + let joystick_index = validate_int(joystick_index, "joystick_index")?; + let raw_type = unsafe { sys::SDL_GameControllerTypeForIndex(joystick_index) }; + Ok(GameControllerType::from_ll(raw_type)) + } + /// If state is `true` controller events are processed, otherwise /// they're ignored. #[doc(alias = "SDL_GameControllerEventState")] @@ -197,6 +205,67 @@ impl GameControllerSubsystem { } } +#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)] +#[repr(i32)] +pub enum GameControllerType { + Unknown = sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_UNKNOWN as i32, + Xbox360 = sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_XBOX360 as i32, + Xboxone = sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_XBOXONE as i32, + PS3 = sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_PS3 as i32, + PS4 = sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_PS4 as i32, + NintendoSwitchPro = sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_PRO as i32, + Virtual = sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_VIRTUAL as i32, + PS5 = sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_PS5 as i32, + AmazonLuna = sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_AMAZON_LUNA as i32, + GoogleStadia = sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_GOOGLE_STADIA as i32, + NvidiaShield = sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_NVIDIA_SHIELD as i32, + NintendoSwitchJoyconLeft = sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_JOYCON_LEFT as i32, + NintendoSwitchJoyconRight = sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_JOYCON_RIGHT as i32, + NintendoSwitchJoyconPair = sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_JOYCON_PAIR as i32, +} + +impl GameControllerType { + pub fn from_ll(bitflags: sys::SDL_GameControllerType) -> GameControllerType { + match bitflags { + sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_UNKNOWN => GameControllerType::Unknown, + sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_XBOX360 => GameControllerType::Xbox360, + sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_XBOXONE => GameControllerType::Xboxone, + sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_PS3 => GameControllerType::PS3, + sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_PS4 => GameControllerType::PS4, + sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_PRO => GameControllerType::NintendoSwitchPro, + sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_VIRTUAL => GameControllerType::Virtual, + sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_PS5 => GameControllerType::PS5, + sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_AMAZON_LUNA => GameControllerType::AmazonLuna, + sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_GOOGLE_STADIA => GameControllerType::GoogleStadia, + sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_NVIDIA_SHIELD => GameControllerType::NvidiaShield, + sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_JOYCON_LEFT => GameControllerType::NintendoSwitchJoyconLeft, + sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_JOYCON_RIGHT => GameControllerType::NintendoSwitchJoyconRight, + sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_JOYCON_PAIR => GameControllerType::NintendoSwitchJoyconPair, + + sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_MAX => GameControllerType::Unknown, + } + } + + pub fn to_ll(self) -> sys::SDL_GameControllerType { + match self { + GameControllerType::Unknown => sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_UNKNOWN, + GameControllerType::Xbox360 => sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_XBOX360, + GameControllerType::Xboxone => sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_XBOXONE, + GameControllerType::PS3 => sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_PS3, + GameControllerType::PS4 => sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_PS4, + GameControllerType::NintendoSwitchPro => sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_PRO, + GameControllerType::Virtual => sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_VIRTUAL, + GameControllerType::PS5 => sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_PS5, + GameControllerType::AmazonLuna => sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_AMAZON_LUNA, + GameControllerType::GoogleStadia => sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_GOOGLE_STADIA, + GameControllerType::NvidiaShield => sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_NVIDIA_SHIELD, + GameControllerType::NintendoSwitchJoyconLeft => sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_JOYCON_LEFT, + GameControllerType::NintendoSwitchJoyconRight => sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_JOYCON_RIGHT, + GameControllerType::NintendoSwitchJoyconPair => sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_JOYCON_PAIR, + } + } +} + #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)] #[repr(i32)] pub enum Axis { @@ -410,6 +479,13 @@ impl GameController { c_str_to_string(name) } + /// Return the type of the controller + #[doc(alias = "SDL_GameControllerGetType")] + pub fn r#type(&self) -> GameControllerType { + let raw_type = unsafe { sys::SDL_GameControllerGetType(self.raw) }; + GameControllerType::from_ll(raw_type) + } + /// Return a String describing the controller's button and axis /// mappings #[doc(alias = "SDL_GameControllerMapping")] From 9d233cb297a4f1b86a05581ec559b2c93a9f0082 Mon Sep 17 00:00:00 2001 From: Naum Azeredo Date: Tue, 23 Apr 2024 14:31:54 -0700 Subject: [PATCH 4/7] Reorder GameControllerType list --- src/sdl2/controller.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/sdl2/controller.rs b/src/sdl2/controller.rs index 2186f99d8d..fd3830f373 100644 --- a/src/sdl2/controller.rs +++ b/src/sdl2/controller.rs @@ -209,16 +209,16 @@ impl GameControllerSubsystem { #[repr(i32)] pub enum GameControllerType { Unknown = sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_UNKNOWN as i32, + Virtual = sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_VIRTUAL as i32, Xbox360 = sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_XBOX360 as i32, - Xboxone = sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_XBOXONE as i32, + XboxOne = sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_XBOXONE as i32, PS3 = sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_PS3 as i32, PS4 = sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_PS4 as i32, - NintendoSwitchPro = sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_PRO as i32, - Virtual = sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_VIRTUAL as i32, PS5 = sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_PS5 as i32, AmazonLuna = sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_AMAZON_LUNA as i32, GoogleStadia = sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_GOOGLE_STADIA as i32, NvidiaShield = sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_NVIDIA_SHIELD as i32, + NintendoSwitchPro = sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_PRO as i32, NintendoSwitchJoyconLeft = sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_JOYCON_LEFT as i32, NintendoSwitchJoyconRight = sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_JOYCON_RIGHT as i32, NintendoSwitchJoyconPair = sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_JOYCON_PAIR as i32, @@ -228,16 +228,16 @@ impl GameControllerType { pub fn from_ll(bitflags: sys::SDL_GameControllerType) -> GameControllerType { match bitflags { sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_UNKNOWN => GameControllerType::Unknown, + sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_VIRTUAL => GameControllerType::Virtual, sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_XBOX360 => GameControllerType::Xbox360, - sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_XBOXONE => GameControllerType::Xboxone, + sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_XBOXONE => GameControllerType::XboxOne, sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_PS3 => GameControllerType::PS3, sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_PS4 => GameControllerType::PS4, - sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_PRO => GameControllerType::NintendoSwitchPro, - sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_VIRTUAL => GameControllerType::Virtual, sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_PS5 => GameControllerType::PS5, sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_AMAZON_LUNA => GameControllerType::AmazonLuna, sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_GOOGLE_STADIA => GameControllerType::GoogleStadia, sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_NVIDIA_SHIELD => GameControllerType::NvidiaShield, + sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_PRO => GameControllerType::NintendoSwitchPro, sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_JOYCON_LEFT => GameControllerType::NintendoSwitchJoyconLeft, sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_JOYCON_RIGHT => GameControllerType::NintendoSwitchJoyconRight, sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_JOYCON_PAIR => GameControllerType::NintendoSwitchJoyconPair, @@ -249,16 +249,16 @@ impl GameControllerType { pub fn to_ll(self) -> sys::SDL_GameControllerType { match self { GameControllerType::Unknown => sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_UNKNOWN, + GameControllerType::Virtual => sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_VIRTUAL, GameControllerType::Xbox360 => sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_XBOX360, - GameControllerType::Xboxone => sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_XBOXONE, + GameControllerType::XboxOne => sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_XBOXONE, GameControllerType::PS3 => sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_PS3, GameControllerType::PS4 => sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_PS4, - GameControllerType::NintendoSwitchPro => sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_PRO, - GameControllerType::Virtual => sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_VIRTUAL, GameControllerType::PS5 => sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_PS5, GameControllerType::AmazonLuna => sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_AMAZON_LUNA, GameControllerType::GoogleStadia => sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_GOOGLE_STADIA, GameControllerType::NvidiaShield => sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_NVIDIA_SHIELD, + GameControllerType::NintendoSwitchPro => sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_PRO, GameControllerType::NintendoSwitchJoyconLeft => sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_JOYCON_LEFT, GameControllerType::NintendoSwitchJoyconRight => sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_JOYCON_RIGHT, GameControllerType::NintendoSwitchJoyconPair => sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_JOYCON_PAIR, From f97f4fe24ace3283fe8473e67999b93ed2b33c04 Mon Sep 17 00:00:00 2001 From: Naum Azeredo Date: Sat, 6 Jul 2024 13:46:55 -0700 Subject: [PATCH 5/7] Bump SDL version --- sdl2-sys/SDL | 2 +- sdl2-sys/sdl_bindings.rs | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/sdl2-sys/SDL b/sdl2-sys/SDL index f461d91cd2..7b11fff2ee 160000 --- a/sdl2-sys/SDL +++ b/sdl2-sys/SDL @@ -1 +1 @@ -Subproject commit f461d91cd265d7b9a44b4d472b1df0c0ad2855a0 +Subproject commit 7b11fff2ee24af7bc815f1d741fab3f5307a9c88 diff --git a/sdl2-sys/sdl_bindings.rs b/sdl2-sys/sdl_bindings.rs index 53e1f7b126..138ae9dca0 100644 --- a/sdl2-sys/sdl_bindings.rs +++ b/sdl2-sys/sdl_bindings.rs @@ -471,6 +471,8 @@ pub const SDL_HINT_MOUSE_RELATIVE_SCALING: &[u8; 27] = b"SDL_MOUSE_RELATIVE_SCAL pub const SDL_HINT_MOUSE_RELATIVE_SPEED_SCALE: &[u8; 31] = b"SDL_MOUSE_RELATIVE_SPEED_SCALE\0"; pub const SDL_HINT_MOUSE_RELATIVE_SYSTEM_SCALE: &[u8; 32] = b"SDL_MOUSE_RELATIVE_SYSTEM_SCALE\0"; pub const SDL_HINT_MOUSE_RELATIVE_WARP_MOTION: &[u8; 31] = b"SDL_MOUSE_RELATIVE_WARP_MOTION\0"; +pub const SDL_HINT_MOUSE_RELATIVE_CURSOR_VISIBLE: &[u8; 34] = + b"SDL_MOUSE_RELATIVE_CURSOR_VISIBLE\0"; pub const SDL_HINT_MOUSE_TOUCH_EVENTS: &[u8; 23] = b"SDL_MOUSE_TOUCH_EVENTS\0"; pub const SDL_HINT_MOUSE_AUTO_CAPTURE: &[u8; 23] = b"SDL_MOUSE_AUTO_CAPTURE\0"; pub const SDL_HINT_NO_SIGNAL_HANDLERS: &[u8; 23] = b"SDL_NO_SIGNAL_HANDLERS\0"; @@ -578,7 +580,7 @@ pub const SDL_INVALID_SHAPE_ARGUMENT: i32 = -2; pub const SDL_WINDOW_LACKS_SHAPE: i32 = -3; pub const SDL_MAJOR_VERSION: u32 = 2; pub const SDL_MINOR_VERSION: u32 = 30; -pub const SDL_PATCHLEVEL: u32 = 2; +pub const SDL_PATCHLEVEL: u32 = 5; pub const SDL_INIT_TIMER: u32 = 1; pub const SDL_INIT_AUDIO: u32 = 16; pub const SDL_INIT_VIDEO: u32 = 32; @@ -8775,7 +8777,7 @@ extern "C" { pub fn SDL_JoystickUpdate(); } extern "C" { - #[doc = " Enable/disable joystick event polling.\n\n If joystick events are disabled, you must call SDL_JoystickUpdate()\n yourself and manually check the state of the joystick when you want\n joystick information.\n\n It is recommended that you leave joystick event handling enabled.\n\n **WARNING**: Calling this function may delete all events currently in SDL's\n event queue.\n\n \\param state can be one of `SDL_QUERY`, `SDL_IGNORE`, or `SDL_ENABLE`\n \\returns 1 if enabled, 0 if disabled, or a negative error code on failure;\n call SDL_GetError() for more information.\n\n If `state` is `SDL_QUERY` then the current state is returned,\n otherwise the new processing state is returned.\n\n \\since This function is available since SDL 2.0.0.\n\n \\sa SDL_GameControllerEventState"] + #[doc = " Enable/disable joystick event polling.\n\n If joystick events are disabled, you must call SDL_JoystickUpdate()\n yourself and manually check the state of the joystick when you want\n joystick information.\n\n It is recommended that you leave joystick event handling enabled.\n\n **WARNING**: Calling this function may delete all events currently in SDL's\n event queue.\n\n While `param` is meant to be one of `SDL_QUERY`, `SDL_IGNORE`, or\n `SDL_ENABLE`, this function accepts any value, with any non-zero value that\n isn't `SDL_QUERY` being treated as `SDL_ENABLE`.\n\n If SDL was built with events disabled (extremely uncommon!), this will\n do nothing and always return `SDL_IGNORE`.\n\n \\param state can be one of `SDL_QUERY`, `SDL_IGNORE`, or `SDL_ENABLE`\n \\returns If `state` is `SDL_QUERY` then the current state is returned,\n otherwise `state` is returned (even if it was not one of the\n allowed values).\n\n \\since This function is available since SDL 2.0.0.\n\n \\sa SDL_GameControllerEventState"] pub fn SDL_JoystickEventState(state: libc::c_int) -> libc::c_int; } extern "C" { From 53efd51b414543c4e2f8cefd6cac8c188571a759 Mon Sep 17 00:00:00 2001 From: Naum Azeredo Date: Sat, 6 Jul 2024 14:11:22 -0700 Subject: [PATCH 6/7] Fix tests --- src/sdl2/event.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/sdl2/event.rs b/src/sdl2/event.rs index e81507b1ab..87e458155f 100644 --- a/src/sdl2/event.rs +++ b/src/sdl2/event.rs @@ -2338,8 +2338,6 @@ impl Event { /// mouse_x: 0, /// mouse_y: 0, /// direction: MouseWheelDirection::Normal, - /// mouse_x: 0, - /// mouse_y: 0, /// }; /// assert!(ev.is_mouse()); /// From 911a6dba66353d0cab51b1de2ad142e450dd99ba Mon Sep 17 00:00:00 2001 From: Naum Azeredo Date: Sat, 6 Jul 2024 14:12:50 -0700 Subject: [PATCH 7/7] Run cargo fmt --- src/sdl2/controller.rs | 70 +++++++++++++++++++++++++++++++----------- src/sdl2/event.rs | 5 +-- 2 files changed, 53 insertions(+), 22 deletions(-) diff --git a/src/sdl2/controller.rs b/src/sdl2/controller.rs index fc43ef70d5..bb01377d3a 100644 --- a/src/sdl2/controller.rs +++ b/src/sdl2/controller.rs @@ -114,7 +114,10 @@ impl GameControllerSubsystem { /// Return the type of the controller at index `joystick_index`. #[doc(alias = "SDL_GameControllerTypeForIndex")] - pub fn type_for_index(&self, joystick_index: u32) -> Result { + pub fn type_for_index( + &self, + joystick_index: u32, + ) -> Result { let joystick_index = validate_int(joystick_index, "joystick_index")?; let raw_type = unsafe { sys::SDL_GameControllerTypeForIndex(joystick_index) }; Ok(GameControllerType::from_ll(raw_type)) @@ -213,9 +216,12 @@ pub enum GameControllerType { GoogleStadia = sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_GOOGLE_STADIA as i32, NvidiaShield = sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_NVIDIA_SHIELD as i32, NintendoSwitchPro = sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_PRO as i32, - NintendoSwitchJoyconLeft = sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_JOYCON_LEFT as i32, - NintendoSwitchJoyconRight = sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_JOYCON_RIGHT as i32, - NintendoSwitchJoyconPair = sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_JOYCON_PAIR as i32, + NintendoSwitchJoyconLeft = + sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_JOYCON_LEFT as i32, + NintendoSwitchJoyconRight = + sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_JOYCON_RIGHT as i32, + NintendoSwitchJoyconPair = + sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_JOYCON_PAIR as i32, } impl GameControllerType { @@ -228,13 +234,27 @@ impl GameControllerType { sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_PS3 => GameControllerType::PS3, sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_PS4 => GameControllerType::PS4, sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_PS5 => GameControllerType::PS5, - sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_AMAZON_LUNA => GameControllerType::AmazonLuna, - sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_GOOGLE_STADIA => GameControllerType::GoogleStadia, - sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_NVIDIA_SHIELD => GameControllerType::NvidiaShield, - sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_PRO => GameControllerType::NintendoSwitchPro, - sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_JOYCON_LEFT => GameControllerType::NintendoSwitchJoyconLeft, - sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_JOYCON_RIGHT => GameControllerType::NintendoSwitchJoyconRight, - sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_JOYCON_PAIR => GameControllerType::NintendoSwitchJoyconPair, + sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_AMAZON_LUNA => { + GameControllerType::AmazonLuna + } + sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_GOOGLE_STADIA => { + GameControllerType::GoogleStadia + } + sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_NVIDIA_SHIELD => { + GameControllerType::NvidiaShield + } + sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_PRO => { + GameControllerType::NintendoSwitchPro + } + sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_JOYCON_LEFT => { + GameControllerType::NintendoSwitchJoyconLeft + } + sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_JOYCON_RIGHT => { + GameControllerType::NintendoSwitchJoyconRight + } + sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_JOYCON_PAIR => { + GameControllerType::NintendoSwitchJoyconPair + } sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_MAX => GameControllerType::Unknown, } @@ -249,13 +269,27 @@ impl GameControllerType { GameControllerType::PS3 => sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_PS3, GameControllerType::PS4 => sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_PS4, GameControllerType::PS5 => sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_PS5, - GameControllerType::AmazonLuna => sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_AMAZON_LUNA, - GameControllerType::GoogleStadia => sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_GOOGLE_STADIA, - GameControllerType::NvidiaShield => sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_NVIDIA_SHIELD, - GameControllerType::NintendoSwitchPro => sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_PRO, - GameControllerType::NintendoSwitchJoyconLeft => sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_JOYCON_LEFT, - GameControllerType::NintendoSwitchJoyconRight => sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_JOYCON_RIGHT, - GameControllerType::NintendoSwitchJoyconPair => sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_JOYCON_PAIR, + GameControllerType::AmazonLuna => { + sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_AMAZON_LUNA + } + GameControllerType::GoogleStadia => { + sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_GOOGLE_STADIA + } + GameControllerType::NvidiaShield => { + sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_NVIDIA_SHIELD + } + GameControllerType::NintendoSwitchPro => { + sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_PRO + } + GameControllerType::NintendoSwitchJoyconLeft => { + sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_JOYCON_LEFT + } + GameControllerType::NintendoSwitchJoyconRight => { + sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_JOYCON_RIGHT + } + GameControllerType::NintendoSwitchJoyconPair => { + sys::SDL_GameControllerType::SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_JOYCON_PAIR + } } } } diff --git a/src/sdl2/event.rs b/src/sdl2/event.rs index 87e458155f..186adf04e9 100644 --- a/src/sdl2/event.rs +++ b/src/sdl2/event.rs @@ -450,10 +450,7 @@ impl DisplayEvent { sys::SDL_DisplayEventID::SDL_DISPLAYEVENT_DISCONNECTED as u8, 0, ), - DisplayEvent::Moved => ( - sys::SDL_DisplayEventID::SDL_DISPLAYEVENT_MOVED as u8, - 0, - ), + DisplayEvent::Moved => (sys::SDL_DisplayEventID::SDL_DISPLAYEVENT_MOVED as u8, 0), } }