summaryrefslogtreecommitdiffstats
path: root/keyboard
diff options
context:
space:
mode:
authortmk <nobody@nowhere>2014-06-12 17:23:02 +0900
committertmk <nobody@nowhere>2014-06-12 17:23:02 +0900
commit9fdb02017b8419f81fb363cbb3ced81446db0a4c (patch)
treed4a5a32d400e8a480e3092e3488c51514d3de07f /keyboard
parentcaf7b4e68a597dec1ab23b98838ca0509c318962 (diff)
Add Ctrl + Up(SpaceFN) -> PgUp
Diffstat (limited to 'keyboard')
-rw-r--r--keyboard/hhkb/keymap_spacefn.c45
1 files changed, 43 insertions, 2 deletions
diff --git a/keyboard/hhkb/keymap_spacefn.c b/keyboard/hhkb/keymap_spacefn.c
index b77e9edb92..deff920ae2 100644
--- a/keyboard/hhkb/keymap_spacefn.c
+++ b/keyboard/hhkb/keymap_spacefn.c
@@ -58,12 +58,53 @@ const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
* `-------------------------------------------'
*/
KEYMAP(GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, TRNS,DEL, \
- TRNS,TRNS,TRNS,ESC, TRNS,TRNS,TRNS,HOME,UP, END, PSCR,SLCK,PAUS,INS, \
+ TRNS,TRNS,TRNS,ESC, TRNS,TRNS,TRNS,HOME,FN3, END, PSCR,SLCK,PAUS,INS, \
TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,PGUP,LEFT,DOWN,RGHT,TRNS,TRNS,TRNS, \
TRNS,TRNS,TRNS,TRNS,TRNS,SPC, PGDN,GRV, FN2, TRNS,TRNS,TRNS,NO, \
TRNS,TRNS, TRNS, TRNS,TRNS),
};
+
+/*
+ * user defined action function
+ */
+enum function_id {
+ CTRL_SPACE_I, // Ctrl + Up(SpaceFN) -> PgUp
+};
+
+void action_function(keyrecord_t *record, uint8_t id, uint8_t opt)
+{
+# define MODS_CTRL_MASK (MOD_BIT(KC_LCTRL)|MOD_BIT(KC_RCTRL))
+ static uint8_t ctrl_space_i_prev_ctrl;
+
+ switch (id) {
+ // Ctrl + Up(SpaceFN) -> PgUp
+ case CTRL_SPACE_I:
+ ctrl_space_i_prev_ctrl = get_mods()&MODS_CTRL_MASK;
+ if (record->event.pressed) {
+ if (ctrl_space_i_prev_ctrl) {
+ del_mods(ctrl_space_i_prev_ctrl); // remove Ctrl
+ add_key(KC_PGUP);
+ send_keyboard_report(); // send PgUp without Ctrl
+ add_mods(ctrl_space_i_prev_ctrl); // return Ctrl but not sent
+ } else {
+ add_key(KC_UP);
+ send_keyboard_report();
+ }
+ } else {
+ if (ctrl_space_i_prev_ctrl) {
+ del_key(KC_PGUP);
+ send_keyboard_report();
+ } else {
+ del_key(KC_UP);
+ send_keyboard_report();
+ }
+ }
+ break;
+ }
+}
+
+
/*
* Fn action definition
*/
@@ -71,5 +112,5 @@ const uint16_t PROGMEM fn_actions[] = {
[0] = ACTION_LAYER_MOMENTARY(1),
[1] = ACTION_LAYER_TAP_KEY(2, KC_SPACE),
[2] = ACTION_MODS_KEY(MOD_LSFT, KC_GRV), // tilde
+ [3] = ACTION_FUNCTION(CTRL_SPACE_I), // Ctrl + Up(SpaceFN) -> PgUp
};
-