Page 1 of 1

Strange behaviour of TMK on Alps64

Posted: 11 Mar 2016, 10:42
by scottc
Hey all,

I'm seeing a really strange issue with my Alps64 PCB. Whatever layout I flash, it seems like LGui and RGui aren't recognised as keypresses. Fn layers also don't seem to work correctly. I flash a keymap with the following layout defined:

Code: Select all

    KEYMAP( \
        ESC, 1,   2,   3,   4,   5,   6,   7,   8,   9,   0,   MINS,EQL,  BSPC, \
        TAB, Q,   W,   E,   R,   T,   Y,   U,   I,   O,   P,   LBRC,RBRC,BSLS, \
        LCTL,A,   S,   D,   F,   G,   H,   J,   K,   L,   SCLN,QUOT,ENT,  \
        LSFT,    Z,   X,   C,   V,   B,   N,   M,   COMM,DOT, SLSH,  FN0,  \
        LCTL,LGUI,LALT,          SPC,                     RALT, RGUI,APP,LCAP),
But what I'm actually getting is:

Code: Select all

    KEYMAP( \
        ESC, 1,   2,   3,   4,   5,   6,   7,   8,   9,   0,   MINS,EQL,  BSPC, \
        TAB, Q,   W,   E,   R,   T,   Y,   U,   I,   O,   P,   LBRC,RBRC,BSLS, \
        LCTL,A,   S,   D,   F,   G,   H,   J,   K,   L,   SCLN,QUOT,ENT,  \
        LSFT,    Z,   X,   C,   V,   B,   N,   M,   COMM,DOT, SLSH,  RGUI,  \
        LCTL,LALT,???,          SPC,                     RALT, RGUI,???,LCAP),
So my physical LGUI key, assigned the LGUI keycode, returns no keycode.
My physical RGUI key, similarly assigned the RGUI keycode, returns no keycode.
My right shift key, assigned the FN0 function, strangely returns an RGUI keycode.

Anyone any idea what might be happening? For what it's worth, this also happens with layouts that come straight from Hasu's web configurator. This happens on Linux, Windows and Mac OS X.

keymap_plain.c:

Code: Select all

#include "keymap_common.h"

#ifdef KEYMAP_SECTION_ENABLE
const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS] __attribute__ ((section (".keymap.keymaps"))) = {
#else
const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS] PROGMEM = {
#endif
    /* 0: qwerty
     * ,-----------------------------------------------------------.
     * |Esc|  1|  2|  3|  4|  5|  6|  7|  8|  9|  0|  -|  =|  #|Bsp|
     * |-----------------------------------------------------------|
     * |Tab  |  Q|  W|  E|  R|  T|  Y|  U|  I|  O|  P|  [|  ]|  \  |
     * |-----------------------------------------------------------|
     * |LCtrl |  A|  S|  D|  F|  G|  H|  J|  K|  L|  ;|  '|Enter   |
     * |-----------------------------------------------------------|
     * |Shft|  \|  Z|  X|  C|  V|  B|  N|  M|  ,|  .|  /|Shift |Esc|
     * |-----------------------------------------------------------'
     * |Ctrl|Gui |Alt |         Space         |App |Alt |Gui |Caps |
     * `-----------------------------------------------------------'
     */
    KEYMAP( \
        ESC, 1,   2,   3,   4,   5,   6,   7,   8,   9,   0,   MINS,EQL,  BSPC, \
        TAB, Q,   W,   E,   R,   T,   Y,   U,   I,   O,   P,   LBRC,RBRC,BSLS, \
        LCTL,A,   S,   D,   F,   G,   H,   J,   K,   L,   SCLN,QUOT,ENT,  \
        LSFT,    Z,   X,   C,   V,   B,   N,   M,   COMM,DOT, SLSH,  FN0,  \
        LCTL,LGUI,LALT,          SPC,                     RALT, RGUI,APP,LCAP),
    /* 1: fn layer
     * ,-----------------------------------------------------------.
     * |`  | F1| F2| F3| F4| F5| F6| F7|  8|  9|  0|  -|  =|  #|Bsp|
     * |-----------------------------------------------------------|
     * |Tab  |  Q|  W|  E|  R|  T|  Y|  U|  I|  O|  P|  [|  ]|  \  |
     * |-----------------------------------------------------------|
     * |Caps  |  A|  S|  D|  F|  G|  H|  J|  K|  L|  ;|  '|Enter   |
     * |-----------------------------------------------------------|
     * |Shft|  \|  Z|  X|  C|  V|  B|  N|  M|  ,|  .|  /|Shift |Esc|
     * |-----------------------------------------------------------'
     * |Ctrl|Gui |Alt |         Space         |App |Alt |Gui |Ctrl |
     * `-----------------------------------------------------------'
     */
    KEYMAP( \
        GRV,F1,  F2,  F3,  F4,  F5,  F6,  F7,  F8,  F9,  F10,  F11,F12,  DEL, \
        TRNS, TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,PSCR, UP,TRNS,TRNS, \
        TRNS,  TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,HOME,PGUP,  LEFT,RGHT,TRNS,  \
        TRNS,  TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,   END,PGDN,   DOWN,  TRNS, \
        TRNS,TRNS,TRNS,         TRNS,                   TRNS, TRNS,TRNS,TRNS),



};
#ifdef KEYMAP_SECTION_ENABLE
const uint16_t fn_actions[] __attribute__ ((section (".keymap.fn_actions"))) = {
 //[0]  = ACTION_LAYER_MOMENTARY(1),
};
#else
const uint16_t fn_actions[] PROGMEM = {};
#endif
keymap_common.h:

Code: Select all

/*
Copyright 2012,2013 Jun Wako <[email protected]>

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef KEYMAP_COMMON_H
#define KEYMAP_COMMON_H

#include <stdint.h>
#include <stdbool.h>
#include <avr/pgmspace.h>
#include "keycode.h"
#include "action.h"
#include "action_macro.h"
#include "report.h"
#include "host.h"
#include "print.h"
#include "debug.h"
#include "keymap.h"


extern const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS];
extern const uint16_t fn_actions[];


/* Alps64 keymap definition macro */
#define KEYMAP( \
    K36, K37, K46, K47, K56, K57, K66, K67, K76, K77, K06, K07, K17,   K27, \
    K34,  K35, K44, K45, K54, K55, K64, K65, K75, K05, K15, K16, K25, K24, \
    K32,   K33, K43, K52, K53, K63, K73, K74, K03, K04, K13, K14,    K23, \
    K31,    K42, K51, K61, K62, K71, K72, K01, K02, K11, K12,    K21,     \
    K30, K40, K50,           K60,                     K70, K00, K10, K20  \
) { \
    { KC_##K00, KC_##K01, KC_##K02, KC_##K03, KC_##K04, KC_##K05, KC_##K06, KC_##K07 }, \
    { KC_##K10, KC_##K11, KC_##K12, KC_##K13, KC_##K14, KC_##K15, KC_##K16, KC_##K17 }, \
    { KC_##K20, KC_##K21, KC_##K00, KC_##K23, KC_##K24, KC_##K25, KC_##K27, KC_##K00 }, \
    { KC_##K30, KC_##K31, KC_##K32, KC_##K33, KC_##K34, KC_##K35, KC_##K36, KC_##K37 }, \
    { KC_##K40, KC_##K00, KC_##K42, KC_##K43, KC_##K44, KC_##K45, KC_##K46, KC_##K47 }, \
    { KC_##K50, KC_##K51, KC_##K52, KC_##K53, KC_##K54, KC_##K55, KC_##K56, KC_##K57 }, \
    { KC_##K60, KC_##K61, KC_##K62, KC_##K63, KC_##K64, KC_##K65, KC_##K66, KC_##K67 }, \
    { KC_##K70, KC_##K71, KC_##K72, KC_##K73, KC_##K74, KC_##K75, KC_##K76, KC_##K77 } \
}

/* AEK US */
#define KEYMAP_AEK( \
    K36, K37, K46, K47, K56, K57, K66, K67, K76, K77, K06, K07, K17, K27, \
    K34, K35, K44, K45, K54, K55, K64, K65, K75, K05, K15, K16, K25, K24, \
    K32, K33, K43, K52, K53, K63, K73, K74, K03, K04, K13, K14, K23, \
    K31, K42, K51, K61, K62, K71, K72, K01, K02, K11, K12, K21, \
    K30, K40, K50,           K60,                          K00, K10, K20  \
) KEYMAP( \
    K36, K37, K46, K47, K56, K57, K66, K67, K76, K77, K06, K07, K17, NUHS,K27, \
    K34, K35, K44, K45, K54, K55, K64, K65, K75, K05, K15, K16, K25, K24, \
    K32, K33, K43, K52, K53, K63, K73, K74, K03, K04, K13, K14, K23, \
    K31, NUBS,K42, K51, K61, K62, K71, K72, K01, K02, K11, K12, K21, ESC, \
    K30, K40, K50,           K60,                     APP, K00, K10, K20  \
)

#endif

Posted: 11 Mar 2016, 16:25
by scottc
Forgot to mention, but for some reason LALT and LGUI are also swapped and I don't know why... I noticed this on my Frosty Flake too but don't really know why it's happening. Not sure if relevant.

Posted: 12 Mar 2016, 00:12
by hasu
Seems like you changed KEYMAP macro wrongly in keymap_common.h. It uses K00 multiple place and this is usaully not what you want. If you don't know what you are doing I'd recommend to use original KEYMAP macro and just place NO on nonexistent keys.


Anyway, I tried to fix you code somehow. Probably it works. If you still have swapped ALT and GUI you will have to disable or clear bootmagic feature. Plugin in with pressing space and backspace to clear it. Or disable it by editing Makefile.(Comment out 'BOOTMAGIC_ENABLE' line)

Code: Select all

#include "keymap_common.h"

const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS] PROGMEM = {
    /* 0: qwerty
     * ,-----------------------------------------------------------.                               
     * |Esc|  1|  2|  3|  4|  5|  6|  7|  8|  9|  0|  -|  =|  #|Bsp|                               
     * |-----------------------------------------------------------|                               
     * |Tab  |  Q|  W|  E|  R|  T|  Y|  U|  I|  O|  P|  [|  ]|  \  |                               
     * |-----------------------------------------------------------|                               
     * |LCtrl |  A|  S|  D|  F|  G|  H|  J|  K|  L|  ;|  '|Enter   |                               
     * |-----------------------------------------------------------|                               
     * |Shft|  \|  Z|  X|  C|  V|  B|  N|  M|  ,|  .|  /|Shift |Esc|                               
     * |-----------------------------------------------------------'                               
     * |Ctrl|Gui |Alt |         Space         |App |Alt |Gui |Caps |
     * `-----------------------------------------------------------'
     */ 
    KEYMAP( \    
        ESC, 1,   2,   3,   4,   5,   6,   7,   8,   9,   0,   MINS,EQL,  BSPC, \                  
        TAB, Q,   W,   E,   R,   T,   Y,   U,   I,   O,   P,   LBRC,RBRC,BSLS, \                   
        LCTL,A,   S,   D,   F,   G,   H,   J,   K,   L,   SCLN,QUOT,ENT,  \                        
        LSFT,    Z,   X,   C,   V,   B,   N,   M,   COMM,DOT, SLSH,  FN0,  \                       
        LCTL,LGUI,LALT,          SPC,                     RALT, RGUI,APP,LCAP),                    
    /* 1: fn layer
     * ,-----------------------------------------------------------.                               
     * |`  | F1| F2| F3| F4| F5| F6| F7|  8|  9|  0|  -|  =|  #|Bsp|                               
     * |-----------------------------------------------------------|                               
     * |Tab  |  Q|  W|  E|  R|  T|  Y|  U|  I|  O|  P|  [|  ]|  \  |                               
     * |-----------------------------------------------------------|                               
     * |Caps  |  A|  S|  D|  F|  G|  H|  J|  K|  L|  ;|  '|Enter   |                               
     * |-----------------------------------------------------------|                               
     * |Shft|  \|  Z|  X|  C|  V|  B|  N|  M|  ,|  .|  /|Shift |Esc|                               
     * |-----------------------------------------------------------'                               
     * |Ctrl|Gui |Alt |         Space         |App |Alt |Gui |Ctrl |
     * `-----------------------------------------------------------'
     */ 
    KEYMAP( \  
        GRV,F1,  F2,  F3,  F4,  F5,  F6,  F7,  F8,  F9,  F10,  F11,F12,  DEL, \                    
        TRNS, TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,PSCR, UP,TRNS,TRNS, \                   
        TRNS,  TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,HOME,PGUP,  LEFT,RGHT,TRNS,  \                   
        TRNS,  TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,   END,PGDN,   DOWN,  TRNS, \                    
        TRNS,TRNS,TRNS,         TRNS,                   TRNS, TRNS,TRNS,TRNS),                     
                                                                                                   

 
};                                                                                                 

const uint16_t fn_actions[] PROGMEM = {
 [0]  = ACTION_LAYER_MOMENTARY(1),
};

Code: Select all

#ifndef KEYMAP_COMMON_H
#define KEYMAP_COMMON_H
 
#include <stdint.h>
#include <stdbool.h>
#include <avr/pgmspace.h>
#include "keycode.h"
#include "action.h"
#include "action_macro.h"
#include "report.h"
#include "host.h"
#include "print.h"
#include "debug.h"
#include "keymap.h"
 
 
extern const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS];
extern const uint16_t fn_actions[];
 
 
/* Alps64 keymap definition macro */
#define KEYMAP( \
    K36, K37, K46, K47, K56, K57, K66, K67, K76, K77, K06, K07, K17,   K27, \
    K34,  K35, K44, K45, K54, K55, K64, K65, K75, K05, K15, K16, K25, K24, \
    K32,   K33, K43, K52, K53, K63, K73, K74, K03, K04, K13, K14,    K23, \
    K31,    K42, K51, K61, K62, K71, K72, K01, K02, K11, K12,    K21,     \
    K30, K40, K50,           K60,                     K70, K00, K10, K20  \
) { \
    { KC_##K00, KC_##K01, KC_##K02, KC_##K03, KC_##K04, KC_##K05, KC_##K06, KC_##K07 }, \
    { KC_##K10, KC_##K11, KC_##K12, KC_##K13, KC_##K14, KC_##K15, KC_##K16, KC_##K17 }, \
    { KC_##K20, KC_##K21, KC_NO,    KC_##K23, KC_##K24, KC_##K25, KC_NO,    KC_##K27 }, \
    { KC_##K30, KC_##K31, KC_##K32, KC_##K33, KC_##K34, KC_##K35, KC_##K36, KC_##K37 }, \
    { KC_##K40, KC_NO,    KC_##K42, KC_##K43, KC_##K44, KC_##K45, KC_##K46, KC_##K47 }, \
    { KC_##K50, KC_##K51, KC_##K52, KC_##K53, KC_##K54, KC_##K55, KC_##K56, KC_##K57 }, \
    { KC_##K60, KC_##K61, KC_##K62, KC_##K63, KC_##K64, KC_##K65, KC_##K66, KC_##K67 }, \
    { KC_##K70, KC_##K71, KC_##K72, KC_##K73, KC_##K74, KC_##K75, KC_##K76, KC_##K77 } \
}
#endif

Posted: 12 Mar 2016, 03:49
by scottc
Thank you very much for the help Hasu! I'll try this tomorrow morning. For what it's worth, the issue came up with a clean hex built from the TMK Alps64 subdirectory (and the web configurator) when I last tested it so my bad K00 edits might not be the cause. The K00s are typos, I meant NO but it was late at night so I must've been mistaken. I'll try disabling bootmagic too and report on what changes.

Posted: 12 Mar 2016, 11:57
by scottc
Update: GREAT SUCCESS!

It looks like it was bootmagic + NKRO that was causing this. Having just one enabled doesn't cause the error. I've disabled bootmagic for now and all seems well. Thank you Hasu! :D

Posted: 10 Jun 2016, 16:03
by Hypersphere
I was unsure where to post questions or comments about the Hasu Alps64 TMK Editor, but I saw this thread and decided to post here.

I have a 60% keyboard with the Hasu Alps64 PCB, and I wish to use the excellent TMK editor to create a HHKB-like layout. However, I have been unsure what to do with two things:

1. How to designate keys that are on the editor map but not on my keyboard (such as the split Backspace and split left and right Shift keys).

2. How to designate a Fn key. For example, I would like to remap the RCtrl as Fn.

I have been told by a very knowledgeable source that for (1) I can either do nothing or use the "NO" designation. Likewise, for (2), I have been told to use L1 for Fn for layer 1, L2 for Fn for layer 2, etc. This certainly makes logical sense, but I wanted to check because the documentation can seem confusing for new users.

UPDATE: After some false starts trying to flash the chip with FLIP for Windows, I was about to move over to my Linux box, but I got things working. My first hex file was not quite correct, but I re-did it, and SUCCESS! I now have a custom brown Alps 60% board with a HHKB layout, complete with media controls.

For reasons unknown the Esc key is unresponsive, which I think is a hardware problem with the board, but I made a new Esc key by mapping Fn+E --> Esc.

Full programmability is definitely the way to go with keyboards. I hope that keyboard companies will start incorporating fully programmable chips using either TMK or their own systems for programming.

In any event, Thanks, Hasu! You have created a marvelous tool and made it relatively easy to use.