Posted: 07 Feb 2013, 12:38
Thank you a lot hasu, it was exactly a solution like that I had in mind! Works perfectly for me!
mechanical keyboard authority
http://www.deskthority.net/
Code: Select all
#if defined(KEYMAP_CUSTOM)
#include "keymap_custom.h"
Code: Select all
make -f Makefile.[lufa|pjrc] custom
I was wondering if there are any plans on your part to implement locking functions or macro functionality?hasu wrote:ADB converter has similar lock switch support already. It looks like this feature can be applied to all keyboard and converter projects as build option or keymap option. I added this as issue on github, I'll work on this later when I have time. https://github.com/tmk/tmk_keyboard/issues/19damorgue wrote: I know there are some interesting ideas out there where the mx lock forces its state to the OS. If the OS has caps lock on, and the mx lock isn't depressed, then it sends caps lock to change it. This prevents desyncs where the OS has caps lock turned off and the caps lock of the keyboard is depressed. I find the mx lock to be unreliable in this regards, as it can activate without physically locking for instance.
Thanks for the suggestion.
bees wrote:Hi Hasu. I wanted to thank you for making this collection, I've used it in a couple of projects and it's great!
I've been working on a new project, a tenkeyless AEKII mod, and was wondering if you could give me some insight. I've been unable to fix a error, I'm pretty sure my keymap is set up wrong but I'm unsure how to fix it. If you could point me in the right direction I'd really appreciate it. As you can see the firmware is pretty much directly adapted from your Phantom Firmware, just with the pin assignments changed.
damorgue wrote:I was wondering if there are any plans on your part to implement locking functions or macro functionality?hasu wrote:ADB converter has similar lock switch support already. It looks like this feature can be applied to all keyboard and converter projects as build option or keymap option. I added this as issue on github, I'll work on this later when I have time. https://github.com/tmk/tmk_keyboard/issues/19damorgue wrote: I know there are some interesting ideas out there where the mx lock forces its state to the OS. If the OS has caps lock on, and the mx lock isn't depressed, then it sends caps lock to change it. This prevents desyncs where the OS has caps lock turned off and the caps lock of the keyboard is depressed. I find the mx lock to be unreliable in this regards, as it can activate without physically locking for instance.
Thanks for the suggestion.
sweethasu wrote:awesomeness
Code: Select all
keymap.c:79:89: error: macro "KEYMAP_ANSI" requires 66 arguments, but only 62 given
keymap.c:74: error: 'KEYMAP_ANSI' undeclared here (not in a function)
Code: Select all
[size=85]/* Layer 0: Default Layer
* ,------------------------------------------------------------------------------------------------------------------.
* |SCKLOCK| F1| F2| F3| F4| F5| F6| F7| F8| F9| F10| F11| INSERT| DELETE| INSERT| DELETE| CLEAR| CLEAR_AGAIN| EXECUTE|
* |------------------------------------------------------------------------------------------------------------------|
* |ESC| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| MINUS| EQUAL| GRAVE| BSLASH| BSPACE| KP_7| KP_8| KP_9| |
* |------------------------------------------------------------------------------------------------------------------|
* |Tab | Q| W| E| R| T| Y| U| I| O| P| LBRACKET| SEPARATOR| CLEAR| KP_4| KP_5| KP_6| |
* |------------------------------------------------------------------------------------------------------------------|
* |CAPSLOCK| A| S| D| F| G| H| J| K| L| RCTRL| SCOLON| QUOTE| RETURN| RETURN| STOP| KP_1| KP_2| KP_3| |
* |------------------------------------------------------------------------------------------------------------------|
* |LSHIFT | Z| X| C| V| B| N| M| COMMA| PRIOR| DOT| SLASH| RSHIFT | RBRACKET| DELETE| KP_DOT| KP_0| KP_COMMA|
* |------------------------------------------------------------------------------------------------------------------|
* |PSCREEN | LALT| SPACE| HOME| DOWN| UP| LEFT| RIGHT| |
* `------------------------------------------------------------------------------------------------------------------'
*/
KEYMAP(SCKLOCK, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, INSERT, DELETE, INSERT, DELETE, CLEAR, CLEAR_AGAIN, EXECUTE, \
ESC, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINUS, EQUAL, GRAVE, BSLASH, BSPACE, KP_7, KP_8, KP_9, \
Tab, Q, W, E, R, T, Y, U, I, O, P, LBRACKET, SEPARATOR, CLEAR, KP_4, KP_5, KP_6, \
CAPSLOCK, A, S, D, F, G, H, J, K, L, RCTRL, SCOLON, QUOTE, RETURN, RETURN, STOP, KP_1, KP_2, KP_3, \
LSHIFT, Z, X, C, V, B, N, M, COMMA, PRIOR, DOT, SLASH, RSHIFT , RBRACKET, DELETE, KP_DOT, KP_0, KP_COMMA, \
PSCREEN, LALT, SPACE, HOME, DOWN, UP, LEFT, RIGHT),[/size]
Is that the section noted below?hasu wrote:First, you must modify KEYMAP macro depending on your matrix wiring.
Code: Select all
#define KEYMAP( \
K11, K10, K20, K30, K40, K41, K51, K50, K60, K70, K80, K81, K61, K02, \
K12, K13, K23, K33, K43, K42, K52, K53, K63, K73, K83, K82, K62, K01, \
K15, K14, K24, K34, K44, K45, K55, K54, K64, K74, K84, K85, K06, \
K67, K16, K26, K36, K46, K47, K57, K56, K66, K76, K87, K32, K35, \
K75, K22, K00, K07, K21, K04, K37, K27, K17 \
) { \
{ KC_##K00, KC_##K01, KC_##K02, KC_NO, KC_##K04, KC_NO, KC_##K06, KC_##K07 }, \
{ KC_##K10, KC_##K11, KC_##K12, KC_##K13, KC_##K14, KC_##K15, KC_##K16, KC_##K17 }, \
{ KC_##K20, KC_##K21, KC_##K22, KC_##K23, KC_##K24, KC_NO, KC_##K26, KC_##K27 }, \
{ KC_##K30, KC_NO, KC_##K32, KC_##K33, KC_##K34, KC_##K35, KC_##K36, KC_##K37 }, \
{ KC_##K40, KC_##K41, KC_##K42, KC_##K43, KC_##K44, KC_##K45, KC_##K46, KC_##K47 }, \
{ KC_##K50, KC_##K51, KC_##K52, KC_##K53, KC_##K54, KC_##K55, KC_##K56, KC_##K57 }, \
{ KC_##K60, KC_##K61, KC_##K62, KC_##K63, KC_##K64, KC_NO, KC_##K66, KC_##K67 }, \
{ KC_##K70, KC_NO, KC_NO, KC_##K73, KC_##K74, KC_##K75, KC_##K76, KC_NO }, \
{ KC_##K80, KC_##K81, KC_##K82, KC_##K83, KC_##K84, KC_##K85, KC_NO, KC_##K87 } \
}
#define KEYCODE(layer, row, col) (pgm_read_byte(&keymaps[(layer)][(row)][(col)]))
Okay, thanks!hasu wrote:right.
I would be happy to do so, once I figure out how that file is supposed to be edited.hasu wrote:right.
Edit: can you show your matrix.c?
Code: Select all
/*
* scan matrix
*/
#include <stdint.h>
#include <stdbool.h>
#include <avr/io.h>
#include <util/delay.h>
#include "print.h"
#include "debug.h"
#include "util.h"
#include "matrix.h"
#ifndef DEBOUNCE
# define DEBOUNCE 5
#endif
static uint8_t debouncing = DEBOUNCE;
/* matrix state(1:on, 0:off) */
static matrix_row_t matrix[MATRIX_ROWS];
static matrix_row_t matrix_debouncing[MATRIX_ROWS];
static matrix_row_t read_cols(void);
static void init_cols(void);
static void unselect_rows(void);
static void select_row(uint8_t row);
inline
uint8_t matrix_rows(void)
{
return MATRIX_ROWS;
}
inline
uint8_t matrix_cols(void)
{
return MATRIX_COLS;
}
void matrix_init(void)
{
// initialize row and col
unselect_rows();
init_cols();
// initialize matrix state: all keys off
for (uint8_t i=0; i < MATRIX_ROWS; i++) {
matrix[i] = 0;
matrix_debouncing[i] = 0;
}
}
uint8_t matrix_scan(void)
{
for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
select_row(i);
_delay_us(30); // without this wait read unstable value.
matrix_row_t cols = read_cols();
if (matrix_debouncing[i] != cols) {
matrix_debouncing[i] = cols;
if (debouncing) {
debug("bounce!: "); debug_hex(debouncing); debug("\n");
}
debouncing = DEBOUNCE;
}
unselect_rows();
}
if (debouncing) {
if (--debouncing) {
_delay_ms(1);
} else {
for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
matrix[i] = matrix_debouncing[i];
}
}
}
return 1;
}
bool matrix_is_modified(void)
{
if (debouncing) return false;
return true;
}
inline
bool matrix_is_on(uint8_t row, uint8_t col)
{
return (matrix[row] & ((matrix_row_t)1<<col));
}
inline
matrix_row_t matrix_get_row(uint8_t row)
{
return matrix[row];
}
void matrix_print(void)
{
print("\nr/c 0123456789ABCDEF\n");
for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
phex(row); print(": ");
pbin_reverse16(matrix_get_row(row));
print("\n");
}
}
uint8_t matrix_key_count(void)
{
uint8_t count = 0;
for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
count += bitpop16(matrix[i]);
}
return count;
}
/* Column pin configuration
* col: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
* pin: C7 E6 D5 D4 D1 D2 D3 C6 D7 B4 B5 B6 F5 F6 F7 F0 F1 F4
*/
static void init_cols(void)
{
// Input with pull-up(DDR:0, PORT:1)
DDRF &= ~(1<<0 | 1<<1 | 1<<4 | 1<<5 | 1<<6 | 1<<7);
PORTF |= (1<<0 | 1<<1 | 1<<4 | 1<<5 | 1<<6 | 1<<7);
DDRE &= ~(1<<6);
PORTE |= (1<<6);
DDRD &= ~(1<<7 | 1<<5 | 1<<4 | 1<<3 | 1<<2 | 1<<1);
PORTD |= (1<<7 | 1<<5 | 1<<4 | 1<<3 | 1<<2 | 1<<1);
DDRC &= ~(1<<7 | 1<<6);
PORTC |= (1<<7 | 1<<6);
DDRB &= ~(1<<6 | 1<< 5 | 1<<4);
PORTB |= (1<<6 | 1<< 5 | 1<<4);
}
static matrix_row_t read_cols(void)
{
return (PINC&(1<<7) ? 0 : (1<<0)) |
(PINE&(1<<6) ? 0 : (1<<1)) |
(PIND&(1<<5) ? 0 : (1<<2)) |
(PIND&(1<<4) ? 0 : (1<<3)) |
(PIND&(1<<1) ? 0 : (1<<4)) |
(PIND&(1<<2) ? 0 : (1<<5)) |
(PIND&(1<<3) ? 0 : (1<<6)) |
(PINC&(1<<6) ? 0 : (1<<7)) |
(PIND&(1<<7) ? 0 : (1<<8)) |
(PINB&(1<<4) ? 0 : (1<<9)) |
(PINB&(1<<5) ? 0 : (1<<10)) |
(PINB&(1<<6) ? 0 : (1<<11)) |
(PINF&(1<<5) ? 0 : (1<<12)) |
(PINF&(1<<6) ? 0 : (1<<13)) |
(PINF&(1<<7) ? 0 : (1<<14)) |
(PINF&(1<<0) ? 0 : (1<<15)) |
(PINF&(1<<1) ? 0 : (1<<16)) |
(PINF&(1<<4) ? 0 : (1<<17));
}
/* Row pin configuration
* row: 0 1 2 3 4 5
* pin: D0 B3 B0 B7 B1 B2
*/
static void unselect_rows(void)
{
// Hi-Z(DDR:0, PORT:0) to unselect
DDRD &= ~0b00000001; // PD: 0
PORTD &= ~0b00000001;
DDRB &= ~0b10001111; // PB: 7 3 2 1 0
PORTB &= ~0b10001111;
}
static void select_row(uint8_t row)
{
// Output low(DDR:1, PORT:0) to select
switch (row) {
case 0:
DDRD |= (1<<0);
PORTD &= ~(1<<0);
break;
case 1:
DDRB |= (1<<3);
PORTB &= ~(1<<3);
break;
case 2:
DDRB |= (1<<0);
PORTB &= ~(1<<0);
break;
case 3:
DDRB |= (1<<7);
PORTB &= ~(1<<7);
break;
case 4:
DDRB |= (1<<1);
PORTB &= ~(1<<1);
break;
case 5:
DDRB |= (1<<2);
PORTB &= ~(1<<2);
break;
}
}
Working on this now!hasu wrote:matrix.c looks good to me. Now you need to define your KEYMAP macro, I guess.
keycodes are defined in common/keycode.h. or see https://github.com/tmk/tmk_keyboard/blo ... eycode.txt
Code: Select all
#define KEYMAP( \
Code: Select all
#define KEYMAP( \
/* these parameters indicate keyboard layout order */
) { \
/* you must place C array notation of your matrix structure here */
}
I think I've got it. The first section of the KEYMAP macro contains the keycodes as they are laid out on the keyboard? And the the second section of the KEYMAP macro should contain the keycodes, as they are physically wired to rows and columns on the keyboard? I've done the first bit, now I'm working to translate the layout diagram to keycodes, inserting the right number of KC_NOs.hasu wrote:Yes. With KEYMAP you can convert physical matrix structure into real keyboard layout order.The roles of KEYMAP macro are 1)to offer short keycodes without 'KC_' and 2)to convert matrix structure into keyboard layout. With KEYMAP you can place just 'A' instead of 'KC_A' and define keymap in form of real keyboard look.Code: Select all
#define KEYMAP( \ /* these parameters indicate keyboard layout order */ ) { \ /* you must place C array notation of your matrix structure here */ }
Code: Select all
#define KEYMAP( \
K11, K10, K20, K30, K40, K41, K51, K50, K60, K70, K80, K81, K61, K02, \
K12, K13, K23, K33, K43, K42, K52, K53, K63, K73, K83, K82, K62, K01, \
K15, K14, K24, K34, K44, K45, K55, K54, K64, K74, K84, K85, K06, \
K67, K16, K26, K36, K46, K47, K57, K56, K66, K76, K87, K32, K35, \
K75, K22, K00, K07, K21, K04, K37, K27, K17 \
Code: Select all
#define MATRIX_ROWS 6
#define MATRIX_COLS 19
Code: Select all
#define KEYMAP( \
K84, K3A, K3B, K3C, K3D, K3E, K3F, K40, K42, K43, K44, K49, K4C, K49, K4C, K9C, KA2, K74, \
K29, K1E, K1F, K20, K21, K22, K23, K24, K25, K26, K27, K2D, K2E, K35, K31, K2A, K5F, K60, K61, \
K2B, K14, K1A, K08, K15, K17, K1C, K18, K0C, K12, K13, K2F, K9F, K9C, K5C, K5D, K5E, \
KE0, K39, K04, K16, K07, K09, K0A, K0B, K0D, K0E, K0F, K33, K34, K28, K78, K59, K5A, K5B, \
K9D, KE1, K1D, K1B, K06, K19, K05, K11, K10, K36, K37, K38, KE5, K30, K4C, K63, K62, K85, \
K46, KE2, K2C, K4A, K51, K52, K50, K4F, K58, K56 \
) { \
{ KC_##K84, KC_##K3A, KC_##K3B, KC_##K3C, KC_##K3D, KC_##K3E, KC_##K3F, KC_##K40, KC_##K42, KC_##K43, KC_##K44, KC_##K49, KC_##K4C, KC_##K49, KC_##K4C, KC_##K9C, KC_##KA2, KC_##K74, }, \
{ KC_##K29, KC_##K1E, KC_##K1F, KC_##K20, KC_##K21, KC_##K22, KC_##K23, KC_##K24, KC_##K26, KC_##K27, KC_##K2D, KC_##K2E, KC_##K35, KC_##K31, KC_##K2A, KC_##K5F, KC_##K60, KC_##K61, }, \
{ KC_##K2B, KC_##K14, KC_##K1A, KC_##K08, KC_##K15, KC_##K17, KC_##K1C, KC_##K18, KC_##K12, KC_##K0C, KC_##K13, KC_##K2F, KC_##K9F, KC_##K25, KC_##K9C, KC_##K5C, KC_##K5D, KC_##K5E, }, \
{ KC_##K39, KC_##K04, KC_##K16, KC_##K07, KC_##K09, KC_##K0A, KC_##K0B, KC_##K0D, KC_##K0F, KC_##KE0, KC_##K33, KC_##K34, KC_##K0E, KC_##K28, KC_##K78, KC_##K59, KC_##K5A, KC_##K5B, }, \
{ KC_##KE1, KC_##K1D, KC_##K1B, KC_##K06, KC_##K19, KC_##K05, KC_##K11, KC_##K10, KC_NO, KC_##K9D, KC_##K37, KC_##K38, KC_##KE5, KC_##K30, KC_##K4C, KC_##K63, KC_##K62, KC_##K85, }, \
{ KC_##K46, KC_##KE2, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_##K36, KC_NO, KC_##K2C, KC_##K4A, KC_##K51, KC_##K52, KC_##K50, KC_##K4F, KC_##K58, KC_##K56, KC_NO}, \
}
Code: Select all
{ KC_##K50, KC_##K51, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_##K55, KC_NO,