1
0
Fork 0

new build method for macway

This commit is contained in:
tmk 2010-10-27 20:51:45 +09:00
parent 461e0d3d8c
commit 2f80e790c6
17 changed files with 432 additions and 227 deletions

View file

@ -39,7 +39,13 @@
# To rebuild project do "make clean" then "make all".
#----------------------------------------------------------------------------
DESCRIPTION = 't.m.k. firmware for HHKB pro\n'
VENDOR_ID = 0xFEED
PRODUCT_ID = 0xCAFE
MANUFACTURER = 't.m.k.'
PRODUCT = 't.m.k. HHKB pro'
DESCRIPTION = 't.m.k. firmware for HHKB pro'
MOUSE_DELAY_TIME = 127
# Target file name (without extension).
TARGET = tmk_hhkb

View file

@ -1,14 +1,16 @@
/*
* Keymap for PFU HHKB Pro
*/
#include <stdint.h>
#include <stdbool.h>
#include <avr/pgmspace.h>
#include "usb_keyboard.h"
#include "usb_keycodes.h"
#include "matrix.h"
#include "keymap.h"
#include "print.h"
#include "debug.h"
#include "util.h"
#include "keymap.h"
#define FN_KEYCODE(fn) (pgm_read_byte(&fn_keycode[(fn)]))
@ -33,9 +35,6 @@
}
static int onbit(uint8_t bits);
static int current_layer = 0;
static bool layer_used = false;
@ -104,7 +103,7 @@ static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
* |-----------------------------------------------------------|
* |Shift | | | | | | | | | | |Shift | |
* `-----------------------------------------------------------'
* |Gui|Alt |Sapce |Alt |Gui|
* |Gui|Alt |Space |Alt |Gui|
* `-------------------------------------------'
*/
KEYMAP(KB_ESC, KB_F1, KB_F2, KB_F3, KB_F4, KB_F5, KB_F6, KB_F7, KB_F8, KB_F9, KB_F10, KB_F11, KB_F12, KB_INS, KB_DEL, \
@ -199,7 +198,7 @@ void keymap_fn_proc(int fn_bits)
} else if (fn_bits == 0) {
// send key when Fn key is released without using the layer
if (!layer_used) {
uint8_t code = FN_KEYCODE(onbit(last_bits));
uint8_t code = FN_KEYCODE(biton(last_bits));
if (code != KB_NO) {
if (IS_MOD(code)) {
keyboard_modifier_keys = last_mod | 1<<(code & 0x07);
@ -221,18 +220,9 @@ void keymap_fn_proc(int fn_bits)
last_bits = fn_bits;
last_mod = keyboard_modifier_keys;
layer_used = false;
keymap_set_layer(FN_LAYER(onbit(fn_bits)));
keymap_set_layer(FN_LAYER(biton(fn_bits)));
debug("layer: "); phex(current_layer); debug("(");
debug_bin(last_bits); debug(")\n");
debug("last_mod: "); debug_hex(last_mod); debug("\n");
}
}
static int onbit(uint8_t bits)
{
int n = 0;
if (bits >> 4) { bits >>= 4; n += 4;}
if (bits >> 2) { bits >>= 2; n += 2;}
if (bits >> 1) { bits >>= 1; n += 1;}
return n;
}

View file

@ -1,8 +1,6 @@
#ifndef KEYMAP_H
#define KEYMAP_H 1
#include <stdint.h>
#include <stdbool.h>
#include "usb_keycodes.h"
#include "keymap_skel.h"

View file

@ -1,10 +1,13 @@
/*
* scan matrix
*/
#include <stdint.h>
#include <stdbool.h>
#include <avr/io.h>
#include <util/delay.h>
#include "matrix.h"
#include "print.h"
#include "util.h"
// matrix is active low. (key on: 0/key off: 1)
//
@ -30,10 +33,6 @@ static uint8_t _matrix0[MATRIX_ROWS];
static uint8_t _matrix1[MATRIX_ROWS];
static bool matrix_has_ghost_in_row(int row);
static int bit_pop(uint8_t bits);
inline
int matrix_rows(void)
{
@ -122,9 +121,6 @@ void matrix_print(void)
for (int row = 0; row < matrix_rows(); row++) {
phex(row); print(": ");
pbin_reverse(matrix_get_row(row));
if (matrix_has_ghost_in_row(row)) {
print(" <ghost");
}
print("\n");
}
}
@ -133,22 +129,7 @@ int matrix_key_count(void)
{
int count = 0;
for (int i = 0; i < MATRIX_ROWS; i++) {
count += bit_pop(matrix[i]);
count += bitpop(matrix[i]);
}
return count;
}
inline
static bool matrix_has_ghost_in_row(int row)
{
return false;
}
inline
static int bit_pop(uint8_t bits)
{
int c;
for (c = 0; bits; c++)
bits &= bits -1;
return c;
}