fixes for bluetooth without usb
This commit is contained in:
parent
61fea81a24
commit
ff8d8a50df
@ -78,74 +78,6 @@ extern const uint16_t fn_actions[];
|
||||
#define S(kc) LSFT(kc)
|
||||
#define F(kc) FUNC(kc)
|
||||
|
||||
// For software implementation of colemak
|
||||
#define CM_Q KC_Q
|
||||
#define CM_W KC_W
|
||||
#define CM_F KC_E
|
||||
#define CM_P KC_R
|
||||
#define CM_G KC_T
|
||||
#define CM_J KC_Y
|
||||
#define CM_L KC_U
|
||||
#define CM_U KC_I
|
||||
#define CM_Y KC_O
|
||||
#define CM_SCLN KC_P
|
||||
|
||||
#define CM_A KC_A
|
||||
#define CM_R KC_S
|
||||
#define CM_S KC_D
|
||||
#define CM_T KC_F
|
||||
#define CM_D KC_G
|
||||
#define CM_H KC_H
|
||||
#define CM_N KC_J
|
||||
#define CM_E KC_K
|
||||
#define CM_I KC_L
|
||||
#define CM_O KC_SCLN
|
||||
|
||||
#define CM_Z KC_Z
|
||||
#define CM_X KC_X
|
||||
#define CM_C KC_C
|
||||
#define CM_V KC_V
|
||||
#define CM_B KC_B
|
||||
#define CM_K KC_N
|
||||
#define CM_M KC_M
|
||||
#define CM_COMM KC_COMM
|
||||
#define CM_DOT KC_DOT
|
||||
#define CM_SLSH KC_SLSH
|
||||
|
||||
// Make it easy to support these in macros
|
||||
#define KC_CM_Q CM_Q
|
||||
#define KC_CM_W CM_W
|
||||
#define KC_CM_F CM_F
|
||||
#define KC_CM_P CM_P
|
||||
#define KC_CM_G CM_G
|
||||
#define KC_CM_J CM_J
|
||||
#define KC_CM_L CM_L
|
||||
#define KC_CM_U CM_U
|
||||
#define KC_CM_Y CM_Y
|
||||
#define KC_CM_SCLN CM_SCLN
|
||||
|
||||
#define KC_CM_A CM_A
|
||||
#define KC_CM_R CM_R
|
||||
#define KC_CM_S CM_S
|
||||
#define KC_CM_T CM_T
|
||||
#define KC_CM_D CM_D
|
||||
#define KC_CM_H CM_H
|
||||
#define KC_CM_N CM_N
|
||||
#define KC_CM_E CM_E
|
||||
#define KC_CM_I CM_I
|
||||
#define KC_CM_O CM_O
|
||||
|
||||
#define KC_CM_Z CM_Z
|
||||
#define KC_CM_X CM_X
|
||||
#define KC_CM_C CM_C
|
||||
#define KC_CM_V CM_V
|
||||
#define KC_CM_B CM_B
|
||||
#define KC_CM_K CM_K
|
||||
#define KC_CM_M CM_M
|
||||
#define KC_CM_COMM CM_COMM
|
||||
#define KC_CM_DOT CM_DOT
|
||||
#define KC_CM_SLSH CM_SLSH
|
||||
|
||||
#define M(kc) kc | 0x3000
|
||||
|
||||
#define MACRODOWN(...) (record->event.pressed ? MACRO(__VA_ARGS__) : MACRO_NONE)
|
||||
|
@ -14,7 +14,7 @@
|
||||
#define FR_QUOT KC_3
|
||||
#define FR_APOS KC_4
|
||||
#define FR_LPRN KC_5
|
||||
#define FR_DASH KC_6
|
||||
#define FR_MINS KC_6
|
||||
#define FR_EGRV KC_7
|
||||
#define FR_UNDS KC_8
|
||||
#define FR_CCED KC_9
|
||||
|
@ -19,7 +19,7 @@
|
||||
#define NO_APOS KC_NUHS
|
||||
|
||||
#define NO_LESS KC_NUBS
|
||||
#define NO_DASH KC_SLSH
|
||||
#define NO_MINS KC_SLSH
|
||||
|
||||
// Shifted characters
|
||||
#define NO_SECT LSFT(NO_HALF)
|
||||
@ -38,7 +38,7 @@
|
||||
#define NO_GRTR LSFT(NO_LESS)
|
||||
#define NO_SCLN LSFT(KC_COMM)
|
||||
#define NO_COLN LSFT(KC_DOT)
|
||||
#define NO_UNDS LSFT(NO_DASH)
|
||||
#define NO_UNDS LSFT(NO_MINS)
|
||||
|
||||
// Alt Gr-ed characters
|
||||
#define NO_AT ALGR(KC_2)
|
||||
|
@ -20,7 +20,7 @@
|
||||
#define ES_CCED KC_NUHS
|
||||
|
||||
#define ES_LESS KC_NUBS
|
||||
#define ES_DASH KC_SLSH
|
||||
#define ES_MINS KC_SLSH
|
||||
|
||||
// Shifted characters
|
||||
#define ES_ASML LSFT(ES_OVRR)
|
||||
@ -42,7 +42,7 @@
|
||||
#define ES_GRTR LSFT(ES_LESS)
|
||||
#define ES_SCLN LSFT(ES_COMM)
|
||||
#define ES_COLN LSFT(ES_DOT)
|
||||
#define ES_UNDS LSFT(ES_DASH)
|
||||
#define ES_UNDS LSFT(ES_MINS)
|
||||
|
||||
// Alt Gr-ed characters
|
||||
#define ES_BSLS ALGR(ES_OVRR)
|
||||
|
@ -445,6 +445,14 @@ static uint8_t keyboard_leds(void)
|
||||
|
||||
static void send_keyboard(report_keyboard_t *report)
|
||||
{
|
||||
|
||||
#ifdef BLUETOOTH_ENABLE
|
||||
bluefruit_serial_send(0xFD);
|
||||
for (uint8_t i = 0; i < KEYBOARD_EPSIZE; i++) {
|
||||
bluefruit_serial_send(report->raw[i]);
|
||||
}
|
||||
#endif
|
||||
|
||||
uint8_t timeout = 255;
|
||||
|
||||
if (USB_DeviceState != DEVICE_STATE_Configured)
|
||||
@ -482,17 +490,24 @@ static void send_keyboard(report_keyboard_t *report)
|
||||
|
||||
keyboard_report_sent = *report;
|
||||
|
||||
#ifdef BLUETOOTH_ENABLE
|
||||
bluefruit_serial_send(0xFD);
|
||||
for (uint8_t i = 0; i < KEYBOARD_EPSIZE; i++) {
|
||||
bluefruit_serial_send(report->raw[i]);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
static void send_mouse(report_mouse_t *report)
|
||||
{
|
||||
#ifdef MOUSE_ENABLE
|
||||
|
||||
#ifdef BLUETOOTH_ENABLE
|
||||
bluefruit_serial_send(0xFD);
|
||||
bluefruit_serial_send(0x00);
|
||||
bluefruit_serial_send(0x03);
|
||||
bluefruit_serial_send(report->buttons);
|
||||
bluefruit_serial_send(report->x);
|
||||
bluefruit_serial_send(report->y);
|
||||
bluefruit_serial_send(report->v); // should try sending the wheel v here
|
||||
bluefruit_serial_send(report->h); // should try sending the wheel h here
|
||||
bluefruit_serial_send(0x00);
|
||||
#endif
|
||||
|
||||
uint8_t timeout = 255;
|
||||
|
||||
if (USB_DeviceState != DEVICE_STATE_Configured)
|
||||
@ -511,19 +526,6 @@ static void send_mouse(report_mouse_t *report)
|
||||
/* Finalize the stream transfer to send the last packet */
|
||||
Endpoint_ClearIN();
|
||||
|
||||
|
||||
#ifdef BLUETOOTH_ENABLE
|
||||
bluefruit_serial_send(0xFD);
|
||||
bluefruit_serial_send(0x00);
|
||||
bluefruit_serial_send(0x03);
|
||||
bluefruit_serial_send(report->buttons);
|
||||
bluefruit_serial_send(report->x);
|
||||
bluefruit_serial_send(report->y);
|
||||
bluefruit_serial_send(report->v); // should try sending the wheel v here
|
||||
bluefruit_serial_send(report->h); // should try sending the wheel h here
|
||||
bluefruit_serial_send(0x00);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -550,6 +552,23 @@ static void send_system(uint16_t data)
|
||||
|
||||
static void send_consumer(uint16_t data)
|
||||
{
|
||||
|
||||
#ifdef BLUETOOTH_ENABLE
|
||||
static uint16_t last_data = 0;
|
||||
if (data == last_data) return;
|
||||
last_data = data;
|
||||
uint16_t bitmap = CONSUMER2BLUEFRUIT(data);
|
||||
bluefruit_serial_send(0xFD);
|
||||
bluefruit_serial_send(0x00);
|
||||
bluefruit_serial_send(0x02);
|
||||
bluefruit_serial_send((bitmap>>8)&0xFF);
|
||||
bluefruit_serial_send(bitmap&0xFF);
|
||||
bluefruit_serial_send(0x00);
|
||||
bluefruit_serial_send(0x00);
|
||||
bluefruit_serial_send(0x00);
|
||||
bluefruit_serial_send(0x00);
|
||||
#endif
|
||||
|
||||
uint8_t timeout = 255;
|
||||
|
||||
if (USB_DeviceState != DEVICE_STATE_Configured)
|
||||
@ -568,21 +587,6 @@ static void send_consumer(uint16_t data)
|
||||
Endpoint_Write_Stream_LE(&r, sizeof(report_extra_t), NULL);
|
||||
Endpoint_ClearIN();
|
||||
|
||||
#ifdef BLUETOOTH_ENABLE
|
||||
static uint16_t last_data = 0;
|
||||
if (data == last_data) return;
|
||||
last_data = data;
|
||||
uint16_t bitmap = CONSUMER2BLUEFRUIT(data);
|
||||
bluefruit_serial_send(0xFD);
|
||||
bluefruit_serial_send(0x00);
|
||||
bluefruit_serial_send(0x02);
|
||||
bluefruit_serial_send((bitmap>>8)&0xFF);
|
||||
bluefruit_serial_send(bitmap&0xFF);
|
||||
bluefruit_serial_send(0x00);
|
||||
bluefruit_serial_send(0x00);
|
||||
bluefruit_serial_send(0x00);
|
||||
bluefruit_serial_send(0x00);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
@ -881,19 +885,18 @@ int main(void)
|
||||
#endif
|
||||
|
||||
#ifdef BLUETOOTH_ENABLE
|
||||
print_set_sendchar(sendchar);
|
||||
serial_init();
|
||||
#endif
|
||||
|
||||
|
||||
/* wait for USB startup & debug output */
|
||||
while (USB_DeviceState != DEVICE_STATE_Configured) {
|
||||
// while (USB_DeviceState != DEVICE_STATE_Configured) {
|
||||
// #if defined(INTERRUPT_CONTROL_ENDPOINT)
|
||||
// ;
|
||||
// #else
|
||||
USB_USBTask();
|
||||
// #endif
|
||||
}
|
||||
// }
|
||||
print("USB configured.\n");
|
||||
|
||||
/* init modules */
|
||||
@ -905,13 +908,13 @@ int main(void)
|
||||
|
||||
print("Keyboard start.\n");
|
||||
while (1) {
|
||||
while (USB_DeviceState == DEVICE_STATE_Suspended) {
|
||||
print("[s]");
|
||||
suspend_power_down();
|
||||
if (USB_Device_RemoteWakeupEnabled && suspend_wakeup_condition()) {
|
||||
USB_Device_SendRemoteWakeup();
|
||||
}
|
||||
}
|
||||
// while (USB_DeviceState == DEVICE_STATE_Suspended) {
|
||||
// print("[s]");
|
||||
// suspend_power_down();
|
||||
// if (USB_Device_RemoteWakeupEnabled && suspend_wakeup_condition()) {
|
||||
// USB_Device_SendRemoteWakeup();
|
||||
// }
|
||||
// }
|
||||
|
||||
#ifdef MIDI_ENABLE
|
||||
midi_device_process(&midi_device);
|
||||
|
Loading…
Reference in New Issue
Block a user