aboutsummaryrefslogtreecommitdiff
path: root/tmk_core/protocol/lufa/lufa.c
diff options
context:
space:
mode:
Diffstat (limited to 'tmk_core/protocol/lufa/lufa.c')
-rw-r--r--tmk_core/protocol/lufa/lufa.c92
1 files changed, 48 insertions, 44 deletions
diff --git a/tmk_core/protocol/lufa/lufa.c b/tmk_core/protocol/lufa/lufa.c
index ba49284c9..60cba8d2a 100644
--- a/tmk_core/protocol/lufa/lufa.c
+++ b/tmk_core/protocol/lufa/lufa.c
@@ -67,10 +67,11 @@
67#endif 67#endif
68 68
69#ifdef BLUETOOTH_ENABLE 69#ifdef BLUETOOTH_ENABLE
70 #include "bluetooth.h" 70 #ifdef MODULE_ADAFRUIT_BLE
71#endif
72#ifdef ADAFRUIT_BLE_ENABLE
73 #include "adafruit_ble.h" 71 #include "adafruit_ble.h"
72 #else
73 #include "bluetooth.h"
74 #endif
74#endif 75#endif
75 76
76#ifdef VIRTSER_ENABLE 77#ifdef VIRTSER_ENABLE
@@ -602,18 +603,16 @@ static void send_keyboard(report_keyboard_t *report)
602 uint8_t where = where_to_send(); 603 uint8_t where = where_to_send();
603 604
604#ifdef BLUETOOTH_ENABLE 605#ifdef BLUETOOTH_ENABLE
605 if (where == OUTPUT_BLUETOOTH || where == OUTPUT_USB_AND_BT) { 606 if (where == OUTPUT_BLUETOOTH || where == OUTPUT_USB_AND_BT) {
606 bluefruit_serial_send(0xFD); 607 #ifdef MODULE_ADAFRUIT_BLE
607 for (uint8_t i = 0; i < KEYBOARD_EPSIZE; i++) {
608 bluefruit_serial_send(report->raw[i]);
609 }
610 }
611#endif
612
613#ifdef ADAFRUIT_BLE_ENABLE
614 if (where == OUTPUT_ADAFRUIT_BLE) {
615 adafruit_ble_send_keys(report->mods, report->keys, sizeof(report->keys)); 608 adafruit_ble_send_keys(report->mods, report->keys, sizeof(report->keys));
616 } 609 #else
610 bluefruit_serial_send(0xFD);
611 for (uint8_t i = 0; i < KEYBOARD_EPSIZE; i++) {
612 bluefruit_serial_send(report->raw[i]);
613 }
614 #endif
615 }
617#endif 616#endif
618 617
619 if (where != OUTPUT_USB && where != OUTPUT_USB_AND_BT) { 618 if (where != OUTPUT_USB && where != OUTPUT_USB_AND_BT) {
@@ -660,24 +659,22 @@ static void send_mouse(report_mouse_t *report)
660 uint8_t where = where_to_send(); 659 uint8_t where = where_to_send();
661 660
662#ifdef BLUETOOTH_ENABLE 661#ifdef BLUETOOTH_ENABLE
663 if (where == OUTPUT_BLUETOOTH || where == OUTPUT_USB_AND_BT) { 662 if (where == OUTPUT_BLUETOOTH || where == OUTPUT_USB_AND_BT) {
664 bluefruit_serial_send(0xFD); 663 #ifdef MODULE_ADAFRUIT_BLE
665 bluefruit_serial_send(0x00);
666 bluefruit_serial_send(0x03);
667 bluefruit_serial_send(report->buttons);
668 bluefruit_serial_send(report->x);
669 bluefruit_serial_send(report->y);
670 bluefruit_serial_send(report->v); // should try sending the wheel v here
671 bluefruit_serial_send(report->h); // should try sending the wheel h here
672 bluefruit_serial_send(0x00);
673 }
674#endif
675
676#ifdef ADAFRUIT_BLE_ENABLE
677 if (where == OUTPUT_ADAFRUIT_BLE) {
678 // FIXME: mouse buttons 664 // FIXME: mouse buttons
679 adafruit_ble_send_mouse_move(report->x, report->y, report->v, report->h); 665 adafruit_ble_send_mouse_move(report->x, report->y, report->v, report->h);
680 } 666 #else
667 bluefruit_serial_send(0xFD);
668 bluefruit_serial_send(0x00);
669 bluefruit_serial_send(0x03);
670 bluefruit_serial_send(report->buttons);
671 bluefruit_serial_send(report->x);
672 bluefruit_serial_send(report->y);
673 bluefruit_serial_send(report->v); // should try sending the wheel v here
674 bluefruit_serial_send(report->h); // should try sending the wheel h here
675 bluefruit_serial_send(0x00);
676 #endif
677 }
681#endif 678#endif
682 679
683 if (where != OUTPUT_USB && where != OUTPUT_USB_AND_BT) { 680 if (where != OUTPUT_USB && where != OUTPUT_USB_AND_BT) {
@@ -727,6 +724,9 @@ static void send_consumer(uint16_t data)
727 724
728#ifdef BLUETOOTH_ENABLE 725#ifdef BLUETOOTH_ENABLE
729 if (where == OUTPUT_BLUETOOTH || where == OUTPUT_USB_AND_BT) { 726 if (where == OUTPUT_BLUETOOTH || where == OUTPUT_USB_AND_BT) {
727 #ifdef MODULE_ADAFRUIT_BLE
728 adafruit_ble_send_consumer_key(data, 0);
729 #else
730 static uint16_t last_data = 0; 730 static uint16_t last_data = 0;
731 if (data == last_data) return; 731 if (data == last_data) return;
732 last_data = data; 732 last_data = data;
@@ -740,12 +740,7 @@ static void send_consumer(uint16_t data)
740 bluefruit_serial_send(0x00); 740 bluefruit_serial_send(0x00);
741 bluefruit_serial_send(0x00); 741 bluefruit_serial_send(0x00);
742 bluefruit_serial_send(0x00); 742 bluefruit_serial_send(0x00);
743 } 743 #endif
744#endif
745
746#ifdef ADAFRUIT_BLE_ENABLE
747 if (where == OUTPUT_ADAFRUIT_BLE) {
748 adafruit_ble_send_consumer_key(data, 0);
749 } 744 }
750#endif 745#endif
751 746
@@ -1101,16 +1096,23 @@ void cc_callback(MidiDevice * device,
1101 uint8_t chan, uint8_t num, uint8_t val); 1096 uint8_t chan, uint8_t num, uint8_t val);
1102void sysex_callback(MidiDevice * device, 1097void sysex_callback(MidiDevice * device,
1103 uint16_t start, uint8_t length, uint8_t * data); 1098 uint16_t start, uint8_t length, uint8_t * data);
1099
1100void setup_midi(void)
1101{
1102#ifdef MIDI_ADVANCED
1103 midi_init();
1104#endif
1105 midi_device_init(&midi_device);
1106 midi_device_set_send_func(&midi_device, usb_send_func);
1107 midi_device_set_pre_input_process_func(&midi_device, usb_get_midi);
1108}
1104#endif 1109#endif
1105 1110
1106int main(void) __attribute__ ((weak)); 1111int main(void) __attribute__ ((weak));
1107int main(void) 1112int main(void)
1108{ 1113{
1109
1110#ifdef MIDI_ENABLE 1114#ifdef MIDI_ENABLE
1111 midi_device_init(&midi_device); 1115 setup_midi();
1112 midi_device_set_send_func(&midi_device, usb_send_func);
1113 midi_device_set_pre_input_process_func(&midi_device, usb_get_midi);
1114#endif 1116#endif
1115 1117
1116 setup_mcu(); 1118 setup_mcu();
@@ -1130,7 +1132,7 @@ int main(void)
1130 // midi_send_noteoff(&midi_device, 0, 64, 127); 1132 // midi_send_noteoff(&midi_device, 0, 64, 127);
1131#endif 1133#endif
1132 1134
1133#ifdef BLUETOOTH_ENABLE 1135#ifdef MODULE_ADAFRUIT_EZKEY
1134 serial_init(); 1136 serial_init();
1135#endif 1137#endif
1136 1138
@@ -1161,7 +1163,7 @@ int main(void)
1161 1163
1162 print("Keyboard start.\n"); 1164 print("Keyboard start.\n");
1163 while (1) { 1165 while (1) {
1164 #if !defined(BLUETOOTH_ENABLE) && !defined(ADAFRUIT_BLE_ENABLE) 1166 #if !defined(BLUETOOTH_ENABLE)
1165 while (USB_DeviceState == DEVICE_STATE_Suspended) { 1167 while (USB_DeviceState == DEVICE_STATE_Suspended) {
1166 print("[s]"); 1168 print("[s]");
1167 suspend_power_down(); 1169 suspend_power_down();
@@ -1175,14 +1177,16 @@ int main(void)
1175 1177
1176#ifdef MIDI_ENABLE 1178#ifdef MIDI_ENABLE
1177 midi_device_process(&midi_device); 1179 midi_device_process(&midi_device);
1178 // MIDI_Task(); 1180#ifdef MIDI_ADVANCED
1181 midi_task();
1182#endif
1179#endif 1183#endif
1180 1184
1181#if defined(RGBLIGHT_ANIMATIONS) & defined(RGBLIGHT_ENABLE) 1185#if defined(RGBLIGHT_ANIMATIONS) & defined(RGBLIGHT_ENABLE)
1182 rgblight_task(); 1186 rgblight_task();
1183#endif 1187#endif
1184 1188
1185#ifdef ADAFRUIT_BLE_ENABLE 1189#ifdef MODULE_ADAFRUIT_BLE
1186 adafruit_ble_task(); 1190 adafruit_ble_task();
1187#endif 1191#endif
1188 1192