Переглянути джерело

Added locking capslock key support and default now.

tags/v1.9
tmk 12 роки тому
джерело
коміт
b703de7b29
2 змінених файлів з 34 додано та 0 видалено
  1. 3
    0
      adb_usb/config.h
  2. 31
    0
      adb_usb/matrix.c

+ 3
- 0
adb_usb/config.h Переглянути файл

#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



/* key combination for command */ /* key combination for command */
#define IS_COMMAND() ( \ #define IS_COMMAND() ( \

+ 31
- 0
adb_usb/matrix.c Переглянути файл

#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"


# error "MATRIX_ROWS must not exceed 255" # error "MATRIX_ROWS must not exceed 255"
#endif #endif


#define CAPS 0x39
#define CAPS_UP (CAPS | 0x80)
#define ROW(key) ((key)>>3&0x0F)
#define COL(key) ((key)&0x07)



static bool _matrix_is_modified = false; static bool _matrix_is_modified = false;


key0 = codes>>8; key0 = codes>>8;
key1 = codes&0xFF; key1 = codes&0xFF;


#ifdef MATRIX_HAS_LOCKING_CAPS
// Send Caps key up event
if (matrix_is_on(ROW(CAPS), COL(CAPS))) {
_matrix_is_modified = true;
_register_key(CAPS_UP);
}
#endif
if (codes == 0) { // no keys if (codes == 0) { // no keys
return 0; return 0;
} else if (key0 == 0xFF && key1 != 0xFF) { // error } else if (key0 == 0xFF && key1 != 0xFF) { // error
return codes&0xFF; return codes&0xFF;
} 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 == CAPS && (key1 == CAPS || key1 == 0xFF)) return 0;
if (key0 == CAPS) key0 = key1;
if (key1 == CAPS) key1 = 0xFF;
// Convert LockingCaps key up event into down event
if (key0 == CAPS_UP) key0 = CAPS;
if (key1 == CAPS_UP) key1 = CAPS;
} else {
// CAPS LOCK off:
// Ignore LockingCaps key up event when CAPS LOCK is off
if (key0 == CAPS_UP && (key1 == CAPS_UP || key1 == 0xFF)) return 0;
if (key0 == CAPS_UP) key0 = key1;
if (key1 == CAPS_UP) key1 = 0xFF;
}
#endif
_matrix_is_modified = true; _matrix_is_modified = true;
_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.

Завантаження…
Відмінити
Зберегти