Remerge 0.16.x' into firmware21
This commit is contained in:
@@ -67,10 +67,10 @@ extern keymap_config_t keymap_config;
|
||||
|
||||
#ifdef BLUETOOTH_ENABLE
|
||||
# include "outputselect.h"
|
||||
# ifdef MODULE_ADAFRUIT_BLE
|
||||
# include "adafruit_ble.h"
|
||||
# else
|
||||
# include "../serial.h"
|
||||
# ifdef BLUETOOTH_BLUEFRUIT_LE
|
||||
# include "bluefruit_le.h"
|
||||
# elif BLUETOOTH_RN42
|
||||
# include "rn42.h"
|
||||
# endif
|
||||
#endif
|
||||
|
||||
@@ -93,46 +93,6 @@ extern keymap_config_t keymap_config;
|
||||
# include "joystick.h"
|
||||
#endif
|
||||
|
||||
// https://cdn.sparkfun.com/datasheets/Wireless/Bluetooth/bluetooth_cr_UG-v1.0r.pdf#G7.663734
|
||||
static inline uint16_t CONSUMER2RN42(uint16_t usage) {
|
||||
switch (usage) {
|
||||
case AC_HOME:
|
||||
return 0x0001;
|
||||
case AL_EMAIL:
|
||||
return 0x0002;
|
||||
case AC_SEARCH:
|
||||
return 0x0004;
|
||||
case AL_KEYBOARD_LAYOUT:
|
||||
return 0x0008;
|
||||
case AUDIO_VOL_UP:
|
||||
return 0x0010;
|
||||
case AUDIO_VOL_DOWN:
|
||||
return 0x0020;
|
||||
case AUDIO_MUTE:
|
||||
return 0x0040;
|
||||
case TRANSPORT_PLAY_PAUSE:
|
||||
return 0x0080;
|
||||
case TRANSPORT_NEXT_TRACK:
|
||||
return 0x0100;
|
||||
case TRANSPORT_PREV_TRACK:
|
||||
return 0x0200;
|
||||
case TRANSPORT_STOP:
|
||||
return 0x0400;
|
||||
case TRANSPORT_EJECT:
|
||||
return 0x0800;
|
||||
case TRANSPORT_FAST_FORWARD:
|
||||
return 0x1000;
|
||||
case TRANSPORT_REWIND:
|
||||
return 0x2000;
|
||||
case TRANSPORT_STOP_EJECT:
|
||||
return 0x4000;
|
||||
case AL_LOCAL_BROWSER:
|
||||
return 0x8000;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t keyboard_idle = 0;
|
||||
/* 0: Boot Protocol, 1: Report Protocol(default) */
|
||||
uint8_t keyboard_protocol = 1;
|
||||
@@ -299,7 +259,8 @@ static void Console_Task(void) {
|
||||
}
|
||||
|
||||
// fill empty bank
|
||||
while (Endpoint_IsReadWriteAllowed()) Endpoint_Write_8(0);
|
||||
while (Endpoint_IsReadWriteAllowed())
|
||||
Endpoint_Write_8(0);
|
||||
|
||||
// flush sendchar packet
|
||||
if (Endpoint_IsINReady()) {
|
||||
@@ -399,7 +360,7 @@ void send_joystick_packet(joystick_t *joystick) {
|
||||
joystick->axes[5],
|
||||
# endif
|
||||
},
|
||||
# endif // JOYSTICK_AXES_COUNT>0
|
||||
# endif // JOYSTICK_AXES_COUNT>0
|
||||
|
||||
# if JOYSTICK_BUTTON_COUNT > 0
|
||||
.buttons = {
|
||||
@@ -415,14 +376,15 @@ void send_joystick_packet(joystick_t *joystick) {
|
||||
joystick->buttons[3],
|
||||
# endif
|
||||
}
|
||||
# endif // JOYSTICK_BUTTON_COUNT>0
|
||||
# endif // JOYSTICK_BUTTON_COUNT>0
|
||||
};
|
||||
|
||||
/* Select the Joystick Report Endpoint */
|
||||
Endpoint_SelectEndpoint(JOYSTICK_IN_EPNUM);
|
||||
|
||||
/* Check if write ready for a polling interval around 10ms */
|
||||
while (timeout-- && !Endpoint_IsReadWriteAllowed()) _delay_us(40);
|
||||
while (timeout-- && !Endpoint_IsReadWriteAllowed())
|
||||
_delay_us(40);
|
||||
if (!Endpoint_IsReadWriteAllowed()) return;
|
||||
|
||||
/* Write Joystick Report Data */
|
||||
@@ -517,9 +479,11 @@ void EVENT_USB_Device_WakeUp() {
|
||||
|
||||
#ifdef CONSOLE_ENABLE
|
||||
static bool console_flush = false;
|
||||
# define CONSOLE_FLUSH_SET(b) \
|
||||
do { \
|
||||
ATOMIC_BLOCK(ATOMIC_RESTORESTATE) { console_flush = b; } \
|
||||
# define CONSOLE_FLUSH_SET(b) \
|
||||
do { \
|
||||
ATOMIC_BLOCK(ATOMIC_RESTORESTATE) { \
|
||||
console_flush = b; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
/** \brief Event USB Device Start Of Frame
|
||||
@@ -785,7 +749,9 @@ void EVENT_USB_Device_ControlRequest(void) {
|
||||
*
|
||||
* FIXME: Needs doc
|
||||
*/
|
||||
static uint8_t keyboard_leds(void) { return keyboard_led_state; }
|
||||
static uint8_t keyboard_leds(void) {
|
||||
return keyboard_led_state;
|
||||
}
|
||||
|
||||
/** \brief Send Keyboard
|
||||
*
|
||||
@@ -796,17 +762,10 @@ static void send_keyboard(report_keyboard_t *report) {
|
||||
|
||||
#ifdef BLUETOOTH_ENABLE
|
||||
if (where_to_send() == OUTPUT_BLUETOOTH) {
|
||||
# ifdef MODULE_ADAFRUIT_BLE
|
||||
adafruit_ble_send_keys(report->mods, report->keys, sizeof(report->keys));
|
||||
# elif MODULE_RN42
|
||||
serial_send(0xFD);
|
||||
serial_send(0x09);
|
||||
serial_send(0x01);
|
||||
serial_send(report->mods);
|
||||
serial_send(report->reserved);
|
||||
for (uint8_t i = 0; i < KEYBOARD_REPORT_KEYS; i++) {
|
||||
serial_send(report->keys[i]);
|
||||
}
|
||||
# ifdef BLUETOOTH_BLUEFRUIT_LE
|
||||
bluefruit_le_send_keys(report->mods, report->keys, sizeof(report->keys));
|
||||
# elif BLUETOOTH_RN42
|
||||
rn42_send_keyboard(report);
|
||||
# endif
|
||||
return;
|
||||
}
|
||||
@@ -823,7 +782,8 @@ static void send_keyboard(report_keyboard_t *report) {
|
||||
#endif
|
||||
Endpoint_SelectEndpoint(ep);
|
||||
/* Check if write ready for a polling interval around 10ms */
|
||||
while (timeout-- && !Endpoint_IsReadWriteAllowed()) _delay_us(40);
|
||||
while (timeout-- && !Endpoint_IsReadWriteAllowed())
|
||||
_delay_us(40);
|
||||
if (!Endpoint_IsReadWriteAllowed()) return;
|
||||
|
||||
/* If we're in Boot Protocol, don't send any report ID or other funky fields */
|
||||
@@ -849,19 +809,11 @@ static void send_mouse(report_mouse_t *report) {
|
||||
|
||||
# ifdef BLUETOOTH_ENABLE
|
||||
if (where_to_send() == OUTPUT_BLUETOOTH) {
|
||||
# ifdef MODULE_ADAFRUIT_BLE
|
||||
# ifdef BLUETOOTH_BLUEFRUIT_LE
|
||||
// FIXME: mouse buttons
|
||||
adafruit_ble_send_mouse_move(report->x, report->y, report->v, report->h, report->buttons);
|
||||
# else
|
||||
serial_send(0xFD);
|
||||
serial_send(0x00);
|
||||
serial_send(0x03);
|
||||
serial_send(report->buttons);
|
||||
serial_send(report->x);
|
||||
serial_send(report->y);
|
||||
serial_send(report->v); // should try sending the wheel v here
|
||||
serial_send(report->h); // should try sending the wheel h here
|
||||
serial_send(0x00);
|
||||
bluefruit_le_send_mouse_move(report->x, report->y, report->v, report->h, report->buttons);
|
||||
# elif BLUETOOTH_RN42
|
||||
rn42_send_mouse(report);
|
||||
# endif
|
||||
return;
|
||||
}
|
||||
@@ -871,7 +823,8 @@ static void send_mouse(report_mouse_t *report) {
|
||||
Endpoint_SelectEndpoint(MOUSE_IN_EPNUM);
|
||||
|
||||
/* Check if write ready for a polling interval around 10ms */
|
||||
while (timeout-- && !Endpoint_IsReadWriteAllowed()) _delay_us(40);
|
||||
while (timeout-- && !Endpoint_IsReadWriteAllowed())
|
||||
_delay_us(40);
|
||||
if (!Endpoint_IsReadWriteAllowed()) return;
|
||||
|
||||
/* Write Mouse Report Data */
|
||||
@@ -891,7 +844,8 @@ static void send_report(void *report, size_t size) {
|
||||
Endpoint_SelectEndpoint(SHARED_IN_EPNUM);
|
||||
|
||||
/* Check if write ready for a polling interval around 10ms */
|
||||
while (timeout-- && !Endpoint_IsReadWriteAllowed()) _delay_us(40);
|
||||
while (timeout-- && !Endpoint_IsReadWriteAllowed())
|
||||
_delay_us(40);
|
||||
if (!Endpoint_IsReadWriteAllowed()) return;
|
||||
|
||||
Endpoint_Write_Stream_LE(report, size, NULL);
|
||||
@@ -934,6 +888,7 @@ static void send_consumer(uint16_t data) {
|
||||
if (where == OUTPUT_BLUETOOTH || where == OUTPUT_USB_AND_BT) {
|
||||
=======
|
||||
if (where_to_send() == OUTPUT_BLUETOOTH) {
|
||||
<<<<<<< HEAD
|
||||
>>>>>>> 0.12.52~1
|
||||
# ifdef MODULE_ADAFRUIT_BLE
|
||||
adafruit_ble_send_consumer_key(data);
|
||||
@@ -947,6 +902,12 @@ static void send_consumer(uint16_t data) {
|
||||
serial_send(0x03);
|
||||
serial_send(bitmap & 0xFF);
|
||||
serial_send((bitmap >> 8) & 0xFF);
|
||||
=======
|
||||
# ifdef BLUETOOTH_BLUEFRUIT_LE
|
||||
bluefruit_le_send_consumer_key(data);
|
||||
# elif BLUETOOTH_RN42
|
||||
rn42_send_consumer(data);
|
||||
>>>>>>> qmk/master
|
||||
# endif
|
||||
<<<<<<< HEAD
|
||||
}
|
||||
@@ -1066,9 +1027,13 @@ USB_ClassInfo_MIDI_Device_t USB_MIDI_Interface = {
|
||||
|
||||
// clang-format on
|
||||
|
||||
void send_midi_packet(MIDI_EventPacket_t *event) { MIDI_Device_SendEventPacket(&USB_MIDI_Interface, event); }
|
||||
void send_midi_packet(MIDI_EventPacket_t *event) {
|
||||
MIDI_Device_SendEventPacket(&USB_MIDI_Interface, event);
|
||||
}
|
||||
|
||||
bool recv_midi_packet(MIDI_EventPacket_t *const event) { return MIDI_Device_ReceiveEventPacket(&USB_MIDI_Interface, event); }
|
||||
bool recv_midi_packet(MIDI_EventPacket_t *const event) {
|
||||
return MIDI_Device_ReceiveEventPacket(&USB_MIDI_Interface, event);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1124,7 +1089,8 @@ void virtser_send(const uint8_t byte) {
|
||||
return;
|
||||
}
|
||||
|
||||
while (timeout-- && !Endpoint_IsReadWriteAllowed()) _delay_us(40);
|
||||
while (timeout-- && !Endpoint_IsReadWriteAllowed())
|
||||
_delay_us(40);
|
||||
|
||||
Endpoint_Write_8(byte);
|
||||
CDC_Device_Flush(&cdc_device);
|
||||
@@ -1147,7 +1113,8 @@ void send_digitizer(report_digitizer_t *report) {
|
||||
Endpoint_SelectEndpoint(DIGITIZER_IN_EPNUM);
|
||||
|
||||
/* Check if write ready for a polling interval around 10ms */
|
||||
while (timeout-- && !Endpoint_IsReadWriteAllowed()) _delay_us(40);
|
||||
while (timeout-- && !Endpoint_IsReadWriteAllowed())
|
||||
_delay_us(40);
|
||||
if (!Endpoint_IsReadWriteAllowed()) return;
|
||||
|
||||
Endpoint_Write_Stream_LE(report, sizeof(report_digitizer_t), NULL);
|
||||
@@ -1203,8 +1170,8 @@ void protocol_pre_init(void) {
|
||||
setup_usb();
|
||||
sei();
|
||||
|
||||
#if defined(MODULE_RN42)
|
||||
serial_init();
|
||||
#if defined(BLUETOOTH_RN42)
|
||||
rn42_init();
|
||||
#endif
|
||||
|
||||
/* wait for USB startup & debug output */
|
||||
@@ -1223,7 +1190,9 @@ void protocol_pre_init(void) {
|
||||
#endif
|
||||
}
|
||||
|
||||
void protocol_post_init(void) { host_set_driver(&lufa_driver); }
|
||||
void protocol_post_init(void) {
|
||||
host_set_driver(&lufa_driver);
|
||||
}
|
||||
|
||||
void protocol_pre_task(void) {
|
||||
#if !defined(NO_USB_STARTUP_CHECK)
|
||||
@@ -1256,8 +1225,8 @@ void protocol_post_task(void) {
|
||||
MIDI_Device_USBTask(&USB_MIDI_Interface);
|
||||
#endif
|
||||
|
||||
#ifdef MODULE_ADAFRUIT_BLE
|
||||
adafruit_ble_task();
|
||||
#ifdef BLUETOOTH_BLUEFRUIT_LE
|
||||
bluefruit_le_task();
|
||||
#endif
|
||||
|
||||
#ifdef VIRTSER_ENABLE
|
||||
@@ -1278,4 +1247,6 @@ void protocol_post_task(void) {
|
||||
#endif
|
||||
}
|
||||
|
||||
uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, const uint16_t wIndex, const void **const DescriptorAddress) { return get_usb_descriptor(wValue, wIndex, DescriptorAddress); }
|
||||
uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, const uint16_t wIndex, const void **const DescriptorAddress) {
|
||||
return get_usb_descriptor(wValue, wIndex, DescriptorAddress);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user