From ff8d8a50dfbb8502003a5181878c54a71b8c57d5 Mon Sep 17 00:00:00 2001 From: Jack Humbert Date: Sun, 25 Oct 2015 21:40:56 -0400 Subject: fixes for bluetooth without usb --- keyboard/planck/keymap_common.h | 68 ------------------------------ keyboard/planck/keymap_french.h | 2 +- keyboard/planck/keymap_nordic.h | 4 +- keyboard/planck/keymap_spanish.h | 4 +- protocol/lufa/lufa.c | 91 +++++++++++++++++++++------------------- 5 files changed, 52 insertions(+), 117 deletions(-) diff --git a/keyboard/planck/keymap_common.h b/keyboard/planck/keymap_common.h index 73df8424a5..21908a2be3 100644 --- a/keyboard/planck/keymap_common.h +++ b/keyboard/planck/keymap_common.h @@ -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) diff --git a/keyboard/planck/keymap_french.h b/keyboard/planck/keymap_french.h index 71c8033c2a..ccfaed8f07 100644 --- a/keyboard/planck/keymap_french.h +++ b/keyboard/planck/keymap_french.h @@ -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 diff --git a/keyboard/planck/keymap_nordic.h b/keyboard/planck/keymap_nordic.h index 56ae8b63bd..02a704216a 100644 --- a/keyboard/planck/keymap_nordic.h +++ b/keyboard/planck/keymap_nordic.h @@ -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) diff --git a/keyboard/planck/keymap_spanish.h b/keyboard/planck/keymap_spanish.h index 50bcb999b1..7f980afbcf 100644 --- a/keyboard/planck/keymap_spanish.h +++ b/keyboard/planck/keymap_spanish.h @@ -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) diff --git a/protocol/lufa/lufa.c b/protocol/lufa/lufa.c index e5267fead6..c9504483af 100644 --- a/protocol/lufa/lufa.c +++ b/protocol/lufa/lufa.c @@ -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); -- cgit v1.2.3