Author Topic: Looking for some help understanding TMK  (Read 1488 times)

0 Members and 1 Guest are viewing this topic.

Offline apanzerj

  • Thread Starter
  • Posts: 6
Looking for some help understanding TMK
« on: Tue, 25 April 2017, 00:27:07 »
Is there a good intro article or something that goes over the very basics? I'm just trying to get layer switching working. I can't seem to switch layers back after going forward. IE: I can get to layer 1 but then I can't get back.

I'm using a USB-to-USB converter.

#include "keymap_common.h"


const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS] PROGMEM = {
   KEYMAP_ALL(
              F13, F14, F15, F16, F17, F18, F19, F20, F21, F22, F23, F24,
    ESC,      FN1,  F2,  F3,  F4,  F5,  F6,  F7,  F8,  F9,  F10, F11, F12,           PSCR,SLCK,PAUS,    VOLD,VOLU,MUTE,PWR,     HELP,
    GRV, FN1,   2,   3,   4,   5,   6,   7,   8,   9,   0,   MINS,EQL, JYEN,BSPC,     INS, HOME,PGUP,    NLCK,PSLS,PAST,PMNS,    STOP,AGIN,
    TAB, Q,   0,   E,   R,   T,   Y,   U,   I,   O,   P,   LBRC,RBRC,     BSLS,     DEL, END, PGDN,    P7,  P8,  P9,  PPLS,    MENU,UNDO,
    CAPS,A,   S,   D,   F,   G,   H,   J,   K,   L,   SCLN,QUOT,     NUHS,ENT,                         P4,  P5,  P6,  PCMM,    SLCT,COPY,
    LSFT,NUBS,Z,   X,   C,   V,   B,   N,   M,   COMM,DOT, SLSH,     RO,  RSFT,          UP,           P1,  P2,  P3,  PEQL,    EXEC,PSTE,
    LCTL,LGUI,LALT,MHEN,HANJ,     SPC,      HAEN,HENK,KANA,RALT,RGUI,APP, RCTL,     LEFT,DOWN,RGHT,    P0,       PDOT,PENT,    FIND,CUT
    ),
    KEYMAP_ALL(
              F13, F14, F15, F16, F17, F18, F19, F20, F21, F22, F23, F24,
    ESC,      F1,  FN0,  F3,  F4,  F5,  F6,  F7,  F8,  F9,  F10, F11, F12,           PSCR,SLCK,PAUS,    VOLD,VOLU,MUTE,PWR,     HELP,
    GRV, 1,   FN0,   3,   4,   5,   6,   7,   8,   9,   0,   MINS,EQL, JYEN,BSPC,     INS, HOME,PGUP,    NLCK,PSLS,PAST,PMNS,    STOP,AGIN,
    TAB, Q,   W,   1,   R,   T,   Y,   U,   I,   O,   P,   LBRC,RBRC,     BSLS,     DEL, END, PGDN,    P7,  P8,  P9,  PPLS,    MENU,UNDO,
    CAPS,A,   S,   D,   F,   G,   H,   J,   K,   L,   SCLN,QUOT,     NUHS,ENT,                         P4,  P5,  P6,  PCMM,    SLCT,COPY,
    LSFT,NUBS,Z,   X,   C,   V,   B,   N,   M,   COMM,DOT, SLSH,     RO,  RSFT,          UP,           P1,  P2,  P3,  PEQL,    EXEC,PSTE,
    LCTL,LGUI,LALT,MHEN,HANJ,     SPC,      HAEN,HENK,KANA,RALT,RGUI,APP, RCTL,     LEFT,DOWN,RGHT,    P0,       PDOT,PENT,    FIND,CUT
    ),
};

const action_t PROGMEM fn_actions[] = {
        ACTION_LAYER_TOGGLE(0),
        ACTION_LAYER_TOGGLE(1)
};

Offline henz

  • * Exquisite Elder
  • Posts: 1284
  • What?
Re: Looking for some help understanding TMK
« Reply #1 on: Tue, 25 April 2017, 08:12:58 »
toggle means switch to

what you are looking for is ACTION_LAYER_MOMENTARY,

which changes to lvl2 while holding down and when released you get back.

Offline TalkingTree

  • Posts: 2452
  • Location: Italy (142)
    • My projects
Re: Looking for some help understanding TMK
« Reply #2 on: Tue, 25 April 2017, 09:20:07 »
By the look of your code, everything should work as intended.
I don't know if it matters much, but your second line should read like this:

Code: [Select]
const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {You're missing PROGMEM.
My opensource projects: GH80-3000, TOAD, XMMX. Classified: stuff

Offline apanzerj

  • Thread Starter
  • Posts: 6
Re: Looking for some help understanding TMK
« Reply #3 on: Tue, 25 April 2017, 21:15:59 »
I didn't want to do the momentary, I wanted to actually switch to that layer.

I'll add PROGMEM in there and report back.

Offline Thereminz

  • Posts: 12
Re: Looking for some help understanding TMK
« Reply #4 on: Tue, 25 April 2017, 23:02:05 »
i used

http://qmk.sized.io/

it makes it a bit easier

your tg(whatever layer) button should also be your trns button to go back to your previous layer

Offline apanzerj

  • Thread Starter
  • Posts: 6
Re: Looking for some help understanding TMK
« Reply #5 on: Tue, 25 April 2017, 23:53:10 »
Quote
your tg(whatever layer) button should also be your trns button to go back to your previous layer

I don't get what you just said there. What does tg mean? If one of my FN keys is set to toggle layer 1 then you can't use trns because that would just still do toggle layer 1, right?

Offline TalkingTree

  • Posts: 2452
  • Location: Italy (142)
    • My projects
Re: Looking for some help understanding TMK
« Reply #6 on: Wed, 26 April 2017, 05:10:49 »
Change this array:
Code: [Select]
const action_t PROGMEM fn_actions[] = {
        ACTION_LAYER_TOGGLE(0),
        ACTION_LAYER_TOGGLE(1)
};

to:

Code: [Select]
static const action_t PROGMEM fn_actions[] = {
    [0] = ACTION_LAYER_TOGGLE(1),
    [1] = ACTION_LAYER_TOGGLE(0)
};
My opensource projects: GH80-3000, TOAD, XMMX. Classified: stuff

Offline hasu

  • Posts: 3472
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
Re: Looking for some help understanding TMK
« Reply #7 on: Wed, 26 April 2017, 08:50:57 »
TOGGLE just turns on/off specific layer.
So you will have to useTOGGLE(1) to turn off layer 1 if you activated it with TOGGLE(1).

these may help.
https://github.com/tmk/tmk_core/blob/master/doc/keymap.md
https://github.com/tmk/tmk_keyboard/wiki/FAQ-Keymap
« Last Edit: Wed, 26 April 2017, 08:55:32 by hasu »