From d5ac54449ad7726e4d392d14551f3559cc63afbf Mon Sep 17 00:00:00 2001 From: tmk Date: Sun, 5 Apr 2015 14:41:14 +0900 Subject: Add alps64 --- keyboard/alps64/Makefile | 134 ++++++++++++++++++++++++++++ keyboard/alps64/config.h | 70 +++++++++++++++ keyboard/alps64/keymap_common.c | 30 +++++++ keyboard/alps64/keymap_common.h | 70 +++++++++++++++ keyboard/alps64/keymap_hasu.c | 151 +++++++++++++++++++++++++++++++ keyboard/alps64/keymap_plain.c | 12 +++ keyboard/alps64/led.c | 34 +++++++ keyboard/alps64/matrix.c | 190 ++++++++++++++++++++++++++++++++++++++++ 8 files changed, 691 insertions(+) create mode 100644 keyboard/alps64/Makefile create mode 100644 keyboard/alps64/config.h create mode 100644 keyboard/alps64/keymap_common.c create mode 100644 keyboard/alps64/keymap_common.h create mode 100644 keyboard/alps64/keymap_hasu.c create mode 100644 keyboard/alps64/keymap_plain.c create mode 100644 keyboard/alps64/led.c create mode 100644 keyboard/alps64/matrix.c (limited to 'keyboard/alps64') diff --git a/keyboard/alps64/Makefile b/keyboard/alps64/Makefile new file mode 100644 index 0000000000..a7d59309e8 --- /dev/null +++ b/keyboard/alps64/Makefile @@ -0,0 +1,134 @@ +#---------------------------------------------------------------------------- +# 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 = alps64 + +# Directory common source filess exist +TOP_DIR = ../.. + +# 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_plain.c $(SRC) +endif + +CONFIG_H = config.h + + +# MCU name +MCU = atmega32u2 + +# 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 - not yet supported in LUFA + + +# Optimize size but this may cause error "relocation truncated to fit" +#EXTRALDFLAGS = -Wl,--relax + +# Search Path +VPATH += $(TARGET_DIR) +VPATH += $(TOP_DIR) + +include $(TOP_DIR)/protocol/lufa.mk +include $(TOP_DIR)/common.mk +include $(TOP_DIR)/rules.mk diff --git a/keyboard/alps64/config.h b/keyboard/alps64/config.h new file mode 100644 index 0000000000..06649a092d --- /dev/null +++ b/keyboard/alps64/config.h @@ -0,0 +1,70 @@ +/* +Copyright 2015 Jun Wako + +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 . +*/ + +#ifndef CONFIG_H +#define CONFIG_H + + +/* USB Device descriptor parameter */ +#define VENDOR_ID 0xFEED +#define PRODUCT_ID 0x6464 +#define DEVICE_VER 0x0001 +#define MANUFACTURER geekhack +#define PRODUCT Alps64 +#define DESCRIPTION t.m.k. keyboard firmware for Alps64 + +/* key matrix size */ +#define MATRIX_ROWS 8 +#define MATRIX_COLS 8 + +/* 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 diff --git a/keyboard/alps64/keymap_common.c b/keyboard/alps64/keymap_common.c new file mode 100644 index 0000000000..fdb1769e1c --- /dev/null +++ b/keyboard/alps64/keymap_common.c @@ -0,0 +1,30 @@ +/* +Copyright 2012,2013 Jun Wako + +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 . +*/ +#include "keymap_common.h" + + +/* translates key to keycode */ +uint8_t keymap_key_to_keycode(uint8_t layer, keypos_t key) +{ + return pgm_read_byte(&keymaps[(layer)][(key.row)][(key.col)]); +} + +/* translates Fn keycode to action */ +action_t keymap_fn_to_action(uint8_t keycode) +{ + return (action_t){ .code = pgm_read_word(&fn_actions[FN_INDEX(keycode)]) }; +} diff --git a/keyboard/alps64/keymap_common.h b/keyboard/alps64/keymap_common.h new file mode 100644 index 0000000000..b2d6ad5c4a --- /dev/null +++ b/keyboard/alps64/keymap_common.h @@ -0,0 +1,70 @@ +/* +Copyright 2012,2013 Jun Wako + +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 . +*/ +#ifndef KEYMAP_COMMON_H +#define KEYMAP_COMMON_H + +#include +#include +#include +#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[]; + + +/* Alps64 keymap definition macro */ +#define KEYMAP( \ + K36, K37, K46, K47, K56, K57, K66, K67, K76, K77, K06, K07, K17, K26, K27, \ + K34, K35, K44, K45, K54, K55, K64, K65, K75, K05, K15, K16, K25, K24, \ + K32, K33, K43, K52, K53, K63, K73, K74, K03, K04, K13, K14, K23, \ + K31, K41, K42, K51, K61, K62, K71, K72, K01, K02, K11, K12, K21, K22, \ + K30, K40, K50, K60, K70, K00, K10, K20 \ +) { \ + { KC_##K00, KC_##K01, KC_##K02, KC_##K03, KC_##K04, KC_##K05, 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_##K25, KC_##K26, KC_##K27 }, \ + { KC_##K30, KC_##K31, 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_##K65, KC_##K66, KC_##K67 }, \ + { KC_##K70, KC_##K71, KC_##K72, KC_##K73, KC_##K74, KC_##K75, KC_##K76, KC_##K77 } \ +} + +/* AEK US */ +#define KEYMAP_AEK( \ + K36, K37, K46, K47, K56, K57, K66, K67, K76, K77, K06, K07, K17, K27, \ + K34, K35, K44, K45, K54, K55, K64, K65, K75, K05, K15, K16, K25, K24, \ + K32, K33, K43, K52, K53, K63, K73, K74, K03, K04, K13, K14, K23, \ + K31, K42, K51, K61, K62, K71, K72, K01, K02, K11, K12, K21, \ + K30, K40, K50, K60, K00, K10, K20 \ +) KEYMAP( \ + K36, K37, K46, K47, K56, K57, K66, K67, K76, K77, K06, K07, K17, NO, K27, \ + K34, K35, K44, K45, K54, K55, K64, K65, K75, K05, K15, K16, K25, K24, \ + K32, K33, K43, K52, K53, K63, K73, K74, K03, K04, K13, K14, K23, \ + K31, NO, K42, K51, K61, K62, K71, K72, K01, K02, K11, K12, K21, NO, \ + K30, K40, K50, K60, NO, K00, K10, K20 \ +) + +#endif diff --git a/keyboard/alps64/keymap_hasu.c b/keyboard/alps64/keymap_hasu.c new file mode 100644 index 0000000000..784b313134 --- /dev/null +++ b/keyboard/alps64/keymap_hasu.c @@ -0,0 +1,151 @@ +#include "keymap_common.h" + +/* + * Hasu + */ +const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + /* Default Layer + * ,-----------------------------------------------------------. + * |Esc| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backsp | + * |-----------------------------------------------------------| + * |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \| + * |-----------------------------------------------------------| + * |Ctrl | A| S| D| F| G| H| J| K| L|Fn3| '|FN1 | + * |-----------------------------------------------------------| + * |Shift | Z| X| C| V| B| N| M| ,| .|Fn2|Shift | + * |-----------------------------------------------------------| + * |Ctrl |Gui |Alt | Space |Alt |Fn5 |Ctrl | + * `-----------------------------------------------------------' + */ + [0] = KEYMAP_AEK( \ + ESC, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSPC, \ + TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,BSLS, \ + LCTL,A, S, D, F, G, H, J, K, L, FN3, QUOT,FN1, \ + LSFT,Z, X, C, V, B, N, M, COMM,DOT, FN2, RSFT, \ + LCTL,LGUI,LALT, FN4, RALT,FN5, RCTL), + + /* HHKB mode[HHKB Fn] + * ,-----------------------------------------------------------. + * |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Del | + * |-----------------------------------------------------------| + * |Caps | | | | | | | |Psc|Slk|Pus|Up | |Backs| + * |-----------------------------------------------------------| + * |Contro|VoD|VoU|Mut| | | *| /|Hom|PgU|Lef|Rig|Enter | + * |-----------------------------------------------------------| + * |Shift | | | | | | +| -|End|PgD|Dow|Shift | + * |-----------------------------------------------------------| + * |Ctrl |Gui |Alt | Space |Alt |Fn5 |Ctrl | + * `-----------------------------------------------------------' + */ + [1] = KEYMAP_AEK( \ + GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, DEL, \ + CAPS,NO, NO, NO, NO, NO, NO, NO, PSCR,SLCK,PAUS,UP, NO, BSPC, \ + LCTL,VOLD,VOLU,MUTE,NO, NO, PAST,PSLS,HOME,PGUP,LEFT,RGHT,TRNS, \ + LSFT,NO, NO, NO, NO, NO, PPLS,PMNS,END, PGDN,DOWN,RSFT, \ + LCTL,LGUI,LALT, TRNS, RALT,RGUI,RCTL), + + /* Vi mode[Slash] + * ,-----------------------------------------------------------. + * |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Del | + * |-----------------------------------------------------------| + * |Tab |Hom|PgD|Up |PgU|End|Hom|PgD|PgUlEnd| | | |Backs| + * |-----------------------------------------------------------| + * |Contro| |Lef|Dow|Rig| |Lef|Dow|Up |Rig| | |Return | + * |-----------------------------------------------------------| + * |Shift | | | | | |Hom|PgD|PgUlEnd|Fn0|Shift | + * |-----------------------------------------------------------| + * |Ctrl |Gui |Alt | Space |Alt |Fn5 |Ctrl | + * `-----------------------------------------------------------' + */ + [2] = KEYMAP_AEK( \ + GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, DEL, \ + TAB, HOME,PGDN,UP, PGUP,END, HOME,PGDN,PGUP,END, NO, NO, NO, BSPC, \ + LCTL,NO, LEFT,DOWN,RGHT,NO, LEFT,DOWN,UP, RGHT,NO, NO, ENT, \ + LSFT,NO, NO, NO, NO, NO, HOME,PGDN,PGUP,END, FN2, RSFT, \ + LCTL,LGUI,LALT, SPC, RALT,RGUI,RCTL), + + /* Mouse mode(IJKL)[Semicolon] + * ,-----------------------------------------------------------. + * |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Ins|Del| + * |-----------------------------------------------------------| + * |Tab | | | | | |MwL|MwD|McU|MwU|MwR|Wbk|Wfr|Alt-T| + * |-----------------------------------------------------------| + * |Contro| | | | | |Mb2|McL|McD|McR|Fn | |Return | + * |-----------------------------------------------------------| + * |Shift | | | | |Mb3|Mb2|Mb1|Mb4|Mb5| |Shift | | + * |-----------------------------------------------------------| + * |Ctrl |Gui |Alt | Space |Alt |Fn5 |Ctrl | + * `-----------------------------------------------------------' + * Mc: Mouse Cursor / Mb: Mouse Button / Mw: Mouse Wheel + */ + [3] = KEYMAP_AEK( \ + GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, DEL, \ + FN8, NO, NO, NO, NO, NO, NO, WH_D,MS_U,WH_U,RGHT,FN9, FN10,FN8, \ + LCTL,ACL0,ACL1,ACL2,ACL2,NO, NO, MS_L,MS_D,MS_R,TRNS,NO, ENT, \ + LSFT,NO, NO, NO, NO, BTN3,BTN2,BTN1,FN9, FN10,NO, RSFT, \ + LCTL,LGUI,LALT, BTN1, TRNS,TRNS,TRNS), + + /* Layer 4: Mouse mode(IJKL)[Space] + * ,-----------------------------------------------------------. + * |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Ins|Del| + * |-----------------------------------------------------------| + * |Tab | | | | | |MwL|MwD|McU|MwU|MwR|Wbk|Wfr|Alt-T| + * |-----------------------------------------------------------| + * |Contro| | | | | |Mb2|McL|McD|McR|Mb1| |Return | + * |-----------------------------------------------------------| + * |Shift | | | | |Mb3|Mb2|Mb1|Mb4|Mb5| |Shift | | + * |-----------------------------------------------------------| + * |Ctrl |Gui |Alt | Space |Alt |Fn5 |Ctrl | + * `-----------------------------------------------------------' + * Mc: Mouse Cursor / Mb: Mouse Button / Mw: Mouse Wheel + */ + [4] = KEYMAP_AEK( \ + GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, DEL, \ + FN8, NO, NO, NO, NO, NO, NO, WH_D,MS_U,WH_U,RGHT,FN9, FN10,FN8, \ + LCTL,VOLD,VOLU,MUTE,NO, NO, NO, MS_L,MS_D,MS_R,BTN1,NO, ENT, \ + LSFT,NO, NO, NO, NO, BTN3,BTN2,BTN1,FN9, FN10,NO, RSFT, \ + LCTL,LGUI,LALT, TRNS, TRNS,TRNS,TRNS), +}; + + +/* id for user defined function/macro */ +enum function_id { + NONE, +}; + +enum macro_id { + ALT_TAB, +}; + + +/* + * Fn action definition + */ +const uint16_t PROGMEM fn_actions[] = { + [0] = ACTION_DEFAULT_LAYER_SET(0), // Default layer(not used) + [1] = ACTION_LAYER_TAP_KEY(1, KC_ENTER), // HHKB layer + [2] = ACTION_LAYER_TAP_KEY(2, KC_SLASH), // Cursor layer with Slash* + [3] = ACTION_LAYER_TAP_KEY(3, KC_SCLN), // Mousekey layer with Semicolon* + [4] = ACTION_LAYER_TAP_KEY(4, KC_SPC), // Mousekey layer with Space + [5] = ACTION_LAYER_MOMENTARY(3), // Mousekey layer(IJKL) + [6] = ACTION_LAYER_TAP_KEY(MOD_RCTL, KC_ENT), // RControl with tap Enter + [7] = ACTION_MODS_ONESHOT(MOD_LSFT), // Oneshot Shift + [8] = ACTION_MACRO(ALT_TAB), // Application switching + [9] = ACTION_MODS_KEY(MOD_LALT, KC_LEFT), + [10] = ACTION_MODS_KEY(MOD_LALT, KC_RIGHT), +}; + + +/* + * Macro definition + */ +const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) +{ + switch (id) { + case ALT_TAB: + return (record->event.pressed ? + MACRO( D(LALT), D(TAB), END ) : + MACRO( U(TAB), END )); + } + return MACRO_NONE; +} diff --git a/keyboard/alps64/keymap_plain.c b/keyboard/alps64/keymap_plain.c new file mode 100644 index 0000000000..13a4407f8f --- /dev/null +++ b/keyboard/alps64/keymap_plain.c @@ -0,0 +1,12 @@ +#include "keymap_common.h" + +const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + /* 0: qwerty */ + KEYMAP_AEK( \ + 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,BSLS, \ + CAPS,A, S, D, F, G, H, J, K, L, SCLN,QUOT,ENT, \ + LSFT,Z, X, C, V, B, N, M, COMM,DOT, SLSH,RSFT, \ + LCTL,LGUI,LALT, SPC, RALT,RGUI,RCTL), +}; +const uint16_t PROGMEM fn_actions[] = {}; diff --git a/keyboard/alps64/led.c b/keyboard/alps64/led.c new file mode 100644 index 0000000000..d20c51aabe --- /dev/null +++ b/keyboard/alps64/led.c @@ -0,0 +1,34 @@ +/* +Copyright 2012 Jun Wako + +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 . +*/ + +#include +#include "stdint.h" +#include "led.h" + + +void led_set(uint8_t usb_led) +{ + if (usb_led & (1< + +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 . +*/ + +/* + * scan matrix + */ +#include +#include +#include +#include +#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; +} + +inline +bool matrix_is_on(uint8_t row, uint8_t col) +{ + return (matrix[row] & ((matrix_row_t)1< Date: Thu, 9 Apr 2015 16:20:42 +0900 Subject: Change TOP_DIR to TMK_DIR in makefiles --- keyboard/alps64/Makefile | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'keyboard/alps64') diff --git a/keyboard/alps64/Makefile b/keyboard/alps64/Makefile index a7d59309e8..3e0dccc9e9 100644 --- a/keyboard/alps64/Makefile +++ b/keyboard/alps64/Makefile @@ -42,7 +42,7 @@ TARGET = alps64 # Directory common source filess exist -TOP_DIR = ../.. +TMK_DIR = ../.. # Directory keyboard dependent files exist TARGET_DIR = . @@ -127,8 +127,8 @@ COMMAND_ENABLE = yes # Commands for debug and configuration # Search Path VPATH += $(TARGET_DIR) -VPATH += $(TOP_DIR) +VPATH += $(TMK_DIR) -include $(TOP_DIR)/protocol/lufa.mk -include $(TOP_DIR)/common.mk -include $(TOP_DIR)/rules.mk +include $(TMK_DIR)/protocol/lufa.mk +include $(TMK_DIR)/common.mk +include $(TMK_DIR)/rules.mk -- cgit v1.2.3 From 7860d09914dba5e7d2d6c1c25b62b49d1bbd2591 Mon Sep 17 00:00:00 2001 From: tmk Date: Fri, 10 Apr 2015 01:53:24 +0900 Subject: Change TMK_DIR setting --- keyboard/alps64/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'keyboard/alps64') diff --git a/keyboard/alps64/Makefile b/keyboard/alps64/Makefile index 3e0dccc9e9..e90dcedb67 100644 --- a/keyboard/alps64/Makefile +++ b/keyboard/alps64/Makefile @@ -42,7 +42,7 @@ TARGET = alps64 # Directory common source filess exist -TMK_DIR = ../.. +TMK_DIR = ../../tmk_core # Directory keyboard dependent files exist TARGET_DIR = . -- cgit v1.2.3 From 177400b7e0932701a0d0f5d1c931b42907e3472f Mon Sep 17 00:00:00 2001 From: tmk Date: Wed, 13 May 2015 16:25:41 +0900 Subject: alps64: Change keymap --- keyboard/alps64/keymap_hasu.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'keyboard/alps64') diff --git a/keyboard/alps64/keymap_hasu.c b/keyboard/alps64/keymap_hasu.c index 784b313134..d297d72fea 100644 --- a/keyboard/alps64/keymap_hasu.c +++ b/keyboard/alps64/keymap_hasu.c @@ -6,9 +6,9 @@ const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { /* Default Layer * ,-----------------------------------------------------------. - * |Esc| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backsp | + * |Esc| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =| \ | * |-----------------------------------------------------------| - * |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \| + * |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]|Bspc | * |-----------------------------------------------------------| * |Ctrl | A| S| D| F| G| H| J| K| L|Fn3| '|FN1 | * |-----------------------------------------------------------| @@ -18,17 +18,17 @@ const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { * `-----------------------------------------------------------' */ [0] = KEYMAP_AEK( \ - ESC, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSPC, \ - TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,BSLS, \ + ESC, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSLS, \ + TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,BSPC, \ LCTL,A, S, D, F, G, H, J, K, L, FN3, QUOT,FN1, \ LSFT,Z, X, C, V, B, N, M, COMM,DOT, FN2, RSFT, \ - LCTL,LGUI,LALT, FN4, RALT,FN5, RCTL), + LCTL,LGUI,LALT, FN4, RALT,FN5, FN0), /* HHKB mode[HHKB Fn] * ,-----------------------------------------------------------. - * |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Del | + * |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12| ` | * |-----------------------------------------------------------| - * |Caps | | | | | | | |Psc|Slk|Pus|Up | |Backs| + * |Caps | | | | | | | |Psc|Slk|Pus|Up | |Del | * |-----------------------------------------------------------| * |Contro|VoD|VoU|Mut| | | *| /|Hom|PgU|Lef|Rig|Enter | * |-----------------------------------------------------------| @@ -38,11 +38,11 @@ const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { * `-----------------------------------------------------------' */ [1] = KEYMAP_AEK( \ - GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, DEL, \ - CAPS,NO, NO, NO, NO, NO, NO, NO, PSCR,SLCK,PAUS,UP, NO, BSPC, \ + GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, GRV, \ + CAPS,NO, NO, NO, NO, NO, NO, NO, PSCR,SLCK,PAUS,UP, NO, DEL, \ LCTL,VOLD,VOLU,MUTE,NO, NO, PAST,PSLS,HOME,PGUP,LEFT,RGHT,TRNS, \ LSFT,NO, NO, NO, NO, NO, PPLS,PMNS,END, PGDN,DOWN,RSFT, \ - LCTL,LGUI,LALT, TRNS, RALT,RGUI,RCTL), + LCTL,LGUI,LALT, TRNS, RALT,RGUI,TRNS), /* Vi mode[Slash] * ,-----------------------------------------------------------. @@ -58,8 +58,8 @@ const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { * `-----------------------------------------------------------' */ [2] = KEYMAP_AEK( \ - GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, DEL, \ - TAB, HOME,PGDN,UP, PGUP,END, HOME,PGDN,PGUP,END, NO, NO, NO, BSPC, \ + GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, GRV, \ + TAB, HOME,PGDN,UP, PGUP,END, HOME,PGDN,PGUP,END, NO, NO, NO, DEL, \ LCTL,NO, LEFT,DOWN,RGHT,NO, LEFT,DOWN,UP, RGHT,NO, NO, ENT, \ LSFT,NO, NO, NO, NO, NO, HOME,PGDN,PGUP,END, FN2, RSFT, \ LCTL,LGUI,LALT, SPC, RALT,RGUI,RCTL), @@ -79,7 +79,7 @@ const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { * Mc: Mouse Cursor / Mb: Mouse Button / Mw: Mouse Wheel */ [3] = KEYMAP_AEK( \ - GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, DEL, \ + GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, GRV, \ FN8, NO, NO, NO, NO, NO, NO, WH_D,MS_U,WH_U,RGHT,FN9, FN10,FN8, \ LCTL,ACL0,ACL1,ACL2,ACL2,NO, NO, MS_L,MS_D,MS_R,TRNS,NO, ENT, \ LSFT,NO, NO, NO, NO, BTN3,BTN2,BTN1,FN9, FN10,NO, RSFT, \ @@ -100,7 +100,7 @@ const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { * Mc: Mouse Cursor / Mb: Mouse Button / Mw: Mouse Wheel */ [4] = KEYMAP_AEK( \ - GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, DEL, \ + GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, GRV, \ FN8, NO, NO, NO, NO, NO, NO, WH_D,MS_U,WH_U,RGHT,FN9, FN10,FN8, \ LCTL,VOLD,VOLU,MUTE,NO, NO, NO, MS_L,MS_D,MS_R,BTN1,NO, ENT, \ LSFT,NO, NO, NO, NO, BTN3,BTN2,BTN1,FN9, FN10,NO, RSFT, \ @@ -122,7 +122,7 @@ enum macro_id { * Fn action definition */ const uint16_t PROGMEM fn_actions[] = { - [0] = ACTION_DEFAULT_LAYER_SET(0), // Default layer(not used) + [0] = ACTION_LAYER_MOMENTARY(1), // HHKB layer [1] = ACTION_LAYER_TAP_KEY(1, KC_ENTER), // HHKB layer [2] = ACTION_LAYER_TAP_KEY(2, KC_SLASH), // Cursor layer with Slash* [3] = ACTION_LAYER_TAP_KEY(3, KC_SCLN), // Mousekey layer with Semicolon* -- cgit v1.2.3 From 507ebb34f5e7ca0eb2543f3c755ae39671a9b44c Mon Sep 17 00:00:00 2001 From: tmk Date: Fri, 26 Jun 2015 08:49:03 +0900 Subject: alps64: Change keymaps and USB descriptors. --- keyboard/alps64/config.h | 4 ++-- keyboard/alps64/keymap_common.h | 6 +++--- keyboard/alps64/keymap_plain.c | 8 ++++---- keyboard/alps64/matrix.c | 10 ++++++++++ 4 files changed, 19 insertions(+), 9 deletions(-) (limited to 'keyboard/alps64') diff --git a/keyboard/alps64/config.h b/keyboard/alps64/config.h index 06649a092d..824d3e8302 100644 --- a/keyboard/alps64/config.h +++ b/keyboard/alps64/config.h @@ -23,9 +23,9 @@ along with this program. If not, see . #define VENDOR_ID 0xFEED #define PRODUCT_ID 0x6464 #define DEVICE_VER 0x0001 -#define MANUFACTURER geekhack +#define MANUFACTURER TMK #define PRODUCT Alps64 -#define DESCRIPTION t.m.k. keyboard firmware for Alps64 +#define DESCRIPTION TMK keyboard firmware for Alps64 /* key matrix size */ #define MATRIX_ROWS 8 diff --git a/keyboard/alps64/keymap_common.h b/keyboard/alps64/keymap_common.h index b2d6ad5c4a..957db57922 100644 --- a/keyboard/alps64/keymap_common.h +++ b/keyboard/alps64/keymap_common.h @@ -60,11 +60,11 @@ extern const uint16_t fn_actions[]; K31, K42, K51, K61, K62, K71, K72, K01, K02, K11, K12, K21, \ K30, K40, K50, K60, K00, K10, K20 \ ) KEYMAP( \ - K36, K37, K46, K47, K56, K57, K66, K67, K76, K77, K06, K07, K17, NO, K27, \ + K36, K37, K46, K47, K56, K57, K66, K67, K76, K77, K06, K07, K17, NUHS,K27, \ K34, K35, K44, K45, K54, K55, K64, K65, K75, K05, K15, K16, K25, K24, \ K32, K33, K43, K52, K53, K63, K73, K74, K03, K04, K13, K14, K23, \ - K31, NO, K42, K51, K61, K62, K71, K72, K01, K02, K11, K12, K21, NO, \ - K30, K40, K50, K60, NO, K00, K10, K20 \ + K31, NUBS,K42, K51, K61, K62, K71, K72, K01, K02, K11, K12, K21, ESC, \ + K30, K40, K50, K60, APP, K00, K10, K20 \ ) #endif diff --git a/keyboard/alps64/keymap_plain.c b/keyboard/alps64/keymap_plain.c index 13a4407f8f..a54899196a 100644 --- a/keyboard/alps64/keymap_plain.c +++ b/keyboard/alps64/keymap_plain.c @@ -2,11 +2,11 @@ const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { /* 0: qwerty */ - KEYMAP_AEK( \ - GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSPC, \ + KEYMAP( \ + GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, NUHS, BSPC, \ TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,BSLS, \ CAPS,A, S, D, F, G, H, J, K, L, SCLN,QUOT,ENT, \ - LSFT,Z, X, C, V, B, N, M, COMM,DOT, SLSH,RSFT, \ - LCTL,LGUI,LALT, SPC, RALT,RGUI,RCTL), + LSFT,NUBS,Z, X, C, V, B, N, M, COMM,DOT, SLSH,RSFT,ESC, \ + LCTL,LGUI,LALT, SPC, APP, RALT,RGUI,RCTL), }; const uint16_t PROGMEM fn_actions[] = {}; diff --git a/keyboard/alps64/matrix.c b/keyboard/alps64/matrix.c index a49755c3a3..aa991e0aec 100644 --- a/keyboard/alps64/matrix.c +++ b/keyboard/alps64/matrix.c @@ -55,6 +55,10 @@ uint8_t matrix_cols(void) return MATRIX_COLS; } +#define LED_ON() do { DDRC |= (1<<5); PORTC |= (1<<5); } while (0) +#define LED_OFF() do { DDRC &= ~(1<<5); PORTC &= ~(1<<5); } while (0) +#define LED_TGL() do { DDRC |= (1<<5); PINC |= (1<<5); } while (0) + void matrix_init(void) { // initialize row and col @@ -66,6 +70,12 @@ void matrix_init(void) matrix[i] = 0; matrix_debouncing[i] = 0; } + + //debug + debug_matrix = true; + LED_ON(); + _delay_ms(500); + LED_OFF(); } uint8_t matrix_scan(void) -- cgit v1.2.3 From 6fe4af82fa21cbeb8e22c9f0630e5a908963cc13 Mon Sep 17 00:00:00 2001 From: tmk Date: Thu, 15 Oct 2015 11:48:14 +0900 Subject: Fix port setting of alps64/matrix.c --- keyboard/alps64/matrix.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'keyboard/alps64') diff --git a/keyboard/alps64/matrix.c b/keyboard/alps64/matrix.c index aa991e0aec..5638d7f69d 100644 --- a/keyboard/alps64/matrix.c +++ b/keyboard/alps64/matrix.c @@ -157,7 +157,7 @@ static void unselect_rows(void) DDRD &= ~0b01111111; PORTD &= ~0b01111111; DDRC &= ~0b00000100; - PORTD &= ~0b00000100; + PORTC &= ~0b00000100; } static void select_row(uint8_t row) -- cgit v1.2.3