TMK keyboard firmware collection

Thank you a lot hasu, it was exactly a solution like that I had in mind! Works perfectly for me!
fruktstund
User avatar

Unread post07 Feb 2013, 11:38

User avatar
X
fruktstund
 
Posts: 257
Joined: 28 Feb 2012, 15:52
Location: Sweden
Main keyboard: HHKB Pro 2
Main mouse: Logitech g400
Favorite switch: Ergo-Clears (I think - can never decide)
Club member: -
 
I've finally found time to solder together my HID Liberation Device. Unfortunately, my last endeavors into programming are from the time when Turbo Pascal was hot. Here's my question:
How do I make use of the file keymap_custom.h ?

The file
/keyboard/hid_liber/keymap.c
contains this statement at lines 68 - 69
Code: Select all
#if defined(KEYMAP_CUSTOM)
    #include "keymap_custom.h"

So how do I tell the compiler to make use of the keymap as laid out in keymap_custom.h instead of the standard key map? How do I properly define KEYMAP_CUSTOM? And where should I define it?

I could of course just modify the keymap.c file and leave keymap_custom.h alone.

Any help is appreciated.
Kurk
User avatar

Unread post15 Apr 2013, 21:33

User avatar
X
Kurk
 
Posts: 601
Joined: 03 Nov 2011, 20:10
Location: Sauce Hollondaise (=The Netherlands)
Main keyboard: Kinesis Advantage // Filco MJ2 + HID liberation
Main mouse: ITAC Mousetrak Professional
Club member: 0027
 
Hi,
To use keymap_custom just run make with custom target like:
Code: Select all
 make -f Makefile.[lufa|pjrc] custom

See end of Makefiles for custom target definition.
hasu
User avatar

Unread post16 Apr 2013, 00:03

User avatar
X
hasu
 
Posts: 354
Joined: 02 Sep 2011, 14:47
Location: Japan
Main keyboard: HHKB
Main mouse: HHKB
Favorite switch: Topre
Club member: -
 
Hi Hasu. I wanted to thank you for making this collection, I've used it in a couple of projects and it's great!

I've been working on a new project, a tenkeyless AEKII mod, and was wondering if you could give me some insight. I've been unable to fix a error, I'm pretty sure my keymap is set up wrong but I'm unsure how to fix it. If you could point me in the right direction I'd really appreciate it. As you can see the firmware is pretty much directly adapted from your Phantom Firmware, just with the pin assignments changed.
bees
User avatar

Unread post14 Jun 2013, 21:47

User avatar
X
bees
 
Posts: 2
Joined: 14 Jun 2013, 21:15
Location: usa
Main keyboard: Leopold FC200RT
Main mouse: Razer Abyssus
Favorite switch: Alps Cream
Club member: -
 
hasu wrote:
damorgue wrote:I know there are some interesting ideas out there where the mx lock forces its state to the OS. If the OS has caps lock on, and the mx lock isn't depressed, then it sends caps lock to change it. This prevents desyncs where the OS has caps lock turned off and the caps lock of the keyboard is depressed. I find the mx lock to be unreliable in this regards, as it can activate without physically locking for instance.

ADB converter has similar lock switch support already. It looks like this feature can be applied to all keyboard and converter projects as build option or keymap option. I added this as issue on github, I'll work on this later when I have time. https://github.com/tmk/tmk_keyboard/issues/19

Thanks for the suggestion.

I was wondering if there are any plans on your part to implement locking functions or macro functionality?
damorgue
User avatar

Unread post14 Jun 2013, 22:56

User avatar
X
damorgue
 
Posts: 841
Joined: 14 Jul 2011, 20:08
Location: Sweden
Main mouse: MX500
Favorite switch: BS, MX Green and MX Clear
Club member: -
 
Hi,
interesting project! do you have a plan for case mod too? post it when you finish!

Macro expansion finally leads to here...
In line 46 you don't have enough comma, this is where the error comes.
https://bitbucket.org/bees/aekmod/src/9 ... ster#cl-46

bees wrote:Hi Hasu. I wanted to thank you for making this collection, I've used it in a couple of projects and it's great!

I've been working on a new project, a tenkeyless AEKII mod, and was wondering if you could give me some insight. I've been unable to fix a error, I'm pretty sure my keymap is set up wrong but I'm unsure how to fix it. If you could point me in the right direction I'd really appreciate it. As you can see the firmware is pretty much directly adapted from your Phantom Firmware, just with the pin assignments changed.
hasu
User avatar

Unread post15 Jun 2013, 02:33

User avatar
X
hasu
 
Posts: 354
Joined: 02 Sep 2011, 14:47
Location: Japan
Main keyboard: HHKB
Main mouse: HHKB
Favorite switch: Topre
Club member: -
 
That issue was closed some ago and mechanical locking caps is now supported. And resync feature is also implemented in somewhat passive way.

https://github.com/tmk/tmk_keyboard#mec ... r-capslock
https://github.com/tmk/tmk_keyboard/blo ... ion.c#L318
damorgue wrote:
hasu wrote:
damorgue wrote:I know there are some interesting ideas out there where the mx lock forces its state to the OS. If the OS has caps lock on, and the mx lock isn't depressed, then it sends caps lock to change it. This prevents desyncs where the OS has caps lock turned off and the caps lock of the keyboard is depressed. I find the mx lock to be unreliable in this regards, as it can activate without physically locking for instance.

ADB converter has similar lock switch support already. It looks like this feature can be applied to all keyboard and converter projects as build option or keymap option. I added this as issue on github, I'll work on this later when I have time. https://github.com/tmk/tmk_keyboard/issues/19

Thanks for the suggestion.

I was wondering if there are any plans on your part to implement locking functions or macro functionality?
hasu
User avatar

Unread post15 Jun 2013, 02:47

User avatar
X
hasu
 
Posts: 354
Joined: 02 Sep 2011, 14:47
Location: Japan
Main keyboard: HHKB
Main mouse: HHKB
Favorite switch: Topre
Club member: -
 
hasu wrote:awesomeness

sweet
damorgue
User avatar

Unread post15 Jun 2013, 03:39

User avatar
X
damorgue
 
Posts: 841
Joined: 14 Jul 2011, 20:08
Location: Sweden
Main mouse: MX500
Favorite switch: BS, MX Green and MX Clear
Club member: -
 
Would anyone mind taking a look at my keymap.c file and to see why I'm getting the error below? I've modified the GH60 code to allow an extra column for my 65% design but I've obviously made a mess of it.

Code: Select all
keymap.c:79:89: error: macro "KEYMAP_ANSI" requires 66 arguments, but only 62 given
keymap.c:74: error: 'KEYMAP_ANSI' undeclared here (not in a function)

Other files
config.h
matrix.c
makefile.lufa
bueller
User avatar

Unread post15 Aug 2013, 14:19

User avatar
X
bueller
 
Posts: 41
Joined: 16 Jun 2013, 11:53
Location: Australia
Main keyboard: Quickfire TK
Main mouse: Logitech G400
Favorite switch: Alps Tactile White
Club member: -
 
you need to post your actual keymap as well
Last edited by matt3o on 15 Aug 2013, 14:48, edited 1 time in total.
matt3o
User avatar
-[°_°]-

Unread post15 Aug 2013, 14:34

User avatar
X
matt3o
-[°_°]-
 
Posts: 8334
Joined: 03 Sep 2012, 15:14
Location: Italy
Main keyboard: WhiteFox
Main mouse: Anywhere MX
Favorite switch: Anything, really
Club member: 0030
 
 
This signature intentionally left blank...
So a different file to matrix.c?
bueller
User avatar

Unread post15 Aug 2013, 14:37

User avatar
X
bueller
 
Posts: 41
Joined: 16 Jun 2013, 11:53
Location: Australia
Main keyboard: Quickfire TK
Main mouse: Logitech G400
Favorite switch: Alps Tactile White
Club member: -
 
sorry I mean keymap file
matt3o
User avatar
-[°_°]-

Unread post15 Aug 2013, 14:48

User avatar
X
matt3o
-[°_°]-
 
Posts: 8334
Joined: 03 Sep 2012, 15:14
Location: Italy
Main keyboard: WhiteFox
Main mouse: Anywhere MX
Favorite switch: Anything, really
Club member: 0030
 
 
This signature intentionally left blank...
bueller
User avatar

Unread post15 Aug 2013, 14:50

User avatar
X
bueller
 
Posts: 41
Joined: 16 Jun 2013, 11:53
Location: Australia
Main keyboard: Quickfire TK
Main mouse: Logitech G400
Favorite switch: Alps Tactile White
Club member: -
 
All fixed, just need to fix the shorts with my soldering now :\
bueller
User avatar

Unread post15 Aug 2013, 17:16

User avatar
X
bueller
 
Posts: 41
Joined: 16 Jun 2013, 11:53
Location: Australia
Main keyboard: Quickfire TK
Main mouse: Logitech G400
Favorite switch: Alps Tactile White
Club member: -
 
Apologies for the basic questions, but I was hoping for some direction/assistance/instructions with editing the keymap.c file.

I'm trying to define a keymap for a Televideo terminal keyboard that I've hardwired to a Teensy 2.0. The layout is below, is this how I define keys in this file?

Code: Select all
[size=85]/* Layer 0: Default Layer
     * ,------------------------------------------------------------------------------------------------------------------.
     * |SCKLOCK| F1| F2| F3| F4| F5| F6| F7| F8| F9| F10| F11| INSERT| DELETE| INSERT| DELETE| CLEAR| CLEAR_AGAIN| EXECUTE|
     * |------------------------------------------------------------------------------------------------------------------|
     * |ESC|  1|  2|  3|  4|  5|  6|  7|  8|  9|  0|  MINUS|  EQUAL|  GRAVE|  BSLASH|  BSPACE|   KP_7|   KP_8|   KP_9|    |
     * |------------------------------------------------------------------------------------------------------------------|
    * |Tab  |  Q|  W|  E|  R|  T|  Y|  U|  I|  O|  P|  LBRACKET| SEPARATOR| CLEAR|  KP_4|  KP_5|  KP_6|                  |
     * |------------------------------------------------------------------------------------------------------------------|
     * |CAPSLOCK|   A|  S|  D|  F|  G|  H|  J|  K|  L| RCTRL| SCOLON| QUOTE| RETURN| RETURN| STOP|  KP_1|  KP_2|  KP_3|   |
     * |------------------------------------------------------------------------------------------------------------------|
     * |LSHIFT  |  Z|  X|  C|  V|  B|  N|  M|  COMMA| PRIOR| DOT| SLASH| RSHIFT | RBRACKET| DELETE| KP_DOT| KP_0| KP_COMMA|
     * |------------------------------------------------------------------------------------------------------------------|
     * |PSCREEN | LALT|                     SPACE|                     HOME| DOWN| UP| LEFT| RIGHT|                       |
     * `------------------------------------------------------------------------------------------------------------------'
     */
    KEYMAP(SCKLOCK, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, INSERT, DELETE, INSERT, DELETE, CLEAR, CLEAR_AGAIN, EXECUTE, \
      ESC,  1,  2,  3,  4,  5,  6,  7,  8,  9,  0,  MINUS,  EQUAL,  GRAVE,  BSLASH,  BSPACE,   KP_7,   KP_8,   KP_9,  \
      Tab,  Q,  W,  E,  R,  T,  Y,  U,  I,  O,  P,  LBRACKET, SEPARATOR, CLEAR,  KP_4,  KP_5,  KP_6, \                 
      CAPSLOCK, A,  S,  D,  F,  G,  H,  J,  K,  L,  RCTRL,  SCOLON, QUOTE, RETURN, RETURN, STOP,  KP_1,  KP_2,  KP_3,  \
      LSHIFT,   Z,  X,  C,  V,  B,  N,  M,  COMMA,  PRIOR,  DOT, SLASH, RSHIFT , RBRACKET, DELETE, KP_DOT, KP_0, KP_COMMA,  \
      PSCREEN,  LALT,                     SPACE,                     HOME, DOWN, UP, LEFT, RIGHT),[/size]
Greystoke

Unread post19 Oct 2013, 19:11

X
Greystoke
 
Posts: 100
Joined: 26 Feb 2013, 14:16
Main keyboard: CM Storm Trigger
Main mouse: Razer
Favorite switch: Cherry MX Green
Club member: -
 
First, you must modify KEYMAP macro depending on your matrix wiring.
hasu
User avatar

Unread post19 Oct 2013, 19:34

User avatar
X
hasu
 
Posts: 354
Joined: 02 Sep 2011, 14:47
Location: Japan
Main keyboard: HHKB
Main mouse: HHKB
Favorite switch: Topre
Club member: -
 
hasu wrote:First, you must modify KEYMAP macro depending on your matrix wiring.

Is that the section noted below?

Code: Select all
#define KEYMAP( \
    K11, K10, K20, K30, K40, K41, K51, K50, K60, K70, K80, K81, K61, K02, \
    K12, K13, K23, K33, K43, K42, K52, K53, K63, K73, K83, K82, K62, K01, \
    K15, K14, K24, K34, K44, K45, K55, K54, K64, K74, K84, K85, K06, \
    K67, K16, K26, K36, K46, K47, K57, K56, K66, K76, K87, K32, K35, \
    K75, K22, K00, K07, K21, K04, K37, K27, K17 \
) { \
    { KC_##K00, KC_##K01, KC_##K02, KC_NO,    KC_##K04, KC_NO,    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_##K22, KC_##K23, KC_##K24, KC_NO,    KC_##K26, KC_##K27 }, \
    { KC_##K30, KC_NO,    KC_##K32, KC_##K33, KC_##K34, KC_##K35, KC_##K36, KC_##K37 }, \
    { KC_##K40, KC_##K41, 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_NO,    KC_##K66, KC_##K67 }, \
    { KC_##K70, KC_NO,    KC_NO,    KC_##K73, KC_##K74, KC_##K75, KC_##K76, KC_NO    }, \
    { KC_##K80, KC_##K81, KC_##K82, KC_##K83, KC_##K84, KC_##K85, KC_NO,    KC_##K87 } \
}

#define KEYCODE(layer, row, col) (pgm_read_byte(&keymaps[(layer)][(row)][(col)]))
Greystoke

Unread post19 Oct 2013, 19:47

X
Greystoke
 
Posts: 100
Joined: 26 Feb 2013, 14:16
Main keyboard: CM Storm Trigger
Main mouse: Razer
Favorite switch: Cherry MX Green
Club member: -
 
right.

Edit: can you show your matrix.c?
Last edited by hasu on 19 Oct 2013, 19:58, edited 1 time in total.
hasu
User avatar

Unread post19 Oct 2013, 19:55

User avatar
X
hasu
 
Posts: 354
Joined: 02 Sep 2011, 14:47
Location: Japan
Main keyboard: HHKB
Main mouse: HHKB
Favorite switch: Topre
Club member: -
 
hasu wrote:right.

Okay, thanks!
Greystoke

Unread post19 Oct 2013, 19:57

X
Greystoke
 
Posts: 100
Joined: 26 Feb 2013, 14:16
Main keyboard: CM Storm Trigger
Main mouse: Razer
Favorite switch: Cherry MX Green
Club member: -
 
hasu wrote:right.

Edit: can you show your matrix.c?

I would be happy to do so, once I figure out how that file is supposed to be edited. :oops:

All I have at this point is the row and columns mapped in an Excel file, I'd just started to tackle the files in your GitHub macway directory as a basis for this keyboard.
Last edited by Greystoke on 20 Oct 2013, 03:39, edited 1 time in total.
Greystoke

Unread post19 Oct 2013, 20:12

X
Greystoke
 
Posts: 100
Joined: 26 Feb 2013, 14:16
Main keyboard: CM Storm Trigger
Main mouse: Razer
Favorite switch: Cherry MX Green
Club member: -
 
And... I found an error in my Teensy layout. Apparently you're not supposed to use the AREF pin. Crap.
Greystoke

Unread post19 Oct 2013, 22:27

X
Greystoke
 
Posts: 100
Joined: 26 Feb 2013, 14:16
Main keyboard: CM Storm Trigger
Main mouse: Razer
Favorite switch: Cherry MX Green
Club member: -
 
All right, I resoldered four switches to move them to different rows/columns. Took the opportunity to organize my wiring a bit...

I've updated the matrix.c file with the pins for rows and columns (I think...). After updating the matrix.c file I tried running makefile, and got a bunch of errors in my keymap.c, probably because I don't understand what keycodes are used in the macro section. :?

Code: Select all
/*
 * scan matrix
 */
#include <stdint.h>
#include <stdbool.h>
#include <avr/io.h>
#include <util/delay.h>
#include "print.h"
#include "debug.h"
#include "util.h"
#include "matrix.h"


#ifndef DEBOUNCE
#   define DEBOUNCE   5
#endif
static uint8_t debouncing = DEBOUNCE;

/* matrix state(1:on, 0:off) */
static matrix_row_t matrix[MATRIX_ROWS];
static matrix_row_t matrix_debouncing[MATRIX_ROWS];

static matrix_row_t read_cols(void);
static void init_cols(void);
static void unselect_rows(void);
static void select_row(uint8_t row);


inline
uint8_t matrix_rows(void)
{
    return MATRIX_ROWS;
}

inline
uint8_t matrix_cols(void)
{
    return MATRIX_COLS;
}

void matrix_init(void)
{
    // initialize row and col
    unselect_rows();
    init_cols();

    // initialize matrix state: all keys off
    for (uint8_t i=0; i < MATRIX_ROWS; i++) {
        matrix[i] = 0;
        matrix_debouncing[i] = 0;
    }
}

uint8_t matrix_scan(void)
{
    for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
        select_row(i);
        _delay_us(30);  // without this wait read unstable value.
        matrix_row_t cols = read_cols();
        if (matrix_debouncing[i] != cols) {
            matrix_debouncing[i] = cols;
            if (debouncing) {
                debug("bounce!: "); debug_hex(debouncing); debug("\n");
            }
            debouncing = DEBOUNCE;
        }
        unselect_rows();
    }

    if (debouncing) {
        if (--debouncing) {
            _delay_ms(1);
        } else {
            for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
                matrix[i] = matrix_debouncing[i];
            }
        }
    }

    return 1;
}

bool matrix_is_modified(void)
{
    if (debouncing) return false;
    return true;
}

inline
bool matrix_is_on(uint8_t row, uint8_t col)
{
    return (matrix[row] & ((matrix_row_t)1<<col));
}

inline
matrix_row_t matrix_get_row(uint8_t row)
{
    return matrix[row];
}

void matrix_print(void)
{
    print("\nr/c 0123456789ABCDEF\n");
    for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
        phex(row); print(": ");
        pbin_reverse16(matrix_get_row(row));
        print("\n");
    }
}

uint8_t matrix_key_count(void)
{
    uint8_t count = 0;
    for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
        count += bitpop16(matrix[i]);
    }
    return count;
}

/* Column pin configuration
 * col: 0   1   2   3   4   5   6   7  8   9   10  11  12  13  14  15  16  17
 * pin: C7  E6  D5  D4  D1  D2  D3  C6 D7  B4  B5  B6  F5  F6  F7  F0  F1  F4
 */
static void  init_cols(void)
{
    // Input with pull-up(DDR:0, PORT:1)
    DDRF  &= ~(1<<0 | 1<<1 | 1<<4 | 1<<5 | 1<<6 | 1<<7);
    PORTF |=  (1<<0 | 1<<1 | 1<<4 | 1<<5 | 1<<6 | 1<<7);
    DDRE  &= ~(1<<6);
    PORTE |=  (1<<6);
    DDRD  &= ~(1<<7 | 1<<5 | 1<<4 | 1<<3 | 1<<2 | 1<<1);
    PORTD |=  (1<<7 | 1<<5 | 1<<4 | 1<<3 | 1<<2 | 1<<1);
    DDRC  &= ~(1<<7 | 1<<6);
    PORTC |=  (1<<7 | 1<<6);
    DDRB  &= ~(1<<6 | 1<< 5 | 1<<4);
    PORTB |=  (1<<6 | 1<< 5 | 1<<4);
}

static matrix_row_t read_cols(void)
{
    return (PINC&(1<<7) ? 0 : (1<<0)) |
           (PINE&(1<<6) ? 0 : (1<<1)) |
           (PIND&(1<<5) ? 0 : (1<<2)) |
           (PIND&(1<<4) ? 0 : (1<<3)) |
           (PIND&(1<<1) ? 0 : (1<<4)) |
           (PIND&(1<<2) ? 0 : (1<<5)) |
           (PIND&(1<<3) ? 0 : (1<<6)) |
           (PINC&(1<<6) ? 0 : (1<<7)) |
           (PIND&(1<<7) ? 0 : (1<<8)) |
           (PINB&(1<<4) ? 0 : (1<<9)) |
           (PINB&(1<<5) ? 0 : (1<<10)) |
           (PINB&(1<<6) ? 0 : (1<<11)) |
           (PINF&(1<<5) ? 0 : (1<<12)) |
           (PINF&(1<<6) ? 0 : (1<<13)) |
           (PINF&(1<<7) ? 0 : (1<<14)) |
           (PINF&(1<<0) ? 0 : (1<<15)) |
           (PINF&(1<<1) ? 0 : (1<<16)) |
           (PINF&(1<<4) ? 0 : (1<<17));
}

/* Row pin configuration
 * row: 0   1   2   3   4   5
 * pin: D0  B3  B0  B7  B1  B2
 */
static void unselect_rows(void)
{
    // Hi-Z(DDR:0, PORT:0) to unselect
    DDRD  &= ~0b00000001; // PD: 0
    PORTD &= ~0b00000001;
    DDRB  &= ~0b10001111; // PB: 7 3 2 1 0
    PORTB &= ~0b10001111;
}

static void select_row(uint8_t row)
{
    // Output low(DDR:1, PORT:0) to select
    switch (row) {
        case 0:
            DDRD  |= (1<<0);
            PORTD &= ~(1<<0);
            break;
        case 1:
            DDRB  |= (1<<3);
            PORTB &= ~(1<<3);
            break;
        case 2:
            DDRB  |= (1<<0);
            PORTB &= ~(1<<0);
            break;
        case 3:
            DDRB  |= (1<<7);
            PORTB &= ~(1<<7);
            break;
        case 4:
            DDRB  |= (1<<1);
            PORTB &= ~(1<<1);
            break;
        case 5:
            DDRB  |= (1<<2);
            PORTB &= ~(1<<2);
            break;
    }
}
Greystoke

Unread post20 Oct 2013, 03:38

X
Greystoke
 
Posts: 100
Joined: 26 Feb 2013, 14:16
Main keyboard: CM Storm Trigger
Main mouse: Razer
Favorite switch: Cherry MX Green
Club member: -
 
matrix.c looks good to me. Now you need to define your KEYMAP macro, I guess.
keycodes are defined in common/keycode.h. or see https://github.com/tmk/tmk_keyboard/blo ... eycode.txt
hasu
User avatar

Unread post20 Oct 2013, 04:47

User avatar
X
hasu
 
Posts: 354
Joined: 02 Sep 2011, 14:47
Location: Japan
Main keyboard: HHKB
Main mouse: HHKB
Favorite switch: Topre
Club member: -
 
hasu wrote:matrix.c looks good to me. Now you need to define your KEYMAP macro, I guess.
keycodes are defined in common/keycode.h. or see https://github.com/tmk/tmk_keyboard/blo ... eycode.txt

Working on this now!

For the section that starts with:
Code: Select all
#define KEYMAP( \
are these keycodes supposed to be in the same order as the keys on the keyboard? And then the same codes are used in the block of code with all the "KC_##K00," again in the order as they appear on the keyboard?

I'm trying to figure out the relationship between these two sections, and it's not clear to me.
Greystoke

Unread post21 Oct 2013, 00:10

X
Greystoke
 
Posts: 100
Joined: 26 Feb 2013, 14:16
Main keyboard: CM Storm Trigger
Main mouse: Razer
Favorite switch: Cherry MX Green
Club member: -
 
Yes. With KEYMAP you can convert physical matrix structure into real keyboard layout order.
Code: Select all
#define KEYMAP( \
/* these parameters indicate keyboard layout order */
) { \
/* you must place C array notation of your matrix structure here */
}


The roles of KEYMAP macro are 1)to offer short keycodes without 'KC_' and 2)to convert matrix structure into keyboard layout. With KEYMAP you can place just 'A' instead of 'KC_A' and define keymap in form of real keyboard look.
hasu
User avatar

Unread post21 Oct 2013, 01:52

User avatar
X
hasu
 
Posts: 354
Joined: 02 Sep 2011, 14:47
Location: Japan
Main keyboard: HHKB
Main mouse: HHKB
Favorite switch: Topre
Club member: -
 
hasu wrote:Yes. With KEYMAP you can convert physical matrix structure into real keyboard layout order.
Code: Select all
#define KEYMAP( \
/* these parameters indicate keyboard layout order */
) { \
/* you must place C array notation of your matrix structure here */
}


The roles of KEYMAP macro are 1)to offer short keycodes without 'KC_' and 2)to convert matrix structure into keyboard layout. With KEYMAP you can place just 'A' instead of 'KC_A' and define keymap in form of real keyboard look.

I think I've got it. The first section of the KEYMAP macro contains the keycodes as they are laid out on the keyboard? And the the second section of the KEYMAP macro should contain the keycodes, as they are physically wired to rows and columns on the keyboard? I've done the first bit, now I'm working to translate the layout diagram to keycodes, inserting the right number of KC_NOs.

Code: Select all
#define KEYMAP( \
    K11, K10, K20, K30, K40, K41, K51, K50, K60, K70, K80, K81, K61, K02, \
    K12, K13, K23, K33, K43, K42, K52, K53, K63, K73, K83, K82, K62, K01, \
    K15, K14, K24, K34, K44, K45, K55, K54, K64, K74, K84, K85, K06, \
    K67, K16, K26, K36, K46, K47, K57, K56, K66, K76, K87, K32, K35, \
    K75, K22, K00, K07, K21, K04, K37, K27, K17 \


Apologies for the elementary questions, but the last real programming I'd done was writing BASIC scripts for a computer course, in 1981. ;)
Greystoke

Unread post21 Oct 2013, 12:59

X
Greystoke
 
Posts: 100
Joined: 26 Feb 2013, 14:16
Main keyboard: CM Storm Trigger
Main mouse: Razer
Favorite switch: Cherry MX Green
Club member: -
 
OK. I did code keymap.c for you. Keymap definition is not finished yet, but it is enough to test run.
https://gist.github.com/tmk/7083995

With fixing matrix size in config.h and your matrix.c I could compile it successfully.(You'll have some warnings but not critical.)
Try it and report. If you are lucky you'll see some key is registered on your comp.

config.h fix:
Code: Select all
#define MATRIX_ROWS 6                                                                                                               
#define MATRIX_COLS 19


Is this your keyboard, right? I refered pics of that post to make your keymap.
http://geekhack.org/index.php?topic=49758.0
hasu
User avatar

Unread post21 Oct 2013, 14:47

User avatar
X
hasu
 
Posts: 354
Joined: 02 Sep 2011, 14:47
Location: Japan
Main keyboard: HHKB
Main mouse: HHKB
Favorite switch: Topre
Club member: -
 
That is indeed the keyboard I'm trying to use your code for, thanks! I'll give it a try in a moment, just finished a macro version;

Code: Select all
#define KEYMAP( \
    K84, K3A, K3B, K3C, K3D, K3E, K3F, K40, K42, K43, K44, K49, K4C, K49, K4C, K9C, KA2, K74, \
    K29, K1E, K1F, K20, K21, K22, K23, K24, K25, K26, K27, K2D, K2E, K35, K31, K2A, K5F, K60, K61, \
    K2B, K14, K1A, K08, K15, K17, K1C, K18, K0C, K12, K13, K2F, K9F, K9C, K5C, K5D, K5E, \
    KE0, K39, K04, K16, K07, K09, K0A, K0B, K0D, K0E, K0F, K33, K34, K28, K78, K59, K5A, K5B, \
    K9D, KE1, K1D, K1B, K06, K19, K05, K11, K10, K36, K37, K38, KE5, K30, K4C, K63, K62, K85, \
   K46, KE2, K2C, K4A, K51, K52, K50, K4F, K58, K56  \
) { \
    { KC_##K84, KC_##K3A, KC_##K3B, KC_##K3C, KC_##K3D, KC_##K3E, KC_##K3F, KC_##K40, KC_##K42, KC_##K43, KC_##K44, KC_##K49, KC_##K4C, KC_##K49, KC_##K4C, KC_##K9C, KC_##KA2, KC_##K74, }, \
    { KC_##K29, KC_##K1E, KC_##K1F, KC_##K20, KC_##K21, KC_##K22, KC_##K23, KC_##K24, KC_##K26, KC_##K27, KC_##K2D, KC_##K2E, KC_##K35, KC_##K31, KC_##K2A, KC_##K5F, KC_##K60, KC_##K61, }, \
    { KC_##K2B, KC_##K14, KC_##K1A, KC_##K08, KC_##K15, KC_##K17, KC_##K1C, KC_##K18, KC_##K12, KC_##K0C, KC_##K13, KC_##K2F, KC_##K9F, KC_##K25, KC_##K9C, KC_##K5C, KC_##K5D, KC_##K5E, }, \
    { KC_##K39, KC_##K04, KC_##K16, KC_##K07, KC_##K09, KC_##K0A, KC_##K0B, KC_##K0D, KC_##K0F, KC_##KE0, KC_##K33, KC_##K34, KC_##K0E, KC_##K28, KC_##K78, KC_##K59, KC_##K5A, KC_##K5B, }, \
    { KC_##KE1, KC_##K1D, KC_##K1B, KC_##K06, KC_##K19, KC_##K05, KC_##K11, KC_##K10, KC_NO,    KC_##K9D, KC_##K37, KC_##K38, KC_##KE5, KC_##K30, KC_##K4C, KC_##K63, KC_##K62, KC_##K85, }, \
    { KC_##K46, KC_##KE2, KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_##K36, KC_NO,    KC_##K2C, KC_##K4A, KC_##K51, KC_##K52, KC_##K50, KC_##K4F, KC_##K58, KC_##K56, KC_NO}, \
}
Greystoke

Unread post21 Oct 2013, 15:00

X
Greystoke
 
Posts: 100
Joined: 26 Feb 2013, 14:16
Main keyboard: CM Storm Trigger
Main mouse: Razer
Favorite switch: Cherry MX Green
Club member: -
 
Thanks, hasu! Your code version is working!

I still have some errors (some keys in the middle of the board are transposed, the space bar isn't working, and the number pad is about 50%), but it's far more functional than anything I've been able to produce! :lol:

Now I think I have to trace some column wiring...
Greystoke

Unread post21 Oct 2013, 22:50

X
Greystoke
 
Posts: 100
Joined: 26 Feb 2013, 14:16
Main keyboard: CM Storm Trigger
Main mouse: Razer
Favorite switch: Cherry MX Green
Club member: -
 
[url][/url]Another question, if I may? Looking at the keymap.c file, I'm trying to cross-reference the KC_ codes used with the keycode.txt document you'd linked above (https://github.com/tmk/tmk_keyboard/blob/master/doc/keycode.txt).

For the keymap macro, one line is as follows:
Code: Select all
 { KC_##K50, KC_##K51, KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_##K55, KC_NO,


Referring to the text file, it appears that KC_##K55 is the code for "Keyboard Spacebar," which makes sense, because that's the last/bottom line of the KEYMAP macro section. It seems to correlate to the line number in the txt file document.

Looking at KC_##K50 or KC_##K51, if these codes are line numbers, then 50 = "27 Keyboard 0 and )" and 51 = "28 Keyboard Return (ENTER)". Is this correct?
Greystoke

Unread post21 Oct 2013, 23:41

X
Greystoke
 
Posts: 100
Joined: 26 Feb 2013, 14:16
Main keyboard: CM Storm Trigger
Main mouse: Razer
Favorite switch: Cherry MX Green
Club member: -
 
PreviousNext

Who is online

Users browsing this forum: listofoptions, lupodimare, MatchstickMan, mmcdowell and 42 guests