Browse Source

Add NO_ACTION_TAPPING and NO_ACTION_MACRO config options

tags/v1.9
tmk 11 years ago
parent
commit
9757f960f9
4 changed files with 36 additions and 6 deletions
  1. 27
    6
      common/action.c
  2. 3
    0
      common/action_macro.c
  3. 4
    0
      common/action_macro.h
  4. 2
    0
      keyboard/gh60/config.h

+ 27
- 6
common/action.c View File





static void process_action(keyrecord_t *record); static void process_action(keyrecord_t *record);
#ifndef NO_ACTION_TAPPING
static bool process_tapping(keyrecord_t *record); static bool process_tapping(keyrecord_t *record);
static void waiting_buffer_scan_tap(void); static void waiting_buffer_scan_tap(void);
#endif


static void debug_event(keyevent_t event); static void debug_event(keyevent_t event);
static void debug_record(keyrecord_t record); static void debug_record(keyrecord_t record);
static void debug_action(action_t action); static void debug_action(action_t action);
#ifndef NO_ACTION_TAPPING
static void debug_tapping_key(void); static void debug_tapping_key(void);
static void debug_waiting_buffer(void); static void debug_waiting_buffer(void);
#endif




/* /*
#define TAPPING_TOGGLE 5 #define TAPPING_TOGGLE 5
#endif #endif


#ifndef NO_ACTION_TAPPING
/* stores a key event of current tap. */ /* stores a key event of current tap. */
static keyrecord_t tapping_key = {}; static keyrecord_t tapping_key = {};


{ {
oneshot_state.disabled = !oneshot_state.disabled; oneshot_state.disabled = !oneshot_state.disabled;
} }
#endif




void action_exec(keyevent_t event) void action_exec(keyevent_t event)


keyrecord_t record = { .event = event }; keyrecord_t record = { .event = event };


#ifndef NO_ACTION_TAPPING
// pre-process on tapping // pre-process on tapping
if (process_tapping(&record)) { if (process_tapping(&record)) {
if (!IS_NOEVENT(record.event)) { if (!IS_NOEVENT(record.event)) {
if (!IS_NOEVENT(event)) { if (!IS_NOEVENT(event)) {
debug("\n"); debug("\n");
} }
#else
process_action(&record);
if (!IS_NOEVENT(record.event)) {
debug("processed: "); debug_record(record); debug("\n");
}
#endif
} }


static void process_action(keyrecord_t *record) static void process_action(keyrecord_t *record)
} }
} }
break; break;
#ifndef NO_ACTION_TAPPING
case ACT_LMODS_TAP: case ACT_LMODS_TAP:
case ACT_RMODS_TAP: case ACT_RMODS_TAP:
{ {
} }
} }
break; break;
#endif


#ifdef EXTRAKEY_ENABLE
/* other HID usage */ /* other HID usage */
case ACT_USAGE: case ACT_USAGE:
#ifdef EXTRAKEY_ENABLE
switch (action.usage.page) { switch (action.usage.page) {
case PAGE_SYSTEM: case PAGE_SYSTEM:
if (event.pressed) { if (event.pressed) {
} }
break; break;
} }
#endif
break; break;
#endif


#ifdef MOUSEKEY_ENABLE
/* Mouse key */ /* Mouse key */
case ACT_MOUSEKEY: case ACT_MOUSEKEY:
#ifdef MOUSEKEY_ENABLE
if (event.pressed) { if (event.pressed) {
mousekey_on(action.key.code); mousekey_on(action.key.code);
mousekey_send(); mousekey_send();
mousekey_off(action.key.code); mousekey_off(action.key.code);
mousekey_send(); mousekey_send();
} }
#endif
break; break;
#endif


case ACT_KEYMAP: case ACT_KEYMAP:
switch (action.layer.code) { switch (action.layer.code) {
} }
} }


#ifndef NO_ACTION_TAPPING
/* Tapping /* Tapping
* *
* Rule: Tap key is typed(pressed and released) within TAPPING_TERM. * Rule: Tap key is typed(pressed and released) within TAPPING_TERM.
} }
} }
} }
#endif






// TODO: should push command_proc out of this block? // TODO: should push command_proc out of this block?
if (command_proc(code)) return; if (command_proc(code)) return;


#ifndef NO_ACTION_TAPPING
if (oneshot_state.mods && oneshot_state.ready && !oneshot_state.disabled) { if (oneshot_state.mods && oneshot_state.ready && !oneshot_state.disabled) {
uint8_t tmp_mods = host_get_mods(); uint8_t tmp_mods = host_get_mods();
host_add_mods(oneshot_state.mods); host_add_mods(oneshot_state.mods);


host_set_mods(tmp_mods); host_set_mods(tmp_mods);
oneshot_state.ready = false; oneshot_state.ready = false;
} else {
} else
#endif
{
host_add_key(code); host_add_key(code);
host_send_keyboard_report(); host_send_keyboard_report();
} }
debug_hex8(action.kind.param & 0xff); debug_hex8(action.kind.param & 0xff);
debug("]"); debug("]");
} }
#ifndef NO_ACTION_TAPPING
static void debug_tapping_key(void) static void debug_tapping_key(void)
{ {
debug("TAPPING_KEY="); debug_record(tapping_key); debug("\n"); debug("TAPPING_KEY="); debug_record(tapping_key); debug("\n");
} }
debug("}\n"); debug("}\n");
} }
#endif

+ 3
- 0
common/action_macro.c View File

#include "action_macro.h" #include "action_macro.h"




#ifndef NO_ACTION_MACRO

#define MACRO_READ() (macro = pgm_read_byte(macro_p++)) #define MACRO_READ() (macro = pgm_read_byte(macro_p++))
void action_macro_play(const prog_macro_t *macro_p) void action_macro_play(const prog_macro_t *macro_p)
{ {
{ uint8_t ms = interval; while (ms--) _delay_ms(1); } { uint8_t ms = interval; while (ms--) _delay_ms(1); }
} }
} }
#endif

+ 4
- 0
common/action_macro.h View File

typedef macro_t prog_macro_t PROGMEM; typedef macro_t prog_macro_t PROGMEM;




#ifndef NO_ACTION_MACRO
void action_macro_play(const prog_macro_t *macro); void action_macro_play(const prog_macro_t *macro);
#else
#define action_macro_play(macro)
#endif







+ 2
- 0
keyboard/gh60/config.h View File

//#define NO_PRINT //#define NO_PRINT


#define NO_ACTION_OVERLAY #define NO_ACTION_OVERLAY
#define NO_ACTION_TAPPING
#define NO_ACTION_MACRO


#endif #endif

Loading…
Cancel
Save