diff --git a/input.c b/input.c index 6ccbb22..0f6fd6d 100644 --- a/input.c +++ b/input.c @@ -17,19 +17,23 @@ const char *input_KeyNames[input_Key_Count] = { "Spell", "Use", "Dash", - "Escape"}; + "Escape", + "Left Mouse Button", + "Right Mouse Button"}; void input_SetDefaultKeymap(System_Input *sys) { - sys->systemKeymap[input_Key_Up] = 'W'; - sys->systemKeymap[input_Key_Left] = 'A'; - sys->systemKeymap[input_Key_Down] = 'S'; - sys->systemKeymap[input_Key_Right] = 'D'; - sys->systemKeymap[input_Key_Jump] = VK_SPACE; - sys->systemKeymap[input_Key_Attack] = 'J'; - sys->systemKeymap[input_Key_Spell] = 'K'; - sys->systemKeymap[input_Key_Use] = 'L'; - sys->systemKeymap[input_Key_Dash] = VK_OEM_1; // The ;: key on the US keyboard - sys->systemKeymap[input_Key_Escape] = VK_ESCAPE; + sys->systemKeymap[input_Key_Up] = 'W'; + sys->systemKeymap[input_Key_Left] = 'A'; + sys->systemKeymap[input_Key_Down] = 'S'; + sys->systemKeymap[input_Key_Right] = 'D'; + sys->systemKeymap[input_Key_Jump] = VK_SPACE; + sys->systemKeymap[input_Key_Attack] = 'J'; + sys->systemKeymap[input_Key_Spell] = 'K'; + sys->systemKeymap[input_Key_Use] = 'L'; + sys->systemKeymap[input_Key_Dash] = VK_OEM_1; // The ;: key on the US keyboard + sys->systemKeymap[input_Key_Escape] = VK_ESCAPE; + sys->systemKeymap[input_Key_LeftMouse] = VK_LBUTTON; + sys->systemKeymap[input_Key_RightMouse] = VK_RBUTTON; } System_Input *input_NewSystem(App *super) { @@ -78,3 +82,11 @@ void input_Advance(System_Input *sys) { sys->super->paused = !sys->super->paused; } } + + +Vec2 input_MousePosition(System_Input *sys) { + POINT point; + GetCursorPos(&point); + ScreenToClient((HWND)sys->super->window, &point); + return vec2(point.x, point.y); +} diff --git a/input.h b/input.h index 820c37a..a6f0d8a 100644 --- a/input.h +++ b/input.h @@ -1,5 +1,6 @@ #pragma once +#include "types.h" #include #include @@ -21,6 +22,8 @@ typedef enum { input_Key_Use, input_Key_Dash, input_Key_Escape, + input_Key_LeftMouse, + input_Key_RightMouse, input_Key_Count } input_Key; @@ -63,6 +66,10 @@ void input_SetDefaultKeymap(System_Input *sys); void input_Advance(System_Input *sys); +// Get where the mouse is right now +Vec2 input_MousePosition(System_Input *sys); + + #ifdef __cplusplus } #endif