1 /* 2 * SDL - Simple DirectMedia Layer 3 * Copyright (C) 1997-2009 Sam Lantinga 4 * Sam Lantinga 5 * slouken@libsdl.org 6 * 7 * Copyright (C) 2005-2018 Team Kodi 8 * This file is part of Kodi - https://kodi.tv 9 * 10 * SPDX-License-Identifier: GPL-2.0-or-later 11 * See LICENSES/README.md for more information. 12 */ 13 14 #pragma once 15 16 /* Include file for SDL event handling */ 17 18 #include "Resolution.h" 19 #include "input/XBMC_keyboard.h" 20 21 /* Event enumerations */ 22 typedef enum { 23 XBMC_NOEVENT = 0, /* Unused (do not remove) */ 24 XBMC_KEYDOWN, /* Keys pressed */ 25 XBMC_KEYUP, /* Keys released */ 26 XBMC_MOUSEMOTION, /* Mouse moved */ 27 XBMC_MOUSEBUTTONDOWN, /* Mouse button pressed */ 28 XBMC_MOUSEBUTTONUP, /* Mouse button released */ 29 XBMC_QUIT, /* User-requested quit */ 30 XBMC_VIDEORESIZE, /* User resized video mode */ 31 XBMC_VIDEOMOVE, /* User moved the window */ 32 XBMC_MODECHANGE, /* Video mode must be changed */ 33 XBMC_TOUCH, 34 XBMC_BUTTON, /* Button (remote) pressed */ 35 XBMC_SETFOCUS, 36 XBMC_USEREVENT, 37 38 XBMC_MAXEVENT = 256 /* XBMC_EventType is represented as uchar */ 39 } XBMC_EventType; 40 41 /* Keyboard event structure */ 42 typedef struct XBMC_KeyboardEvent { 43 XBMC_keysym keysym; 44 } XBMC_KeyboardEvent; 45 46 /* Mouse motion event structure */ 47 typedef struct XBMC_MouseMotionEvent { 48 uint16_t x, y; /* The X/Y coordinates of the mouse */ 49 } XBMC_MouseMotionEvent; 50 51 /* Mouse button event structure */ 52 typedef struct XBMC_MouseButtonEvent { 53 unsigned char button; /* The mouse button index */ 54 uint16_t x, y; /* The X/Y coordinates of the mouse at press time */ 55 } XBMC_MouseButtonEvent; 56 57 /* The "window resized" event 58 When you get this event, you are responsible for setting a new video 59 mode with the new width and height. 60 */ 61 typedef struct XBMC_ResizeEvent { 62 int w; /* New width */ 63 int h; /* New height */ 64 } XBMC_ResizeEvent; 65 66 typedef struct XBMC_MoveEvent { 67 int x; /* New x position */ 68 int y; /* New y position */ 69 } XBMC_MoveEvent; 70 71 struct XBMC_ModeChangeEvent 72 { 73 RESOLUTION res; 74 }; 75 76 /* The "quit requested" event */ 77 typedef struct XBMC_QuitEvent { 78 } XBMC_QuitEvent; 79 80 /* A user-defined event type */ 81 typedef struct XBMC_UserEvent { 82 int code; /* User defined event code */ 83 void *data1; /* User defined data pointer */ 84 void *data2; /* User defined data pointer */ 85 } XBMC_UserEvent; 86 87 /* Multimedia keys on keyboards / remotes are mapped to APPCOMMAND events */ 88 typedef struct XBMC_AppCommandEvent { 89 unsigned int action; /* One of ACTION_... */ 90 } XBMC_AppCommandEvent; 91 92 /* Mouse motion event structure */ 93 typedef struct XBMC_TouchEvent { 94 int action; /* action ID */ 95 float x, y; /* The X/Y coordinates of the mouse */ 96 float x2, y2; /* Additional X/Y coordinates */ 97 float x3, y3; /* Additional X/Y coordinates */ 98 int pointers; /* number of touch pointers */ 99 } XBMC_TouchEvent; 100 101 typedef struct XBMC_SetFocusEvent { 102 int x; /* x position */ 103 int y; /* y position */ 104 } XBMC_SetFocusEvent; 105 106 /* Button event structure */ 107 typedef struct XBMC_ButtonEvent 108 { 109 uint32_t button; 110 uint32_t holdtime; 111 } XBMC_ButtonEvent; 112 113 /* General event structure */ 114 typedef struct XBMC_Event { 115 uint8_t type; 116 union 117 { 118 XBMC_KeyboardEvent key; 119 XBMC_MouseMotionEvent motion; 120 XBMC_MouseButtonEvent button; 121 XBMC_ResizeEvent resize; 122 XBMC_MoveEvent move; 123 XBMC_ModeChangeEvent mode; 124 XBMC_QuitEvent quit; 125 XBMC_UserEvent user; 126 XBMC_AppCommandEvent appcommand; 127 XBMC_TouchEvent touch; 128 XBMC_ButtonEvent keybutton; 129 XBMC_SetFocusEvent focus; 130 }; 131 } XBMC_Event; 132 133