WPILib 2012
WPILibRoboticsLibraryforFRC
|
00001 /*----------------------------------------------------------------------------*/ 00002 /* Copyright (c) FIRST 2011. All Rights Reserved. */ 00003 /* Open Source Software - may be modified and shared by FRC teams. The code */ 00004 /* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib. */ 00005 /*----------------------------------------------------------------------------*/ 00006 00007 #ifndef __KINECT_STICK_H__ 00008 #define __KINECT_STICK_H__ 00009 00010 #include "ErrorBase.h" 00011 #include "GenericHID.h" 00012 00013 class KinectStick : public GenericHID, public ErrorBase 00014 { 00015 public: 00016 explicit KinectStick(int id); 00017 virtual float GetX(JoystickHand hand = kRightHand); 00018 virtual float GetY(JoystickHand hand = kRightHand); 00019 virtual float GetZ(); 00020 virtual float GetTwist(); 00021 virtual float GetThrottle(); 00022 virtual float GetRawAxis(UINT32 axis); 00023 00024 virtual bool GetTrigger(JoystickHand hand = kRightHand); 00025 virtual bool GetTop(JoystickHand hand = kRightHand); 00026 virtual bool GetBumper(JoystickHand hand = kRightHand); 00027 virtual bool GetRawButton(UINT32 button); 00028 00029 private: 00030 void GetData(); 00031 float ConvertRawToFloat(INT8 charValue); 00032 00033 typedef union 00034 { 00035 struct 00036 { 00037 UINT8 size; 00038 UINT8 id; 00039 struct 00040 { 00041 unsigned char axis[6]; 00042 unsigned short buttons; 00043 } rawSticks[2]; 00044 } formatted; 00045 char data[18]; 00046 } KinectStickData; 00047 00048 int m_id; 00049 static UINT32 _recentPacketNumber; 00050 static KinectStickData _sticks; 00051 }; 00052 00053 #endif 00054