My Project
GUIKeyboardVirtual.h
1 #pragma once
2 
3 #define SAMPLE_BUFFER_SIZE 1024
4 #define KEY_PRESSED(x,y) (((x)[(y)]&0x80)!=0)
5 
6 namespace ParaEngine
7 {
8  class CGUIBase;
9 
13  {
14  public:
17 
19  virtual bool IsUseWindowsMessage();
21  virtual void SetUseWindowsMessage(bool bUseWinMsg);
22 
24  virtual void PushKeyEvent(UINT uMsg, WPARAM wParam, LPARAM lParam);
26  virtual void PushKeyEvent(const MSG &msg);
27 
29  virtual void Update();
30 
33  virtual bool IsKeyPressed(DWORD nKey);
34  virtual void SetKeyPressed(DWORD nKey, bool bPressed);
35  virtual void Reset();
36 
37  virtual HRESULT ReadBufferedData();
38  virtual HRESULT ReadImmediateData();
39 
40  virtual BYTE GetLastKeyState(int nIndex);
41  virtual BYTE GetCurrentKeyState(int nIndex);
42  virtual short GetKeyState(int nIndex);
43  inline BYTE* GetKeyStates(){ return m_keystate; }
44 
45  DWORD GetElementsCount() const;
46  void SetElementsCount(DWORD val);
47 
48  inline DIDEVICEOBJECTDATA* GetDeviceObjectData(){
49  return m_didod;
50  }
51  public:
52  static void SetCapture(CGUIBase* obj);
53  static void ReleaseCapture();
54  static void ReleaseCapture(CGUIBase* obj);
55  static CGUIBase* GetCapture();
56 
57  protected:
58  DWORD m_dwElements;
59 
60  BYTE m_keystate[256]; // DirectInput keyboard state buffer
61 
62  BYTE m_lastkeystate[256]; //last DirectInput keyboard state buffer
63  DIDEVICEOBJECTDATA m_didod[SAMPLE_BUFFER_SIZE]; // Receives buffered data
64 
65  static CGUIBase * m_objCaptured;
68 
69  MSG m_buffered_key_msgs[SAMPLE_BUFFER_SIZE / 2];
70  int m_buffered_key_msgs_count;
71  };
72 }
Definition: RenderCoreOpenGL.h:38
virtual void SetUseWindowsMessage(bool bUseWinMsg)
whether to use window message for buffered mouse event.
Definition: GUIKeyboardVirtual.cpp:174
bool m_bUseWindowMessage
whether to use window message for buffered mouse event.
Definition: GUIKeyboardVirtual.h:67
Definition: EventBinding.h:22
different physics engine has different winding order.
Definition: EventBinding.h:32
virtual bool IsUseWindowsMessage()
whether to use window message for buffered mouse event.
Definition: GUIKeyboardVirtual.cpp:169
base object for all 2D GUI objects (1) 2D GUI object are not tested against view frustum, instead it is controlled by visibility tag automatically or through user input.
Definition: GUIBase.h:54
virtual void PushKeyEvent(UINT uMsg, WPARAM wParam, LPARAM lParam)
push a standard windows key event to the buffer for processing in the next frame move.
Definition: GUIKeyboardVirtual.cpp:55
virtual bool IsKeyPressed(DWORD nKey)
return true if the key is being pressed at the time of calling.
Definition: GUIKeyboardVirtual.cpp:35
virtual HRESULT ReadBufferedData()
Definition: GUIKeyboardVirtual.cpp:79
virtual void Update()
read hardware buffer and immediate keyboard states to internal data structure.
Definition: GUIKeyboardVirtual.cpp:110
base class for keyboard system.
Definition: GUIKeyboardVirtual.h:12