aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortmk <nobody@nowhere>2013-03-12 01:07:06 +0900
committertmk <nobody@nowhere>2013-03-12 10:43:02 +0900
commit92b92dd78f5488981244d353f2d500ad9d82fc49 (patch)
treed0d1a061fd8dd7e8ff07ce63f8493618c30f9031
parent8b9bd51d3a13959a4d59fdbc819a033cd8b0a3ce (diff)
downloadqmk_firmware-92b92dd78f5488981244d353f2d500ad9d82fc49.tar.gz
qmk_firmware-92b92dd78f5488981244d353f2d500ad9d82fc49.zip
Add mechanical locking switch support for CapsLock
-rw-r--r--common/action.c30
-rw-r--r--common/keyboard.c1
-rw-r--r--common/keycode.h1
-rw-r--r--keyboard/gh60/config.h24
4 files changed, 38 insertions, 18 deletions
diff --git a/common/action.c b/common/action.c
index 15e125a3e..4fafbfa79 100644
--- a/common/action.c
+++ b/common/action.c
@@ -23,6 +23,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
23#include "command.h" 23#include "command.h"
24#include "util.h" 24#include "util.h"
25#include "debug.h" 25#include "debug.h"
26#include "led.h"
26#include "layer_switch.h" 27#include "layer_switch.h"
27#include "action_macro.h" 28#include "action_macro.h"
28#include "action.h" 29#include "action.h"
@@ -889,6 +890,18 @@ void register_code(uint8_t code)
889 if (code == KC_NO) { 890 if (code == KC_NO) {
890 return; 891 return;
891 } 892 }
893#ifdef CAPSLOCK_LOCKING_ENABLE
894 else if (KC_LOCKING_CAPS == code) {
895#ifdef CAPSLOCK_LOCKING_RESYNC_ENABLE
896 // Resync: ignore if caps lock already is on
897 if (host_keyboard_leds() & (1<<USB_LED_CAPS_LOCK)) return;
898#endif
899 host_add_key(KC_CAPSLOCK);
900 host_send_keyboard_report();
901 host_del_key(KC_CAPSLOCK);
902 host_send_keyboard_report();
903 }
904#endif
892 else if IS_KEY(code) { 905 else if IS_KEY(code) {
893 // TODO: should push command_proc out of this block? 906 // TODO: should push command_proc out of this block?
894 if (command_proc(code)) return; 907 if (command_proc(code)) return;
@@ -914,7 +927,22 @@ void register_code(uint8_t code)
914 927
915void unregister_code(uint8_t code) 928void unregister_code(uint8_t code)
916{ 929{
917 if IS_KEY(code) { 930 if (code == KC_NO) {
931 return;
932 }
933#ifdef CAPSLOCK_LOCKING_ENABLE
934 else if (KC_LOCKING_CAPS == code) {
935#ifdef CAPSLOCK_LOCKING_RESYNC_ENABLE
936 // Resync: ignore if caps lock already is off
937 if (!(host_keyboard_leds() & (1<<USB_LED_CAPS_LOCK))) return;
938#endif
939 host_add_key(KC_CAPSLOCK);
940 host_send_keyboard_report();
941 host_del_key(KC_CAPSLOCK);
942 host_send_keyboard_report();
943 }
944#endif
945 else if IS_KEY(code) {
918 host_del_key(code); 946 host_del_key(code);
919 host_send_keyboard_report(); 947 host_send_keyboard_report();
920 } 948 }
diff --git a/common/keyboard.c b/common/keyboard.c
index 401fdb4e1..42c57ac96 100644
--- a/common/keyboard.c
+++ b/common/keyboard.c
@@ -134,5 +134,6 @@ MATRIX_LOOP_END:
134 134
135void keyboard_set_leds(uint8_t leds) 135void keyboard_set_leds(uint8_t leds)
136{ 136{
137 if (debug_keyboard) { debug("keyboard_set_led: "); debug_hex8(leds); debug("\n"); }
137 led_set(leds); 138 led_set(leds);
138} 139}
diff --git a/common/keycode.h b/common/keycode.h
index 364679994..aea630846 100644
--- a/common/keycode.h
+++ b/common/keycode.h
@@ -81,6 +81,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
81#define KC_APP KC_APPLICATION 81#define KC_APP KC_APPLICATION
82#define KC_NUHS KC_NONUS_HASH 82#define KC_NUHS KC_NONUS_HASH
83#define KC_NUBS KC_NONUS_BSLASH 83#define KC_NUBS KC_NONUS_BSLASH
84#define KC_LCAP KC_LOCKING_CAPS
84#define KC_ERAS KC_ALT_ERASE, 85#define KC_ERAS KC_ALT_ERASE,
85#define KC_CLR KC_CLEAR 86#define KC_CLR KC_CLEAR
86/* Japanese specific */ 87/* Japanese specific */
diff --git a/keyboard/gh60/config.h b/keyboard/gh60/config.h
index cd98395eb..bd0a19c33 100644
--- a/keyboard/gh60/config.h
+++ b/keyboard/gh60/config.h
@@ -27,16 +27,21 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
27#define PRODUCT GH60 27#define PRODUCT GH60
28#define DESCRIPTION t.m.k. keyboard firmware for GH60 28#define DESCRIPTION t.m.k. keyboard firmware for GH60
29 29
30/* matrix size */ 30/* key matrix size */
31#define MATRIX_ROWS 5 31#define MATRIX_ROWS 5
32#define MATRIX_COLS 14 32#define MATRIX_COLS 14
33 33
34/* define if matrix has ghost */ 34/* define if matrix has ghost */
35//#define MATRIX_HAS_GHOST 35//#define MATRIX_HAS_GHOST
36 36
37/* Set 0 if need no debouncing */ 37/* Set 0 if debouncing isn't needed */
38#define DEBOUNCE 5 38#define DEBOUNCE 5
39 39
40/* Mechanical locking CapsLock support. Use KC_LCAP instead of KC_CAPS in keymap */
41#define CAPSLOCK_LOCKING_ENABLE
42/* Locking CapsLock resynchronize hack, which won't work on Linux */
43#define CAPSLOCK_LOCKING_RESYNC_ENABLE
44
40/* key combination for command */ 45/* key combination for command */
41#define IS_COMMAND() ( \ 46#define IS_COMMAND() ( \
42 keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \ 47 keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \
@@ -51,20 +56,5 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
51 */ 56 */
52#define BOOTLOADER_SIZE 4096 57#define BOOTLOADER_SIZE 4096
53 58
54/*
55 * Boot magic keys
56 * call some function by pressing key when pluging cable or powering on.
57 */
58/* key position on matrix(ROW:COL) */
59#define KEY_FN 0x4A
60#define KEY_D 0x23
61#define KEY_ESC 0x00
62#define KEY_IS_ON(key) matrix_is_on((key)>>4, (key)&0xF)
63/* kick up bootloader */
64#define IS_BOOTMAGIC_BOOTLOADER() KEY_IS_ON(KEY_FN)
65/* debug on */
66#define IS_BOOTMAGIC_DEBUG() KEY_IS_ON(KEY_D)
67/* eeprom clear */
68#define IS_BOOTMAGIC_EEPROM_CLEAR() KEY_IS_ON(KEY_ESC)
69 59
70#endif 60#endif