ysjoyreader.h
Go to the documentation of this file.
00001 #ifndef YSMACOSXJOYSTICK_IS_INCLUDED
00002 #define YSMACOSXJOYSTICK_IS_INCLUDED
00003 /* { */
00004 
00005 const int YsJoyReaderMaxNumAxis=6;
00006 const int YsJoyReaderMaxNumButton=32;
00007 const int YsJoyReaderMaxNumHatSwitch=4;
00008 
00009 #include <stdio.h>
00010 #include <unistd.h>
00011 #include <stdlib.h>
00012 #include <ctype.h>
00013 #include <sys/errno.h>
00014 #include <sysexits.h>
00015 #include <IOKit/hid/IOHIDLib.h>
00016 
00017 
00018 
00019 class YsJoyReaderElement
00020 {
00021 public:
00022         int exist;
00023         IOHIDElementRef elem;
00024         int value;
00025 
00026         YsJoyReaderElement();
00027 };
00028 
00029 class YsJoyReaderAxis : public YsJoyReaderElement
00030 {
00031 public:
00032         int min,max;
00033         int scaledMin,scaledMax;
00034         int calibCenter,calibMin,calibMax;
00035 
00036         YsJoyReaderAxis();
00037         double GetCalibratedValue(void) const;
00038 
00039         void CaptureCenter(void);
00040         void BeginCaptureMinMax(void);
00041         void CaptureMinMax(void);
00042         void CenterFromMinMax(void);
00043 };
00044 
00045 class YsJoyReaderButton : public YsJoyReaderElement
00046 {
00047 public:
00048         YsJoyReaderButton();
00049 };
00050 
00051 class YsJoyReaderHatSwitch : public YsJoyReaderElement
00052 {
00053 public:
00054         YsJoyReaderHatSwitch();
00055         int valueNeutral;
00056         int value0Deg;
00057         int value90Deg;
00058         int value180Deg;
00059         int value270Deg;
00060         int GetDiscreteValue(void) const;
00061 };
00062 
00063 class  YsJoyReader
00064 {
00065 public:
00066         static IOHIDManagerRef hidManager;
00067         static CFMutableArrayRef devArray;
00068 
00069         int joyId;
00070         IOHIDDeviceRef hidDev;
00071         char regPath[512];
00072 
00073         YsJoyReaderAxis axis[YsJoyReaderMaxNumAxis];
00074         YsJoyReaderButton button[YsJoyReaderMaxNumButton];
00075         YsJoyReaderHatSwitch hatSwitch[YsJoyReaderMaxNumHatSwitch];
00076 
00077         YsJoyReader();
00078         int SetUpInterface(int joyId,IOHIDDeviceRef hidDev);
00079         void Read(void);
00080         void ReleaseInterface(void);
00081 
00082         int WriteCalibInfoFile(FILE *fp) const;
00083         int ReadCalibInfoFile(FILE *fp);
00084 
00085 protected:
00086         void AddAxis(int axisId,IOHIDElementRef elem,int min,int max,int scaledMin,int scaledMax);
00087 
00088 public:
00089         static int SetUpJoystick(int &nJoystick,YsJoyReader joystick[],int maxNumJoystick);
00090 };
00091 
00092 
00093 
00094 
00095 int YsJoyReaderSetUpJoystick(int &nJoystick,YsJoyReader joystick[],int maxNumJoystick);
00096 
00097 FILE *YsJoyReaderOpenJoystickCalibrationFile(const char mode[]);
00098 
00099 int YsJoyReaderSaveJoystickCalibrationInfo(int nJoystick,YsJoyReader joystick[]);
00100 int YsJoyReaderLoadJoystickCalibrationInfo(int nJoystick,YsJoyReader joystick[]);
00101 
00102 /* } */
00103 #endif


hrpsys
Author(s): AIST, Fumio Kanehiro
autogenerated on Wed May 15 2019 05:02:19