aboutsummaryrefslogtreecommitdiff
path: root/tmk_core
diff options
context:
space:
mode:
authora-chol <a-chol@users.noreply.github.com>2020-07-25 14:01:15 +0200
committerJames Young <18669334+noroadsleft@users.noreply.github.com>2020-08-29 14:30:02 -0700
commitd4be07dad368c57669c88ead6c093c9e23086855 (patch)
tree91d2e4e4dec57c978e92dfd71056aadb0dfdaaeb /tmk_core
parent9d3b26a47543d9898a2af2cee5f6ef53b4995e9f (diff)
downloadqmk_firmware-d4be07dad368c57669c88ead6c093c9e23086855.tar.gz
qmk_firmware-d4be07dad368c57669c88ead6c093c9e23086855.zip
Hid joystick interface (#4226)
* add support for hid gamepad interface add documentation for HID joystick Add joystick_task to read analog axes values even when no key is pressed or release. update doc Update docs/feature_joystick.md Manage pin setup and read to maintain matrix scan after analog read * Incorporates patches and changes to HID reporting There are some patches provided by @a-chol incorporated on this commit, and also some changes I made to the HID Report structure. The most interesting is the one dealing with number of buttons: Linux doesn't seem to care, but Windows requires the HID structure to be byte aligned (that's in the spec). So if one declares 8/16/32... buttons they should not have any issues, but this is what happens when you have 9 buttons: ``` bits |0|1|2|3|4|5|6|7| |*|*|*|*|*|*|*|*| axis 0 (report size 8) |*|*|*|*|*|*|*|*| ... |*|*|*|*|*|*|*|*| |*|*|*|*|*|*|*|*| |*|*|*|*|*|*|*|*| |*|*|*|*|*|*|*|*| |*|*|*|*|*|*|*|*| axis 6 |*|*|*|*|*|*|*|*| first 8 buttons (report size 1) |*| | | | | | | | last of 9 buttons, not aligned ``` So for that I added a conditonal that will add a number of reports with size 1 to make sure it aligns to the next multiple of 8. Those reports send dummy inputs that don't do anything aside from aligning the data. Tested on Linux, Windows 10 and Street Fighter (where the joystick is recognized as direct-input) * Add save and restore of each pin used in reading joystick (AVR). Allow output pin to be JS_VIRTUAL_AXIS if the axis is connected to Vcc instead of an output pin from the MCU. Fix joystick report id Fix broken v-usb hid joystick interface. Make it more resilient to unusual settings (none multiple of eight button count, 0 buttons or 0 axes) Correct adc reading for multiple axes. Piecewise range conversion for uncentered raw value range. Input, output and ground pin configuration per axis. Documentation fixes * Fix port addressing for joystick analog read * The other required set of changes As per the PR, the changes still holding it up. Add onekey for testing. Fix ARM builds. Fix device descriptor when either axes or buttons is zero. Add compile-time check for at least one axis or button. Move definition to try to fix conflict. PR review comments. qmk cformat * avoid float functions to compute range mapping for axis adc reading * Remove V-USB support for now. Updated docs accordingly. * Update tmk_core/protocol/lufa/lufa.c Co-Authored-By: Ryan <fauxpark@gmail.com> * Update tmk_core/protocol/usb_descriptor.c Co-Authored-By: Ryan <fauxpark@gmail.com> * Update tmk_core/protocol/usb_descriptor.c Co-Authored-By: Ryan <fauxpark@gmail.com> * Update tmk_core/protocol/usb_descriptor.c Co-Authored-By: Ryan <fauxpark@gmail.com> * Add support for joystick adc reading for stm32 MCUs. Fix joystick hid report sending for chibios * Fix HID joystick report sending for ChibiOS. Add one analog axis to the onekey:joystick keymap. Fix pin state save and restore during joystick analog read for STM32 MCUs. * Update tmk_core/protocol/chibios/usb_main.c Co-Authored-By: Ryan <fauxpark@gmail.com> * Update tmk_core/protocol/lufa/lufa.c Co-Authored-By: Ryan <fauxpark@gmail.com> * Add missing mcuconf.h and halconf.h to onekey:joystick keymap. Add suggested fixes from PR. * Switch saveState and restoreState signature to use pin_t type. onekey:joystick : add a second axis, virtual and programmatically animated. * Update docs/feature_joystick.md Co-Authored-By: Ryan <fauxpark@gmail.com> * Update docs/feature_joystick.md Co-Authored-By: Ryan <fauxpark@gmail.com> * Add PR corrections * Remove halconf.h and mcuconf.h from onekey keymaps * Change ADC_PIN to A0 Co-authored-by: achol <allecooll@hotmail.com> Co-authored-by: José Júnior <jose.junior@gmail.com> Co-authored-by: a-chol <achol@notamail.com> Co-authored-by: Nick Brassel <nick@tzarc.org> Co-authored-by: Ryan <fauxpark@gmail.com>
Diffstat (limited to 'tmk_core')
-rw-r--r--tmk_core/common/keyboard.c7
-rw-r--r--tmk_core/common/report.h13
-rw-r--r--tmk_core/protocol/chibios/usb_main.c69
-rw-r--r--tmk_core/protocol/lufa/lufa.c67
-rw-r--r--tmk_core/protocol/usb_descriptor.c111
-rw-r--r--tmk_core/protocol/usb_descriptor.h15
6 files changed, 280 insertions, 2 deletions
diff --git a/tmk_core/common/keyboard.c b/tmk_core/common/keyboard.c
index 714c3d048..a45af56df 100644
--- a/tmk_core/common/keyboard.c
+++ b/tmk_core/common/keyboard.c
@@ -74,6 +74,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
74#ifdef MIDI_ENABLE 74#ifdef MIDI_ENABLE
75# include "process_midi.h" 75# include "process_midi.h"
76#endif 76#endif
77#ifdef JOYSTICK_ENABLE
78# include "process_joystick.h"
79#endif
77#ifdef HD44780_ENABLE 80#ifdef HD44780_ENABLE
78# include "hd44780.h" 81# include "hd44780.h"
79#endif 82#endif
@@ -420,6 +423,10 @@ MATRIX_LOOP_END:
420 } 423 }
421#endif 424#endif
422 425
426#ifdef JOYSTICK_ENABLE
427 joystick_task();
428#endif
429
423 // update LED 430 // update LED
424 if (led_status != host_keyboard_leds()) { 431 if (led_status != host_keyboard_leds()) {
425 led_status = host_keyboard_leds(); 432 led_status = host_keyboard_leds();
diff --git a/tmk_core/common/report.h b/tmk_core/common/report.h
index 1b2f13bdd..1aa33c998 100644
--- a/tmk_core/common/report.h
+++ b/tmk_core/common/report.h
@@ -29,7 +29,8 @@ enum hid_report_ids {
29 REPORT_ID_MOUSE, 29 REPORT_ID_MOUSE,
30 REPORT_ID_SYSTEM, 30 REPORT_ID_SYSTEM,
31 REPORT_ID_CONSUMER, 31 REPORT_ID_CONSUMER,
32 REPORT_ID_NKRO 32 REPORT_ID_NKRO,
33 REPORT_ID_JOYSTICK
33}; 34};
34 35
35/* Mouse buttons */ 36/* Mouse buttons */
@@ -189,6 +190,16 @@ typedef struct {
189 int8_t h; 190 int8_t h;
190} __attribute__((packed)) report_mouse_t; 191} __attribute__((packed)) report_mouse_t;
191 192
193typedef struct {
194#if JOYSTICK_AXES_COUNT > 0
195 int8_t axes[JOYSTICK_AXES_COUNT];
196#endif
197
198#if JOYSTICK_BUTTON_COUNT > 0
199 uint8_t buttons[(JOYSTICK_BUTTON_COUNT - 1) / 8 + 1];
200#endif
201} __attribute__((packed)) joystick_report_t;
202
192/* keycode to system usage */ 203/* keycode to system usage */
193static inline uint16_t KEYCODE2SYSTEM(uint8_t key) { 204static inline uint16_t KEYCODE2SYSTEM(uint8_t key) {
194 switch (key) { 205 switch (key) {
diff --git a/tmk_core/protocol/chibios/usb_main.c b/tmk_core/protocol/chibios/usb_main.c
index 21e9f14e5..68c61cf55 100644
--- a/tmk_core/protocol/chibios/usb_main.c
+++ b/tmk_core/protocol/chibios/usb_main.c
@@ -47,6 +47,10 @@
47extern keymap_config_t keymap_config; 47extern keymap_config_t keymap_config;
48#endif 48#endif
49 49
50#ifdef JOYSTICK_ENABLE
51# include "joystick.h"
52#endif
53
50/* --------------------------------------------------------- 54/* ---------------------------------------------------------
51 * Global interface variables and declarations 55 * Global interface variables and declarations
52 * --------------------------------------------------------- 56 * ---------------------------------------------------------
@@ -247,6 +251,9 @@ typedef struct {
247#ifdef VIRTSER_ENABLE 251#ifdef VIRTSER_ENABLE
248 usb_driver_config_t serial_driver; 252 usb_driver_config_t serial_driver;
249#endif 253#endif
254#ifdef JOYSTICK_ENABLE
255 usb_driver_config_t joystick_driver;
256#endif
250 }; 257 };
251 usb_driver_config_t array[0]; 258 usb_driver_config_t array[0];
252 }; 259 };
@@ -283,6 +290,14 @@ static usb_driver_configs_t drivers = {
283# define CDC_OUT_MODE USB_EP_MODE_TYPE_BULK 290# define CDC_OUT_MODE USB_EP_MODE_TYPE_BULK
284 .serial_driver = QMK_USB_DRIVER_CONFIG(CDC, CDC_NOTIFICATION_EPNUM, false), 291 .serial_driver = QMK_USB_DRIVER_CONFIG(CDC, CDC_NOTIFICATION_EPNUM, false),
285#endif 292#endif
293
294#ifdef JOYSTICK_ENABLE
295# define JOYSTICK_IN_CAPACITY 4
296# define JOYSTICK_OUT_CAPACITY 4
297# define JOYSTICK_IN_MODE USB_EP_MODE_TYPE_BULK
298# define JOYSTICK_OUT_MODE USB_EP_MODE_TYPE_BULK
299 .joystick_driver = QMK_USB_DRIVER_CONFIG(JOYSTICK, 0, false),
300#endif
286}; 301};
287 302
288#define NUM_USB_DRIVERS (sizeof(drivers) / sizeof(usb_driver_config_t)) 303#define NUM_USB_DRIVERS (sizeof(drivers) / sizeof(usb_driver_config_t))
@@ -867,3 +882,57 @@ void virtser_task(void) {
867} 882}
868 883
869#endif 884#endif
885
886#ifdef JOYSTICK_ENABLE
887
888void send_joystick_packet(joystick_t *joystick) {
889 joystick_report_t rep = {
890# if JOYSTICK_AXES_COUNT > 0
891 .axes = {joystick->axes[0],
892
893# if JOYSTICK_AXES_COUNT >= 2
894 joystick->axes[1],
895# endif
896# if JOYSTICK_AXES_COUNT >= 3
897 joystick->axes[2],
898# endif
899# if JOYSTICK_AXES_COUNT >= 4
900 joystick->axes[3],
901# endif
902# if JOYSTICK_AXES_COUNT >= 5
903 joystick->axes[4],
904# endif
905# if JOYSTICK_AXES_COUNT >= 6
906 joystick->axes[5],
907# endif
908 },
909# endif // JOYSTICK_AXES_COUNT>0
910
911# if JOYSTICK_BUTTON_COUNT > 0
912 .buttons = {joystick->buttons[0],
913
914# if JOYSTICK_BUTTON_COUNT > 8
915 joystick->buttons[1],
916# endif
917# if JOYSTICK_BUTTON_COUNT > 16
918 joystick->buttons[2],
919# endif
920# if JOYSTICK_BUTTON_COUNT > 24
921 joystick->buttons[3],
922# endif
923 }
924# endif // JOYSTICK_BUTTON_COUNT>0
925 };
926
927 // chnWrite(&drivers.joystick_driver.driver, (uint8_t *)&rep, sizeof(rep));
928 osalSysLock();
929 if (usbGetDriverStateI(&USB_DRIVER) != USB_ACTIVE) {
930 osalSysUnlock();
931 return;
932 }
933
934 usbStartTransmitI(&USB_DRIVER, JOYSTICK_IN_EPNUM, (uint8_t *)&rep, sizeof(joystick_report_t));
935 osalSysUnlock();
936}
937
938#endif
diff --git a/tmk_core/protocol/lufa/lufa.c b/tmk_core/protocol/lufa/lufa.c
index 6776a964e..85603646d 100644
--- a/tmk_core/protocol/lufa/lufa.c
+++ b/tmk_core/protocol/lufa/lufa.c
@@ -85,6 +85,10 @@ extern keymap_config_t keymap_config;
85# include "raw_hid.h" 85# include "raw_hid.h"
86#endif 86#endif
87 87
88#ifdef JOYSTICK_ENABLE
89# include "joystick.h"
90#endif
91
88uint8_t keyboard_idle = 0; 92uint8_t keyboard_idle = 0;
89/* 0: Boot Protocol, 1: Report Protocol(default) */ 93/* 0: Boot Protocol, 1: Report Protocol(default) */
90uint8_t keyboard_protocol = 1; 94uint8_t keyboard_protocol = 1;
@@ -264,6 +268,66 @@ static void Console_Task(void) {
264#endif 268#endif
265 269
266/******************************************************************************* 270/*******************************************************************************
271 * Joystick
272 ******************************************************************************/
273#ifdef JOYSTICK_ENABLE
274void send_joystick_packet(joystick_t *joystick) {
275 uint8_t timeout = 255;
276
277 joystick_report_t r = {
278# if JOYSTICK_AXES_COUNT > 0
279 .axes = {joystick->axes[0],
280
281# if JOYSTICK_AXES_COUNT >= 2
282 joystick->axes[1],
283# endif
284# if JOYSTICK_AXES_COUNT >= 3
285 joystick->axes[2],
286# endif
287# if JOYSTICK_AXES_COUNT >= 4
288 joystick->axes[3],
289# endif
290# if JOYSTICK_AXES_COUNT >= 5
291 joystick->axes[4],
292# endif
293# if JOYSTICK_AXES_COUNT >= 6
294 joystick->axes[5],
295# endif
296 },
297# endif // JOYSTICK_AXES_COUNT>0
298
299# if JOYSTICK_BUTTON_COUNT > 0
300 .buttons = {joystick->buttons[0],
301
302# if JOYSTICK_BUTTON_COUNT > 8
303 joystick->buttons[1],
304# endif
305# if JOYSTICK_BUTTON_COUNT > 16
306 joystick->buttons[2],
307# endif
308# if JOYSTICK_BUTTON_COUNT > 24
309 joystick->buttons[3],
310# endif
311 }
312# endif // JOYSTICK_BUTTON_COUNT>0
313 };
314
315 /* Select the Joystick Report Endpoint */
316 Endpoint_SelectEndpoint(JOYSTICK_IN_EPNUM);
317
318 /* Check if write ready for a polling interval around 10ms */
319 while (timeout-- && !Endpoint_IsReadWriteAllowed()) _delay_us(40);
320 if (!Endpoint_IsReadWriteAllowed()) return;
321
322 /* Write Joystick Report Data */
323 Endpoint_Write_Stream_LE(&r, sizeof(joystick_report_t), NULL);
324
325 /* Finalize the stream transfer to send the last packet */
326 Endpoint_ClearIN();
327}
328#endif
329
330/*******************************************************************************
267 * USB Events 331 * USB Events
268 ******************************************************************************/ 332 ******************************************************************************/
269/* 333/*
@@ -411,6 +475,9 @@ void EVENT_USB_Device_ConfigurationChanged(void) {
411 ConfigSuccess &= Endpoint_ConfigureEndpoint((CDC_OUT_EPNUM | ENDPOINT_DIR_OUT), EP_TYPE_BULK, CDC_EPSIZE, 1); 475 ConfigSuccess &= Endpoint_ConfigureEndpoint((CDC_OUT_EPNUM | ENDPOINT_DIR_OUT), EP_TYPE_BULK, CDC_EPSIZE, 1);
412 ConfigSuccess &= Endpoint_ConfigureEndpoint((CDC_IN_EPNUM | ENDPOINT_DIR_IN), EP_TYPE_BULK, CDC_EPSIZE, 1); 476 ConfigSuccess &= Endpoint_ConfigureEndpoint((CDC_IN_EPNUM | ENDPOINT_DIR_IN), EP_TYPE_BULK, CDC_EPSIZE, 1);
413#endif 477#endif
478#ifdef JOYSTICK_ENABLE
479 ConfigSuccess &= ENDPOINT_CONFIG(JOYSTICK_IN_EPNUM, EP_TYPE_INTERRUPT, ENDPOINT_DIR_IN, JOYSTICK_EPSIZE, ENDPOINT_BANK_SINGLE);
480#endif
414} 481}
415 482
416/* FIXME: Expose this table in the docs somehow 483/* FIXME: Expose this table in the docs somehow
diff --git a/tmk_core/protocol/usb_descriptor.c b/tmk_core/protocol/usb_descriptor.c
index bcca24586..f5d32445d 100644
--- a/tmk_core/protocol/usb_descriptor.c
+++ b/tmk_core/protocol/usb_descriptor.c
@@ -279,6 +279,63 @@ const USB_Descriptor_HIDReport_Datatype_t PROGMEM ConsoleReport[] = {
279}; 279};
280#endif 280#endif
281 281
282#ifdef JOYSTICK_ENABLE
283# if JOYSTICK_AXES_COUNT == 0 && JOYSTICK_BUTTON_COUNT == 0
284# error Need at least one axis or button for joystick
285# endif
286const USB_Descriptor_HIDReport_Datatype_t PROGMEM JoystickReport[] = {
287 HID_RI_USAGE_PAGE(8, 0x01), // Generic Desktop
288 HID_RI_USAGE(8, 0x04), // Joystick
289 HID_RI_COLLECTION(8, 0x01), // Application
290 HID_RI_COLLECTION(8, 0x00), // Physical
291 HID_RI_USAGE_PAGE(8, 0x01), // Generic Desktop
292# if JOYSTICK_AXES_COUNT >= 1
293 HID_RI_USAGE(8, 0x30), // X
294# endif
295# if JOYSTICK_AXES_COUNT >= 2
296 HID_RI_USAGE(8, 0x31), // Y
297# endif
298# if JOYSTICK_AXES_COUNT >= 3
299 HID_RI_USAGE(8, 0x32), // Z
300# endif
301# if JOYSTICK_AXES_COUNT >= 4
302 HID_RI_USAGE(8, 0x33), // Rx
303# endif
304# if JOYSTICK_AXES_COUNT >= 5
305 HID_RI_USAGE(8, 0x34), // Ry
306# endif
307# if JOYSTICK_AXES_COUNT >= 6
308 HID_RI_USAGE(8, 0x35), // Rz
309# endif
310# if JOYSTICK_AXES_COUNT >= 1
311 HID_RI_LOGICAL_MINIMUM(8, -127),
312 HID_RI_LOGICAL_MAXIMUM(8, 127),
313 HID_RI_REPORT_COUNT(8, JOYSTICK_AXES_COUNT),
314 HID_RI_REPORT_SIZE(8, 0x08),
315 HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE),
316# endif
317
318# if JOYSTICK_BUTTON_COUNT >= 1
319 HID_RI_USAGE_PAGE(8, 0x09), // Button
320 HID_RI_USAGE_MINIMUM(8, 0x01),
321 HID_RI_USAGE_MAXIMUM(8, JOYSTICK_BUTTON_COUNT),
322 HID_RI_LOGICAL_MINIMUM(8, 0x00),
323 HID_RI_LOGICAL_MAXIMUM(8, 0x01),
324 HID_RI_REPORT_COUNT(8, JOYSTICK_BUTTON_COUNT),
325 HID_RI_REPORT_SIZE(8, 0x01),
326 HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE),
327
328# if (JOYSTICK_BUTTON_COUNT % 8) != 0
329 HID_RI_REPORT_COUNT(8, 8 - (JOYSTICK_BUTTON_COUNT % 8)),
330 HID_RI_REPORT_SIZE(8, 0x01),
331 HID_RI_INPUT(8, HID_IOF_CONSTANT),
332# endif
333# endif
334 HID_RI_END_COLLECTION(0),
335 HID_RI_END_COLLECTION(0)
336};
337#endif
338
282/* 339/*
283 * Device descriptor 340 * Device descriptor
284 */ 341 */
@@ -288,7 +345,7 @@ const USB_Descriptor_Device_t PROGMEM DeviceDescriptor = {
288 .Type = DTYPE_Device 345 .Type = DTYPE_Device
289 }, 346 },
290 .USBSpecification = VERSION_BCD(1, 1, 0), 347 .USBSpecification = VERSION_BCD(1, 1, 0),
291 348
292#if VIRTSER_ENABLE 349#if VIRTSER_ENABLE
293 .Class = USB_CSCP_IADDeviceClass, 350 .Class = USB_CSCP_IADDeviceClass,
294 .SubClass = USB_CSCP_IADDeviceSubclass, 351 .SubClass = USB_CSCP_IADDeviceSubclass,
@@ -813,6 +870,46 @@ const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor = {
813 .PollingIntervalMS = 0x05 870 .PollingIntervalMS = 0x05
814 }, 871 },
815#endif 872#endif
873
874 /*
875 * Joystick
876 */
877#ifdef JOYSTICK_ENABLE
878 .Joystick_Interface = {
879 .Header = {
880 .Size = sizeof(USB_Descriptor_Interface_t),
881 .Type = DTYPE_Interface
882 },
883 .InterfaceNumber = JOYSTICK_INTERFACE,
884 .AlternateSetting = 0x00,
885 .TotalEndpoints = 1,
886 .Class = HID_CSCP_HIDClass,
887 .SubClass = HID_CSCP_NonBootSubclass,
888 .Protocol = HID_CSCP_NonBootProtocol,
889 .InterfaceStrIndex = NO_DESCRIPTOR
890 },
891 .Joystick_HID = {
892 .Header = {
893 .Size = sizeof(USB_HID_Descriptor_HID_t),
894 .Type = HID_DTYPE_HID
895 },
896 .HIDSpec = VERSION_BCD(1, 1, 1),
897 .CountryCode = 0x00,
898 .TotalReportDescriptors = 1,
899 .HIDReportType = HID_DTYPE_Report,
900 .HIDReportLength = sizeof(JoystickReport)
901 },
902 .Joystick_INEndpoint = {
903 .Header = {
904 .Size = sizeof(USB_Descriptor_Endpoint_t),
905 .Type = DTYPE_Endpoint
906 },
907 .EndpointAddress = (ENDPOINT_DIR_IN | JOYSTICK_IN_EPNUM),
908 .Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
909 .EndpointSize = JOYSTICK_EPSIZE,
910 .PollingIntervalMS = USB_POLLING_INTERVAL_MS
911 }
912#endif
816}; 913};
817 914
818/* 915/*
@@ -945,6 +1042,12 @@ uint16_t get_usb_descriptor(const uint16_t wValue, const uint16_t wIndex, const
945 1042
946 break; 1043 break;
947#endif 1044#endif
1045#ifdef JOYSTICK_ENABLE
1046 case JOYSTICK_INTERFACE:
1047 Address = &ConfigurationDescriptor.Joystick_HID;
1048 Size = sizeof(USB_HID_Descriptor_HID_t);
1049 break;
1050#endif
948 } 1051 }
949 1052
950 break; 1053 break;
@@ -989,6 +1092,12 @@ uint16_t get_usb_descriptor(const uint16_t wValue, const uint16_t wIndex, const
989 1092
990 break; 1093 break;
991#endif 1094#endif
1095#ifdef JOYSTICK_ENABLE
1096 case JOYSTICK_INTERFACE:
1097 Address = &JoystickReport;
1098 Size = sizeof(JoystickReport);
1099 break;
1100#endif
992 } 1101 }
993 1102
994 break; 1103 break;
diff --git a/tmk_core/protocol/usb_descriptor.h b/tmk_core/protocol/usb_descriptor.h
index 34a85978a..79dd87014 100644
--- a/tmk_core/protocol/usb_descriptor.h
+++ b/tmk_core/protocol/usb_descriptor.h
@@ -123,6 +123,13 @@ typedef struct {
123 USB_Descriptor_Endpoint_t CDC_DataOutEndpoint; 123 USB_Descriptor_Endpoint_t CDC_DataOutEndpoint;
124 USB_Descriptor_Endpoint_t CDC_DataInEndpoint; 124 USB_Descriptor_Endpoint_t CDC_DataInEndpoint;
125#endif 125#endif
126
127#ifdef JOYSTICK_ENABLE
128 // Joystick HID Interface
129 USB_Descriptor_Interface_t Joystick_Interface;
130 USB_HID_Descriptor_HID_t Joystick_HID;
131 USB_Descriptor_Endpoint_t Joystick_INEndpoint;
132#endif
126} USB_Descriptor_Configuration_t; 133} USB_Descriptor_Configuration_t;
127 134
128/* 135/*
@@ -164,6 +171,9 @@ enum usb_interfaces {
164 CDI_INTERFACE, 171 CDI_INTERFACE,
165#endif 172#endif
166 173
174#if defined(JOYSTICK_ENABLE)
175 JOYSTICK_INTERFACE,
176#endif
167 TOTAL_INTERFACES 177 TOTAL_INTERFACES
168}; 178};
169 179
@@ -219,6 +229,10 @@ enum usb_endpoints {
219 CDC_IN_EPNUM = NEXT_EPNUM, 229 CDC_IN_EPNUM = NEXT_EPNUM,
220 CDC_OUT_EPNUM = NEXT_EPNUM, 230 CDC_OUT_EPNUM = NEXT_EPNUM,
221#endif 231#endif
232#ifdef JOYSTICK_ENABLE
233 JOYSTICK_IN_EPNUM = NEXT_EPNUM,
234 JOYSTICK_OUT_EPNUM = NEXT_EPNUM,
235#endif
222}; 236};
223 237
224#ifdef PROTOCOL_LUFA 238#ifdef PROTOCOL_LUFA
@@ -243,6 +257,7 @@ enum usb_endpoints {
243#define MIDI_STREAM_EPSIZE 64 257#define MIDI_STREAM_EPSIZE 64
244#define CDC_NOTIFICATION_EPSIZE 8 258#define CDC_NOTIFICATION_EPSIZE 8
245#define CDC_EPSIZE 16 259#define CDC_EPSIZE 16
260#define JOYSTICK_EPSIZE 8
246 261
247uint16_t get_usb_descriptor(const uint16_t wValue, const uint16_t wIndex, const void** const DescriptorAddress); 262uint16_t get_usb_descriptor(const uint16_t wValue, const uint16_t wIndex, const void** const DescriptorAddress);
248#endif 263#endif