TMK keyboard firmware collection

User avatar
snacksthecat
✶✶✶✶

13 Oct 2018, 22:04

Sorry, I never got around to doing the leafspring board yet but I will post the keymap here once I do.

I eventually figured out the LED issue with my other keyboard. It turned out I had it wired incorrectly. After I fixed the wiring issue, it worked perfectly with that snippet.

Thank you for this great software!

User avatar
snacksthecat
✶✶✶✶

06 Jan 2019, 00:32

I have an IBM model M industrial with an integrated mouse nub thingy. Could anyone point me in the right direction for getting that two work with TMK? I haven't been able to figure it out so far. Also, would it be possible to use a single microcontroller or would it require two? Thanks!

User avatar
snacksthecat
✶✶✶✶

06 Jan 2019, 20:35

Update: I got just the trackpoint working with the "onekey" configuration. But still unsure about how I would enable this feature in addition to using the "ps2_usb" converter. It seems like the converter and the ps2 mouse support both use the same pin definitions. My main question now is whether I'd need to use two microcontrollers or if it's possible to do both on the same chip.

User avatar
hasu

08 Jan 2019, 04:06

Current firmeware(ps2_interrupt.c) doesn't support two instances of PS/2 device(keyboard and mouse) unfortunately. I believe it is possible to support the two PS/2 devices with some fixes on the related source codes, though. You will have to parameterize clock and data pin configuration to give to PS/2 initialization function.

trey1901

12 Jan 2019, 05:37

was able to fix some errors still need some help here are current error codes, posted in another forum this one was linked there and seemed more active!
Spoiler:

Code: Select all

Trey@GHOST MINGW64 ~/qmk_firmware/tmk_keyboard-master/keyboard/gh60
$ make -f Makefile


avr-gcc.exe (AVR_8_bit_GNU_Toolchain_3.6.1_1752) 5.4.0
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


mkdir -p obj_gh60_lufa
Compiling C: keymap_poker.c
avr-gcc -c -mmcu=at90usb1287 -gdwarf-2 -DF_CPU=16000000UL -DINTERRUPT_CONTROL_ENDPOINT -DBOOTLOADER_SIZE=4096 -DF_USB=16000000UL -DARCH=ARCH_AVR8 -DUSB_DEVICE_ONLY -DUSE_FLASH_DESCRIPTORS -DUSE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)" -DFIXED_CONTROL_ENDPOINT_SIZE=8  -DFIXED_NUM_CONFIGURATIONS=1 -DPROTOCOL_LUFA -DBOOTMAGIC_ENABLE -DMOUSEKEY_ENABLE -DMOUSE_ENABLE -DEXTRAKEY_ENABLE -DCONSOLE_ENABLE -DCOMMAND_ENABLE -DVERSION=preonic-1.0-7068-g9c2d77612-dirty -Os -funsigned-char -funsigned-bitfields -ffunction-sections -fdata-sections -fno-inline-small-functions -fpack-struct -fshort-enums -fno-strict-aliasing -Wall -Wstrict-prototypes -Wa,-adhlns=obj_gh60_lufa/keymap_poker.lst -I. -I../../tmk_core -I../../tmk_core/protocol/lufa -I../../tmk_core/protocol/lufa/LUFA-git -I../../tmk_core/common -std=gnu99 -include config.h -MMD -MP -MF .dep/obj_gh60_lufa_keymap_poker.o.d  keymap_poker.c -o obj_gh60_lufa/keymap_poker.o
In file included from keymap_poker.c:1:0:
keymap_common.h:46:147: error: 'KC_' undeclared here (not in a function)
     { KC_##K40, KC_##K41, KC_##K42, KC_NO,    KC_##K44,    KC_NO, KC_NO,    KC_NO,    KC_NO,    KC_##K49, KC_##K4A, KC_##K4B, KC_##K4C, KC_##K4D, KC_##K4E }  \
                                                                                                                                                   ^
keymap_poker.c:5:5: note: in expansion of macro 'KEYMAP'
     KEYMAP(ESC, 1,   2,   3,   4,   5,   6,   7,   8,   9,   0,   MINS,EQL, BSPC,\
     ^
keymap_common.h:46:147: warning: excess elements in array initializer
     { KC_##K40, KC_##K41, KC_##K42, KC_NO,    KC_##K44,    KC_NO, KC_NO,    KC_NO,    KC_NO,    KC_##K49, KC_##K4A, KC_##K4B, KC_##K4C, KC_##K4D, KC_##K4E }  \
                                                                                                                                                   ^
keymap_poker.c:5:5: note: in expansion of macro 'KEYMAP'
     KEYMAP(ESC, 1,   2,   3,   4,   5,   6,   7,   8,   9,   0,   MINS,EQL, BSPC,\
     ^
keymap_common.h:46:147: note: (near initialization for 'keymaps[0][4]')
     { KC_##K40, KC_##K41, KC_##K42, KC_NO,    KC_##K44,    KC_NO, KC_NO,    KC_NO,    KC_NO,    KC_##K49, KC_##K4A, KC_##K4B, KC_##K4C, KC_##K4D, KC_##K4E }  \
                                                                                                                                                   ^
keymap_poker.c:5:5: note: in expansion of macro 'KEYMAP'
     KEYMAP(ESC, 1,   2,   3,   4,   5,   6,   7,   8,   9,   0,   MINS,EQL, BSPC,\
     ^
make: *** [../../tmk_core/rules.mk:557: obj_gh60_lufa/keymap_poker.o] Error 1
here is my poker.c file
Spoiler:

Code: Select all

#include "keymap_common.h"

const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
    /* 0: qwerty */
    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, \
        CAPS,A,   S,   D,   F,   G,   H,   J,   K,   L,   SCLN,QUOT,     ENT, \
        LSFT,Z,   X,   C,   V,   B,   N,   M,   COMM,DOT, SLSH,          RSFT,UP, \
        LCTL,LGUI,LALT,          SPC,                     RALT,RCTL,GRV, LEFT,DOWN,RGHT,),
};

const uint16_t PROGMEM fn_actions[] = {

};
here is the config file
Spoiler:

Code: Select all

#ifndef CONFIG_H
#define CONFIG_H


/* USB Device descriptor parameter */
#define VENDOR_ID       0xFEED
#define PRODUCT_ID      0x6060
#define DEVICE_VER      0x0001
#define MANUFACTURER    geekhack
#define PRODUCT         GH60
#define DESCRIPTION     t.m.k. keyboard firmware for GH60

/* key matrix size */
#define MATRIX_ROWS 5
#define MATRIX_COLS 14

/* define if matrix has ghost */
//#define MATRIX_HAS_GHOST

/* Set 0 if debouncing isn't needed */
#define DEBOUNCE    5

/* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */
#define LOCKING_SUPPORT_ENABLE
/* Locking resynchronize hack */
#define LOCKING_RESYNC_ENABLE

/* key combination for command */
#define IS_COMMAND() ( \
    keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \
)



/*
 * Feature disable options
 *  These options are also useful to firmware size reduction.
 */

/* disable debug print */
//#define NO_DEBUG

/* disable print */
//#define NO_PRINT

/* disable action features */
//#define NO_ACTION_LAYER
//#define NO_ACTION_TAPPING
//#define NO_ACTION_ONESHOT
//#define NO_ACTION_MACRO
//#define NO_ACTION_FUNCTION

#endif
and finally the keymap common file
Spoiler:

Code: Select all

#ifndef KEYMAP_COMMON_H
#define KEYMAP_COMMON_H

#include <stdint.h>
#include <stdbool.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"


/* GH60 keymap definition macro
 * K2C, K31 and  K3C are extra keys for ISO
 */
#define KEYMAP( \
    K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, K0C, K0D, \
    K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D, \
    K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, K2C, \
    K30, K31, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B, K3C, K3D,\
    K40, K41, K42,      K44,                     K49, K4A, K4B, K4C, K4D, K4E \
) { \
    { KC_##K00, KC_##K01, KC_##K02, KC_##K03, KC_##K04, KC_##K05, KC_##K06, KC_##K07, KC_##K08, KC_##K09, KC_##K0A, KC_##K0B, KC_##K0C, KC_##K0D }, \
    { KC_##K10, KC_##K11, KC_##K12, KC_##K13, KC_##K14, KC_##K15, KC_##K16, KC_##K17, KC_##K18, KC_##K19, KC_##K1A, KC_##K1B, KC_##K1C, KC_##K1D }, \
    { KC_##K20, KC_##K21, KC_##K22, KC_##K23, KC_##K24, KC_##K25, KC_##K26, KC_##K27, KC_##K28, KC_##K29, KC_##K2A, KC_##K2B, KC_##K2C }, \
    { KC_##K30, KC_##K31, KC_##K32, KC_##K33, KC_##K34, KC_##K35, KC_##K36, KC_##K37, KC_##K38, KC_##K39, KC_##K3A, KC_##K3B, KC_##K3C, KC_##K3D }, \
    { KC_##K40, KC_##K41, KC_##K42, KC_NO,    KC_##K44,    KC_NO, KC_NO,    KC_NO,    KC_NO,    KC_##K49, KC_##K4A, KC_##K4B, KC_##K4C, KC_##K4D, KC_##K4E }  \
}

/* ANSI variant. No extra keys for ISO */
#define KEYMAP_ANSI( \
    K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, K0C, K0D, \
    K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D, \
    K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B,      K2D, \
    K30, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B,           K3D, \
    K40, K41, K42,           K45,                     K4A, K4B, K4C, K4D  \
) KEYMAP( \
    K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, K0C, K0D, \
    K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D, \
    K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, NO,  K2D, \
    K30, NO,  K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B, NO,  K3D, \
    K40, K41, K42,           K45,                NO,  K4A, K4B, K4C, K4D  \
)


#define KEYMAP_HHKB( \
    K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, K0C, K0D, K49,\
    K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D, \
    K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B,      K2D, \
    K30, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B,      K3D, K3C, \
    K40, K41, K42,           K45,                     K4A, K4B, K4C, K4D  \
) KEYMAP( \
    K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, K0C, K0D, \
    K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D, \
    K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, NO,  K2D, \
    K30, NO,  K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B, K3C, K3D, \
    K40, K41, K42,           K45,                K49, K4A, K4B, K4C, K4D  \
)

#endif
will still be trying to solve it but any help would be great!

User avatar
hasu

12 Jan 2019, 06:07

Parameters of KEYMAP in your poker.c doesn't match for keymap common.
Check fourth line and the last(fifth) line of your KEYMAP().

trey1901

12 Jan 2019, 08:01

hasu wrote:
12 Jan 2019, 06:07
Parameters of KEYMAP in your poker.c doesn't match for keymap common.
Check fourth line and the last(fifth) line of your KEYMAP().
okay now i seem to get an error about my matrix file
Spoiler:

Code: Select all

atrix.o.d  matrix.c -o obj_gh60_lufa/matrix.o
matrix.c: In function 'read_cols':
matrix.c:128:41: error: expected expression before ')' token
            (PINF&(1<<7) ? 0 : (1<<14)) |);
                                         ^
matrix.c:128:41: error: expected statement before ')' token
matrix.c:129:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
make: *** [../../tmk_core/rules.mk:557: obj_gh60_lufa/matrix.o] Error 1
here is the matrix file with lines mentioned
Spoiler:

Code: Select all

/* Column pin configuration
 * col: 0   1   2   3   4   5   6   7   8   9   10 11 12 13 14
 * pin: B6  B5  B4  B3  B2  B1  B0  E7  E6  F0  F1 F2 F3 F4 F7  (Rev.A)
 * pin:                                 B7                      (Rev.B)
 */
static void  init_cols(void)
{
    // Input with pull-up(DDR:0, PORT:1)
    DDRF  &= ~(1<<6 | 1<<5 | 1<<4 | 1<<3 | 1<<1 | 1<<0);
    PORTF |=  (1<<6 | 1<<5 | 1<<4 | 1<<3 | 1<<1 | 1<<0);
    DDRE  &= ~(1<<7 | 1<<6);
    PORTE |=  (1<<7 | 1<<6);
    DDRC  &= ~(1<<7 | 1<<6 | 1<<5 | 1<<4 | 1<<3);
    PORTC |=  (1<<7 | 1<<6 | 1<<5 | 1<<4 | 1<<3);
    DDRB  &= ~(1<<6 | 1<<5 | 1<<4 | 1<<3 | 1<<1 | 1<<0);
    PORTB |=  (1<<6 | 1<<5 | 1<<4 | 1<<3 | 1<<1 | 1<<0);
}

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

/* Row pin configuration
 * row: 0   1   2   3   4
 * pin: C3  C4  C5  C6  C7
 */
static void unselect_rows(void)

trey1901

12 Jan 2019, 08:11

well i got it to compile, but it doesnt type just random stings of letters and shit.

trey1901

12 Jan 2019, 09:44

trey1901 wrote:
12 Jan 2019, 08:11
well i got it to compile, but it doesnt type just random stings of letters and shit.
if someone would like to look at my files and maybe see if they can tell that'd be great cause im sorta at a loss.

config
Spoiler:

Code: Select all

#ifndef CONFIG_H
#define CONFIG_H


/* USB Device descriptor parameter */
#define VENDOR_ID       0xFEED
#define PRODUCT_ID      0x6060
#define DEVICE_VER      0x0001
#define MANUFACTURER    geekhack
#define PRODUCT         GH60
#define DESCRIPTION     t.m.k. keyboard firmware for GH60

/* key matrix size */
#define MATRIX_ROWS 5
#define MATRIX_COLS 14

/* define if matrix has ghost */
//#define MATRIX_HAS_GHOST

/* Set 0 if debouncing isn't needed */
#define DEBOUNCE    5

/* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */
#define LOCKING_SUPPORT_ENABLE
/* Locking resynchronize hack */
#define LOCKING_RESYNC_ENABLE

/* key combination for command */
#define IS_COMMAND() ( \
    keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \
)



/*
 * Feature disable options
 *  These options are also useful to firmware size reduction.
 */

/* disable debug print */
//#define NO_DEBUG

/* disable print */
//#define NO_PRINT

/* disable action features */
//#define NO_ACTION_LAYER
//#define NO_ACTION_TAPPING
//#define NO_ACTION_ONESHOT
//#define NO_ACTION_MACRO
//#define NO_ACTION_FUNCTION

#endif
keymap common
Spoiler:

Code: Select all

#ifndef KEYMAP_COMMON_H
#define KEYMAP_COMMON_H

#include <stdint.h>
#include <stdbool.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"


/* GH60 keymap definition macro
 * K2C, K31 and  K3C are extra keys for ISO
 */
#define KEYMAP( \
    K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, K0C, K0D, \
    K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D, \
    K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, K2C, \
    K30, K31, K32, K33, K34, K35, K36, K37, K38, K39, K3A,      K3C, K3D,\
    K40, K41, K42,      K44,                     K49, K4A, K4B, K4C, K4D, K4E \
) { \
    { KC_##K00, KC_##K01, KC_##K02, KC_##K03, KC_##K04, KC_##K05, KC_##K06, KC_##K07, KC_##K08, KC_##K09, KC_##K0A, KC_##K0B, KC_##K0C, KC_##K0D }, \
    { KC_##K10, KC_##K11, KC_##K12, KC_##K13, KC_##K14, KC_##K15, KC_##K16, KC_##K17, KC_##K18, KC_##K19, KC_##K1A, KC_##K1B, KC_##K1C, KC_##K1D }, \
    { KC_##K20, KC_##K21, KC_##K22, KC_##K23, KC_##K24, KC_##K25, KC_##K26, KC_##K27, KC_##K28, KC_##K29, KC_##K2A, KC_##K2B, KC_##K2C }, \
    { KC_##K30, KC_##K31, KC_##K32, KC_##K33, KC_##K34, KC_##K35, KC_##K36, KC_##K37, KC_##K38, KC_##K39, KC_##K3A, KC_NO,    KC_##K3C, KC_##K3D }, \
    { KC_##K40, KC_##K41, KC_##K42, KC_NO,    KC_##K44,    KC_NO, KC_NO,    KC_NO,    KC_NO,    KC_##K49, KC_##K4A, KC_##K4B, KC_##K4C, KC_##K4D, KC_##K4E }  \
}

/* ANSI variant. No extra keys for ISO */
#define KEYMAP_ANSI( \
    K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, K0C, K0D, \
    K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D, \
    K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B,      K2D, \
    K30, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B,           K3D, \
    K40, K41, K42,           K45,                     K4A, K4B, K4C, K4D  \
) KEYMAP( \
    K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, K0C, K0D, \
    K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D, \
    K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, NO,  K2D, \
    K30, NO,  K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B, NO,  K3D, \
    K40, K41, K42,           K45,                NO,  K4A, K4B, K4C, K4D  \
)


#define KEYMAP_HHKB( \
    K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, K0C, K0D, K49,\
    K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D, \
    K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B,      K2D, \
    K30, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B,      K3D, K3C, \
    K40, K41, K42,           K45,                     K4A, K4B, K4C, K4D  \
) KEYMAP( \
    K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, K0C, K0D, \
    K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D, \
    K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, NO,  K2D, \
    K30, NO,  K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B, K3C, K3D, \
    K40, K41, K42,           K45,                K49, K4A, K4B, K4C, K4D  \
)

#endif
keymap poker
Spoiler:

Code: Select all

#include "keymap_common.h"

const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
    /* 0: qwerty */
    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, \
        CAPS,A,   S,   D,   F,   G,   H,   J,   K,   L,   SCLN,QUOT,ENT,    \
        LSFT,Z,   X,   C,   V,   B,   N,   M,   COMM,DOT, SLSH,     RSFT, UP, \
        LCTL,LGUI,LALT,     SPC,                     RALT,RCTL,GRV, LEFT,DOWN,RIGHT),
};

const uint16_t PROGMEM fn_actions[] = {

};
and the matrix
Spoiler:

Code: Select all

#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);


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;
}

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

/* Column pin configuration
 * col: 0   1   2   3   4   5   6   7   8   9   10 11 12 13 14
 * pin: B6  B5  B4  B3  B2  B1  B0  E7  E6  F0  F1 F2 F3 F4 F7  (Rev.A)
 * pin:                                 B7                      (Rev.B)
 */
static void  init_cols(void)
{
    // Input with pull-up(DDR:0, PORT:1)
	DDRB  &= ~(1<<6 | 1<<5 | 1<<4 | 1<<3 | 1<<2 | 1<<1 | 1<<0);
    PORTB |=  (1<<6 | 1<<5 | 1<<4 | 1<<3 | 1<<2 | 1<<1 | 1<<0);
    DDRE  &= ~(1<<7 | 1<<6);
    PORTE |=  (1<<7 | 1<<6);
	DDRF  &= ~(1<<7 | 1<<4 | 1<<3 | 1<<2 | 1<<1 | 1<<0);
    PORTF |=  (1<<7 | 1<<4 | 1<<3 | 1<<2 | 1<<1 | 1<<0);
    
}

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

/* Row pin configuration
 * row: 0   1   2   3   4
 * pin: C3  C4  C5  C6  C7
 */
static void unselect_rows(void)
{
    // Hi-Z(DDR:0, PORT:0) to unselect
    DDRC  &= ~0b01111100;
    PORTC &= ~0b01111100;
}

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

User avatar
snacksthecat
✶✶✶✶

12 Jan 2019, 20:00

hasu wrote:
08 Jan 2019, 04:06
Current firmeware(ps2_interrupt.c) doesn't support two instances of PS/2 device(keyboard and mouse) unfortunately. I believe it is possible to support the two PS/2 devices with some fixes on the related source codes, though. You will have to parameterize clock and data pin configuration to give to PS/2 initialization function.
Thank you! I'll give it a shot

User avatar
Muirium
µ

15 Jan 2019, 05:35

Hey Hasu (and anyone else with more clues than me!),

Here's my current HHKB layout in Unimap. I'm trying to add an integrated numpad mode (like my Realforce 87U) and even some mouse keys while I'm at it. The mystery is how best to access those layers. Here's what I'm trying: a whole line of layer shortcuts along the unused ZXC and V keys in Layer 1:

Screenshot 2019-01-14 at 8.29.36 pm.png
Screenshot 2019-01-14 at 8.29.36 pm.png (42.31 KiB) Viewed 137 times
What I'd really like is to fall back to Layer 0 whenever I want to get out of numpad or mouse modes. But layer toggles don't work like that. They seem to be a stack where you pop things on and off. But I don't want to wind up "stuck" in numpad mode or mouse mode, or indeed a hybrid of both, which is what it feels like using this! I don't want to memorise the "route" I took to get to a given state.

I'd much rather have a sanity key that takes me back to layer 0 and the HHKB I love! Any idea how to do that?

User avatar
hasu

15 Jan 2019, 06:46

Can't you disable the numpad and mouse layer with pressing L1+{C, V}?
Layer1 is disabled when you release L1(on layer 0), so Toggle keys(T*) on Layer1 is not available on Layer2(numpad) and 3(mouse) without pressing L1.

Or you want to place real toggle keys on those layers instead of 'TRNS' so that you can press just C and V without L1 to leave the layer?

User avatar
Muirium
µ

15 Jan 2019, 07:06

Hi Hasu! Strange things happen…

Just now, for instance, I noticed your reply in the Forum Spy, so I toggled the mouse keys layer with Fn + V to mouse over and click the link to this thread. Which worked fine.

Then I tried to get back to Layer 0 to write this response. But I couldn't! I was stuck in mouse keys. I could only disable them with a power cycle of the keyboard. Let's try a numpad example…

So I'm in Layer 0. I press Fn + C to enter Layer 2: numpad. 123456789. I press Fn + C again to exit it. Works good. But what I really want is to tell the keyboard where I want to *go*, not to "undo where I am". So let's try that. I press Fn + C 987654321 And then Fn = wa5t a 05n45t+ No, needs to be Fn + C. Fn + Z actually puts me in a weird hybrid layer where, as you can see, the keys specified in the numpad layer act as a numpad while the others are still regular alphas; falling back to TRNS I suppose. The only way to escape this is by popping the stack with Fn + C, not Z.

Real problems begin when I've already switched layers a few times. That's when I can get completely trapped, I guess because I'm adding *more* layers to the stack by toggling them off in an incorrect sequence. It's very weird when you wind up trapped!


Edit: I get what you're saying about putting layer toggle keys inside the alternate layers. I tried that with Z always being T0 on every layer. Didn't seem to help.

What I'd really like is to change (with layers) what the Fn key does. Because to me it feels more natural holding Fn when using the mouse keys and numpad. And whenever Fn is not pressed? Layer 0, of course. Perhaps I'm looking for Fn + C <hold Fn> press keys for numpad function <release Fn> return to normal HHKB Layer 0; with subsequent presses of Fn going back to Layer 1 as usual.

User avatar
hasu

15 Jan 2019, 09:13

Muirium wrote:
15 Jan 2019, 07:06
Hi Hasu! Strange things happen…

Just now, for instance, I noticed your reply in the Forum Spy, so I toggled the mouse keys layer with Fn + V to mouse over and click the link to this thread. Which worked fine.

Then I tried to get back to Layer 0 to write this response. But I couldn't! I was stuck in mouse keys. I could only disable them with a power cycle of the keyboard. Let's try a numpad example…
How did you leave the mouse keys layer?
I assume you used Fn+V, this doesn't work for you? This shouldn't be stuck in the layer.

Or You are using T0? No, T0 doens't work like that and it is not useful at all in most use cases. I don't think using T0 is harmful here, though.

So I'm in Layer 0. I press Fn + C to enter Layer 2: numpad. 123456789. I press Fn + C again to exit it. Works good. But what I really want is to tell the keyboard where I want to *go*, not to "undo where I am". So let's try that. I press Fn + C 987654321 And then Fn = wa5t a 05n45t+ No, needs to be Fn + C. Fn + Z actually puts me in a weird hybrid layer where, as you can see, the keys specified in the numpad layer act as a numpad while the others are still regular alphas; falling back to TRNS I suppose. The only way to escape this is by popping the stack with Fn + C, not Z.
I'm still not completely sure but probably you want to use 'ACTION_LAYER_SET(layer, on)' to enable a layer at a time. Unfortunately the action is not support in Keymap Editor at this point, you have write keymapping file and build firmware from source.
https://github.com/tmk/tmk_core/blob/ma ... -set-layer

Real problems begin when I've already switched layers a few times. That's when I can get completely trapped, I guess because I'm adding *more* layers to the stack by toggling them off in an incorrect sequence. It's very weird when you wind up trapped!


Edit: I get what you're saying about putting layer toggle keys inside the alternate layers. I tried that with Z always being T0 on every layer. Didn't seem to help.

What I'd really like is to change (with layers) what the Fn key does. Because to me it feels more natural holding Fn when using the mouse keys and numpad. And whenever Fn is not pressed? Layer 0, of course. Perhaps I'm looking for Fn + C <hold Fn> press keys for numpad function <release Fn> return to normal HHKB Layer 0; with subsequent presses of Fn going back to Layer 1 as usual.
You may find useful actions in this document for your needs, otherwise, you will have to write you own function for the key.
https://github.com/tmk/tmk_core/blob/ma ... /keymap.md

User avatar
Muirium
µ

15 Jan 2019, 09:33

Thanks for the pointers, Hasu. I may get good and nerdy and redefine the Fn key for real, someday…

For now, I'm using this keymap which is working better. I changed Z in the other layers to ACTION_LAYER_CLEAR in Unimap's Code tab. That actually shows up as ACTION_LAYER_BIT_AND but works as I thought: the layer toggles are dropped and you're back in Layer 0. I don't seem to be getting "lost" now, phew!

Incidentally, I'm doing all this firmware flashing with QMK Toolbox. Works great. A much friendlier GUI experience for me.

User avatar
Muirium
µ

16 Jan 2019, 02:22

All right! Here's today's fresh attempt, this time using tap layers:

Screenshot 2019-01-15 at 5.17.03 pm.png
Screenshot 2019-01-15 at 5.17.03 pm.png (29.3 KiB) Viewed 68 times
LT = layer tap. The key works like normal, unless held down in which case it becomes an Fn key for a whole other layer.

Works really nicely! Hasu's link to the documentation got me reading about tap keys, and the example in there using semicolon as a second function key made me try the same. Brilliant! So now ; = mouse key layer, and ' = numpad layer. Those two keys are well placed and aren't alphas I often need to type quickly in succession. So far so nifty.

Post Reply

Return to “Workshop”