26 #include "../../SDL_internal.h" 28 #if SDL_VIDEO_DRIVER_MIR 30 #include "../../events/SDL_events_c.h" 31 #include "../../events/SDL_keyboard_c.h" 32 #include "../../events/SDL_touch_c.h" 33 #include "../../events/scancodes_xfree86.h" 38 #include <xkbcommon/xkbcommon.h> 48 size = MIR_xkb_keysym_to_utf8(key_code, text,
sizeof text);
61 if (keyboard_window != sdl_window)
76 CheckKeyboardFocus(window);
85 HandleKeyText(ev.key_code);
94 switch (button_state) {
95 case mir_motion_button_primary:
98 case mir_motion_button_secondary:
101 case mir_motion_button_tertiary:
104 case mir_motion_button_forward:
107 case mir_motion_button_back:
111 sdl_button = last_sdl_button;
115 last_sdl_button = sdl_button;
126 HandleTouchPress(
int device_id,
int source_id,
SDL_bool down,
float x,
float y,
float pressure)
132 HandleTouchMotion(
int device_id,
int source_id,
float x,
float y,
float pressure)
138 HandleMouseScroll(
SDL_Window* sdl_window,
int hscroll,
int vscroll)
144 AddTouchDevice(
int device_id)
147 SDL_SetError(
"Error: can't add touch %s, %d", __FILE__, __LINE__);
151 HandleTouchEvent(MirMotionEvent
const motion,
int cord_index,
SDL_Window* sdl_window)
153 int device_id = motion.device_id;
154 int id = motion.pointer_coordinates[cord_index].id;
156 int width = sdl_window->
w;
158 float x = motion.pointer_coordinates[cord_index].x;
159 float y = motion.pointer_coordinates[cord_index].y;
161 float n_x = x /
width;
163 float pressure = motion.pointer_coordinates[cord_index].pressure;
165 AddTouchDevice(motion.device_id);
167 switch (motion.action) {
168 case mir_motion_action_down:
169 case mir_motion_action_pointer_down:
170 HandleTouchPress(device_id,
id,
SDL_TRUE, n_x, n_y, pressure);
172 case mir_motion_action_up:
173 case mir_motion_action_pointer_up:
174 HandleTouchPress(device_id,
id,
SDL_FALSE, n_x, n_y, pressure);
176 case mir_motion_action_hover_move:
177 case mir_motion_action_move:
178 HandleTouchMotion(device_id,
id, n_x, n_y, pressure);
186 HandleMouseEvent(MirMotionEvent
const motion,
int cord_index,
SDL_Window* sdl_window)
190 switch (motion.action) {
191 case mir_motion_action_down:
192 case mir_motion_action_pointer_down:
193 HandleMouseButton(sdl_window,
SDL_PRESSED, motion.button_state);
195 case mir_motion_action_up:
196 case mir_motion_action_pointer_up:
197 HandleMouseButton(sdl_window,
SDL_RELEASED, motion.button_state);
199 case mir_motion_action_hover_move:
200 case mir_motion_action_move:
201 HandleMouseMotion(sdl_window,
202 motion.pointer_coordinates[cord_index].
x,
203 motion.pointer_coordinates[cord_index].y);
205 case mir_motion_action_outside:
208 case mir_motion_action_scroll:
209 HandleMouseScroll(sdl_window,
210 motion.pointer_coordinates[cord_index].hscroll,
211 motion.pointer_coordinates[cord_index].vscroll);
213 case mir_motion_action_cancel:
214 case mir_motion_action_hover_enter:
215 case mir_motion_action_hover_exit:
223 HandleMotionEvent(MirMotionEvent
const motion,
SDL_Window* sdl_window)
226 for (cord_index = 0; cord_index < motion.pointer_count; cord_index++) {
227 if (motion.pointer_coordinates[cord_index].tool_type == mir_motion_tool_type_finger) {
228 HandleTouchEvent(motion, cord_index, sdl_window);
231 HandleMouseEvent(motion, cord_index, sdl_window);
237 MIR_HandleInput(MirSurface* surface, MirEvent
const* ev,
void* context)
241 case (mir_event_type_key):
242 HandleKeyEvent(ev->key, window);
244 case (mir_event_type_motion):
245 HandleMotionEvent(ev->motion, window);
void SDL_SetKeyboardFocus(SDL_Window *window)
GLint GLint GLsizei width
GLint GLint GLint GLint GLint x
int SDL_SendTouch(SDL_TouchID id, SDL_FingerID fingerid, SDL_bool down, float x, float y, float pressure)
static const SDL_Scancode xfree86_scancode_table2[]
void SDL_SetMouseFocus(SDL_Window *window)
#define SDL_GetKeyboardFocus
GLint GLint GLsizei GLsizei height
int SDL_SendKeyboardKey(Uint8 state, SDL_Scancode scancode)
int SDL_SendTouchMotion(SDL_TouchID id, SDL_FingerID fingerid, float x, float y, float pressure)
GLint GLint GLint GLint GLint GLint y
int SDL_SendMouseMotion(SDL_Window *window, SDL_MouseID mouseID, int relative, int x, int y)
uint8_t Uint8
An unsigned 8-bit integer type.
int SDL_SendKeyboardText(const char *text)
#define SDL_BUTTON_MIDDLE
int SDL_AddTouch(SDL_TouchID touchID, const char *name)
void MIR_HandleInput(MirSurface *surface, MirEvent const *ev, void *context)
static char text[MAX_TEXT_LENGTH]
The type used to identify a window.
#define SDL_arraysize(array)
int SDL_SendMouseWheel(SDL_Window *window, SDL_MouseID mouseID, int x, int y, SDL_MouseWheelDirection direction)
int SDL_SendMouseButton(SDL_Window *window, SDL_MouseID mouseID, Uint8 state, Uint8 button)