From e0c845d01bb29ddab63f44995eda6e4d46a798af Mon Sep 17 00:00:00 2001 From: Nico Date: Sun, 11 Jan 2015 15:36:08 +0100 Subject: [PATCH] Added custom gamepad example --- Readme.md | 1 + avr/variants/leonardo_custom/pins_arduino.h | 47 +++++++++++++++++++++ avr/variants/micro_custom/pins_arduino.h | 47 +++++++++++++++++++++ 3 files changed, 95 insertions(+) diff --git a/Readme.md b/Readme.md index 854381c..d4f44a9 100644 --- a/Readme.md +++ b/Readme.md @@ -388,6 +388,7 @@ Useful Links/Credits * [Paul Stoffregen's Teensy Core](https://github.com/PaulStoffregen/cores) * [Keyboard Led Out report by hartmut_holgraefe](http://forum.arduino.cc/index.php?topic=173583.0) * [Github Pull Request with a lot of new functions](https://github.com/arduino/Arduino/pull/1803) +* [Arduino ISP fix](https://petervanhoyweghen.wordpress.com/2012/09/16/arduinoisp-on-the-leonardo/) * A lot of searching through the web * The awesome official Arduino IRC chat! * [The NicoHood Protocol ^.^](https://github.com/NicoHood/NicoHoodProtocol) diff --git a/avr/variants/leonardo_custom/pins_arduino.h b/avr/variants/leonardo_custom/pins_arduino.h index c50913a..111d4f9 100644 --- a/avr/variants/leonardo_custom/pins_arduino.h +++ b/avr/variants/leonardo_custom/pins_arduino.h @@ -83,6 +83,53 @@ HID_REPORT_MOUSE(HID_REPORTID_MOUSE) //#define HID_GAMEPAD_API_ENABLE //#define HID_ENABLE_ALL_APIS // enables all of the ones above + +//// 2nd example with a custom Joystick report (the Gamepad API wont work anymor since the report is different) +//#define EXTERN_HID_REPORT \ /* Gamepad with 32 buttons and 10 axis*/ \ +//0x05, 0x01, /* USAGE_PAGE (Generic Desktop) */ \ +//0x09, 0x04, /* USAGE (Joystick) */ \ +//0xa1, 0x01, /* COLLECTION (Application) */ \ +//0x85, HID_REPORTID_GAMEPAD, /* REPORT_ID */ \ +///* 32 Buttons */ \ +//0x05, 0x09, /* USAGE_PAGE (Button) */ \ +//0x19, 0x01, /* USAGE_MINIMUM (Button 1) */ \ +//0x29, 0x20, /* USAGE_MAXIMUM (Button 32) */ \ +//0x15, 0x00, /* LOGICAL_MINIMUM (0) */ \ +//0x25, 0x01, /* LOGICAL_MAXIMUM (1) */ \ +//0x75, 0x01, /* REPORT_SIZE (1) */ \ +//0x95, 0x20, /* REPORT_COUNT (32) */ \ +//0x81, 0x02, /* INPUT (Data,Var,Abs) */ \ +///* 10 8bit Axis */ \ +//0x05, 0x01, /* USAGE_PAGE (Generic Desktop) */ \ +//0xa1, 0x00, /* COLLECTION (Physical) */ \ +//0x09, 0x30, /* USAGE (X) */ \ +//0x09, 0x31, /* USAGE (Y) */ \ +//0x09, 0x33, /* USAGE (Rx) */ \ +//0x09, 0x34, /* USAGE (Ry) */ \ +//0x09, 0x32, /* USAGE (Z) */ \ +//0x09, 0x35, /* USAGE (Rz) */ \ +//0x09, 0x36, /* Usage (Slider) */ \ +//0x09, 0x36, /* Usage (Slider) */ \ +//0x09, 0x36, /* Usage (Slider) */ \ +//0x09, 0x36, /* Usage (Slider) */ \ +//0x15, 0x80, /* LOGICAL_MINIMUM (-128) */ \ +//0x25, 0x7F, /* LOGICAL_MAXIMUM (127) */ \ +//0x75, 0x08, /* REPORT_SIZE (8) */ \ +//0x95, 0x0A, /* REPORT_COUNT (10) */ \ +//0x81, 0x02, /* INPUT (Data,Var,Abs) */ \ +//0xc0, /* END_COLLECTION */ \ +//0xc0 /* END_COLLECTION */ +// +//// activate your custom HID-APIs here: +////#define HID_MOUSE_API_ENABLE +////#define HID_KEYBOARD_API_ENABLE +////#define HID_RAWHID_API_ENABLE +////#define HID_CONSUMER_API_ENABLE +////#define HID_SYSTEM_API_ENABLE +////#define HID_GAMEPAD_API_ENABLE +////#define HID_ENABLE_ALL_APIS // enables all of the ones above + + /* You can use the pre defined reports as well. Keep in mind that changing the ids or reports might confuse your OS. diff --git a/avr/variants/micro_custom/pins_arduino.h b/avr/variants/micro_custom/pins_arduino.h index 912bb51..59045af 100644 --- a/avr/variants/micro_custom/pins_arduino.h +++ b/avr/variants/micro_custom/pins_arduino.h @@ -83,6 +83,53 @@ HID_REPORT_MOUSE(HID_REPORTID_MOUSE) //#define HID_GAMEPAD_API_ENABLE //#define HID_ENABLE_ALL_APIS // enables all of the ones above + +//// 2nd example with a custom Joystick report (the Gamepad API wont work anymor since the report is different) +//#define EXTERN_HID_REPORT \ /* Gamepad with 32 buttons and 10 axis*/ \ +//0x05, 0x01, /* USAGE_PAGE (Generic Desktop) */ \ +//0x09, 0x04, /* USAGE (Joystick) */ \ +//0xa1, 0x01, /* COLLECTION (Application) */ \ +//0x85, HID_REPORTID_GAMEPAD, /* REPORT_ID */ \ +///* 32 Buttons */ \ +//0x05, 0x09, /* USAGE_PAGE (Button) */ \ +//0x19, 0x01, /* USAGE_MINIMUM (Button 1) */ \ +//0x29, 0x20, /* USAGE_MAXIMUM (Button 32) */ \ +//0x15, 0x00, /* LOGICAL_MINIMUM (0) */ \ +//0x25, 0x01, /* LOGICAL_MAXIMUM (1) */ \ +//0x75, 0x01, /* REPORT_SIZE (1) */ \ +//0x95, 0x20, /* REPORT_COUNT (32) */ \ +//0x81, 0x02, /* INPUT (Data,Var,Abs) */ \ +///* 10 8bit Axis */ \ +//0x05, 0x01, /* USAGE_PAGE (Generic Desktop) */ \ +//0xa1, 0x00, /* COLLECTION (Physical) */ \ +//0x09, 0x30, /* USAGE (X) */ \ +//0x09, 0x31, /* USAGE (Y) */ \ +//0x09, 0x33, /* USAGE (Rx) */ \ +//0x09, 0x34, /* USAGE (Ry) */ \ +//0x09, 0x32, /* USAGE (Z) */ \ +//0x09, 0x35, /* USAGE (Rz) */ \ +//0x09, 0x36, /* Usage (Slider) */ \ +//0x09, 0x36, /* Usage (Slider) */ \ +//0x09, 0x36, /* Usage (Slider) */ \ +//0x09, 0x36, /* Usage (Slider) */ \ +//0x15, 0x80, /* LOGICAL_MINIMUM (-128) */ \ +//0x25, 0x7F, /* LOGICAL_MAXIMUM (127) */ \ +//0x75, 0x08, /* REPORT_SIZE (8) */ \ +//0x95, 0x0A, /* REPORT_COUNT (10) */ \ +//0x81, 0x02, /* INPUT (Data,Var,Abs) */ \ +//0xc0, /* END_COLLECTION */ \ +//0xc0 /* END_COLLECTION */ +// +//// activate your custom HID-APIs here: +////#define HID_MOUSE_API_ENABLE +////#define HID_KEYBOARD_API_ENABLE +////#define HID_RAWHID_API_ENABLE +////#define HID_CONSUMER_API_ENABLE +////#define HID_SYSTEM_API_ENABLE +////#define HID_GAMEPAD_API_ENABLE +////#define HID_ENABLE_ALL_APIS // enables all of the ones above + + /* You can use the pre defined reports as well. Keep in mind that changing the ids or reports might confuse your OS.