-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInput.h
More file actions
51 lines (46 loc) · 915 Bytes
/
Input.h
File metadata and controls
51 lines (46 loc) · 915 Bytes
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#pragma once
#ifndef Input_H
#define Input_H
#include <SDL.h>
#include <iostream>
struct Point {
Point(){}
Point(int x_, int y_) {
x = x_;
y = y_;
}
int x;
int y;
};
const int Key_Up = 0;
const int Key_Down = 1;
const int Key_Keep = 2;
const int Key_None = 3;
#pragma message ("Loading Input...")
class Input {
public:
//初始化
int CreateInput();
//更新
int Updata();
//键盘状态
int GetKeyState(SDL_Scancode key);
//鼠标状态
int GetMouseState(int button);
bool GetMouseMove();
struct Point* GetNowPoint() { return &nowPoint; };
struct Point* GetbeforePoint() { return &beforePoint; };
private:
//现在的键盘状态
Uint8 nowKeyState[SDL_NUM_SCANCODES];
//上一帧键盘状态
Uint8 beforeKeyState[SDL_NUM_SCANCODES];
//现在鼠标状态
struct Point nowPoint;
Uint32 nowMouseState;
//上一帧鼠标状态
struct Point beforePoint;
Uint32 beforeMouseState;
};
#pragma message ("Input is loaded")
#endif