timesynk/engine/ts_event.h

57 lines
1.4 KiB
C

/*
================================================================
TSEvent and related structures
Timesynk's Event structure mirrors, to some extent, SDL's own. Input/Events generated from within an interface, such as SDL, must be converted into the appropriate TSEvent and passed to the given State's handleState function (i.e., handleMenuState(TSEvent *ts_event)).
As it stands, TSEvent(s) do not cache or poll a list of unhandled TSEvents, but rather handle new TSEvent(s) as they are generated. This model may change in the future.
================================================================
*/
#ifndef TS_EVENT
#define TS_EVENT
#include <SDL/SDL.h> // FIXME: using this for keysym stuff for now
#define TS_KEYDOWN 0
#define TS_KEYUP 1
enum TSEventType { TS_WINDOW, TS_KEYBOARD, TS_MOUSECLICK, TS_MOUSEMOVE };
struct TSEvent_Key {
int scancode;
SDLMod mod;
SDLKey sym; // ripped from SDL?
Uint16 unicode;
};
struct TSEvent_Keyboard {
int state;
struct TSEvent_Key key;
};
struct TSEvent_Window {
int eventcode;
};
struct TSEvent_Mouseclick {
int state;
int button;
int x;
int y;
};
struct TSEvent_Mousemove {
int x;
int y;
};
struct TSEvent {
enum TSEventType type;
union {
struct TSEvent_Keyboard keyboard;
struct TSEvent_Window window;
struct TSEvent_Mouseclick mouseclick;
struct TSEvent_Mousemove mousemove;
};
};
#endif