162 lines
2.4 KiB
C
162 lines
2.4 KiB
C
////////////////////////////////////////////////////////////
|
|
//~ Controller button types
|
|
|
|
Enum(Button)
|
|
{
|
|
Button_None,
|
|
|
|
//- Mouse buttons
|
|
Button_M1,
|
|
Button_M2,
|
|
Button_M3,
|
|
Button_M4,
|
|
Button_M5,
|
|
|
|
//- Mouse wheel
|
|
Button_MWheelUp,
|
|
Button_MWheelDown,
|
|
|
|
//- Keyboard buttons
|
|
Button_Escape,
|
|
Button_F1,
|
|
Button_F2,
|
|
Button_F3,
|
|
Button_F4,
|
|
Button_F5,
|
|
Button_F6,
|
|
Button_F7,
|
|
Button_F8,
|
|
Button_F9,
|
|
Button_F10,
|
|
Button_F11,
|
|
Button_F12,
|
|
Button_F13,
|
|
Button_F14,
|
|
Button_F15,
|
|
Button_F16,
|
|
Button_F17,
|
|
Button_F18,
|
|
Button_F19,
|
|
Button_F20,
|
|
Button_F21,
|
|
Button_F22,
|
|
Button_F23,
|
|
Button_F24,
|
|
Button_GraveAccent,
|
|
Button_0,
|
|
Button_1,
|
|
Button_2,
|
|
Button_3,
|
|
Button_4,
|
|
Button_5,
|
|
Button_6,
|
|
Button_7,
|
|
Button_8,
|
|
Button_9,
|
|
Button_Minus,
|
|
Button_Equal,
|
|
Button_Backspace,
|
|
Button_Delete,
|
|
Button_Tab,
|
|
Button_A,
|
|
Button_B,
|
|
Button_C,
|
|
Button_D,
|
|
Button_E,
|
|
Button_F,
|
|
Button_G,
|
|
Button_H,
|
|
Button_I,
|
|
Button_J,
|
|
Button_K,
|
|
Button_L,
|
|
Button_M,
|
|
Button_N,
|
|
Button_O,
|
|
Button_P,
|
|
Button_Q,
|
|
Button_R,
|
|
Button_S,
|
|
Button_T,
|
|
Button_U,
|
|
Button_V,
|
|
Button_W,
|
|
Button_X,
|
|
Button_Y,
|
|
Button_Z,
|
|
Button_Space,
|
|
Button_Enter,
|
|
Button_Ctrl,
|
|
Button_Shift,
|
|
Button_Alt,
|
|
Button_Up,
|
|
Button_Left,
|
|
Button_Down,
|
|
Button_Right,
|
|
Button_PageUp,
|
|
Button_PageDown,
|
|
Button_Home,
|
|
Button_End,
|
|
Button_ForwardSlash,
|
|
Button_Period,
|
|
Button_Comma,
|
|
Button_Quote,
|
|
Button_LeftBracket,
|
|
Button_RightBracket,
|
|
Button_Insert,
|
|
Button_Semicolon,
|
|
|
|
Button_COUNT
|
|
};
|
|
|
|
////////////////////////////////////////////////////////////
|
|
//~ Controller event types
|
|
|
|
Enum(ControllerEventKind)
|
|
{
|
|
ControllerEventKind_None,
|
|
|
|
ControllerEventKind_ButtonDown,
|
|
ControllerEventKind_ButtonUp,
|
|
|
|
ControllerEventKind_CursorMove,
|
|
ControllerEventKind_MouseMove,
|
|
|
|
ControllerEventKind_Text,
|
|
|
|
ControllerEventKind_Quit,
|
|
|
|
ControllerEventKind_COUNT
|
|
};
|
|
|
|
Struct(ControllerEvent)
|
|
{
|
|
ControllerEventKind kind;
|
|
|
|
// ControllerEventKind_ButtonDown
|
|
// ControllerEventKind_ButtonUp
|
|
Button button;
|
|
b32 is_repeat;
|
|
|
|
// ControllerEventKind_Text
|
|
u32 text_codepoint;
|
|
|
|
// ControllerEventKind_CursorMove
|
|
Vec2I32 cursor_pos;
|
|
|
|
// ControllerEventKind_MouseMove
|
|
Vec2I32 mouse_delta;
|
|
};
|
|
|
|
Struct(ControllerEventsArray)
|
|
{
|
|
u64 count;
|
|
ControllerEvent *events;
|
|
};
|
|
|
|
////////////////////////////////////////////////////////////
|
|
//~ Button helpers
|
|
|
|
String StringFromButton(Button button);
|
|
b32 IsMouseButton(Button button);
|