Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef OVR_OSX_Gamepad_h
00025 #define OVR_OSX_Gamepad_h
00026
00027 #include <IOKit/IOKitLib.h>
00028 #include <IOKit/hid/IOHIDManager.h>
00029
00030 #include "Gamepad.h"
00031
00032 namespace OVR { namespace Platform { namespace OSX {
00033
00034
00035 class GamepadManager : public Platform::GamepadManager
00036 {
00037 public:
00038 GamepadManager();
00039 ~GamepadManager();
00040
00041 virtual UInt32 GetGamepadCount();
00042 virtual bool GetGamepadState(UInt32 index, GamepadState* pState);
00043
00044 private:
00045 static void staticOnDeviceMatched(void* context, IOReturn result, void* sender, IOHIDDeviceRef device);
00046 void onDeviceMatched(IOHIDDeviceRef device);
00047
00048 static void staticOnDeviceRemoved(void* context, IOReturn result, void* sender, IOHIDDeviceRef device);
00049 void onDeviceRemoved(IOHIDDeviceRef device);
00050
00051 static void staticOnDeviceValueChanged(void* context, IOReturn result, void* sender, IOHIDValueRef value);
00052 void onDeviceValueChanged(IOHIDValueRef value);
00053
00054 int getIntDeviceProperty(IOHIDDeviceRef device, CFStringRef key);
00055 float mapAnalogAxis(IOHIDValueRef value, IOHIDElementRef element);
00056 void manipulateBitField(unsigned int& bitfield, unsigned int mask, bool val);
00057 bool setStateIfDifferent(float& state, float newState);
00058
00059 IOHIDManagerRef HidManager;
00060 GamepadState State;
00061 bool bStateChanged;
00062 };
00063
00064 }}}
00065
00066 #endif // OVR_OSX_Gamepad_h