commit
9307a0a3e4
64 changed files with 2626 additions and 1805 deletions
17
README.md
17
README.md
|
|
@ -54,6 +54,15 @@ You can find some keyboard specific projects under `converter` and `keyboard` di
|
|||
* [KMAC](keyboard/kmac/) - Korean custom keyboard
|
||||
* [Lightsaber](keyboard/lightsaber/) - Korean custom keyboard
|
||||
* [Infinity](keyboard/infinity/) - Massdrop [Infinity keyboard][Infinity]
|
||||
* [NerD](keyboard/nerd/) - Korean custom keyboard
|
||||
* [KittenPaw](keyboard/kitten_paw) - Custom Majestouch controller
|
||||
* [Lightpad](keyboard/lightpad) - Korean custom keypad
|
||||
* [ghost_squid](keyboard/ghost_squid/) - [The Ghost Squid][ghost_squid] controller for [Cooler Master QuickFire XT][cmxt]
|
||||
|
||||
### Extenal projects using tmk_keyboard
|
||||
* [ErgoDox_cub-uanic][cub-uanic] - Split Ergonomic Keyboard [ErgoDox][ergodox_org]
|
||||
* [mcdox][mcdox_tmk] - [mcdox][mcdox]
|
||||
|
||||
|
||||
[GH_macway]: http://geekhack.org/showwiki.php?title=Island:11930
|
||||
[GH_hhkb]: http://geekhack.org/showwiki.php?title=Island:12047
|
||||
|
|
@ -74,6 +83,12 @@ You can find some keyboard specific projects under `converter` and `keyboard` di
|
|||
[Sun]: http://en.wikipedia.org/wiki/Sun-3
|
||||
[IIGS]: http://en.wikipedia.org/wiki/Apple_IIGS
|
||||
[Infinity]: https://www.massdrop.com/buy/infinity-keyboard-kit
|
||||
[ghost_squid]: http://deskthority.net/wiki/Costar_replacement_controllers#The_Ghost_Squid
|
||||
[cmxt]: http://gaming.coolermaster.com/en/products/keyboards/quickfirext/
|
||||
[ergodox_org]: http://ergodox.org/
|
||||
[cub-uanic]: https://github.com/cub-uanic/tmk_keyboard/tree/master/keyboard/ergodox
|
||||
[mcdox]: https://github.com/DavidMcEwan/mcdox
|
||||
[mcdox_tmk]: https://github.com/DavidMcEwan/tmk_keyboard/tree/master/keyboard/mcdox
|
||||
|
||||
|
||||
|
||||
|
|
@ -278,4 +293,4 @@ Coding Style
|
|||
|
||||
Other Keyboard Firmware Projects
|
||||
------------------
|
||||
See [doc/other_projects.md](doc/other_projects.md).
|
||||
You can learn a lot about keyboard firmware from these. See [doc/other_projects.md](doc/other_projects.md).
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
#include "backlight.h"
|
||||
#include "suspend_avr.h"
|
||||
#include "suspend.h"
|
||||
#include "timer.h"
|
||||
#ifdef PROTOCOL_LUFA
|
||||
#include "lufa.h"
|
||||
#endif
|
||||
|
|
@ -52,11 +53,13 @@ void suspend_idle(uint8_t time)
|
|||
* WDTO_4S
|
||||
* WDTO_8S
|
||||
*/
|
||||
void suspend_power_down(uint8_t wdto)
|
||||
static uint8_t wdt_timeout = 0;
|
||||
static void power_down(uint8_t wdto)
|
||||
{
|
||||
#ifdef PROTOCOL_LUFA
|
||||
if (USB_DeviceState == DEVICE_STATE_Configured) return;
|
||||
#endif
|
||||
wdt_timeout = wdto;
|
||||
|
||||
// Watchdog Interrupt Mode
|
||||
wdt_intr_enable(wdto);
|
||||
|
|
@ -67,7 +70,6 @@ void suspend_power_down(uint8_t wdto)
|
|||
// - prescale clock
|
||||
// - BOD disable
|
||||
// - Power Reduction Register PRR
|
||||
|
||||
set_sleep_mode(SLEEP_MODE_PWR_DOWN);
|
||||
sleep_enable();
|
||||
sei();
|
||||
|
|
@ -78,6 +80,11 @@ void suspend_power_down(uint8_t wdto)
|
|||
wdt_disable();
|
||||
}
|
||||
|
||||
void suspend_power_down(void)
|
||||
{
|
||||
power_down(WDTO_15MS);
|
||||
}
|
||||
|
||||
bool suspend_wakeup_condition(void)
|
||||
{
|
||||
matrix_power_up();
|
||||
|
|
@ -103,15 +110,13 @@ void suspend_wakeup_init(void)
|
|||
/* watchdog timeout */
|
||||
ISR(WDT_vect)
|
||||
{
|
||||
/* wakeup from MCU sleep mode */
|
||||
/*
|
||||
// blink LED
|
||||
static uint8_t led_state = 0;
|
||||
static uint8_t led_count = 0;
|
||||
led_count++;
|
||||
if ((led_count & 0x07) == 0) {
|
||||
led_set((led_state ^= (1<<USB_LED_CAPS_LOCK)));
|
||||
// compensate timer for sleep
|
||||
switch (wdt_timeout) {
|
||||
case WDTO_15MS:
|
||||
timer_count += 15 + 2; // WDTO_15MS + 2(from observation)
|
||||
break;
|
||||
default:
|
||||
;
|
||||
}
|
||||
*/
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -303,7 +303,7 @@ static bool command_common(uint8_t code)
|
|||
#endif
|
||||
" " STR(BOOTLOADER_SIZE) "\n");
|
||||
|
||||
print("GCC: " STR(__GNUC__) "." STR(__GNUC_MINOR__) "." STR(__GNUC_PATCHLEVEL__)
|
||||
print("GCC: " STR(__GNUC__) "." STR(__GNUC_MINOR__) "." STR(__GNUC_PATCHLEVEL__)
|
||||
" AVR-LIBC: " __AVR_LIBC_VERSION_STRING__
|
||||
" AVR_ARCH: avr" STR(__AVR_ARCH__) "\n");
|
||||
break;
|
||||
|
|
@ -542,12 +542,12 @@ static void mousekey_console_help(void)
|
|||
print("4: select mk_time_to_max\n");
|
||||
print("5: select mk_wheel_max_speed\n");
|
||||
print("6: select mk_wheel_time_to_max\n");
|
||||
print("p: print prameters\n");
|
||||
print("p: print parameters\n");
|
||||
print("d: set default values\n");
|
||||
print("up: increase prameters(+1)\n");
|
||||
print("down: decrease prameters(-1)\n");
|
||||
print("pgup: increase prameters(+10)\n");
|
||||
print("pgdown: decrease prameters(-10)\n");
|
||||
print("up: increase parameters(+1)\n");
|
||||
print("down: decrease parameters(-1)\n");
|
||||
print("pgup: increase parameters(+10)\n");
|
||||
print("pgdown: decrease parameters(-10)\n");
|
||||
print("\nspeed = delta * max_speed * (repeat / time_to_max)\n");
|
||||
print("where delta: cursor="); pdec(MOUSEKEY_MOVE_DELTA);
|
||||
print(", wheel="); pdec(MOUSEKEY_WHEEL_DELTA); print("\n");
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
|
||||
void suspend_idle(uint8_t timeout);
|
||||
void suspend_power_down(uint8_t timeout);
|
||||
void suspend_power_down(void);
|
||||
bool suspend_wakeup_condition(void);
|
||||
void suspend_wakeup_init(void);
|
||||
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ modifiers except for GUI key(Windows/Command).
|
|||
And most ADB keyboard has no diodes in its matrix so they are not NKRO,
|
||||
though ADB protocol itself supports it. See protocol/adb.c for more info.
|
||||
|
||||
If keyobard has ISO layout you need to use ISO keymap with `make KEYMAP=iso`. With ANSI
|
||||
If keyboard has ISO layout you need to use ISO keymap with `make KEYMAP=iso`. With ANSI
|
||||
keymap you will suffer from swapped keys problem.
|
||||
|
||||
https://github.com/tmk/tmk_keyboard/issues/35
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ KC_F12 45 Keyboard F12
|
|||
KC_PSCREEN KC_PSCR 46 Keyboard PrintScreen1
|
||||
KC_SCKLOCK KC_SLCK 47 Keyboard Scroll Lock11
|
||||
KC_PAUSE KC_PAUS 48 Keyboard Pause1
|
||||
KC_INSERT KC_INT 49 Keyboard Insert1
|
||||
KC_INSERT KC_INS 49 Keyboard Insert1
|
||||
KC_HOME 4A Keyboard Home1
|
||||
KC_PGUP 4B Keyboard PageUp1
|
||||
KC_DELETE KC_DELETE 4C Keyboard Delete Forward
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ Other Keyboard Firmware Projects
|
|||
## ErgoDox[Ergo][Split][USB][AVR]
|
||||
- <http://geekhack.org/index.php?topic=22780.0>
|
||||
- <https://github.com/benblazak/ergodox-firmware>
|
||||
- <https://github.com/cub-uanic/tmk_keyboard>
|
||||
|
||||
## Suka's keyboard collection[Ergo][Split][3DPrinting][USB][AVR]
|
||||
- <http://deskthority.net/workshop-f7/my-diy-keyboard-collection-or-how-i-became-a-kb-geek-t2534.html>
|
||||
|
|
|
|||
117
keyboard/ghost_squid/Makefile.lufa
Normal file
117
keyboard/ghost_squid/Makefile.lufa
Normal file
|
|
@ -0,0 +1,117 @@
|
|||
#----------------------------------------------------------------------------
|
||||
# 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 = ghostsquid_lufa
|
||||
|
||||
# Directory common source filess exist
|
||||
TOP_DIR = ../..
|
||||
|
||||
# Directory keyboard dependent files exist
|
||||
TARGET_DIR = .
|
||||
|
||||
# List C source files here. (C dependencies are automatically generated.)
|
||||
SRC = keymap.c \
|
||||
matrix.c \
|
||||
led.c
|
||||
|
||||
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)
|
||||
|
||||
|
||||
# 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
|
||||
|
||||
|
||||
# Boot Section Size in bytes
|
||||
# Teensy halfKay 512
|
||||
# Atmel DFU loader 4096
|
||||
# LUFA bootloader 4096
|
||||
OPT_DEFS += -DBOOTLOADER_SIZE=4096
|
||||
|
||||
# Search Path
|
||||
VPATH += $(TARGET_DIR)
|
||||
VPATH += $(TOP_DIR)
|
||||
|
||||
include $(TOP_DIR)/protocol/lufa.mk
|
||||
include $(TOP_DIR)/common.mk
|
||||
include $(TOP_DIR)/rules.mk
|
||||
20
keyboard/ghost_squid/README.md
Normal file
20
keyboard/ghost_squid/README.md
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
The Ghost Squid controller
|
||||
==========================
|
||||
Custom controller for the Cooler Master QuickFire XT keyboard designed by bpiphany.
|
||||
|
||||
*Note that this is not the official firmware*
|
||||
|
||||
Build
|
||||
-----
|
||||
Move to this directory then just run `make` like:
|
||||
|
||||
$ make -f Makefile.lufa
|
||||
|
||||
At the moment only the LUFA stack is supported.
|
||||
|
||||
|
||||
Bootloader
|
||||
---------
|
||||
To enter bootloader by hardware use a magnet above the controller before connecting the usb cable.
|
||||
|
||||
It is still possible to use Boot Magic and Command (LSFT+RSFT+PAUS) to access the bootloader though.
|
||||
43
keyboard/ghost_squid/config.h
Normal file
43
keyboard/ghost_squid/config.h
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
/*
|
||||
Copyright 2014 Ralf Schmitt <ralf@bunkertor.net>
|
||||
|
||||
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 // 0x2516 (original CM XT value)
|
||||
#define PRODUCT_ID 0x001A
|
||||
#define DEVICE_VER 0x0000
|
||||
#define MANUFACTURER Cooler Master
|
||||
#define PRODUCT Cooler Master QuickFire XT
|
||||
|
||||
/* message strings */
|
||||
#define DESCRIPTION t.m.k. keyboard firmware for Cooler Master QuickFire XT
|
||||
|
||||
/* matrix size */
|
||||
#define MATRIX_ROWS 8
|
||||
#define MATRIX_COLS 18
|
||||
|
||||
/* Set 0 if need no debouncing */
|
||||
#define DEBOUNCE 5
|
||||
|
||||
/* key combination for command */
|
||||
#define IS_COMMAND() ( \
|
||||
keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \
|
||||
)
|
||||
|
||||
#endif
|
||||
102
keyboard/ghost_squid/keymap.c
Normal file
102
keyboard/ghost_squid/keymap.c
Normal file
|
|
@ -0,0 +1,102 @@
|
|||
/*
|
||||
Copyright 2014 Ralf Schmitt <ralf@bunkertor.net>
|
||||
|
||||
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 <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 "debug.h"
|
||||
#include "keymap.h"
|
||||
|
||||
/*
|
||||
Matrix col/row mapping
|
||||
|
||||
,----. ,-------------------. ,-------------------. ,-------------------. ,--------------.
|
||||
|06/6| |07/4|08/4|08/2|08/6| |15/5|11/6|12/2|12/4| |14/4|14/5|14/6|14/0| |13/5|13/7|15/7|
|
||||
`----' `-------------------' `-------------------' `-------------------' `--------------'
|
||||
,-------------------------------------------------------------------------. ,--------------. ,-------------------.
|
||||
|06/4|06/5|07/5|08/5|09/5|09/4|10/4|10/5|11/5|12/5|05/5|05/4|11/4| 14/2| |17/4|02/4|04/4| |16/1|17/1|04/1|04/0|
|
||||
|-------------------------------------------------------------------------| |--------------| |-------------------|
|
||||
|06/2 |06/7|07/7|08/7|09/7|09/2|10/2|10/7|11/7|12/7|05/7|05/2|11/2| 14/3| |16/4|02/5|04/5| |16/7|17/7|04/7| |
|
||||
|-------------------------------------------------------------------------| '--------------' |-------------- 02/7|
|
||||
|02/7 |06/3|07/3|08/3|09/3|09/6|10/6|10/3|11/3|12/3|05/3|05/6| 14/1| |16/2|17/2|04/2| |
|
||||
|-------------------------------------------------------------------------| ,----. |-------------------|
|
||||
|01/2 |06/1|07/1|08/1|09/1|09/0|10/0|10/1|11/1|12/1|05/0| 01/3| |02/6| |16/3|17/3|04/3| |
|
||||
|-------------------------------------------------------------------------| ,--------------. |-------------- 02/3|
|
||||
|15/4|03/2|13/6| 16/6 |13/0|0/3|12/0|15/1| |02/0|16/0|17/0| | 17/6 |04/6| |
|
||||
`-------------------------------------------------------------------------' `--------------' `-------------------'
|
||||
*/
|
||||
|
||||
#define KEYMAP( \
|
||||
KG6, KH4, KI4, KI2, KI6, KP5, KL6, KM2, KM4, KO4, KO5, KO6, KO0, KN5, KN7, KP7, \
|
||||
KG4, KG5, KH5, KI5, KJ5, KJ4, KK4, KK5, KL5, KM5, KF5, KF4, KL4, KO2, KR4, KC4, KE4, KQ1, KR1, KE1, KE0, \
|
||||
KG2, KG7, KH7, KI7, KJ7, KJ2, KK2, KK7, KL7, KM7, KF7, KF2, KL2, KO3, KQ4, KC5, KE5, KQ7, KR7, KE7, KC7, \
|
||||
KH2, KG3, KH3, KI3, KJ3, KJ6, KK6, KK3, KL3, KM3, KF3, KF6, KO1, KQ2, KR2, KE2, \
|
||||
KB2, KH6, KG1, KH1, KI1, KJ1, KJ0, KK0, KK1, KL1, KM1, KF0, KB3, KC6, KQ3, KR3, KE3, KC3, \
|
||||
KP4, KD2, KN6, KQ6, KN0, KA3, KM0, KP1, KC0, KQ0, KR0, KR6, KE6 \
|
||||
) { \
|
||||
/* 0 1 2 3 4 5 6 7 */ \
|
||||
/* A 0 */ {KC_NO, KC_NO, KC_NO, KC_##KA3, KC_NO, KC_NO, KC_NO, KC_NO },\
|
||||
/* B 1 */ {KC_NO, KC_NO, KC_##KB2, KC_##KB3, KC_NO, KC_NO, KC_NO, KC_NO },\
|
||||
/* C 2 */ {KC_##KC0, KC_NO, KC_NO, KC_##KC3, KC_##KC4, KC_##KC5, KC_##KC6, KC_##KC7},\
|
||||
/* D 3 */ {KC_NO, KC_NO, KC_##KD2, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO },\
|
||||
/* E 4 */ {KC_##KE0, KC_##KE1, KC_##KE2, KC_##KE3, KC_##KE4, KC_##KE5, KC_##KE6, KC_##KE7},\
|
||||
/* F 5 */ {KC_##KF0, KC_NO, KC_##KF2, KC_##KF3, KC_##KF4, KC_##KF5, KC_##KF6, KC_##KF7},\
|
||||
/* G 6 */ {KC_NO, KC_##KG1, KC_##KG2, KC_##KG3, KC_##KG4, KC_##KG5, KC_##KG6, KC_##KG7},\
|
||||
/* H 7 */ {KC_NO, KC_##KH1, KC_##KH2, KC_##KH3, KC_##KH4, KC_##KH5, KC_##KH6, KC_##KH7},\
|
||||
/* I 8 */ {KC_NO, KC_##KI1, KC_##KI2, KC_##KI3, KC_##KI4, KC_##KI5, KC_##KI6, KC_##KI7},\
|
||||
/* J 9 */ {KC_##KJ0, KC_##KJ1, KC_##KJ2, KC_##KJ3, KC_##KJ4, KC_##KJ5, KC_##KJ6, KC_##KJ7},\
|
||||
/* K 10 */ {KC_##KK0, KC_##KK1, KC_##KK2, KC_##KK3, KC_##KK4, KC_##KK5, KC_##KK6, KC_##KK7},\
|
||||
/* L 11 */ {KC_NO, KC_##KL1, KC_##KL2, KC_##KL3, KC_##KL4, KC_##KL5, KC_##KL6, KC_##KL7},\
|
||||
/* M 12 */ {KC_##KM0, KC_##KM1, KC_##KM2, KC_##KM3, KC_##KM4, KC_##KM5, KC_NO, KC_##KM7},\
|
||||
/* N 13 */ {KC_##KN0, KC_NO, KC_NO, KC_NO, KC_NO, KC_##KN5, KC_##KN6, KC_##KN7},\
|
||||
/* O 14 */ {KC_##KO0, KC_##KO1, KC_##KO2, KC_##KO3, KC_##KO4, KC_##KO5, KC_##KO6, KC_NO },\
|
||||
/* P 15 */ {KC_NO, KC_##KP1, KC_NO, KC_NO, KC_##KP4, KC_##KP5, KC_NO, KC_##KP7},\
|
||||
/* Q 16 */ {KC_##KQ0, KC_##KQ1, KC_##KQ2, KC_##KQ3, KC_##KQ4, KC_NO, KC_##KQ6, KC_##KQ7},\
|
||||
/* R 17 */ {KC_##KR0, KC_##KR1, KC_##KR2, KC_##KR3, KC_##KR4, KC_NO, KC_##KR6, KC_##KR7} \
|
||||
}
|
||||
|
||||
#include "keymap_ansi.h"
|
||||
|
||||
#define KEYMAPS_SIZE (sizeof(keymaps) / sizeof(keymaps[0]))
|
||||
#define FN_ACTIONS_SIZE (sizeof(fn_actions) / sizeof(fn_actions[0]))
|
||||
|
||||
/* translates key to keycode */
|
||||
uint8_t keymap_key_to_keycode(uint8_t layer, keypos_t key)
|
||||
{
|
||||
if (layer < KEYMAPS_SIZE) {
|
||||
return pgm_read_byte(&keymaps[(layer)][(key.col)][(key.row)]);
|
||||
} else {
|
||||
return pgm_read_byte(&keymaps[0][(key.col)][(key.row)]);
|
||||
}
|
||||
}
|
||||
|
||||
/* translates Fn keycode to action */
|
||||
action_t keymap_fn_to_action(uint8_t keycode)
|
||||
{
|
||||
action_t action;
|
||||
if (FN_INDEX(keycode) < FN_ACTIONS_SIZE) {
|
||||
action.code = pgm_read_word(&fn_actions[FN_INDEX(keycode)]);
|
||||
} else {
|
||||
action.code = ACTION_NO;
|
||||
}
|
||||
return action;
|
||||
}
|
||||
23
keyboard/ghost_squid/keymap_ansi.h
Normal file
23
keyboard/ghost_squid/keymap_ansi.h
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
|
||||
static const uint8_t PROGMEM keymaps[][MATRIX_COLS][MATRIX_ROWS] = {
|
||||
/* Layer 0: Standard ANSI layer */
|
||||
KEYMAP(\
|
||||
ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR,SLCK,PAUS, \
|
||||
GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS, EQL,BSPC, INS, HOME,PGUP, NLCK,PSLS,PAST,PMNS, \
|
||||
TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,BSLS, DEL, END, PGDN, P7, P8, P9, PPLS, \
|
||||
CAPS,A, S, D, F, G, H, J, K, L, SCLN,QUOT, ENT, P4, P5, P6, \
|
||||
LSFT,NUBS,Z, X, C, V, B, N, M, COMM,DOT, SLSH, RSFT, UP, P1, P2, P3, PENT, \
|
||||
LCTL,LGUI,LALT, SPC, RALT,RGUI, FN0,RCTL, LEFT,DOWN,RGHT, P0, PDOT), \
|
||||
/* Layer 1: Function layer */
|
||||
KEYMAP(\
|
||||
CALC,MYCM,WSCH,WHOM,MAIL,VOLD,VOLU,MSEL,MSTP,MPLY,MPRV,MNXT,TRNS, WAKE, PWR,SLEP, \
|
||||
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,TRNS, TRNS, TRNS, TRNS,TRNS,TRNS,TRNS, \
|
||||
TRNS,TRNS,TRNS, TRNS, TRNS,TRNS,TRNS,TRNS, TRNS,TRNS,TRNS, TRNS,TRNS)
|
||||
};
|
||||
|
||||
static const uint16_t PROGMEM fn_actions[] = {
|
||||
[0] = ACTION_LAYER_MOMENTARY(1)
|
||||
};
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright 2011 Jun Wako <wakojun@gmail.com>
|
||||
Copyright 2014 Ralf Schmitt <ralf@bunkertor.net>
|
||||
|
||||
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
|
||||
|
|
@ -19,15 +19,42 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
#include "stdint.h"
|
||||
#include "led.h"
|
||||
|
||||
|
||||
/* HHKB has no LEDs */
|
||||
/* LED pin configuration
|
||||
*
|
||||
* Scroll Lock PB7
|
||||
* CAPS PC6
|
||||
* NUMLOCK PC5
|
||||
*
|
||||
*/
|
||||
void led_set(uint8_t usb_led)
|
||||
{
|
||||
if (usb_led & (1<<USB_LED_CAPS_LOCK)) {
|
||||
DDRD |= (1<<6);
|
||||
PORTD |= (1<<6);
|
||||
} else {
|
||||
DDRD |= (1<<6);
|
||||
PORTD &= ~(1<<6);
|
||||
DDRB |= (1<<7);
|
||||
DDRC |= (1<<5) | (1<<6);
|
||||
|
||||
if (usb_led & (1<<USB_LED_CAPS_LOCK))
|
||||
{
|
||||
PORTC &= ~(1<<6);
|
||||
}
|
||||
else
|
||||
{
|
||||
PORTC |= (1<<6);
|
||||
}
|
||||
|
||||
if (usb_led & (1<<USB_LED_NUM_LOCK))
|
||||
{
|
||||
PORTC &= ~(1<<5);
|
||||
}
|
||||
else
|
||||
{
|
||||
PORTC |= (1<<5);
|
||||
}
|
||||
|
||||
if (usb_led & (1<<USB_LED_SCROLL_LOCK))
|
||||
{
|
||||
PORTB &= ~(1<<7);
|
||||
}
|
||||
else
|
||||
{
|
||||
PORTB |= (1<<7);
|
||||
}
|
||||
}
|
||||
237
keyboard/ghost_squid/matrix.c
Normal file
237
keyboard/ghost_squid/matrix.c
Normal file
|
|
@ -0,0 +1,237 @@
|
|||
/*
|
||||
Copyright 2014 Ralf Schmitt <ralf@bunkertor.net>
|
||||
|
||||
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 <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 0
|
||||
#endif
|
||||
static uint8_t debouncing = DEBOUNCE;
|
||||
|
||||
static matrix_row_t matrix[MATRIX_ROWS];
|
||||
static matrix_row_t matrix_debouncing[MATRIX_ROWS];
|
||||
|
||||
static uint8_t read_rows(void);
|
||||
static void init_rows(void);
|
||||
static void unselect_cols(void);
|
||||
static void select_col(uint8_t col);
|
||||
|
||||
inline uint8_t matrix_rows(void)
|
||||
{
|
||||
return MATRIX_ROWS;
|
||||
}
|
||||
|
||||
inline uint8_t matrix_cols(void)
|
||||
{
|
||||
return MATRIX_COLS;
|
||||
}
|
||||
|
||||
void matrix_init(void)
|
||||
{
|
||||
unselect_cols();
|
||||
init_rows();
|
||||
for (uint8_t i=0; i < MATRIX_ROWS; i++) {
|
||||
matrix[i] = 0;
|
||||
matrix_debouncing[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t matrix_scan(void)
|
||||
{
|
||||
for (uint8_t col = 0; col < MATRIX_COLS; col++) {
|
||||
select_col(col);
|
||||
_delay_us(3);
|
||||
uint8_t rows = read_rows();
|
||||
for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
|
||||
bool prev_bit = matrix_debouncing[row] & ((matrix_row_t)1<<col);
|
||||
bool curr_bit = rows & (1<<row);
|
||||
if (prev_bit != curr_bit) {
|
||||
matrix_debouncing[row] ^= ((matrix_row_t)1<<col);
|
||||
debouncing = DEBOUNCE;
|
||||
}
|
||||
}
|
||||
unselect_cols();
|
||||
}
|
||||
|
||||
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++) {
|
||||
xprintf("%02X: %032lb\n", row, bitrev32(matrix_get_row(row)));
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t matrix_key_count(void)
|
||||
{
|
||||
uint8_t count = 0;
|
||||
for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
|
||||
count += bitpop32(matrix[i]);
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
/* Row pin configuration
|
||||
*
|
||||
* row: 0 1 2 3 4 5 6 7
|
||||
* pin: PB1 PC2 PB6 PB4 PB3 PB5 PB0 PB2
|
||||
*
|
||||
*/
|
||||
static void init_rows(void)
|
||||
{
|
||||
DDRC &= ~0b00000100;
|
||||
DDRB &= ~0b01111111;
|
||||
PORTC |= 0b00000100;
|
||||
PORTB |= 0b01111111;
|
||||
}
|
||||
|
||||
static uint8_t read_rows(void)
|
||||
{
|
||||
return (PINB&(1<<1) ? 0 : (1<<0)) |
|
||||
(PINC&(1<<2) ? 0 : (1<<1)) |
|
||||
(PINB&(1<<6) ? 0 : (1<<2)) |
|
||||
(PINB&(1<<4) ? 0 : (1<<3)) |
|
||||
(PINB&(1<<3) ? 0 : (1<<4)) |
|
||||
(PINB&(1<<5) ? 0 : (1<<5)) |
|
||||
(PINB&(1<<0) ? 0 : (1<<6)) |
|
||||
(PINB&(1<<2) ? 0 : (1<<7));
|
||||
}
|
||||
|
||||
/* These columns uses two 74HC42 4 to 10 bit demultiplexers (low active).
|
||||
*
|
||||
* COL PD6 PD5 PD4 PD3 PD2 PD1
|
||||
* 10 1 1 0 0 0 0
|
||||
* 15 1 1 0 0 0 1
|
||||
* 8 1 1 0 0 1 0
|
||||
* 14 1 1 0 1 0 0
|
||||
* 6 1 1 0 1 0 1
|
||||
* 13 1 1 0 1 1 0
|
||||
* 12 1 1 1 0 0 0
|
||||
* 9 1 1 1 0 1 0
|
||||
* 11 1 1 1 1 0 0
|
||||
* 7 1 1 1 1 1 0
|
||||
*
|
||||
* COL PD1 PD2 PD3 PD4 PD5 PD6
|
||||
* 3 1 1 0 0 0 1
|
||||
* 4 1 1 0 0 1 0
|
||||
* 17 1 1 0 1 0 0
|
||||
* 16 1 1 0 1 1 0
|
||||
* 0 1 1 1 0 0 1
|
||||
* 5 1 1 1 0 1 0
|
||||
* 2 1 1 1 1 0 0
|
||||
* 1 1 1 1 1 1 0
|
||||
*/
|
||||
static void unselect_cols(void)
|
||||
{
|
||||
DDRD |= 0b01111111;
|
||||
PORTD &= ~0b01111111;
|
||||
}
|
||||
|
||||
static void select_col(uint8_t col)
|
||||
{
|
||||
switch (col) {
|
||||
case 0:
|
||||
PORTD |= (1<<6) | (1<<3) | (1<<2) | (1<<1);
|
||||
break;
|
||||
case 1:
|
||||
PORTD |= (1<<5) | (1<<4) | (1<<3) | (1<<2) | (1<<1);
|
||||
break;
|
||||
case 2:
|
||||
PORTD |= (1<<4) | (1<<3) | (1<<2) | (1<<1);
|
||||
break;
|
||||
case 3:
|
||||
PORTD |= (1<<6) | (1<<2) | (1<<1);
|
||||
break;
|
||||
case 4:
|
||||
PORTD |= (1<<5) | (1<<2) | (1<<1);
|
||||
break;
|
||||
case 5:
|
||||
PORTD |= (1<<5) | (1<<3) | (1<<2) | (1<<1);
|
||||
break;
|
||||
case 6:
|
||||
PORTD |= (1<<6) | (1<<5) | (1<<3) | (1<<1);
|
||||
break;
|
||||
case 7:
|
||||
PORTD |= (1<<6) | (1<<5) | (1<<4) | (1<<3) | (1<<2);
|
||||
break;
|
||||
case 8:
|
||||
PORTD |= (1<<6) | (1<<5) | (1<<2);
|
||||
break;
|
||||
case 9:
|
||||
PORTD |= (1<<6) | (1<<5) | (1<<4) | (1<<2);
|
||||
break;
|
||||
case 10:
|
||||
PORTD |= (1<<6) | (1<<5);
|
||||
break;
|
||||
case 11:
|
||||
PORTD |= (1<<6) | (1<<5) | (1<<4) | (1<<3);
|
||||
break;
|
||||
case 12:
|
||||
PORTD |= (1<<6) | (1<<5) | (1<<4);
|
||||
break;
|
||||
case 13:
|
||||
PORTD |= (1<<6) | (1<<5) | (1<<3) | (1<<2);
|
||||
break;
|
||||
case 14:
|
||||
PORTD |= (1<<6) | (1<<5) | (1<<3);
|
||||
break;
|
||||
case 15:
|
||||
PORTD |= (1<<6) | (1<<5) | (1<<1);
|
||||
break;
|
||||
case 16:
|
||||
PORTD |= (1<<5) | (1<<4) | (1<<2) | (1<<1);
|
||||
break;
|
||||
case 17:
|
||||
PORTD |= (1<<4) | (1<<2) | (1<<1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -39,7 +39,7 @@
|
|||
#----------------------------------------------------------------------------
|
||||
|
||||
# Target file name (without extension).
|
||||
TARGET = hhkb_lufa
|
||||
TARGET = hhkb_rn42
|
||||
|
||||
# Directory common source filess exist
|
||||
TOP_DIR = ../..
|
||||
|
|
@ -53,19 +53,10 @@ SRC += keymap_common.c \
|
|||
matrix.c \
|
||||
led.c
|
||||
|
||||
ifdef KEYMAP
|
||||
SRC := keymap_$(KEYMAP).c $(SRC)
|
||||
else
|
||||
SRC := keymap_hasu.c $(SRC)
|
||||
endif
|
||||
|
||||
CONFIG_H = config.h
|
||||
CONFIG_H = config_rn42.h
|
||||
|
||||
|
||||
# MCU name
|
||||
# PJRC Teensy++ 2.0
|
||||
#MCU = at90usb1286
|
||||
# TMK Alt Controller or PJRC Teensy 2.0
|
||||
MCU = atmega32u4
|
||||
|
||||
# Processor frequency.
|
||||
|
|
@ -117,19 +108,41 @@ OPT_DEFS += -DBOOTLOADER_SIZE=4096
|
|||
# Build Options
|
||||
# comment out to disable the options.
|
||||
#
|
||||
BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration
|
||||
#BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration
|
||||
MOUSEKEY_ENABLE = yes # Mouse keys
|
||||
EXTRAKEY_ENABLE = yes # Audio control and System control
|
||||
#CONSOLE_ENABLE = yes # Console for debug
|
||||
CONSOLE_ENABLE = yes # Console for debug
|
||||
COMMAND_ENABLE = yes # Commands for debug and configuration
|
||||
NKRO_ENABLE = yes # USB Nkey Rollover
|
||||
KEYMAP_SECTION_ENABLE = yes # fixed address keymap for keymap editor
|
||||
#NKRO_ENABLE = yes # USB Nkey Rollover
|
||||
#KEYMAP_SECTION_ENABLE = yes # fixed address keymap for keymap editor
|
||||
#HHKB_JP = yes # HHKB JP support
|
||||
|
||||
|
||||
#
|
||||
# Keymap file
|
||||
#
|
||||
ifdef KEYMAP
|
||||
SRC := keymap_$(KEYMAP).c $(SRC)
|
||||
else
|
||||
ifdef HHKB_JP
|
||||
SRC := keymap_jp.c $(SRC)
|
||||
else
|
||||
SRC := keymap_hhkb.c $(SRC)
|
||||
endif
|
||||
endif
|
||||
|
||||
|
||||
ifneq (, $(or $(findstring keymap_jp.c, $(SRC)), $(findstring yes, $(HHKB_JP))))
|
||||
OPT_DEFS += -DHHKB_JP
|
||||
endif
|
||||
|
||||
|
||||
# Search Path
|
||||
VPATH += $(TARGET_DIR)
|
||||
VPATH += $(TOP_DIR)
|
||||
|
||||
include rn42.mk
|
||||
include $(TOP_DIR)/protocol.mk
|
||||
include $(TOP_DIR)/protocol/lufa.mk
|
||||
include $(TOP_DIR)/common.mk
|
||||
include $(TOP_DIR)/rules.mk
|
||||
|
|
@ -138,4 +151,5 @@ debug-on: EXTRAFLAGS += -DDEBUG -DDEBUG_ACTION
|
|||
debug-on: all
|
||||
|
||||
debug-off: EXTRAFLAGS += -DNO_DEBUG -DNO_PRINT
|
||||
debug-off: OPT_DEFS := $(filter-out -DCONSOLE_ENABLE,$(OPT_DEFS))
|
||||
debug-off: all
|
||||
|
|
@ -10,11 +10,17 @@ See [this thread][AltController] in geekhack.org.
|
|||
[AltController]: http://geekhack.org/index.php?topic=12047.0
|
||||
|
||||
|
||||
## Update
|
||||
* Bluetooth module RN-42 is supported.(2015/01)
|
||||
* V-USB and iWRAP are no longer supported now, but still it'll works with a little fix. See not_supported directory.(2015/01)
|
||||
|
||||
|
||||
##Features
|
||||
* Customizable keymap
|
||||
* More keymap layers(more Fn keys)
|
||||
* Mouse keys
|
||||
* USB NKRO
|
||||
* Bluetooth(RN-42)
|
||||
|
||||
See README of [tmk_keyboard] for more.
|
||||
|
||||
|
|
@ -50,8 +56,9 @@ If you use other than **TMK Alt Controller Board** set proper `MCU`, `BOOTLOADER
|
|||
### Build
|
||||
Several version of keymap are available in advance but you are recommended to define your favorite layout yourself. Just `make` with `KEYMAP` option like:
|
||||
|
||||
$ make KEYMAP=[hasu|hhkb|spacefn|<name>]
|
||||
$ make -f Makefile.jp KEYMAP=[jp|<name>] # for HHKB JP
|
||||
$ make -f Makefile.<jp|pjrc|rn42> KEYMAP=(hasu|hhkb|spacefn|<name>)
|
||||
|
||||
You can omit `-f` option when you use `Makefile`. `Makefile` is used for **Pro2 and Pro**, `Makefile.jp` fits for **JP** model and `Makefile.rn42` supports Bluetooth module **RN-42**. `Makefile.pjrc` uses **PJRC** as output protocol instead of **LUFA**.
|
||||
|
||||
|
||||
### Program
|
||||
|
|
@ -59,13 +66,11 @@ First, push reset button on board to start bootloader.
|
|||
|
||||
This command programs the controller with [dfu-programmer] if the tool is installed and configured properly.
|
||||
|
||||
$ make dfu
|
||||
$ make -f Makefile.jp dfu # for HHKB JP
|
||||
$ make -f Makefile.<variant> KEYMAP=<name> dfu
|
||||
|
||||
Or you can also use [FLIP] command to program. Also the tool should be installed and configured properly. FLIP GUI application is also available.
|
||||
|
||||
$ make flip
|
||||
$ make -f Makefile.jp flip # for HHKB JP
|
||||
$ make -f Makefile.<variant> KEYMAP=<name> flip
|
||||
|
||||
Use [Teensy Loader] if your controller is Teensy/Teensy++.
|
||||
|
||||
|
|
|
|||
|
|
@ -41,17 +41,32 @@ static inline void KEY_UNABLE(void) { (PORTB |= (1<<6)); }
|
|||
static inline bool KEY_STATE(void) { return (PIND & (1<<7)); }
|
||||
static inline void KEY_PREV_ON(void) { (PORTB |= (1<<7)); }
|
||||
static inline void KEY_PREV_OFF(void) { (PORTB &= ~(1<<7)); }
|
||||
#ifdef HHKB_POWER_SAVING
|
||||
static inline void KEY_POWER_ON(void) {
|
||||
DDRB = 0xFF; PORTB = 0x40; // change pins output
|
||||
DDRD |= (1<<4); PORTD |= (1<<4); // MOS FET switch on
|
||||
/* Without this wait you will miss or get false key events. */
|
||||
_delay_ms(5); // wait for powering up
|
||||
}
|
||||
static inline void KEY_POWER_OFF(void) {
|
||||
/* input with pull-up consumes less than without it when pin is open. */
|
||||
DDRB = 0x00; PORTB = 0xFF; // change pins input with pull-up
|
||||
DDRD |= (1<<4); PORTD &= ~(1<<4); // MOS FET switch off
|
||||
}
|
||||
static inline bool KEY_POWER_STATE(void) { return PORTD & (1<<4); }
|
||||
#else
|
||||
static inline void KEY_POWER_ON(void) {}
|
||||
static inline void KEY_POWER_OFF(void) {}
|
||||
static inline bool KEY_POWER_STATE(void) { return true; }
|
||||
#endif
|
||||
static inline void KEY_INIT(void)
|
||||
{
|
||||
/* row,col,prev: output */
|
||||
DDRB = 0xFF;
|
||||
PORTB = 0x00;
|
||||
PORTB = 0x40; // unable
|
||||
/* key: input with pull-up */
|
||||
DDRD &= ~0x80;
|
||||
PORTD |= 0x80;
|
||||
/* keyswitch board power on */
|
||||
DDRD |= (1<<4);
|
||||
PORTD |= (1<<4);
|
||||
PORTD |= 0x80;
|
||||
#ifdef HHKB_JP
|
||||
/* row extention for HHKB JP */
|
||||
DDRC |= (1<<6|1<<7);
|
||||
|
|
@ -59,6 +74,8 @@ static inline void KEY_INIT(void)
|
|||
#endif
|
||||
KEY_UNABLE();
|
||||
KEY_PREV_OFF();
|
||||
|
||||
KEY_POWER_OFF();
|
||||
}
|
||||
static inline void KEY_SELECT(uint8_t ROW, uint8_t COL)
|
||||
{
|
||||
|
|
@ -98,6 +115,7 @@ static inline void KEY_SELECT(uint8_t ROW, uint8_t COL)
|
|||
#define KEY_PREV_OFF() (PORTE &= ~(1<<7))
|
||||
#define KEY_POWER_ON()
|
||||
#define KEY_POWER_OFF()
|
||||
#define KEY_POWER_STATE() true
|
||||
|
||||
|
||||
#else
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS] PROGMEM = {
|
|||
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,FN6, \
|
||||
FN7, Z, X, C, V, B, N, M, COMM,DOT, FN2, RSFT,FN1, \
|
||||
LGUI,LALT, FN4, FN5, FN5),
|
||||
LGUI,LALT, FN4, FN5, RGUI),
|
||||
|
||||
/* Layer 1: HHKB mode[HHKB Fn]
|
||||
* ,-----------------------------------------------------------.
|
||||
|
|
@ -47,7 +47,7 @@ const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS] PROGMEM = {
|
|||
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,ENT, \
|
||||
LSFT,NO, NO, NO, NO, NO, PPLS,PMNS,END, PGDN,DOWN,RSFT,TRNS, \
|
||||
LGUI,LALT, SPC, RALT,RGUI),
|
||||
LGUI,LALT, TRNS, RALT,RGUI),
|
||||
|
||||
/* Layer 2: Vi mode[Slash]
|
||||
* ,-----------------------------------------------------------.
|
||||
|
|
@ -66,7 +66,7 @@ const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS] PROGMEM = {
|
|||
KEYMAP(GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, INS, 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, TRNS,RSFT,NO, \
|
||||
LSFT,NO, NO, NO, NO, NO, HOME,PGDN,PGUP,END, FN2, RSFT,TRNS, \
|
||||
LGUI,LALT, SPC, RALT,RGUI),
|
||||
|
||||
/* Layer 3: Mouse mode(IJKL)[Semicolon]
|
||||
|
|
@ -81,16 +81,16 @@ const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS] PROGMEM = {
|
|||
* `-----------------------------------------------------------'
|
||||
* |Gui |Alt | Mb1 |Fn |Fn |
|
||||
* `--------------------------------------------'
|
||||
* Mc: Mouse Cursor / Mb: Mouse Button / Mw: Mouse Wheel8
|
||||
* Mc: Mouse Cursor / Mb: Mouse Button / Mw: Mouse Wheel
|
||||
*/
|
||||
[3] = \
|
||||
KEYMAP(GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, INS, DEL, \
|
||||
FN8, NO, NO, NO, NO, NO, WH_L,WH_D,MS_U,WH_U,WH_R,WBAK,WFWD,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,BTN4,BTN5,NO, RSFT,NO, \
|
||||
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,FN3, NO, ENT, \
|
||||
LSFT,NO, NO, NO, NO, BTN3,BTN2,BTN1,FN9, FN10,NO, RSFT,TRNS, \
|
||||
LGUI,LALT, BTN1, TRNS,TRNS),
|
||||
|
||||
/* Layer 5: Mouse mode(IJKL)[Space]
|
||||
/* Layer 4: Mouse mode(IJKL)[Space]
|
||||
* ,-----------------------------------------------------------.
|
||||
* |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Ins|Del|
|
||||
* |-----------------------------------------------------------|
|
||||
|
|
@ -102,13 +102,13 @@ const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS] PROGMEM = {
|
|||
* `-----------------------------------------------------------'
|
||||
* |Gui |Alt | Mb1 |Fn |Fn |
|
||||
* `--------------------------------------------'
|
||||
* Mc: Mouse Cursor / Mb: Mouse Button / Mw: Mouse Wheel8
|
||||
* Mc: Mouse Cursor / Mb: Mouse Button / Mw: Mouse Wheel
|
||||
*/
|
||||
[4] = \
|
||||
KEYMAP(GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, INS, DEL, \
|
||||
FN8, NO, NO, NO, NO, NO, WH_L,WH_D,MS_U,WH_U,WH_R,WBAK,WFWD,FN8, \
|
||||
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,BTN4,BTN5,NO, RSFT,NO, \
|
||||
LSFT,NO, NO, NO, NO, BTN3,BTN2,BTN1,FN9, FN10,NO, RSFT,TRNS, \
|
||||
LGUI,LALT, TRNS, TRNS,TRNS),
|
||||
|
||||
#if 0
|
||||
|
|
@ -127,9 +127,9 @@ const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS] PROGMEM = {
|
|||
* Mc: Mouse Cursor / Mb: Mouse Button / Mw: Mouse Wheel
|
||||
*/
|
||||
KEYMAP(GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, INS, DEL, \
|
||||
TAB, NO, NO, NO, NO, NO, WH_L,WH_D,WH_U,WH_R,NO, NO, NO, BSPC, \
|
||||
TAB, NO, NO, NO, NO, NO, NO, WH_D,WH_U,RGHT,NO, NO, NO, BSPC, \
|
||||
LCTL,NO, ACL0,ACL1,ACL2,NO, MS_L,MS_D,MS_U,MS_R,TRNS,QUOT,ENT, \
|
||||
LSFT,NO, NO, NO, NO, BTN3,BTN2,BTN1,BTN4,BTN5,SLSH,RSFT,NO, \
|
||||
LSFT,NO, NO, NO, NO, BTN3,BTN2,BTN1,FN9, FN10,SLSH,RSFT,NO, \
|
||||
LGUI,LALT, BTN1, RALT,TRNS),
|
||||
|
||||
/* Layer4: Mouse mode(HJKL)[Space]
|
||||
|
|
@ -147,9 +147,9 @@ const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS] PROGMEM = {
|
|||
* Mc: Mouse Cursor / Mb: Mouse Button / Mw: Mouse Wheel
|
||||
*/
|
||||
KEYMAP(GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, INS, DEL, \
|
||||
FN8, NO, NO, NO, NO, NO, WH_L,WH_D,WH_U,WH_R,NO, WBAK,WFWD,FN8, \
|
||||
FN8, NO, NO, NO, NO, NO, NO, WH_D,WH_U,RGHT,NO, FN9, FN10,FN8, \
|
||||
LCTL,NO, ACL0,ACL1,ACL2,NO, MS_L,MS_D,MS_U,MS_R,BTN1,NO, ENT, \
|
||||
LSFT,NO, NO, NO, NO, BTN3,BTN2,BTN1,BTN4,BTN5,NO, RSFT,NO, \
|
||||
LSFT,NO, NO, NO, NO, BTN3,BTN2,BTN1,FN9, FN10,NO, RSFT,NO, \
|
||||
LGUI,LALT, TRNS, RALT,RGUI),
|
||||
#endif
|
||||
#if 0
|
||||
|
|
@ -201,10 +201,12 @@ const uint16_t fn_actions[] PROGMEM = {
|
|||
[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
|
||||
[5] = ACTION_LAYER_MOMENTARY(4), // Mousekey layer(IJKL)
|
||||
[6] = ACTION_MODS_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),
|
||||
|
||||
// [x] = ACTION_LMOD_TAP_KEY(KC_LCTL, KC_BSPC), // LControl with tap Backspace
|
||||
// [x] = ACTION_LMOD_TAP_KEY(KC_LCTL, KC_ESC), // LControl with tap Esc
|
||||
|
|
|
|||
|
|
@ -27,8 +27,15 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
#include "timer.h"
|
||||
#include "matrix.h"
|
||||
#include "hhkb_avr.h"
|
||||
#include <avr/wdt.h>
|
||||
#include "suspend.h"
|
||||
#include "lufa.h"
|
||||
|
||||
|
||||
// matrix power saving
|
||||
#define MATRIX_POWER_SAVE 10000
|
||||
static uint32_t matrix_last_modified = 0;
|
||||
|
||||
// matrix state buffer(1:on, 0:off)
|
||||
static matrix_row_t *matrix;
|
||||
static matrix_row_t *matrix_prev;
|
||||
|
|
@ -72,7 +79,8 @@ uint8_t matrix_scan(void)
|
|||
matrix_prev = matrix;
|
||||
matrix = tmp;
|
||||
|
||||
KEY_POWER_ON();
|
||||
// power on
|
||||
if (!KEY_POWER_STATE()) KEY_POWER_ON();
|
||||
for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
|
||||
for (uint8_t col = 0; col < MATRIX_COLS; col++) {
|
||||
KEY_SELECT(row, col);
|
||||
|
|
@ -126,8 +134,16 @@ uint8_t matrix_scan(void)
|
|||
// This takes 25us or more to make sure KEY_STATE returns to idle state.
|
||||
_delay_us(75);
|
||||
}
|
||||
if (matrix[row] ^ matrix_prev[row]) matrix_last_modified = timer_read32();
|
||||
}
|
||||
// power off
|
||||
if (KEY_POWER_STATE() &&
|
||||
(USB_DeviceState == DEVICE_STATE_Suspended ||
|
||||
USB_DeviceState == DEVICE_STATE_Unattached ) &&
|
||||
timer_elapsed32(matrix_last_modified) > MATRIX_POWER_SAVE) {
|
||||
KEY_POWER_OFF();
|
||||
suspend_power_down();
|
||||
}
|
||||
KEY_POWER_OFF();
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
@ -165,3 +181,10 @@ void matrix_print(void)
|
|||
xprintf("%02X: %08b\n", row, bitrev(matrix_get_row(row)));
|
||||
}
|
||||
}
|
||||
|
||||
void matrix_power_up(void) {
|
||||
KEY_POWER_ON();
|
||||
}
|
||||
void matrix_power_down(void) {
|
||||
KEY_POWER_OFF();
|
||||
}
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue