1
0

Merge branch 'macro_mediakey'(Fix issue #42)

This commit is contained in:
tmk 2013-07-23 07:54:14 +09:00
commit b52dc89a81
6 changed files with 77 additions and 79 deletions

View File

@ -373,6 +373,12 @@ void register_code(uint8_t code)
host_add_mods(MOD_BIT(code)); host_add_mods(MOD_BIT(code));
host_send_keyboard_report(); host_send_keyboard_report();
} }
else if IS_SYSTEM(code) {
host_system_send(KEYCODE2SYSTEM(code));
}
else if IS_CONSUMER(code) {
host_consumer_send(KEYCODE2CONSUMER(code));
}
} }
void unregister_code(uint8_t code) void unregister_code(uint8_t code)
@ -400,6 +406,12 @@ void unregister_code(uint8_t code)
host_del_mods(MOD_BIT(code)); host_del_mods(MOD_BIT(code));
host_send_keyboard_report(); host_send_keyboard_report();
} }
else if IS_SYSTEM(code) {
host_system_send(0);
}
else if IS_CONSUMER(code) {
host_consumer_send(0);
}
} }
void add_mods(uint8_t mods) void add_mods(uint8_t mods)

View File

@ -33,9 +33,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
* r: Left/Right flag(Left:0, Right:1) * r: Left/Right flag(Left:0, Right:1)
* *
* ACT_MODS_TAP(001r): * ACT_MODS_TAP(001r):
* 0010|mods|0000 0000 Modifiers with OneShot * 001r|mods|0000 0000 Modifiers with OneShot
* 0010|mods|0000 00xx (reserved) * 001r|mods|0000 00xx (reserved)
* 0010|mods| keycode Modifiers with Tap Key * 001r|mods| keycode Modifiers with Tap Key
* *
* *
* Other Keys(01xx) * Other Keys(01xx)

View File

@ -36,31 +36,31 @@ void action_macro_play(const macro_t *macro_p)
if (!macro_p) return; if (!macro_p) return;
while (true) { while (true) {
switch (MACRO_READ()) { switch (MACRO_READ()) {
case INTERVAL: case KEY_DOWN:
interval = MACRO_READ(); MACRO_READ();
debug("INTERVAL("); debug_dec(interval); debug(")\n"); dprintf("KEY_DOWN(%02X)\n", macro);
register_code(macro);
break;
case KEY_UP:
MACRO_READ();
dprintf("KEY_UP(%02X)\n", macro);
unregister_code(macro);
break; break;
case WAIT: case WAIT:
MACRO_READ(); MACRO_READ();
debug("WAIT("); debug_dec(macro); debug(")\n"); dprintf("WAIT(%u)\n", macro);
{ uint8_t ms = macro; while (ms--) _delay_ms(1); } { uint8_t ms = macro; while (ms--) _delay_ms(1); }
break; break;
case MODS_DOWN: case INTERVAL:
MACRO_READ(); interval = MACRO_READ();
debug("MODS_DOWN("); debug_hex(macro); debug(")\n"); dprintf("INTERVAL(%u)\n", interval);
add_mods(macro);
break;
case MODS_UP:
MACRO_READ();
debug("MODS_UP("); debug_hex(macro); debug(")\n");
del_mods(macro);
break; break;
case 0x04 ... 0x73: case 0x04 ... 0x73:
debug("DOWN("); debug_hex(macro); debug(")\n"); dprintf("DOWN(%02X)\n", macro);
register_code(macro); register_code(macro);
break; break;
case 0x84 ... 0xF3: case 0x84 ... 0xF3:
debug("UP("); debug_hex(macro); debug(")\n"); dprintf("UP(%02X)\n", macro);
unregister_code(macro&0x7F); unregister_code(macro&0x7F);
break; break;
case END: case END:

View File

@ -35,80 +35,68 @@ void action_macro_play(const macro_t *macro_p);
/* TODO: NOT FINISHED /* Macro commands
normal mode command: * code(0x04-73) // key down(1byte)
key(down): 0x04-7f/73(F24) * code(0x04-73) | 0x80 // key up(1byte)
key(up): 0x84-ff * { KEY_DOWN, code(0x04-0xff) } // key down(2bytes)
command: 0x00-03, 0x80-83(0x74-7f, 0xf4-ff) * { KEY_UP, code(0x04-0xff) } // key up(2bytes)
mods down 0x00 * WAIT // wait milli-seconds
mods up 0x01 * INTERVAL // set interval between macro commands
wait 0x02 * END // stop macro execution
interval 0x03 *
extkey down 0x80 * Ideas(Not implemented):
extkey up 0x81 * modifiers
ext commad 0x82 * system usage
ext mode 0x83 * consumer usage
end 0xff * unicode usage
* function call
extension mode command: NOT IMPLEMENTED * conditionals
key down 0x00 * loop
key up 0x01 */
key down + wait
key up + wait
mods push
mods pop
wait
interval
if
loop
push
pop
all up
end
*/
enum macro_command_id{ enum macro_command_id{
/* 0x00 - 0x03 */ /* 0x00 - 0x03 */
END = 0x00, END = 0x00,
MODS_DOWN = 0x01, KEY_DOWN,
MODS_UP = 0x02, KEY_UP,
MODS_SET,
MODS_PUSH,
MODS_POP,
/* 0x04 - 0x73 (reserved for keycode down) */
/* 0x74 - 0x83 */
WAIT = 0x74, WAIT = 0x74,
INTERVAL, INTERVAL,
/* 0x74 - 0x7f */
/* 0x80 - 0x84 */
EXT_DOWN, /* 0x84 - 0xf3 (reserved for keycode up) */
EXT_UP,
EXT_WAIT,
EXT_INTERVAL,
COMPRESSION_MODE,
EXTENSION_MODE = 0xff, /* 0xf4 - 0xff */
}; };
/* normal mode */ /* TODO: keycode:0x04-0x73 can be handled by 1byte command else 2bytes are needed
#define DOWN(key) (key) * if keycode between 0x04 and 0x73
#define UP(key) ((key) | 0x80) * keycode / (keycode|0x80)
#define TYPE(key) (key), (key | 0x80) * else
#define MODS_DOWN(mods) MODS_DOWN, (mods) * {KEY_DOWN, keycode} / {KEY_UP, keycode}
#define MODS_UP(mods) MODS_UP, (mods) */
#define DOWN(key) KEY_DOWN, (key)
#define UP(key) KEY_UP, (key)
#define TYPE(key) DOWN(key), UP(key)
#define WAIT(ms) WAIT, (ms) #define WAIT(ms) WAIT, (ms)
#define INTERVAL(ms) INTERVAL, (ms) #define INTERVAL(ms) INTERVAL, (ms)
/* key down */
#define D(key) DOWN(KC_##key) #define D(key) DOWN(KC_##key)
/* key up */
#define U(key) UP(KC_##key) #define U(key) UP(KC_##key)
/* key type */
#define T(key) TYPE(KC_##key) #define T(key) TYPE(KC_##key)
#define MD(key) MODS_DOWN(MOD_BIT(KC_##key)) /* wait */
#define MU(key) MODS_UP(MOD_BIT(KC_##key))
#define W(ms) WAIT(ms) #define W(ms) WAIT(ms)
/* interval */
#define I(ms) INTERVAL(ms) #define I(ms) INTERVAL(ms)
/* for backward comaptibility */
/* extension mode */ #define MD(key) DOWN(KC_##key)
#define MU(key) UP(KC_##key)
#endif /* ACTION_MACRO_H */ #endif /* ACTION_MACRO_H */

View File

@ -30,7 +30,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define IS_SPECIAL(code) ((0xA5 <= (code) && (code) <= 0xDF) || (0xE8 <= (code) && (code) <= 0xFF)) #define IS_SPECIAL(code) ((0xA5 <= (code) && (code) <= 0xDF) || (0xE8 <= (code) && (code) <= 0xFF))
#define IS_SYSTEM(code) (KC_POWER <= (code) && (code) <= KC_WAKE) #define IS_SYSTEM(code) (KC_PWR <= (code) && (code) <= KC_WAKE)
#define IS_CONSUMER(code) (KC_MUTE <= (code) && (code) <= KC_WFAV) #define IS_CONSUMER(code) (KC_MUTE <= (code) && (code) <= KC_WFAV)
#define IS_FN(code) (KC_FN0 <= (code) && (code) <= KC_FN31) #define IS_FN(code) (KC_FN0 <= (code) && (code) <= KC_FN31)
#define IS_MOUSEKEY(code) (KC_MS_UP <= (code) && (code) <= KC_MS_ACCEL2) #define IS_MOUSEKEY(code) (KC_MS_UP <= (code) && (code) <= KC_MS_ACCEL2)

View File

@ -363,21 +363,19 @@ Default Layer also has bitwise operations, they are executed when key is release
`Macro` action indicates complex key strokes. `Macro` action indicates complex key strokes.
MACRO( MD(LSHIFT), D(D), END ) MACRO( D(LSHIFT), D(D), END )
MACRO( U(D), MU(LSHIFT), END ) MACRO( U(D), U(LSHIFT), END )
MACRO( I(255), T(H), T(E), T(L), T(L), W(255), T(O), END ) MACRO( I(255), T(H), T(E), T(L), T(L), W(255), T(O), END )
#### 2.3.1 Normal mode #### 2.3.1 Macro Commands
- **I()** change interavl of stroke. - **I()** change interavl of stroke.
- **D()** press key - **D()** press key
- **U()** release key - **U()** release key
- **T()** type key(press and release) - **T()** type key(press and release)
- **W()** wait - **W()** wait
- **MD()** modifier down
- **MU()** modifier up
- **END** end mark - **END** end mark
#### 2.3.2 Extended mode #### 2.3.2 Examples
***TODO: sample impl*** ***TODO: sample impl***
See `keyboard/hhkb/keymap.c` for sample. See `keyboard/hhkb/keymap.c` for sample.