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:
Nick Brassel 2020-01-10 06:29:34 +11:00 committed by a-chol
parent d88bdc6a1b
commit 801be60473
18 changed files with 455 additions and 458 deletions

View file

@ -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