Bläddra i källkod

Add MACRO action

tags/v1.9
tmk 11 år sedan
förälder
incheckning
23c32d304b
4 ändrade filer med 39 tillägg och 30 borttagningar
  1. 3
    2
      common/action.c
  2. 27
    25
      common/action.h
  3. 4
    0
      common/action_macro.h
  4. 5
    3
      common/keymap.c

+ 3
- 2
common/action.c Visa fil

#include "command.h" #include "command.h"
#include "util.h" #include "util.h"
#include "debug.h" #include "debug.h"
#include "action.h"
#include "layer_switch.h" #include "layer_switch.h"
#include "action_macro.h"
#include "action.h"




static void process_action(keyrecord_t *record); static void process_action(keyrecord_t *record);


/* Extentions */ /* Extentions */
case ACT_MACRO: case ACT_MACRO:
// TODO
action_macro_play(action_get_macro(record, action.func.id, action.func.opt));
break; break;
case ACT_COMMAND: case ACT_COMMAND:
break; break;

+ 27
- 25
common/action.h Visa fil



#include "keyboard.h" #include "keyboard.h"
#include "keycode.h" #include "keycode.h"
#include "action_macro.h"




/* Struct to record event and tap count */ /* Struct to record event and tap count */
/* action for key */ /* action for key */
action_t action_for_key(uint8_t layer, key_t key); action_t action_for_key(uint8_t layer, key_t key);


/* macro */
const prog_macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt);

/* user defined special function */ /* user defined special function */
void action_function(keyrecord_t *record, uint8_t id, uint8_t opt); void action_function(keyrecord_t *record, uint8_t id, uint8_t opt);


* ============ * ============
* 16bit code: action_kind(4bit) + action_parameter(12bit) * 16bit code: action_kind(4bit) + action_parameter(12bit)
* *
* Keyboard Keys
* -------------
* Keyboard Keys(00XX)
* -------------------
* ACT_LMODS(0000): * ACT_LMODS(0000):
* 0000|0000|000000|00 No action * 0000|0000|000000|00 No action
* 0000|0000|000000|01 Transparent * 0000|0000|000000|01 Transparent
* 0011|mods| keycode Right mods + tap Key * 0011|mods| keycode Right mods + tap Key
* *
* *
* Other HID Usage
* ---------------
* Other keys(01XX)
* --------------------
* This action handles other usages than keyboard. * This action handles other usages than keyboard.
* ACT_USAGE(0100): * ACT_USAGE(0100):
* 0100|00| usage(10) System control(0x80) - General Desktop page(0x01) * 0100|00| usage(10) System control(0x80) - General Desktop page(0x01)
* 0100|10| usage(10) (reserved) * 0100|10| usage(10) (reserved)
* 0100|11| usage(10) (reserved) * 0100|11| usage(10) (reserved)
* *
*
* Mouse Keys
* ----------
* ACT_MOUSEKEY(0110): * ACT_MOUSEKEY(0110):
* 0101|XXXX| keycode Mouse key * 0101|XXXX| keycode Mouse key
* *
* *
* Layer Actions
* -------------
* Layer Actions(10XX)
* -------------------
* ACT_KEYMAP: * ACT_KEYMAP:
* 1000|--xx|0000 0000 Clear keyamp and overlay * 1000|--xx|0000 0000 Clear keyamp and overlay
* 1000|LLLL|0000 00xx Reset default layer and clear keymap and overlay * 1000|LLLL|0000 00xx Reset default layer and clear keymap and overlay
* *
* Extensions(11XX) * Extensions(11XX)
* ---------------- * ----------------
* NOTE: NOT FIXED
*
* ACT_MACRO(1100): * ACT_MACRO(1100):
* 1100|opt | id(8) Macro play? * 1100|opt | id(8) Macro play?
* 1100|1111| id(8) Macro record? * 1100|1111| id(8) Macro record?
#define ACTION_RMOD_TAP_KEY(mod, key) ACTION(ACT_RMODS_TAP, MODS4(MOD_BIT(mod))<<8 | (key)) #define ACTION_RMOD_TAP_KEY(mod, key) ACTION(ACT_RMODS_TAP, MODS4(MOD_BIT(mod))<<8 | (key))
#define ACTION_RMOD_ONESHOT(mod) ACTION(ACT_RMODS_TAP, MODS4(MOD_BIT(mod))<<8 | MODS_ONESHOT) #define ACTION_RMOD_ONESHOT(mod) ACTION(ACT_RMODS_TAP, MODS4(MOD_BIT(mod))<<8 | MODS_ONESHOT)


/* HID Usage */
enum usage_pages {
PAGE_SYSTEM,
PAGE_CONSUMER
};
#define ACTION_USAGE_SYSTEM(id) ACTION(ACT_USAGE, PAGE_SYSTEM<<10 | (id))
#define ACTION_USAGE_CONSUMER(id) ACTION(ACT_USAGE, PAGE_CONSUMER<<10 | (id))

/* Mousekey */
#define ACTION_MOUSEKEY(key) ACTION(ACT_MOUSEKEY, key)




/* Layer Operation:
/* Layer Actions:
* Invert layer ^= (1<<layer) * Invert layer ^= (1<<layer)
* On layer |= (1<<layer) * On layer |= (1<<layer)
* Off layer &= ~(1<<layer) * Off layer &= ~(1<<layer)




/* /*
* HID Usage
* Extensions
*/ */
enum usage_pages {
PAGE_SYSTEM,
PAGE_CONSUMER
};
#define ACTION_USAGE_SYSTEM(id) ACTION(ACT_USAGE, PAGE_SYSTEM<<10 | (id))
#define ACTION_USAGE_CONSUMER(id) ACTION(ACT_USAGE, PAGE_CONSUMER<<10 | (id))

/* Mousekey */
#define ACTION_MOUSEKEY(key) ACTION(ACT_MOUSEKEY, key)

/* Macro */ /* Macro */
#define ACTION_MACRO(opt, id) ACTION(ACT_FUNCTION, (opt)<<8 | (addr))
#define ACTION_MACRO(id) ACTION(ACT_MACRO, (id))
#define ACTION_MACRO_OPT(id, opt) ACTION(ACT_MACRO, (opt)<<8 | (id))


/* Command */ /* Command */
#define ACTION_COMMAND(opt, id) ACTION(ACT_COMMAND, (opt)<<8 | (addr))
#define ACTION_COMMAND(id, opt) ACTION(ACT_COMMAND, (opt)<<8 | (addr))


/* Function */ /* Function */
enum function_opts { enum function_opts {

+ 4
- 0
common/action_macro.h Visa fil

#include <avr/pgmspace.h> #include <avr/pgmspace.h>




#define MACRO_NONE 0
#define MACRO(...) ({ static prog_macro_t _m[] PROGMEM = { __VA_ARGS__ }; _m; })


typedef uint8_t macro_t; typedef uint8_t macro_t;
typedef macro_t prog_macro_t PROGMEM; typedef macro_t prog_macro_t PROGMEM;



+ 5
- 3
common/keymap.c Visa fil

#include "keycode.h" #include "keycode.h"
#include "layer_switch.h" #include "layer_switch.h"
#include "action.h" #include "action.h"
#include "action_macro.h"
#include "debug.h" #include "debug.h"




} }


__attribute__ ((weak)) __attribute__ ((weak))
void action_function(keyrecord_t *record, uint8_t id, uint8_t opt)
{
}
const prog_macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) { return MACRO_NONE; }

__attribute__ ((weak))
void action_function(keyrecord_t *record, uint8_t id, uint8_t opt) {}
#else #else
/* /*
* legacy keymap support * legacy keymap support

Laddar…
Avbryt
Spara