Author Topic: TMK alt, alt tab key mapping ideas  (Read 2138 times)

0 Members and 1 Guest are viewing this topic.

Offline tokyo

  • Thread Starter
  • Posts: 17
TMK alt, alt tab key mapping ideas
« on: Wed, 18 May 2016, 16:16:40 »
I spent lots of time on window switching.
It makes sense to improve that.
The usual alt + tab key is annoying as your hand have to move.
Mapping alt + tab, alt + ←, alt + ↓ would be nice.
What is your idea about window switching?

Exact behavior of it is well documented here
https://en.wikipedia.org/wiki/Alt-Tab

here is my idea (not sure how to implement it):
hold down A to activate momentary layer and define alt to be held down
  map l to tab, h to ←, j to ↓

found this to be almost what I want:
ACTION_LAYER_MODS(2, MOD_LSFT | MOD_LALT)
  but it lacks one parameter to define its tap key  (which I plan to use as letter A)

« Last Edit: Thu, 19 May 2016, 06:49:02 by tokyo »

Offline suicidal_orange

  • * Global Moderator
  • Posts: 4771
  • Location: England
Re: TMK alt, alt tab key mapping ideas
« Reply #1 on: Wed, 18 May 2016, 18:12:59 »
Welcome to GH, interesting first post :)

For me I find thumb on left Alt and pinky finger on tab works well with minimal hand movement and I rarely use it with arrows so it's not something I've given any thought, but I don't think it could work using a letter as your trigger - what happens when you type album quickly?  You switch window and type bum in it :))

You could use tab (or caps lock, if you have one) instead of A then it would be easy to do in EasyAVR - Tab would be an FN key with a tap key of Tab, then on the layer you map the arrows and Tab wherever you want them with the 'implied mods: alt' ticked.  Last I heard TMK didn't play nice with dual use keys but someone may correct me on that...
120/100g linear Zealio R1  
GMK Hyperfuse
'Split everything' perfection  
MX Clear
SA Hack'd by Geeks     
EasyAVR mod

Offline hasu

  • Posts: 3475
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
Re: TMK alt, alt tab key mapping ideas
« Reply #2 on: Thu, 19 May 2016, 11:50:08 »
I spent lots of time on window switching.
It makes sense to improve that.
The usual alt + tab key is annoying as your hand have to move.
Mapping alt + tab, alt + ←, alt + ↓ would be nice.
What is your idea about window switching?

Exact behavior of it is well documented here
https://en.wikipedia.org/wiki/Alt-Tab

here is my idea (not sure how to implement it):
hold down A to activate momentary layer and define alt to be held down
  map l to tab, h to ←, j to ↓

found this to be almost what I want:
ACTION_LAYER_MODS(2, MOD_LSFT | MOD_LALT)
  but it lacks one parameter to define its tap key  (which I plan to use as letter A)



No simple answer,  you'll have to write code.

EDIT: as you said, you need a tap key with layer switch + Alt on 'A' key. It is not supported in current keymap implementation unfortunately. But I think you can write code for this in action_function(). You can refer tmk_core/common/action.c to know how to implement  tap key.
« Last Edit: Thu, 19 May 2016, 12:03:28 by hasu »

Offline tokyo

  • Thread Starter
  • Posts: 17
Re: TMK alt, alt tab key mapping ideas
« Reply #3 on: Fri, 20 May 2016, 22:05:30 »
yes, typing "album" is a problem, typing fast gets many problems
so I switched to using TAB key instead and it works well

here is my code:
Code: [Select]
...
#include "action_layer.h"  //for layer_on functions
...
    KEYMAP(
    TRNS, TRNS,  TRNS,  TRNS,  TRNS,  TRNS,  TRNS,  TRNS,  TRNS,  TRNS,  TRNS, TRNS, TRNS,           PSCR,SLCK,BRK,
    TRNS, F1,  F2,  F3,  F4,  F5,  F6,  F7,  F8,  F9,  F10, F11, F12, TRNS,      INS, HOME,PGUP,    NLCK,PSLS,PAST,PMNS,
    TRNS, TRNS,TRNS,TRNS,  TRNS,TRNS, TRNS,TRNS,F4,TRNS, TRNS,  TRNS,  TRNS,  TRNS,     DEL, END, PGDN,    P7,  P8,  P9,
    TRNS,TRNS,  LEFT,DOWN,RGHT,TRNS,  LEFT,DOWN,UP,  TAB,TRNS,  TRNS,       TRNS,                         P4,  P5,  P6,  PPLS,
    TRNS,TRNS,  TRNS,  TRNS,  TRNS,  TRNS,  TRNS,TRNS,TRNS,TRNS, TRNS,          TRNS,          UP,           P1,  P2,  P3,
    TRNS,TRNS,TRNS,          TRNS,                     TRNS,TRNS,TRNS, TRNS,     LEFT,DOWN,RGHT,    P0,       PDOT,PENT
            ),

...
enum function_id {
        LALT_TAB,

...
        [6] = ACTION_FUNCTION_TAP(LALT_TAB),           //

...

/*
 * user defined action function
 * copied from   /keyboard/hhkb/keymap_hasu.c
 */
void action_function(keyrecord_t *record, uint8_t id, uint8_t opt)
{
    /* if (record->event.pressed) dprint("P"); else dprint("R"); */
    /* dprintf("%d", record->tap.count); */
    /* if (record->tap.interrupted) dprint("i"); */
    /* dprint("\n"); */

    switch (id) {
        case LALT_TAB:
            if (record->event.pressed) {
                if (record->tap.count > 0 && !record->tap.interrupted) {
                        if (record->tap.interrupted) {  //strange that it would get here
                            //dprint("tap interrupted\n");
                        layer_on(2);
                        register_mods(MOD_BIT(KC_LALT));
                        //optimization for alt tab
                        register_code(KC_TAB);
                        unregister_code(KC_TAB);
                    }
                } else {
                    layer_on(2);
                    register_mods(MOD_BIT(KC_LALT));
                        //optimization for alt tab
                        register_code(KC_TAB);
                        unregister_code(KC_TAB);
                }
            } else {
                if (record->tap.count > 0 && !(record->tap.interrupted)) {
                    /* add_weak_mods(MOD_BIT(KC_LSHIFT)); */
                    /* send_keyboard_report(); */
                    register_code(KC_TAB);
                    unregister_code(KC_TAB);
                    /* del_weak_mods(MOD_BIT(KC_LSHIFT)); */
                    /* send_keyboard_report(); */
                    record->tap.count = 0;  // ad hoc: cancel tap
                } else {
                    unregister_mods(MOD_BIT(KC_LALT));
                    layer_off(2);
                }
            }
            break;