Fix Locking CapsLock support in ADB converter

master
tmk 2013-03-12 12:10:12 +09:00
parent c0137b4b32
commit c4ab832be0
5 changed files with 16 additions and 37 deletions

View File

@ -20,10 +20,7 @@ Build
LOCKING CAPSLOCK LOCKING CAPSLOCK
---------------- ----------------
Many old ADB keyboards have mechanical push-lock switch for Capslock key. This converter support the locking Capslock key by default. Many of old ADB keyboards have mechanical push-lock switch for Capslock key and this converter supports the locking Capslock key by default. See README in top directory for more detail about this feature.
This feature will prevent you from remaping as normal key. You can disable the feature by *commenting out* a macro in config.h like this:
//#define MATRIX_HAS_LOCKING_CAPS
Also you may want to remove locking pin from the push-lock switch to use capslock as a normal momentary switch. Also you may want to remove locking pin from the push-lock switch to use capslock as a normal momentary switch.
http://www.youtube.com/watch?v=9wqnt2mGJ2Y http://www.youtube.com/watch?v=9wqnt2mGJ2Y
@ -58,7 +55,7 @@ effort at this time.
ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR,SLCK,BRK, PWR, ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR,SLCK,BRK, PWR,
GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSPC, INS, HOME,PGUP, NLCK,EQL, PSLS,PAST, GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSPC, INS, HOME,PGUP, NLCK,EQL, PSLS,PAST,
TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,BSLS, DEL, END, PGDN, P7, P8, P9, PMNS, TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,BSLS, DEL, END, PGDN, P7, P8, P9, PMNS,
CAPS,A, S, D, F, G, H, J, K, L, SCLN,QUOT, ENT, P4, P5, P6, PPLS, LCAP,A, S, D, F, G, H, J, K, L, SCLN,QUOT, ENT, P4, P5, P6, PPLS,
LSFT,Z, X, C, V, B, N, M, COMM,DOT, SLSH, RSFT, UP, P1, P2, P3, LSFT,Z, X, C, V, B, N, M, COMM,DOT, SLSH, RSFT, UP, P1, P2, P3,
LCTL,LGUI,LALT, SPC, LEFT,DOWN,RGHT, P0, PDOT,PENT LCTL,LGUI,LALT, SPC, LEFT,DOWN,RGHT, P0, PDOT,PENT
), ),

View File

@ -32,13 +32,22 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define MATRIX_ROWS 16 // keycode bit: 3-0 #define MATRIX_ROWS 16 // keycode bit: 3-0
#define MATRIX_COLS 8 // keycode bit: 6-4 #define MATRIX_COLS 8 // keycode bit: 6-4
/* Locking Caps Lock support */
#define MATRIX_HAS_LOCKING_CAPS
#define MATRIX_ROW(code) ((code)>>3&0x0F) #define MATRIX_ROW(code) ((code)>>3&0x0F)
#define MATRIX_COL(code) ((code)&0x07) #define MATRIX_COL(code) ((code)&0x07)
/* Locking Caps Lock support */
//#define MATRIX_HAS_LOCKING_CAPS
/* Mechanical locking CapsLock support. Use KC_LCAP instead of KC_CAPS in keymap */
#define CAPSLOCK_LOCKING_ENABLE
/* Locking CapsLock resynchronize hack */
#define CAPSLOCK_LOCKING_RESYNC_ENABLE
/* legacy keymap support */
#define USE_LEGACY_KEYMAP
/* mouse keys */ /* mouse keys */
#ifdef MOUSEKEY_ENABLE #ifdef MOUSEKEY_ENABLE
# define MOUSEKEY_DELAY_TIME 192 # define MOUSEKEY_DELAY_TIME 192

View File

@ -155,7 +155,7 @@ static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR,SLCK,PAUS, PWR, ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR,SLCK,PAUS, PWR,
GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSPC, INS, HOME,PGUP, NLCK,PEQL,PSLS,PAST, GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSPC, INS, HOME,PGUP, NLCK,PEQL,PSLS,PAST,
TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,BSLS, DEL, END, PGDN, P7, P8, P9, PMNS, TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,BSLS, DEL, END, PGDN, P7, P8, P9, PMNS,
CAPS,A, S, D, F, G, H, J, K, L, SCLN,QUOT, ENT, P4, P5, P6, PPLS, LCAP,A, S, D, F, G, H, J, K, L, SCLN,QUOT, ENT, P4, P5, P6, PPLS,
LSFT,Z, X, C, V, B, N, M, COMM,DOT, SLSH, RSFT, UP, P1, P2, P3, LSFT,Z, X, C, V, B, N, M, COMM,DOT, SLSH, RSFT, UP, P1, P2, P3,
LCTL,LGUI,LALT, SPC, RGUI,RCTL, LEFT,DOWN,RGHT, P0, PDOT,PENT LCTL,LGUI,LALT, SPC, RGUI,RCTL, LEFT,DOWN,RGHT, P0, PDOT,PENT
), ),

View File

@ -25,8 +25,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "print.h" #include "print.h"
#include "util.h" #include "util.h"
#include "debug.h" #include "debug.h"
#include "host.h"
#include "led.h"
#include "adb.h" #include "adb.h"
#include "matrix.h" #include "matrix.h"
@ -38,8 +36,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
# error "MATRIX_ROWS must not exceed 255" # error "MATRIX_ROWS must not exceed 255"
#endif #endif
#define ADB_CAPS_UP (ADB_CAPS | 0x80)
static bool is_modified = false; static bool is_modified = false;
@ -98,12 +94,6 @@ uint8_t matrix_scan(void)
print("adb_host_kbd_recv: "); phex16(codes); print("\n"); print("adb_host_kbd_recv: "); phex16(codes); print("\n");
} }
#ifdef MATRIX_HAS_LOCKING_CAPS
// Send Caps key up event
if (matrix_is_on(MATRIX_ROW(ADB_CAPS), MATRIX_COL(ADB_CAPS))) {
register_key(ADB_CAPS_UP);
}
#endif
if (codes == 0) { // no keys if (codes == 0) { // no keys
return 0; return 0;
} else if (codes == 0x7F7F) { // power key press } else if (codes == 0x7F7F) { // power key press
@ -116,23 +106,6 @@ uint8_t matrix_scan(void)
for (uint8_t i=0; i < MATRIX_ROWS; i++) matrix[i] = 0x00; for (uint8_t i=0; i < MATRIX_ROWS; i++) matrix[i] = 0x00;
return key1; return key1;
} else { } else {
#ifdef MATRIX_HAS_LOCKING_CAPS
if (host_keyboard_leds() & (1<<USB_LED_CAPS_LOCK)) {
// Ignore LockingCaps key down event when CAPS LOCK is on
if (key0 == ADB_CAPS && (key1 == ADB_CAPS || key1 == 0xFF)) return 0;
if (key0 == ADB_CAPS) key0 = key1;
if (key1 == ADB_CAPS) key1 = 0xFF;
// Convert LockingCaps key up event into down event
if (key0 == ADB_CAPS_UP) key0 = ADB_CAPS;
if (key1 == ADB_CAPS_UP) key1 = ADB_CAPS;
} else {
// ADB_CAPS LOCK off:
// Ignore LockingCaps key up event when ADB_CAPS LOCK is off
if (key0 == ADB_CAPS_UP && (key1 == ADB_CAPS_UP || key1 == 0xFF)) return 0;
if (key0 == ADB_CAPS_UP) key0 = key1;
if (key1 == ADB_CAPS_UP) key1 = 0xFF;
}
#endif
register_key(key0); register_key(key0);
if (key1 != 0xFF) // key1 is 0xFF when no second key. if (key1 != 0xFF) // key1 is 0xFF when no second key.
register_key(key1); register_key(key1);

View File

@ -39,7 +39,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
/* Mechanical locking CapsLock support. Use KC_LCAP instead of KC_CAPS in keymap */ /* Mechanical locking CapsLock support. Use KC_LCAP instead of KC_CAPS in keymap */
#define CAPSLOCK_LOCKING_ENABLE #define CAPSLOCK_LOCKING_ENABLE
/* Locking CapsLock resynchronize hack, which won't work on Linux */ /* Locking CapsLock resynchronize hack */
#define CAPSLOCK_LOCKING_RESYNC_ENABLE #define CAPSLOCK_LOCKING_RESYNC_ENABLE
/* key combination for command */ /* key combination for command */