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
This commit is contained in:
parent
d88bdc6a1b
commit
801be60473
18 changed files with 455 additions and 458 deletions
|
@ -48,7 +48,7 @@ extern keymap_config_t keymap_config;
|
|||
#endif
|
||||
|
||||
#ifdef JOYSTICK_ENABLE
|
||||
# include <quantum/joystick.h>
|
||||
# include "joystick.h"
|
||||
#endif
|
||||
|
||||
/* ---------------------------------------------------------
|
||||
|
@ -292,11 +292,11 @@ static usb_driver_configs_t drivers = {
|
|||
#endif
|
||||
|
||||
#ifdef JOYSTICK_ENABLE
|
||||
#define JOYSTICK_IN_CAPACITY 4
|
||||
#define JOYSTICK_OUT_CAPACITY 4
|
||||
#define JOYSTICK_IN_MODE USB_EP_MODE_TYPE_BULK
|
||||
#define JOYSTICK_OUT_MODE USB_EP_MODE_TYPE_BULK
|
||||
.joystick_driver = QMK_USB_DRIVER_CONFIG(JOYSTICK, 0, false),
|
||||
# define JOYSTICK_IN_CAPACITY 4
|
||||
# define JOYSTICK_OUT_CAPACITY 4
|
||||
# define JOYSTICK_IN_MODE USB_EP_MODE_TYPE_BULK
|
||||
# define JOYSTICK_OUT_MODE USB_EP_MODE_TYPE_BULK
|
||||
.joystick_driver = QMK_USB_DRIVER_CONFIG(JOYSTICK, 0, false),
|
||||
#endif
|
||||
};
|
||||
|
||||
|
@ -888,58 +888,54 @@ void virtser_task(void) {
|
|||
|
||||
#ifdef JOYSTICK_ENABLE
|
||||
|
||||
typedef struct {
|
||||
#if JOYSTICK_AXES_COUNT>0
|
||||
int8_t axes[JOYSTICK_AXES_COUNT];
|
||||
#endif
|
||||
|
||||
#if JOYSTICK_BUTTON_COUNT>0
|
||||
uint8_t buttons[(JOYSTICK_BUTTON_COUNT-1)/8+1];
|
||||
#endif
|
||||
} __attribute__ ((packed)) joystick_report_t;
|
||||
|
||||
void send_joystick_packet(joystick_t* joystick) {
|
||||
void send_joystick_packet(joystick_t *joystick) {
|
||||
joystick_report_t rep = {
|
||||
#if JOYSTICK_AXES_COUNT>0
|
||||
.axes = {
|
||||
joystick->axes[0]
|
||||
# if JOYSTICK_AXES_COUNT > 0
|
||||
.axes = {joystick->axes[0]
|
||||
|
||||
#if JOYSTICK_AXES_COUNT >= 2
|
||||
,joystick->axes[1]
|
||||
#endif
|
||||
#if JOYSTICK_AXES_COUNT >= 3
|
||||
,joystick->axes[2]
|
||||
#endif
|
||||
#if JOYSTICK_AXES_COUNT >= 4
|
||||
,joystick->axes[3]
|
||||
#endif
|
||||
#if JOYSTICK_AXES_COUNT >= 5
|
||||
,joystick->axes[4]
|
||||
#endif
|
||||
#if JOYSTICK_AXES_COUNT >= 6
|
||||
,joystick->axes[5]
|
||||
#endif
|
||||
},
|
||||
#endif //JOYSTICK_AXES_COUNT>0
|
||||
|
||||
#if JOYSTICK_BUTTON_COUNT>0
|
||||
.buttons = {
|
||||
joystick->buttons[0]
|
||||
|
||||
#if JOYSTICK_BUTTON_COUNT>8
|
||||
,joystick->buttons[1]
|
||||
#endif
|
||||
#if JOYSTICK_BUTTON_COUNT>16
|
||||
,joystick->buttons[2]
|
||||
#endif
|
||||
#if JOYSTICK_BUTTON_COUNT>24
|
||||
,joystick->buttons[3]
|
||||
#endif
|
||||
}
|
||||
#endif //JOYSTICK_BUTTON_COUNT>0
|
||||
};
|
||||
|
||||
chnWrite(&drivers.joystick_driver.driver, (uint8_t*)&rep, sizeof(rep));
|
||||
# if JOYSTICK_AXES_COUNT >= 2
|
||||
,
|
||||
joystick->axes[1]
|
||||
# endif
|
||||
# if JOYSTICK_AXES_COUNT >= 3
|
||||
,
|
||||
joystick->axes[2]
|
||||
# endif
|
||||
# if JOYSTICK_AXES_COUNT >= 4
|
||||
,
|
||||
joystick->axes[3]
|
||||
# endif
|
||||
# if JOYSTICK_AXES_COUNT >= 5
|
||||
,
|
||||
joystick->axes[4]
|
||||
# endif
|
||||
# if JOYSTICK_AXES_COUNT >= 6
|
||||
,
|
||||
joystick->axes[5]
|
||||
# endif
|
||||
},
|
||||
# endif // JOYSTICK_AXES_COUNT>0
|
||||
|
||||
# if JOYSTICK_BUTTON_COUNT > 0
|
||||
.buttons = {joystick->buttons[0]
|
||||
|
||||
# if JOYSTICK_BUTTON_COUNT > 8
|
||||
,
|
||||
joystick->buttons[1]
|
||||
# endif
|
||||
# if JOYSTICK_BUTTON_COUNT > 16
|
||||
,
|
||||
joystick->buttons[2]
|
||||
# endif
|
||||
# if JOYSTICK_BUTTON_COUNT > 24
|
||||
,
|
||||
joystick->buttons[3]
|
||||
# endif
|
||||
}
|
||||
# endif // JOYSTICK_BUTTON_COUNT>0
|
||||
};
|
||||
|
||||
chnWrite(&drivers.joystick_driver.driver, (uint8_t *)&rep, sizeof(rep));
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -86,7 +86,7 @@ extern keymap_config_t keymap_config;
|
|||
#endif
|
||||
|
||||
#ifdef JOYSTICK_ENABLE
|
||||
#include "joystick.h"
|
||||
# include "joystick.h"
|
||||
#endif
|
||||
|
||||
uint8_t keyboard_idle = 0;
|
||||
|
@ -271,64 +271,58 @@ static void Console_Task(void) {
|
|||
* Joystick
|
||||
******************************************************************************/
|
||||
#ifdef JOYSTICK_ENABLE
|
||||
|
||||
typedef struct {
|
||||
#if JOYSTICK_AXES_COUNT>0
|
||||
int8_t axes[JOYSTICK_AXES_COUNT];
|
||||
#endif
|
||||
|
||||
#if JOYSTICK_BUTTON_COUNT>0
|
||||
uint8_t buttons[(JOYSTICK_BUTTON_COUNT-1)/8+1];
|
||||
#endif
|
||||
} __attribute__ ((packed)) joystick_report_t;
|
||||
|
||||
void send_joystick_packet(joystick_t* joystick){
|
||||
|
||||
void send_joystick_packet(joystick_t *joystick) {
|
||||
uint8_t timeout = 255;
|
||||
uint8_t where = where_to_send();
|
||||
|
||||
if (where != OUTPUT_USB && where != OUTPUT_USB_AND_BT) {
|
||||
return;
|
||||
}
|
||||
|
||||
joystick_report_t r = {
|
||||
#if JOYSTICK_AXES_COUNT>0
|
||||
.axes = {
|
||||
joystick->axes[0]
|
||||
uint8_t where = where_to_send();
|
||||
|
||||
#if JOYSTICK_AXES_COUNT >= 2
|
||||
,joystick->axes[1]
|
||||
#endif
|
||||
#if JOYSTICK_AXES_COUNT >= 3
|
||||
,joystick->axes[2]
|
||||
#endif
|
||||
#if JOYSTICK_AXES_COUNT >= 4
|
||||
,joystick->axes[3]
|
||||
#endif
|
||||
#if JOYSTICK_AXES_COUNT >= 5
|
||||
,joystick->axes[4]
|
||||
#endif
|
||||
#if JOYSTICK_AXES_COUNT >= 6
|
||||
,joystick->axes[5]
|
||||
#endif
|
||||
if (where != OUTPUT_USB && where != OUTPUT_USB_AND_BT) {
|
||||
return;
|
||||
}
|
||||
|
||||
joystick_report_t r = {
|
||||
# if JOYSTICK_AXES_COUNT > 0
|
||||
.axes = {joystick->axes[0]
|
||||
|
||||
# if JOYSTICK_AXES_COUNT >= 2
|
||||
,
|
||||
joystick->axes[1]
|
||||
# endif
|
||||
# if JOYSTICK_AXES_COUNT >= 3
|
||||
,
|
||||
joystick->axes[2]
|
||||
# endif
|
||||
# if JOYSTICK_AXES_COUNT >= 4
|
||||
,
|
||||
joystick->axes[3]
|
||||
# endif
|
||||
# if JOYSTICK_AXES_COUNT >= 5
|
||||
,
|
||||
joystick->axes[4]
|
||||
# endif
|
||||
# if JOYSTICK_AXES_COUNT >= 6
|
||||
,
|
||||
joystick->axes[5]
|
||||
# endif
|
||||
},
|
||||
#endif //JOYSTICK_AXES_COUNT>0
|
||||
|
||||
#if JOYSTICK_BUTTON_COUNT>0
|
||||
.buttons = {
|
||||
joystick->buttons[0]
|
||||
|
||||
#if JOYSTICK_BUTTON_COUNT>8
|
||||
,joystick->buttons[1]
|
||||
#endif
|
||||
#if JOYSTICK_BUTTON_COUNT>16
|
||||
,joystick->buttons[2]
|
||||
#endif
|
||||
#if JOYSTICK_BUTTON_COUNT>24
|
||||
,joystick->buttons[3]
|
||||
#endif
|
||||
# endif // JOYSTICK_AXES_COUNT>0
|
||||
|
||||
# if JOYSTICK_BUTTON_COUNT > 0
|
||||
.buttons = {joystick->buttons[0]
|
||||
|
||||
# if JOYSTICK_BUTTON_COUNT > 8
|
||||
,
|
||||
joystick->buttons[1]
|
||||
# endif
|
||||
# if JOYSTICK_BUTTON_COUNT > 16
|
||||
,
|
||||
joystick->buttons[2]
|
||||
# endif
|
||||
# if JOYSTICK_BUTTON_COUNT > 24
|
||||
,
|
||||
joystick->buttons[3]
|
||||
# endif
|
||||
}
|
||||
#endif //JOYSTICK_BUTTON_COUNT>0
|
||||
# endif // JOYSTICK_BUTTON_COUNT>0
|
||||
};
|
||||
|
||||
/* Select the Joystick Report Endpoint */
|
||||
|
@ -494,8 +488,7 @@ void EVENT_USB_Device_ConfigurationChanged(void) {
|
|||
ConfigSuccess &= Endpoint_ConfigureEndpoint(CDC_IN_EPADDR, EP_TYPE_BULK, CDC_EPSIZE, ENDPOINT_BANK_SINGLE);
|
||||
#endif
|
||||
#ifdef JOYSTICK_ENABLE
|
||||
ConfigSuccess &= ENDPOINT_CONFIG(JOYSTICK_IN_EPNUM, EP_TYPE_INTERRUPT, ENDPOINT_DIR_IN,
|
||||
JOYSTICK_EPSIZE, ENDPOINT_BANK_SINGLE);
|
||||
ConfigSuccess &= ENDPOINT_CONFIG(JOYSTICK_IN_EPNUM, EP_TYPE_INTERRUPT, ENDPOINT_DIR_IN, JOYSTICK_EPSIZE, ENDPOINT_BANK_SINGLE);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -279,51 +279,58 @@ const USB_Descriptor_HIDReport_Datatype_t PROGMEM ConsoleReport[] = {
|
|||
#endif
|
||||
|
||||
#ifdef JOYSTICK_ENABLE
|
||||
#if JOYSTICK_AXES_COUNT == 0 && JOYSTICK_BUTTON_COUNT == 0
|
||||
#error Need at least one axis or button for joystick
|
||||
#endif
|
||||
const USB_Descriptor_HIDReport_Datatype_t PROGMEM JoystickReport[] =
|
||||
{
|
||||
HID_RI_USAGE_PAGE(8, 0x01), /* Generic Desktop */
|
||||
HID_RI_USAGE(8, 0x04), /* Joystick */
|
||||
HID_RI_COLLECTION(8, 0x01), /* Application */
|
||||
HID_RI_COLLECTION(8, 0x00), /* Physical */
|
||||
HID_RI_USAGE_PAGE(8, 0x01), /* Generic Desktop */
|
||||
#if JOYSTICK_AXES_COUNT >= 1
|
||||
HID_RI_USAGE_PAGE(8, 0x01), /* Generic Desktop */
|
||||
#if JOYSTICK_AXES_COUNT >= 1
|
||||
HID_RI_USAGE(8, 0x30), // USAGE (X)
|
||||
#endif
|
||||
#if JOYSTICK_AXES_COUNT >= 2
|
||||
#if JOYSTICK_AXES_COUNT >= 2
|
||||
HID_RI_USAGE(8, 0x31), // USAGE (Y)
|
||||
#endif
|
||||
#if JOYSTICK_AXES_COUNT >= 3
|
||||
#if JOYSTICK_AXES_COUNT >= 3
|
||||
HID_RI_USAGE(8, 0x32), // USAGE (Z)
|
||||
#endif
|
||||
#if JOYSTICK_AXES_COUNT >= 4
|
||||
#if JOYSTICK_AXES_COUNT >= 4
|
||||
HID_RI_USAGE(8, 0x33), // USAGE (RX)
|
||||
#endif
|
||||
#if JOYSTICK_AXES_COUNT >= 5
|
||||
#if JOYSTICK_AXES_COUNT >= 5
|
||||
HID_RI_USAGE(8, 0x34), // USAGE (RY)
|
||||
#endif
|
||||
#if JOYSTICK_AXES_COUNT >= 6
|
||||
#if JOYSTICK_AXES_COUNT >= 6
|
||||
HID_RI_USAGE(8, 0x35), // USAGE (RZ)
|
||||
#endif
|
||||
HID_RI_LOGICAL_MINIMUM(8, -127),
|
||||
HID_RI_LOGICAL_MAXIMUM(8, 127),
|
||||
HID_RI_REPORT_COUNT(8, JOYSTICK_AXES_COUNT),
|
||||
HID_RI_REPORT_SIZE(8, 0x08),
|
||||
HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE),
|
||||
#if JOYSTICK_AXES_COUNT >= 1
|
||||
HID_RI_LOGICAL_MINIMUM(8, -127),
|
||||
HID_RI_LOGICAL_MAXIMUM(8, 127),
|
||||
HID_RI_REPORT_COUNT(8, JOYSTICK_AXES_COUNT),
|
||||
HID_RI_REPORT_SIZE(8, 0x08),
|
||||
HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE),
|
||||
#endif
|
||||
|
||||
HID_RI_USAGE_PAGE(8, 0x09), /* Button */
|
||||
HID_RI_USAGE_MINIMUM(8, 0x01), /* Button 1 */
|
||||
HID_RI_USAGE_MAXIMUM(8, JOYSTICK_BUTTON_COUNT), /* Button 5 */
|
||||
HID_RI_LOGICAL_MINIMUM(8, 0x00),
|
||||
HID_RI_LOGICAL_MAXIMUM(8, 0x01),
|
||||
HID_RI_REPORT_COUNT(8, JOYSTICK_BUTTON_COUNT),
|
||||
HID_RI_REPORT_SIZE(8, 0x01),
|
||||
HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE),
|
||||
#if JOYSTICK_BUTTON_COUNT >= 1
|
||||
HID_RI_USAGE_PAGE(8, 0x09), /* Button */
|
||||
HID_RI_USAGE_MINIMUM(8, 0x01), /* Button 1 */
|
||||
HID_RI_USAGE_MAXIMUM(8, JOYSTICK_BUTTON_COUNT), /* Button max */
|
||||
HID_RI_LOGICAL_MINIMUM(8, 0x00),
|
||||
HID_RI_LOGICAL_MAXIMUM(8, 0x01),
|
||||
HID_RI_REPORT_COUNT(8, JOYSTICK_BUTTON_COUNT),
|
||||
HID_RI_REPORT_SIZE(8, 0x01),
|
||||
HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE),
|
||||
|
||||
#if (JOYSTICK_BUTTON_COUNT % 8) != 0
|
||||
HID_RI_REPORT_SIZE(8, 0x01),
|
||||
HID_RI_REPORT_COUNT(8, 8 - (JOYSTICK_BUTTON_COUNT % 8)),
|
||||
HID_RI_INPUT(8, HID_IOF_CONSTANT),
|
||||
#endif
|
||||
#if (JOYSTICK_BUTTON_COUNT % 8) != 0
|
||||
HID_RI_REPORT_SIZE(8, 0x01),
|
||||
HID_RI_REPORT_COUNT(8, 8 - (JOYSTICK_BUTTON_COUNT % 8)),
|
||||
HID_RI_INPUT(8, HID_IOF_CONSTANT),
|
||||
#endif
|
||||
#endif
|
||||
HID_RI_END_COLLECTION(0),
|
||||
HID_RI_END_COLLECTION(0),
|
||||
};
|
||||
|
@ -863,7 +870,6 @@ const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor = {
|
|||
},
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* Joystick
|
||||
*/
|
||||
|
@ -902,7 +908,7 @@ const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor = {
|
|||
.EndpointAddress = (ENDPOINT_DIR_IN | JOYSTICK_IN_EPNUM),
|
||||
.Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
|
||||
.EndpointSize = JOYSTICK_EPSIZE,
|
||||
.PollingIntervalMS = 0x0A
|
||||
.PollingIntervalMS = USB_POLLING_INTERVAL_MS
|
||||
},
|
||||
#endif
|
||||
};
|
||||
|
@ -1038,10 +1044,10 @@ uint16_t get_usb_descriptor(const uint16_t wValue, const uint16_t wIndex, const
|
|||
break;
|
||||
#endif
|
||||
#ifdef JOYSTICK_ENABLE
|
||||
case JOYSTICK_INTERFACE:
|
||||
Address = &ConfigurationDescriptor.Joystick_HID;
|
||||
Size = sizeof(USB_HID_Descriptor_HID_t);
|
||||
break;
|
||||
case JOYSTICK_INTERFACE:
|
||||
Address = &ConfigurationDescriptor.Joystick_HID;
|
||||
Size = sizeof(USB_HID_Descriptor_HID_t);
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -1088,10 +1094,10 @@ uint16_t get_usb_descriptor(const uint16_t wValue, const uint16_t wIndex, const
|
|||
break;
|
||||
#endif
|
||||
#ifdef JOYSTICK_ENABLE
|
||||
case JOYSTICK_INTERFACE:
|
||||
Address = &JoystickReport;
|
||||
Size = sizeof(JoystickReport);
|
||||
break;
|
||||
case JOYSTICK_INTERFACE:
|
||||
Address = &JoystickReport;
|
||||
Size = sizeof(JoystickReport);
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -126,9 +126,9 @@ typedef struct {
|
|||
|
||||
#ifdef JOYSTICK_ENABLE
|
||||
// Joystick HID Interface
|
||||
USB_Descriptor_Interface_t Joystick_Interface;
|
||||
USB_HID_Descriptor_HID_t Joystick_HID;
|
||||
USB_Descriptor_Endpoint_t Joystick_INEndpoint;
|
||||
USB_Descriptor_Interface_t Joystick_Interface;
|
||||
USB_HID_Descriptor_HID_t Joystick_HID;
|
||||
USB_Descriptor_Endpoint_t Joystick_INEndpoint;
|
||||
#endif
|
||||
} USB_Descriptor_Configuration_t;
|
||||
|
||||
|
@ -235,7 +235,7 @@ enum usb_endpoints {
|
|||
# define CDC_OUT_EPADDR (ENDPOINT_DIR_OUT | CDC_OUT_EPNUM)
|
||||
#endif
|
||||
#ifdef JOYSTICK_ENABLE
|
||||
JOYSTICK_IN_EPNUM = NEXT_EPNUM,
|
||||
JOYSTICK_IN_EPNUM = NEXT_EPNUM,
|
||||
JOYSTICK_OUT_EPNUM = NEXT_EPNUM,
|
||||
#endif
|
||||
};
|
||||
|
|
|
@ -27,7 +27,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
#include "host_driver.h"
|
||||
#include "vusb.h"
|
||||
#include "joystick.h"
|
||||
#include "joystick.h"
|
||||
#include <util/delay.h>
|
||||
|
||||
static uint8_t vusb_keyboard_leds = 0;
|
||||
|
@ -144,64 +143,67 @@ static void send_consumer(uint16_t data) {
|
|||
typedef struct {
|
||||
uint8_t report_id;
|
||||
|
||||
#if JOYSTICK_AXES_COUNT>0
|
||||
int8_t axes[JOYSTICK_AXES_COUNT];
|
||||
#endif
|
||||
#if JOYSTICK_AXES_COUNT > 0
|
||||
int8_t axes[JOYSTICK_AXES_COUNT];
|
||||
#endif
|
||||
|
||||
#if JOYSTICK_BUTTON_COUNT>0
|
||||
uint8_t buttons[(JOYSTICK_BUTTON_COUNT-1)/8+1];
|
||||
#endif
|
||||
} __attribute__ ((packed)) vusb_joystick_report_t;
|
||||
#if JOYSTICK_BUTTON_COUNT > 0
|
||||
uint8_t buttons[(JOYSTICK_BUTTON_COUNT - 1) / 8 + 1];
|
||||
#endif
|
||||
} __attribute__((packed)) vusb_joystick_report_t;
|
||||
|
||||
void send_joystick_packet(joystick_t* status)
|
||||
{
|
||||
void send_joystick_packet(joystick_t *status) {
|
||||
vusb_joystick_report_t r = {
|
||||
.report_id = REPORT_ID_JOYSTICK,
|
||||
#if JOYSTICK_AXES_COUNT>0
|
||||
.axes = {
|
||||
status->axes[0]
|
||||
#if JOYSTICK_AXES_COUNT > 0
|
||||
.axes = {status->axes[0]
|
||||
|
||||
#if JOYSTICK_AXES_COUNT >= 2
|
||||
,status->axes[1]
|
||||
#endif
|
||||
#if JOYSTICK_AXES_COUNT >= 3
|
||||
,status->axes[2]
|
||||
#endif
|
||||
#if JOYSTICK_AXES_COUNT >= 4
|
||||
,status->axes[3]
|
||||
#endif
|
||||
#if JOYSTICK_AXES_COUNT >= 5
|
||||
,status->axes[4]
|
||||
#endif
|
||||
#if JOYSTICK_AXES_COUNT >= 6
|
||||
,status->axes[5]
|
||||
#endif
|
||||
# if JOYSTICK_AXES_COUNT >= 2
|
||||
,
|
||||
status->axes[1]
|
||||
# endif
|
||||
# if JOYSTICK_AXES_COUNT >= 3
|
||||
,
|
||||
status->axes[2]
|
||||
# endif
|
||||
# if JOYSTICK_AXES_COUNT >= 4
|
||||
,
|
||||
status->axes[3]
|
||||
# endif
|
||||
# if JOYSTICK_AXES_COUNT >= 5
|
||||
,
|
||||
status->axes[4]
|
||||
# endif
|
||||
# if JOYSTICK_AXES_COUNT >= 6
|
||||
,
|
||||
status->axes[5]
|
||||
# endif
|
||||
},
|
||||
#endif //JOYSTICK_AXES_COUNT>0
|
||||
#endif // JOYSTICK_AXES_COUNT>0
|
||||
|
||||
#if JOYSTICK_BUTTON_COUNT>0
|
||||
.buttons = {
|
||||
status->buttons[0]
|
||||
#if JOYSTICK_BUTTON_COUNT > 0
|
||||
.buttons = {status->buttons[0]
|
||||
|
||||
#if JOYSTICK_BUTTON_COUNT>8
|
||||
,status->buttons[1]
|
||||
#endif
|
||||
#if JOYSTICK_BUTTON_COUNT>16
|
||||
,status->buttons[2]
|
||||
#endif
|
||||
#if JOYSTICK_BUTTON_COUNT>24
|
||||
,status->buttons[3]
|
||||
#endif
|
||||
# if JOYSTICK_BUTTON_COUNT > 8
|
||||
,
|
||||
status->buttons[1]
|
||||
# endif
|
||||
# if JOYSTICK_BUTTON_COUNT > 16
|
||||
,
|
||||
status->buttons[2]
|
||||
# endif
|
||||
# if JOYSTICK_BUTTON_COUNT > 24
|
||||
,
|
||||
status->buttons[3]
|
||||
# endif
|
||||
}
|
||||
#endif //JOYSTICK_BUTTON_COUNT>0
|
||||
#endif // JOYSTICK_BUTTON_COUNT>0
|
||||
};
|
||||
if (usbInterruptIsReady3()) {
|
||||
usbSetInterrupt3((void *)&r, sizeof(vusb_joystick_report_t));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*------------------------------------------------------------------*
|
||||
* Request from host *
|
||||
*------------------------------------------------------------------*/
|
||||
|
@ -395,57 +397,58 @@ const PROGMEM uchar mouse_extra_hid_report[] = {
|
|||
0x81, 0x00, // Input (Data, Array, Absolute)
|
||||
0xC0 // End Collection
|
||||
# endif
|
||||
#if JOYSTICK_ENABLE
|
||||
0x05, 0x01, // USAGE_PAGE (Generic Desktop)
|
||||
0x09, 0x04, // USAGE (Joystick)
|
||||
0xa1, 0x01, // COLLECTION (Application)
|
||||
0x85, REPORT_ID_JOYSTICK, // REPORT_ID (6)
|
||||
0x09, 0x01, // USAGE (Pointer)
|
||||
0xa1, 0x00, // COLLECTION (Physical)
|
||||
#if JOYSTICK_AXES_COUNT > 0
|
||||
#if JOYSTICK_AXES_COUNT >= 1
|
||||
0x09, 0x30, // USAGE (X)
|
||||
#endif
|
||||
#if JOYSTICK_AXES_COUNT >= 2
|
||||
0x09, 0x31, // USAGE (Y)
|
||||
#endif
|
||||
#if JOYSTICK_AXES_COUNT >= 3
|
||||
0x09, 0x32, // USAGE (Z)
|
||||
#endif
|
||||
#if JOYSTICK_AXES_COUNT >= 4
|
||||
0x09, 0x33, // USAGE (RX)
|
||||
#endif
|
||||
#if JOYSTICK_AXES_COUNT >= 5
|
||||
0x09, 0x34, // USAGE (RY)
|
||||
#endif
|
||||
#if JOYSTICK_AXES_COUNT >= 6
|
||||
0x09, 0x35, // USAGE (RZ)
|
||||
#endif
|
||||
0x15, 0x81, // LOGICAL_MINIMUM (-127)
|
||||
0x25, 0x7f, // LOGICAL_MAXIMUM (127)
|
||||
0x75, 0x08, // REPORT_SIZE (8)
|
||||
0x95, JOYSTICK_AXES_COUNT, // REPORT_COUNT (JOYSTICK_AXES_COUNT)
|
||||
0x81, 0x02, // INPUT (Data,Var,Abs)
|
||||
#endif
|
||||
#if JOYSTICK_BUTTON_COUNT> 0
|
||||
0x05, 0x09, // USAGE_PAGE (Button)
|
||||
0x19, 0x01, // USAGE_MINIMUM (Button 1)
|
||||
0x29, JOYSTICK_BUTTON_COUNT, // USAGE_MAXIMUM
|
||||
0x15, 0x00, // LOGICAL_MINIMUM (0)
|
||||
0x25, 0x01, // LOGICAL_MAXIMUM (1)
|
||||
0x75, 0x01, // REPORT_SIZE (1)
|
||||
0x95, JOYSTICK_BUTTON_COUNT, // REPORT_COUNT
|
||||
0x81, 0x02, // INPUT (Data,Var,Abs)
|
||||
//fill up report to get it byte-aligned
|
||||
#if (JOYSTICK_BUTTON_COUNT % 8) != 0
|
||||
0x75, 0x01, // REPORT_SIZE (1)
|
||||
0x95, 8 - (JOYSTICK_BUTTON_COUNT % 8), // REPORT_COUNT
|
||||
0x81, 0x01, // INPUT (Data,Var,Abs)
|
||||
#endif
|
||||
#endif
|
||||
0xc0, // END_COLLECTION
|
||||
0xc0 // END_COLLECTION
|
||||
#endif //JOYSTICK_ENABLE
|
||||
# if JOYSTICK_ENABLE
|
||||
0x05,
|
||||
0x01, // USAGE_PAGE (Generic Desktop)
|
||||
0x09, 0x04, // USAGE (Joystick)
|
||||
0xa1, 0x01, // COLLECTION (Application)
|
||||
0x85, REPORT_ID_JOYSTICK, // REPORT_ID (6)
|
||||
0x09, 0x01, // USAGE (Pointer)
|
||||
0xa1, 0x00, // COLLECTION (Physical)
|
||||
# if JOYSTICK_AXES_COUNT > 0
|
||||
# if JOYSTICK_AXES_COUNT >= 1
|
||||
0x09, 0x30, // USAGE (X)
|
||||
# endif
|
||||
# if JOYSTICK_AXES_COUNT >= 2
|
||||
0x09, 0x31, // USAGE (Y)
|
||||
# endif
|
||||
# if JOYSTICK_AXES_COUNT >= 3
|
||||
0x09, 0x32, // USAGE (Z)
|
||||
# endif
|
||||
# if JOYSTICK_AXES_COUNT >= 4
|
||||
0x09, 0x33, // USAGE (RX)
|
||||
# endif
|
||||
# if JOYSTICK_AXES_COUNT >= 5
|
||||
0x09, 0x34, // USAGE (RY)
|
||||
# endif
|
||||
# if JOYSTICK_AXES_COUNT >= 6
|
||||
0x09, 0x35, // USAGE (RZ)
|
||||
# endif
|
||||
0x15, 0x81, // LOGICAL_MINIMUM (-127)
|
||||
0x25, 0x7f, // LOGICAL_MAXIMUM (127)
|
||||
0x75, 0x08, // REPORT_SIZE (8)
|
||||
0x95, JOYSTICK_AXES_COUNT, // REPORT_COUNT (JOYSTICK_AXES_COUNT)
|
||||
0x81, 0x02, // INPUT (Data,Var,Abs)
|
||||
# endif
|
||||
# if JOYSTICK_BUTTON_COUNT > 0
|
||||
0x05, 0x09, // USAGE_PAGE (Button)
|
||||
0x19, 0x01, // USAGE_MINIMUM (Button 1)
|
||||
0x29, JOYSTICK_BUTTON_COUNT, // USAGE_MAXIMUM
|
||||
0x15, 0x00, // LOGICAL_MINIMUM (0)
|
||||
0x25, 0x01, // LOGICAL_MAXIMUM (1)
|
||||
0x75, 0x01, // REPORT_SIZE (1)
|
||||
0x95, JOYSTICK_BUTTON_COUNT, // REPORT_COUNT
|
||||
0x81, 0x02, // INPUT (Data,Var,Abs)
|
||||
// fill up report to get it byte-aligned
|
||||
# if (JOYSTICK_BUTTON_COUNT % 8) != 0
|
||||
0x75, 0x01, // REPORT_SIZE (1)
|
||||
0x95, 8 - (JOYSTICK_BUTTON_COUNT % 8), // REPORT_COUNT
|
||||
0x81, 0x01, // INPUT (Data,Var,Abs)
|
||||
# endif
|
||||
# endif
|
||||
0xc0, // END_COLLECTION
|
||||
0xc0 // END_COLLECTION
|
||||
# endif // JOYSTICK_ENABLE
|
||||
};
|
||||
#endif
|
||||
|
||||
|
@ -468,19 +471,19 @@ const PROGMEM char usbDescriptorConfiguration[] = {
|
|||
/* USB configuration descriptor */
|
||||
9, /* sizeof(usbDescriptorConfiguration): length of descriptor in bytes */
|
||||
USBDESCR_CONFIG, /* descriptor type */
|
||||
# if defined (MOUSE_ENABLE) || defined(EXTRAKEY_ENABLE)
|
||||
59, // 9 + (9 + 9 + 7) + (9 + 9 + 7)
|
||||
#else
|
||||
34, // 9 + (9 + 9 + 7)
|
||||
# if defined(MOUSE_ENABLE) || defined(EXTRAKEY_ENABLE)
|
||||
59, // 9 + (9 + 9 + 7) + (9 + 9 + 7)
|
||||
# else
|
||||
34, // 9 + (9 + 9 + 7)
|
||||
# endif
|
||||
0,
|
||||
// 18 + 7 * USB_CFG_HAVE_INTRIN_ENDPOINT + 7 * USB_CFG_HAVE_INTRIN_ENDPOINT3 + 9, 0,
|
||||
/* total length of data returned (including inlined descriptors) */
|
||||
// 18 + 7 * USB_CFG_HAVE_INTRIN_ENDPOINT + 7 * USB_CFG_HAVE_INTRIN_ENDPOINT3 + 9, 0,
|
||||
/* total length of data returned (including inlined descriptors) */
|
||||
# if defined(MOUSE_ENABLE) || defined(EXTRAKEY_ENABLE)
|
||||
2, /* number of interfaces in this configuration */
|
||||
# else
|
||||
1,
|
||||
#endif
|
||||
# endif
|
||||
1, /* index of this configuration */
|
||||
0, /* configuration name string index */
|
||||
# if USB_CFG_IS_SELF_POWERED
|
||||
|
@ -533,13 +536,13 @@ const PROGMEM char usbDescriptorConfiguration[] = {
|
|||
0, /* PROTOCOL: none */
|
||||
0, /* string index for interface */
|
||||
/* HID descriptor */
|
||||
9, /* sizeof(usbDescrHID): length of descriptor in bytes */
|
||||
USBDESCR_HID, /* descriptor type: HID */
|
||||
0x01, 0x01, /* BCD representation of HID version */
|
||||
0x00, /* target country code */
|
||||
0x01, /* number of HID Report (or other HID class) Descriptor infos to follow */
|
||||
0x22, /* descriptor type: report */
|
||||
sizeof(mouse_extra_hid_report), 0, /* total length of report descriptor */
|
||||
9, /* sizeof(usbDescrHID): length of descriptor in bytes */
|
||||
USBDESCR_HID, /* descriptor type: HID */
|
||||
0x01, 0x01, /* BCD representation of HID version */
|
||||
0x00, /* target country code */
|
||||
0x01, /* number of HID Report (or other HID class) Descriptor infos to follow */
|
||||
0x22, /* descriptor type: report */
|
||||
sizeof(mouse_extra_hid_report), 0, /* total length of report descriptor */
|
||||
# if USB_CFG_HAVE_INTRIN_ENDPOINT3 /* endpoint descriptor for endpoint 3 */
|
||||
/* Endpoint descriptor */
|
||||
7, /* sizeof(usbDescrEndpoint) */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue