OSX_Gamepad.h
Go to the documentation of this file.
00001 /************************************************************************************
00002 
00003 Filename    :   OSX_Gamepad.h
00004 Content     :   OSX implementation of Gamepad functionality.
00005 Created     :   May 6, 2013
00006 Authors     :   Lee Cooper
00007 
00008 Copyright   :   Copyright 2013 Oculus VR, Inc. All Rights reserved.
00009 
00010 Licensed under the Apache License, Version 2.0 (the "License");
00011 you may not use this file except in compliance with the License.
00012 You may obtain a copy of the License at
00013 
00014 http://www.apache.org/licenses/LICENSE-2.0
00015 
00016 Unless required by applicable law or agreed to in writing, software
00017 distributed under the License is distributed on an "AS IS" BASIS,
00018 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00019 See the License for the specific language governing permissions and
00020 limitations under the License.
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


oculus_sdk
Author(s):
autogenerated on Fri Aug 28 2015 11:53:10