My Project
GUIMouseVirtual.h
1 #pragma once
2 
3 
4 #define L_PRESSED(x) (((x)->m_dims2.rgbButtons[0]&0x80)!=0)
5 #define R_PRESSED(x) (((x)->m_dims2.rgbButtons[1]&0x80)!=0)
6 #define M_PRESSED(x) (((x)->m_dims2.rgbButtons[2]&0x80)!=0)
7 
8 #define SAMPLE_BUFFER_SIZE 1024
9 
10 namespace ParaEngine
11 {
15  {
16  public:
18  virtual ~CGUIMouseVirtual();
19  public:
22  LEFT_BUTTON = 0,
23  RIGHT_BUTTON = 1,
24  MIDDLE_BUTTON = 2
25  };
26  virtual HRESULT ReadBufferedData();
27  virtual HRESULT ReadImmediateData();
28  virtual void Update();
30  virtual void ResetLastMouseState();
31 
32  virtual void Reset();
33  virtual bool IsButtonDown(MOUSE_KEY_STD nMouseButton);
35  virtual int GetMouseWheelDeltaSteps();
37  virtual int GetMouseXDeltaSteps();
39  virtual int GetMouseYDeltaSteps();
40 
41  virtual bool IsLocked();
43  virtual void SetLock(bool bLock);;
44 
45  virtual void UpdateX(int delta);
46  virtual void UpdateY(int delta);
47 
48 
50  virtual void PushMouseEvent(UINT uMsg, WPARAM wParam, LPARAM lParam);
52  virtual void PushMouseEvent(const MSG &msg);
53 
54  virtual void SetCapture(CGUIBase* obj);
55  virtual void ReleaseCapture(CGUIBase* obj);
56  virtual CGUIBase* GetCapture();
57  virtual void ReleaseCapture();
58 
60  virtual bool IsUseWindowsMessage();
62  virtual void SetUseWindowsMessage(bool bUseWinMsg);
63 
65  virtual void ShowCursor(bool bShowCursor){};
66 
68  virtual void ForceShowCursor(bool bShow){};
69 
71  virtual int GetCursorSize(){ return 32; };
72 
74  virtual bool IsMouseButtonSwapped();
75  virtual void SetMouseButtonSwapped(bool bSwapped);
76 
78  virtual void GetDeviceCursorPos(int& x, int&y);
79  virtual void SetDeviceCursorPos(int x, int y);
81  virtual void SetMousePosition(int x, int y);
82 
84  virtual int GetBufferedMessageCount();;
85  protected:
86 
87  bool m_bLock;
92  bool m_bLastMouseReset;
93  public:
94  DIDEVICEOBJECTDATA m_didod[SAMPLE_BUFFER_SIZE]; // Receives buffered data
95  DWORD m_dwElements;
96  DIMOUSESTATE2 m_dims2; // DirectInput Mouse state buffer
97  DIMOUSESTATE2 m_lastMouseState;
98  DIMOUSESTATE2 m_curMouseState;
99  int m_x, m_y; //coordinate of the current mouse position
100 
101  MSG m_buffered_mouse_msgs[SAMPLE_BUFFER_SIZE / 2];
102  int m_buffered_mouse_msgs_count;
103 
104  bool m_isTouchInputting;
105 
106  CGUIBase * m_objCaptured;
107  };
108 }
Definition: RenderCoreOpenGL.h:38
virtual bool IsUseWindowsMessage()
whether to use window message for buffered mouse event.
Definition: GUIMouseVirtual.cpp:45
bool m_bSwapMouseButton
swap left/right button.
Definition: GUIMouseVirtual.h:91
Definition: EventBinding.h:22
different physics engine has different winding order.
Definition: EventBinding.h:32
virtual int GetBufferedMessageCount()
check if there is any unprocessed buffered window mouse message.
Definition: GUIMouseVirtual.cpp:287
virtual void SetMousePosition(int x, int y)
only change m_x, m_y, which is pretty fast.
Definition: GUIMouseVirtual.cpp:273
virtual HRESULT ReadBufferedData()
Definition: GUIMouseVirtual.cpp:155
virtual void ResetLastMouseState()
reset mouse to make the mouse delta correct in the next frame.
Definition: GUIMouseVirtual.cpp:292
virtual int GetCursorSize()
get the cursor size in pixels
Definition: GUIMouseVirtual.h:71
virtual void ShowCursor(bool bShowCursor)
true to show the cursor.
Definition: GUIMouseVirtual.h:65
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 bool IsMouseButtonSwapped()
swap left/right button.
Definition: GUIMouseVirtual.cpp:251
virtual void SetUseWindowsMessage(bool bUseWinMsg)
whether to use window message for buffered mouse event.
Definition: GUIMouseVirtual.cpp:50
virtual int GetMouseXDeltaSteps()
the current mouse X delta in steps, such as -2,-1,0,1,2
Definition: GUIMouseVirtual.cpp:97
virtual void GetDeviceCursorPos(int &x, int &y)
get current cursor position.
Definition: GUIMouseVirtual.cpp:261
bool m_bUseWindowMessage
whether to use window message for buffered mouse event.
Definition: GUIMouseVirtual.h:89
virtual int GetMouseYDeltaSteps()
the current mouse Y delta in steps, such as -2,-1,0,1,2
Definition: GUIMouseVirtual.cpp:92
virtual int GetMouseWheelDeltaSteps()
the current mouse wheel delta in steps, such as -2,-1,0,1,2
Definition: GUIMouseVirtual.cpp:102
base class for GUI mouse
Definition: GUIMouseVirtual.h:14
virtual void PushMouseEvent(UINT uMsg, WPARAM wParam, LPARAM lParam)
push a standard windows mouse event to the buffer for processing in the next frame move...
Definition: GUIMouseVirtual.cpp:27
virtual void SetLock(bool bLock)
true to lock the mouse at its current location
Definition: GUIMouseVirtual.cpp:60
MOUSE_KEY_STD
this is just traditional mouse key mapping.
Definition: GUIMouseVirtual.h:21
virtual void ForceShowCursor(bool bShow)
Force the device to show its cursor.
Definition: GUIMouseVirtual.h:68
Definition: RenderCoreOpenGL.h:19