diff options
Diffstat (limited to 'common')
| -rw-r--r-- | common/action.c | 12 | ||||
| -rw-r--r-- | common/action_code.h | 6 | ||||
| -rw-r--r-- | common/action_macro.c | 30 | ||||
| -rw-r--r-- | common/action_macro.h | 96 | ||||
| -rw-r--r-- | common/keycode.h | 2 |
5 files changed, 73 insertions, 73 deletions
diff --git a/common/action.c b/common/action.c index a42a7a4ae..c22f681fb 100644 --- a/common/action.c +++ b/common/action.c | |||
| @@ -373,6 +373,12 @@ void register_code(uint8_t code) | |||
| 373 | host_add_mods(MOD_BIT(code)); | 373 | host_add_mods(MOD_BIT(code)); |
| 374 | host_send_keyboard_report(); | 374 | host_send_keyboard_report(); |
| 375 | } | 375 | } |
| 376 | else if IS_SYSTEM(code) { | ||
| 377 | host_system_send(KEYCODE2SYSTEM(code)); | ||
| 378 | } | ||
| 379 | else if IS_CONSUMER(code) { | ||
| 380 | host_consumer_send(KEYCODE2CONSUMER(code)); | ||
| 381 | } | ||
| 376 | } | 382 | } |
| 377 | 383 | ||
| 378 | void unregister_code(uint8_t code) | 384 | void unregister_code(uint8_t code) |
| @@ -400,6 +406,12 @@ void unregister_code(uint8_t code) | |||
| 400 | host_del_mods(MOD_BIT(code)); | 406 | host_del_mods(MOD_BIT(code)); |
| 401 | host_send_keyboard_report(); | 407 | host_send_keyboard_report(); |
| 402 | } | 408 | } |
| 409 | else if IS_SYSTEM(code) { | ||
| 410 | host_system_send(0); | ||
| 411 | } | ||
| 412 | else if IS_CONSUMER(code) { | ||
| 413 | host_consumer_send(0); | ||
| 414 | } | ||
| 403 | } | 415 | } |
| 404 | 416 | ||
| 405 | void add_mods(uint8_t mods) | 417 | void add_mods(uint8_t mods) |
diff --git a/common/action_code.h b/common/action_code.h index df6ce9998..45e974a66 100644 --- a/common/action_code.h +++ b/common/action_code.h | |||
| @@ -33,9 +33,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 33 | * r: Left/Right flag(Left:0, Right:1) | 33 | * r: Left/Right flag(Left:0, Right:1) |
| 34 | * | 34 | * |
| 35 | * ACT_MODS_TAP(001r): | 35 | * ACT_MODS_TAP(001r): |
| 36 | * 0010|mods|0000 0000 Modifiers with OneShot | 36 | * 001r|mods|0000 0000 Modifiers with OneShot |
| 37 | * 0010|mods|0000 00xx (reserved) | 37 | * 001r|mods|0000 00xx (reserved) |
| 38 | * 0010|mods| keycode Modifiers with Tap Key | 38 | * 001r|mods| keycode Modifiers with Tap Key |
| 39 | * | 39 | * |
| 40 | * | 40 | * |
| 41 | * Other Keys(01xx) | 41 | * Other Keys(01xx) |
diff --git a/common/action_macro.c b/common/action_macro.c index 29cfd23df..cc7ac18a0 100644 --- a/common/action_macro.c +++ b/common/action_macro.c | |||
| @@ -36,31 +36,31 @@ void action_macro_play(const macro_t *macro_p) | |||
| 36 | if (!macro_p) return; | 36 | if (!macro_p) return; |
| 37 | while (true) { | 37 | while (true) { |
| 38 | switch (MACRO_READ()) { | 38 | switch (MACRO_READ()) { |
| 39 | case INTERVAL: | 39 | case KEY_DOWN: |
| 40 | interval = MACRO_READ(); | ||
| 41 | debug("INTERVAL("); debug_dec(interval); debug(")\n"); | ||
| 42 | break; | ||
| 43 | case WAIT: | ||
| 44 | MACRO_READ(); | 40 | MACRO_READ(); |
| 45 | debug("WAIT("); debug_dec(macro); debug(")\n"); | 41 | dprintf("KEY_DOWN(%02X)\n", macro); |
| 46 | { uint8_t ms = macro; while (ms--) _delay_ms(1); } | 42 | register_code(macro); |
| 47 | break; | 43 | break; |
| 48 | case MODS_DOWN: | 44 | case KEY_UP: |
| 49 | MACRO_READ(); | 45 | MACRO_READ(); |
| 50 | debug("MODS_DOWN("); debug_hex(macro); debug(")\n"); | 46 | dprintf("KEY_UP(%02X)\n", macro); |
| 51 | add_mods(macro); | 47 | unregister_code(macro); |
| 52 | break; | 48 | break; |
| 53 | case MODS_UP: | 49 | case WAIT: |
| 54 | MACRO_READ(); | 50 | MACRO_READ(); |
| 55 | debug("MODS_UP("); debug_hex(macro); debug(")\n"); | 51 | dprintf("WAIT(%u)\n", macro); |
| 56 | del_mods(macro); | 52 | { uint8_t ms = macro; while (ms--) _delay_ms(1); } |
| 53 | break; | ||
| 54 | case INTERVAL: | ||
| 55 | interval = MACRO_READ(); | ||
| 56 | dprintf("INTERVAL(%u)\n", interval); | ||
| 57 | break; | 57 | break; |
| 58 | case 0x04 ... 0x73: | 58 | case 0x04 ... 0x73: |
| 59 | debug("DOWN("); debug_hex(macro); debug(")\n"); | 59 | dprintf("DOWN(%02X)\n", macro); |
| 60 | register_code(macro); | 60 | register_code(macro); |
| 61 | break; | 61 | break; |
| 62 | case 0x84 ... 0xF3: | 62 | case 0x84 ... 0xF3: |
| 63 | debug("UP("); debug_hex(macro); debug(")\n"); | 63 | dprintf("UP(%02X)\n", macro); |
| 64 | unregister_code(macro&0x7F); | 64 | unregister_code(macro&0x7F); |
| 65 | break; | 65 | break; |
| 66 | case END: | 66 | case END: |
diff --git a/common/action_macro.h b/common/action_macro.h index eea8ef57d..621826308 100644 --- a/common/action_macro.h +++ b/common/action_macro.h | |||
| @@ -35,80 +35,68 @@ void action_macro_play(const macro_t *macro_p); | |||
| 35 | 35 | ||
| 36 | 36 | ||
| 37 | 37 | ||
| 38 | /* TODO: NOT FINISHED | 38 | /* Macro commands |
| 39 | normal mode command: | 39 | * code(0x04-73) // key down(1byte) |
| 40 | key(down): 0x04-7f/73(F24) | 40 | * code(0x04-73) | 0x80 // key up(1byte) |
| 41 | key(up): 0x84-ff | 41 | * { KEY_DOWN, code(0x04-0xff) } // key down(2bytes) |
| 42 | command: 0x00-03, 0x80-83(0x74-7f, 0xf4-ff) | 42 | * { KEY_UP, code(0x04-0xff) } // key up(2bytes) |
| 43 | mods down 0x00 | 43 | * WAIT // wait milli-seconds |
| 44 | mods up 0x01 | 44 | * INTERVAL // set interval between macro commands |
| 45 | wait 0x02 | 45 | * END // stop macro execution |
| 46 | interval 0x03 | 46 | * |
| 47 | extkey down 0x80 | 47 | * Ideas(Not implemented): |
| 48 | extkey up 0x81 | 48 | * modifiers |
| 49 | ext commad 0x82 | 49 | * system usage |
| 50 | ext mode 0x83 | 50 | * consumer usage |
| 51 | end 0xff | 51 | * unicode usage |
| 52 | 52 | * function call | |
| 53 | extension mode command: NOT IMPLEMENTED | 53 | * conditionals |
| 54 | key down 0x00 | 54 | * loop |
| 55 | key up 0x01 | 55 | */ |
| 56 | key down + wait | ||
| 57 | key up + wait | ||
| 58 | mods push | ||
| 59 | mods pop | ||
| 60 | wait | ||
| 61 | interval | ||
| 62 | if | ||
| 63 | loop | ||
| 64 | push | ||
| 65 | pop | ||
| 66 | all up | ||
| 67 | end | ||
| 68 | */ | ||
| 69 | enum macro_command_id{ | 56 | enum macro_command_id{ |
| 70 | /* 0x00 - 0x03 */ | 57 | /* 0x00 - 0x03 */ |
| 71 | END = 0x00, | 58 | END = 0x00, |
| 72 | MODS_DOWN = 0x01, | 59 | KEY_DOWN, |
| 73 | MODS_UP = 0x02, | 60 | KEY_UP, |
| 74 | MODS_SET, | 61 | |
| 75 | MODS_PUSH, | 62 | /* 0x04 - 0x73 (reserved for keycode down) */ |
| 76 | MODS_POP, | ||
| 77 | 63 | ||
| 64 | /* 0x74 - 0x83 */ | ||
| 78 | WAIT = 0x74, | 65 | WAIT = 0x74, |
| 79 | INTERVAL, | 66 | INTERVAL, |
| 80 | /* 0x74 - 0x7f */ | ||
| 81 | /* 0x80 - 0x84 */ | ||
| 82 | 67 | ||
| 83 | EXT_DOWN, | 68 | /* 0x84 - 0xf3 (reserved for keycode up) */ |
| 84 | EXT_UP, | ||
| 85 | EXT_WAIT, | ||
| 86 | EXT_INTERVAL, | ||
| 87 | COMPRESSION_MODE, | ||
| 88 | 69 | ||
| 89 | EXTENSION_MODE = 0xff, | 70 | /* 0xf4 - 0xff */ |
| 90 | }; | 71 | }; |
| 91 | 72 | ||
| 92 | 73 | ||
| 93 | /* normal mode */ | 74 | /* TODO: keycode:0x04-0x73 can be handled by 1byte command else 2bytes are needed |
| 94 | #define DOWN(key) (key) | 75 | * if keycode between 0x04 and 0x73 |
| 95 | #define UP(key) ((key) | 0x80) | 76 | * keycode / (keycode|0x80) |
| 96 | #define TYPE(key) (key), (key | 0x80) | 77 | * else |
| 97 | #define MODS_DOWN(mods) MODS_DOWN, (mods) | 78 | * {KEY_DOWN, keycode} / {KEY_UP, keycode} |
| 98 | #define MODS_UP(mods) MODS_UP, (mods) | 79 | */ |
| 80 | #define DOWN(key) KEY_DOWN, (key) | ||
| 81 | #define UP(key) KEY_UP, (key) | ||
| 82 | #define TYPE(key) DOWN(key), UP(key) | ||
| 99 | #define WAIT(ms) WAIT, (ms) | 83 | #define WAIT(ms) WAIT, (ms) |
| 100 | #define INTERVAL(ms) INTERVAL, (ms) | 84 | #define INTERVAL(ms) INTERVAL, (ms) |
| 101 | 85 | ||
| 86 | /* key down */ | ||
| 102 | #define D(key) DOWN(KC_##key) | 87 | #define D(key) DOWN(KC_##key) |
| 88 | /* key up */ | ||
| 103 | #define U(key) UP(KC_##key) | 89 | #define U(key) UP(KC_##key) |
| 90 | /* key type */ | ||
| 104 | #define T(key) TYPE(KC_##key) | 91 | #define T(key) TYPE(KC_##key) |
| 105 | #define MD(key) MODS_DOWN(MOD_BIT(KC_##key)) | 92 | /* wait */ |
| 106 | #define MU(key) MODS_UP(MOD_BIT(KC_##key)) | ||
| 107 | #define W(ms) WAIT(ms) | 93 | #define W(ms) WAIT(ms) |
| 94 | /* interval */ | ||
| 108 | #define I(ms) INTERVAL(ms) | 95 | #define I(ms) INTERVAL(ms) |
| 109 | 96 | ||
| 110 | 97 | /* for backward comaptibility */ | |
| 111 | /* extension mode */ | 98 | #define MD(key) DOWN(KC_##key) |
| 99 | #define MU(key) UP(KC_##key) | ||
| 112 | 100 | ||
| 113 | 101 | ||
| 114 | #endif /* ACTION_MACRO_H */ | 102 | #endif /* ACTION_MACRO_H */ |
diff --git a/common/keycode.h b/common/keycode.h index acbec07d2..77d5b79ba 100644 --- a/common/keycode.h +++ b/common/keycode.h | |||
| @@ -30,7 +30,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 30 | 30 | ||
| 31 | 31 | ||
| 32 | #define IS_SPECIAL(code) ((0xA5 <= (code) && (code) <= 0xDF) || (0xE8 <= (code) && (code) <= 0xFF)) | 32 | #define IS_SPECIAL(code) ((0xA5 <= (code) && (code) <= 0xDF) || (0xE8 <= (code) && (code) <= 0xFF)) |
| 33 | #define IS_SYSTEM(code) (KC_POWER <= (code) && (code) <= KC_WAKE) | 33 | #define IS_SYSTEM(code) (KC_PWR <= (code) && (code) <= KC_WAKE) |
| 34 | #define IS_CONSUMER(code) (KC_MUTE <= (code) && (code) <= KC_WFAV) | 34 | #define IS_CONSUMER(code) (KC_MUTE <= (code) && (code) <= KC_WFAV) |
| 35 | #define IS_FN(code) (KC_FN0 <= (code) && (code) <= KC_FN31) | 35 | #define IS_FN(code) (KC_FN0 <= (code) && (code) <= KC_FN31) |
| 36 | #define IS_MOUSEKEY(code) (KC_MS_UP <= (code) && (code) <= KC_MS_ACCEL2) | 36 | #define IS_MOUSEKEY(code) (KC_MS_UP <= (code) && (code) <= KC_MS_ACCEL2) |
