/
Input.h
50 lines (38 loc) · 879 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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#ifndef INPUT_H
#define INPUT_H
#include <Windows.h>
#include <dinput.h>
#include "Vector.h"
#include "d3dUtil.h"
//! Wrapper for input with keyboard and mouse.
class Input
{
public:
Input();
~Input();
void update(float dt);
void draw();
void poll();
bool keyPressed(int key);
bool keyDown(int key);
bool keyReleased(int key);
void getWorldPickingRay(D3DXVECTOR3& originW, D3DXVECTOR3& dirW);
float mouseDx();
float mouseDy();
float mouseDz();
Vector mousePosition();
void setMousePosition(Vector pos);
LRESULT msgProc(UINT msg, WPARAM wParam, LPARAM lParam);
private:
unsigned char mLastKeyState[256];
unsigned char mKeyState[256];
IDirectInput8* mDInput;
IDirectInputDevice8* mMouse;
DIMOUSESTATE2 mMouseState;
DIMOUSESTATE2 mLastMouseState;
Vector mMousePosition;
float mDx, mDy;
};
// Global
extern Input* gInput;
#endif