diff options
| author | 3gg <3gg@shellblade.net> | 2025-12-27 12:03:39 -0800 |
|---|---|---|
| committer | 3gg <3gg@shellblade.net> | 2025-12-27 12:03:39 -0800 |
| commit | 5a079a2d114f96d4847d1ee305d5b7c16eeec50e (patch) | |
| tree | 8926ab44f168acf787d8e19608857b3af0f82758 /contrib/SDL-3.2.8/src/video/wayland/SDL_waylandevents_c.h | |
Initial commit
Diffstat (limited to 'contrib/SDL-3.2.8/src/video/wayland/SDL_waylandevents_c.h')
| -rw-r--r-- | contrib/SDL-3.2.8/src/video/wayland/SDL_waylandevents_c.h | 195 |
1 files changed, 195 insertions, 0 deletions
diff --git a/contrib/SDL-3.2.8/src/video/wayland/SDL_waylandevents_c.h b/contrib/SDL-3.2.8/src/video/wayland/SDL_waylandevents_c.h new file mode 100644 index 0000000..6158882 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/wayland/SDL_waylandevents_c.h | |||
| @@ -0,0 +1,195 @@ | |||
| 1 | /* | ||
| 2 | Simple DirectMedia Layer | ||
| 3 | Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org> | ||
| 4 | |||
| 5 | This software is provided 'as-is', without any express or implied | ||
| 6 | warranty. In no event will the authors be held liable for any damages | ||
| 7 | arising from the use of this software. | ||
| 8 | |||
| 9 | Permission is granted to anyone to use this software for any purpose, | ||
| 10 | including commercial applications, and to alter it and redistribute it | ||
| 11 | freely, subject to the following restrictions: | ||
| 12 | |||
| 13 | 1. The origin of this software must not be misrepresented; you must not | ||
| 14 | claim that you wrote the original software. If you use this software | ||
| 15 | in a product, an acknowledgment in the product documentation would be | ||
| 16 | appreciated but is not required. | ||
| 17 | 2. Altered source versions must be plainly marked as such, and must not be | ||
| 18 | misrepresented as being the original software. | ||
| 19 | 3. This notice may not be removed or altered from any source distribution. | ||
| 20 | */ | ||
| 21 | |||
| 22 | #include "SDL_internal.h" | ||
| 23 | |||
| 24 | #ifndef SDL_waylandevents_h_ | ||
| 25 | #define SDL_waylandevents_h_ | ||
| 26 | |||
| 27 | #include "../../events/SDL_mouse_c.h" | ||
| 28 | #include "../../events/SDL_pen_c.h" | ||
| 29 | |||
| 30 | #include "SDL_waylandvideo.h" | ||
| 31 | #include "SDL_waylandwindow.h" | ||
| 32 | #include "SDL_waylanddatamanager.h" | ||
| 33 | #include "SDL_waylandkeyboard.h" | ||
| 34 | |||
| 35 | enum SDL_WaylandAxisEvent | ||
| 36 | { | ||
| 37 | AXIS_EVENT_CONTINUOUS = 0, | ||
| 38 | AXIS_EVENT_DISCRETE, | ||
| 39 | AXIS_EVENT_VALUE120 | ||
| 40 | }; | ||
| 41 | |||
| 42 | struct SDL_WaylandTabletSeat; | ||
| 43 | |||
| 44 | typedef struct SDL_WaylandTabletInput | ||
| 45 | { | ||
| 46 | struct SDL_WaylandInput *input; | ||
| 47 | struct zwp_tablet_seat_v2 *seat; | ||
| 48 | } SDL_WaylandTabletInput; | ||
| 49 | |||
| 50 | typedef struct | ||
| 51 | { | ||
| 52 | int32_t repeat_rate; // Repeat rate in range of [1, 1000] character(s) per second | ||
| 53 | int32_t repeat_delay_ms; // Time to first repeat event in milliseconds | ||
| 54 | Uint32 keyboard_id; // ID of the source keyboard. | ||
| 55 | bool is_initialized; | ||
| 56 | |||
| 57 | bool is_key_down; | ||
| 58 | uint32_t key; | ||
| 59 | Uint64 wl_press_time_ns; // Key press time as reported by the Wayland API | ||
| 60 | Uint64 sdl_press_time_ns; // Key press time expressed in SDL ticks | ||
| 61 | Uint64 next_repeat_ns; // Next repeat event in nanoseconds | ||
| 62 | uint32_t scancode; | ||
| 63 | char text[8]; | ||
| 64 | } SDL_WaylandKeyboardRepeat; | ||
| 65 | |||
| 66 | struct SDL_WaylandInput | ||
| 67 | { | ||
| 68 | SDL_VideoData *display; | ||
| 69 | struct wl_seat *seat; | ||
| 70 | struct wl_pointer *pointer; | ||
| 71 | struct wl_touch *touch; | ||
| 72 | struct wl_keyboard *keyboard; | ||
| 73 | SDL_WaylandDataDevice *data_device; | ||
| 74 | SDL_WaylandPrimarySelectionDevice *primary_selection_device; | ||
| 75 | SDL_WaylandTextInput *text_input; | ||
| 76 | struct wp_cursor_shape_device_v1 *cursor_shape; | ||
| 77 | struct zwp_relative_pointer_v1 *relative_pointer; | ||
| 78 | struct zwp_input_timestamps_v1 *keyboard_timestamps; | ||
| 79 | struct zwp_input_timestamps_v1 *pointer_timestamps; | ||
| 80 | struct zwp_input_timestamps_v1 *touch_timestamps; | ||
| 81 | SDL_WindowData *pointer_focus; | ||
| 82 | SDL_WindowData *keyboard_focus; | ||
| 83 | SDL_CursorData *current_cursor; | ||
| 84 | SDL_KeyboardID keyboard_id; | ||
| 85 | SDL_MouseID pointer_id; | ||
| 86 | uint32_t pointer_enter_serial; | ||
| 87 | |||
| 88 | // High-resolution event timestamps | ||
| 89 | Uint64 keyboard_timestamp_ns; | ||
| 90 | Uint64 pointer_timestamp_ns; | ||
| 91 | Uint64 touch_timestamp_ns; | ||
| 92 | |||
| 93 | // Last motion location | ||
| 94 | wl_fixed_t sx_w; | ||
| 95 | wl_fixed_t sy_w; | ||
| 96 | |||
| 97 | SDL_MouseButtonFlags buttons_pressed; | ||
| 98 | |||
| 99 | // The serial of the last implicit grab event for window activation and selection data. | ||
| 100 | Uint32 last_implicit_grab_serial; | ||
| 101 | |||
| 102 | struct | ||
| 103 | { | ||
| 104 | struct xkb_keymap *keymap; | ||
| 105 | struct xkb_state *state; | ||
| 106 | struct xkb_compose_table *compose_table; | ||
| 107 | struct xkb_compose_state *compose_state; | ||
| 108 | |||
| 109 | // Keyboard layout "group" | ||
| 110 | uint32_t current_group; | ||
| 111 | |||
| 112 | // Modifier bitshift values | ||
| 113 | uint32_t idx_shift; | ||
| 114 | uint32_t idx_ctrl; | ||
| 115 | uint32_t idx_alt; | ||
| 116 | uint32_t idx_gui; | ||
| 117 | uint32_t idx_mod3; | ||
| 118 | uint32_t idx_mod5; | ||
| 119 | uint32_t idx_num; | ||
| 120 | uint32_t idx_caps; | ||
| 121 | |||
| 122 | // Current system modifier flags | ||
| 123 | uint32_t wl_pressed_modifiers; | ||
| 124 | uint32_t wl_locked_modifiers; | ||
| 125 | } xkb; | ||
| 126 | |||
| 127 | // information about axis events on current frame | ||
| 128 | struct | ||
| 129 | { | ||
| 130 | enum SDL_WaylandAxisEvent x_axis_type; | ||
| 131 | float x; | ||
| 132 | |||
| 133 | enum SDL_WaylandAxisEvent y_axis_type; | ||
| 134 | float y; | ||
| 135 | |||
| 136 | // Event timestamp in nanoseconds | ||
| 137 | Uint64 timestamp_ns; | ||
| 138 | SDL_MouseWheelDirection direction; | ||
| 139 | } pointer_curr_axis_info; | ||
| 140 | |||
| 141 | SDL_WaylandKeyboardRepeat keyboard_repeat; | ||
| 142 | |||
| 143 | SDL_WaylandTabletInput *tablet_input; | ||
| 144 | |||
| 145 | bool keyboard_is_virtual; | ||
| 146 | |||
| 147 | // Current SDL modifier flags | ||
| 148 | SDL_Keymod pressed_modifiers; | ||
| 149 | SDL_Keymod locked_modifiers; | ||
| 150 | }; | ||
| 151 | |||
| 152 | |||
| 153 | extern Uint64 Wayland_GetTouchTimestamp(struct SDL_WaylandInput *input, Uint32 wl_timestamp_ms); | ||
| 154 | |||
| 155 | extern void Wayland_PumpEvents(SDL_VideoDevice *_this); | ||
| 156 | extern void Wayland_SendWakeupEvent(SDL_VideoDevice *_this, SDL_Window *window); | ||
| 157 | extern int Wayland_WaitEventTimeout(SDL_VideoDevice *_this, Sint64 timeoutNS); | ||
| 158 | |||
| 159 | extern void Wayland_create_data_device(SDL_VideoData *d); | ||
| 160 | extern void Wayland_create_primary_selection_device(SDL_VideoData *d); | ||
| 161 | |||
| 162 | extern void Wayland_create_text_input_manager(SDL_VideoData *d, uint32_t id); | ||
| 163 | |||
| 164 | extern void Wayland_input_initialize_seat(SDL_VideoData *d); | ||
| 165 | extern void Wayland_display_destroy_input(SDL_VideoData *d); | ||
| 166 | |||
| 167 | extern void Wayland_input_init_relative_pointer(SDL_VideoData *d); | ||
| 168 | extern bool Wayland_input_enable_relative_pointer(struct SDL_WaylandInput *input); | ||
| 169 | extern bool Wayland_input_disable_relative_pointer(struct SDL_WaylandInput *input); | ||
| 170 | |||
| 171 | extern bool Wayland_input_lock_pointer(struct SDL_WaylandInput *input, SDL_Window *window); | ||
| 172 | extern bool Wayland_input_unlock_pointer(struct SDL_WaylandInput *input, SDL_Window *window); | ||
| 173 | |||
| 174 | extern bool Wayland_input_confine_pointer(struct SDL_WaylandInput *input, SDL_Window *window); | ||
| 175 | extern bool Wayland_input_unconfine_pointer(struct SDL_WaylandInput *input, SDL_Window *window); | ||
| 176 | |||
| 177 | extern bool Wayland_input_grab_keyboard(SDL_Window *window, struct SDL_WaylandInput *input); | ||
| 178 | extern bool Wayland_input_ungrab_keyboard(SDL_Window *window); | ||
| 179 | |||
| 180 | extern void Wayland_input_init_tablet_support(struct SDL_WaylandInput *input, struct zwp_tablet_manager_v2 *tablet_manager); | ||
| 181 | extern void Wayland_input_quit_tablet_support(struct SDL_WaylandInput *input); | ||
| 182 | |||
| 183 | extern void Wayland_RegisterTimestampListeners(struct SDL_WaylandInput *input); | ||
| 184 | extern void Wayland_CreateCursorShapeDevice(struct SDL_WaylandInput *input); | ||
| 185 | |||
| 186 | /* The implicit grab serial needs to be updated on: | ||
| 187 | * - Keyboard key down/up | ||
| 188 | * - Mouse button down | ||
| 189 | * - Touch event down | ||
| 190 | * - Tablet tool down | ||
| 191 | * - Tablet tool button down/up | ||
| 192 | */ | ||
| 193 | extern void Wayland_UpdateImplicitGrabSerial(struct SDL_WaylandInput *input, Uint32 serial); | ||
| 194 | |||
| 195 | #endif // SDL_waylandevents_h_ | ||
