Avionics
Dropship Simulator
Keyboard.h
Go to the documentation of this file.
1 #pragma once
2 
3 // have to include these in this order because bass.h refers to something that screws it up
4 #include <WinSock2.h>
5 #include <Windows.h>
6 //#include <WS2tcpip.h>
7 
8 #define DIRECTINPUT_VERSION 0x0800
9 #include <dinput.h>
10 #include "Bus.h"
11 
12 namespace Devices
13 {
15  {
16  GUID serialno = GUID_NULL;
17  bool enable;
18 
21 
22  struct Buffer
23  {
24  std::string input;
26  std::vector<Command> commands;
27  };
28 
29  std::vector<Buffer> buffers;
30 
31  struct Key
32  {
33  UINT input;
34  std::vector<Command> commands;
35  };
36 
37  std::vector<Key> keys;
38  };
39 
40  class Keyboard
41  {
42  private:
43  LPDIRECTINPUTDEVICE8 g_pKeyboard = nullptr;
44 
45  static BOOL CALLBACK EnumKeyboardsCallback(const DIDEVICEINSTANCE* pdidInstance, VOID* pContext);
46  //static BOOL CALLBACK EnumObjectsCallback(const DIDEVICEOBJECTINSTANCE* pdidoi, VOID* pContext);
47 
48  HKL hkl = nullptr;
50  unsigned char keyboardState[256];
52  unsigned char oldKeyboardState[256];
53 
54  void BufferProc(bool bEnterKey);
55  static void SetNumLock(bool bState);
56 
57  Logger* logger = nullptr;
58  Bus* bus = nullptr;
60 
61  float timeSinceLastKeypress = 0.0f;
62  char buffer[10];
63 
64  bool shift = false;
65  bool ctrl = false;
66  bool alt = false;
67 
68  std::vector<HWND> hwnds;
69 
70  public:
71  void FrameMove(float fElapsed);
72 
73  void Initialize(Logger* logger, KeyboardConfig* config, Bus* prmBus, LPDIRECTINPUT8 g_pDI);
74 
75  void SetWindowHandles(std::vector<HWND> prmHwnds)
76  {
77  hwnds = prmHwnds;
78  }
79 
80  void Destroy();
81  };
82 }
LPDIRECTINPUTDEVICE8 g_pKeyboard
Definition: Keyboard.h:43
std::vector< Command > commands
Definition: Keyboard.h:26
char buffer[10]
Definition: Keyboard.h:62
void BufferProc(bool bEnterKey)
Definition: Keyboard.cpp:7
unsigned char keyboardState[256]
contains state of keyboard
Definition: Keyboard.h:50
static BOOL CALLBACK EnumKeyboardsCallback(const DIDEVICEINSTANCE *pdidInstance, VOID *pContext)
Definition: Keyboard.cpp:302
std::vector< Command > commands
Definition: Keyboard.h:34
Definition: Logger.h:5
LPDIRECTINPUT8 g_pDI
Definition: Avionics.cpp:16
okay, the portable keyboard numbers don&#39;t work like the outside keypad because the outside keypad is ...
Definition: Analog.cpp:3
Config config
Definition: Avionics.cpp:22
void FrameMove(float fElapsed)
Definition: Keyboard.cpp:84
Definition: Bus.h:12
static void SetNumLock(bool bState)
Definition: Keyboard.cpp:284
KeyboardConfig * keyboardConfig
Definition: Keyboard.h:59
void SetWindowHandles(std::vector< HWND > prmHwnds)
Definition: Keyboard.h:75
unsigned char oldKeyboardState[256]
contains previous state of keyboard
Definition: Keyboard.h:52
std::vector< Key > keys
Definition: Keyboard.h:37
void Initialize(Logger *logger, KeyboardConfig *config, Bus *prmBus, LPDIRECTINPUT8 g_pDI)
Definition: Keyboard.cpp:19
Logger * logger
Definition: Keyboard.h:57
std::vector< Buffer > buffers
Definition: Keyboard.h:29
std::vector< HWND > hwnds
Definition: Keyboard.h:68
float timeSinceLastKeypress
Definition: Keyboard.h:61