Modification of USB Joystick to work as a Hitbox-like game controller using the F401RE. Works reasonably well under Windows.

Dependencies:   USBDevice mbed

This is a hobby project trying to recreate a Hitbox Controller for fun .

The original code was based off of http://developer.mbed.org/users/wim/notebook/usb-joystick-device/ Slight modifications were made to the USB HID descriptor to up the number of buttons reported to 13.

Currently, this works well under Windows and Linux, but no luck getting it to work with Mac OS X or a PS3 so far.

If anybody has useful information, feel free to contribute. :)

p.s: My thread for hooking up an F401RE board as a USB device is here: http://developer.mbed.org/questions/5364/Cannot-get-the-Nucleo-F401RE-to-work-as-/

p.s.2: Cabling information and <del>pictures</del> will be uploaded in the near future.

p.s.3: 2015-04-20: added support for FRDM-KL25Z board. Due to the better usb functionality, this hitbox now works on Windows, Mac OS X, Linux and PS3 too! (minus the "PS" button...)

Revision:
2:278b7a590311
Parent:
0:c8e9c90ca7f4
--- a/USBJoystick.cpp	Mon Dec 08 09:13:59 2014 +0000
+++ b/USBJoystick.cpp	Mon Apr 20 14:58:21 2015 +0000
@@ -104,24 +104,26 @@
              LOGICAL_MINIMUM(1), 0x00,      // Logical_Minimum (0)             
              USAGE(1), 0x04,                // Usage (Joystick)
              COLLECTION(1), 0x01,           // Application
-               USAGE_PAGE(1), 0x02,            // Simulation Controls
-               USAGE(1), 0xBB,                 // Throttle             
-               USAGE(1), 0xBA,                 // Rudder               
-               LOGICAL_MINIMUM(1), 0x81,       // -127
-               LOGICAL_MAXIMUM(1), 0x7f,       // 127
-               REPORT_SIZE(1), 0x08,
-               REPORT_COUNT(1), 0x02,
-               INPUT(1), 0x02,                 // Data, Variable, Absolute               
+             //  USAGE_PAGE(1), 0x02,            // Simulation Controls
+             //  USAGE(1), 0xBB,                 // Throttle             
+             //  USAGE(1), 0xBA,                 // Rudder               
+             //  LOGICAL_MINIMUM(1), 0x81,       // -127
+             //  LOGICAL_MAXIMUM(1), 0x7f,       // 127
+             //  REPORT_SIZE(1), 0x08,
+             //  REPORT_COUNT(1), 0x02,
+             //  INPUT(1), 0x02,                 // Data, Variable, Absolute               
                USAGE_PAGE(1), 0x01,            // Generic Desktop
                USAGE(1), 0x01,                 // Usage (Pointer)
                COLLECTION(1), 0x00,            // Physical
                  USAGE(1), 0x30,                 // X
                  USAGE(1), 0x31,                 // Y
+                 USAGE(1), 0x32,                 //R
+                 USAGE(1), 0x35,                 //Rz?
 //  8 bit values
                  LOGICAL_MINIMUM(1), 0x81,       // -127
                  LOGICAL_MAXIMUM(1), 0x7f,       // 127
                  REPORT_SIZE(1), 0x08,
-                 REPORT_COUNT(1), 0x02,
+                 REPORT_COUNT(1), 0x04,
                  INPUT(1), 0x02,                 // Data, Variable, Absolute                  
 // 16 bit values
 //                 LOGICAL_MINIMUM(1), 0x00,       // 0