Merge remote-tracking branch 'origin/develop' into xap

This commit is contained in:
Drashna Jael're
2022-09-29 13:30:12 -07:00
225 changed files with 5934 additions and 1391 deletions
+3 -51
View File
@@ -50,10 +50,6 @@
extern keymap_config_t keymap_config;
#endif
#ifdef JOYSTICK_ENABLE
# include "joystick.h"
#endif
#ifdef XAP_ENABLE
# include "xap.h"
#endif
@@ -1229,59 +1225,15 @@ void virtser_task(void) {
#endif
void send_joystick(report_joystick_t *report) {
#ifdef JOYSTICK_ENABLE
void send_joystick_packet(joystick_t *joystick) {
static joystick_report_t rep;
rep = (joystick_report_t) {
# 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));
osalSysLock();
if (usbGetDriverStateI(&USB_DRIVER) != USB_ACTIVE) {
osalSysUnlock();
return;
}
usbStartTransmitI(&USB_DRIVER, JOYSTICK_IN_EPNUM, (uint8_t *)&rep, sizeof(joystick_report_t));
usbStartTransmitI(&USB_DRIVER, JOYSTICK_IN_EPNUM, (uint8_t *)report, sizeof(report_joystick_t));
osalSysUnlock();
}
#endif
}
+60 -21
View File
@@ -24,13 +24,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "debug.h"
#include "digitizer.h"
#ifdef JOYSTICK_ENABLE
# include "joystick.h"
#endif
#ifdef BLUETOOTH_ENABLE
# include "bluetooth.h"
# include "outputselect.h"
# ifdef BLUETOOTH_BLUEFRUIT_LE
# include "bluefruit_le.h"
# elif BLUETOOTH_RN42
# include "rn42.h"
# endif
#endif
#ifdef NKRO_ENABLE
@@ -74,11 +74,7 @@ led_t host_keyboard_led_state(void) {
void host_keyboard_send(report_keyboard_t *report) {
#ifdef BLUETOOTH_ENABLE
if (where_to_send() == OUTPUT_BLUETOOTH) {
# ifdef BLUETOOTH_BLUEFRUIT_LE
bluefruit_le_send_keys(report->mods, report->keys, sizeof(report->keys));
# elif BLUETOOTH_RN42
rn42_send_keyboard(report);
# endif
bluetooth_send_keyboard(report);
return;
}
#endif
@@ -112,12 +108,7 @@ void host_keyboard_send(report_keyboard_t *report) {
void host_mouse_send(report_mouse_t *report) {
#ifdef BLUETOOTH_ENABLE
if (where_to_send() == OUTPUT_BLUETOOTH) {
# ifdef BLUETOOTH_BLUEFRUIT_LE
// FIXME: mouse buttons
bluefruit_le_send_mouse_move(report->x, report->y, report->v, report->h, report->buttons);
# elif BLUETOOTH_RN42
rn42_send_mouse(report);
# endif
bluetooth_send_mouse(report);
return;
}
#endif
@@ -148,11 +139,7 @@ void host_consumer_send(uint16_t report) {
#ifdef BLUETOOTH_ENABLE
if (where_to_send() == OUTPUT_BLUETOOTH) {
# ifdef BLUETOOTH_BLUEFRUIT_LE
bluefruit_le_send_consumer_key(report);
# elif BLUETOOTH_RN42
rn42_send_consumer(report);
# endif
bluetooth_send_consumer(report);
return;
}
#endif
@@ -161,6 +148,58 @@ void host_consumer_send(uint16_t report) {
(*driver->send_extra)(REPORT_ID_CONSUMER, report);
}
#ifdef JOYSTICK_ENABLE
void host_joystick_send(joystick_t *joystick) {
if (!driver) return;
report_joystick_t report = {
# 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
# 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
};
send_joystick(&report);
}
#endif
__attribute__((weak)) void send_joystick(report_joystick_t *report) {}
void host_digitizer_send(digitizer_t *digitizer) {
if (!driver) return;
+1
View File
@@ -31,4 +31,5 @@ typedef struct {
void (*send_programmable_button)(uint32_t);
} host_driver_t;
void send_joystick(report_joystick_t *report);
void send_digitizer(report_digitizer_t *report);
+3 -48
View File
@@ -81,10 +81,6 @@ extern keymap_config_t keymap_config;
# include "xap.h"
#endif
#ifdef JOYSTICK_ENABLE
# include "joystick.h"
#endif
uint8_t keyboard_idle = 0;
/* 0: Boot Protocol, 1: Report Protocol(default) */
uint8_t keyboard_protocol = 1;
@@ -364,51 +360,10 @@ static void Console_Task(void) {
/*******************************************************************************
* Joystick
******************************************************************************/
void send_joystick(report_joystick_t *report) {
#ifdef JOYSTICK_ENABLE
void send_joystick_packet(joystick_t *joystick) {
uint8_t timeout = 255;
static joystick_report_t r;
r = (joystick_report_t) {
# 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
};
/* Select the Joystick Report Endpoint */
Endpoint_SelectEndpoint(JOYSTICK_IN_EPNUM);
@@ -418,12 +373,12 @@ void send_joystick_packet(joystick_t *joystick) {
if (!Endpoint_IsReadWriteAllowed()) return;
/* Write Joystick Report Data */
Endpoint_Write_Stream_LE(&r, sizeof(joystick_report_t), NULL);
Endpoint_Write_Stream_LE(report, sizeof(report_joystick_t), NULL);
/* Finalize the stream transfer to send the last packet */
Endpoint_ClearIN();
}
#endif
}
/*******************************************************************************
* USB Events
+1 -1
View File
@@ -245,7 +245,7 @@ typedef struct {
#if JOYSTICK_BUTTON_COUNT > 0
uint8_t buttons[(JOYSTICK_BUTTON_COUNT - 1) / 8 + 1];
#endif
} __attribute__((packed)) joystick_report_t;
} __attribute__((packed)) report_joystick_t;
/* keycode to system usage */
static inline uint16_t KEYCODE2SYSTEM(uint8_t key) {