diff options
Diffstat (limited to 'common')
-rw-r--r-- | common/action.c | 10 | ||||
-rw-r--r-- | common/action_code.h | 3 | ||||
-rw-r--r-- | common/avr/xprintf.h | 8 | ||||
-rw-r--r-- | common/debug.c | 24 | ||||
-rw-r--r-- | common/debug.h | 2 | ||||
-rw-r--r-- | common/debug_config.h | 51 | ||||
-rw-r--r-- | common/keyboard.c | 11 |
7 files changed, 107 insertions, 2 deletions
diff --git a/common/action.c b/common/action.c index 94498fe6cb..ec8eeae7bc 100644 --- a/common/action.c +++ b/common/action.c @@ -237,6 +237,16 @@ void process_action(keyrecord_t *record) case ACT_LAYER_TAP: case ACT_LAYER_TAP_EXT: switch (action.layer_tap.code) { + case 0xe0 ... 0xef: + /* layer On/Off with modifiers(left only) */ + if (event.pressed) { + layer_on(action.layer_tap.val); + register_mods(action.layer_tap.code & 0x0f); + } else { + layer_off(action.layer_tap.val); + unregister_mods(action.layer_tap.code & 0x0f); + } + break; case OP_TAP_TOGGLE: /* tap toggle */ if (event.pressed) { diff --git a/common/action_code.h b/common/action_code.h index 50112d4d20..bc40e2c6fb 100644 --- a/common/action_code.h +++ b/common/action_code.h @@ -71,7 +71,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. * * ACT_LAYER_TAP(101x): * 101E|LLLL| keycode On/Off with tap key - * 101E|LLLL|1110 xxxx Reserved(0xE0-EF) + * 101E|LLLL|1110 mods On/Off with modifiers(0xE0-EF) * 101E|LLLL|1111 0000 Invert with tap toggle(0xF0) * 101E|LLLL|1111 0001 On/Off * 101E|LLLL|1111 0010 Off/On @@ -266,6 +266,7 @@ enum layer_pram_tap_op { #define ACTION_LAYER_ON_OFF(layer) ACTION_LAYER_TAP((layer), OP_ON_OFF) #define ACTION_LAYER_OFF_ON(layer) ACTION_LAYER_TAP((layer), OP_OFF_ON) #define ACTION_LAYER_SET_CLEAR(layer) ACTION_LAYER_TAP((layer), OP_SET_CLEAR) +#define ACTION_LAYER_MODS(layer, mods) ACTION_LAYER_TAP((layer), 0xe0 | (mods)&0x0f) /* With Tapping */ #define ACTION_LAYER_TAP_KEY(layer, key) ACTION_LAYER_TAP((layer), (key)) #define ACTION_LAYER_TAP_TOGGLE(layer) ACTION_LAYER_TAP((layer), OP_TAP_TOGGLE) diff --git a/common/avr/xprintf.h b/common/avr/xprintf.h index f58bca817b..59c6f25312 100644 --- a/common/avr/xprintf.h +++ b/common/avr/xprintf.h @@ -8,6 +8,10 @@ #include <inttypes.h>
#include <avr/pgmspace.h>
+#ifdef __cplusplus
+extern "C" {
+#endif
+
extern void (*xfunc_out)(uint8_t);
#define xdev_out(func) xfunc_out = (void(*)(uint8_t))(func)
@@ -99,5 +103,9 @@ char xatoi(char **str, long *ret); Pointer to return value
*/
+#ifdef __cplusplus
+}
+#endif
+
#endif
diff --git a/common/debug.c b/common/debug.c new file mode 100644 index 0000000000..18613fc28b --- /dev/null +++ b/common/debug.c @@ -0,0 +1,24 @@ +#include <stdbool.h> +#include "debug.h" + +#define GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) + +debug_config_t debug_config = { +/* GCC Bug 10676 - Using unnamed fields in initializers + * https://gcc.gnu.org/bugzilla/show_bug.cgi?id=10676 */ +#if GCC_VERSION >= 40600 + .enable = false, + .matrix = false, + .keyboard = false, + .mouse = false, + .reserved = 0 +#else + { + false, // .enable + false, // .matrix + false, // .keyboard + false, // .mouse + 0 // .reserved + } +#endif +}; diff --git a/common/debug.h b/common/debug.h index 26472c8fa3..472dd478c4 100644 --- a/common/debug.h +++ b/common/debug.h @@ -29,7 +29,6 @@ extern "C" { #endif typedef union { - uint8_t raw; struct { bool enable:1; bool matrix:1; @@ -37,6 +36,7 @@ typedef union { bool mouse:1; uint8_t reserved:4; }; + uint8_t raw; } debug_config_t; extern debug_config_t debug_config; diff --git a/common/debug_config.h b/common/debug_config.h new file mode 100644 index 0000000000..28bc34cd57 --- /dev/null +++ b/common/debug_config.h @@ -0,0 +1,51 @@ +/* +Copyright 2013 Jun Wako <wakojun@gmail.com> + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +#ifndef DEBUG_CONFIG_H +#define DEBUG_CONFIG_H 1 + +#include <stdbool.h> + + +#ifdef __cplusplus +extern "C" { +#endif + +/* NOTE: Not portable. Bit field order depends on implementation */ +typedef union { + struct { + bool enable:1; + bool matrix:1; + bool keyboard:1; + bool mouse:1; + uint8_t reserved:4; + }; + uint8_t raw; +} debug_config_t; +extern debug_config_t debug_config; + +/* for backward compatibility */ +#define debug_enable (debug_config.enable) +#define debug_matrix (debug_config.matrix) +#define debug_keyboard (debug_config.keyboard) +#define debug_mouse (debug_config.mouse) + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/common/keyboard.c b/common/keyboard.c index 9a809ff4a1..1e3fb510a4 100644 --- a/common/keyboard.c +++ b/common/keyboard.c @@ -36,6 +36,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #ifdef PS2_MOUSE_ENABLE # include "ps2_mouse.h" #endif +#ifdef SERIAL_MOUSE_ENABLE +#include "serial_mouse.h" +#endif #ifdef MATRIX_HAS_GHOST @@ -63,6 +66,10 @@ void keyboard_init(void) #ifdef PS2_MOUSE_ENABLE ps2_mouse_init(); #endif +#ifdef SERIAL_MOUSE_ENABLE + serial_mouse_init(); +#endif + #ifdef BOOTMAGIC_ENABLE bootmagic(); @@ -125,6 +132,10 @@ MATRIX_LOOP_END: ps2_mouse_task(); #endif +#ifdef SERIAL_MOUSE_ENABLE + serial_mouse_task(); +#endif + // update LED if (led_status != host_keyboard_leds()) { led_status = host_keyboard_leds(); |