| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
#pragma once |
| 29 |
|
| 30 |
#include <SDL_events.h> |
| 31 |
|
| 32 |
#include "joystick.h" |
| 33 |
#include "keyboard.h" |
| 34 |
#include "mouse.h" |
| 35 |
#include "player.h" |
| 36 |
|
| 37 |
typedef struct |
| 38 |
{ |
| 39 |
keyboard_t keyboard; |
| 40 |
CArray joysticks; |
| 41 |
Mouse mouse; |
| 42 |
|
| 43 |
char *DropFile; |
| 44 |
|
| 45 |
bool HasResolutionChanged; |
| 46 |
bool HasQuit; |
| 47 |
bool HasLostFocus; |
| 48 |
int DemoQuitTimer; |
| 49 |
} EventHandlers; |
| 50 |
|
| 51 |
extern EventHandlers gEventHandlers; |
| 52 |
|
| 53 |
void EventInit(EventHandlers *handlers); |
| 54 |
void EventTerminate(EventHandlers *handlers); |
| 55 |
void EventReset(EventHandlers *handlers); |
| 56 |
|
| 57 |
void EventPoll( |
| 58 |
EventHandlers *handlers, const Uint32 ticks, int (*onEvent)(SDL_Event *)); |
| 59 |
|
| 60 |
int GetOnePlayerCmd( |
| 61 |
EventHandlers *handlers, const bool isPressed, const input_device_e device, |
| 62 |
const int deviceIndex); |
| 63 |
int GetGameCmd(EventHandlers *handlers, const PlayerData *playerData); |
| 64 |
int GetKeyboardCmd( |
| 65 |
keyboard_t *keyboard, const int kbIndex, const bool isPressed); |
| 66 |
SDL_Scancode GetKey(EventHandlers *handlers); |
| 67 |
|
| 68 |
SDL_Scancode EventWaitKeyOrText(EventHandlers *handlers); |
| 69 |
typedef enum |
| 70 |
{ |
| 71 |
EVENT_WAIT_CONTINUE, |
| 72 |
EVENT_WAIT_OK, |
| 73 |
EVENT_WAIT_CANCEL |
| 74 |
} EventWaitResult; |
| 75 |
EventWaitResult EventWaitForAnyKeyOrButton(void); |
| 76 |
void GetPlayerCmds(EventHandlers *handlers, int (*cmds)[MAX_LOCAL_PLAYERS]); |
| 77 |
int GetMenuCmd(EventHandlers *handlers, const bool useMouse); |
| 78 |
void InputGetButtonNameColor( |
| 79 |
const input_device_e d, const int dIndex, const int cmd, char *buf, |
| 80 |
color_t *color); |
| 81 |
#define InputGetButtonName(_d, _dIndex, _cmd, _buf) \ |
| 82 |
InputGetButtonNameColor(_d, _dIndex, _cmd, _buf, NULL) |
| 83 |
|
| 84 |
void InputGetDirectionNames( |
| 85 |
char *buf, const input_device_e d, const int dIndex); |
| 86 |
bool InputHasGrenadeButton(const input_device_e d, const int dIndex); |
| 87 |
|
| 88 |
bool EventIsEscape( |
| 89 |
EventHandlers *handlers, const int cmds[MAX_LOCAL_PLAYERS], |
| 90 |
const int menuCmd); |