1 #ifndef LIBRARIES_SENSORS_HID_H
    2 #define LIBRARIES_SENSORS_HID_H
    3 
    4 #ifndef LIBRARIES_SENSORS_H
    5 # include <libraries/sensors.h>
    6 #endif
    7 
    8 /* STRING, HID device name */
    9 #define SENSORS_HID_Name                        (SENSORS_Dummy + 2000)
   10 
   11 /* ULONG, HID device Vendor ID */
   12 #define SENSORS_HID_Vendor                      (SENSORS_Dummy + 2001)
   13 
   14 /* ULONG, HID device Produce ID */
   15 #define SENSORS_HID_Product                     (SENSORS_Dummy + 2002)
   16 
   17 /* STRING, HID device's serial number, if non-empty, it may be used
   18 ** to serialize per-controller settings */
   19 #define SENSORS_HID_Serial                      (SENSORS_Dummy + 2003)
   20 
   21 /*
   22 ** Sensors in the HIDInput class are always child sensors of a SENSORS_HID
   23 ** sensor. Each SENSORS_HID sensor corresponds to a single physical device
   24 ** like a pad, joystick, etc. In case of devices like the Xbox Wireless
   25 ** Controller PC adapter, which can handle up to 4 pads, a SENSORS_HID sensor
   26 ** will be created for each pad synchronized with the receiver.
   27 **
   28 ** Pads may disappear at any time, resulting in a removal of the sensor!
   29 **
   30 ** It is good practice to implement a learning mechanism for the inputs.
   31 */
   32 
   33 /* This section describes input values associated with the sensor */
   34 
   35 /* DOUBLE *, current state of the input for HID_Trigger and HID_Analog
   36 ** sensors */
   37 #define SENSORS_HIDInput_Value                  (SENSORS_Dummy + 2200)
   38 
   39 /* DOUBLE *, current state of the input in the N-S direction of 
   40 ** HID_Stick and HID_AnalogStick inputs */
   41 #define SENSORS_HIDInput_NS_Value               (SENSORS_Dummy + 2201)
   42 
   43 /* DOUBLE *, current state of the input in the E-W direction of 
   44 ** HID_Stick and HID_AnalogStick inputs */
   45 #define SENSORS_HIDInput_EW_Value               (SENSORS_Dummy + 2202)
   46 
   47 /* 3D Analog sticks may report a whole lot more values, they're all DOUBLE */
   48 #define SENSORS_HIDInput_X_Index                (SENSORS_Dummy + 2203)
   49 #define SENSORS_HIDInput_Y_Index                (SENSORS_Dummy + 2204)
   50 #define SENSORS_HIDInput_Z_Index                (SENSORS_Dummy + 2205)
   51 
   52 #define SENSORS_HIDInput_X_Rotation             (SENSORS_Dummy + 2206)
   53 #define SENSORS_HIDInput_Y_Rotation             (SENSORS_Dummy + 2207)
   54 #define SENSORS_HIDInput_Z_Rotation             (SENSORS_Dummy + 2208)
   55 
   56 #define SENSORS_HIDInput_X_Vector               (SENSORS_Dummy + 2209)
   57 #define SENSORS_HIDInput_Y_Vector               (SENSORS_Dummy + 2210)
   58 #define SENSORS_HIDInput_Z_Vector               (SENSORS_Dummy + 2211)
   59 
   60 #define SENSORS_HIDInput_X_BodyRelVector        (SENSORS_Dummy + 2212)
   61 #define SENSORS_HIDInput_Y_BodyRelVector        (SENSORS_Dummy + 2213)
   62 #define SENSORS_HIDInput_Z_BodyRelVector        (SENSORS_Dummy + 2214)
   63 
   64 /* This section contains other properties of the input sensor, namely ones
   65 ** that do not change based on user input */
   66 
   67 /* ULONG, HID controller's input trigger's unique identifier, may be handy
   68 ** if the device has several similar inputs like analog sticks */
   69 #define SENSORS_HIDInput_ID                     (SENSORS_Dummy + 2300)
   70 
   71 /* STRING, Human readable description of the input. In English */
   72 #define SENSORS_HIDInput_Name                   (SENSORS_Dummy + 2301)
   73 
   74 /* STRING, Human readable description of the input. Localized */
   75 #define SENSORS_HIDInput_Name_Translated        (SENSORS_Dummy + 2302)
   76 
   77 /* ULONG, XXRRGGBB, color of the input trigger, if known */
   78 #define SENSORS_HIDInput_Color                  (SENSORS_Dummy + 2303)
   79 
   80 /* ULONG, Sensor_HIDInput_Limb, for controllers held in both hands,
   81 ** tells which hand controls the given input, etc */
   82 #define SENSORS_HIDInput_Limb                   (SENSORS_Dummy + 2304)
   83 
   84 
   85 
   86 /* Rumble control sensors */
   87 
   88 /* Controlling a rumble in a pad is relatively simple. Once a client
   89 ** locates a rumble sensor, it can call SetSensorAttr in order to power
   90 ** the motors on. To power on a motor, one has to set both the Power and
   91 ** Duration attributes pairs. */
   92 
   93 /* DOUBLE *, sets the rumble motor power, values between 0.0 and 1.0.
   94 ** This attribute follows the SENSORS_AllowSetAttr paradigm */
   95 #define SENSORS_HIDInput_Rumble_Power           (SENSORS_Dummy + 2401)
   96 
   97 /* ULONG, ms, the time to power the rumble on for
   98 ** This attribute follows the SENSORS_AllowSetAttr paradigm */
   99 #define SENSORS_HIDInput_Rumble_Duration        (SENSORS_Dummy + 2402)
  100 
  101 /* ULONG, Sensor_HIDInput_Rumble_Type, type of the rumble motor */
  102 #define SENSORS_HIDInput_Rumble_Type            (SENSORS_Dummy + 2403)
  103 
  104 /* Trigger sensors may sometimes have leds */
  105 /* DOUBLE *, sets the backlight level, 0 for off, 1 for fully on (usually
  106 ** values between will result as 'on') */
  107 #define SENSORS_HIDInput_Trigger_Led            (SENSORS_Dummy + 2501)
  108 
  109 /* ULONG, triggers a blinking mode for the trigger led */
  110 #define SENSORS_HIDInput_Trigger_Blinking       (SENSORS_Dummy + 2502)
  111 
  112 /* values for the main HID class controller */
  113 typedef enum
  114 {
  115 	SensorType_HID_Unknown                   = -1,
  116 	/* A gamepad will have a certain, well defined set of features */
  117 	SensorType_HID_Gamepad                   = 0,
  118 	/* Generic is usually a USB HID device with all HID design pitfalls and limitations */
  119 	SensorType_HID_Generic                   = 1,
  120 	/* A music-purpose device */
  121 	SensorType_HID_Music                     = 2,
  122 } SensorType_HID;
  123 
  124 /* values returned by SENSORS_Type for HID class input sensors */
  125 typedef enum
  126 {
  127 	SensorType_HIDInput_Unknown              = -1,
  128 	SensorType_HIDInput_Trigger              = 0, /* single digital button, reports either 0.0 or 1.0 */
  129 	SensorType_HIDInput_Analog               = 1, /* single axis analog button, reports values between 0.0 and 1.0 */
  130 	SensorType_HIDInput_Stick                = 2, /* bidirectional digital stick, reports -1.0 for N, W and 1.0 for S, E */
  131 	SensorType_HIDInput_AnalogStick          = 3, /* bidirectional analog stick, reports values between -1.0 and 0.0 for N, W and 0.0 to 1.0 for S, E */
  132 	SensorType_HIDInput_Battery              = 4, /* wireless controllers often report battery state, 0.0 to 1.0 */
  133 	SensorType_HIDInput_Rumble               = 5, /* rumble motors control */
  134 	SensorType_HIDInput_3DStick              = 6, /* an analog stick that has an additional Z index, rotations and vectors */
  135 	SensorType_HIDInput_Wheel                = 7, /* reports relative movements between -1.0 and 1.0 */
  136 	SensorType_HIDInput_Knob                 = 8, /* reports abs values between -1.0 and 1.0 */
  137 } SensorType_HIDInput;
  138 
  139 typedef enum
  140 {
  141 	Sensor_HIDInput_Limb_Unknown             = -1,
  142 	Sensor_HIDInput_Limb_LeftHand            = 0,
  143 	Sensor_HIDInput_Limb_RightHand           = 1,
  144 	Sensor_HIDInput_Limb_EitherHand          = 2,
  145 	Sensor_HIDInput_Limb_LeftLeg             = 3,
  146 	Sensor_HIDInput_Limb_RightLeg            = 4,
  147 	Sensor_HIDInput_Limb_EitherLeg           = 5,
  148 } Sensor_HIDInput_Limb;
  149 
  150 typedef enum
  151 {
  152 	Sensor_HIDInput_Rumble_Type_Vibration = 0,
  153 	Sensor_HIDInput_Rumble_Type_Impulse   = 1,
  154 } Sensor_HIDInput_Rumble_Type;
  155 
  156 #endif