Torque3D Documentation / _generateds / razerHydraDevice.h

razerHydraDevice.h

Engine/source/platform/input/razerHydra/razerHydraDevice.h

More...

Classes:

Public Defines

define
FN_HYDRA() __cdecl
define
RAZERHYDRADEV() <>::instance()

Returns the RazerHydraDevice singleton.

Public Typedefs

int(FN_HYDRA *
FN_SixenseAutoEnableHemisphereTracking )(int which_controller)
int(FN_HYDRA *
FN_SixenseExit )()
int(FN_HYDRA *
FN_SixenseGetAllData )(int index_back, sixenseAllControllerData *)
int(FN_HYDRA *
FN_SixenseGetAllNewestData )(sixenseAllControllerData *)
int(FN_HYDRA *
FN_SixenseGetBaseColor )(unsigned char *red, unsigned char *green, unsigned char *blue)
int(FN_HYDRA *
FN_SixenseGetData )(int which, int index_back, sixenseControllerData *)
int(FN_HYDRA *
FN_SixenseGetFilterEnabled )(int *on_or_off)
int(FN_HYDRA *
FN_SixenseGetFilterParams )(float *near_range, float *near_val, float *far_range, float *far_val)
int(FN_HYDRA *
FN_SixenseGetHemisphereTrackingMode )(int which_controller, int *state)
int(FN_HYDRA *
FN_SixenseGetHighPriorityBindingEnabled )(int *on_or_off)
int(FN_HYDRA *
FN_SixenseGetHistorySize )()
int(FN_HYDRA *
FN_SixenseGetMaxBases )()
int(FN_HYDRA *
FN_SixenseGetMaxControllers )()
int(FN_HYDRA *
FN_SixenseGetNewestData )(int which, sixenseControllerData *)
int(FN_HYDRA *
FN_SixenseGetNumActiveControllers )()
int(FN_HYDRA *
FN_SixenseInit )()
int(FN_HYDRA *
FN_SixenseIsBaseConnected )(int base_num)
int(FN_HYDRA *
FN_SixenseIsControllerEnabled )(int which)
int(FN_HYDRA *
FN_SixenseSetActiveBase )(int base_num)
int(FN_HYDRA *
FN_SixenseSetBaseColor )(unsigned char red, unsigned char green, unsigned char blue)
int(FN_HYDRA *
FN_SixenseSetFilterEnabled )(int on_or_off)
int(FN_HYDRA *
FN_SixenseSetFilterParams )(float near_range, float near_val, float far_range, float far_val)
int(FN_HYDRA *
FN_SixenseSetHemisphereTrackingMode )(int which_controller, int state)
int(FN_HYDRA *
FN_SixenseSetHighPriorityBindingEnabled )(int on_or_off)
int(FN_HYDRA *
FN_SixenseTriggerVibration )(int controller_id, int duration_100ms, int pattern_id)

Detailed Description

Public Defines

FN_HYDRA() __cdecl
HYDRA_ACTIVE_CHECK_FREQ() 1000
RAZERHYDRADEV() <>::instance()

Returns the RazerHydraDevice singleton.

Public Typedefs

typedef int(FN_HYDRA * FN_SixenseAutoEnableHemisphereTracking )(int which_controller)
typedef int(FN_HYDRA * FN_SixenseExit )()
typedef int(FN_HYDRA * FN_SixenseGetAllData )(int index_back, sixenseAllControllerData *)
typedef int(FN_HYDRA * FN_SixenseGetAllNewestData )(sixenseAllControllerData *)
typedef int(FN_HYDRA * FN_SixenseGetBaseColor )(unsigned char *red, unsigned char *green, unsigned char *blue)
typedef int(FN_HYDRA * FN_SixenseGetData )(int which, int index_back, sixenseControllerData *)
typedef int(FN_HYDRA * FN_SixenseGetFilterEnabled )(int *on_or_off)
typedef int(FN_HYDRA * FN_SixenseGetFilterParams )(float *near_range, float *near_val, float *far_range, float *far_val)
typedef int(FN_HYDRA * FN_SixenseGetHemisphereTrackingMode )(int which_controller, int *state)
typedef int(FN_HYDRA * FN_SixenseGetHighPriorityBindingEnabled )(int *on_or_off)
typedef int(FN_HYDRA * FN_SixenseGetHistorySize )()
typedef int(FN_HYDRA * FN_SixenseGetMaxBases )()
typedef int(FN_HYDRA * FN_SixenseGetMaxControllers )()
typedef int(FN_HYDRA * FN_SixenseGetNewestData )(int which, sixenseControllerData *)
typedef int(FN_HYDRA * FN_SixenseGetNumActiveControllers )()
typedef int(FN_HYDRA * FN_SixenseInit )()
typedef int(FN_HYDRA * FN_SixenseIsBaseConnected )(int base_num)
typedef int(FN_HYDRA * FN_SixenseIsControllerEnabled )(int which)
typedef int(FN_HYDRA * FN_SixenseSetActiveBase )(int base_num)
typedef int(FN_HYDRA * FN_SixenseSetBaseColor )(unsigned char red, unsigned char green, unsigned char blue)
typedef int(FN_HYDRA * FN_SixenseSetFilterEnabled )(int on_or_off)
typedef int(FN_HYDRA * FN_SixenseSetFilterParams )(float near_range, float near_val, float far_range, float far_val)
typedef int(FN_HYDRA * FN_SixenseSetHemisphereTrackingMode )(int which_controller, int state)
typedef int(FN_HYDRA * FN_SixenseSetHighPriorityBindingEnabled )(int on_or_off)
typedef int(FN_HYDRA * FN_SixenseTriggerVibration )(int controller_id, int duration_100ms, int pattern_id)
  1
  2//-----------------------------------------------------------------------------
  3// Copyright (c) 2012 GarageGames, LLC
  4//
  5// Permission is hereby granted, free of charge, to any person obtaining a copy
  6// of this software and associated documentation files (the "Software"), to
  7// deal in the Software without restriction, including without limitation the
  8// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  9// sell copies of the Software, and to permit persons to whom the Software is
 10// furnished to do so, subject to the following conditions:
 11//
 12// The above copyright notice and this permission notice shall be included in
 13// all copies or substantial portions of the Software.
 14//
 15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 18// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
 21// IN THE SOFTWARE.
 22//-----------------------------------------------------------------------------
 23
 24#ifndef _RAZERHYDRADEVICE_H_
 25#define _RAZERHYDRADEVICE_H_
 26
 27#include "platform/input/razerHydra/razerHydraConstants.h"
 28#include "platform/platformDlibrary.h"
 29#include "platform/input/IInputDevice.h"
 30#include "platform/input/event.h"
 31#include "core/util/tSingleton.h"
 32#include "math/mQuat.h"
 33#include "sixense.h"
 34
 35#define HYDRA_ACTIVE_CHECK_FREQ 1000
 36
 37#define FN_HYDRA __cdecl
 38
 39// Library function typedefs
 40typedef int (FN_HYDRA* FN_SixenseInit)();
 41typedef int (FN_HYDRA* FN_SixenseExit)();
 42
 43typedef int (FN_HYDRA* FN_SixenseGetMaxBases)();
 44typedef int (FN_HYDRA* FN_SixenseSetActiveBase)(int base_num);
 45typedef int (FN_HYDRA* FN_SixenseIsBaseConnected)(int base_num);
 46
 47typedef int (FN_HYDRA* FN_SixenseGetMaxControllers)();
 48typedef int (FN_HYDRA* FN_SixenseIsControllerEnabled)(int which);
 49typedef int (FN_HYDRA* FN_SixenseGetNumActiveControllers)();
 50
 51typedef int (FN_HYDRA* FN_SixenseGetHistorySize)();
 52
 53typedef int (FN_HYDRA* FN_SixenseGetData)(int which, int index_back, sixenseControllerData *);
 54typedef int (FN_HYDRA* FN_SixenseGetAllData)(int index_back, sixenseAllControllerData *);
 55typedef int (FN_HYDRA* FN_SixenseGetNewestData)(int which, sixenseControllerData *);
 56typedef int (FN_HYDRA* FN_SixenseGetAllNewestData)(sixenseAllControllerData *);
 57
 58typedef int (FN_HYDRA* FN_SixenseSetHemisphereTrackingMode)(int which_controller, int state);
 59typedef int (FN_HYDRA* FN_SixenseGetHemisphereTrackingMode)(int which_controller, int *state);
 60
 61typedef int (FN_HYDRA* FN_SixenseAutoEnableHemisphereTracking)(int which_controller);
 62
 63typedef int (FN_HYDRA* FN_SixenseSetHighPriorityBindingEnabled)(int on_or_off);
 64typedef int (FN_HYDRA* FN_SixenseGetHighPriorityBindingEnabled)(int *on_or_off);
 65
 66typedef int (FN_HYDRA* FN_SixenseTriggerVibration)(int controller_id, int duration_100ms, int pattern_id);
 67
 68typedef int (FN_HYDRA* FN_SixenseSetFilterEnabled)(int on_or_off);
 69typedef int (FN_HYDRA* FN_SixenseGetFilterEnabled)(int *on_or_off);
 70
 71typedef int (FN_HYDRA* FN_SixenseSetFilterParams)(float near_range, float near_val, float far_range, float far_val);
 72typedef int (FN_HYDRA* FN_SixenseGetFilterParams)(float *near_range, float *near_val, float *far_range, float *far_val);
 73
 74typedef int (FN_HYDRA* FN_SixenseSetBaseColor)(unsigned char red, unsigned char green, unsigned char blue);
 75typedef int (FN_HYDRA* FN_SixenseGetBaseColor)(unsigned char *red, unsigned char *green, unsigned char *blue);
 76
 77struct RazerHyrdaControllerData;
 78
 79class RazerHydraDevice : public IInputDevice
 80{
 81public:
 82   static bool smEnableDevice;
 83
 84   // Should events be sent when a controller is docked
 85   static bool smProcessWhenDocked;
 86
 87   // The type of position events to broadcast
 88   static bool smSeparatePositionEvents;
 89   static bool smCombinedPositionEvents;
 90
 91   // Broadcast controller rotation as axis
 92   static bool smRotationAsAxisEvents;
 93
 94   // The maximum controller angle when used as an axis event
 95   // as measured from a vector pointing straight up (in degrees)
 96   static F32 smMaximumAxisAngle;
 97
 98   // Indicates that a whole frame event should be generated and frames
 99   // should be buffered.
100   static bool smGenerateWholeFrameEvents;
101
102   // Controller Action Codes
103   static U32 RH_DOCKED[RazerHydraConstants::MaxControllers];     // SI_BUTTON
104
105   static U32 RH_POSX[RazerHydraConstants::MaxControllers];       // SI_FLOAT
106   static U32 RH_POSY[RazerHydraConstants::MaxControllers];
107   static U32 RH_POSZ[RazerHydraConstants::MaxControllers];
108
109   static U32 RH_POS[RazerHydraConstants::MaxControllers];        // SI_POS
110
111   static U32 RH_ROT[RazerHydraConstants::MaxControllers];        // SI_ROT
112
113   static U32 RH_ROTAXISX[RazerHydraConstants::MaxControllers];   // SI_AXIS
114   static U32 RH_ROTAXISY[RazerHydraConstants::MaxControllers];
115
116   static U32 RH_THUMBX[RazerHydraConstants::MaxControllers];     // SI_AXIS
117   static U32 RH_THUMBY[RazerHydraConstants::MaxControllers];
118
119   static U32 RH_TRIGGER[RazerHydraConstants::MaxControllers];    // SI_AXIS
120
121   static U32 RH_SHOULDER[RazerHydraConstants::MaxControllers];   // SI_BUTTON
122   static U32 RH_THUMB[RazerHydraConstants::MaxControllers];      // SI_BUTTON
123   static U32 RH_START[RazerHydraConstants::MaxControllers];      // SI_BUTTON
124   static U32 RH_1[RazerHydraConstants::MaxControllers];          // SI_BUTTON
125   static U32 RH_2[RazerHydraConstants::MaxControllers];          // SI_BUTTON
126   static U32 RH_3[RazerHydraConstants::MaxControllers];          // SI_BUTTON
127   static U32 RH_4[RazerHydraConstants::MaxControllers];          // SI_BUTTON
128
129   // Whole frame
130   static U32 RH_FRAME;       // SI_INT
131
132public:
133   RazerHydraDevice();
134   ~RazerHydraDevice();
135
136   static void staticInit();
137
138   bool enable();
139
140   void disable();
141
142   bool process();
143
144   bool isActive() { return mActive; }
145
146   bool isControllerDocked(U32 controller);
147
148   const Point3F& getControllerPosition(U32 controller);
149
150   const QuatF& getControllerRotation(U32 controller);
151
152protected:
153   DLibraryRef mRazerHydraLib;
154
155   FN_SixenseInit                      mfnSixenseInit;
156   FN_SixenseExit                      mfnSixenseExit;
157
158   FN_SixenseGetMaxBases               mfnSixenseGetMaxBases;
159   FN_SixenseSetActiveBase             mfnSixenseSetActiveBase;
160   FN_SixenseIsBaseConnected           mfnSixenseIsBaseConnected;
161
162   FN_SixenseGetMaxControllers         mfnSixenseGetMaxControllers;
163   FN_SixenseIsControllerEnabled       mfnSixenseIsControllerEnabled;
164   FN_SixenseGetNumActiveControllers   mfnSixenseGetNumActiveControllers;
165
166   FN_SixenseGetHistorySize            mfnSixenseGetHistorySize;
167
168   FN_SixenseGetData                   mfnSixenseGetData;
169   FN_SixenseGetAllData                mfnSixenseGetAllData;
170   FN_SixenseGetNewestData             mfnSixenseGetNewestData;
171   FN_SixenseGetAllNewestData          mfnSixenseGetAllNewestData;
172
173   FN_SixenseSetHemisphereTrackingMode mfnSixenseSetHemisphereTrackingMode;
174   FN_SixenseGetHemisphereTrackingMode mfnSixenseGetHemisphereTrackingMode;
175
176   FN_SixenseAutoEnableHemisphereTracking mfnSixenseAutoEnableHemisphereTracking;
177
178   FN_SixenseSetHighPriorityBindingEnabled   mfnSixenseSetHighPriorityBindingEnabled;
179   FN_SixenseGetHighPriorityBindingEnabled   mfnSixenseGetHighPriorityBindingEnabled;
180
181   FN_SixenseTriggerVibration          mfnSixenseTriggerVibration;
182
183   FN_SixenseSetFilterEnabled          mfnSixenseSetFilterEnabled;
184   FN_SixenseGetFilterEnabled          mfnSixenseGetFilterEnabled;
185
186   FN_SixenseSetFilterParams           mfnSixenseSetFilterParams;
187   FN_SixenseGetFilterParams           mfnSixenseGetFilterParams;
188
189   FN_SixenseSetBaseColor              mfnSixenseSetBaseColor;
190   FN_SixenseGetBaseColor              mfnSixenseGetBaseColor;
191
192   S32 mMaximumBases;
193   S32 mMaximumControllers;
194
195   S32 mNumberActiveControllers;
196
197   /// Is the Razer Hydra active (enabled means the library is loaded)
198   bool mActive;
199
200   /// When was the last check for an active Hydra
201   S32 mLastActiveCheck;
202
203   /// Buffers to store data for the controllers
204   RazerHyrdaControllerData*  mDataBuffer[RazerHydraConstants::MaxControllers][2];
205
206   /// Points to the buffers that holds the previously collected data
207   /// for each controller
208   RazerHyrdaControllerData*  mPrevData[RazerHydraConstants::MaxControllers];
209
210protected:
211   /// Build out the codes used for controller actions with the
212   /// Input Event Manager
213   void buildCodeTable();
214
215   /// Checks if there are active controllers
216   bool checkControllers();
217
218public:
219   // For ManagedSingleton.
220   static const char* getSingletonName() { return "RazerHydraDevice"; }   
221};
222
223/// Returns the RazerHydraDevice singleton.
224#define RAZERHYDRADEV ManagedSingleton<RazerHydraDevice>::instance()
225
226#endif   // _RAZERHYDRADEVICE_H_
227