Umasoft
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
SpaceNav.h
1 //
2 // Name: SpaceNav.h
3 // Purpose: Implements Win32-specific support for the SpaceNavigator 6DOF device.
4 //
5 // Copyright (c) 2008 Virtual Terrain Project
6 // Free for all uses, see license.txt for details.
7 //
8 
9 #if WIN32
10 #ifndef _WINDEF_
11 #error Sorry, this class is only usable from code which includes windows.h
12 #endif
13 #endif
14 
15 #include "vtlib/core/Engine.h"
16 
17 class vtSpaceNav : public vtEngine
18 {
19 public:
20  vtSpaceNav();
21  ~vtSpaceNav();
22 
23  bool Init() { return InitRawDevices(); }
24  void SetSpeed(float s) { m_fSpeed = s; }
25  float GetSpeed() { return m_fSpeed; }
26  void SetAllowRoll(bool b) { m_bAllowRoll = b; }
27  bool GetAllowRoll() { return m_bAllowRoll; }
28  virtual void OnButtons(uchar b1, uchar b2, uchar b3) {}
29  virtual void Eval();
30 
31 #if WIN32
32  // The implementation of this class is WIN32-specfic
33  void ProcessWM_INPUTEvent(LPARAM lParam);
34 
35 protected:
36  // ---------------- RawInput ------------------
37  HMODULE m_hUser32Dll;
38  typedef UINT (WINAPI *GetRawInputDeviceList_t)(PRAWINPUTDEVICELIST, PUINT, UINT);
39  typedef UINT (WINAPI *GetRawInputDeviceInfo_t)(HANDLE, UINT, LPVOID, PUINT);
40  typedef BOOL (WINAPI *RegisterRawInputDevices_t)(PCRAWINPUTDEVICE, UINT, UINT);
41  typedef UINT (WINAPI *GetRawInputData_t)(HRAWINPUT, UINT, LPVOID, PUINT, UINT);
42  GetRawInputData_t m_pfnGetRawInputData;
43 
44  PRAWINPUTDEVICELIST g_pRawInputDeviceList;
45  PRAWINPUTDEVICE g_pRawInputDevices;
46  int g_nUsagePage1Usage8Devices;
47 #endif
48 
49  bool InitRawDevices();
50  float m_fSpeed;
51  bool m_bAllowRoll;
52 };
53