How to build your very own keyboard firmware

K-rnix

11 Jun 2017, 02:41

I finally got Hasu's code working on my Commodore 64 keyboard. Now I'm facing a new challenge. See, the C-64 keyboard has different keys not found in a PC keyboard, for example a "@" only key, or an asterisk only (*) key too. I think I can use the LANGn keycode and replace it for a MACRO, but I do not know how to do it. Also I'd like to define some usefull macros, for example LSHIFT+SPACE as TAB key, or RSHIFT+LSHIFHT+DEL as ALT+CTRL+DEL.
Is there someone can give me a hint? I cannot figure it out from the Hasu's docs (https://github.com/tmk/tmk_core/blob/ma ... /keymap.md)

Jdude1

01 Jul 2017, 17:33

So I am trying to build my first custom Keyboard device. I decided to start simple with a Numpad. I also decided to go cheap so I bought a 3 pack of Kookye Pro Micro's (Lenardo Arduino) microcontrollers. I've got my matrix wired and now I'm working through the code here to try to make a simple 5 row x 4 column numpad (with a few No Connects). Here's the message I'm getting when I try to build the code with Cygwin64 Terminal. I'll preface all of this with the fact that I only took one C++ class in college and I was always having issues in the class due to the length of time it took me to even debug simple code I wrote myself so Unfortunatly you're working with a Noob Here. I saw Matt3o's walkthough and though. Hmmm I could probably do this but unfortnately I'm in a rut so I thought I'd post my code here and ask you experts how to clean it up.

Here's the Compile Error.
dcmcf@DESKTOP-DAVID /cygdrive/c/users/dcmcf/desktop/tmk_keyboard-master/keyboard/gh60
$ make -f Makefile
/usr/bin/sh: dfu-programmer: command not found
/usr/bin/sh: dfu-programmer: command not found

-------- begin --------
avr-gcc (WinAVR 20100110) 4.3.3
Copyright (C) 2008 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=atmega32u4 -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=unknown -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
keymap_poker.c:9:1: error: pasting "KC_" and "/" does not give a valid preprocessing token
keymap_poker.c:9: error: 'KC_' undeclared here (not in a function)
keymap_poker.c:5: error: expected expression before ',' token
keymap_poker.c:9:1: error: pasting "KC_" and "*" does not give a valid preprocessing token
keymap_poker.c:9:1: error: pasting "KC_" and "-" does not give a valid preprocessing token
keymap_poker.c:5: warning: braces around scalar initializer
keymap_poker.c:5: warning: (near initialization for 'keymaps[0][0][3]')
keymap_poker.c:5: warning: excess elements in scalar initializer
keymap_poker.c:5: warning: (near initialization for 'keymaps[0][0][3]')
keymap_poker.c:5: warning: excess elements in scalar initializer
keymap_poker.c:5: warning: (near initialization for 'keymaps[0][0][3]')
keymap_poker.c:9:1: error: pasting "KC_" and "+" does not give a valid preprocessing token
keymap_poker.c:5: error: expected expression before '}' token
keymap_poker.c:5: warning: excess elements in scalar initializer
keymap_poker.c:5: warning: (near initialization for 'keymaps[0][0][3]')
keymap_poker.c:9:1: error: pasting "KC_" and "." does not give a valid preprocessing token
keymap_poker.c:5: warning: excess elements in array initializer
keymap_poker.c:5: warning: (near initialization for 'keymaps[0][0]')
keymap_poker.c:12: warning: braces around scalar initializer
keymap_poker.c:12: warning: (near initialization for 'keymaps[0][0][4]')
keymap_poker.c:12: warning: braces around scalar initializer
keymap_poker.c:12: warning: (near initialization for 'keymaps[0][0][4]')
keymap_poker.c:12: warning: excess elements in scalar initializer
keymap_poker.c:12: warning: (near initialization for 'keymaps[0][0][4]')
keymap_poker.c:12: warning: excess elements in scalar initializer
keymap_poker.c:12: warning: (near initialization for 'keymaps[0][0][4]')
keymap_poker.c:12: warning: excess elements in scalar initializer
keymap_poker.c:12: warning: (near initialization for 'keymaps[0][0][4]')
keymap_poker.c:12: warning: braces around scalar initializer
keymap_poker.c:12: warning: (near initialization for 'keymaps[0][0][4]')
keymap_poker.c:12: warning: excess elements in scalar initializer
keymap_poker.c:12: warning: (near initialization for 'keymaps[0][0][4]')
keymap_poker.c:12: warning: excess elements in scalar initializer
keymap_poker.c:12: warning: (near initialization for 'keymaps[0][0][4]')
keymap_poker.c:12: warning: excess elements in scalar initializer
keymap_poker.c:12: warning: (near initialization for 'keymaps[0][0][4]')
keymap_poker.c:12: warning: excess elements in scalar initializer
keymap_poker.c:12: warning: (near initialization for 'keymaps[0][0][4]')
keymap_poker.c:12: warning: braces around scalar initializer
keymap_poker.c:12: warning: (near initialization for 'keymaps[0][0][4]')
keymap_poker.c:12: warning: excess elements in scalar initializer
keymap_poker.c:12: warning: (near initialization for 'keymaps[0][0][4]')
keymap_poker.c:12: warning: excess elements in scalar initializer
keymap_poker.c:12: warning: (near initialization for 'keymaps[0][0][4]')
keymap_poker.c:12: warning: excess elements in scalar initializer
keymap_poker.c:12: warning: (near initialization for 'keymaps[0][0][4]')
keymap_poker.c:12: warning: excess elements in scalar initializer
keymap_poker.c:12: warning: (near initialization for 'keymaps[0][0][4]')
keymap_poker.c:12: warning: braces around scalar initializer
keymap_poker.c:12: warning: (near initialization for 'keymaps[0][0][4]')
keymap_poker.c:12: warning: excess elements in scalar initializer
keymap_poker.c:12: warning: (near initialization for 'keymaps[0][0][4]')
keymap_poker.c:12: warning: excess elements in scalar initializer
keymap_poker.c:12: warning: (near initialization for 'keymaps[0][0][4]')
keymap_poker.c:12: warning: excess elements in scalar initializer
keymap_poker.c:12: warning: (near initialization for 'keymaps[0][0][4]')
keymap_poker.c:12: warning: excess elements in scalar initializer
keymap_poker.c:12: warning: (near initialization for 'keymaps[0][0][4]')
keymap_poker.c:12: warning: braces around scalar initializer
keymap_poker.c:12: warning: (near initialization for 'keymaps[0][0][4]')
keymap_poker.c:12: warning: excess elements in scalar initializer
keymap_poker.c:12: warning: (near initialization for 'keymaps[0][0][4]')
keymap_poker.c:12: warning: excess elements in scalar initializer
keymap_poker.c:12: warning: (near initialization for 'keymaps[0][0][4]')
keymap_poker.c:12: warning: excess elements in scalar initializer
keymap_poker.c:12: warning: (near initialization for 'keymaps[0][0][4]')
keymap_poker.c:12: warning: excess elements in scalar initializer
keymap_poker.c:12: warning: (near initialization for 'keymaps[0][0][4]')
keymap_poker.c:12: warning: excess elements in array initializer
keymap_poker.c:12: warning: (near initialization for 'keymaps[0][0]')
keymap_poker.c:19: warning: braces around scalar initializer
keymap_poker.c:19: warning: (near initialization for 'fn_actions[0]')
keymap_poker.c:19: error: field name not in record or union initializer
keymap_poker.c:19: error: (near initialization for 'fn_actions[0]')
keymap_poker.c:20: warning: braces around scalar initializer
keymap_poker.c:20: warning: (near initialization for 'fn_actions[1]')
keymap_poker.c:20: error: field name not in record or union initializer
keymap_poker.c:20: error: (near initialization for 'fn_actions[1]')
make: *** [obj_gh60_lufa/keymap_poker.o] Error 1
Here's my Code in Question. I'm assuming it's an error in my Keymap_common.h file or my Keymap_poker.c file. Am I using bad parameters /,*,- or something? Am I missing a simple comma or backslash?

config.h

Code: Select all

#----------------------------------------------------------------------------
# On command line:
#
# make all = Make software.
#
# make clean = Clean out built project files.
#
# make coff = Convert ELF to AVR COFF.
#
# make extcoff = Convert ELF to AVR Extended COFF.
#
# make program = Download the hex file to the device.
#                Please customize your programmer settings(PROGRAM_CMD)
#
# make teensy = Download the hex file to the device, using teensy_loader_cli.
#               (must have teensy_loader_cli installed).
#
# make dfu = Download the hex file to the device, using dfu-programmer (must
#            have dfu-programmer installed).
#
# make flip = Download the hex file to the device, using Atmel FLIP (must
#             have Atmel FLIP installed).
#
# make dfu-ee = Download the eeprom file to the device, using dfu-programmer
#               (must have dfu-programmer installed).
#
# make flip-ee = Download the eeprom file to the device, using Atmel FLIP
#                (must have Atmel FLIP installed).
#
# make debug = Start either simulavr or avarice as specified for debugging, 
#              with avr-gdb or avr-insight as the front end for debugging.
#
# make filename.s = Just compile filename.c into the assembler code only.
#
# make filename.i = Create a preprocessed source file for use in submitting
#                   bug reports to the GCC project.
#
# To rebuild project do "make clean" then "make all".
#----------------------------------------------------------------------------

# Target file name (without extension).
TARGET = gh60_lufa

# Directory common source filess exist
TMK_DIR = ../../tmk_core

# Directory keyboard dependent files exist
TARGET_DIR = .

# project specific files
SRC =	matrix.c \
	led.c

ifdef KEYMAP
    SRC := keymap_$(KEYMAP).c $(SRC)
else
    SRC := keymap_poker.c $(SRC)
endif

CONFIG_H = config.h


# MCU name
#MCU = at90usb1287
MCU = atmega32u4

# Processor frequency.
#     This will define a symbol, F_CPU, in all source code files equal to the
#     processor frequency in Hz. You can then use this symbol in your source code to
#     calculate timings. Do NOT tack on a 'UL' at the end, this will be done
#     automatically to create a 32-bit value in your source code.
#
#     This will be an integer division of F_USB below, as it is sourced by
#     F_USB after it has run through any CPU prescalers. Note that this value
#     does not *change* the processor frequency - it should merely be updated to
#     reflect the processor speed set externally so that the code can use accurate
#     software delays.
F_CPU = 16000000


#
# LUFA specific
#
# Target architecture (see library "Board Types" documentation).
ARCH = AVR8

# Input clock frequency.
#     This will define a symbol, F_USB, in all source code files equal to the
#     input clock frequency (before any prescaling is performed) in Hz. This value may
#     differ from F_CPU if prescaling is used on the latter, and is required as the
#     raw input clock is fed directly to the PLL sections of the AVR for high speed
#     clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL'
#     at the end, this will be done automatically to create a 32-bit value in your
#     source code.
#
#     If no clock division is performed on the input clock inside the AVR (via the
#     CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU.
F_USB = $(F_CPU)

# Interrupt driven control endpoint task(+60)
OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT


# Boot Section Size in *bytes*
#   Teensy halfKay   512
#   Teensy++ halfKay 1024
#   Atmel DFU loader 4096
#   LUFA bootloader  4096
#   USBaspLoader     2048
OPT_DEFS += -DBOOTLOADER_SIZE=4096


# Build Options
#   comment out to disable the options.
#
BOOTMAGIC_ENABLE = yes	# Virtual DIP switch configuration(+1000)
MOUSEKEY_ENABLE = yes	# Mouse keys(+4700)
EXTRAKEY_ENABLE = yes	# Audio control and System control(+450)
CONSOLE_ENABLE = yes	# Console for debug(+400)
COMMAND_ENABLE = yes    # Commands for debug and configuration
#SLEEP_LED_ENABLE = yes  # Breathing sleep LED during USB suspend
#NKRO_ENABLE = yes	# USB Nkey Rollover


# Optimize size but this may cause error "relocation truncated to fit"
#EXTRALDFLAGS = -Wl,--relax

# Search Path
VPATH += $(TARGET_DIR)
VPATH += $(TMK_DIR)

include $(TMK_DIR)/protocol/lufa.mk
include $(TMK_DIR)/common.mk
include $(TMK_DIR)/rules.mk


config.h

Code: Select all

/*
Copyright 2012 Jun Wako <wakojun@gmail.com>

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 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 4

/* 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
matrix.c

Code: Select all

/*
Copyright 2012 Jun Wako <wakojun@gmail.com>

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/>.
*/

/*
 * 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);


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  
 * pin: e6  b4  b5  b6  
 * ARD: 7   8   9   10
 */
static void  init_cols(void)
{
    // Input with pull-up(DDR:0, PORT:1)
    DDRE  &= ~(1<<6);
    PORTE |=  (1<<6);
    DDRB  &= ~(1<<4 | 1<< 5 | 1<<6);
    PORTB |=  (1<<4 | 1<< 5 | 1<<6);}

static matrix_row_t read_cols(void)
{
    return (PINE&(1<<6) ? 0 : (1<<0)) |
           (PINB&(1<<4) ? 0 : (1<<1)) |
           (PINB&(1<<5) ? 0 : (1<<2)) |
           (PINB&(1<<6) ? 0 : (1<<3)) |;
}

/* Row pin configuration
 * row:  0   1   2   3   4
 * pin: D1  D0  C6  D4  D7
 */
static void unselect_rows(void)
{
    // Hi-Z(DDR:0, PORT:0) to unselect
    DDRD  &= ~0b10010011;
    PORTD &= ~0b10010011;
	DDRC  &= ~0b01000000;
	PORTC  &= ~0b01000000;
}

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

Code: Select all

/*
Copyright 2012,2013 Jun Wako <wakojun@gmail.com>

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 "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,\
    K10, K11, K12, K13,\
    K20, K21, K22,\
    K30, K31, K32, K33,\
    K40, K42 \
	) { \
    { KC_##K00, KC_##K01, KC_##K02, KC_##K03 }, \
    { KC_##K10, KC_##K11, KC_##K12, KC_##K13 }, \
    { KC_##K20, KC_##K21, KC_##K22, KC_NO }, \
    { KC_##K30, KC_##K31, KC_##K32, KC_##K33 }, \
    { KC_##K40, KC_NO, KC_##K42, KC_NO }  \
}

/* ANSI valiant. 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.c

Code: Select all

#include "keymap_common.h"

const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
       /* 0: qwerty */
	   KEYMAP(FN1, /, *, -,\
	   7,  8, 9, +,\
	   4, 5, 6,\
	   1, 2, 3, ENT,\
	   0, .),
	  
	   /* 0: Numlock off*/
	   KEYMAP(TRNS, TRNS, TRNS, TRNS,  \
	   HOME, UP,  PGUP, TRNS,  \
	   LEFT, TRNS, RIGHT,   \
	   END, DOWN, PGDN, ENT,         \
	   INS, DEL),
};
const uint16_t PROGMEM fn_actions[] = {
    [0] = ACTION_LAYER_MOMENTARY(1),
    [1] = ACTION_LAYER_TOGGLE(1)
};
I don't believe I've made any other changes to the GH60 files beyond commenting out the LED.c file as shown below.

Code: Select all

/*
Copyright 2012 Jun Wako <wakojun@gmail.com>

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/>.
*/

#include <avr/io.h>
#include "stdint.h"
#include "led.h"


/*void led_set(uint8_t usb_led)
*{
*   if (usb_led & (1<<USB_LED_CAPS_LOCK)) {
*      // output low
*       DDRB |= (1<<2);
*       PORTB &= ~(1<<2);
*   } else {
*       // Hi-Z
*       DDRB &= ~(1<<2);
*       PORTB &= ~(1<<2);
*   }
* }
*/
Any suggestions would be appreciated!

EDIT: Also is there a command I can use for Numlock? would prefer to just use that instead of the FN1 command in the keymap_poker.c file anyway

User avatar
Ray

02 Jul 2017, 13:56

there's no KC_/, KC_*, KC_- etc. defined, which makes total sense.
look here, the stuff you are looking for should be starting line 94

crossharu

02 Jul 2017, 21:48

Hi! I wonder if someone could help me out a bit.

After a few hiccups here and there I've managed to compile the firmware and have finally worked out how to get my mac to recognise the Teensy (through booting in Windows and burning from there). However, I'm getting the attached error message due to the firmware being built for the Teensy 2 (I have the 2++). I've edited my Makefile.pjrc below for the 2++ but something seems to be going wrong. I've also run 'make clean' to make sure that it is the 2++ version which is compiling but no joy. Any ideas?

Thanks!

Code: Select all

#----------------------------------------------------------------------------
# On command line:
#
# make all = Make software.
#
# make clean = Clean out built project files.
#
# make coff = Convert ELF to AVR COFF.
#
# make extcoff = Convert ELF to AVR Extended COFF.
#
# make program = Download the hex file to the device.
#                Please customize your programmer settings(PROGRAM_CMD)
#
# make teensy = Download the hex file to the device, using teensy_loader_cli.
#               (must have teensy_loader_cli installed).
#
# make dfu = Download the hex file to the device, using dfu-programmer (must
#            have dfu-programmer installed).
#
# make flip = Download the hex file to the device, using Atmel FLIP (must
#             have Atmel FLIP installed).
#
# make dfu-ee = Download the eeprom file to the device, using dfu-programmer
#               (must have dfu-programmer installed).
#
# make flip-ee = Download the eeprom file to the device, using Atmel FLIP
#                (must have Atmel FLIP installed).
#
# make debug = Start either simulavr or avarice as specified for debugging, 
#              with avr-gdb or avr-insight as the front end for debugging.
#
# make filename.s = Just compile filename.c into the assembler code only.
#
# make filename.i = Create a preprocessed source file for use in submitting
#                   bug reports to the GCC project.
#
# To rebuild project do "make clean" then "make all".
#----------------------------------------------------------------------------

# Target file name (without extension).
TARGET = gh60_lufa

# Directory common source filess exist
TMK_DIR = ../../tmk_core

# Directory keyboard dependent files exist
TARGET_DIR = .

# project specific files
SRC =	keymap_common.c \
	matrix.c \
	led.c

ifdef KEYMAP
    SRC := keymap_$(KEYMAP).c $(SRC)
else
    SRC := keymap_poker.c $(SRC)
endif

CONFIG_H = config.h


# MCU name, you MUST set this to match the board you are using
# type "make clean" after changing this, so all files will be rebuilt
MCU = at90usb1286


# Processor frequency.
#   Normally the first thing your program should do is set the clock prescaler,
#   so your program will run at the correct speed.  You should also set this
#   variable to same clock speed.  The _delay_ms() macro uses this, and many
#   examples use this variable to calculate timings.  Do not add a "UL" here.
F_CPU = 16000000


# Boot Section Size in *bytes*
#   Teensy halfKay   512
#   Atmel DFU loader 4096
#   LUFA bootloader  4096
OPT_DEFS += -DBOOTLOADER_SIZE=4096


# Build Options
#   comment out to disable the options.
#
BOOTMAGIC_ENABLE = yes	# Virtual DIP switch configuration(+1000)
MOUSEKEY_ENABLE = yes	# Mouse keys(+5000)
EXTRAKEY_ENABLE = yes	# Audio control and System control(+600)
CONSOLE_ENABLE = yes    # Console for debug
COMMAND_ENABLE = yes    # Commands for debug and configuration
SLEEP_LED_ENABLE = yes  # Breathing sleep LED during USB suspend
#NKRO_ENABLE = yes	# USB Nkey Rollover(+500)
#PS2_MOUSE_ENABLE = yes	# PS/2 mouse(TrackPoint) support


# Search Path
VPATH += $(TARGET_DIR)
VPATH += $(TMK_DIR)

include $(TMK_DIR)/protocol/pjrc.mk
include $(TMK_DIR)/common.mk
include $(TMK_DIR)/rules.mk

plain: OPT_DEFS += -DKEYMAP_PLAIN
plain: all

poker: OPT_DEFS += -DKEYMAP_POKER
poker: all

poker_set: OPT_DEFS += -DKEYMAP_POKER_SET
poker_set: all

poker_bit: OPT_DEFS += -DKEYMAP_POKER_BIT
poker_bit: all
Attachments
Error!
Error!
Capture.PNG (19.3 KiB) Viewed 11326 times

User avatar
Ray

02 Jul 2017, 22:08

I don't know anything about the Arduino IDE, but TMK is not an arduino sketch. I don't know if Arduino IDE can handle this makefile, linking and all...
In case you are using make and are getting that nice-looking GUI: make does get called with Makefile.pjrc, not the regular Makefile?

crossharu

02 Jul 2017, 23:09

Thanks very much for the response - prompted me to check if it should be the definition in the Makefile I should be editing rather than Makefile.pjrc and that was the answer. Thanks again!

Jdude1

03 Jul 2017, 13:49

Ray wrote: there's no KC_/, KC_*, KC_- etc. defined, which makes total sense.
look here, the stuff you are looking for should be starting line 94
Thanks Ray! That was it exactly. I've bookmarked this URL now for future reference. I also had another error that came up because I had commented out the LED.c portion so I un-commented that and set it to an output pin I'm not using and I was able to compile the hex file. A few command lines later and I've got a working Pro-Micro and numpad!

teyuze

10 Aug 2017, 12:19

Please, I need help with a laptop keyboard. I have attached my matrix, pictures of the keyboard and the code used to build the firmware. I was able to build the firmware and my laptop recognises that a keyboard is connected but when I press a key, it does not output the key I have pressed. I have checked the wiring with the teensy thoroughly. My guess is that this problem is from my keymap on keymap_poker.c file but I am unsure of how to correct this
Makefile

Code: Select all

#----------------------------------------------------------------------------
# On command line:
#
# make all = Make software.
#
# make clean = Clean out built project files.
#
# make coff = Convert ELF to AVR COFF.
#
# make extcoff = Convert ELF to AVR Extended COFF.
#
# make program = Download the hex file to the device.
#                Please customize your programmer settings(PROGRAM_CMD)
#
# make teensy = Download the hex file to the device, using teensy_loader_cli.
#               (must have teensy_loader_cli installed).
#
# make dfu = Download the hex file to the device, using dfu-programmer (must
#            have dfu-programmer installed).
#
# make flip = Download the hex file to the device, using Atmel FLIP (must
#             have Atmel FLIP installed).
#
# make dfu-ee = Download the eeprom file to the device, using dfu-programmer
#               (must have dfu-programmer installed).
#
# make flip-ee = Download the eeprom file to the device, using Atmel FLIP
#                (must have Atmel FLIP installed).
#
# make debug = Start either simulavr or avarice as specified for debugging, 
#              with avr-gdb or avr-insight as the front end for debugging.
#
# make filename.s = Just compile filename.c into the assembler code only.
#
# make filename.i = Create a preprocessed source file for use in submitting
#                   bug reports to the GCC project.
#
# To rebuild project do "make clean" then "make all".
#----------------------------------------------------------------------------

# Target file name (without extension).
TARGET = gh60_lufa

# Directory common source filess exist
TMK_DIR = ../../tmk_core

# Directory keyboard dependent files exist
TARGET_DIR = .

# project specific files
SRC =	matrix.c \
	led.c

ifdef KEYMAP
    SRC := keymap_$(KEYMAP).c $(SRC)
else
    SRC := keymap_poker.c $(SRC)
endif

CONFIG_H = config.h


# MCU name
MCU = at90usb1286
#MCU = atmega32u4

# Processor frequency.
#     This will define a symbol, F_CPU, in all source code files equal to the
#     processor frequency in Hz. You can then use this symbol in your source code to
#     calculate timings. Do NOT tack on a 'UL' at the end, this will be done
#     automatically to create a 32-bit value in your source code.
#
#     This will be an integer division of F_USB below, as it is sourced by
#     F_USB after it has run through any CPU prescalers. Note that this value
#     does not *change* the processor frequency - it should merely be updated to
#     reflect the processor speed set externally so that the code can use accurate
#     software delays.
F_CPU = 16000000


#
# LUFA specific
#
# Target architecture (see library "Board Types" documentation).
ARCH = AVR8

# Input clock frequency.
#     This will define a symbol, F_USB, in all source code files equal to the
#     input clock frequency (before any prescaling is performed) in Hz. This value may
#     differ from F_CPU if prescaling is used on the latter, and is required as the
#     raw input clock is fed directly to the PLL sections of the AVR for high speed
#     clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL'
#     at the end, this will be done automatically to create a 32-bit value in your
#     source code.
#
#     If no clock division is performed on the input clock inside the AVR (via the
#     CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU.
F_USB = $(F_CPU)

# Interrupt driven control endpoint task(+60)
OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT


# Boot Section Size in *bytes*
#   Teensy halfKay   512
#   Teensy++ halfKay 1024
#   Atmel DFU loader 4096
#   LUFA bootloader  4096
#   USBaspLoader     2048
OPT_DEFS += -DBOOTLOADER_SIZE=4096


# Build Options
#   comment out to disable the options.
#
BOOTMAGIC_ENABLE = yes	# Virtual DIP switch configuration(+1000)
MOUSEKEY_ENABLE = yes	# Mouse keys(+4700)
EXTRAKEY_ENABLE = yes	# Audio control and System control(+450)
CONSOLE_ENABLE = yes	# Console for debug(+400)
COMMAND_ENABLE = yes    # Commands for debug and configuration
#SLEEP_LED_ENABLE = yes  # Breathing sleep LED during USB suspend
#NKRO_ENABLE = yes	# USB Nkey Rollover


# Optimize size but this may cause error "relocation truncated to fit"
#EXTRALDFLAGS = -Wl,--relax

# Search Path
VPATH += $(TARGET_DIR)
VPATH += $(TMK_DIR)

include $(TMK_DIR)/protocol/lufa.mk
include $(TMK_DIR)/common.mk
include $(TMK_DIR)/rules.mk
Config.h

Code: Select all

 /*
Copyright 2012 Jun Wako <wakojun@gmail.com>

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 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  8
#define MATRIX_COLS  16

/* 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
Matrix.c

Code: Select all

  /*
Copyright 2012 Jun Wako <wakojun@gmail.com>

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/>.
*/

/*
 * 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);


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  15
 * pin: D0  D1  E6  C7  C6  B6  B1  B0  B5  B4  B3  B2  D4  D5  D7  B7     
*/                                                               
static void  init_cols(void)
{
    // Input with pull-up(DDR:0, PORT:1)
    DDRD  &= ~(1<<7 | 1<<5 | 1<<4 | 1<<1 | 1<<0);
    PORTD |=  (1<<7 | 1<<5 | 1<<4 | 1<<1 | 1<<0);
    DDRE  &= ~(1<<6);
    PORTE |=  (1<<6);
    DDRC  &= ~(1<<7 | 1<<6);
    PORTC |=  (1<<7 | 1<<6);
    DDRB  &= ~(1<<7 |1<<6 | 1<<5 | 1<<4 | 1<<3 | 1<<2 | 1<<1 | 1<<0);
    PORTB |=  (1<<7 |1<<6 | 1<<5 | 1<<4 | 1<<3 | 1<<2 | 1<<1 | 1<<0);
}

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

/* Row pin configuration
 * row: 0   1   2   3   4   5   6   7
 * pin: F0  F1  F2  F3  F4  F5  F6  F7
 */
static void unselect_rows(void)
{
    // Hi-Z(DDR:0, PORT:0) to unselect
    DDRF  &= ~0b11111111;
    PORTF &= ~0b11111111;
}

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

Code: Select all

/*
Copyright 2012,2013 Jun Wako <wakojun@gmail.com>

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 "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( \
    K6C, K7B, K1B, K0B, K6B, K1D, K0D, K6D, K7D, K12, K02, K62, K72, K60, K70, \
    K1C, K4C, K4D, K4B, K4A, K1A, K18, K48, K47, K42, K41, K11, K71, K63, \
    K0C, K5C, K5D, K5B, K5A, K0A, K08, K58, K57, K52, K51, K01, K17, \
    K7C, K3C, K3D, K3B, K3A, K6A, K68, K38, K37, K32, K31, K61, K03, K33, \
    K2F, K07, K2C, K2D, K2B, K2A, K7A, K78, K28, K27, K22, K21, K5F,\
    K0E, K19, K66, K44,      K23,      K74, K15, K3E, K50, K53, K43, K40  \
) { \
    { KC_NO,    KC_##K01, KC_##K02, KC_##K03, KC_NO,    KC_NO,    KC_NO,    KC_##K07, KC_##K08, KC_NO,    KC_##K0A, KC_##K0B, KC_##K0C, KC_##K0D, KC_##K0E, KC_NO }, \
    { KC_NO,    KC_##K11, KC_##K12, KC_NO,    KC_NO,    KC_##K15, KC_NO,    KC_##K17, KC_##K18, KC_##K19, KC_##K1A, KC_##K1B, KC_##K1C, KC_##K1D, KC_NO,    KC_NO }, \
    { KC_NO,    KC_##K21, KC_##K22, KC_##K23, KC_NO,    KC_NO,    KC_NO,    KC_##K27, KC_##K28, KC_NO,    KC_##K2A, KC_##K2B, KC_##K2C, KC_##K2D, KC_NO,    KC_##K2F }, \
    { KC_NO,    KC_##K31, KC_##K32, KC_##K33, KC_NO,    KC_NO,    KC_NO,    KC_##K37, KC_##K38, KC_NO,    KC_##K3A, KC_##K3B, KC_##K3C, KC_##K3D, KC_##K3E, KC_NO }, \
    { KC_##K40, KC_##K41, KC_##K42, KC_##K43, KC_##K44, KC_NO,    KC_NO,    KC_##K47, KC_##K48, KC_NO,    KC_##K4A, KC_##K4B, KC_##K4C, KC_##K4D, KC_NO,    KC_NO }, \
    { KC_##K50, KC_##K51, KC_##K52, KC_##K53, KC_NO,    KC_NO,    KC_NO,    KC_##K57, KC_##K58, KC_NO,    KC_##K5A, KC_##K5B, KC_##K5C, KC_##K5D, KC_NO,    KC_##K5F }, \
    { KC_##K60, KC_##K61, KC_##K62, KC_##K63, KC_NO,    KC_NO,    KC_##K66, KC_NO,    KC_##K68, KC_NO,    KC_##K6A, KC_##K6B, KC_##K6C, KC_##K6D, KC_NO,    KC_NO }, \
    { KC_##K70, KC_##K71, KC_##K72, KC_NO,    KC_##K74, KC_NO,    KC_NO,    KC_NO,    KC_##K78, KC_NO,    KC_##K7A, KC_##K7B, KC_##K7C, KC_##K7D, KC_NO,    KC_NO } \
}
/* ANSI valiant. 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.c

Code: Select all

#include "keymap_common.h"

const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
    /* 0: qwerty */
 KEYMAP(ESC,  F1,  F2,  F3,  F4,  F5,  F6,  F7,  F8,  F9,  F10,    F11, F12, PSCR,DEL, \
             GRV,   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, \
            CAPS,   A,   S,   D,   F,   G,   H,   J,   K,   L,   SCLN, QUOT,SLSH,  ENT, \
            LSFT, SLSH,  Z,   X,   C,   V,   B,   N,   M, COMM,   DOT, SLSH,RSFT, \
            LCTL,   FN0,LGUI, LALT,    SPC,    RALT, MENU, RCTL, LEFT, UP, DOWN, RIGHT),
    /* 1: FN 1 */
 KEYMAP(TRNS,TRNS, TRNS,TRNS,CALC,MPRV,MPLY,MSTP,MNXT,VOLU,VOLD,MUTE,TRNS,TRNS,TRNS, \
        TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, \
        TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, \
        TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, \
        TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, \
        TRNS,TRNS,TRNS,TRNS,     TRNS,     TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS),
};
const action_t PROGMEM fn_actions[] = {
    /* Poker Layout */
    [0] = ACTION_LAYER_MOMENTARY(1),  
};
Attachments
20170810_104642.jpg
20170810_104642.jpg (1.65 MiB) Viewed 11204 times
20170810_104744.jpg
20170810_104744.jpg (1.76 MiB) Viewed 11204 times
Matrix.pdf
(23.4 KiB) Downloaded 193 times

User avatar
Mieber

10 Aug 2017, 13:00

Ok, so today I learned how you can map a specific matrix to a keymap in a way that the layout still is normal. Sorry, I can't help you directly, but maybe you could try what I did when my setup didn't work:
  • I stripped the files of all unnecessary definitions
  • I mapped a single key and got that working
  • I mapped a 2x2 matrix and got that working
You can see my efforts two pages behind in this thread. e.g. my keymap was just this:

Code: Select all

#define KEYMAP( \
    K00, K01, \
    K10, K11 \
) { \
    { KC_##K00, KC_##K01 }, \
    { KC_##K10, KC_##K01 } \
}
That way I found that my row definition was upside down (not possible in your case, you are using all 8 pins).

My experience: if your matrix is wrong it usually starts printing chars immediately when connected. If your keymap is wrong it usually prints wrong chars. If its doing nothing its sth else.

crossharu

13 Aug 2017, 13:11

[Deleted duplicate post]
Last edited by crossharu on 13 Aug 2017, 13:11, edited 1 time in total.

crossharu

13 Aug 2017, 13:11

teyuze wrote: Please, I need help with a laptop keyboard. I have attached my matrix, pictures of the keyboard and the code used to build the firmware. I was able to build the firmware and my laptop recognises that a keyboard is connected but when I press a key, it does not output the key I have pressed. I have checked the wiring with the teensy thoroughly. My guess is that this problem is from my keymap on keymap_poker.c file but I am unsure of how to correct this
[/code]
Teyuze - could you give some more information on what keys are outputted when when you press a key? Is there a pattern to it? I completed my first completely custom keyboard yesterday after a couple of months of planning it and with a few hours of troubleshooting annoying issues it eventually worked perfectly (typing on it now) - so stick with it and you'll get there!


All - one issue I have with my keyboard on OSX is that when trying to switch between windows of the same application using cmd+\ (UK keyboard layout) an error sound is generated and it does not switch. The key works fine for typing normally (\| as expected) and cmd works with other combinations fine. Any ideas?

User avatar
hbar

15 Aug 2017, 16:05

After doing an extensive search of this and other websites, I can't find any pointers to instructions on how to debug tmk_keyboard-based firmware.

Background: On my hbar alpha, I run tmk_keyboard with suka's modifications (in particular, automatic mouse layer when the trackpoint is moved), and the keyboard disconnects from USB every now and then (which I guess is a reboot of the microcontroller). I stared at all the modifications I made to tmk_keyboard, but can't find anything wrong with the code (not that C is very easily inspected, but I tried at least). The controller board is a Pro Micro (32u4). I haven't used JTAG on it yet and I'm not sure the controller allows me to anyway (with the pinout I use).

So, in practice, how do I debug this thing? Is there any useful alternative to JTAG? Any help would be appreciated.

pomk

16 Aug 2017, 15:51

TMK has built in debug printing support. You can print out stuff with xprintf and see the output using PJRC's HID listen tool.

User avatar
hbar

17 Aug 2017, 09:29

Thanks pomk, I'll try to figure out how to use it. Is there documentation somewhere?

pomk

17 Aug 2017, 10:54

The tmk github has very basic info, but it all should be very straight forward. Just make sure that your build has debug features enabled and press magic+d and you should see something in the hid listen window. I can try to help more next week if you are still struggling.

User avatar
Halvar

17 Aug 2017, 19:16

If you have questions, you can also ask here or in the author's own thread.

User avatar
mecano

18 Aug 2017, 00:05

hbar, I'd first check the hardware rather than software with such behaviour, for debugging I use dprintf.
Basically : launch hid-listen, hit magic-D (magic is both shift depressed by default), for help hit magic-H. I usually deactivate matrix, keyboard and mouse messages (magic-K, magic-X, magic-M) so the output is less verbose.

User avatar
mecano

18 Aug 2017, 00:12

crossharu wrote: All - one issue I have with my keyboard on OSX is that when trying to switch between windows of the same application using cmd+\ (UK keyboard layout) an error sound is generated and it does not switch. The key works fine for typing normally (\| as expected) and cmd works with other combinations fine. Any ideas?
Check if the shortcut is right in System Prefs, Keyboard, Shortcuts, Keyboard. And just to be sure reset it with the key sequence you are trying. If it still fails get Karabiner, show package contents, copy contents/applications/eventviewer.app to your applications folder, trash Karabiner, launch EventViewer, test your keys.

User avatar
hbar

18 Aug 2017, 10:06

Thanks mecano. The hardware should be OK because it used to be OK, but, unfortunately, I can't find the source code I used to build the firmware back then, and I wanted to change the layout. Therefore I did it all over again, and now it's misbehaving, I just don't know why.

Zarugal

20 Aug 2017, 01:10

Could one of you knowledgeable people please help me out with some code for a custom TKL build using a Teensy LC? I'm able to code, but I'm totally lost with this one - if someone could just point me in the direction of a good foundation firmware that's compatible with the LC so I know where to start I'd be most thankful!

I've followed Matt3o's fantastic build guide thus far and I'm close to the end, just need a little help to get over the line!

User avatar
mecano

20 Aug 2017, 17:09

ARM Cortex (Teensy LC chip) is supported through ChibiOS afaik check this post workshop-f7/tmk-support-for-arm-teensies-t11799.html

The_SkatingLemon

23 Aug 2017, 14:06

Having trouble with my keymap_poker.c file
Can anyone tell me where I'm going wrong?

Code: Select all

#include "keymap_common.h"

const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
    /* 0: qwerty */
    KEYMAP_ANSI
	(TAB,    Q,   W,   E,   R,   T,   Y,   U,   I,   O,   P, \
           CAPS,   A,   S,   D,   F,   G,   H,   J,   K,   L,QUOT, \
           LSFT,   Z,   X,   C,   V,   B,   N,   M,COMM, DOT,SLSH, \
           LCTL, FN1,LALT,      ENT, SPC,BSPC,     RGUI,PAUS, ESC),
	/* 1: FN 1 */
	KEYMAP_ANSI
	(F1,  F2,  F3,  F4,  TRNS,TRNS,TRNS,  P7,  P8,  P9,PMNS, \
		   F5,  F6,  F7,  F8,  TRNS,TRNS,TRNS,  P4,  P5,  P6,PPLS, \
		   F9,  F10, F11, F12, TRNS,TRNS,TRNS,  P1,  P2,  P3,PAST, \
		   TRNS,TRNS,TRNS,     TRNS,TRNS,TRNS,       P0,PDOT,PSLS), 
};

const action_t PROGMEM fn_actions[] = {
	[0] = ACTION_LAYER_TOGGLE(1),
};
This is the error I get when using the "make -f Makefile" command in cmd

Code: Select all

D:\Documents\Keyboards\tmk_keyboard-master\keyboard\gh60>make -f Makefile
/usr/bin/sh: dfu-programmer: command not found
/usr/bin/sh: dfu-programmer: command not found

-------- begin --------
avr-gcc (WinAVR 20100110) 4.3.3
Copyright (C) 2008 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=atmega32u4 -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 -DNKRO_ENABLE -DVERSION=unknown -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:                                                                                 keymap_common.h:38:1: error: parameter name missing                                                                     keymap_poker.c:6: warning: implicit declaration of function 'KEYMAP_ANSI'                                               keymap_poker.c:6: error: 'TAB' undeclared here (not in a function)
keymap_poker.c:6: error: 'Q' undeclared here (not in a function)
keymap_poker.c:6: error: 'W' undeclared here (not in a function)
keymap_poker.c:6: error: 'E' undeclared here (not in a function)
keymap_poker.c:6: error: 'R' undeclared here (not in a function)
keymap_poker.c:6: error: 'T' undeclared here (not in a function)
keymap_poker.c:6: error: 'Y' undeclared here (not in a function)
keymap_poker.c:6: error: 'U' undeclared here (not in a function)
keymap_poker.c:6: error: 'I' undeclared here (not in a function)
keymap_poker.c:6: error: 'O' undeclared here (not in a function)
keymap_poker.c:6: error: 'P' undeclared here (not in a function)
keymap_poker.c:7: error: 'CAPS' undeclared here (not in a function)
keymap_poker.c:7: error: 'A' undeclared here (not in a function)
keymap_poker.c:7: error: 'S' undeclared here (not in a function)
keymap_poker.c:7: error: 'D' undeclared here (not in a function)
keymap_poker.c:7: error: 'F' undeclared here (not in a function)
keymap_poker.c:7: error: 'G' undeclared here (not in a function)
keymap_poker.c:7: error: 'H' undeclared here (not in a function)
keymap_poker.c:7: error: 'J' undeclared here (not in a function)
keymap_poker.c:7: error: 'K' undeclared here (not in a function)
keymap_poker.c:7: error: 'L' undeclared here (not in a function)
keymap_poker.c:7: error: 'QUOT' undeclared here (not in a function)
keymap_poker.c:8: error: 'LSFT' undeclared here (not in a function)
keymap_poker.c:8: error: 'Z' undeclared here (not in a function)
keymap_poker.c:8: error: 'X' undeclared here (not in a function)
keymap_poker.c:8: error: 'C' undeclared here (not in a function)
keymap_poker.c:8: error: 'V' undeclared here (not in a function)
keymap_poker.c:8: error: 'B' undeclared here (not in a function)
keymap_poker.c:8: error: 'N' undeclared here (not in a function)
keymap_poker.c:8: error: 'M' undeclared here (not in a function)
keymap_poker.c:8: error: 'COMM' undeclared here (not in a function)
keymap_poker.c:8: error: 'DOT' undeclared here (not in a function)
keymap_poker.c:8: error: 'SLSH' undeclared here (not in a function)
keymap_poker.c:9: error: 'LCTL' undeclared here (not in a function)
keymap_poker.c:9: error: 'FN1' undeclared here (not in a function)
keymap_poker.c:9: error: 'LALT' undeclared here (not in a function)
keymap_poker.c:9: error: 'ENT' undeclared here (not in a function)
keymap_poker.c:9: error: 'SPC' undeclared here (not in a function)
keymap_poker.c:9: error: 'BSPC' undeclared here (not in a function)
keymap_poker.c:9: error: 'RGUI' undeclared here (not in a function)
keymap_poker.c:9: error: 'PAUS' undeclared here (not in a function)
keymap_poker.c:9: error: 'ESC' undeclared here (not in a function)
keymap_poker.c:6: warning: missing braces around initializer
keymap_poker.c:6: warning: (near initialization for 'keymaps[0]')
keymap_poker.c:6: error: initializer element is not constant
keymap_poker.c:6: error: (near initialization for 'keymaps[0][0][0]')
keymap_poker.c:12: error: 'F1' undeclared here (not in a function)
keymap_poker.c:12: error: 'F2' undeclared here (not in a function)
keymap_poker.c:12: error: 'F3' undeclared here (not in a function)
keymap_poker.c:12: error: 'F4' undeclared here (not in a function)
keymap_poker.c:12: error: 'TRNS' undeclared here (not in a function)
keymap_poker.c:12: error: 'P7' undeclared here (not in a function)
keymap_poker.c:12: error: 'P8' undeclared here (not in a function)
keymap_poker.c:12: error: 'P9' undeclared here (not in a function)
keymap_poker.c:12: error: 'PMNS' undeclared here (not in a function)
keymap_poker.c:13: error: 'F5' undeclared here (not in a function)
keymap_poker.c:13: error: 'F6' undeclared here (not in a function)
keymap_poker.c:13: error: 'F7' undeclared here (not in a function)
keymap_poker.c:13: error: 'F8' undeclared here (not in a function)
keymap_poker.c:13: error: 'P4' undeclared here (not in a function)
keymap_poker.c:13: error: 'P5' undeclared here (not in a function)
keymap_poker.c:13: error: 'P6' undeclared here (not in a function)
keymap_poker.c:13: error: 'PPLS' undeclared here (not in a function)
keymap_poker.c:14: error: 'F9' undeclared here (not in a function)
keymap_poker.c:14: error: 'F10' undeclared here (not in a function)
keymap_poker.c:14: error: 'F11' undeclared here (not in a function)
keymap_poker.c:14: error: 'F12' undeclared here (not in a function)
keymap_poker.c:14: error: 'P1' undeclared here (not in a function)
keymap_poker.c:14: error: 'P2' undeclared here (not in a function)
keymap_poker.c:14: error: 'P3' undeclared here (not in a function)
keymap_poker.c:14: error: 'PAST' undeclared here (not in a function)
keymap_poker.c:15: error: 'P0' undeclared here (not in a function)
keymap_poker.c:15: error: 'PDOT' undeclared here (not in a function)
keymap_poker.c:15: error: 'PSLS' undeclared here (not in a function)
keymap_poker.c:12: error: initializer element is not constant
keymap_poker.c:12: error: (near initialization for 'keymaps[0][0][1]')
make: *** [obj_gh60_lufa/keymap_poker.o] Error 1

D:\Documents\Keyboards\tmk_keyboard-master\keyboard\gh60>

User avatar
Halvar

23 Aug 2017, 17:08

Could you show the file keymap_common.h ?

It looks like something is wrong there, the definition of the macro KEYMAP_ANSI throws an error.

That's the part starting with

Code: Select all

#define KEYMAP_ANSI (
Also, on line 15 of keymap_poker.c, the comma at the end should be deleted.

The_SkatingLemon

27 Aug 2017, 06:02

Here it is
Thanks for the help

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 */
#define KEYMAP_ANSI ( \
    K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, \
    K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, \
    K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, \
    K30, K31, K32,      K34, K35, K36,      K38, K39, K3A  \
) { \
    { KC_##K00, KC_##K01, KC_##K02, KC_##K03, KC_##K04, KC_##K05, KC_##K06, KC_##K07, KC_##K08, KC_##K09, KC_##K0A }, \
    { KC_##K10, KC_##K11, KC_##K12, KC_##K13, KC_##K14, KC_##K15, KC_##K16, KC_##K17, KC_##K18, KC_##K19, KC_##K1A }, \
    { KC_##K20, KC_##K21, KC_##K22, KC_##K23, KC_##K24, KC_##K25, KC_##K26, KC_##K27, KC_##K28, KC_##K29, KC_##K2A }, \
    { KC_##K30, KC_##K31, KC_##K32, KC_NO,    KC_##K34, KC_##K35, KC_##K36, KC_NO,    KC_##K38, KC_##K39, KC_##K3A }  \
}
#endif
And this is the error I'm currently getting

Code: Select all

D:\Documents\Keyboards\tmk_keyboard-master\keyboard\gh60>make -f Makefile
/usr/bin/sh: dfu-programmer: command not found
/usr/bin/sh: dfu-programmer: command not found

-------- begin --------
avr-gcc (WinAVR 20100110) 4.3.3
Copyright (C) 2008 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=atmega32u4 -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 -DNKRO_ENABLE -DVERSION=unknown -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
keymap_poker.c:5: error: 'K00' undeclared here (not in a function)
keymap_poker.c:5: error: 'K01' undeclared here (not in a function)
keymap_poker.c:5: warning: left-hand operand of comma expression has no effect
keymap_poker.c:5: error: 'K02' undeclared here (not in a function)
keymap_poker.c:5: warning: left-hand operand of comma expression has no effect
keymap_poker.c:5: error: 'K03' undeclared here (not in a function)
keymap_poker.c:5: warning: left-hand operand of comma expression has no effect
keymap_poker.c:5: error: 'K04' undeclared here (not in a function)
keymap_poker.c:5: warning: left-hand operand of comma expression has no effect
keymap_poker.c:5: error: 'K05' undeclared here (not in a function)
keymap_poker.c:5: warning: left-hand operand of comma expression has no effect
keymap_poker.c:5: error: 'K06' undeclared here (not in a function)
keymap_poker.c:5: warning: left-hand operand of comma expression has no effect
keymap_poker.c:5: error: 'K07' undeclared here (not in a function)
keymap_poker.c:5: warning: left-hand operand of comma expression has no effect
keymap_poker.c:5: error: 'K08' undeclared here (not in a function)
keymap_poker.c:5: warning: left-hand operand of comma expression has no effect
keymap_poker.c:5: error: 'K09' undeclared here (not in a function)
keymap_poker.c:5: warning: left-hand operand of comma expression has no effect
keymap_poker.c:5: error: 'K0A' undeclared here (not in a function)
keymap_poker.c:5: warning: left-hand operand of comma expression has no effect
keymap_poker.c:5: error: 'K10' undeclared here (not in a function)
keymap_poker.c:5: warning: left-hand operand of comma expression has no effect
keymap_poker.c:5: error: 'K11' undeclared here (not in a function)
keymap_poker.c:5: warning: left-hand operand of comma expression has no effect
keymap_poker.c:5: error: 'K12' undeclared here (not in a function)
keymap_poker.c:5: warning: left-hand operand of comma expression has no effect
keymap_poker.c:5: error: 'K13' undeclared here (not in a function)
keymap_poker.c:5: warning: left-hand operand of comma expression has no effect
keymap_poker.c:5: error: 'K14' undeclared here (not in a function)
keymap_poker.c:5: warning: left-hand operand of comma expression has no effect
keymap_poker.c:5: error: 'K15' undeclared here (not in a function)
keymap_poker.c:5: warning: left-hand operand of comma expression has no effect
keymap_poker.c:5: error: 'K16' undeclared here (not in a function)
keymap_poker.c:5: warning: left-hand operand of comma expression has no effect
keymap_poker.c:5: error: 'K17' undeclared here (not in a function)
keymap_poker.c:5: warning: left-hand operand of comma expression has no effect
keymap_poker.c:5: error: 'K18' undeclared here (not in a function)
keymap_poker.c:5: warning: left-hand operand of comma expression has no effect
keymap_poker.c:5: error: 'K19' undeclared here (not in a function)
keymap_poker.c:5: warning: left-hand operand of comma expression has no effect
keymap_poker.c:5: error: 'K1A' undeclared here (not in a function)
keymap_poker.c:5: warning: left-hand operand of comma expression has no effect
keymap_poker.c:5: error: 'K20' undeclared here (not in a function)
keymap_poker.c:5: warning: left-hand operand of comma expression has no effect
keymap_poker.c:5: error: 'K21' undeclared here (not in a function)
keymap_poker.c:5: warning: left-hand operand of comma expression has no effect
keymap_poker.c:5: error: 'K22' undeclared here (not in a function)
keymap_poker.c:5: warning: left-hand operand of comma expression has no effect
keymap_poker.c:5: error: 'K23' undeclared here (not in a function)
keymap_poker.c:5: warning: left-hand operand of comma expression has no effect
keymap_poker.c:5: error: 'K24' undeclared here (not in a function)
keymap_poker.c:5: warning: left-hand operand of comma expression has no effect
keymap_poker.c:5: error: 'K25' undeclared here (not in a function)
keymap_poker.c:5: warning: left-hand operand of comma expression has no effect
keymap_poker.c:5: error: 'K26' undeclared here (not in a function)
keymap_poker.c:5: warning: left-hand operand of comma expression has no effect
keymap_poker.c:5: error: 'K27' undeclared here (not in a function)
keymap_poker.c:5: warning: left-hand operand of comma expression has no effect
keymap_poker.c:5: error: 'K28' undeclared here (not in a function)
keymap_poker.c:5: warning: left-hand operand of comma expression has no effect
keymap_poker.c:5: error: 'K29' undeclared here (not in a function)
keymap_poker.c:5: warning: left-hand operand of comma expression has no effect
keymap_poker.c:5: error: 'K2A' undeclared here (not in a function)
keymap_poker.c:5: warning: left-hand operand of comma expression has no effect
keymap_poker.c:5: error: 'K30' undeclared here (not in a function)
keymap_poker.c:5: warning: left-hand operand of comma expression has no effect
keymap_poker.c:5: error: 'K31' undeclared here (not in a function)
keymap_poker.c:5: warning: left-hand operand of comma expression has no effect
keymap_poker.c:5: error: 'K32' undeclared here (not in a function)
keymap_poker.c:5: warning: left-hand operand of comma expression has no effect
keymap_poker.c:5: error: 'K34' undeclared here (not in a function)
keymap_poker.c:5: warning: left-hand operand of comma expression has no effect
keymap_poker.c:5: error: 'K35' undeclared here (not in a function)
keymap_poker.c:5: warning: left-hand operand of comma expression has no effect
keymap_poker.c:5: error: 'K36' undeclared here (not in a function)
keymap_poker.c:5: warning: left-hand operand of comma expression has no effect
keymap_poker.c:5: error: 'K38' undeclared here (not in a function)
keymap_poker.c:5: warning: left-hand operand of comma expression has no effect
keymap_poker.c:5: error: 'K39' undeclared here (not in a function)
keymap_poker.c:5: warning: left-hand operand of comma expression has no effect
keymap_poker.c:5: error: 'K3A' undeclared here (not in a function)
keymap_poker.c:5: warning: left-hand operand of comma expression has no effect
keymap_poker.c:5: error: expected '}' before '{' token
make: *** [obj_gh60_lufa/keymap_poker.o] Error 1

SpacemanToby

28 Sep 2017, 03:16

I'm having a weird issue. I followed the guide and got my keyboard working perfectly on my macbook pro, in both mac os environment and my windows 10 partition. But when I try to use it on my work laptop (Dell running windows 7) one of my columns just triggers over and over again even if i'm not pressing anything. Anyone have any ideas?

bandreadygoband

23 Oct 2017, 19:32

I have had a hell of a time with between Windows 10 and trying to run Ubuntu on OracleVM. I'm hitting a dead end where ever I go. If anyone is still around could they get this compiled? Windows gives me this error, which seemed to be unresolved on other posts:

Code: Select all

      0 [main] sh 2324 sync_with_child: child 8972(0x1C0) died before initialization with status code 0xC0000142
    161 [main] sh 2324 sync_with_child: *** child state waiting for longjmp
/usr/bin/sh: fork: Resource temporarily unavailable
      0 [main] sh 3624 sync_with_child: child 10272(0x1C0) died before initialization with status code 0xC0000142
    229 [main] sh 3624 sync_with_child: *** child state waiting for longjmp
/usr/bin/sh: fork: Resource temporarily unavailable
      0 [main] sh 11620 sync_with_child: child 11600(0x1C0) died before initialization with status code 0xC0000142
    196 [main] sh 11620 sync_with_child: *** child state waiting for longjmp
/usr/bin/sh: fork: Resource temporarily unavailable
      0 [main] sh 7396 sync_with_child: child 10084(0x1C4) died before initialization with status code 0xC0000142
    154 [main] sh 7396 sync_with_child: *** child state waiting for longjmp
/usr/bin/sh: fork: Resource temporarily unavailable
      0 [main] sh 7860 sync_with_child: child 2848(0x1C0) died before initialization with status code 0xC0000142
    206 [main] sh 7860 sync_with_child: *** child state waiting for longjmp
/usr/bin/sh: fork: Resource temporarily unavailable

-------- begin --------
avr-gcc (WinAVR 20100110) 4.3.3
Copyright (C) 2008 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=atmega32u4 -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= -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
make: *** [obj_gh60_lufa/keymap_poker.o] Error -1073741502
... and Ubuntu gives error code 127 when I run it on the terminal. Not sure what else I can do as an extreme amateur.
To add to hitting dead ends, I seem to only be able to quick reply and can't add my file. Any help with that as well?

Edit: I've been using OracleVM and properly got Ubuntu 12.04 installed with all the correct packages, but now I get a different error:

Code: Select all

...
from ../../tmk_core/common/keymap.c:17:
/usr/lib/gcc/avr/4.5.3/include/stdint.h:3:26: fatal error: stdint.h: No such file or directory
complication terminated
make: ** [obj_gh60_lufa/common/keymap.o] Error 1
I followed the path and found the file, so it's there in the VM I just don't know what to do with that information...

fntanyl

24 Mar 2018, 21:34

Hi, I know its been a while since there has been replied here but im having some issues with the custom build keyboard i made.

I tried to follow matt3o his tutorial to build my own custom keyboard.
Now that i am testing out the keyboard row 1/2/3 work perfectly fine but something weird is happening with my 4th and 5th row.

When i press the first key on the 4th row im getting not only the key i pressed but also the first key out of the 3rd row, this is the same for every button in the 4th row. In the 5th row its basically the same but it outputs the 3rd,4th and 5th row key.

I checked my wiring over and over again, and i cant find anything wrong with it. I even disconnected every single key but the last key on the 4th row [7] and it still outputs a 67 (6 = last key in 3rd row) which leads me to belief its something in the code?

However the code compiled without any issues? And since im just a newb with this stuff i have no idea where to begin to fix this.

These are the files i edited:

keymap_common.h

Code: Select all

/*
Copyright 2012,2013 Jun Wako <wakojun@gmail.com>

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[];


/* 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, K10, K11, K12, \
    K13, K14, K15, K16, K17, K18, K19, \
    K20, K21, K22, K23, K24, K25, K26, \
    K27, K28, K29,      K30 \
) { \
    { KC_##K00, KC_##K01, KC_##K02, KC_##K03, KC_##K04, KC_##K05, }, \
    { KC_##K06, KC_##K07, KC_##K08, KC_##K09, KC_##K10, KC_##K11, KC_##K12, }, \
    { KC_##K13, KC_##K14, KC_##K15, KC_##K16, KC_##K17, KC_##K18, KC_##K19, }, \
    { KC_##K20, KC_##K21, KC_##K22, KC_##K23, KC_##K24, KC_##K25, KC_##K26, }, \
    { KC_##K27, KC_##K28, KC_##K29, KC_NO, KC_##K30, } \
}
/* ANSI valiant. 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.c

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, \
           TAB,  Q,     W,     E,   R,   T,   PAUS, \
           BSLS, A,     S,     D,   F,   G,   6, \
           LSFT, Z,     X,     C,   V,   B,   7, \
           LCTL, MINS,  LALT,       SPC ),  
};

const uint16_t PROGMEM fn_actions[] = {
	
};


matrix.c

Code: Select all

/*
/*
Copyright 2012 Jun Wako <wakojun@gmail.com>

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/>.
*/

/*
 * 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  
 * pin: F0  F1  F4  F5 F6  F7 B6
 */
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);
    DDRB  &= ~(1<<6);
    PORTB |=  (1<<6);
}

static matrix_row_t read_cols(void)
{
    return (PINF&(1<<0) ? 0 : (1<<0)) |
		   (PINF&(1<<1) ? 0 : (1<<1)) |
		   (PINF&(1<<4) ? 0 : (1<<2)) |
		   (PINF&(1<<5) ? 0 : (1<<3)) |
           (PINF&(1<<6) ? 0 : (1<<4)) |
           (PINF&(1<<7) ? 0 : (1<<5)) |
           (PINB&(1<<6) ? 0 : (1<<6));
}

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

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

led.c

Code: Select all

/*
Copyright 2012 Jun Wako <wakojun@gmail.com>

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/>.
*/

#include <avr/io.h>
#include "stdint.h"
#include "led.h"


void led_set(uint8_t usb_led)
{
    if (usb_led & (1<<USB_LED_CAPS_LOCK)) {
        // output low
        DDRD |= (1<<2);
        PORTD &= ~(1<<2);
    } else {
        // Hi-Z
        DDRD &= ~(1<<2);
        PORTD &= ~(1<<2);
    }
}
config.c

Code: Select all

/*
Copyright 2012 Jun Wako <wakojun@gmail.com>

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 CONFIG_H
#define CONFIG_H


/* USB Device descriptor parameter */
#define VENDOR_ID       0xFEED
#define PRODUCT_ID      0x6060
#define DEVICE_VER      0x0001
#define MANUFACTURER    fnta
#define PRODUCT         fnta_board
#define DESCRIPTION     keyboard firmware for fnta_board

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

/* 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
Picture of the bottom and solder connections
Image

I really hope someone can help me out here or atleast point me in the right direction i want this thing to work so bad :)

SpacemanToby

27 Mar 2018, 13:57

I've only wired up a couple boards with pretty standard layouts, so I'm not a great source of knowledge, but is there a reason you have your keymap laid out the way it is? For example, in mine, everything on the top row is K00, K01, K02, etc.. and everything on the second row is K10, K11, K12, etc..., 3rd row is K20, K21, K22, etc... and so on, with the second digit representing the row number and the 3rd digit representing the column number and always starting at 0.

Also, while I leave out keys in the top portion of the keymap, every column position is represented in the bottom portion, and KC_NO is used where the gaps are.

Again though, you might be attempting to do something different and that was on purpose, and you can just ignore what I'm saying. I don't pretend to have a deep understanding of the code.

ineph

11 Jun 2018, 20:48

it can be done using the Frosty Flake??

Ty34er

18 Aug 2018, 23:53

Alright, I'll be honest, I have checked my code 5 times, I have downloaded 5 different ways to run the Makefile to make the hex file and none of them have worked for me. If I provided the link to my folders (uploaded to Google Drive), would someone be able to make the hex file for me? Or could someone recommend a fool proof version to create it?

Yes, I'm using Windows and don't have a Linux or Mac OS based device.

Post Reply

Return to “Workshop”