diff --git a/.gitignore b/.gitignore
index c25d41d2..36d378de 100644
--- a/.gitignore
+++ b/.gitignore
@@ -8,3 +8,4 @@
*.map
*.sym
tags
+*.swp
diff --git a/.gitmodules b/.gitmodules
index 3e34a635..17a20dec 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -1,3 +1,6 @@
[submodule "protocol/usb_hid/USB_Host_Shield_2.0"]
path = protocol/usb_hid/USB_Host_Shield_2.0
url = git@github.com:tmk/USB_Host_Shield_2.0.git
+[submodule "protocol/lufa/LUFA-git"]
+ path = protocol/lufa/LUFA-git
+ url = https://github.com/abcminiuser/lufa.git
diff --git a/README.md b/README.md
index a561b38e..6596dc33 100644
--- a/README.md
+++ b/README.md
@@ -52,6 +52,7 @@ You can find some keyboard specific projects under `converter` and `keyboard` di
* [IIgs_Standard](keyboard/IIgs/) - Apple [IIGS] keyboard mod(by JeffreySung)
* [macway](keyboard/macway/) - [Compact keyboard mod][GH_macway] [retired]
* [KMAC](keyboard/kmac/) - Korean custom keyboard
+* [Lightsaber](keyboard/lightsaber/) - Korean custom keyboard
[GH_macway]: http://geekhack.org/showwiki.php?title=Island:11930
[GH_hhkb]: http://geekhack.org/showwiki.php?title=Island:12047
diff --git a/common.mk b/common.mk
index fb4ca939..06f57465 100644
--- a/common.mk
+++ b/common.mk
@@ -22,7 +22,7 @@ ifdef BOOTMAGIC_ENABLE
OPT_DEFS += -DBOOTMAGIC_ENABLE
endif
-ifdef MOUSEKEY_ENABLE
+ifdef $(or MOUSEKEY_ENABLE, PS2_MOUSE_ENABLE)
SRC += $(COMMON_DIR)/mousekey.c
OPT_DEFS += -DMOUSEKEY_ENABLE
OPT_DEFS += -DMOUSE_ENABLE
@@ -54,6 +54,11 @@ ifdef SLEEP_LED_ENABLE
OPT_DEFS += -DNO_SUSPEND_POWER_DOWN
endif
+ifdef BREATHING_LED_ENABLE
+ SRC += $(COMMON_DIR)/breathing_led.c
+ OPT_DEFS += -DBREATHING_LED_ENABLE
+endif
+
ifdef BACKLIGHT_ENABLE
SRC += $(COMMON_DIR)/backlight.c
OPT_DEFS += -DBACKLIGHT_ENABLE
@@ -69,6 +74,11 @@ ifdef KEYMAP_IN_EEPROM_ENABLE
OPT_DEFS += -DKEYMAP_IN_EEPROM_ENABLE
endif
+ifdef LED_MATRIX_ENABLE
+ SRC += $(COMMON_DIR)/led_matrix.c
+ OPT_DEFS += -DLED_MATRIX_ENABLE
+endif
+
# Version string
OPT_DEFS += -DVERSION=$(shell (git describe --always --dirty || echo 'unknown') 2> /dev/null)
diff --git a/common/action.c b/common/action.c
index e6938f5a..fddb97c5 100644
--- a/common/action.c
+++ b/common/action.c
@@ -294,7 +294,7 @@ void process_action(keyrecord_t *record)
#ifdef BACKLIGHT_ENABLE
case ACT_BACKLIGHT:
if (!event.pressed) {
- switch (action.backlight.id) {
+ switch (action.backlight.opt) {
case BACKLIGHT_INCREASE:
backlight_increase();
break;
@@ -307,6 +307,9 @@ void process_action(keyrecord_t *record)
case BACKLIGHT_STEP:
backlight_step();
break;
+ case BACKLIGHT_LEVEL:
+ backlight_level(action.backlight.level);
+ break;
}
}
break;
diff --git a/common/action_code.h b/common/action_code.h
index 8df86b11..50112d4d 100644
--- a/common/action_code.h
+++ b/common/action_code.h
@@ -87,7 +87,7 @@ along with this program. If not, see .
* 1100|1111| id(8) Macro record?
*
* ACT_BACKLIGHT(1101):
- * 1101|xxxx| id(8) Backlight commands
+ * 1101|opt |level(8) Backlight commands
*
* ACT_COMMAND(1110):
* 1110|opt | id(8) Built-in Command exec
@@ -163,7 +163,9 @@ typedef union {
uint8_t kind :4;
} usage;
struct action_backlight {
- uint8_t id :8;
+ uint8_t level :8;
+ uint8_t opt :4;
+ uint8_t kind :4;
} backlight;
struct action_command {
uint8_t id :8;
@@ -282,21 +284,23 @@ enum layer_pram_tap_op {
/*
* Extensions
*/
-enum backlight_id {
+enum backlight_opt {
BACKLIGHT_INCREASE = 0,
BACKLIGHT_DECREASE = 1,
BACKLIGHT_TOGGLE = 2,
BACKLIGHT_STEP = 3,
+ BACKLIGHT_LEVEL = 4,
};
/* Macro */
#define ACTION_MACRO(id) ACTION(ACT_MACRO, (id))
#define ACTION_MACRO_TAP(id) ACTION(ACT_MACRO, FUNC_TAP<<8 | (id))
#define ACTION_MACRO_OPT(id, opt) ACTION(ACT_MACRO, (opt)<<8 | (id))
/* Backlight */
-#define ACTION_BACKLIGHT_INCREASE() ACTION(ACT_BACKLIGHT, BACKLIGHT_INCREASE)
-#define ACTION_BACKLIGHT_DECREASE() ACTION(ACT_BACKLIGHT, BACKLIGHT_DECREASE)
-#define ACTION_BACKLIGHT_TOGGLE() ACTION(ACT_BACKLIGHT, BACKLIGHT_TOGGLE)
-#define ACTION_BACKLIGHT_STEP() ACTION(ACT_BACKLIGHT, BACKLIGHT_STEP)
+#define ACTION_BACKLIGHT_INCREASE() ACTION(ACT_BACKLIGHT, BACKLIGHT_INCREASE << 8)
+#define ACTION_BACKLIGHT_DECREASE() ACTION(ACT_BACKLIGHT, BACKLIGHT_DECREASE << 8)
+#define ACTION_BACKLIGHT_TOGGLE() ACTION(ACT_BACKLIGHT, BACKLIGHT_TOGGLE << 8)
+#define ACTION_BACKLIGHT_STEP() ACTION(ACT_BACKLIGHT, BACKLIGHT_STEP << 8)
+#define ACTION_BACKLIGHT_LEVEL(level) ACTION(ACT_BACKLIGHT, BACKLIGHT_LEVEL << 8 | level)
/* Command */
#define ACTION_COMMAND(id, opt) ACTION(ACT_COMMAND, (opt)<<8 | (addr))
/* Function */
diff --git a/common/backlight.c b/common/backlight.c
index 00dc04a0..c3001dd0 100644
--- a/common/backlight.c
+++ b/common/backlight.c
@@ -33,6 +33,16 @@ void backlight_init(void)
void backlight_increase(void)
{
+#ifdef BACKLIGHT_CUSTOM
+ if (backlight_config.enable) {
+ if (backlight_config.level < BACKLIGHT_LEVELS) {
+ backlight_config.level++;
+ eeconfig_write_backlight(backlight_config.raw);
+ }
+ dprintf("backlight custom increase: %u\n", backlight_config.level);
+ backlight_set(backlight_config.level);
+ }
+#else
if(backlight_config.level < BACKLIGHT_LEVELS)
{
backlight_config.level++;
@@ -41,10 +51,22 @@ void backlight_increase(void)
}
dprintf("backlight increase: %u\n", backlight_config.level);
backlight_set(backlight_config.level);
+#endif
}
void backlight_decrease(void)
{
+#ifdef BACKLIGHT_CUSTOM
+ if (backlight_config.enable) {
+ if(backlight_config.level > 1)
+ {
+ backlight_config.level--;
+ eeconfig_write_backlight(backlight_config.raw);
+ }
+ dprintf("backlight custom decrease: %u\n", backlight_config.level);
+ backlight_set(backlight_config.level);
+ }
+#else
if(backlight_config.level > 0)
{
backlight_config.level--;
@@ -53,11 +75,18 @@ void backlight_decrease(void)
}
dprintf("backlight decrease: %u\n", backlight_config.level);
backlight_set(backlight_config.level);
+#endif
}
void backlight_toggle(void)
{
backlight_config.enable ^= 1;
+ if (backlight_config.enable)
+ {
+ if (backlight_config.level == 0) {
+ backlight_config.level = 1;
+ }
+ }
eeconfig_write_backlight(backlight_config.raw);
dprintf("backlight toggle: %u\n", backlight_config.enable);
backlight_set(backlight_config.enable ? backlight_config.level : 0);
@@ -75,3 +104,11 @@ void backlight_step(void)
dprintf("backlight step: %u\n", backlight_config.level);
backlight_set(backlight_config.level);
}
+
+void backlight_level(uint8_t level)
+{
+ backlight_config.level ^= level;
+ backlight_config.enable = !!backlight_config.level;
+ eeconfig_write_backlight(backlight_config.raw);
+ backlight_set(backlight_config.level);
+}
diff --git a/common/backlight.h b/common/backlight.h
index 685c422a..525ec8bb 100644
--- a/common/backlight.h
+++ b/common/backlight.h
@@ -24,18 +24,17 @@ along with this program. If not, see .
typedef union {
uint8_t raw;
struct {
- bool enable:1;
- uint8_t level:7;
+ bool enable :1;
+ uint8_t level :7;
};
} backlight_config_t;
void backlight_init(void);
-
void backlight_increase(void);
void backlight_decrease(void);
void backlight_toggle(void);
void backlight_step(void);
-
void backlight_set(uint8_t level);
+void backlight_level(uint8_t level);
#endif
diff --git a/common/bootmagic.c b/common/bootmagic.c
index 0baff830..1668ee49 100644
--- a/common/bootmagic.c
+++ b/common/bootmagic.c
@@ -31,6 +31,7 @@ void bootmagic(void)
/* eeconfig clear */
if (bootmagic_scan_keycode(BOOTMAGIC_KEY_EEPROM_CLEAR)) {
+ eeconfig_disable();
eeconfig_init();
#ifdef KEYMAP_IN_EEPROM_ENABLE
write_keymap_to_eeprom();
diff --git a/common/breathing_led.c b/common/breathing_led.c
new file mode 100644
index 00000000..4e4822f8
--- /dev/null
+++ b/common/breathing_led.c
@@ -0,0 +1,73 @@
+#include
+#include
+#include "led.h"
+#include "breathing_led.h"
+#include "debug.h"
+
+#define BREATHING_LED_TIMER_TOP F_CPU/256
+
+static uint8_t breathing_led_duration = 0;
+
+void breathing_led_init(void)
+{
+ /* Timer3 setup */
+ /* CTC mode */
+ TCCR3B |= (1<>8)&0xff;
+ OCR3AL = BREATHING_LED_TIMER_TOP&0xff;
+ SREG = sreg;
+}
+
+void breathing_led_enable(void)
+{
+ /* Enable Compare Match Interrupt */
+ TIMSK3 |= (1< breathing_led_duration) {
+ step = 0;
+ breathing_led_set_raw(pgm_read_byte(&breathing_table[index]));
+ index++;
+ }
+}
diff --git a/common/breathing_led.h b/common/breathing_led.h
new file mode 100644
index 00000000..b3a9e775
--- /dev/null
+++ b/common/breathing_led.h
@@ -0,0 +1,25 @@
+#ifndef BREATHING_LED_H
+#define BREATHING_LED_H
+
+
+#ifdef BREATHING_LED_ENABLE
+
+void breathing_led_init(void);
+void breathing_led_enable(void);
+void breathing_led_disable(void);
+void breathing_led_toggle(void);
+void breathing_led_set_duration(uint8_t dur);
+void breathing_led_set_raw(uint8_t raw);
+
+#else
+
+#define breathing_led_init()
+#define breathing_led_enable()
+#define breathing_led_disable()
+#define breathing_led_toggle()
+#define breathing_led_set_duration()
+#define breathing_led_set_raw()
+
+#endif
+
+#endif
diff --git a/common/command.c b/common/command.c
index f6f27695..d2f8eb83 100644
--- a/common/command.c
+++ b/common/command.c
@@ -301,13 +301,13 @@ static bool command_common(uint8_t code)
case KC_S:
print("\n\n----- Status -----\n");
print_val_hex8(host_keyboard_leds());
+ print_val_hex8(keyboard_protocol);
+ print_val_hex8(keyboard_idle);
#ifdef PROTOCOL_PJRC
print_val_hex8(UDCON);
print_val_hex8(UDIEN);
print_val_hex8(UDINT);
print_val_hex8(usb_keyboard_leds);
- print_val_hex8(usb_keyboard_protocol);
- print_val_hex8(usb_keyboard_idle_config);
print_val_hex8(usb_keyboard_idle_count);
#endif
diff --git a/common/eeconfig.c b/common/eeconfig.c
index 5bd47dc6..5aadf1c5 100644
--- a/common/eeconfig.c
+++ b/common/eeconfig.c
@@ -2,6 +2,7 @@
#include
#include
#include "eeconfig.h"
+#include "keymap_ex.h"
void eeconfig_init(void)
{
@@ -13,6 +14,9 @@ void eeconfig_init(void)
#ifdef BACKLIGHT_ENABLE
eeprom_write_byte(EECONFIG_BACKLIGHT, 0);
#endif
+#ifdef KEYMAP_EX_ENABLE
+ keymap_ex_init();
+#endif
}
void eeconfig_enable(void)
@@ -22,6 +26,9 @@ void eeconfig_enable(void)
void eeconfig_disable(void)
{
+#ifdef KEYMAP_EX_ENABLE
+ keymap_ex_disable();
+#endif
eeprom_write_word(EECONFIG_MAGIC, 0xFFFF);
}
diff --git a/common/host.c b/common/host.c
index 1eafef75..2e56971b 100644
--- a/common/host.c
+++ b/common/host.c
@@ -24,7 +24,7 @@ along with this program. If not, see .
#ifdef NKRO_ENABLE
-bool keyboard_nkro = false;
+bool keyboard_nkro = true;
#endif
static host_driver_t *driver;
diff --git a/common/host.h b/common/host.h
index 8ff26298..a56e6c3b 100644
--- a/common/host.h
+++ b/common/host.h
@@ -32,6 +32,9 @@ extern "C" {
extern bool keyboard_nkro;
#endif
+uint8_t keyboard_idle;
+uint8_t keyboard_protocol;
+
/* host driver */
void host_set_driver(host_driver_t *driver);
diff --git a/common/keyboard.c b/common/keyboard.c
index 20dfbca8..08f86be3 100644
--- a/common/keyboard.c
+++ b/common/keyboard.c
@@ -31,6 +31,7 @@ along with this program. If not, see .
#include "bootmagic.h"
#include "eeconfig.h"
#include "backlight.h"
+#include "breathing_led.h"
#include "keymap_in_eeprom.h"
#ifdef MOUSEKEY_ENABLE
# include "mousekey.h"
@@ -62,8 +63,15 @@ void keyboard_init(void)
{
timer_init();
matrix_init();
+
+#ifdef LED_MATRIX_ENABLE
+ led_matrix_init();
+#endif
+
#ifdef PS2_MOUSE_ENABLE
- ps2_mouse_init();
+ if (ps2_enabled()) {
+ ps2_mouse_init();
+ }
#endif
#ifdef BOOTMAGIC_ENABLE
@@ -74,6 +82,10 @@ void keyboard_init(void)
backlight_init();
#endif
+#ifdef BREATHING_LED_ENABLE
+ breathing_led_init();
+#endif
+
#ifdef KEYMAP_IN_EEPROM_ENABLE
keymap_in_eeprom_init();
#endif
@@ -128,7 +140,9 @@ MATRIX_LOOP_END:
#endif
#ifdef PS2_MOUSE_ENABLE
- ps2_mouse_task();
+ if (ps2_enabled()) {
+ ps2_mouse_task();
+ }
#endif
// update LED
diff --git a/common/led_matrix.c b/common/led_matrix.c
new file mode 100644
index 00000000..e5a4629f
--- /dev/null
+++ b/common/led_matrix.c
@@ -0,0 +1,91 @@
+/*
+Copyright 2013,2014 Kai Ryu
+
+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
+#include
+#include "led_matrix.h"
+
+#define LED_MATRIX_TIMER_TOP F_CPU/(256*64)/LED_MATRIX_ROWS
+
+static led_matrix_element_t led_matrix[LED_MATRIX_ROWS][LED_MATRIX_COLS];
+
+void led_matrix_init(void)
+{
+ led_matrix_unselect_rows();
+ led_matrix_write_cols(0);
+ /* Timer1 setup */
+ /* CTC mode */
+ TCCR1B |= (1<> 8) & 0xFF;
+ OCR1AL = LED_MATRIX_TIMER_TOP & 0xFF;
+ SREG = sreg;
+}
+
+void led_matrix_enable(void)
+{
+ /* Enable Compare Match Interrupt */
+ TIMSK1 |= _BV(OCIE1A);
+}
+
+void led_matrix_disable(void)
+{
+ /* Disable Compare Match Interrupt */
+ TIMSK1 &= ~_BV(OCIE1A);
+}
+
+inline
+led_matrix_row_t led_matrix_make_cols(uint8_t row, uint8_t pwm)
+{
+ led_matrix_row_t cols = 0;
+ for (uint8_t i = 0; i < LED_MATRIX_COLS; i++) {
+ cols |= ((led_matrix[row][i].value < pwm ? 1 : 0) << i);
+ }
+ return cols;
+}
+
+inline
+void led_matrix_set_value(uint8_t row, uint8_t col, uint8_t value)
+{
+ led_matrix[row][col].value = value;
+}
+
+inline
+void led_matrix_set_delta(uint8_t row, uint8_t col, int8_t delta)
+{
+ led_matrix[row][col].delta = delta;
+}
+
+ISR(TIMER1_COMPA_vect)
+{
+ static uint8_t row = 0;
+ static uint8_t pwm = 0;
+
+ row = (row + 1) % LED_MATRIX_ROWS;
+ pwm++;
+
+ led_matrix_select_row(row);
+ _delay_us(10);
+ led_matrix_write_cols(led_matrix_make_cols(row, pwm));
+ _delay_us(10);
+ led_matrix_unselect_rows();
+}
diff --git a/common/led_matrix.h b/common/led_matrix.h
new file mode 100644
index 00000000..513f2c8d
--- /dev/null
+++ b/common/led_matrix.h
@@ -0,0 +1,65 @@
+/*
+Copyright 2013,2014 Kai Ryu
+
+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 LED_MATRIX_H
+#define LED_MATRIX_H
+
+#include
+#include
+
+#if (LED_MATRIX_COLS <= 8)
+typedef uint8_t led_matrix_row_t;
+#elif (LED_MATRIX_COLS <= 16)
+typedef uint16_t led_matrix_row_t;
+#elif (LED_MATRIX_COLS <= 32)
+typedef uint32_t led_matrix_row_t;
+#else
+#error "LED_MATRIX_COLS: invalid value"
+#endif
+
+typedef struct {
+ union {
+ int8_t delta;
+ struct {
+ bool direction:1;
+ };
+ };
+ uint8_t value;
+} led_matrix_element_t;
+
+#ifdef LED_MATRIX_ENABLE
+void led_matrix_init(void);
+void led_matrix_enable(void);
+void led_matrix_disable(void);
+void led_matrix_init_cols(void);
+led_matrix_row_t led_matrix_make_cols(uint8_t row, uint8_t pwm);
+void led_matrix_set_value(uint8_t row, uint8_t col, uint8_t value);
+void led_matrix_set_delta(uint8_t row, uint8_t col, int8_t delta);
+extern void led_matrix_write_cols(led_matrix_row_t cols);
+extern void led_matrix_unselect_rows(void);
+extern void led_matrix_select_row(uint8_t row);
+#else
+#define led_matrix_init()
+#define led_matrix_enable()
+#define led_matrix_disable()
+#define led_matrix_init_cols()
+#define led_matrix_write_cols()
+#define led_matrix_unselect_rows()
+#define led_matrix_select_row()
+#endif
+
+#endif
diff --git a/converter/pc98_usb/README b/converter/pc98_usb/README
index a010dee2..c9bdf3d8 100644
--- a/converter/pc98_usb/README
+++ b/converter/pc98_usb/README
@@ -20,7 +20,7 @@ Wiring: You can change this with editing config.h.
Pin mini DIN MCU
----------------------------------
- 1 ~RST PD1
+ 1 ~RST(TXD) PD3
2 GND GND
3 ~RDY PD4
4 RXD PD2
@@ -37,9 +37,6 @@ Protocol
Signal: Asynchronous, Positive logic, 19200baud, Least bit first
Frame format: 1-Start bit(Lo), 8-Data bits, Odd-Parity, 1-Stop bit
-This converter uses software method for testing purpose. AVR UART engine will work better.
-
-
Build Firmware
diff --git a/converter/ps2_usb/Makefile b/converter/ps2_usb/Makefile
index db0912eb..1dd23c15 100644
--- a/converter/ps2_usb/Makefile
+++ b/converter/ps2_usb/Makefile
@@ -1,3 +1,6 @@
+#
+# Makefile for Teensy
+#
# Target file name (without extension).
TARGET = ps2_usb_lufa
@@ -59,7 +62,7 @@ ARCH = AVR8
F_USB = $(F_CPU)
# Interrupt driven control endpoint task(+60)
-OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT
+#OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT
# Boot Section Size in *bytes*
@@ -68,7 +71,7 @@ OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT
# Atmel DFU loader 4096
# LUFA bootloader 4096
# USBaspLoader 2048
-OPT_DEFS += -DBOOTLOADER_SIZE=4096
+OPT_DEFS += -DBOOTLOADER_SIZE=512
# Build Options
diff --git a/converter/ps2_usb/Makefile.jis b/converter/ps2_usb/Makefile.jis
deleted file mode 100644
index 4e091e8e..00000000
--- a/converter/ps2_usb/Makefile.jis
+++ /dev/null
@@ -1,75 +0,0 @@
-# Target file name (without extension).
-TARGET = ps2_usb_jis
-
-# Directory common source filess exist
-TOP_DIR = ../..
-
-# Directory keyboard dependent files exist
-TARGET_DIR = .
-
-
-# MCU name, you MUST set this to match the board you are using
-# type "make clean" after changing this, so all files will be rebuilt
-#MCU = at90usb162 # Teensy 1.0
-MCU = atmega32u4 # Teensy 2.0
-#MCU = at90usb646 # Teensy++ 1.0
-#MCU = at90usb1286 # Teensy++ 2.0
-
-
-# Processor frequency.
-# Normally the first thing your program should do is set the clock prescaler,
-# so your program will run at the correct speed. You should also set this
-# variable to same clock speed. The _delay_ms() macro uses this, and many
-# examples use this variable to calculate timings. Do not add a "UL" here.
-F_CPU = 16000000
-
-
-# Build Options
-# *Comment out* to disable the options.
-#
-MOUSEKEY_ENABLE = yes # Mouse keys
-EXTRAKEY_ENABLE = yes # Audio control and System control
-NKRO_ENABLE = yes # USB Nkey Rollover
-
-#PS2_USE_USART = yes # uses hardware USART engine for PS/2 signal receive(recomened)
-#PS2_USE_INT = yes # uses external interrupt for falling edge of PS/2 clock pin
-PS2_USE_BUSYWAIT = yes # uses primitive reference code
-
-
-# keyboard dependent files
-SRC = keymap_jis.c \
- matrix.c \
- led.c
-
-
-ifdef PS2_USE_USART
- SRC += protocol/ps2_usart.c
- OPT_DEFS += -DPS2_USE_USART
-endif
-ifdef PS2_USE_INT
- SRC += protocol/ps2.c
- OPT_DEFS += -DPS2_USE_INT
-endif
-ifdef PS2_USE_BUSYWAIT
- SRC += protocol/ps2.c
- OPT_DEFS += -DPS2_USE_BUSYWAIT
-endif
-
-
-#CONFIG_H = config_pjrc_usart.h
-CONFIG_H = config.h
-
-
-#---------------- Programming Options --------------------------
-PROGRAM_CMD = teensy_loader_cli -mmcu=$(MCU) -w -v $(TARGET).hex
-
-
-# Search Path
-VPATH += $(TARGET_DIR)
-VPATH += $(TOP_DIR)
-
-
-include $(TOP_DIR)/protocol/pjrc.mk
-include $(TOP_DIR)/protocol.mk
-include $(TOP_DIR)/common.mk
-include $(TOP_DIR)/rules.mk
diff --git a/converter/ps2_usb/Makefile.tmk_rev1 b/converter/ps2_usb/Makefile.tmk_rev1
new file mode 100644
index 00000000..59c44f75
--- /dev/null
+++ b/converter/ps2_usb/Makefile.tmk_rev1
@@ -0,0 +1,98 @@
+#
+# Makefile for TMK keyboard converter rev2
+# https://github.com/tmk/keyboard_converter#pcb-rev1
+#
+# Target file name (without extension).
+TARGET = ps2_usb_tmk_rev1
+
+# 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_tmk_rev1.h
+
+
+# MCU name
+MCU = atmega32u4
+
+# Processor frequency.
+# This will define a symbol, F_CPU, in all source code files equal to the
+# processor frequency in Hz. You can then use this symbol in your source code to
+# calculate timings. Do NOT tack on a 'UL' at the end, this will be done
+# automatically to create a 32-bit value in your source code.
+#
+# This will be an integer division of F_USB below, as it is sourced by
+# F_USB after it has run through any CPU prescalers. Note that this value
+# does not *change* the processor frequency - it should merely be updated to
+# reflect the processor speed set externally so that the code can use accurate
+# software delays.
+F_CPU = 16000000
+
+
+#
+# LUFA specific
+#
+# Target architecture (see library "Board Types" documentation).
+ARCH = AVR8
+
+# Input clock frequency.
+# This will define a symbol, F_USB, in all source code files equal to the
+# input clock frequency (before any prescaling is performed) in Hz. This value may
+# differ from F_CPU if prescaling is used on the latter, and is required as the
+# raw input clock is fed directly to the PLL sections of the AVR for high speed
+# clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL'
+# at the end, this will be done automatically to create a 32-bit value in your
+# source code.
+#
+# If no clock division is performed on the input clock inside the AVR (via the
+# CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU.
+F_USB = $(F_CPU)
+
+
+# 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
+#NKRO_ENABLE = yes # USB Nkey Rollover - not yet supported in LUFA
+
+
+# PS/2 Options
+#
+PS2_USE_USART = yes # uses hardware USART engine for PS/2 signal receive(recomened)
+#PS2_USE_BUSYWAIT = yes # uses primitive reference code
+
+
+# Search Path
+VPATH += $(TARGET_DIR)
+VPATH += $(TOP_DIR)
+
+include $(TOP_DIR)/protocol.mk
+include $(TOP_DIR)/protocol/lufa.mk
+include $(TOP_DIR)/common.mk
+include $(TOP_DIR)/rules.mk
diff --git a/converter/ps2_usb/Makefile.tmk_rev2 b/converter/ps2_usb/Makefile.tmk_rev2
new file mode 100644
index 00000000..bad958c3
--- /dev/null
+++ b/converter/ps2_usb/Makefile.tmk_rev2
@@ -0,0 +1,98 @@
+#
+# Makefile for TMK keyboard converter rev2
+# https://github.com/tmk/keyboard_converter#pcb-rev2
+#
+# Target file name (without extension).
+TARGET = ps2_usb_tmk_rev2
+
+# 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_tmk_rev2.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)
+
+
+# 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
+#NKRO_ENABLE = yes # USB Nkey Rollover - not yet supported in LUFA
+
+
+# PS/2 Options
+#
+PS2_USE_INT = yes # uses external interrupt for falling edge of PS/2 clock pin
+#PS2_USE_BUSYWAIT = yes # uses primitive reference code
+
+
+# Search Path
+VPATH += $(TARGET_DIR)
+VPATH += $(TOP_DIR)
+
+include $(TOP_DIR)/protocol.mk
+include $(TOP_DIR)/protocol/lufa.mk
+include $(TOP_DIR)/common.mk
+include $(TOP_DIR)/rules.mk
diff --git a/converter/ps2_usb/README.md b/converter/ps2_usb/README.md
index 8f06fdd0..537e92e6 100644
--- a/converter/ps2_usb/README.md
+++ b/converter/ps2_usb/README.md
@@ -1,11 +1,50 @@
PS/2 to USB keyboard converter
==============================
-This firmware converts PS/2 keyboard protocol to USB and supports only Scan Code Set 2.
+This firmware converts PS/2 keyboard protocol to USB.(It supports Scan Code Set 2.)
+
+
+Connect Wires
+-------------
+In case of Teensy2.0(ATMega32U4):
+
+1. Connect **Vcc** and **GND**.
+2. Connect **Clock** and **Data** line.
+ - **Interrupt**: **Clock** is on `PD1` and **Data** on `PD0`.(Recommended. Soarer's converter compatible)
+ - **Busywait**: **Clock** is on `PD1` and **Data** on `PD0`.
+ - **USART**: **Clock** is on `PD5` and **Data** on `PD2`.
+3. Optionally you need pull-up register. 1K-10K Ohm is OK.
+
+To change pin configuration edit config.h.
+
+
+Build Firmware
+--------------
+For **PJRC Teensy** just run `make`:
+
+ $ make clean
+ $ make
+
+To select keymap:
+
+ $ make clean
+ $ make KEYMAP=[plain|jis|spacefn|...]
+
+After that you will find HEX file `ps2_usb_lufa.hex` in current directory.
+
+
+- For **TMK converter Rev.1** use `make -f Makefile.tmk_rev1` instead of `make` and HEX file is `ps2_usb_tmk_rev1.hex`.
+
+- For **TMK converter Rev.2** use `make -f Makefile.tmk_rev2` instead of `make` and HEX file is `ps2_usb_tmk_rev2.hex`.
+
+
+Keymap
+------
+Several version of keymap are available in advance but you are recommended to define your favorite layout yourself. To define your own keymap create file named `keymap_.c` and see keymap document(you can find in README.md of top directory) and existent keymap files.
PS/2 signal handling implementations
------------------------------------
-Following three methods are used to implement PS/2 signal handling.
+Following three methods can be used to implement PS/2 signal handling.
### Simple and stupid busy-wait(ps2_busywait.c)
This is expected to implemented with portable C code for reference.
@@ -17,36 +56,6 @@ Following three methods are used to implement PS/2 signal handling.
To select method edit Makefile.
-Connect Wires
--------------
-In case of Teensy2.0(ATMega32U4):
-
-1. Connect Vcc and GND.
-2. Connect Clock and Data line.
- - Busywait: Clock is on PD5 and Data on PD2.
- - Interrupt: Clock is on PD1 and Data on PD2.
- - USART: Clock is on PD5 and Data on PD2.
-3. Optionally you need pull-up register. 1K-10K Ohm is OK.
-
-To change pin configuration edit config.h.
-
-
-Build Firmware
---------------
-Just run `make`:
-
- $ make
-
-To select keymap:
-
- $ make KEYMAP=[plain|jis|spacefn|...]
-
-
-Keymap
-------
-Several version of keymap are available in advance but you are recommended to define your favorite layout yourself. To define your own keymap create file named `keymap_.c` and see keymap document(you can find in top README.md) and existent keymap files.
-
-
V-USB Support
-------------
You can also use this converter on ATmega(168/328) with V-USB instead of Teensy.
diff --git a/converter/ps2_usb/config_tmk_rev1.h b/converter/ps2_usb/config_tmk_rev1.h
new file mode 100644
index 00000000..75dc97df
--- /dev/null
+++ b/converter/ps2_usb/config_tmk_rev1.h
@@ -0,0 +1,147 @@
+/*
+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 .
+*/
+
+#ifndef CONFIG_H
+#define CONFIG_H
+
+#include
+
+#define VENDOR_ID 0xFEED
+#define PRODUCT_ID 0x6512
+#define DEVICE_VER 0x0001
+#define MANUFACTURER t.m.k.
+#define PRODUCT PS/2 keyboard converter
+#define DESCRIPTION convert PS/2 keyboard to USB
+
+
+/* matrix size */
+#define MATRIX_ROWS 32 // keycode bit: 3-0
+#define MATRIX_COLS 8 // keycode bit: 6-4
+
+
+/* key combination for command */
+#define IS_COMMAND() ( \
+ keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) || \
+ keyboard_report->mods == (MOD_BIT(KC_LCTRL) | MOD_BIT(KC_RSHIFT)) \
+)
+
+
+//#define NO_SUSPEND_POWER_DOWN
+
+
+/*
+ * PS/2 Busywait
+ */
+#ifdef PS2_USE_BUSYWAIT
+#define PS2_CLOCK_PORT PORTD
+#define PS2_CLOCK_PIN PIND
+#define PS2_CLOCK_DDR DDRD
+#define PS2_CLOCK_BIT 5
+#define PS2_DATA_PORT PORTD
+#define PS2_DATA_PIN PIND
+#define PS2_DATA_DDR DDRD
+#define PS2_DATA_BIT 2
+#endif
+
+/*
+ * PS/2 USART
+ */
+#ifdef PS2_USE_USART
+#if defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__)
+/* XCK for clock line and RXD for data line */
+#define PS2_CLOCK_PORT PORTD
+#define PS2_CLOCK_PIN PIND
+#define PS2_CLOCK_DDR DDRD
+#define PS2_CLOCK_BIT 5
+#define PS2_DATA_PORT PORTD
+#define PS2_DATA_PIN PIND
+#define PS2_DATA_DDR DDRD
+#define PS2_DATA_BIT 2
+/* synchronous, odd parity, 1-bit stop, 8-bit data, sample at falling edge */
+/* set DDR of CLOCK as input to be slave */
+#define PS2_USART_INIT() do { \
+ PS2_CLOCK_DDR &= ~(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 .
+*/
+
+#ifndef CONFIG_H
+#define CONFIG_H
+
+#include
+
+#define VENDOR_ID 0xFEED
+#define PRODUCT_ID 0x6512
+#define DEVICE_VER 0x0001
+#define MANUFACTURER t.m.k.
+#define PRODUCT PS/2 keyboard converter
+#define DESCRIPTION convert PS/2 keyboard to USB
+
+
+/* matrix size */
+#define MATRIX_ROWS 32 // keycode bit: 3-0
+#define MATRIX_COLS 8 // keycode bit: 6-4
+
+
+/* key combination for command */
+#define IS_COMMAND() ( \
+ keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) || \
+ keyboard_report->mods == (MOD_BIT(KC_LCTRL) | MOD_BIT(KC_RSHIFT)) \
+)
+
+
+//#define NO_SUSPEND_POWER_DOWN
+
+
+/*
+ * PS/2 Busywait
+ */
+#ifdef PS2_USE_BUSYWAIT
+#define PS2_CLOCK_PORT PORTD
+#define PS2_CLOCK_PIN PIND
+#define PS2_CLOCK_DDR DDRD
+#define PS2_CLOCK_BIT 1
+#define PS2_DATA_PORT PORTD
+#define PS2_DATA_PIN PIND
+#define PS2_DATA_DDR DDRD
+#define PS2_DATA_BIT 0
+#endif
+
+/*
+ * PS/2 Pin interrupt
+ */
+#ifdef PS2_USE_INT
+/* uses INT1 for clock line(ATMega32U4) */
+#define PS2_CLOCK_PORT PORTD
+#define PS2_CLOCK_PIN PIND
+#define PS2_CLOCK_DDR DDRD
+#define PS2_CLOCK_BIT 1
+#define PS2_DATA_PORT PORTD
+#define PS2_DATA_PIN PIND
+#define PS2_DATA_DDR DDRD
+#define PS2_DATA_BIT 0
+#define PS2_INT_INIT() do { \
+ EICRA |= ((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 .
+*/
+
+#include
+#include
+#include
+#include "backlight.h"
+#include "breathing_led.h"
+
+#ifdef BACKLIGHT_ENABLE
+
+void backlight_enable(void);
+void backlight_disable(void);
+inline void backlight_set_raw(uint8_t raw);
+
+#ifdef GH60_REV_CHN
+#else
+#define SOFTPWM_TIMER_TOP F_CPU/(256*64)
+uint8_t softpwm_ocr = 0;
+uint8_t softpwm_ocr_buff = 0;
+#endif
+
+static const uint8_t backlight_table[] PROGMEM = {
+ 0, 16, 128, 255
+};
+
+/* Backlight pin configuration
+ * PWM: PB6 (Rev.CHN)
+ * GPIO: PF7 PF6 PF5 PF4 (Rev.B)
+ */
+void backlight_enable(void)
+{
+#if defined(GH60_REV_CHN)
+ // Turn on PWM
+ DDRB |= (1<>8)&0xff;
+ OCR1AL = SOFTPWM_TIMER_TOP&0xff;
+ TIMSK1 |= (1< 0) {
+ backlight_enable();
+ backlight_set_raw(pgm_read_byte(&backlight_table[level]));
+ }
+ else {
+ backlight_disable();
+ }
+#endif
+}
+
+#ifdef BREATHING_LED_ENABLE
+void breathing_led_set_raw(uint8_t raw)
+{
+ backlight_set_raw(raw);
+}
+#endif
+
+inline void backlight_set_raw(uint8_t raw)
+{
+#if defined(GH60_REV_CHN)
+ OCR1B = raw;
+#else
+ softpwm_ocr_buff = raw;
+#endif
+}
+
+#if defined(GH60_REV_CHN)
+#else
+ISR(TIMER1_COMPA_vect)
+{
+ static uint8_t pwm = 0;
+ pwm++;
+ // LED on
+ if (pwm == 0) {
+ //PORTB |= (1<.
/* Set 0 if debouncing isn't needed */
#define DEBOUNCE 5
+/* number of backlight levels */
+#ifdef BREATHING_LED_ENABLE
+#define BACKLIGHT_LEVELS 6
+#else
+#define BACKLIGHT_LEVELS 3
+#endif
+
+#ifdef GH60_REV_CNY
+#define LED_MATRIX_ROWS 6
+#define LED_MATRIX_COLS 14
+#endif
+
/* 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
@@ -51,7 +64,18 @@ along with this program. If not, see .
keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \
)
+/* PS2 mouse support */
+#ifdef PS2_MOUSE_ENABLE
+#define PS2_CLOCK_PORT PORTF
+#define PS2_CLOCK_PIN PINF
+#define PS2_CLOCK_DDR DDRF
+#define PS2_CLOCK_BIT PF7
+#define PS2_DATA_PORT PORTF
+#define PS2_DATA_PIN PINF
+#define PS2_DATA_DDR DDRF
+#define PS2_DATA_BIT PF6
+#endif
/*
* Feature disable options
diff --git a/keyboard/gh60/keymap_common.h b/keyboard/gh60/keymap_common.h
index 8e4bc3bf..5f808023 100644
--- a/keyboard/gh60/keymap_common.h
+++ b/keyboard/gh60/keymap_common.h
@@ -43,13 +43,13 @@ extern const uint16_t fn_actions[];
K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D, \
K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, K2C, K2D, \
K30, K31, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B, K3C, K3D, \
- K40, K41, K42, K45, K49, K4A, K4B, K4C, K4D \
+ K40, K41, K42, K45, K4A, K4B, K4C, K4D \
) { \
{ KC_##K00, KC_##K01, KC_##K02, KC_##K03, KC_##K04, KC_##K05, KC_##K06, KC_##K07, KC_##K08, KC_##K09, KC_##K0A, KC_##K0B, KC_##K0C, KC_##K0D }, \
{ KC_##K10, KC_##K11, KC_##K12, KC_##K13, KC_##K14, KC_##K15, KC_##K16, KC_##K17, KC_##K18, KC_##K19, KC_##K1A, KC_##K1B, KC_##K1C, KC_##K1D }, \
{ KC_##K20, KC_##K21, KC_##K22, KC_##K23, KC_##K24, KC_##K25, KC_##K26, KC_##K27, KC_##K28, KC_##K29, KC_##K2A, KC_##K2B, KC_##K2C, KC_##K2D }, \
{ KC_##K30, KC_##K31, KC_##K32, KC_##K33, KC_##K34, KC_##K35, KC_##K36, KC_##K37, KC_##K38, KC_##K39, KC_##K3A, KC_##K3B, KC_##K3C, KC_##K3D }, \
- { KC_##K40, KC_##K41, KC_##K42, KC_NO, KC_NO, KC_##K45, KC_NO, KC_NO, KC_NO, KC_##K49, KC_##K4A, KC_##K4B, KC_##K4C, KC_##K4D } \
+ { KC_##K40, KC_##K41, KC_##K42, KC_NO, KC_NO, KC_##K45, KC_NO, KC_NO, KC_NO, KC_NO, KC_##K4A, KC_##K4B, KC_##K4C, KC_##K4D } \
}
/* ANSI valiant. No extra keys for ISO */
@@ -64,22 +64,7 @@ extern const uint16_t fn_actions[];
K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D, \
K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, NO, K2D, \
K30, NO, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B, NO, K3D, \
- K40, K41, K42, K45, NO, K4A, K4B, K4C, K4D \
-)
-
-
-#define KEYMAP_HHKB( \
- K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, K0C, K0D, K49,\
- K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D, \
- K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, K2D, \
- K30, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B, K3D, K3C, \
K40, K41, K42, K45, K4A, K4B, K4C, K4D \
-) KEYMAP( \
- K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, K0C, K0D, \
- K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D, \
- K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, NO, K2D, \
- K30, NO, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B, K3C, K3D, \
- K40, K41, K42, K45, K49, K4A, K4B, K4C, K4D \
)
#endif
diff --git a/keyboard/gh60/keymap_poker2.c b/keyboard/gh60/keymap_poker2.c
new file mode 100644
index 00000000..cfcadccf
--- /dev/null
+++ b/keyboard/gh60/keymap_poker2.c
@@ -0,0 +1,72 @@
+#include "keymap_common.h"
+
+// Poker2
+#ifdef KEYMAP_SECTION_ENABLE
+const uint8_t keymaps[KEYMAPS_COUNT][MATRIX_ROWS][MATRIX_COLS] __attribute__ ((section (".keymap.keymaps"))) = {
+#else
+const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS] PROGMEM = {
+#endif
+ /* Keymap 0: 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| [| ]| \|
+ * |-----------------------------------------------------------|
+ * |Caps | A| S| D| F| G| H| J| K| L| ;| '|Return |
+ * |-----------------------------------------------------------|
+ * |Shift | Z| X| C| V| B| N| M| ,| .| /|Shift |Fn0|
+ * |-----------------------------------------------------------|
+ * |Ctrl|Gui |Alt | Space |Alt |Fn0 |Gui |Ctrl|
+ * `-----------------------------------------------------------'
+ */
+ KEYMAP(
+ 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, \
+ CAPS,A, S, D, F, G, H, J, K, L, SCLN,QUOT,NO, ENT, \
+ LSFT,NO, Z, X, C, V, B, N, M, COMM,DOT, SLSH,FN0, RSFT, \
+ LCTL,LGUI,LALT, SPC, NO, RALT,FN0, RGUI,RCTL),
+ /* Keymap 1: Fn Layer
+ * ,-----------------------------------------------------------.
+ * | `| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Delete |
+ * |-----------------------------------------------------------|
+ * | | |Up | | | |Cal| |Ins| |Psc|Slk|Pau| |
+ * |-----------------------------------------------------------|
+ * | |Lef|Dow|Rig| | | | | | |Hom|PgU| |
+ * |-----------------------------------------------------------|
+ * | | |App|Fn1|Fn2|Fn3|VoD|VoU|Mut|End|PgD| | |
+ * |-----------------------------------------------------------|
+ * | | | | | | | | |
+ * `-----------------------------------------------------------'
+ */
+ KEYMAP(
+ GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, DEL, \
+ TRNS,TRNS,UP, TRNS,TRNS,TRNS,CALC,TRNS,INS, TRNS,PSCR,SLCK,PAUS,TRNS, \
+ TRNS,LEFT,DOWN,RGHT,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,HOME,PGUP,NO, TRNS, \
+ TRNS,NO, TRNS,APP, FN1, FN2, FN3, VOLD,VOLU,MUTE,END, PGDN,TRNS,TRNS, \
+ TRNS,TRNS,TRNS, TRNS, NO, TRNS,TRNS,TRNS,TRNS),
+};
+
+/*
+ * Fn action definition
+ */
+#ifdef KEYMAP_SECTION_ENABLE
+const uint16_t fn_actions[FN_ACTIONS_COUNT] __attribute__ ((section (".keymap.fn_actions"))) = {
+#else
+const uint16_t fn_actions[] PROGMEM = {
+#endif
+ /* Poker2 Layout */
+ [0] = ACTION_LAYER_MOMENTARY(1),
+ [1] = ACTION_BACKLIGHT_DECREASE(),
+ [2] = ACTION_BACKLIGHT_TOGGLE(),
+ [3] = ACTION_BACKLIGHT_INCREASE()
+};
+
+#ifdef KEYMAP_EX_ENABLE
+uint16_t keys_count(void) {
+ return sizeof(keymaps) / sizeof(keymaps[0]) * MATRIX_ROWS * MATRIX_COLS;
+}
+
+uint16_t fn_actions_count(void) {
+ return sizeof(fn_actions) / sizeof(fn_actions[0]);
+}
+#endif
diff --git a/keyboard/gh60/led_matrix.c b/keyboard/gh60/led_matrix.c
new file mode 100644
index 00000000..33eaf95f
--- /dev/null
+++ b/keyboard/gh60/led_matrix.c
@@ -0,0 +1,98 @@
+/*
+Copyright 2013,2014 Kai Ryu
+
+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 "led_matrix.h"
+
+#ifdef LED_MATRIX_ENABLE
+#if defined(GH60_REV_CNY)
+
+/* LED Column pin configuration
+ * pin: F0 F1 E6 C7 C6 B7 D4 B0 B1 B5 B4 D7 D6 B3 (Rev.CNY)
+ */
+void led_matrix_write_cols(led_matrix_row_t cols)
+{
+ (cols & (1<<0)) ? (PORTF |= (1<.
#include "debug.h"
#include "util.h"
#include "matrix.h"
+#ifdef PS2_MOUSE_ENABLE
+#include "ps2.h"
+#endif
#ifndef DEBOUNCE
@@ -42,6 +45,14 @@ static void init_cols(void);
static void unselect_rows(void);
static void select_row(uint8_t row);
+#ifdef PS2_MOUSE_ENABLE
+static uint8_t ps2_mouse_detected;
+
+uint8_t ps2_enabled(void)
+{
+ return ps2_mouse_detected;
+}
+#endif
inline
uint8_t matrix_rows(void)
@@ -57,6 +68,23 @@ uint8_t matrix_cols(void)
void matrix_init(void)
{
+ // disable JTAG
+ MCUCR = (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 .
+*/
+
+#include
+#include
+#include
+#include "backlight.h"
+
+static const uint8_t backlight_table[] PROGMEM = {
+ 0, 16, 128, 255
+};
+
+uint8_t softpwm_ocr = 0;
+
+/* Backlight pin configuration
+ * PWM: PB5 (RevRS)
+ * GPIO: PF7 PF6 PF5
+ */
+void backlight_set(uint8_t level)
+{
+ if (level > 0) {
+ // Turn on PWM
+ cli();
+ // Hard PWM
+ DDRB |= (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 .
+*/
+
+#ifndef CONFIG_H
+#define CONFIG_H
+
+
+/* USB Device descriptor parameter */
+#define VENDOR_ID 0xFEED
+#define PRODUCT_ID 0x6060
+#define DEVICE_VER 0x0002
+#define MANUFACTURER geekhack
+#define PRODUCT GHPad
+#define DESCRIPTION t.m.k. keyboard firmware for GHPad
+
+/* key matrix size */
+#define MATRIX_ROWS 6
+#define MATRIX_COLS 4
+
+/* keymap in eeprom */
+#define FN_ACTIONS_COUNT 32
+#define KEYMAPS_COUNT 32
+
+/* define if matrix has ghost */
+//#define MATRIX_HAS_GHOST
+
+/* Set 0 if debouncing isn't needed */
+#define DEBOUNCE 5
+
+/* number of backlight levels */
+#define BACKLIGHT_LEVELS 3
+
+/* number of backlight levels */
+//#define BACKLIGHT_LEVELS 3
+
+/* 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 */
+#ifndef __ASSEMBLER__
+#include "matrix.h"
+#define IS_COMMAND() ( \
+ matrix_is_on(0, 0) && matrix_is_on(0, MATRIX_COLS - 1) \
+)
+#endif
+
+/* boot magic key */
+#define BOOTMAGIC_KEY_SALT KC_FN0
+
+/*
+ * 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/ghpad/keymap_4x6.c b/keyboard/ghpad/keymap_4x6.c
new file mode 100644
index 00000000..c70ff7a7
--- /dev/null
+++ b/keyboard/ghpad/keymap_4x6.c
@@ -0,0 +1,51 @@
+#include "keymap_common.h"
+
+// 4x6 Keypad
+#ifdef KEYMAP_SECTION_ENABLE
+const uint8_t keymaps[KEYMAPS_COUNT][MATRIX_ROWS][MATRIX_COLS] __attribute__ ((section (".keymap.keymaps"))) = {
+#else
+const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS] PROGMEM = {
+#endif
+ /* Keymap 0: Default Layer
+ * ,---------------.
+ * |Esc|Tab|= |Bs |
+ * |---+---+---+---|
+ * |Num|/ |* |- |
+ * |---+---+---+---|
+ * |7 |8 |9 |+ |
+ * |---+---+---| |
+ * |4 |5 |6 | |
+ * |---+---+---+---|
+ * |1 |2 |3 |Ent|
+ * |---+---+---| |
+ * |0 |. | |
+ * `---------------'
+ */
+ [0] = KEYMAP(
+ ESC, TAB, PEQL,BSPC, \
+ NLCK,PSLS,PAST,PMNS, \
+ P7, P8, P9, PPLS, \
+ P4, P5, P6, PENT, \
+ P1, P2, P3, PENT, \
+ P0, NO, PDOT,NO)
+};
+
+/*
+ * Fn action definition
+ */
+#ifdef KEYMAP_SECTION_ENABLE
+const uint16_t fn_actions[FN_ACTIONS_COUNT] __attribute__ ((section (".keymap.fn_actions"))) = {
+#else
+const uint16_t fn_actions[] PROGMEM = {
+#endif
+};
+
+#ifdef KEYMAP_EX_ENABLE
+uint16_t keys_count(void) {
+ return sizeof(keymaps) / sizeof(keymaps[0]) * MATRIX_ROWS * MATRIX_COLS;
+}
+
+uint16_t fn_actions_count(void) {
+ return sizeof(fn_actions) / sizeof(fn_actions[0]);
+}
+#endif
diff --git a/keyboard/ghpad/keymap_4x6_backlight.c b/keyboard/ghpad/keymap_4x6_backlight.c
new file mode 100644
index 00000000..e2359034
--- /dev/null
+++ b/keyboard/ghpad/keymap_4x6_backlight.c
@@ -0,0 +1,54 @@
+#include "keymap_common.h"
+
+// 4x6 Keypad
+#ifdef KEYMAP_SECTION_ENABLE
+const uint8_t keymaps[KEYMAPS_COUNT][MATRIX_ROWS][MATRIX_COLS] __attribute__ ((section (".keymap.keymaps"))) = {
+#else
+const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS] PROGMEM = {
+#endif
+ /* Keymap 0: Default Layer
+ * ,---------------.
+ * |Esc|Fn0|Fn1|Fn2|
+ * |---+---+---+---|
+ * |Num|/ |* |- |
+ * |---+---+---+---|
+ * |7 |8 |9 |+ |
+ * |---+---+---| |
+ * |4 |5 |6 | |
+ * |---+---+---+---|
+ * |1 |2 |3 |Ent|
+ * |---+---+---| |
+ * |0 |. | |
+ * `---------------'
+ */
+ [0] = KEYMAP(
+ ESC, FN0, FN1, FN2, \
+ NLCK,PSLS,PAST,PMNS, \
+ P7, P8, P9, PPLS, \
+ P4, P5, P6, PENT, \
+ P1, P2, P3, PENT, \
+ P0, NO, PDOT,NO)
+};
+
+/*
+ * Fn action definition
+ */
+#ifdef KEYMAP_SECTION_ENABLE
+const uint16_t fn_actions[FN_ACTIONS_COUNT] __attribute__ ((section (".keymap.fn_actions"))) = {
+#else
+const uint16_t fn_actions[] PROGMEM = {
+#endif
+ [0] = ACTION_BACKLIGHT_TOGGLE(),
+ [1] = ACTION_BACKLIGHT_DECREASE(),
+ [2] = ACTION_BACKLIGHT_INCREASE()
+};
+
+#ifdef KEYMAP_EX_ENABLE
+uint16_t keys_count(void) {
+ return sizeof(keymaps) / sizeof(keymaps[0]) * MATRIX_ROWS * MATRIX_COLS;
+}
+
+uint16_t fn_actions_count(void) {
+ return sizeof(fn_actions) / sizeof(fn_actions[0]);
+}
+#endif
diff --git a/keyboard/ghpad/keymap_arrow.c b/keyboard/ghpad/keymap_arrow.c
new file mode 100644
index 00000000..0bf98ed6
--- /dev/null
+++ b/keyboard/ghpad/keymap_arrow.c
@@ -0,0 +1,62 @@
+#include "keymap_common.h"
+
+// Keypad with Arrow
+#ifdef KEYMAP_SECTION_ENABLE
+const uint8_t keymaps[KEYMAPS_COUNT][MATRIX_ROWS][MATRIX_COLS] __attribute__ ((section (".keymap.keymaps"))) = {
+#else
+const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS] PROGMEM = {
+#endif
+ /* Keymap 0: Default Layer
+ * ,---------------.
+ * |Num|/ |* |- |
+ * |---+---+---+---|
+ * |7 |8 |9 |+ |
+ * |---+---+---| |
+ * |4 |5 |6 | |
+ * |---+---+---+---|
+ * |1 |2 |3 |Ent|
+ * |---+---+---| |
+ * |0 |Up |. | |
+ * |---+---+---+---|
+ * |Lef|Dow|Rig|Fn0|
+ * `---------------'
+ */
+ [0] = KEYMAP(
+ NLCK,PSLS,PAST,PMNS, \
+ P7, P8, P9, PPLS, \
+ P4, P5, P6, NO, \
+ P1, P2, P3, PENT, \
+ P0, UP, PDOT,NO, \
+ LEFT,DOWN,RGHT,FN0),
+ /* Keymap 1: */
+ [1] = KEYMAP(
+ TRNS,TRNS,TRNS,TRNS, \
+ TRNS,TRNS,TRNS,TRNS, \
+ TRNS,TRNS,TRNS,TRNS, \
+ TRNS,TRNS,TRNS,TRNS, \
+ TRNS,TRNS,TRNS,TRNS, \
+ FN1, TRNS,FN2, TRNS),
+};
+
+/*
+ * Fn action definition
+ */
+#ifdef KEYMAP_SECTION_ENABLE
+const uint16_t fn_actions[FN_ACTIONS_COUNT] __attribute__ ((section (".keymap.fn_actions"))) = {
+#else
+const uint16_t fn_actions[] PROGMEM = {
+#endif
+ [0] = ACTION_LAYER_MOMENTARY(1),
+ [1] = ACTION_BACKLIGHT_DECREASE(),
+ [2] = ACTION_BACKLIGHT_INCREASE()
+};
+
+#ifdef KEYMAP_EX_ENABLE
+uint16_t keys_count(void) {
+ return sizeof(keymaps) / sizeof(keymaps[0]) * MATRIX_ROWS * MATRIX_COLS;
+}
+
+uint16_t fn_actions_count(void) {
+ return sizeof(fn_actions) / sizeof(fn_actions[0]);
+}
+#endif
diff --git a/keyboard/ghpad/keymap_common.c b/keyboard/ghpad/keymap_common.c
new file mode 100644
index 00000000..ae934eea
--- /dev/null
+++ b/keyboard/ghpad/keymap_common.c
@@ -0,0 +1,49 @@
+/*
+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, key_t key)
+{
+#ifndef KEYMAP_EX_ENABLE
+ return pgm_read_byte(&keymaps[(layer)][(key.row)][(key.col)]);
+#else
+ return eeconfig_read_keymap_key(layer, key.row, key.col);
+#endif
+}
+
+/* translates Fn keycode to action */
+action_t keymap_fn_to_action(uint8_t keycode)
+{
+ return (action_t) {
+#ifndef KEYMAP_EX_ENABLE
+ .code = pgm_read_word(&fn_actions[FN_INDEX(keycode)])
+#else
+ .code = eeconfig_read_keymap_fn_action(FN_INDEX(keycode))
+#endif
+ };
+}
+
+#ifdef KEYMAP_EX_ENABLE
+const uint8_t* keymaps_pointer(void) {
+ return (const uint8_t*)keymaps;
+}
+
+const uint16_t* fn_actions_pointer(void) {
+ return fn_actions;
+}
+#endif
diff --git a/keyboard/ghpad/keymap_common.h b/keyboard/ghpad/keymap_common.h
new file mode 100644
index 00000000..32f4019f
--- /dev/null
+++ b/keyboard/ghpad/keymap_common.h
@@ -0,0 +1,54 @@
+/*
+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"
+#include "keymap_ex.h"
+
+extern const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS];
+extern const uint16_t fn_actions[];
+
+/* GHPad keymap definition macro
+ */
+#define KEYMAP( \
+ K0A, K0B, K0C, K0D, \
+ K1A, K1B, K1C, K1D, \
+ K2A, K2B, K2C, K2D, \
+ K3A, K3B, K3C, K3D, \
+ K4A, K4B, K4C, K4D, \
+ K5A, K5B, K5C, K5D \
+) { \
+ { KC_##K0A, KC_##K0B, KC_##K0C, KC_##K0D }, \
+ { KC_##K1A, KC_##K1B, KC_##K1C, KC_##K1D }, \
+ { KC_##K2A, KC_##K2B, KC_##K2C, KC_##K2D }, \
+ { KC_##K3A, KC_##K3B, KC_##K3C, KC_##K3D }, \
+ { KC_##K4A, KC_##K4B, KC_##K4C, KC_##K4D }, \
+ { KC_##K5A, KC_##K5B, KC_##K5C, KC_##K5D } \
+}
+
+#endif
diff --git a/keyboard/ghpad/keymap_redscarf.c b/keyboard/ghpad/keymap_redscarf.c
new file mode 100644
index 00000000..0bf8c591
--- /dev/null
+++ b/keyboard/ghpad/keymap_redscarf.c
@@ -0,0 +1,52 @@
+#include "keymap_common.h"
+
+// 4x6 Keypad
+#ifdef KEYMAP_SECTION_ENABLE
+const uint8_t keymaps[KEYMAPS_COUNT][MATRIX_ROWS][MATRIX_COLS] __attribute__ ((section (".keymap.keymaps"))) = {
+#else
+const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS] PROGMEM = {
+#endif
+ /* Keymap 0: Default Layer
+ * ,---------------.
+ * |Esc|F5 |Fn0|BS |
+ * |---+---+---+---|
+ * |Num|/ |* |- |
+ * |---+---+---+---|
+ * |7 |8 |9 |+ |
+ * |---+---+---| |
+ * |4 |5 |6 | |
+ * |---+---+---+---|
+ * |1 |2 |3 |Ent|
+ * |---+---+---| |
+ * |0 |. | |
+ * `---------------'
+ */
+ [0] = KEYMAP(
+ ESC, F5, FN0, BSPC, \
+ NLCK,PSLS,PAST,PMNS, \
+ P7, P8, P9, PPLS, \
+ P4, P5, P6, PENT, \
+ P1, P2, P3, PENT, \
+ P0, NO, PDOT,NO)
+};
+
+/*
+ * Fn action definition
+ */
+#ifdef KEYMAP_SECTION_ENABLE
+const uint16_t fn_actions[FN_ACTIONS_COUNT] __attribute__ ((section (".keymap.fn_actions"))) = {
+#else
+const uint16_t fn_actions[] PROGMEM = {
+#endif
+ [0] = ACTION_BACKLIGHT_STEP(),
+};
+
+#ifdef KEYMAP_EX_ENABLE
+uint16_t keys_count(void) {
+ return sizeof(keymaps) / sizeof(keymaps[0]) * MATRIX_ROWS * MATRIX_COLS;
+}
+
+uint16_t fn_actions_count(void) {
+ return sizeof(fn_actions) / sizeof(fn_actions[0]);
+}
+#endif
diff --git a/keyboard/ghpad/led.c b/keyboard/ghpad/led.c
new file mode 100644
index 00000000..04104fb7
--- /dev/null
+++ b/keyboard/ghpad/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)
+{
+ // disable JTAG
+ MCUCR = (1<event;
- tap_t tap = record->tap;
-
switch (id) {
- case LSHIFT_PAREN:
- if (tap.count > 0 && !tap.interrupted) {
- return (event.pressed ?
- MACRO( D(LSHIFT), D(9), U(9), U(LSHIFT), END ) : MACRO_NONE);
- } else {
- return (event.pressed ?
- MACRO( D(LSHIFT), END ) : MACRO( U(LSHIFT), END ) );
- }
- case RSHIFT_PAREN:
- if (tap.count > 0 && !tap.interrupted) {
- return (event.pressed ?
- MACRO( D(RSHIFT), D(0), U(0), U(RSHIFT), END ) : MACRO_NONE);
- } else {
- return (event.pressed ?
- MACRO( D(RSHIFT), END ) : MACRO( U(RSHIFT), END ) );
- }
case HELLO:
- return (event.pressed ?
+ return (record->event.pressed ?
MACRO( I(0), T(H), T(E), T(L), T(L), W(255), T(O), END ) :
MACRO_NONE );
case VOLUP:
- return (event.pressed ?
+ return (record->event.pressed ?
MACRO( D(VOLU), U(VOLU), END ) :
MACRO_NONE );
}
@@ -216,48 +191,36 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
*/
void action_function(keyrecord_t *record, uint8_t id, uint8_t opt)
{
- keyevent_t event = record->event;
- tap_t tap = record->tap;
+ if (record->event.pressed) dprint("P"); else dprint("R");
+ dprintf("%d", record->tap.count);
+ if (record->tap.interrupted) dprint("i");
+ dprint("\n");
switch (id) {
case LSHIFT_LPAREN:
- // LShft + tap '('
- // NOTE: cant use register_code to avoid conflicting with magic key bind
- if (event.pressed) {
- if (tap.count == 0 || tap.interrupted) {
- //add_mods(MOD_BIT(KC_LSHIFT));
- layer_on(1);
+ // Shift parentheses example: LShft + tap '('
+ // http://stevelosh.com/blog/2012/10/a-modern-space-cadet/#shift-parentheses
+ // http://geekhack.org/index.php?topic=41989.msg1304899#msg1304899
+ if (record->event.pressed) {
+ if (record->tap.count > 0 && !record->tap.interrupted) {
+ if (record->tap.interrupted) {
+ dprint("tap interrupted\n");
+ register_mods(MOD_BIT(KC_LSHIFT));
+ }
} else {
- add_mods(MOD_BIT(KC_LSHIFT));
- add_key(KC_9);
- send_keyboard_report();
- del_mods(MOD_BIT(KC_LSHIFT));
- del_key(KC_9);
- send_keyboard_report();
+ register_mods(MOD_BIT(KC_LSHIFT));
}
} else {
- if (tap.count == 0 || tap.interrupted) {
- //del_mods(MOD_BIT(KC_LSHIFT));
- layer_off(1);
- }
- }
- break;
- case RSHIFT_RPAREN:
- // RShift + tap ')'
- if (event.pressed) {
- if (tap.count == 0 || tap.interrupted) {
- add_mods(MOD_BIT(KC_RSHIFT));
+ if (record->tap.count > 0 && !(record->tap.interrupted)) {
+ add_weak_mods(MOD_BIT(KC_LSHIFT));
+ send_keyboard_report();
+ register_code(KC_9);
+ unregister_code(KC_9);
+ del_weak_mods(MOD_BIT(KC_LSHIFT));
+ send_keyboard_report();
+ record->tap.count = 0; // ad hoc: cancel tap
} else {
- add_mods(MOD_BIT(KC_RSHIFT));
- add_key(KC_0);
- send_keyboard_report();
- del_mods(MOD_BIT(KC_RSHIFT));
- del_key(KC_0);
- send_keyboard_report();
- }
- } else {
- if (tap.count == 0 || tap.interrupted) {
- del_mods(MOD_BIT(KC_RSHIFT));
+ unregister_mods(MOD_BIT(KC_LSHIFT));
}
}
break;
diff --git a/keyboard/lightsaber/Makefile.lufa b/keyboard/lightsaber/Makefile.lufa
new file mode 100644
index 00000000..b430efd2
--- /dev/null
+++ b/keyboard/lightsaber/Makefile.lufa
@@ -0,0 +1,126 @@
+#----------------------------------------------------------------------------
+# 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 = lightsaber_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 \
+ backlight.c
+
+CONFIG_H = config.h
+
+
+# MCU name
+MCU = atmega32u4
+
+# Processor frequency.
+# This will define a symbol, F_CPU, in all source code files equal to the
+# processor frequency in Hz. You can then use this symbol in your source code to
+# calculate timings. Do NOT tack on a 'UL' at the end, this will be done
+# automatically to create a 32-bit value in your source code.
+#
+# This will be an integer division of F_USB below, as it is sourced by
+# F_USB after it has run through any CPU prescalers. Note that this value
+# does not *change* the processor frequency - it should merely be updated to
+# reflect the processor speed set externally so that the code can use accurate
+# software delays.
+F_CPU = 8000000
+
+
+#
+# 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
+BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality
+
+
+# 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
+
+winkey: OPT_DEFS += -DLAYOUT_WINKEY
+winkey: all
diff --git a/keyboard/lightsaber/Makefile.pjrc b/keyboard/lightsaber/Makefile.pjrc
new file mode 100644
index 00000000..58735a7e
--- /dev/null
+++ b/keyboard/lightsaber/Makefile.pjrc
@@ -0,0 +1,94 @@
+#----------------------------------------------------------------------------
+# 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 = lightsaber_pjrc
+
+# Directory common source filess exist
+TOP_DIR = ../..
+
+# Directory keyboard dependent files exist
+TARGET_DIR = .
+
+# keyboard dependent files
+SRC = keymap.c \
+ matrix.c \
+ led.c \
+ backlight.c
+
+CONFIG_H = config.h
+
+
+# MCU name
+MCU = atmega32u4
+
+
+# Processor frequency.
+# Normally the first thing your program should do is set the clock prescaler,
+# so your program will run at the correct speed. You should also set this
+# variable to same clock speed. The _delay_ms() macro uses this, and many
+# examples use this variable to calculate timings. Do not add a "UL" here.
+F_CPU = 8000000
+
+
+# Build Options
+# comment out to disable the options.
+#
+BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration(+1000)
+#MOUSEKEY_ENABLE = yes # Mouse keys(+5000)
+EXTRAKEY_ENABLE = yes # Audio control and System control(+600)
+CONSOLE_ENABLE = yes # Console for debug
+COMMAND_ENABLE = yes # Commands for debug and configuration
+#SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend
+#NKRO_ENABLE = yes # USB Nkey Rollover(+500)
+#PS2_MOUSE_ENABLE = yes # PS/2 mouse(TrackPoint) support
+BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality
+
+
+# Search Path
+VPATH += $(TARGET_DIR)
+VPATH += $(TOP_DIR)
+
+include $(TOP_DIR)/protocol/pjrc.mk
+include $(TOP_DIR)/common.mk
+include $(TOP_DIR)/rules.mk
+
+winkey: OPT_DEFS += -DLAYOUT_WINKEY
+winkey: all
diff --git a/keyboard/lightsaber/README.md b/keyboard/lightsaber/README.md
new file mode 100644
index 00000000..9dcd6930
--- /dev/null
+++ b/keyboard/lightsaber/README.md
@@ -0,0 +1,26 @@
+Lightsaber keyboard firmware
+======================
+Korean custom keyboard designed by Duck.
+
+*Note that this is not the official firmware*
+
+Supported models
+----------------
+All pcb options are supported.
+
+
+Build
+-----
+Move to this directory then just run `make` like:
+
+ $ make -f Makefile.[pjrc|lufa]
+
+Use `Makefile.pjrc` if you want to use PJRC stack or use `Makefile.lufa` for LUFA stack.
+
+
+Bootloader
+---------
+The PCB is hardwired to run the bootloader if the key at the `one above backspace` position is held down when connecting the keyboard.
+
+It is still possible to use Boot Magic and Command to access the bootloader though.
+
diff --git a/keyboard/lightsaber/backlight.c b/keyboard/lightsaber/backlight.c
new file mode 100644
index 00000000..59b8b4a6
--- /dev/null
+++ b/keyboard/lightsaber/backlight.c
@@ -0,0 +1,86 @@
+/*
+Copyright 2014 Ralf Schmitt
+
+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 "backlight.h"
+
+/* Backlight pin configuration
+ *
+ * Alphas PB1 (high)
+ * Numeric PB2 (high)
+ * Mod+Num PB3 (high)
+ * Backside PD6 (high)
+ * TopRight PD7 (low)
+ * F-Row PE6 (high)
+ */
+
+void backlight_set(uint8_t level)
+{
+ // Set as output.
+ DDRB |= (1<<1) | (1<<2) | (1<<3);
+ DDRD |= (1<<6) | (1<<7);
+ DDRE |= (1<<6);
+
+ if (level & BACKLIGHT_ALPHA)
+ {
+ PORTB |= (1<<1);
+ }
+ else
+ {
+ PORTB &= ~(1<<1);
+ }
+ if (level & BACKLIGHT_NUMERIC)
+ {
+ PORTB |= (1<<2);
+ }
+ else
+ {
+ PORTB &= ~(1<<2);
+ }
+ if (level & BACKLIGHT_MODNUM)
+ {
+ PORTB |= (1<<3);
+ }
+ else
+ {
+ PORTB &= ~(1<<3);
+ }
+ if (level & BACKLIGHT_BACKSIDE)
+ {
+ PORTD |= (1<<6);
+ }
+ else
+ {
+ PORTD &= ~(1<<6);
+ }
+ if (level & BACKLIGHT_TOPRIGHT)
+ {
+ PORTD &= ~(1<<7);
+ }
+ else
+ {
+ PORTD |= (1<<7);
+ }
+ if (level & BACKLIGHT_FROW)
+ {
+ PORTE |= (1<<6);
+ }
+ else
+ {
+ PORTE &= ~(1<<6);
+ }
+}
diff --git a/keyboard/lightsaber/backlight.h b/keyboard/lightsaber/backlight.h
new file mode 100644
index 00000000..6dc7967a
--- /dev/null
+++ b/keyboard/lightsaber/backlight.h
@@ -0,0 +1,9 @@
+
+enum backlight_level {
+ BACKLIGHT_ALPHA = 0b0000001,
+ BACKLIGHT_NUMERIC = 0b0000010,
+ BACKLIGHT_MODNUM = 0b0000100,
+ BACKLIGHT_BACKSIDE = 0b0001000,
+ BACKLIGHT_TOPRIGHT = 0b0010000,
+ BACKLIGHT_FROW = 0b0100000,
+};
diff --git a/keyboard/lightsaber/config.h b/keyboard/lightsaber/config.h
new file mode 100644
index 00000000..d971d038
--- /dev/null
+++ b/keyboard/lightsaber/config.h
@@ -0,0 +1,46 @@
+/*
+Copyright 2013 Mathias Andersson
+
+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 0x6050
+#define DEVICE_VER 0x0104
+#define MANUFACTURER Duck
+#define PRODUCT Lightsaber
+
+/* message strings */
+#define DESCRIPTION t.m.k. keyboard firmware for Lightsaber
+
+/* matrix size */
+#define MATRIX_ROWS 6
+#define MATRIX_COLS 18
+
+/* number of backlight levels */
+#define BACKLIGHT_LEVELS 1
+
+/* 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
diff --git a/keyboard/lightsaber/keymap.c b/keyboard/lightsaber/keymap.c
new file mode 100644
index 00000000..398e51ec
--- /dev/null
+++ b/keyboard/lightsaber/keymap.c
@@ -0,0 +1,77 @@
+/*
+Copyright 2014 Ralf Schmitt
+
+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 .
+*/
+
+/*
+ * Keymap for Lightsaber controller
+ */
+#include
+#include
+#include
+#include "keycode.h"
+#include "action.h"
+#include "action_macro.h"
+#include "report.h"
+#include "host.h"
+#include "debug.h"
+#include "keymap.h"
+
+// Convert physical keyboard layout to matrix array.
+// This is a macro to define keymap easily in keyboard layout form.
+#define KEYMAP( \
+ K5A, K5B, K5C, K5D, K5E, K5F, K5G, K5H, K5I, K5J, K5K, K5L, K5M, K5N, K5O, K5P, K5Q, K5R, \
+ K4A, K4B, K4C, K4D, K4E, K4F, K4G, K4H, K4I, K4J, K4K, K4L, K4M, K4N, K4O, K4P, K4Q, K4R, \
+ K3A, K3B, K3C, K3D, K3E, K3F, K3G, K3H, K3I, K3J, K3K, K3L, K3M, K3N, K3O, K3P, K3Q, K3R, \
+ K2A, K2B, K2C, K2D, K2E, K2F, K2G, K2H, K2I, K2J, K2K, K2L, K2M, K2N, K2O, K2P, K2Q, K2R, \
+ K1A, K1C, K1D, K1E, K1F, K1G, K1H, K1I, K1J, K1K, K1L, K1M, K1N, K1O, K1P, K1Q, K1R, \
+ K0A, K0B, K0C, K0G, K0K, K0L, K0M, K0N, K0O, K0P, K0Q, K0R \
+) { \
+/* 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 */ \
+/* 5 */ { KC_##K5A, KC_##K5B, KC_##K5C, KC_##K5D, KC_##K5E, KC_##K5F, KC_##K5G, KC_##K5H, KC_##K5I, KC_##K5J, KC_##K5K, KC_##K5L, KC_##K5M, KC_##K5N, KC_##K5O, KC_##K5P, KC_##K5Q, KC_##K5R}, \
+/* 4 */ { KC_##K4A, KC_##K4B, KC_##K4C, KC_##K4D, KC_##K4E, KC_##K4F, KC_##K4G, KC_##K4H, KC_##K4I, KC_##K4J, KC_##K4K, KC_##K4L, KC_##K4M, KC_##K4N, KC_##K4O, KC_##K4P, KC_##K4Q, KC_##K4R}, \
+/* 3 */ { KC_##K3A, KC_##K3B, KC_##K3C, KC_##K3D, KC_##K3E, KC_##K3F, KC_##K3G, KC_##K3H, KC_##K3I, KC_##K3J, KC_##K3K, KC_##K3L, KC_##K3M, KC_##K3N, KC_##K3O, KC_##K3P, KC_##K3Q, KC_##K3R}, \
+/* 2 */ { KC_##K2A, KC_##K2B, KC_##K2C, KC_##K2D, KC_##K2E, KC_##K2F, KC_##K2G, KC_##K2H, KC_##K2I, KC_##K2J, KC_##K2K, KC_##K2L, KC_##K2M, KC_##K2N, KC_##K2O, KC_##K2P, KC_##K2Q, KC_##K2R}, \
+/* 1 */ { KC_##K1A, KC_##K1C, KC_##K1D, KC_##K1E, KC_##K1F, KC_##K1G, KC_##K1H, KC_##K1I, KC_##K1J, KC_##K1K, KC_##K1L, KC_NO, KC_##K1M, KC_##K1N, KC_##K1O, KC_##K1P, KC_##K1Q, KC_##K1R}, \
+/* 0 */ { KC_##K0A, KC_##K0B, KC_##K0C, KC_NO, KC_NO, KC_##K0G, KC_NO, KC_NO, KC_##K0K, KC_NO, KC_##K0L, KC_NO, KC_##K0M, KC_##K0N, KC_##K0O, KC_##K0P, KC_##K0Q, KC_##K0R} \
+}
+
+#include "keymap_winkey.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, key_t key)
+{
+ if (layer < KEYMAPS_SIZE) {
+ return pgm_read_byte(&keymaps[(layer)][(key.row)][(key.col)]);
+ } else {
+ // fall back to layer 0
+ return pgm_read_byte(&keymaps[0][(key.row)][(key.col)]);
+ }
+}
+
+/* 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;
+}
diff --git a/keyboard/lightsaber/keymap_winkey.h b/keyboard/lightsaber/keymap_winkey.h
new file mode 100644
index 00000000..3e836708
--- /dev/null
+++ b/keyboard/lightsaber/keymap_winkey.h
@@ -0,0 +1,29 @@
+#include "backlight.h"
+
+static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
+ KEYMAP(\
+ ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, DEL, INS, PSCR, SLCK, BRK, \
+ GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSPC, NUMLOCK,KP_SLASH,KP_ASTERISK,KP_MINUS, \
+ TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,BSLS, KP_7, KP_8, KP_9, KP_PLUS, \
+ CAPS,A, S, D, F, G, H, J, K, L, SCLN,QUOT,FN0, ENT, KP_4, KP_5, KP_6, NO, \
+ LSFT, Z, X, C, V, B, N, M, COMM,DOT, SLSH,NO, RSFT, KP_1, KP_2, KP_3, KP_ENTER, \
+ LCTL,LGUI,LALT, SPC, NO, RALT,RGUI,RCTL, KP_0, NO, KP_DOT, NO), \
+ KEYMAP(\
+ CALC,MYCM,WSCH,WHOM,MAIL,MUTE,VOLD,VOLU,MSEL,MSTP,MPLY,MPRV,MNXT,TRNS, TRNS, WAKE, PWR, SLEP, \
+ FN1, FN2, FN3, FN4, FN5, FN6, FN7, 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,PGDN,TRNS,LEFT,DOWN,UP ,RGHT,TRNS,TRNS,TRNS,TRNS, TRNS, TRNS, TRNS, TRNS, \
+ TRNS, TRNS,TRNS,TRNS,TRNS,PGUP,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] = ACTION_BACKLIGHT_TOGGLE(),
+ [2] = ACTION_BACKLIGHT_LEVEL(BACKLIGHT_ALPHA),
+ [3] = ACTION_BACKLIGHT_LEVEL(BACKLIGHT_MODNUM),
+ [4] = ACTION_BACKLIGHT_LEVEL(BACKLIGHT_NUMERIC),
+ [5] = ACTION_BACKLIGHT_LEVEL(BACKLIGHT_FROW),
+ [6] = ACTION_BACKLIGHT_LEVEL(BACKLIGHT_BACKSIDE),
+ [7] = ACTION_BACKLIGHT_LEVEL(BACKLIGHT_TOPRIGHT)
+};
diff --git a/keyboard/lightsaber/led.c b/keyboard/lightsaber/led.c
new file mode 100644
index 00000000..c3f85427
--- /dev/null
+++ b/keyboard/lightsaber/led.c
@@ -0,0 +1,54 @@
+/*
+Copyright 2014 Ralf Schmitt
+
+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"
+
+/* LED pin configuration
+ *
+ * Caps PB0 (low)
+ * NumLock PB4 (low)
+ *
+ */
+void led_set(uint8_t usb_led)
+{
+ // Set as output.
+ DDRB |= (1<<0) | (1<<4);
+
+ 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 .
+*/
+
+#include
+#include
+#include
+#include
+#include "print.h"
+#include "debug.h"
+#include "util.h"
+#include "matrix.h"
+
+
+#ifndef DEBOUNCE
+# define DEBOUNCE 0
+#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 uint8_t read_rows(void);
+static uint8_t read_fwkey(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();
+ // 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 col = 0; col < MATRIX_COLS; col++) { // 0-17
+ select_col(col);
+ _delay_us(3); // TODO: Determine the correct value needed here.
+ uint8_t rows = read_rows();
+ // Use the otherwise unused col: 12 row: 3 for firmware.
+ if(col == 12) {
+ rows |= read_fwkey();
+ }
+ for (uint8_t row = 0; row < MATRIX_ROWS; row++) { // 0-5
+ bool prev_bit = matrix_debouncing[row] & ((matrix_row_t)1< 4
+# error "Endpoints are not available enough to support all functions. Remove some in Makefile.(MOUSEKEY, EXTRAKEY, CONSOLE, NKRO)"
+# endif
#endif
@@ -159,4 +163,14 @@ uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
const void** const DescriptorAddress)
ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3);
+
+/* new API */
+#if LUFA_VERSION_INTEGER < 0x140302
+ #undef VERSION_BCD
+ #define VERSION_BCD(Major, Minor, Revision) \
+ CPU_TO_LE16( ((Major & 0xFF) << 8) | \
+ ((Minor & 0x0F) << 4) | \
+ (Revision & 0x0F) )
+#endif
+
#endif
diff --git a/protocol/lufa/lufa.c b/protocol/lufa/lufa.c
index eca51c87..d60aecc3 100644
--- a/protocol/lufa/lufa.c
+++ b/protocol/lufa/lufa.c
@@ -52,8 +52,8 @@
#include "descriptor.h"
#include "lufa.h"
-static uint8_t idle_duration = 0;
-static uint8_t protocol_report = 1;
+uint8_t keyboard_idle = 0;
+uint8_t keyboard_protocol = 1;
static uint8_t keyboard_led_stats = 0;
static report_keyboard_t keyboard_report_sent;
@@ -184,15 +184,6 @@ void EVENT_USB_Device_StartOfFrame(void)
/** Event handler for the USB_ConfigurationChanged event.
* This is fired when the host sets the current configuration of the USB device after enumeration.
*/
-#if LUFA_VERSION_INTEGER < 0x120730
- /* old API 120219 */
- #define ENDPOINT_CONFIG(epnum, eptype, epdir, epsize, epbank) Endpoint_ConfigureEndpoint(epnum, eptype, epdir, epsize, epbank)
-#else
- /* new API >= 120730 */
- #define ENDPOINT_BANK_SINGLE 1
- #define ENDPOINT_BANK_DOUBLE 2
- #define ENDPOINT_CONFIG(epnum, eptype, epdir, epsize, epbank) Endpoint_ConfigureEndpoint((epdir) | (epnum) , eptype, epsize, epbank)
-#endif
void EVENT_USB_Device_ConfigurationChanged(void)
{
bool ConfigSuccess = true;
@@ -217,9 +208,11 @@ void EVENT_USB_Device_ConfigurationChanged(void)
/* Setup Console HID Report Endpoints */
ConfigSuccess &= ENDPOINT_CONFIG(CONSOLE_IN_EPNUM, EP_TYPE_INTERRUPT, ENDPOINT_DIR_IN,
CONSOLE_EPSIZE, ENDPOINT_BANK_DOUBLE);
+#if 0
ConfigSuccess &= ENDPOINT_CONFIG(CONSOLE_OUT_EPNUM, EP_TYPE_INTERRUPT, ENDPOINT_DIR_OUT,
CONSOLE_EPSIZE, ENDPOINT_BANK_SINGLE);
#endif
+#endif
#ifdef NKRO_ENABLE
/* Setup NKRO HID Report Endpoints */
@@ -279,6 +272,7 @@ void EVENT_USB_Device_ControlRequest(void)
// Interface
switch (USB_ControlRequest.wIndex) {
case KEYBOARD_INTERFACE:
+ case NKRO_INTERFACE:
Endpoint_ClearSETUP();
while (!(Endpoint_IsOUTReceived())) {
@@ -299,21 +293,29 @@ void EVENT_USB_Device_ControlRequest(void)
case HID_REQ_GetProtocol:
if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE))
{
- Endpoint_ClearSETUP();
- while (!(Endpoint_IsINReady()));
- Endpoint_Write_8(protocol_report);
- Endpoint_ClearIN();
- Endpoint_ClearStatusStage();
+ if (USB_ControlRequest.wIndex == KEYBOARD_INTERFACE) {
+ Endpoint_ClearSETUP();
+ while (!(Endpoint_IsINReady()));
+ Endpoint_Write_8(keyboard_protocol);
+ Endpoint_ClearIN();
+ Endpoint_ClearStatusStage();
+ }
}
break;
case HID_REQ_SetProtocol:
if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE))
{
- Endpoint_ClearSETUP();
- Endpoint_ClearStatusStage();
+ if (USB_ControlRequest.wIndex == KEYBOARD_INTERFACE) {
+ Endpoint_ClearSETUP();
+ Endpoint_ClearStatusStage();
- protocol_report = ((USB_ControlRequest.wValue & 0xFF) != 0x00);
+ keyboard_protocol = ((USB_ControlRequest.wValue & 0xFF) != 0x00);
+#ifdef NKRO_ENABLE
+ keyboard_nkro = !!keyboard_protocol;
+#endif
+ clear_keyboard();
+ }
}
break;
@@ -323,7 +325,7 @@ void EVENT_USB_Device_ControlRequest(void)
Endpoint_ClearSETUP();
Endpoint_ClearStatusStage();
- idle_duration = ((USB_ControlRequest.wValue & 0xFF00) >> 8);
+ keyboard_idle = ((USB_ControlRequest.wValue & 0xFF00) >> 8);
}
break;
@@ -332,7 +334,7 @@ void EVENT_USB_Device_ControlRequest(void)
{
Endpoint_ClearSETUP();
while (!(Endpoint_IsINReady()));
- Endpoint_Write_8(idle_duration);
+ Endpoint_Write_8(keyboard_idle);
Endpoint_ClearIN();
Endpoint_ClearStatusStage();
}
@@ -351,7 +353,7 @@ static uint8_t keyboard_leds(void)
static void send_keyboard(report_keyboard_t *report)
{
- uint8_t timeout = 0;
+ uint8_t timeout = 255;
if (USB_DeviceState != DEVICE_STATE_Configured)
return;
@@ -359,26 +361,27 @@ static void send_keyboard(report_keyboard_t *report)
/* Select the Keyboard Report Endpoint */
#ifdef NKRO_ENABLE
if (keyboard_nkro) {
+ /* Report protocol - NKRO */
Endpoint_SelectEndpoint(NKRO_IN_EPNUM);
- }
- else
-#endif
- {
- Endpoint_SelectEndpoint(KEYBOARD_IN_EPNUM);
- }
- /* Check if Keyboard Endpoint Ready for Read/Write */
- while (--timeout && !Endpoint_IsReadWriteAllowed()) ;
+ /* Check if write ready for a polling interval around 1ms */
+ while (timeout-- && !Endpoint_IsReadWriteAllowed()) _delay_us(4);
+ if (!Endpoint_IsReadWriteAllowed()) return;
- /* Write Keyboard Report Data */
-#ifdef NKRO_ENABLE
- if (keyboard_nkro) {
+ /* Write Keyboard Report Data */
Endpoint_Write_Stream_LE(report, NKRO_EPSIZE, NULL);
}
else
#endif
{
- /* boot mode */
+ /* Boot protocol */
+ Endpoint_SelectEndpoint(KEYBOARD_IN_EPNUM);
+
+ /* Check if write ready for a polling interval around 10ms */
+ while (timeout-- && !Endpoint_IsReadWriteAllowed()) _delay_us(40);
+ if (!Endpoint_IsReadWriteAllowed()) return;
+
+ /* Write Keyboard Report Data */
Endpoint_Write_Stream_LE(report, KEYBOARD_EPSIZE, NULL);
}
@@ -391,7 +394,7 @@ static void send_keyboard(report_keyboard_t *report)
static void send_mouse(report_mouse_t *report)
{
#ifdef MOUSE_ENABLE
- uint8_t timeout = 0;
+ uint8_t timeout = 255;
if (USB_DeviceState != DEVICE_STATE_Configured)
return;
@@ -399,8 +402,9 @@ static void send_mouse(report_mouse_t *report)
/* Select the Mouse Report Endpoint */
Endpoint_SelectEndpoint(MOUSE_IN_EPNUM);
- /* Check if Mouse Endpoint Ready for Read/Write */
- while (--timeout && !Endpoint_IsReadWriteAllowed()) ;
+ /* Check if write ready for a polling interval around 10ms */
+ while (timeout-- && !Endpoint_IsReadWriteAllowed()) _delay_us(40);
+ if (!Endpoint_IsReadWriteAllowed()) return;
/* Write Mouse Report Data */
Endpoint_Write_Stream_LE(report, sizeof(report_mouse_t), NULL);
@@ -412,7 +416,7 @@ static void send_mouse(report_mouse_t *report)
static void send_system(uint16_t data)
{
- uint8_t timeout = 0;
+ uint8_t timeout = 255;
if (USB_DeviceState != DEVICE_STATE_Configured)
return;
@@ -422,14 +426,18 @@ static void send_system(uint16_t data)
.usage = data
};
Endpoint_SelectEndpoint(EXTRAKEY_IN_EPNUM);
- while (--timeout && !Endpoint_IsReadWriteAllowed()) ;
+
+ /* Check if write ready for a polling interval around 10ms */
+ while (timeout-- && !Endpoint_IsReadWriteAllowed()) _delay_us(40);
+ if (!Endpoint_IsReadWriteAllowed()) return;
+
Endpoint_Write_Stream_LE(&r, sizeof(report_extra_t), NULL);
Endpoint_ClearIN();
}
static void send_consumer(uint16_t data)
{
- uint8_t timeout = 0;
+ uint8_t timeout = 255;
if (USB_DeviceState != DEVICE_STATE_Configured)
return;
@@ -439,7 +447,11 @@ static void send_consumer(uint16_t data)
.usage = data
};
Endpoint_SelectEndpoint(EXTRAKEY_IN_EPNUM);
- while (--timeout && !Endpoint_IsReadWriteAllowed()) ;
+
+ /* Check if write ready for a polling interval around 10ms */
+ while (timeout-- && !Endpoint_IsReadWriteAllowed()) _delay_us(40);
+ if (!Endpoint_IsReadWriteAllowed()) return;
+
Endpoint_Write_Stream_LE(&r, sizeof(report_extra_t), NULL);
Endpoint_ClearIN();
}
diff --git a/protocol/lufa/lufa.h b/protocol/lufa/lufa.h
index bcee060d..195123c0 100644
--- a/protocol/lufa/lufa.h
+++ b/protocol/lufa/lufa.h
@@ -66,4 +66,15 @@ typedef struct {
uint16_t usage;
} __attribute__ ((packed)) report_extra_t;
+
+#if LUFA_VERSION_INTEGER < 0x120730
+ /* old API 120219 */
+ #define ENDPOINT_CONFIG(epnum, eptype, epdir, epsize, epbank) Endpoint_ConfigureEndpoint(epnum, eptype, epdir, epsize, epbank)
+#else
+ /* new API >= 120730 */
+ #define ENDPOINT_BANK_SINGLE 1
+ #define ENDPOINT_BANK_DOUBLE 2
+ #define ENDPOINT_CONFIG(epnum, eptype, epdir, epsize, epbank) Endpoint_ConfigureEndpoint((epdir) | (epnum) , eptype, epsize, epbank)
+#endif
+
#endif
diff --git a/protocol/pjrc/usb.c b/protocol/pjrc/usb.c
index 393b36f7..1e6ba871 100644
--- a/protocol/pjrc/usb.c
+++ b/protocol/pjrc/usb.c
@@ -38,6 +38,7 @@
#include "sleep_led.h"
#endif
#include "suspend.h"
+#include "action.h"
#include "action_util.h"
@@ -628,6 +629,7 @@ uint8_t usb_configured(void)
void usb_remote_wakeup(void)
{
UDCON |= (1<mods;
UEDATX = 0;
- uint8_t keys = usb_keyboard_protocol ? KBD_REPORT_KEYS : 6;
+ uint8_t keys = keyboard_protocol ? KBD_REPORT_KEYS : 6;
for (uint8_t i=0; ikeys[i];
}
@@ -901,13 +903,13 @@ ISR(USB_COM_vect)
}
if (bRequest == HID_GET_IDLE) {
usb_wait_in_ready();
- UEDATX = usb_keyboard_idle_config;
+ UEDATX = keyboard_idle;
usb_send_in();
return;
}
if (bRequest == HID_GET_PROTOCOL) {
usb_wait_in_ready();
- UEDATX = usb_keyboard_protocol;
+ UEDATX = keyboard_protocol;
usb_send_in();
return;
}
@@ -921,14 +923,18 @@ ISR(USB_COM_vect)
return;
}
if (bRequest == HID_SET_IDLE) {
- usb_keyboard_idle_config = (wValue >> 8);
+ keyboard_idle = (wValue >> 8);
usb_keyboard_idle_count = 0;
//usb_wait_in_ready();
usb_send_in();
return;
}
if (bRequest == HID_SET_PROTOCOL) {
- usb_keyboard_protocol = wValue;
+ keyboard_protocol = wValue;
+#ifdef NKRO_ENABLE
+ keyboard_nkro = !!keyboard_protocol;
+#endif
+ clear_keyboard();
//usb_wait_in_ready();
usb_send_in();
return;
diff --git a/protocol/pjrc/usb_keyboard.c b/protocol/pjrc/usb_keyboard.c
index de798fcc..d1683318 100644
--- a/protocol/pjrc/usb_keyboard.c
+++ b/protocol/pjrc/usb_keyboard.c
@@ -34,12 +34,12 @@
// protocol setting from the host. We use exactly the same report
// either way, so this variable only stores the setting since we
// are required to be able to report which setting is in use.
-uint8_t usb_keyboard_protocol=1;
+uint8_t keyboard_protocol=1;
// the idle configuration, how often we send the report to the
// host (ms * 4) even when it hasn't changed
// Windows and Linux set 0 while OS X sets 6(24ms) by SET_IDLE request.
-uint8_t usb_keyboard_idle_config=125;
+uint8_t keyobard_idle=125;
// count until idle timeout
uint8_t usb_keyboard_idle_count=0;
@@ -61,10 +61,7 @@ int8_t usb_keyboard_send_report(report_keyboard_t *report)
else
#endif
{
- if (usb_keyboard_protocol)
- result = send_report(report, KBD_ENDPOINT, 0, KBD_SIZE);
- else
- result = send_report(report, KBD_ENDPOINT, 0, 6);
+ result = send_report(report, KBD_ENDPOINT, 0, KBD_SIZE);
}
if (result) return result;
diff --git a/protocol/pjrc/usb_keyboard.h b/protocol/pjrc/usb_keyboard.h
index c362ca3b..9b798e9a 100644
--- a/protocol/pjrc/usb_keyboard.h
+++ b/protocol/pjrc/usb_keyboard.h
@@ -30,8 +30,6 @@
#include "host.h"
-extern uint8_t usb_keyboard_protocol;
-extern uint8_t usb_keyboard_idle_config;
extern uint8_t usb_keyboard_idle_count;
extern volatile uint8_t usb_keyboard_leds;
diff --git a/protocol/ps2.h b/protocol/ps2.h
index 483eea72..703e0c27 100644
--- a/protocol/ps2.h
+++ b/protocol/ps2.h
@@ -90,6 +90,7 @@ uint8_t ps2_host_send(uint8_t data);
uint8_t ps2_host_recv_response(void);
uint8_t ps2_host_recv(void);
void ps2_host_set_led(uint8_t usb_led);
+uint8_t ps2_enabled(void);
/* Check port settings for clock and data line */