C++ Game Framework  2013-06-04
CGF is a DirectX 11 game framework, built in C++ and DirectX 11. This is used to contain many to the DirectX functionality and wrap them into a framework to make game development easier.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Input.h
Go to the documentation of this file.
1 // Filename: Input.h
4 
5 //Preprocessor directive designed to cause the current source file to be included only once in a single compilation
6 #pragma once
7 
8 //Includes
9 #include <dinput.h>
10 #include "Vector2f.h"
11 #include "InputKey.h"
12 #include "CGFInclude.h"
13 
14 enum
15 {
18 };
19 
21 {
22  IM_LMB = 0,
23  IM_RMB = 1,
24  IM_MMB = 2
25 };
26 
27 namespace CGF
28 {
29  class CGF_API Input
30  {
31  friend class GameEngine;
32 
33  public:
34  bool IsKeyDown(InputKey key);
35  bool IsKeyUp(InputKey key);
36  bool IsKeyPressed(InputKey key);
37  bool IsKeyReleased(InputKey key);
38 
39  bool IsMouseButtonDown(MouseButton button);
40  bool IsMouseButtonUp(MouseButton button);
41  bool IsMouseButtonPressed(MouseButton button);
42  bool IsMouseButtonReleased(MouseButton button);
43 
44  Vector2f GetMousePosition();
45 
46  private:
47  Input();
48  ~Input();
49 
50  bool Initialize(HINSTANCE hinstance, HWND hwnd, int screenWidth, int screenHeight);
51  void Shutdown();
52  bool Update();
53 
54  bool ReadKeyboard();
55  bool ReadMouse();
56  void ProcessInput();
57 
58  private:
59  IDirectInput8* m_directInput;
60  IDirectInputDevice8* m_keyboard;
61  IDirectInputDevice8* m_mouse;
62 
63  unsigned char m_keyboardState1[256];
64  unsigned char m_keyboardState2[256];
65 
66  DIMOUSESTATE m_mouseState;
67  Vector2f m_mousePosition1;
68  byte* m_mouseButtons1;
69  Vector2f m_mousePosition2;
70  byte* m_mouseButtons2;
71 
72  float m_screenWidth, m_screenHeight;
73  unsigned int m_currentState;
74  };
75 }