-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinput.h
35 lines (28 loc) · 995 Bytes
/
input.h
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
29
30
31
32
33
34
35
#pragma once
#include "template.h"
#include <SDL_keycode.h>
#include <SDL_mouse.h>
constexpr int keys = SDL_NUM_SCANCODES;
constexpr int mouseButtons = 5;
class Input
{
public:
static bool GetKeyDown(SDL_Scancode key);
static bool GetKeyUp(SDL_Scancode key);
static bool GetKey(SDL_Scancode key);
static void SetKeyState(SDL_Scancode key, bool state);
static bool GetMouseButtonDown(int button);
static bool GetMouseButtonUp(int button);
static bool GetMouseButton(int button);
static void SetMouseState(int button, bool state);
static void SetMouseWheel(int y) { mouseWheel = y; }
static int GetMouseWheel() { return mouseWheel; }
static Tmpl8::vec2 GetMousePosition() { return mousePosition; }
static void SetMousePosition(Sint32 x, Sint32 y) { mousePosition.x = static_cast<float>(x), mousePosition.y = static_cast<float>(y); }
static void Update();
private:
static int keyStates[];
static int mouseStates[];
static Tmpl8::vec2 mousePosition;
static int mouseWheel;
};