Add mouse tracking in Input
This commit is contained in:
parent
9c2c8ef1c0
commit
b2978f4989
14
input.c
14
input.c
@ -17,7 +17,9 @@ 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';
|
||||
@ -30,6 +32,8 @@ void input_SetDefaultKeymap(System_Input *sys) {
|
||||
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);
|
||||
}
|
||||
|
7
input.h
7
input.h
@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "types.h"
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user