diff options
Diffstat (limited to 'protocol/lufa/lufa.c')
| -rw-r--r-- | protocol/lufa/lufa.c | 91 |
1 files changed, 47 insertions, 44 deletions
diff --git a/protocol/lufa/lufa.c b/protocol/lufa/lufa.c index e5267fead..c9504483a 100644 --- a/protocol/lufa/lufa.c +++ b/protocol/lufa/lufa.c | |||
| @@ -445,6 +445,14 @@ static uint8_t keyboard_leds(void) | |||
| 445 | 445 | ||
| 446 | static void send_keyboard(report_keyboard_t *report) | 446 | static void send_keyboard(report_keyboard_t *report) |
| 447 | { | 447 | { |
| 448 | |||
| 449 | #ifdef BLUETOOTH_ENABLE | ||
| 450 | bluefruit_serial_send(0xFD); | ||
| 451 | for (uint8_t i = 0; i < KEYBOARD_EPSIZE; i++) { | ||
| 452 | bluefruit_serial_send(report->raw[i]); | ||
| 453 | } | ||
| 454 | #endif | ||
| 455 | |||
| 448 | uint8_t timeout = 255; | 456 | uint8_t timeout = 255; |
| 449 | 457 | ||
| 450 | if (USB_DeviceState != DEVICE_STATE_Configured) | 458 | if (USB_DeviceState != DEVICE_STATE_Configured) |
| @@ -482,17 +490,24 @@ static void send_keyboard(report_keyboard_t *report) | |||
| 482 | 490 | ||
| 483 | keyboard_report_sent = *report; | 491 | keyboard_report_sent = *report; |
| 484 | 492 | ||
| 485 | #ifdef BLUETOOTH_ENABLE | ||
| 486 | bluefruit_serial_send(0xFD); | ||
| 487 | for (uint8_t i = 0; i < KEYBOARD_EPSIZE; i++) { | ||
| 488 | bluefruit_serial_send(report->raw[i]); | ||
| 489 | } | ||
| 490 | #endif | ||
| 491 | } | 493 | } |
| 492 | 494 | ||
| 493 | static void send_mouse(report_mouse_t *report) | 495 | static void send_mouse(report_mouse_t *report) |
| 494 | { | 496 | { |
| 495 | #ifdef MOUSE_ENABLE | 497 | #ifdef MOUSE_ENABLE |
| 498 | |||
| 499 | #ifdef BLUETOOTH_ENABLE | ||
| 500 | bluefruit_serial_send(0xFD); | ||
| 501 | bluefruit_serial_send(0x00); | ||
| 502 | bluefruit_serial_send(0x03); | ||
| 503 | bluefruit_serial_send(report->buttons); | ||
| 504 | bluefruit_serial_send(report->x); | ||
| 505 | bluefruit_serial_send(report->y); | ||
| 506 | bluefruit_serial_send(report->v); // should try sending the wheel v here | ||
| 507 | bluefruit_serial_send(report->h); // should try sending the wheel h here | ||
| 508 | bluefruit_serial_send(0x00); | ||
| 509 | #endif | ||
| 510 | |||
| 496 | uint8_t timeout = 255; | 511 | uint8_t timeout = 255; |
| 497 | 512 | ||
| 498 | if (USB_DeviceState != DEVICE_STATE_Configured) | 513 | if (USB_DeviceState != DEVICE_STATE_Configured) |
| @@ -511,19 +526,6 @@ static void send_mouse(report_mouse_t *report) | |||
| 511 | /* Finalize the stream transfer to send the last packet */ | 526 | /* Finalize the stream transfer to send the last packet */ |
| 512 | Endpoint_ClearIN(); | 527 | Endpoint_ClearIN(); |
| 513 | 528 | ||
| 514 | |||
| 515 | #ifdef BLUETOOTH_ENABLE | ||
| 516 | bluefruit_serial_send(0xFD); | ||
| 517 | bluefruit_serial_send(0x00); | ||
| 518 | bluefruit_serial_send(0x03); | ||
| 519 | bluefruit_serial_send(report->buttons); | ||
| 520 | bluefruit_serial_send(report->x); | ||
| 521 | bluefruit_serial_send(report->y); | ||
| 522 | bluefruit_serial_send(report->v); // should try sending the wheel v here | ||
| 523 | bluefruit_serial_send(report->h); // should try sending the wheel h here | ||
| 524 | bluefruit_serial_send(0x00); | ||
| 525 | #endif | ||
| 526 | |||
| 527 | #endif | 529 | #endif |
| 528 | } | 530 | } |
| 529 | 531 | ||
| @@ -550,6 +552,23 @@ static void send_system(uint16_t data) | |||
| 550 | 552 | ||
| 551 | static void send_consumer(uint16_t data) | 553 | static void send_consumer(uint16_t data) |
| 552 | { | 554 | { |
| 555 | |||
| 556 | #ifdef BLUETOOTH_ENABLE | ||
| 557 | static uint16_t last_data = 0; | ||
| 558 | if (data == last_data) return; | ||
| 559 | last_data = data; | ||
| 560 | uint16_t bitmap = CONSUMER2BLUEFRUIT(data); | ||
| 561 | bluefruit_serial_send(0xFD); | ||
| 562 | bluefruit_serial_send(0x00); | ||
| 563 | bluefruit_serial_send(0x02); | ||
| 564 | bluefruit_serial_send((bitmap>>8)&0xFF); | ||
| 565 | bluefruit_serial_send(bitmap&0xFF); | ||
| 566 | bluefruit_serial_send(0x00); | ||
| 567 | bluefruit_serial_send(0x00); | ||
| 568 | bluefruit_serial_send(0x00); | ||
| 569 | bluefruit_serial_send(0x00); | ||
| 570 | #endif | ||
| 571 | |||
| 553 | uint8_t timeout = 255; | 572 | uint8_t timeout = 255; |
| 554 | 573 | ||
| 555 | if (USB_DeviceState != DEVICE_STATE_Configured) | 574 | if (USB_DeviceState != DEVICE_STATE_Configured) |
| @@ -568,21 +587,6 @@ static void send_consumer(uint16_t data) | |||
| 568 | Endpoint_Write_Stream_LE(&r, sizeof(report_extra_t), NULL); | 587 | Endpoint_Write_Stream_LE(&r, sizeof(report_extra_t), NULL); |
| 569 | Endpoint_ClearIN(); | 588 | Endpoint_ClearIN(); |
| 570 | 589 | ||
| 571 | #ifdef BLUETOOTH_ENABLE | ||
| 572 | static uint16_t last_data = 0; | ||
| 573 | if (data == last_data) return; | ||
| 574 | last_data = data; | ||
| 575 | uint16_t bitmap = CONSUMER2BLUEFRUIT(data); | ||
| 576 | bluefruit_serial_send(0xFD); | ||
| 577 | bluefruit_serial_send(0x00); | ||
| 578 | bluefruit_serial_send(0x02); | ||
| 579 | bluefruit_serial_send((bitmap>>8)&0xFF); | ||
| 580 | bluefruit_serial_send(bitmap&0xFF); | ||
| 581 | bluefruit_serial_send(0x00); | ||
| 582 | bluefruit_serial_send(0x00); | ||
| 583 | bluefruit_serial_send(0x00); | ||
| 584 | bluefruit_serial_send(0x00); | ||
| 585 | #endif | ||
| 586 | 590 | ||
| 587 | } | 591 | } |
| 588 | 592 | ||
| @@ -881,19 +885,18 @@ int main(void) | |||
| 881 | #endif | 885 | #endif |
| 882 | 886 | ||
| 883 | #ifdef BLUETOOTH_ENABLE | 887 | #ifdef BLUETOOTH_ENABLE |
| 884 | print_set_sendchar(sendchar); | ||
| 885 | serial_init(); | 888 | serial_init(); |
| 886 | #endif | 889 | #endif |
| 887 | 890 | ||
| 888 | 891 | ||
| 889 | /* wait for USB startup & debug output */ | 892 | /* wait for USB startup & debug output */ |
| 890 | while (USB_DeviceState != DEVICE_STATE_Configured) { | 893 | // while (USB_DeviceState != DEVICE_STATE_Configured) { |
| 891 | // #if defined(INTERRUPT_CONTROL_ENDPOINT) | 894 | // #if defined(INTERRUPT_CONTROL_ENDPOINT) |
| 892 | // ; | 895 | // ; |
| 893 | // #else | 896 | // #else |
| 894 | USB_USBTask(); | 897 | USB_USBTask(); |
| 895 | // #endif | 898 | // #endif |
| 896 | } | 899 | // } |
| 897 | print("USB configured.\n"); | 900 | print("USB configured.\n"); |
| 898 | 901 | ||
| 899 | /* init modules */ | 902 | /* init modules */ |
| @@ -905,13 +908,13 @@ int main(void) | |||
| 905 | 908 | ||
| 906 | print("Keyboard start.\n"); | 909 | print("Keyboard start.\n"); |
| 907 | while (1) { | 910 | while (1) { |
| 908 | while (USB_DeviceState == DEVICE_STATE_Suspended) { | 911 | // while (USB_DeviceState == DEVICE_STATE_Suspended) { |
| 909 | print("[s]"); | 912 | // print("[s]"); |
| 910 | suspend_power_down(); | 913 | // suspend_power_down(); |
| 911 | if (USB_Device_RemoteWakeupEnabled && suspend_wakeup_condition()) { | 914 | // if (USB_Device_RemoteWakeupEnabled && suspend_wakeup_condition()) { |
| 912 | USB_Device_SendRemoteWakeup(); | 915 | // USB_Device_SendRemoteWakeup(); |
| 913 | } | 916 | // } |
| 914 | } | 917 | // } |
| 915 | 918 | ||
| 916 | #ifdef MIDI_ENABLE | 919 | #ifdef MIDI_ENABLE |
| 917 | midi_device_process(&midi_device); | 920 | midi_device_process(&midi_device); |
