104 lines
No EOL
1.8 KiB
C++
104 lines
No EOL
1.8 KiB
C++
#pragma once
|
|
|
|
#include <functional>
|
|
|
|
enum MouseButton
|
|
{
|
|
Left = 0,
|
|
Right = 1
|
|
};
|
|
|
|
enum Key
|
|
{
|
|
A = 0,
|
|
B = 1,
|
|
C = 2,
|
|
D = 3,
|
|
E = 4,
|
|
F = 5,
|
|
G = 6,
|
|
H = 7,
|
|
I = 8,
|
|
J = 9,
|
|
K = 10,
|
|
L = 11,
|
|
M = 12,
|
|
N = 13,
|
|
O = 14,
|
|
P = 15,
|
|
Q = 16,
|
|
R = 17,
|
|
S = 18,
|
|
T = 19,
|
|
U = 20,
|
|
V = 21,
|
|
W = 22,
|
|
X = 23,
|
|
Y = 24,
|
|
Z = 25,
|
|
Tab = 26,
|
|
LeftArrow = 27,
|
|
RightArrow = 28,
|
|
UpArrow = 29,
|
|
DownArrow = 30,
|
|
PageUp = 31,
|
|
PageDown = 32,
|
|
Home = 33,
|
|
End = 34,
|
|
Delete = 35,
|
|
Backspace = 36,
|
|
Enter = 37,
|
|
Escape = 38,
|
|
LeftControl = 39,
|
|
RightControl = 40,
|
|
LeftShift = 41,
|
|
RightShift = 42,
|
|
LeftAlt = 43,
|
|
RightAlt = 44,
|
|
LeftSuper = 45,
|
|
RightSuper = 46
|
|
};
|
|
|
|
enum KeyState
|
|
{
|
|
Release = 0,
|
|
Press = 1,
|
|
Repeat = 2
|
|
};
|
|
|
|
class Input
|
|
{
|
|
public:
|
|
static void NewFrame(); //needed for some input like scrolling
|
|
|
|
static bool IsMouseDown(int button);
|
|
static bool IsMouseClicked(int button);
|
|
|
|
static void GetMousePosition(double& x, double& y);
|
|
|
|
static float GetScrollDelta();
|
|
|
|
static bool IsKeyDown(int key);
|
|
static bool IsKeyPressed(int key);
|
|
|
|
static void FeedMouseState(int button, int state);
|
|
static void FeedMousePosition(float x, float y);
|
|
static void FeedKeyState(int key, int state);
|
|
static void FeedScroll(double y);
|
|
static void FeedChar(unsigned int c);
|
|
|
|
static std::function<void(int, int)> mouseButtonCallback;
|
|
static std::function<void(int, int)> keyButtonCallback;
|
|
static std::function<void(unsigned int)> charCallback;
|
|
|
|
private:
|
|
static int m_mouseState[2];
|
|
static int m_lastMouseState[2];
|
|
|
|
static double m_mouseX;
|
|
static double m_mouseY;
|
|
|
|
static double m_currentScroll;
|
|
|
|
static int m_keyState[26];
|
|
}; |