SDL_events.h 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447
  1. #ifndef _SDL_events_h
  2. #define _SDL_events_h
  3. #include "SDL_stdinc.h"
  4. #include "SDL_error.h"
  5. #include "SDL_video.h"
  6. #include "SDL_keyboard.h"
  7. #include "SDL_mouse.h"
  8. #include "SDL_joystick.h"
  9. #include "SDL_gamecontroller.h"
  10. #include "SDL_quit.h"
  11. #include "SDL_gesture.h"
  12. #include "SDL_touch.h"
  13. #include "begin_code.h"
  14. #ifdef __cplusplus
  15. extern "C" {
  16. #endif
  17. #define SDL_RELEASED 0
  18. #define SDL_PRESSED 1
  19. typedef enum
  20. {
  21. SDL_FIRSTEVENT = 0,
  22. SDL_QUIT = 0x100,
  23. SDL_APP_TERMINATING,
  24. SDL_APP_LOWMEMORY,
  25. SDL_APP_WILLENTERBACKGROUND,
  26. SDL_APP_DIDENTERBACKGROUND,
  27. SDL_APP_WILLENTERFOREGROUND,
  28. SDL_APP_DIDENTERFOREGROUND,
  29. SDL_WINDOWEVENT = 0x200,
  30. SDL_SYSWMEVENT,
  31. SDL_KEYDOWN = 0x300,
  32. SDL_KEYUP,
  33. SDL_TEXTEDITING,
  34. SDL_TEXTINPUT,
  35. SDL_MOUSEMOTION = 0x400,
  36. SDL_MOUSEBUTTONDOWN,
  37. SDL_MOUSEBUTTONUP,
  38. SDL_MOUSEWHEEL,
  39. SDL_JOYAXISMOTION = 0x600,
  40. SDL_JOYBALLMOTION,
  41. SDL_JOYHATMOTION,
  42. SDL_JOYBUTTONDOWN,
  43. SDL_JOYBUTTONUP,
  44. SDL_JOYDEVICEADDED,
  45. SDL_JOYDEVICEREMOVED,
  46. SDL_CONTROLLERAXISMOTION = 0x650,
  47. SDL_CONTROLLERBUTTONDOWN,
  48. SDL_CONTROLLERBUTTONUP,
  49. SDL_CONTROLLERDEVICEADDED,
  50. SDL_CONTROLLERDEVICEREMOVED,
  51. SDL_CONTROLLERDEVICEREMAPPED,
  52. SDL_FINGERDOWN = 0x700,
  53. SDL_FINGERUP,
  54. SDL_FINGERMOTION,
  55. SDL_DOLLARGESTURE = 0x800,
  56. SDL_DOLLARRECORD,
  57. SDL_MULTIGESTURE,
  58. SDL_CLIPBOARDUPDATE = 0x900,
  59. SDL_DROPFILE = 0x1000,
  60. SDL_USEREVENT = 0x8000,
  61. SDL_LASTEVENT = 0xFFFF
  62. } SDL_EventType;
  63. typedef struct SDL_CommonEvent
  64. {
  65. Uint32 type;
  66. Uint32 timestamp;
  67. } SDL_CommonEvent;
  68. typedef struct SDL_WindowEvent
  69. {
  70. Uint32 type;
  71. Uint32 timestamp;
  72. Uint32 windowID;
  73. Uint8 event;
  74. Uint8 padding1;
  75. Uint8 padding2;
  76. Uint8 padding3;
  77. Sint32 data1;
  78. Sint32 data2;
  79. } SDL_WindowEvent;
  80. typedef struct SDL_KeyboardEvent
  81. {
  82. Uint32 type;
  83. Uint32 timestamp;
  84. Uint32 windowID;
  85. Uint8 state;
  86. Uint8 repeat;
  87. Uint8 padding2;
  88. Uint8 padding3;
  89. SDL_Keysym keysym;
  90. } SDL_KeyboardEvent;
  91. #define SDL_TEXTEDITINGEVENT_TEXT_SIZE (32)
  92. typedef struct SDL_TextEditingEvent
  93. {
  94. Uint32 type;
  95. Uint32 timestamp;
  96. Uint32 windowID;
  97. char text[SDL_TEXTEDITINGEVENT_TEXT_SIZE];
  98. Sint32 start;
  99. Sint32 length;
  100. } SDL_TextEditingEvent;
  101. #define SDL_TEXTINPUTEVENT_TEXT_SIZE (32)
  102. typedef struct SDL_TextInputEvent
  103. {
  104. Uint32 type;
  105. Uint32 timestamp;
  106. Uint32 windowID;
  107. char text[SDL_TEXTINPUTEVENT_TEXT_SIZE];
  108. } SDL_TextInputEvent;
  109. typedef struct SDL_MouseMotionEvent
  110. {
  111. Uint32 type;
  112. Uint32 timestamp;
  113. Uint32 windowID;
  114. Uint32 which;
  115. Uint32 state;
  116. Sint32 x;
  117. Sint32 y;
  118. Sint32 xrel;
  119. Sint32 yrel;
  120. } SDL_MouseMotionEvent;
  121. typedef struct SDL_MouseButtonEvent
  122. {
  123. Uint32 type;
  124. Uint32 timestamp;
  125. Uint32 windowID;
  126. Uint32 which;
  127. Uint8 button;
  128. Uint8 state;
  129. Uint8 padding1;
  130. Uint8 padding2;
  131. Sint32 x;
  132. Sint32 y;
  133. } SDL_MouseButtonEvent;
  134. typedef struct SDL_MouseWheelEvent
  135. {
  136. Uint32 type;
  137. Uint32 timestamp;
  138. Uint32 windowID;
  139. Uint32 which;
  140. Sint32 x;
  141. Sint32 y;
  142. } SDL_MouseWheelEvent;
  143. typedef struct SDL_JoyAxisEvent
  144. {
  145. Uint32 type;
  146. Uint32 timestamp;
  147. SDL_JoystickID which;
  148. Uint8 axis;
  149. Uint8 padding1;
  150. Uint8 padding2;
  151. Uint8 padding3;
  152. Sint16 value;
  153. Uint16 padding4;
  154. } SDL_JoyAxisEvent;
  155. typedef struct SDL_JoyBallEvent
  156. {
  157. Uint32 type;
  158. Uint32 timestamp;
  159. SDL_JoystickID which;
  160. Uint8 ball;
  161. Uint8 padding1;
  162. Uint8 padding2;
  163. Uint8 padding3;
  164. Sint16 xrel;
  165. Sint16 yrel;
  166. } SDL_JoyBallEvent;
  167. typedef struct SDL_JoyHatEvent
  168. {
  169. Uint32 type;
  170. Uint32 timestamp;
  171. SDL_JoystickID which;
  172. Uint8 hat;
  173. Uint8 value;
  174. Uint8 padding1;
  175. Uint8 padding2;
  176. } SDL_JoyHatEvent;
  177. typedef struct SDL_JoyButtonEvent
  178. {
  179. Uint32 type;
  180. Uint32 timestamp;
  181. SDL_JoystickID which;
  182. Uint8 button;
  183. Uint8 state;
  184. Uint8 padding1;
  185. Uint8 padding2;
  186. } SDL_JoyButtonEvent;
  187. typedef struct SDL_JoyDeviceEvent
  188. {
  189. Uint32 type;
  190. Uint32 timestamp;
  191. Sint32 which;
  192. } SDL_JoyDeviceEvent;
  193. typedef struct SDL_ControllerAxisEvent
  194. {
  195. Uint32 type;
  196. Uint32 timestamp;
  197. SDL_JoystickID which;
  198. Uint8 axis;
  199. Uint8 padding1;
  200. Uint8 padding2;
  201. Uint8 padding3;
  202. Sint16 value;
  203. Uint16 padding4;
  204. } SDL_ControllerAxisEvent;
  205. typedef struct SDL_ControllerButtonEvent
  206. {
  207. Uint32 type;
  208. Uint32 timestamp;
  209. SDL_JoystickID which;
  210. Uint8 button;
  211. Uint8 state;
  212. Uint8 padding1;
  213. Uint8 padding2;
  214. } SDL_ControllerButtonEvent;
  215. typedef struct SDL_ControllerDeviceEvent
  216. {
  217. Uint32 type;
  218. Uint32 timestamp;
  219. Sint32 which;
  220. } SDL_ControllerDeviceEvent;
  221. typedef struct SDL_TouchFingerEvent
  222. {
  223. Uint32 type;
  224. Uint32 timestamp;
  225. SDL_TouchID touchId;
  226. SDL_FingerID fingerId;
  227. float x;
  228. float y;
  229. float dx;
  230. float dy;
  231. float pressure;
  232. } SDL_TouchFingerEvent;
  233. typedef struct SDL_MultiGestureEvent
  234. {
  235. Uint32 type;
  236. Uint32 timestamp;
  237. SDL_TouchID touchId;
  238. float dTheta;
  239. float dDist;
  240. float x;
  241. float y;
  242. Uint16 numFingers;
  243. Uint16 padding;
  244. } SDL_MultiGestureEvent;
  245. typedef struct SDL_DollarGestureEvent
  246. {
  247. Uint32 type;
  248. Uint32 timestamp;
  249. SDL_TouchID touchId;
  250. SDL_GestureID gestureId;
  251. Uint32 numFingers;
  252. float error;
  253. float x;
  254. float y;
  255. } SDL_DollarGestureEvent;
  256. typedef struct SDL_DropEvent
  257. {
  258. Uint32 type;
  259. Uint32 timestamp;
  260. char *file;
  261. } SDL_DropEvent;
  262. typedef struct SDL_QuitEvent
  263. {
  264. Uint32 type;
  265. Uint32 timestamp;
  266. } SDL_QuitEvent;
  267. typedef struct SDL_OSEvent
  268. {
  269. Uint32 type;
  270. Uint32 timestamp;
  271. } SDL_OSEvent;
  272. typedef struct SDL_UserEvent
  273. {
  274. Uint32 type;
  275. Uint32 timestamp;
  276. Uint32 windowID;
  277. Sint32 code;
  278. void *data1;
  279. void *data2;
  280. } SDL_UserEvent;
  281. struct SDL_SysWMmsg;
  282. typedef struct SDL_SysWMmsg SDL_SysWMmsg;
  283. typedef struct SDL_SysWMEvent
  284. {
  285. Uint32 type;
  286. Uint32 timestamp;
  287. SDL_SysWMmsg *msg;
  288. } SDL_SysWMEvent;
  289. typedef union SDL_Event
  290. {
  291. Uint32 type;
  292. SDL_CommonEvent common;
  293. SDL_WindowEvent window;
  294. SDL_KeyboardEvent key;
  295. SDL_TextEditingEvent edit;
  296. SDL_TextInputEvent text;
  297. SDL_MouseMotionEvent motion;
  298. SDL_MouseButtonEvent button;
  299. SDL_MouseWheelEvent wheel;
  300. SDL_JoyAxisEvent jaxis;
  301. SDL_JoyBallEvent jball;
  302. SDL_JoyHatEvent jhat;
  303. SDL_JoyButtonEvent jbutton;
  304. SDL_JoyDeviceEvent jdevice;
  305. SDL_ControllerAxisEvent caxis;
  306. SDL_ControllerButtonEvent cbutton;
  307. SDL_ControllerDeviceEvent cdevice;
  308. SDL_QuitEvent quit;
  309. SDL_UserEvent user;
  310. SDL_SysWMEvent syswm;
  311. SDL_TouchFingerEvent tfinger;
  312. SDL_MultiGestureEvent mgesture;
  313. SDL_DollarGestureEvent dgesture;
  314. SDL_DropEvent drop;
  315. Uint8 padding[56];
  316. } SDL_Event;
  317. typedef void SDLCALL tSDL_PumpEvents(void);
  318. typedef enum
  319. {
  320. SDL_ADDEVENT,
  321. SDL_PEEKEVENT,
  322. SDL_GETEVENT
  323. } SDL_eventaction;
  324. typedef int SDLCALL tSDL_PeepEvents(SDL_Event * events, int numevents,
  325. SDL_eventaction action,
  326. Uint32 minType, Uint32 maxType);
  327. typedef SDL_bool SDLCALL tSDL_HasEvent(Uint32 type);
  328. typedef SDL_bool SDLCALL tSDL_HasEvents(Uint32 minType, Uint32 maxType);
  329. typedef void SDLCALL tSDL_FlushEvent(Uint32 type);
  330. typedef void SDLCALL tSDL_FlushEvents(Uint32 minType, Uint32 maxType);
  331. typedef int SDLCALL tSDL_PollEvent(SDL_Event * event);
  332. typedef int SDLCALL tSDL_WaitEvent(SDL_Event * event);
  333. typedef int SDLCALL tSDL_WaitEventTimeout(SDL_Event * event,
  334. int timeout);
  335. typedef int SDLCALL tSDL_PushEvent(SDL_Event * event);
  336. typedef int (SDLCALL * SDL_EventFilter) (void *userdata, SDL_Event * event);
  337. typedef void SDLCALL tSDL_SetEventFilter(SDL_EventFilter filter,
  338. void *userdata);
  339. typedef SDL_bool SDLCALL tSDL_GetEventFilter(SDL_EventFilter * filter,
  340. void **userdata);
  341. typedef void SDLCALL tSDL_AddEventWatch(SDL_EventFilter filter,
  342. void *userdata);
  343. typedef void SDLCALL tSDL_DelEventWatch(SDL_EventFilter filter,
  344. void *userdata);
  345. typedef void SDLCALL tSDL_FilterEvents(SDL_EventFilter filter,
  346. void *userdata);
  347. #define SDL_QUERY -1
  348. #define SDL_IGNORE 0
  349. #define SDL_DISABLE 0
  350. #define SDL_ENABLE 1
  351. typedef Uint8 SDLCALL tSDL_EventState(Uint32 type, int state);
  352. #define SDL_GetEventState(type) SDL_EventState(type, SDL_QUERY)
  353. typedef Uint32 SDLCALL tSDL_RegisterEvents(int numevents);
  354. extern tSDL_PumpEvents *SDL_PumpEvents;
  355. extern tSDL_PeepEvents *SDL_PeepEvents;
  356. extern tSDL_HasEvent *SDL_HasEvent;
  357. extern tSDL_HasEvents *SDL_HasEvents;
  358. extern tSDL_FlushEvent *SDL_FlushEvent;
  359. extern tSDL_FlushEvents *SDL_FlushEvents;
  360. extern tSDL_PollEvent *SDL_PollEvent;
  361. extern tSDL_WaitEvent *SDL_WaitEvent;
  362. extern tSDL_WaitEventTimeout *SDL_WaitEventTimeout;
  363. extern tSDL_PushEvent *SDL_PushEvent;
  364. extern tSDL_SetEventFilter *SDL_SetEventFilter;
  365. extern tSDL_GetEventFilter *SDL_GetEventFilter;
  366. extern tSDL_AddEventWatch *SDL_AddEventWatch;
  367. extern tSDL_DelEventWatch *SDL_DelEventWatch;
  368. extern tSDL_FilterEvents *SDL_FilterEvents;
  369. extern tSDL_EventState *SDL_EventState;
  370. extern tSDL_RegisterEvents *SDL_RegisterEvents;
  371. #ifdef __cplusplus
  372. }
  373. #endif
  374. #include "close_code.h"
  375. #endif