diff options
Diffstat (limited to 'tmk_core')
| -rw-r--r-- | tmk_core/common.mk | 14 | ||||
| -rw-r--r-- | tmk_core/common/action.c | 29 | ||||
| -rw-r--r-- | tmk_core/common/action_code.h | 10 | ||||
| -rw-r--r-- | tmk_core/common/action_layer.c | 12 | ||||
| -rw-r--r-- | tmk_core/common/action_layer.h | 5 | ||||
| -rw-r--r-- | tmk_core/common/action_macro.h | 26 | ||||
| -rw-r--r-- | tmk_core/common/action_tapping.c | 11 | ||||
| -rw-r--r-- | tmk_core/common/keyboard.c | 7 | ||||
| -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 | 15 | ||||
| -rw-r--r-- | tmk_core/protocol/lufa/adafruit_ble.h | 4 | ||||
| -rw-r--r-- | tmk_core/protocol/lufa/lufa.c | 160 | ||||
| -rw-r--r-- | tmk_core/protocol/lufa/lufa.h | 2 | ||||
| -rw-r--r-- | tmk_core/protocol/lufa/outputselect.c | 56 | ||||
| -rw-r--r-- | tmk_core/protocol/lufa/outputselect.h | 40 | ||||
| -rw-r--r-- | tmk_core/protocol/ps2_mouse.h | 5 | ||||
| -rw-r--r-- | tmk_core/protocol/vusb/vusb.c | 4 |
18 files changed, 279 insertions, 130 deletions
diff --git a/tmk_core/common.mk b/tmk_core/common.mk index a86dccc61..47f6fc571 100644 --- a/tmk_core/common.mk +++ b/tmk_core/common.mk | |||
| @@ -93,14 +93,20 @@ ifeq ($(strip $(BACKLIGHT_ENABLE)), yes) | |||
| 93 | TMK_COMMON_DEFS += -DBACKLIGHT_ENABLE | 93 | TMK_COMMON_DEFS += -DBACKLIGHT_ENABLE |
| 94 | endif | 94 | endif |
| 95 | 95 | ||
| 96 | ifeq ($(strip $(ADAFRUIT_BLE_ENABLE)), yes) | ||
| 97 | TMK_COMMON_DEFS += -DADAFRUIT_BLE_ENABLE | ||
| 98 | endif | ||
| 99 | |||
| 100 | ifeq ($(strip $(BLUETOOTH_ENABLE)), yes) | 96 | ifeq ($(strip $(BLUETOOTH_ENABLE)), yes) |
| 101 | TMK_COMMON_DEFS += -DBLUETOOTH_ENABLE | 97 | TMK_COMMON_DEFS += -DBLUETOOTH_ENABLE |
| 102 | endif | 98 | endif |
| 103 | 99 | ||
| 100 | ifeq ($(strip $(BLUETOOTH)), AdafruitBLE) | ||
| 101 | TMK_COMMON_DEFS += -DBLUETOOTH_ENABLE | ||
| 102 | TMK_COMMON_DEFS += -DMODULE_ADAFRUIT_BLE | ||
| 103 | endif | ||
| 104 | |||
| 105 | ifeq ($(strip $(BLUETOOTH)), AdafruitEZKey) | ||
| 106 | TMK_COMMON_DEFS += -DBLUETOOTH_ENABLE | ||
| 107 | TMK_COMMON_DEFS += -DMODULE_ADAFRUIT_EZKEY | ||
| 108 | endif | ||
| 109 | |||
| 104 | ifeq ($(strip $(ONEHAND_ENABLE)), yes) | 110 | ifeq ($(strip $(ONEHAND_ENABLE)), yes) |
| 105 | TMK_COMMON_DEFS += -DONEHAND_ENABLE | 111 | TMK_COMMON_DEFS += -DONEHAND_ENABLE |
| 106 | endif | 112 | endif |
diff --git a/tmk_core/common/action.c b/tmk_core/common/action.c index d485b46c7..94de36918 100644 --- a/tmk_core/common/action.c +++ b/tmk_core/common/action.c | |||
| @@ -33,6 +33,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 33 | #include "nodebug.h" | 33 | #include "nodebug.h" |
| 34 | #endif | 34 | #endif |
| 35 | 35 | ||
| 36 | #ifdef FAUXCLICKY_ENABLE | ||
| 37 | #include <fauxclicky.h> | ||
| 38 | #endif | ||
| 36 | 39 | ||
| 37 | void action_exec(keyevent_t event) | 40 | void action_exec(keyevent_t event) |
| 38 | { | 41 | { |
| @@ -41,6 +44,16 @@ void action_exec(keyevent_t event) | |||
| 41 | dprint("EVENT: "); debug_event(event); dprintln(); | 44 | dprint("EVENT: "); debug_event(event); dprintln(); |
| 42 | } | 45 | } |
| 43 | 46 | ||
| 47 | #ifdef FAUXCLICKY_ENABLE | ||
| 48 | if (IS_PRESSED(event)) { | ||
| 49 | FAUXCLICKY_ACTION_PRESS; | ||
| 50 | } | ||
| 51 | if (IS_RELEASED(event)) { | ||
| 52 | FAUXCLICKY_ACTION_RELEASE; | ||
| 53 | } | ||
| 54 | fauxclicky_check(); | ||
| 55 | #endif | ||
| 56 | |||
| 44 | #ifdef ONEHAND_ENABLE | 57 | #ifdef ONEHAND_ENABLE |
| 45 | if (!IS_NOEVENT(event)) { | 58 | if (!IS_NOEVENT(event)) { |
| 46 | process_hand_swap(&event); | 59 | process_hand_swap(&event); |
| @@ -49,6 +62,13 @@ void action_exec(keyevent_t event) | |||
| 49 | 62 | ||
| 50 | keyrecord_t record = { .event = event }; | 63 | keyrecord_t record = { .event = event }; |
| 51 | 64 | ||
| 65 | #if (defined(ONESHOT_TIMEOUT) && (ONESHOT_TIMEOUT > 0)) | ||
| 66 | if (has_oneshot_layer_timed_out()) { | ||
| 67 | dprintf("Oneshot layer: timeout\n"); | ||
| 68 | clear_oneshot_layer_state(ONESHOT_OTHER_KEY_PRESSED); | ||
| 69 | } | ||
| 70 | #endif | ||
| 71 | |||
| 52 | #ifndef NO_ACTION_TAPPING | 72 | #ifndef NO_ACTION_TAPPING |
| 53 | action_tapping_process(record); | 73 | action_tapping_process(record); |
| 54 | #else | 74 | #else |
| @@ -100,7 +120,7 @@ bool process_record_quantum(keyrecord_t *record) { | |||
| 100 | return true; | 120 | return true; |
| 101 | } | 121 | } |
| 102 | 122 | ||
| 103 | void process_record(keyrecord_t *record) | 123 | void process_record(keyrecord_t *record) |
| 104 | { | 124 | { |
| 105 | if (IS_NOEVENT(record->event)) { return; } | 125 | if (IS_NOEVENT(record->event)) { return; } |
| 106 | 126 | ||
| @@ -126,13 +146,6 @@ void process_action(keyrecord_t *record, action_t action) | |||
| 126 | uint8_t tap_count = record->tap.count; | 146 | uint8_t tap_count = record->tap.count; |
| 127 | #endif | 147 | #endif |
| 128 | 148 | ||
| 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) { | 149 | if (event.pressed) { |
| 137 | // clear the potential weak mods left by previously pressed keys | 150 | // clear the potential weak mods left by previously pressed keys |
| 138 | clear_weak_mods(); | 151 | 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_layer.c b/tmk_core/common/action_layer.c index a3c757964..58d919a04 100644 --- a/tmk_core/common/action_layer.c +++ b/tmk_core/common/action_layer.c | |||
| @@ -16,8 +16,14 @@ | |||
| 16 | */ | 16 | */ |
| 17 | uint32_t default_layer_state = 0; | 17 | uint32_t default_layer_state = 0; |
| 18 | 18 | ||
| 19 | __attribute__((weak)) | ||
| 20 | uint32_t default_layer_state_set_kb(uint32_t state) { | ||
| 21 | return state; | ||
| 22 | } | ||
| 23 | |||
| 19 | static void default_layer_state_set(uint32_t state) | 24 | static void default_layer_state_set(uint32_t state) |
| 20 | { | 25 | { |
| 26 | state = default_layer_state_set_kb(state); | ||
| 21 | debug("default_layer_state: "); | 27 | debug("default_layer_state: "); |
| 22 | default_layer_debug(); debug(" to "); | 28 | default_layer_debug(); debug(" to "); |
| 23 | default_layer_state = state; | 29 | default_layer_state = state; |
| @@ -57,8 +63,14 @@ void default_layer_xor(uint32_t state) | |||
| 57 | */ | 63 | */ |
| 58 | uint32_t layer_state = 0; | 64 | uint32_t layer_state = 0; |
| 59 | 65 | ||
| 66 | __attribute__((weak)) | ||
| 67 | uint32_t layer_state_set_kb(uint32_t state) { | ||
| 68 | return state; | ||
| 69 | } | ||
| 70 | |||
| 60 | static void layer_state_set(uint32_t state) | 71 | static void layer_state_set(uint32_t state) |
| 61 | { | 72 | { |
| 73 | state = layer_state_set_kb(state); | ||
| 62 | dprint("layer_state: "); | 74 | dprint("layer_state: "); |
| 63 | layer_debug(); dprint(" to "); | 75 | layer_debug(); dprint(" to "); |
| 64 | layer_state = state; | 76 | layer_state = state; |
diff --git a/tmk_core/common/action_layer.h b/tmk_core/common/action_layer.h index 025cf5420..d89ed6e5c 100644 --- a/tmk_core/common/action_layer.h +++ b/tmk_core/common/action_layer.h | |||
| @@ -29,6 +29,9 @@ extern uint32_t default_layer_state; | |||
| 29 | void default_layer_debug(void); | 29 | void default_layer_debug(void); |
| 30 | void default_layer_set(uint32_t state); | 30 | void default_layer_set(uint32_t state); |
| 31 | 31 | ||
| 32 | __attribute__((weak)) | ||
| 33 | uint32_t default_layer_state_set_kb(uint32_t state); | ||
| 34 | |||
| 32 | #ifndef NO_ACTION_LAYER | 35 | #ifndef NO_ACTION_LAYER |
| 33 | /* bitwise operation */ | 36 | /* bitwise operation */ |
| 34 | void default_layer_or(uint32_t state); | 37 | void default_layer_or(uint32_t state); |
| @@ -69,6 +72,8 @@ void layer_xor(uint32_t state); | |||
| 69 | #define layer_xor(state) | 72 | #define layer_xor(state) |
| 70 | #define layer_debug() | 73 | #define layer_debug() |
| 71 | 74 | ||
| 75 | __attribute__((weak)) | ||
| 76 | uint32_t layer_state_set_kb(uint32_t state); | ||
| 72 | #endif | 77 | #endif |
| 73 | 78 | ||
| 74 | /* pressed actions cache */ | 79 | /* pressed actions cache */ |
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/action_tapping.c b/tmk_core/common/action_tapping.c index e16e11be7..bd9a69ae0 100644 --- a/tmk_core/common/action_tapping.c +++ b/tmk_core/common/action_tapping.c | |||
| @@ -228,6 +228,7 @@ bool process_tapping(keyrecord_t *keyp) | |||
| 228 | if (WITHIN_TAPPING_TERM(event)) { | 228 | if (WITHIN_TAPPING_TERM(event)) { |
| 229 | if (event.pressed) { | 229 | if (event.pressed) { |
| 230 | if (IS_TAPPING_KEY(event.key)) { | 230 | if (IS_TAPPING_KEY(event.key)) { |
| 231 | #ifndef TAPPING_FORCE_HOLD | ||
| 231 | if (!tapping_key.tap.interrupted && tapping_key.tap.count > 0) { | 232 | if (!tapping_key.tap.interrupted && tapping_key.tap.count > 0) { |
| 232 | // sequential tap. | 233 | // sequential tap. |
| 233 | keyp->tap = tapping_key.tap; | 234 | keyp->tap = tapping_key.tap; |
| @@ -237,11 +238,11 @@ bool process_tapping(keyrecord_t *keyp) | |||
| 237 | tapping_key = *keyp; | 238 | tapping_key = *keyp; |
| 238 | debug_tapping_key(); | 239 | debug_tapping_key(); |
| 239 | return true; | 240 | return true; |
| 240 | } else { | ||
| 241 | // FIX: start new tap again | ||
| 242 | tapping_key = *keyp; | ||
| 243 | return true; | ||
| 244 | } | 241 | } |
| 242 | #endif | ||
| 243 | // FIX: start new tap again | ||
| 244 | tapping_key = *keyp; | ||
| 245 | return true; | ||
| 245 | } else if (is_tap_key(event.key)) { | 246 | } else if (is_tap_key(event.key)) { |
| 246 | // Sequential tap can be interfered with other tap key. | 247 | // Sequential tap can be interfered with other tap key. |
| 247 | debug("Tapping: Start with interfering other tap.\n"); | 248 | debug("Tapping: Start with interfering other tap.\n"); |
| @@ -257,7 +258,7 @@ bool process_tapping(keyrecord_t *keyp) | |||
| 257 | return true; | 258 | return true; |
| 258 | } | 259 | } |
| 259 | } else { | 260 | } else { |
| 260 | if (!IS_NOEVENT(event)) debug("Tapping: other key just after tap.\n") {}; | 261 | if (!IS_NOEVENT(event)) debug("Tapping: other key just after tap.\n"); |
| 261 | process_record(keyp); | 262 | process_record(keyp); |
| 262 | return true; | 263 | return true; |
| 263 | } | 264 | } |
diff --git a/tmk_core/common/keyboard.c b/tmk_core/common/keyboard.c index 765350792..eac1f1dd8 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" |
| @@ -50,6 +51,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 50 | #ifdef RGBLIGHT_ENABLE | 51 | #ifdef RGBLIGHT_ENABLE |
| 51 | # include "rgblight.h" | 52 | # include "rgblight.h" |
| 52 | #endif | 53 | #endif |
| 54 | #ifdef FAUXCLICKY_ENABLE | ||
| 55 | # include "fauxclicky.h" | ||
| 56 | #endif | ||
| 53 | #ifdef SERIAL_LINK_ENABLE | 57 | #ifdef SERIAL_LINK_ENABLE |
| 54 | # include "serial_link/system/serial_link.h" | 58 | # include "serial_link/system/serial_link.h" |
| 55 | #endif | 59 | #endif |
| @@ -107,6 +111,9 @@ void keyboard_init(void) { | |||
| 107 | #ifdef RGBLIGHT_ENABLE | 111 | #ifdef RGBLIGHT_ENABLE |
| 108 | rgblight_init(); | 112 | rgblight_init(); |
| 109 | #endif | 113 | #endif |
| 114 | #ifdef FAUXCLICKY_ENABLE | ||
| 115 | fauxclicky_init(); | ||
| 116 | #endif | ||
| 110 | #if defined(NKRO_ENABLE) && defined(FORCE_NKRO) | 117 | #if defined(NKRO_ENABLE) && defined(FORCE_NKRO) |
| 111 | keymap_config.nkro = 1; | 118 | keymap_config.nkro = 1; |
| 112 | #endif | 119 | #endif |
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..5b1577972 100644 --- a/tmk_core/protocol/lufa.mk +++ b/tmk_core/protocol/lufa.mk | |||
| @@ -8,24 +8,30 @@ 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) |
| 21 | include $(TMK_PATH)/protocol/midi.mk | 22 | include $(TMK_PATH)/protocol/midi.mk |
| 22 | endif | 23 | endif |
| 23 | 24 | ||
| 24 | ifeq ($(strip $(ADAFRUIT_BLE_ENABLE)), yes) | 25 | ifeq ($(strip $(BLUETOOTH_ENABLE)), yes) |
| 25 | LUFA_SRC += $(LUFA_DIR)/adafruit_ble.cpp | 26 | LUFA_SRC += $(LUFA_DIR)/bluetooth.c \ |
| 27 | $(TMK_DIR)/protocol/serial_uart.c | ||
| 26 | endif | 28 | endif |
| 27 | 29 | ||
| 28 | ifeq ($(strip $(BLUETOOTH_ENABLE)), yes) | 30 | ifeq ($(strip $(BLUETOOTH)), AdafruitBLE) |
| 31 | LUFA_SRC += $(LUFA_DIR)/adafruit_ble.cpp | ||
| 32 | endif | ||
| 33 | |||
| 34 | ifeq ($(strip $(BLUETOOTH)), AdafruitEZKey) | ||
| 29 | LUFA_SRC += $(LUFA_DIR)/bluetooth.c \ | 35 | LUFA_SRC += $(LUFA_DIR)/bluetooth.c \ |
| 30 | $(TMK_DIR)/protocol/serial_uart.c | 36 | $(TMK_DIR)/protocol/serial_uart.c |
| 31 | endif | 37 | endif |
| @@ -53,6 +59,7 @@ LUFA_OPTS += -DUSE_FLASH_DESCRIPTORS | |||
| 53 | LUFA_OPTS += -DUSE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)" | 59 | LUFA_OPTS += -DUSE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)" |
| 54 | #LUFA_OPTS += -DINTERRUPT_CONTROL_ENDPOINT | 60 | #LUFA_OPTS += -DINTERRUPT_CONTROL_ENDPOINT |
| 55 | LUFA_OPTS += -DFIXED_CONTROL_ENDPOINT_SIZE=8 | 61 | LUFA_OPTS += -DFIXED_CONTROL_ENDPOINT_SIZE=8 |
| 62 | LUFA_OPTS += -DFIXED_CONTROL_ENDPOINT_SIZE=8 | ||
| 56 | LUFA_OPTS += -DFIXED_NUM_CONFIGURATIONS=1 | 63 | LUFA_OPTS += -DFIXED_NUM_CONFIGURATIONS=1 |
| 57 | 64 | ||
| 58 | # Remote wakeup fix for ATmega32U2 https://github.com/tmk/tmk_keyboard/issues/361 | 65 | # Remote wakeup fix for ATmega32U2 https://github.com/tmk/tmk_keyboard/issues/361 |
diff --git a/tmk_core/protocol/lufa/adafruit_ble.h b/tmk_core/protocol/lufa/adafruit_ble.h index 351fd55ae..b3bab3ca0 100644 --- a/tmk_core/protocol/lufa/adafruit_ble.h +++ b/tmk_core/protocol/lufa/adafruit_ble.h | |||
| @@ -3,7 +3,7 @@ | |||
| 3 | * Supports the Adafruit BLE board built around the nRF51822 chip. | 3 | * Supports the Adafruit BLE board built around the nRF51822 chip. |
| 4 | */ | 4 | */ |
| 5 | #pragma once | 5 | #pragma once |
| 6 | #ifdef ADAFRUIT_BLE_ENABLE | 6 | #ifdef MODULE_ADAFRUIT_BLE |
| 7 | #include <stdbool.h> | 7 | #include <stdbool.h> |
| 8 | #include <stdint.h> | 8 | #include <stdint.h> |
| 9 | #include <string.h> | 9 | #include <string.h> |
| @@ -57,4 +57,4 @@ extern bool adafruit_ble_set_power_level(int8_t level); | |||
| 57 | } | 57 | } |
| 58 | #endif | 58 | #endif |
| 59 | 59 | ||
| 60 | #endif // ADAFRUIT_BLE_ENABLE | 60 | #endif // MODULE_ADAFRUIT_BLE |
diff --git a/tmk_core/protocol/lufa/lufa.c b/tmk_core/protocol/lufa/lufa.c index 6dd5959dc..60cba8d2a 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" |
| @@ -66,10 +67,11 @@ | |||
| 66 | #endif | 67 | #endif |
| 67 | 68 | ||
| 68 | #ifdef BLUETOOTH_ENABLE | 69 | #ifdef BLUETOOTH_ENABLE |
| 69 | #include "bluetooth.h" | 70 | #ifdef MODULE_ADAFRUIT_BLE |
| 70 | #endif | ||
| 71 | #ifdef ADAFRUIT_BLE_ENABLE | ||
| 72 | #include "adafruit_ble.h" | 71 | #include "adafruit_ble.h" |
| 72 | #else | ||
| 73 | #include "bluetooth.h" | ||
| 74 | #endif | ||
| 73 | #endif | 75 | #endif |
| 74 | 76 | ||
| 75 | #ifdef VIRTSER_ENABLE | 77 | #ifdef VIRTSER_ENABLE |
| @@ -589,59 +591,31 @@ void EVENT_USB_Device_ControlRequest(void) | |||
| 589 | 591 | ||
| 590 | /******************************************************************************* | 592 | /******************************************************************************* |
| 591 | * Host driver | 593 | * Host driver |
| 592 | p | ||
| 593 | ******************************************************************************/ | 594 | ******************************************************************************/ |
| 594 | static uint8_t keyboard_leds(void) | 595 | static uint8_t keyboard_leds(void) |
| 595 | { | 596 | { |
| 596 | return keyboard_led_stats; | 597 | return keyboard_led_stats; |
| 597 | } | 598 | } |
| 598 | 599 | ||
| 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) | 600 | static void send_keyboard(report_keyboard_t *report) |
| 627 | { | 601 | { |
| 628 | #ifdef BLUETOOTH_ENABLE | ||
| 629 | bluefruit_serial_send(0xFD); | ||
| 630 | for (uint8_t i = 0; i < KEYBOARD_EPSIZE; i++) { | ||
| 631 | bluefruit_serial_send(report->raw[i]); | ||
| 632 | } | ||
| 633 | #endif | ||
| 634 | |||
| 635 | uint8_t timeout = 255; | 602 | uint8_t timeout = 255; |
| 636 | uint8_t where = where_to_send(); | 603 | uint8_t where = where_to_send(); |
| 637 | 604 | ||
| 638 | #ifdef ADAFRUIT_BLE_ENABLE | 605 | #ifdef BLUETOOTH_ENABLE |
| 639 | if (where & SendToBLE) { | 606 | if (where == OUTPUT_BLUETOOTH || where == OUTPUT_USB_AND_BT) { |
| 607 | #ifdef MODULE_ADAFRUIT_BLE | ||
| 640 | adafruit_ble_send_keys(report->mods, report->keys, sizeof(report->keys)); | 608 | adafruit_ble_send_keys(report->mods, report->keys, sizeof(report->keys)); |
| 641 | } | 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 | } | ||
| 642 | #endif | 616 | #endif |
| 643 | 617 | ||
| 644 | if (!(where & SendToUSB)) { | 618 | if (where != OUTPUT_USB && where != OUTPUT_USB_AND_BT) { |
| 645 | return; | 619 | return; |
| 646 | } | 620 | } |
| 647 | 621 | ||
| @@ -681,30 +655,29 @@ static void send_keyboard(report_keyboard_t *report) | |||
| 681 | static void send_mouse(report_mouse_t *report) | 655 | static void send_mouse(report_mouse_t *report) |
| 682 | { | 656 | { |
| 683 | #ifdef MOUSE_ENABLE | 657 | #ifdef MOUSE_ENABLE |
| 684 | |||
| 685 | #ifdef BLUETOOTH_ENABLE | ||
| 686 | bluefruit_serial_send(0xFD); | ||
| 687 | bluefruit_serial_send(0x00); | ||
| 688 | bluefruit_serial_send(0x03); | ||
| 689 | bluefruit_serial_send(report->buttons); | ||
| 690 | bluefruit_serial_send(report->x); | ||
| 691 | bluefruit_serial_send(report->y); | ||
| 692 | bluefruit_serial_send(report->v); // should try sending the wheel v here | ||
| 693 | bluefruit_serial_send(report->h); // should try sending the wheel h here | ||
| 694 | bluefruit_serial_send(0x00); | ||
| 695 | #endif | ||
| 696 | |||
| 697 | uint8_t timeout = 255; | 658 | uint8_t timeout = 255; |
| 698 | |||
| 699 | uint8_t where = where_to_send(); | 659 | uint8_t where = where_to_send(); |
| 700 | 660 | ||
| 701 | #ifdef ADAFRUIT_BLE_ENABLE | 661 | #ifdef BLUETOOTH_ENABLE |
| 702 | if (where & SendToBLE) { | 662 | if (where == OUTPUT_BLUETOOTH || where == OUTPUT_USB_AND_BT) { |
| 663 | #ifdef MODULE_ADAFRUIT_BLE | ||
| 703 | // FIXME: mouse buttons | 664 | // FIXME: mouse buttons |
| 704 | 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); |
| 705 | } | 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 | } | ||
| 706 | #endif | 678 | #endif |
| 707 | if (!(where & SendToUSB)) { | 679 | |
| 680 | if (where != OUTPUT_USB && where != OUTPUT_USB_AND_BT) { | ||
| 708 | return; | 681 | return; |
| 709 | } | 682 | } |
| 710 | 683 | ||
| @@ -746,32 +719,32 @@ static void send_system(uint16_t data) | |||
| 746 | 719 | ||
| 747 | static void send_consumer(uint16_t data) | 720 | static void send_consumer(uint16_t data) |
| 748 | { | 721 | { |
| 749 | |||
| 750 | #ifdef BLUETOOTH_ENABLE | ||
| 751 | static uint16_t last_data = 0; | ||
| 752 | if (data == last_data) return; | ||
| 753 | last_data = data; | ||
| 754 | uint16_t bitmap = CONSUMER2BLUEFRUIT(data); | ||
| 755 | bluefruit_serial_send(0xFD); | ||
| 756 | bluefruit_serial_send(0x00); | ||
| 757 | bluefruit_serial_send(0x02); | ||
| 758 | bluefruit_serial_send((bitmap>>8)&0xFF); | ||
| 759 | bluefruit_serial_send(bitmap&0xFF); | ||
| 760 | bluefruit_serial_send(0x00); | ||
| 761 | bluefruit_serial_send(0x00); | ||
| 762 | bluefruit_serial_send(0x00); | ||
| 763 | bluefruit_serial_send(0x00); | ||
| 764 | #endif | ||
| 765 | |||
| 766 | uint8_t timeout = 255; | 722 | uint8_t timeout = 255; |
| 767 | uint8_t where = where_to_send(); | 723 | uint8_t where = where_to_send(); |
| 768 | 724 | ||
| 769 | #ifdef ADAFRUIT_BLE_ENABLE | 725 | #ifdef BLUETOOTH_ENABLE |
| 770 | if (where & SendToBLE) { | 726 | if (where == OUTPUT_BLUETOOTH || where == OUTPUT_USB_AND_BT) { |
| 771 | adafruit_ble_send_consumer_key(data, 0); | 727 | #ifdef MODULE_ADAFRUIT_BLE |
| 728 | adafruit_ble_send_consumer_key(data, 0); | ||
| 729 | #else | ||
| 730 | static uint16_t last_data = 0; | ||
| 731 | if (data == last_data) return; | ||
| 732 | last_data = data; | ||
| 733 | uint16_t bitmap = CONSUMER2BLUEFRUIT(data); | ||
| 734 | bluefruit_serial_send(0xFD); | ||
| 735 | bluefruit_serial_send(0x00); | ||
| 736 | bluefruit_serial_send(0x02); | ||
| 737 | bluefruit_serial_send((bitmap>>8)&0xFF); | ||
| 738 | bluefruit_serial_send(bitmap&0xFF); | ||
| 739 | bluefruit_serial_send(0x00); | ||
| 740 | bluefruit_serial_send(0x00); | ||
| 741 | bluefruit_serial_send(0x00); | ||
| 742 | bluefruit_serial_send(0x00); | ||
| 743 | #endif | ||
| 772 | } | 744 | } |
| 773 | #endif | 745 | #endif |
| 774 | if (!(where & SendToUSB)) { | 746 | |
| 747 | if (where != OUTPUT_USB && where != OUTPUT_USB_AND_BT) { | ||
| 775 | return; | 748 | return; |
| 776 | } | 749 | } |
| 777 | 750 | ||
| @@ -1123,16 +1096,23 @@ void cc_callback(MidiDevice * device, | |||
| 1123 | uint8_t chan, uint8_t num, uint8_t val); | 1096 | uint8_t chan, uint8_t num, uint8_t val); |
| 1124 | void sysex_callback(MidiDevice * device, | 1097 | void sysex_callback(MidiDevice * device, |
| 1125 | uint16_t start, uint8_t length, uint8_t * data); | 1098 | uint16_t start, uint8_t length, uint8_t * data); |
| 1099 | |||
| 1100 | void 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 | } | ||
| 1126 | #endif | 1109 | #endif |
| 1127 | 1110 | ||
| 1128 | int main(void) __attribute__ ((weak)); | 1111 | int main(void) __attribute__ ((weak)); |
| 1129 | int main(void) | 1112 | int main(void) |
| 1130 | { | 1113 | { |
| 1131 | |||
| 1132 | #ifdef MIDI_ENABLE | 1114 | #ifdef MIDI_ENABLE |
| 1133 | midi_device_init(&midi_device); | 1115 | setup_midi(); |
| 1134 | midi_device_set_send_func(&midi_device, usb_send_func); | ||
| 1135 | midi_device_set_pre_input_process_func(&midi_device, usb_get_midi); | ||
| 1136 | #endif | 1116 | #endif |
| 1137 | 1117 | ||
| 1138 | setup_mcu(); | 1118 | setup_mcu(); |
| @@ -1152,7 +1132,7 @@ int main(void) | |||
| 1152 | // midi_send_noteoff(&midi_device, 0, 64, 127); | 1132 | // midi_send_noteoff(&midi_device, 0, 64, 127); |
| 1153 | #endif | 1133 | #endif |
| 1154 | 1134 | ||
| 1155 | #ifdef BLUETOOTH_ENABLE | 1135 | #ifdef MODULE_ADAFRUIT_EZKEY |
| 1156 | serial_init(); | 1136 | serial_init(); |
| 1157 | #endif | 1137 | #endif |
| 1158 | 1138 | ||
| @@ -1183,7 +1163,7 @@ int main(void) | |||
| 1183 | 1163 | ||
| 1184 | print("Keyboard start.\n"); | 1164 | print("Keyboard start.\n"); |
| 1185 | while (1) { | 1165 | while (1) { |
| 1186 | #if !defined(BLUETOOTH_ENABLE) && !defined(ADAFRUIT_BLE_ENABLE) | 1166 | #if !defined(BLUETOOTH_ENABLE) |
| 1187 | while (USB_DeviceState == DEVICE_STATE_Suspended) { | 1167 | while (USB_DeviceState == DEVICE_STATE_Suspended) { |
| 1188 | print("[s]"); | 1168 | print("[s]"); |
| 1189 | suspend_power_down(); | 1169 | suspend_power_down(); |
| @@ -1197,14 +1177,16 @@ int main(void) | |||
| 1197 | 1177 | ||
| 1198 | #ifdef MIDI_ENABLE | 1178 | #ifdef MIDI_ENABLE |
| 1199 | midi_device_process(&midi_device); | 1179 | midi_device_process(&midi_device); |
| 1200 | // MIDI_Task(); | 1180 | #ifdef MIDI_ADVANCED |
| 1181 | midi_task(); | ||
| 1182 | #endif | ||
| 1201 | #endif | 1183 | #endif |
| 1202 | 1184 | ||
| 1203 | #if defined(RGBLIGHT_ANIMATIONS) & defined(RGBLIGHT_ENABLE) | 1185 | #if defined(RGBLIGHT_ANIMATIONS) & defined(RGBLIGHT_ENABLE) |
| 1204 | rgblight_task(); | 1186 | rgblight_task(); |
| 1205 | #endif | 1187 | #endif |
| 1206 | 1188 | ||
| 1207 | #ifdef ADAFRUIT_BLE_ENABLE | 1189 | #ifdef MODULE_ADAFRUIT_BLE |
| 1208 | adafruit_ble_task(); | 1190 | adafruit_ble_task(); |
| 1209 | #endif | 1191 | #endif |
| 1210 | 1192 | ||
diff --git a/tmk_core/protocol/lufa/lufa.h b/tmk_core/protocol/lufa/lufa.h index a049fd43c..a51573786 100644 --- a/tmk_core/protocol/lufa/lufa.h +++ b/tmk_core/protocol/lufa/lufa.h | |||
| @@ -49,7 +49,7 @@ | |||
| 49 | #include <LUFA/Drivers/USB/USB.h> | 49 | #include <LUFA/Drivers/USB/USB.h> |
| 50 | #include "host.h" | 50 | #include "host.h" |
| 51 | #ifdef MIDI_ENABLE | 51 | #ifdef MIDI_ENABLE |
| 52 | #include "midi.h" | 52 | #include "process_midi.h" |
| 53 | #endif | 53 | #endif |
| 54 | #ifdef __cplusplus | 54 | #ifdef __cplusplus |
| 55 | extern "C" { | 55 | extern "C" { |
diff --git a/tmk_core/protocol/lufa/outputselect.c b/tmk_core/protocol/lufa/outputselect.c new file mode 100644 index 000000000..0df5d3b75 --- /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 MODULE_ADAFRUIT_BLE | ||
| 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 MODULE_ADAFRUIT_BLE | ||
| 38 | if (adafruit_ble_is_connected()) { | ||
| 39 | return OUTPUT_BLUETOOTH; | ||
| 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..28cc3298e --- /dev/null +++ b/tmk_core/protocol/lufa/outputselect.h | |||
| @@ -0,0 +1,40 @@ | |||
| 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 | |||
| 22 | // backward compatibility | ||
| 23 | OUTPUT_USB_AND_BT | ||
| 24 | }; | ||
| 25 | |||
| 26 | /** | ||
| 27 | * backward compatibility for BLUETOOTH_ENABLE, send to BT and USB by default | ||
| 28 | */ | ||
| 29 | #ifndef OUTPUT_DEFAULT | ||
| 30 | #ifdef BLUETOOTH_ENABLE | ||
| 31 | #define OUTPUT_DEFAULT OUTPUT_USB_AND_BT | ||
| 32 | #else | ||
| 33 | #define OUTPUT_DEFAULT OUTPUT_AUTO | ||
| 34 | #endif | ||
| 35 | #endif | ||
| 36 | |||
| 37 | void set_output(uint8_t output); | ||
| 38 | void set_output_user(uint8_t output); | ||
| 39 | uint8_t auto_detect_output(void); | ||
| 40 | 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) |
