diff options
Diffstat (limited to 'hhkb/keymap.c')
| -rw-r--r-- | hhkb/keymap.c | 22 |
1 files changed, 6 insertions, 16 deletions
diff --git a/hhkb/keymap.c b/hhkb/keymap.c index f5386b722..ca78200c0 100644 --- a/hhkb/keymap.c +++ b/hhkb/keymap.c | |||
| @@ -1,14 +1,16 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * Keymap for PFU HHKB Pro | 2 | * Keymap for PFU HHKB Pro |
| 3 | */ | 3 | */ |
| 4 | #include <stdint.h> | ||
| 4 | #include <stdbool.h> | 5 | #include <stdbool.h> |
| 5 | #include <avr/pgmspace.h> | 6 | #include <avr/pgmspace.h> |
| 6 | #include "usb_keyboard.h" | 7 | #include "usb_keyboard.h" |
| 7 | #include "usb_keycodes.h" | 8 | #include "usb_keycodes.h" |
| 8 | #include "matrix.h" | 9 | #include "matrix.h" |
| 9 | #include "keymap.h" | ||
| 10 | #include "print.h" | 10 | #include "print.h" |
| 11 | #include "debug.h" | 11 | #include "debug.h" |
| 12 | #include "util.h" | ||
| 13 | #include "keymap.h" | ||
| 12 | 14 | ||
| 13 | 15 | ||
| 14 | #define FN_KEYCODE(fn) (pgm_read_byte(&fn_keycode[(fn)])) | 16 | #define FN_KEYCODE(fn) (pgm_read_byte(&fn_keycode[(fn)])) |
| @@ -33,9 +35,6 @@ | |||
| 33 | } | 35 | } |
| 34 | 36 | ||
| 35 | 37 | ||
| 36 | static int onbit(uint8_t bits); | ||
| 37 | |||
| 38 | |||
| 39 | static int current_layer = 0; | 38 | static int current_layer = 0; |
| 40 | static bool layer_used = false; | 39 | static bool layer_used = false; |
| 41 | 40 | ||
| @@ -104,7 +103,7 @@ static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | |||
| 104 | * |-----------------------------------------------------------| | 103 | * |-----------------------------------------------------------| |
| 105 | * |Shift | | | | | | | | | | |Shift | | | 104 | * |Shift | | | | | | | | | | |Shift | | |
| 106 | * `-----------------------------------------------------------' | 105 | * `-----------------------------------------------------------' |
| 107 | * |Gui|Alt |Sapce |Alt |Gui| | 106 | * |Gui|Alt |Space |Alt |Gui| |
| 108 | * `-------------------------------------------' | 107 | * `-------------------------------------------' |
| 109 | */ | 108 | */ |
| 110 | KEYMAP(KB_ESC, KB_F1, KB_F2, KB_F3, KB_F4, KB_F5, KB_F6, KB_F7, KB_F8, KB_F9, KB_F10, KB_F11, KB_F12, KB_INS, KB_DEL, \ | 109 | KEYMAP(KB_ESC, KB_F1, KB_F2, KB_F3, KB_F4, KB_F5, KB_F6, KB_F7, KB_F8, KB_F9, KB_F10, KB_F11, KB_F12, KB_INS, KB_DEL, \ |
| @@ -199,7 +198,7 @@ void keymap_fn_proc(int fn_bits) | |||
| 199 | } else if (fn_bits == 0) { | 198 | } else if (fn_bits == 0) { |
| 200 | // send key when Fn key is released without using the layer | 199 | // send key when Fn key is released without using the layer |
| 201 | if (!layer_used) { | 200 | if (!layer_used) { |
| 202 | uint8_t code = FN_KEYCODE(onbit(last_bits)); | 201 | uint8_t code = FN_KEYCODE(biton(last_bits)); |
| 203 | if (code != KB_NO) { | 202 | if (code != KB_NO) { |
| 204 | if (IS_MOD(code)) { | 203 | if (IS_MOD(code)) { |
| 205 | keyboard_modifier_keys = last_mod | 1<<(code & 0x07); | 204 | keyboard_modifier_keys = last_mod | 1<<(code & 0x07); |
| @@ -221,18 +220,9 @@ void keymap_fn_proc(int fn_bits) | |||
| 221 | last_bits = fn_bits; | 220 | last_bits = fn_bits; |
| 222 | last_mod = keyboard_modifier_keys; | 221 | last_mod = keyboard_modifier_keys; |
| 223 | layer_used = false; | 222 | layer_used = false; |
| 224 | keymap_set_layer(FN_LAYER(onbit(fn_bits))); | 223 | keymap_set_layer(FN_LAYER(biton(fn_bits))); |
| 225 | debug("layer: "); phex(current_layer); debug("("); | 224 | debug("layer: "); phex(current_layer); debug("("); |
| 226 | debug_bin(last_bits); debug(")\n"); | 225 | debug_bin(last_bits); debug(")\n"); |
| 227 | debug("last_mod: "); debug_hex(last_mod); debug("\n"); | 226 | debug("last_mod: "); debug_hex(last_mod); debug("\n"); |
| 228 | } | 227 | } |
| 229 | } | 228 | } |
| 230 | |||
| 231 | static int onbit(uint8_t bits) | ||
| 232 | { | ||
| 233 | int n = 0; | ||
| 234 | if (bits >> 4) { bits >>= 4; n += 4;} | ||
| 235 | if (bits >> 2) { bits >>= 2; n += 2;} | ||
| 236 | if (bits >> 1) { bits >>= 1; n += 1;} | ||
| 237 | return n; | ||
| 238 | } | ||
