diff options
Diffstat (limited to 'tmk_core')
| -rw-r--r-- | tmk_core/common/action.c | 16 | ||||
| -rw-r--r-- | tmk_core/common/action_code.h | 10 | ||||
| -rw-r--r-- | tmk_core/common/action_macro.h | 26 | ||||
| -rw-r--r-- | tmk_core/common/keyboard.c | 3 | ||||
| -rw-r--r-- | tmk_core/common/matrix.h | 2 | ||||
| -rw-r--r-- | tmk_core/common/report.h | 7 | ||||
| -rw-r--r-- | tmk_core/protocol/lufa.mk | 3 | ||||
| -rw-r--r-- | tmk_core/protocol/lufa/lufa.c | 116 | ||||
| -rw-r--r-- | tmk_core/protocol/lufa/outputselect.c | 56 | ||||
| -rw-r--r-- | tmk_core/protocol/lufa/outputselect.h | 41 | ||||
| -rw-r--r-- | tmk_core/protocol/ps2_mouse.h | 5 | ||||
| -rw-r--r-- | tmk_core/protocol/vusb/vusb.c | 4 |
12 files changed, 193 insertions, 96 deletions
diff --git a/tmk_core/common/action.c b/tmk_core/common/action.c index d485b46c7..f03670a7f 100644 --- a/tmk_core/common/action.c +++ b/tmk_core/common/action.c | |||
| @@ -49,6 +49,13 @@ void action_exec(keyevent_t event) | |||
| 49 | 49 | ||
| 50 | keyrecord_t record = { .event = event }; | 50 | keyrecord_t record = { .event = event }; |
| 51 | 51 | ||
| 52 | #if (defined(ONESHOT_TIMEOUT) && (ONESHOT_TIMEOUT > 0)) | ||
| 53 | if (has_oneshot_layer_timed_out()) { | ||
| 54 | dprintf("Oneshot layer: timeout\n"); | ||
| 55 | clear_oneshot_layer_state(ONESHOT_OTHER_KEY_PRESSED); | ||
| 56 | } | ||
| 57 | #endif | ||
| 58 | |||
| 52 | #ifndef NO_ACTION_TAPPING | 59 | #ifndef NO_ACTION_TAPPING |
| 53 | action_tapping_process(record); | 60 | action_tapping_process(record); |
| 54 | #else | 61 | #else |
| @@ -100,7 +107,7 @@ bool process_record_quantum(keyrecord_t *record) { | |||
| 100 | return true; | 107 | return true; |
| 101 | } | 108 | } |
| 102 | 109 | ||
| 103 | void process_record(keyrecord_t *record) | 110 | void process_record(keyrecord_t *record) |
| 104 | { | 111 | { |
| 105 | if (IS_NOEVENT(record->event)) { return; } | 112 | if (IS_NOEVENT(record->event)) { return; } |
| 106 | 113 | ||
| @@ -126,13 +133,6 @@ void process_action(keyrecord_t *record, action_t action) | |||
| 126 | uint8_t tap_count = record->tap.count; | 133 | uint8_t tap_count = record->tap.count; |
| 127 | #endif | 134 | #endif |
| 128 | 135 | ||
| 129 | #if (defined(ONESHOT_TIMEOUT) && (ONESHOT_TIMEOUT > 0)) | ||
| 130 | if (has_oneshot_layer_timed_out()) { | ||
| 131 | dprintf("Oneshot layer: timeout\n"); | ||
| 132 | clear_oneshot_layer_state(ONESHOT_OTHER_KEY_PRESSED); | ||
| 133 | } | ||
| 134 | #endif | ||
| 135 | |||
| 136 | if (event.pressed) { | 136 | if (event.pressed) { |
| 137 | // clear the potential weak mods left by previously pressed keys | 137 | // clear the potential weak mods left by previously pressed keys |
| 138 | clear_weak_mods(); | 138 | clear_weak_mods(); |
diff --git a/tmk_core/common/action_code.h b/tmk_core/common/action_code.h index 33da35f35..b15aaa0eb 100644 --- a/tmk_core/common/action_code.h +++ b/tmk_core/common/action_code.h | |||
| @@ -47,10 +47,15 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 47 | * 0100|10| usage(10) (reserved) | 47 | * 0100|10| usage(10) (reserved) |
| 48 | * 0100|11| usage(10) (reserved) | 48 | * 0100|11| usage(10) (reserved) |
| 49 | * | 49 | * |
| 50 | * ACT_MOUSEKEY(0110): TODO: Not needed? | 50 | * |
| 51 | * ACT_MOUSEKEY(0101): TODO: Merge these two actions to conserve space? | ||
| 51 | * 0101|xxxx| keycode Mouse key | 52 | * 0101|xxxx| keycode Mouse key |
| 52 | * | 53 | * |
| 53 | * 011x|xxxx xxxx xxxx (reseved) | 54 | * ACT_SWAP_HANDS(0110): |
| 55 | * 0110|xxxx| keycode Swap hands (keycode on tap, or options) | ||
| 56 | * | ||
| 57 | * | ||
| 58 | * 0111|xxxx xxxx xxxx (reserved) | ||
| 54 | * | 59 | * |
| 55 | * | 60 | * |
| 56 | * Layer Actions(10xx) | 61 | * Layer Actions(10xx) |
| @@ -67,7 +72,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 67 | * ee: on event(01:press, 10:release, 11:both) | 72 | * ee: on event(01:press, 10:release, 11:both) |
| 68 | * | 73 | * |
| 69 | * 1001|xxxx|xxxx xxxx (reserved) | 74 | * 1001|xxxx|xxxx xxxx (reserved) |
| 70 | * 1001|oopp|BBBB BBBB 8-bit Bitwise Operation??? | ||
| 71 | * | 75 | * |
| 72 | * ACT_LAYER_TAP(101x): | 76 | * ACT_LAYER_TAP(101x): |
| 73 | * 101E|LLLL| keycode On/Off with tap key (0x00-DF)[TAP] | 77 | * 101E|LLLL| keycode On/Off with tap key (0x00-DF)[TAP] |
diff --git a/tmk_core/common/action_macro.h b/tmk_core/common/action_macro.h index aedc32ec6..f373f5068 100644 --- a/tmk_core/common/action_macro.h +++ b/tmk_core/common/action_macro.h | |||
| @@ -20,11 +20,33 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 20 | #include "progmem.h" | 20 | #include "progmem.h" |
| 21 | 21 | ||
| 22 | 22 | ||
| 23 | #define MACRO_NONE 0 | 23 | |
| 24 | typedef uint8_t macro_t; | ||
| 25 | |||
| 26 | #define MACRO_NONE (macro_t*)0 | ||
| 24 | #define MACRO(...) ({ static const macro_t __m[] PROGMEM = { __VA_ARGS__ }; &__m[0]; }) | 27 | #define MACRO(...) ({ static const macro_t __m[] PROGMEM = { __VA_ARGS__ }; &__m[0]; }) |
| 25 | #define MACRO_GET(p) pgm_read_byte(p) | 28 | #define MACRO_GET(p) pgm_read_byte(p) |
| 26 | 29 | ||
| 27 | typedef uint8_t macro_t; | 30 | // Sends press when the macro key is pressed, release when release, or tap_macro when the key has been tapped |
| 31 | #define MACRO_TAP_HOLD(record, press, release, tap_macro) ( ((record)->event.pressed) ? \ | ||
| 32 | ( ((record)->tap.count <= 0 || (record)->tap.interrupted) ? (press) : MACRO_NONE ) : \ | ||
| 33 | ( ((record)->tap.count > 0 && !((record)->tap.interrupted)) ? (tap_macro) : (release) ) ) | ||
| 34 | |||
| 35 | // Holds down the modifier mod when the macro key is held, or sends macro instead when tapped | ||
| 36 | #define MACRO_TAP_HOLD_MOD(record, macro, mod) MACRO_TAP_HOLD(record, (MACRO(D(mod), END)), MACRO(U(mod), END), macro) | ||
| 37 | |||
| 38 | // Holds down the modifier mod when the macro key is held, or pressed a shifted key when tapped (eg: shift+3 for #) | ||
| 39 | #define MACRO_TAP_SHFT_KEY_HOLD_MOD(record, key, mod) MACRO_TAP_HOLD_MOD(record, (MACRO(I(10), D(LSFT), T(key), U(LSFT), END)), mod) | ||
| 40 | |||
| 41 | |||
| 42 | // Momentary switch layer when held, sends macro if tapped | ||
| 43 | #define MACRO_TAP_HOLD_LAYER(record, macro, layer) ( ((record)->event.pressed) ? \ | ||
| 44 | ( ((record)->tap.count <= 0 || (record)->tap.interrupted) ? ({layer_on((layer)); MACRO_NONE; }) : MACRO_NONE ) : \ | ||
| 45 | ( ((record)->tap.count > 0 && !((record)->tap.interrupted)) ? (macro) : ({layer_off((layer)); MACRO_NONE; }) ) ) | ||
| 46 | |||
| 47 | // Momentary switch layer when held, presses a shifted key when tapped (eg: shift+3 for #) | ||
| 48 | #define MACRO_TAP_SHFT_KEY_HOLD_LAYER(record, key, layer) MACRO_TAP_HOLD_LAYER(record, MACRO(I(10), D(LSFT), T(key), U(LSFT), END), layer) | ||
| 49 | |||
| 28 | 50 | ||
| 29 | 51 | ||
| 30 | #ifndef NO_ACTION_MACRO | 52 | #ifndef NO_ACTION_MACRO |
diff --git a/tmk_core/common/keyboard.c b/tmk_core/common/keyboard.c index 371d93f3e..3aa82231b 100644 --- a/tmk_core/common/keyboard.c +++ b/tmk_core/common/keyboard.c | |||
| @@ -14,6 +14,7 @@ GNU General Public License for more details. | |||
| 14 | You should have received a copy of the GNU General Public License | 14 | You should have received a copy of the GNU General Public License |
| 15 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 15 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 16 | */ | 16 | */ |
| 17 | |||
| 17 | #include <stdint.h> | 18 | #include <stdint.h> |
| 18 | #include "keyboard.h" | 19 | #include "keyboard.h" |
| 19 | #include "matrix.h" | 20 | #include "matrix.h" |
| @@ -188,7 +189,7 @@ MATRIX_LOOP_END: | |||
| 188 | #endif | 189 | #endif |
| 189 | 190 | ||
| 190 | #ifdef VISUALIZER_ENABLE | 191 | #ifdef VISUALIZER_ENABLE |
| 191 | visualizer_update(default_layer_state, layer_state, host_keyboard_leds()); | 192 | visualizer_update(default_layer_state, layer_state, visualizer_get_mods(), host_keyboard_leds()); |
| 192 | #endif | 193 | #endif |
| 193 | 194 | ||
| 194 | // update LED | 195 | // update LED |
diff --git a/tmk_core/common/matrix.h b/tmk_core/common/matrix.h index cee3593ee..2543f5abc 100644 --- a/tmk_core/common/matrix.h +++ b/tmk_core/common/matrix.h | |||
| @@ -50,7 +50,7 @@ void matrix_init(void); | |||
| 50 | uint8_t matrix_scan(void); | 50 | uint8_t matrix_scan(void); |
| 51 | /* whether modified from previous scan. used after matrix_scan. */ | 51 | /* whether modified from previous scan. used after matrix_scan. */ |
| 52 | bool matrix_is_modified(void) __attribute__ ((deprecated)); | 52 | bool matrix_is_modified(void) __attribute__ ((deprecated)); |
| 53 | /* whether a swtich is on */ | 53 | /* whether a switch is on */ |
| 54 | bool matrix_is_on(uint8_t row, uint8_t col); | 54 | bool matrix_is_on(uint8_t row, uint8_t col); |
| 55 | /* matrix state on row */ | 55 | /* matrix state on row */ |
| 56 | matrix_row_t matrix_get_row(uint8_t row); | 56 | matrix_row_t matrix_get_row(uint8_t row); |
diff --git a/tmk_core/common/report.h b/tmk_core/common/report.h index 0c799eca3..8fb28b6ce 100644 --- a/tmk_core/common/report.h +++ b/tmk_core/common/report.h | |||
| @@ -134,13 +134,6 @@ typedef union { | |||
| 134 | } nkro; | 134 | } nkro; |
| 135 | #endif | 135 | #endif |
| 136 | } __attribute__ ((packed)) report_keyboard_t; | 136 | } __attribute__ ((packed)) report_keyboard_t; |
| 137 | /* | ||
| 138 | typedef struct { | ||
| 139 | uint8_t mods; | ||
| 140 | uint8_t reserved; | ||
| 141 | uint8_t keys[REPORT_KEYS]; | ||
| 142 | } __attribute__ ((packed)) report_keyboard_t; | ||
| 143 | */ | ||
| 144 | 137 | ||
| 145 | typedef struct { | 138 | typedef struct { |
| 146 | uint8_t buttons; | 139 | uint8_t buttons; |
diff --git a/tmk_core/protocol/lufa.mk b/tmk_core/protocol/lufa.mk index 151d26cbc..de0cc795f 100644 --- a/tmk_core/protocol/lufa.mk +++ b/tmk_core/protocol/lufa.mk | |||
| @@ -8,13 +8,14 @@ LUFA_PATH ?= $(LUFA_DIR)/LUFA-git | |||
| 8 | ifneq (, $(wildcard $(TMK_PATH)/$(LUFA_PATH)/LUFA/Build/lufa_sources.mk)) | 8 | ifneq (, $(wildcard $(TMK_PATH)/$(LUFA_PATH)/LUFA/Build/lufa_sources.mk)) |
| 9 | # New build system from 20120730 | 9 | # New build system from 20120730 |
| 10 | LUFA_ROOT_PATH = $(LUFA_PATH)/LUFA | 10 | LUFA_ROOT_PATH = $(LUFA_PATH)/LUFA |
| 11 | include $(TMK_PATH)/$(LUFA_PATH)/LUFA/Build/lufa_sources.mk | 11 | include $(TMK_PATH)/$(LUFA_PATH)/LUFA/Build/lufa_sources.mk |
| 12 | else | 12 | else |
| 13 | include $(TMK_PATH)/$(LUFA_PATH)/LUFA/makefile | 13 | include $(TMK_PATH)/$(LUFA_PATH)/LUFA/makefile |
| 14 | endif | 14 | endif |
| 15 | 15 | ||
| 16 | LUFA_SRC = lufa.c \ | 16 | LUFA_SRC = lufa.c \ |
| 17 | descriptor.c \ | 17 | descriptor.c \ |
| 18 | outputselect.c \ | ||
| 18 | $(LUFA_SRC_USB) | 19 | $(LUFA_SRC_USB) |
| 19 | 20 | ||
| 20 | ifeq ($(strip $(MIDI_ENABLE)), yes) | 21 | ifeq ($(strip $(MIDI_ENABLE)), yes) |
diff --git a/tmk_core/protocol/lufa/lufa.c b/tmk_core/protocol/lufa/lufa.c index 6dd5959dc..ba49284c9 100644 --- a/tmk_core/protocol/lufa/lufa.c +++ b/tmk_core/protocol/lufa/lufa.c | |||
| @@ -53,6 +53,7 @@ | |||
| 53 | #include "lufa.h" | 53 | #include "lufa.h" |
| 54 | #include "quantum.h" | 54 | #include "quantum.h" |
| 55 | #include <util/atomic.h> | 55 | #include <util/atomic.h> |
| 56 | #include "outputselect.h" | ||
| 56 | 57 | ||
| 57 | #ifdef NKRO_ENABLE | 58 | #ifdef NKRO_ENABLE |
| 58 | #include "keycode_config.h" | 59 | #include "keycode_config.h" |
| @@ -589,59 +590,33 @@ void EVENT_USB_Device_ControlRequest(void) | |||
| 589 | 590 | ||
| 590 | /******************************************************************************* | 591 | /******************************************************************************* |
| 591 | * Host driver | 592 | * Host driver |
| 592 | p | ||
| 593 | ******************************************************************************/ | 593 | ******************************************************************************/ |
| 594 | static uint8_t keyboard_leds(void) | 594 | static uint8_t keyboard_leds(void) |
| 595 | { | 595 | { |
| 596 | return keyboard_led_stats; | 596 | return keyboard_led_stats; |
| 597 | } | 597 | } |
| 598 | 598 | ||
| 599 | #define SendToUSB 1 | ||
| 600 | #define SendToBT 2 | ||
| 601 | #define SendToBLE 4 | ||
| 602 | |||
| 603 | static inline uint8_t where_to_send(void) { | ||
| 604 | #ifdef ADAFRUIT_BLE_ENABLE | ||
| 605 | #if 0 | ||
| 606 | if (adafruit_ble_is_connected()) { | ||
| 607 | // For testing, send to BLE as a priority | ||
| 608 | return SendToBLE; | ||
| 609 | } | ||
| 610 | #endif | ||
| 611 | |||
| 612 | // This is the real policy | ||
| 613 | if (USB_DeviceState != DEVICE_STATE_Configured) { | ||
| 614 | if (adafruit_ble_is_connected()) { | ||
| 615 | return SendToBLE; | ||
| 616 | } | ||
| 617 | } | ||
| 618 | #endif | ||
| 619 | return ((USB_DeviceState == DEVICE_STATE_Configured) ? SendToUSB : 0) | ||
| 620 | #ifdef BLUETOOTH_ENABLE | ||
| 621 | || SendToBT | ||
| 622 | #endif | ||
| 623 | ; | ||
| 624 | } | ||
| 625 | |||
| 626 | static void send_keyboard(report_keyboard_t *report) | 599 | static void send_keyboard(report_keyboard_t *report) |
| 627 | { | 600 | { |
| 601 | uint8_t timeout = 255; | ||
| 602 | uint8_t where = where_to_send(); | ||
| 603 | |||
| 628 | #ifdef BLUETOOTH_ENABLE | 604 | #ifdef BLUETOOTH_ENABLE |
| 629 | bluefruit_serial_send(0xFD); | 605 | if (where == OUTPUT_BLUETOOTH || where == OUTPUT_USB_AND_BT) { |
| 630 | for (uint8_t i = 0; i < KEYBOARD_EPSIZE; i++) { | 606 | bluefruit_serial_send(0xFD); |
| 631 | bluefruit_serial_send(report->raw[i]); | 607 | for (uint8_t i = 0; i < KEYBOARD_EPSIZE; i++) { |
| 608 | bluefruit_serial_send(report->raw[i]); | ||
| 609 | } | ||
| 632 | } | 610 | } |
| 633 | #endif | 611 | #endif |
| 634 | 612 | ||
| 635 | uint8_t timeout = 255; | ||
| 636 | uint8_t where = where_to_send(); | ||
| 637 | |||
| 638 | #ifdef ADAFRUIT_BLE_ENABLE | 613 | #ifdef ADAFRUIT_BLE_ENABLE |
| 639 | if (where & SendToBLE) { | 614 | if (where == OUTPUT_ADAFRUIT_BLE) { |
| 640 | adafruit_ble_send_keys(report->mods, report->keys, sizeof(report->keys)); | 615 | adafruit_ble_send_keys(report->mods, report->keys, sizeof(report->keys)); |
| 641 | } | 616 | } |
| 642 | #endif | 617 | #endif |
| 643 | 618 | ||
| 644 | if (!(where & SendToUSB)) { | 619 | if (where != OUTPUT_USB && where != OUTPUT_USB_AND_BT) { |
| 645 | return; | 620 | return; |
| 646 | } | 621 | } |
| 647 | 622 | ||
| @@ -681,30 +656,31 @@ static void send_keyboard(report_keyboard_t *report) | |||
| 681 | static void send_mouse(report_mouse_t *report) | 656 | static void send_mouse(report_mouse_t *report) |
| 682 | { | 657 | { |
| 683 | #ifdef MOUSE_ENABLE | 658 | #ifdef MOUSE_ENABLE |
| 659 | uint8_t timeout = 255; | ||
| 660 | uint8_t where = where_to_send(); | ||
| 684 | 661 | ||
| 685 | #ifdef BLUETOOTH_ENABLE | 662 | #ifdef BLUETOOTH_ENABLE |
| 686 | bluefruit_serial_send(0xFD); | 663 | if (where == OUTPUT_BLUETOOTH || where == OUTPUT_USB_AND_BT) { |
| 687 | bluefruit_serial_send(0x00); | 664 | bluefruit_serial_send(0xFD); |
| 688 | bluefruit_serial_send(0x03); | 665 | bluefruit_serial_send(0x00); |
| 689 | bluefruit_serial_send(report->buttons); | 666 | bluefruit_serial_send(0x03); |
| 690 | bluefruit_serial_send(report->x); | 667 | bluefruit_serial_send(report->buttons); |
| 691 | bluefruit_serial_send(report->y); | 668 | bluefruit_serial_send(report->x); |
| 692 | bluefruit_serial_send(report->v); // should try sending the wheel v here | 669 | bluefruit_serial_send(report->y); |
| 693 | bluefruit_serial_send(report->h); // should try sending the wheel h here | 670 | bluefruit_serial_send(report->v); // should try sending the wheel v here |
| 694 | bluefruit_serial_send(0x00); | 671 | bluefruit_serial_send(report->h); // should try sending the wheel h here |
| 672 | bluefruit_serial_send(0x00); | ||
| 673 | } | ||
| 695 | #endif | 674 | #endif |
| 696 | 675 | ||
| 697 | uint8_t timeout = 255; | ||
| 698 | |||
| 699 | uint8_t where = where_to_send(); | ||
| 700 | |||
| 701 | #ifdef ADAFRUIT_BLE_ENABLE | 676 | #ifdef ADAFRUIT_BLE_ENABLE |
| 702 | if (where & SendToBLE) { | 677 | if (where == OUTPUT_ADAFRUIT_BLE) { |
| 703 | // FIXME: mouse buttons | 678 | // FIXME: mouse buttons |
| 704 | adafruit_ble_send_mouse_move(report->x, report->y, report->v, report->h); | 679 | adafruit_ble_send_mouse_move(report->x, report->y, report->v, report->h); |
| 705 | } | 680 | } |
| 706 | #endif | 681 | #endif |
| 707 | if (!(where & SendToUSB)) { | 682 | |
| 683 | if (where != OUTPUT_USB && where != OUTPUT_USB_AND_BT) { | ||
| 708 | return; | 684 | return; |
| 709 | } | 685 | } |
| 710 | 686 | ||
| @@ -746,32 +722,34 @@ static void send_system(uint16_t data) | |||
| 746 | 722 | ||
| 747 | static void send_consumer(uint16_t data) | 723 | static void send_consumer(uint16_t data) |
| 748 | { | 724 | { |
| 725 | uint8_t timeout = 255; | ||
| 726 | uint8_t where = where_to_send(); | ||
| 749 | 727 | ||
| 750 | #ifdef BLUETOOTH_ENABLE | 728 | #ifdef BLUETOOTH_ENABLE |
| 751 | static uint16_t last_data = 0; | 729 | if (where == OUTPUT_BLUETOOTH || where == OUTPUT_USB_AND_BT) { |
| 752 | if (data == last_data) return; | 730 | static uint16_t last_data = 0; |
| 753 | last_data = data; | 731 | if (data == last_data) return; |
| 754 | uint16_t bitmap = CONSUMER2BLUEFRUIT(data); | 732 | last_data = data; |
| 755 | bluefruit_serial_send(0xFD); | 733 | uint16_t bitmap = CONSUMER2BLUEFRUIT(data); |
| 756 | bluefruit_serial_send(0x00); | 734 | bluefruit_serial_send(0xFD); |
| 757 | bluefruit_serial_send(0x02); | 735 | bluefruit_serial_send(0x00); |
| 758 | bluefruit_serial_send((bitmap>>8)&0xFF); | 736 | bluefruit_serial_send(0x02); |
| 759 | bluefruit_serial_send(bitmap&0xFF); | 737 | bluefruit_serial_send((bitmap>>8)&0xFF); |
| 760 | bluefruit_serial_send(0x00); | 738 | bluefruit_serial_send(bitmap&0xFF); |
| 761 | bluefruit_serial_send(0x00); | 739 | bluefruit_serial_send(0x00); |
| 762 | bluefruit_serial_send(0x00); | 740 | bluefruit_serial_send(0x00); |
| 763 | bluefruit_serial_send(0x00); | 741 | bluefruit_serial_send(0x00); |
| 742 | bluefruit_serial_send(0x00); | ||
| 743 | } | ||
| 764 | #endif | 744 | #endif |
| 765 | 745 | ||
| 766 | uint8_t timeout = 255; | ||
| 767 | uint8_t where = where_to_send(); | ||
| 768 | |||
| 769 | #ifdef ADAFRUIT_BLE_ENABLE | 746 | #ifdef ADAFRUIT_BLE_ENABLE |
| 770 | if (where & SendToBLE) { | 747 | if (where == OUTPUT_ADAFRUIT_BLE) { |
| 771 | adafruit_ble_send_consumer_key(data, 0); | 748 | adafruit_ble_send_consumer_key(data, 0); |
| 772 | } | 749 | } |
| 773 | #endif | 750 | #endif |
| 774 | if (!(where & SendToUSB)) { | 751 | |
| 752 | if (where != OUTPUT_USB && where != OUTPUT_USB_AND_BT) { | ||
| 775 | return; | 753 | return; |
| 776 | } | 754 | } |
| 777 | 755 | ||
diff --git a/tmk_core/protocol/lufa/outputselect.c b/tmk_core/protocol/lufa/outputselect.c new file mode 100644 index 000000000..5d2457bff --- /dev/null +++ b/tmk_core/protocol/lufa/outputselect.c | |||
| @@ -0,0 +1,56 @@ | |||
| 1 | /* | ||
| 2 | Copyright 2017 Priyadi Iman Nurcahyo | ||
| 3 | This program is free software: you can redistribute it and/or modify | ||
| 4 | it under the terms of the GNU General Public License as published by | ||
| 5 | the Free Software Foundation, either version 2 of the License, or | ||
| 6 | (at your option) any later version. | ||
| 7 | This program is distributed in the hope that it will be useful, | ||
| 8 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 9 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 10 | GNU General Public License for more details. | ||
| 11 | You should have received a copy of the GNU General Public License | ||
| 12 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 13 | */ | ||
| 14 | |||
| 15 | #include "lufa.h" | ||
| 16 | #include "outputselect.h" | ||
| 17 | #ifdef ADAFRUIT_BLE_ENABLE | ||
| 18 | #include "adafruit_ble.h" | ||
| 19 | #endif | ||
| 20 | |||
| 21 | uint8_t desired_output = OUTPUT_DEFAULT; | ||
| 22 | |||
| 23 | void set_output(uint8_t output) { | ||
| 24 | set_output_user(output); | ||
| 25 | desired_output = output; | ||
| 26 | } | ||
| 27 | |||
| 28 | __attribute__((weak)) | ||
| 29 | void set_output_user(uint8_t output) { | ||
| 30 | } | ||
| 31 | |||
| 32 | uint8_t auto_detect_output(void) { | ||
| 33 | if (USB_DeviceState == DEVICE_STATE_Configured) { | ||
| 34 | return OUTPUT_USB; | ||
| 35 | } | ||
| 36 | |||
| 37 | #ifdef ADAFRUIT_BLE_ENABLE | ||
| 38 | if (adafruit_ble_is_connected()) { | ||
| 39 | return OUTPUT_ADAFRUIT_BLE; | ||
| 40 | } | ||
| 41 | #endif | ||
| 42 | |||
| 43 | #ifdef BLUETOOTH_ENABLE | ||
| 44 | return OUTPUT_BLUETOOTH; // should check if BT is connected here | ||
| 45 | #endif | ||
| 46 | |||
| 47 | return OUTPUT_NONE; | ||
| 48 | } | ||
| 49 | |||
| 50 | uint8_t where_to_send(void) { | ||
| 51 | if (desired_output == OUTPUT_AUTO) { | ||
| 52 | return auto_detect_output(); | ||
| 53 | } | ||
| 54 | return desired_output; | ||
| 55 | } | ||
| 56 | |||
diff --git a/tmk_core/protocol/lufa/outputselect.h b/tmk_core/protocol/lufa/outputselect.h new file mode 100644 index 000000000..79b4dd35d --- /dev/null +++ b/tmk_core/protocol/lufa/outputselect.h | |||
| @@ -0,0 +1,41 @@ | |||
| 1 | /* | ||
| 2 | Copyright 2017 Priyadi Iman Nurcahyo | ||
| 3 | This program is free software: you can redistribute it and/or modify | ||
| 4 | it under the terms of the GNU General Public License as published by | ||
| 5 | the Free Software Foundation, either version 2 of the License, or | ||
| 6 | (at your option) any later version. | ||
| 7 | This program is distributed in the hope that it will be useful, | ||
| 8 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 9 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 10 | GNU General Public License for more details. | ||
| 11 | You should have received a copy of the GNU General Public License | ||
| 12 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 13 | */ | ||
| 14 | |||
| 15 | enum outputs { | ||
| 16 | OUTPUT_AUTO, | ||
| 17 | |||
| 18 | OUTPUT_NONE, | ||
| 19 | OUTPUT_USB, | ||
| 20 | OUTPUT_BLUETOOTH, | ||
| 21 | OUTPUT_ADAFRUIT_BLE, | ||
| 22 | |||
| 23 | // backward compatibility | ||
| 24 | OUTPUT_USB_AND_BT | ||
| 25 | }; | ||
| 26 | |||
| 27 | /** | ||
| 28 | * backward compatibility for BLUETOOTH_ENABLE, send to BT and USB by default | ||
| 29 | */ | ||
| 30 | #ifndef OUTPUT_DEFAULT | ||
| 31 | #ifdef BLUETOOTH_ENABLE | ||
| 32 | #define OUTPUT_DEFAULT OUTPUT_USB_AND_BT | ||
| 33 | #else | ||
| 34 | #define OUTPUT_DEFAULT OUTPUT_AUTO | ||
| 35 | #endif | ||
| 36 | #endif | ||
| 37 | |||
| 38 | void set_output(uint8_t output); | ||
| 39 | void set_output_user(uint8_t output); | ||
| 40 | uint8_t auto_detect_output(void); | ||
| 41 | uint8_t where_to_send(void); \ No newline at end of file | ||
diff --git a/tmk_core/protocol/ps2_mouse.h b/tmk_core/protocol/ps2_mouse.h index 3c93a4634..eeeffe4d8 100644 --- a/tmk_core/protocol/ps2_mouse.h +++ b/tmk_core/protocol/ps2_mouse.h | |||
| @@ -23,7 +23,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 23 | 23 | ||
| 24 | #define PS2_MOUSE_SEND(command, message) \ | 24 | #define PS2_MOUSE_SEND(command, message) \ |
| 25 | do { \ | 25 | do { \ |
| 26 | uint8_t rcv = ps2_host_send(command); \ | 26 | __attribute__ ((unused)) uint8_t rcv = ps2_host_send(command); \ |
| 27 | if (debug_mouse) { \ | 27 | if (debug_mouse) { \ |
| 28 | print((message)); \ | 28 | print((message)); \ |
| 29 | xprintf(" command: %X, result: %X, error: %X \n", command, rcv, ps2_error); \ | 29 | xprintf(" command: %X, result: %X, error: %X \n", command, rcv, ps2_error); \ |
| @@ -55,13 +55,14 @@ do { \ | |||
| 55 | 55 | ||
| 56 | #define PS2_MOUSE_RECEIVE(message) \ | 56 | #define PS2_MOUSE_RECEIVE(message) \ |
| 57 | do { \ | 57 | do { \ |
| 58 | uint8_t rcv = ps2_host_recv_response(); \ | 58 | __attribute__ ((unused)) uint8_t rcv = ps2_host_recv_response(); \ |
| 59 | if (debug_mouse) { \ | 59 | if (debug_mouse) { \ |
| 60 | print((message)); \ | 60 | print((message)); \ |
| 61 | xprintf(" result: %X, error: %X \n", rcv, ps2_error); \ | 61 | xprintf(" result: %X, error: %X \n", rcv, ps2_error); \ |
| 62 | } \ | 62 | } \ |
| 63 | } while(0) | 63 | } while(0) |
| 64 | 64 | ||
| 65 | __attribute__ ((unused)) | ||
| 65 | static enum ps2_mouse_mode_e { | 66 | static enum ps2_mouse_mode_e { |
| 66 | PS2_MOUSE_STREAM_MODE, | 67 | PS2_MOUSE_STREAM_MODE, |
| 67 | PS2_MOUSE_REMOTE_MODE, | 68 | PS2_MOUSE_REMOTE_MODE, |
diff --git a/tmk_core/protocol/vusb/vusb.c b/tmk_core/protocol/vusb/vusb.c index a8c13b928..022ac6f6b 100644 --- a/tmk_core/protocol/vusb/vusb.c +++ b/tmk_core/protocol/vusb/vusb.c | |||
| @@ -280,7 +280,7 @@ const PROGMEM uchar keyboard_hid_report[] = { | |||
| 280 | 0x95, 0x06, // Report Count (6), | 280 | 0x95, 0x06, // Report Count (6), |
| 281 | 0x75, 0x08, // Report Size (8), | 281 | 0x75, 0x08, // Report Size (8), |
| 282 | 0x15, 0x00, // Logical Minimum (0), | 282 | 0x15, 0x00, // Logical Minimum (0), |
| 283 | 0x25, 0xFF, 0x00, // Logical Maximum(255), | 283 | 0x26, 0xFF, 0x00, // Logical Maximum(255), |
| 284 | 0x05, 0x07, // Usage Page (Key Codes), | 284 | 0x05, 0x07, // Usage Page (Key Codes), |
| 285 | 0x19, 0x00, // Usage Minimum (0), | 285 | 0x19, 0x00, // Usage Minimum (0), |
| 286 | 0x29, 0xFF, // Usage Maximum (255), | 286 | 0x29, 0xFF, // Usage Maximum (255), |
| @@ -350,7 +350,7 @@ const PROGMEM uchar mouse_hid_report[] = { | |||
| 350 | 0xa1, 0x01, // COLLECTION (Application) | 350 | 0xa1, 0x01, // COLLECTION (Application) |
| 351 | 0x85, REPORT_ID_SYSTEM, // REPORT_ID (2) | 351 | 0x85, REPORT_ID_SYSTEM, // REPORT_ID (2) |
| 352 | 0x15, 0x01, // LOGICAL_MINIMUM (0x1) | 352 | 0x15, 0x01, // LOGICAL_MINIMUM (0x1) |
| 353 | 0x25, 0xb7, 0x00, // LOGICAL_MAXIMUM (0xb7) | 353 | 0x26, 0xb7, 0x00, // LOGICAL_MAXIMUM (0xb7) |
| 354 | 0x19, 0x01, // USAGE_MINIMUM (0x1) | 354 | 0x19, 0x01, // USAGE_MINIMUM (0x1) |
| 355 | 0x29, 0xb7, // USAGE_MAXIMUM (0xb7) | 355 | 0x29, 0xb7, // USAGE_MAXIMUM (0xb7) |
| 356 | 0x75, 0x10, // REPORT_SIZE (16) | 356 | 0x75, 0x10, // REPORT_SIZE (16) |
