diff --git a/converter/adb_usb/matrix.c b/converter/adb_usb/matrix.c index 6190c71a..8f6a0dc9 100644 --- a/converter/adb_usb/matrix.c +++ b/converter/adb_usb/matrix.c @@ -31,44 +31,18 @@ along with this program. If not, see . #include "host.h" -#if (MATRIX_COLS > 16) -# error "MATRIX_COLS must not exceed 16" -#endif -#if (MATRIX_ROWS > 255) -# error "MATRIX_ROWS must not exceed 255" -#endif static bool has_media_keys = false; static bool is_iso_layout = false; -static bool is_modified = false; static report_mouse_t mouse_report = {}; // matrix state buffer(1:on, 0:off) -#if (MATRIX_COLS <= 8) -static uint8_t matrix[MATRIX_ROWS]; -#else -static uint16_t matrix[MATRIX_ROWS]; -#endif +static matrix_row_t matrix[MATRIX_ROWS]; -#ifdef MATRIX_HAS_GHOST -static bool matrix_has_ghost_in_row(uint8_t row); -#endif static void register_key(uint8_t key); -inline -uint8_t matrix_rows(void) -{ - return MATRIX_ROWS; -} - -inline -uint8_t matrix_cols(void) -{ - return MATRIX_COLS; -} - void matrix_init(void) { // LED on @@ -208,8 +182,6 @@ uint8_t matrix_scan(void) uint16_t codes; uint8_t key0, key1; - is_modified = false; - codes = extra_key; extra_key = 0xFFFF; @@ -328,93 +300,12 @@ uint8_t matrix_scan(void) return 1; } -bool matrix_is_modified(void) -{ - return is_modified; -} - inline -bool matrix_has_ghost(void) -{ -#ifdef MATRIX_HAS_GHOST - for (uint8_t i = 0; i < MATRIX_ROWS; i++) { - if (matrix_has_ghost_in_row(i)) - return true; - } -#endif - return false; -} - -inline -bool matrix_is_on(uint8_t row, uint8_t col) -{ - return (matrix[row] & (1<>3)&0xF) #define COL(code) (code&0x07) -static bool is_modified = false; - - -inline -uint8_t matrix_rows(void) -{ - return MATRIX_ROWS; -} - -inline -uint8_t matrix_cols(void) -{ - return MATRIX_COLS; -} void matrix_init(void) { @@ -74,8 +60,6 @@ void matrix_init(void) uint8_t matrix_scan(void) { - is_modified = false; - uint8_t code; code = news_recv(); if (code == 0) { @@ -87,56 +71,18 @@ uint8_t matrix_scan(void) // break code if (matrix_is_on(ROW(code), COL(code))) { matrix[ROW(code)] &= ~(1<>3)&0xF) #define COL(code) (code&0x07) -static bool is_modified = false; - - -inline -uint8_t matrix_rows(void) -{ - return MATRIX_ROWS; -} - -inline -uint8_t matrix_cols(void) -{ - return MATRIX_COLS; -} static void pc98_inhibit_repeat(void) { @@ -128,8 +114,6 @@ void matrix_init(void) uint8_t matrix_scan(void) { - is_modified = false; - uint16_t code; PC98_RDY_PORT |= (1<. #include "matrix.h" #include "debug.h" #include "protocol/serial.h" +#include "led.h" +#include "host.h" /* @@ -46,20 +48,6 @@ static uint8_t matrix[MATRIX_ROWS]; #define ROW(code) ((code>>3)&0xF) #define COL(code) (code&0x07) -static bool is_modified = false; - - -inline -uint8_t matrix_rows(void) -{ - return MATRIX_ROWS; -} - -inline -uint8_t matrix_cols(void) -{ - return MATRIX_COLS; -} void matrix_init(void) { @@ -92,8 +80,6 @@ void matrix_init(void) uint8_t matrix_scan(void) { - is_modified = false; - uint8_t code; code = serial_recv(); if (!code) return 0; @@ -131,56 +117,18 @@ uint8_t matrix_scan(void) // break code if (matrix_is_on(ROW(code), COL(code))) { matrix[ROW(code)] &= ~(1<. static void matrix_make(uint8_t code); static void matrix_break(uint8_t code); -#ifdef MATRIX_HAS_GHOST -static bool matrix_has_ghost_in_row(uint8_t row); -#endif /* @@ -49,20 +46,6 @@ static uint8_t matrix[MATRIX_ROWS]; #define ROW(code) (code>>3) #define COL(code) (code&0x07) -static bool is_modified = false; - - -inline -uint8_t matrix_rows(void) -{ - return MATRIX_ROWS; -} - -inline -uint8_t matrix_cols(void) -{ - return MATRIX_COLS; -} void matrix_init(void) { @@ -93,8 +76,6 @@ uint8_t matrix_scan(void) F0, } state = RESET; - is_modified = false; - uint8_t code; if ((code = ps2_host_recv())) { debug("r"); debug_hex(code); debug(" "); @@ -172,83 +153,17 @@ uint8_t matrix_scan(void) return 1; } -bool matrix_is_modified(void) -{ - return is_modified; -} - -inline -bool matrix_has_ghost(void) -{ -#ifdef MATRIX_HAS_GHOST - for (uint8_t i = 0; i < MATRIX_ROWS; i++) { - if (matrix_has_ghost_in_row(i)) - return true; - } -#endif - return false; -} - -inline -bool matrix_is_on(uint8_t row, uint8_t col) -{ - return (matrix[row] & (1<. #include "timer.h" #include "matrix.h" #include "led.h" +#include "host.h" +#include "keyboard.h" /* KEY CODE to Matrix @@ -151,6 +153,16 @@ uint8_t matrix_scan(void) { dprintf("host.Task: %d\n", timer); } + static uint8_t usb_state = 0; + if (usb_state != usb_host.getUsbTaskState()) { + usb_state = usb_host.getUsbTaskState(); + dprintf("usb_state: %02X\n", usb_state); + + // restore LED state when keyboard comes up + if (usb_state == USB_STATE_RUNNING) { + keyboard_set_leds(host_keyboard_leds()); + } + } return 1; } diff --git a/converter/x68k_usb/matrix.c b/converter/x68k_usb/matrix.c index 2d5a1e11..9dff7ba6 100644 --- a/converter/x68k_usb/matrix.c +++ b/converter/x68k_usb/matrix.c @@ -50,18 +50,6 @@ static uint8_t matrix[MATRIX_ROWS]; static bool is_modified = false; -inline -uint8_t matrix_rows(void) -{ - return MATRIX_ROWS; -} - -inline -uint8_t matrix_cols(void) -{ - return MATRIX_COLS; -} - void matrix_init(void) { serial_init(); @@ -99,44 +87,8 @@ uint8_t matrix_scan(void) return code; } -bool matrix_is_modified(void) -{ - return is_modified; -} - -inline -bool matrix_has_ghost(void) -{ - return false; -} - -inline -bool matrix_is_on(uint8_t row, uint8_t col) -{ - return (matrix[row] & (1<. static void matrix_make(uint8_t code); static void matrix_break(uint8_t code); -#ifdef MATRIX_HAS_GHOST -static bool matrix_has_ghost_in_row(uint8_t row); -#endif static uint8_t matrix[MATRIX_ROWS]; #define ROW(code) (code>>3) @@ -40,20 +37,6 @@ static uint8_t matrix[MATRIX_ROWS]; #define PRINT_SCREEN (0x7C) #define PAUSE (0x7D) -static bool is_modified = false; - - -inline -uint8_t matrix_rows(void) -{ - return MATRIX_ROWS; -} - -inline -uint8_t matrix_cols(void) -{ - return MATRIX_COLS; -} void matrix_init(void) { @@ -131,8 +114,6 @@ uint8_t matrix_scan(void) } state = INIT; - is_modified = false; - // 'pseudo break code' hack if (matrix_is_on(ROW(PAUSE), COL(PAUSE))) { matrix_break(PAUSE); @@ -236,83 +217,17 @@ uint8_t matrix_scan(void) return 1; } -bool matrix_is_modified(void) -{ - return is_modified; -} - -inline -bool matrix_has_ghost(void) -{ -#ifdef MATRIX_HAS_GHOST - for (uint8_t i = 0; i < MATRIX_ROWS; i++) { - if (matrix_has_ghost_in_row(i)) - return true; - } -#endif - return false; -} - -inline -bool matrix_is_on(uint8_t row, uint8_t col) -{ - return (matrix[row] & (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 "unimap_trans.h" + + +#define AC_FN0 ACTION_LAYER_MOMENTARY(1) + +#ifdef KEYMAP_SECTION_ENABLE +const action_t actionmaps[][UNIMAP_ROWS][UNIMAP_COLS] __attribute__ ((section (".keymap.keymaps"))) = { +#else +const action_t actionmaps[][UNIMAP_ROWS][UNIMAP_COLS] PROGMEM = { +#endif + /* + * Universal keyboard layout + * ,-----------------------------------------------. + * |F13|F14|F15|F16|F17|F18|F19|F20|F21|F22|F23|F24| + * ,---. |-----------------------------------------------| ,-----------. ,-----------. + * |Esc| |F1 |F2 |F3 |F4 |F5 |F6 |F7 |F8 |F9 |F10|F11|F12| |PrS|ScL|Pau| |VDn|VUp|Mut| + * `---' `-----------------------------------------------' `-----------' `-----------' + * ,-----------------------------------------------------------. ,-----------. ,---------------. + * | `| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|JPY|Bsp| |Ins|Hom|PgU| |NmL| /| *| -| + * |-----------------------------------------------------------| |-----------| |---------------| + * |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \ | |Del|End|PgD| | 7| 8| 9| +| + * |-----------------------------------------------------------| `-----------' |---------------| + * |CapsL | A| S| D| F| G| H| J| K| L| ;| '| #|Retn| | 4| 5| 6|KP,| + * |-----------------------------------------------------------| ,---. |---------------| + * |Shft| <| Z| X| C| V| B| N| M| ,| .| /| RO|Shift | |Up | | 1| 2| 3|KP=| + * |-----------------------------------------------------------| ,-----------. |---------------| + * |Ctl|Gui|Alt|MHEN| Space |HENK|KANA|Alt|Gui|App|Ctl| |Lef|Dow|Rig| | 0 | .|Ent| + * `-----------------------------------------------------------' `-----------' `---------------' + */ + UNIMAP( + NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, + ESC, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, + GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, NUHS,BSPC, NO, NO, NO, NO, NO, NO, NO, + TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC, BSLS, NO, NO, NO, NO, NO, NO, NO, + LCTL,A, S, D, F, G, H, J, K, L, SCLN,QUOT, NO, ENT, NO, NO, NO, NO, + LSFT,NUBS,Z, X, C, V, B, N, M, COMM,DOT, SLSH, NO, RSFT, NO, NO, NO, NO, NO, + LCTL,LGUI,LALT,NO, SPC, NO, NO, RALT,RGUI,APP, FN0, NO, NO, NO, NO, NO, NO + ), + UNIMAP( + 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, + ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, INS, DEL, TRNS,TRNS,TRNS, TRNS,TRNS,TRNS,TRNS, + CAPS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,PSCR,SLCK,PAUS,UP, TRNS, TRNS, TRNS,TRNS,TRNS, TRNS,TRNS,TRNS,TRNS, + TRNS,VOLD,VOLU,MUTE,TRNS,TRNS,PAST,PSLS,HOME,PGUP,LEFT,RGHT, TRNS,PENT, TRNS,TRNS,TRNS,TRNS, + TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,PPLS,PMNS,END, PGDN,DOWN, TRNS,TRNS, TRNS, TRNS,TRNS,TRNS,TRNS, + TRNS,TRNS,TRNS,TRNS, TRNS, TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, TRNS,TRNS,TRNS, TRNS, TRNS,TRNS + ), +}; diff --git a/keyboard/alps64/unimap_trans.h b/keyboard/alps64/unimap_trans.h new file mode 100644 index 00000000..e52bd55e --- /dev/null +++ b/keyboard/alps64/unimap_trans.h @@ -0,0 +1,63 @@ +/* +Copyright 2016 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 UNIMAP_TRNAS_H +#define UNIMAP_TRNAS_H + +#include +#include +#include "unimap.h" + + +/* Mapping to Universal keyboard layout + * ,-----------------------------------------------------------. + * |` | 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|JPY|Bsp| + * |-----------------------------------------------------------| + * |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \ | + * |-----------------------------------------------------------| + * |Caps | A| S| D| F| G| H| J| K| L| ;| '|Enter | + * |-----------------------------------------------------------| + * |Shft| \| Z| X| C| V| B| N| M| ,| .| /|Shift |Esc| + * |-----------------------------------------------------------' + * |Ctrl|Gui |Alt | Space |App |Alt |Gui |Ctrl | + * `-----------------------------------------------------------' + * + * ,-----------------------------------------------------------. + * |36 |37 |46 |47 |56 |57 |66 |67 |76 |77 |06 |07 |17 |26 |27 | + * |-----------------------------------------------------------| + * |34 |35 |44 |45 |54 |55 |64 |65 |75 |05 |15 |16 |25 |24 | + * |-----------------------------------------------------------| + * |32 |33 |43 |52 |53 |63 |73 |74 |03 |04 |13 |14 | 23 | + * |-----------------------------------------------------------| + * |31 |41 |42 |51 |61 |62 |71 |72 |01 |02 |11 |12 |21 |22 | + * |-----------------------------------------------------------| + * |30 |40 |50 | 60 |70 |00 |10 |20 | + * `-----------------------------------------------------------' + */ +const uint8_t PROGMEM unimap_trans[MATRIX_ROWS][MATRIX_COLS] = { + { UNIMAP_RALT, UNIMAP_M, UNIMAP_COMM, UNIMAP_K, UNIMAP_L, UNIMAP_O, UNIMAP_0, UNIMAP_MINS }, /* 00-07 */ + { UNIMAP_RGUI, UNIMAP_DOT, UNIMAP_SLSH, UNIMAP_SCLN, UNIMAP_QUOT, UNIMAP_P, UNIMAP_LBRC, UNIMAP_EQL }, /* 10-17 */ + { UNIMAP_RCTL, UNIMAP_RSFT, UNIMAP_ESC, UNIMAP_ENT, UNIMAP_BSLS, UNIMAP_RBRC, UNIMAP_JYEN, UNIMAP_BSPC }, /* 20-27 */ + { UNIMAP_LCTL, UNIMAP_LSFT, UNIMAP_CAPS, UNIMAP_A, UNIMAP_TAB, UNIMAP_Q, UNIMAP_GRV, UNIMAP_1 }, /* 30-37 */ + { UNIMAP_LGUI, UNIMAP_NUBS, UNIMAP_Z, UNIMAP_S, UNIMAP_W, UNIMAP_E, UNIMAP_2, UNIMAP_3 }, /* 40-47 */ + { UNIMAP_LALT, UNIMAP_X, UNIMAP_D, UNIMAP_F, UNIMAP_R, UNIMAP_T, UNIMAP_4, UNIMAP_5 }, /* 50-57 */ + { UNIMAP_SPC, UNIMAP_C, UNIMAP_V, UNIMAP_G, UNIMAP_Y, UNIMAP_U, UNIMAP_6, UNIMAP_7 }, /* 60-67 */ + { UNIMAP_APP, UNIMAP_B, UNIMAP_N, UNIMAP_H, UNIMAP_J, UNIMAP_I, UNIMAP_8, UNIMAP_9 }, /* 70-77 */ +}; + +#endif + + diff --git a/keyboard/gh60/matrix.c b/keyboard/gh60/matrix.c index a6121515..5a56cee0 100644 --- a/keyboard/gh60/matrix.c +++ b/keyboard/gh60/matrix.c @@ -43,18 +43,6 @@ 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) { // initialize row and col @@ -97,43 +85,12 @@ uint8_t matrix_scan(void) return 1; } -bool matrix_is_modified(void) -{ - if (debouncing) return false; - return true; -} - -inline -bool matrix_is_on(uint8_t row, uint8_t col) -{ - return (matrix[row] & ((matrix_row_t)1<send_keyboard)(report); if (debug_keyboard) { - dprint("keyboard_report: "); + dprint("keyboard: "); for (uint8_t i = 0; i < KEYBOARD_REPORT_SIZE; i++) { dprintf("%02X ", report->raw[i]); } @@ -75,6 +75,10 @@ void host_system_send(uint16_t report) if (!driver) return; (*driver->send_system)(report); + + if (debug_keyboard) { + dprintf("system: %04X\n", report); + } } void host_consumer_send(uint16_t report) @@ -84,6 +88,10 @@ void host_consumer_send(uint16_t report) if (!driver) return; (*driver->send_consumer)(report); + + if (debug_keyboard) { + dprintf("consumer: %04X\n", report); + } } uint16_t host_last_sysytem_report(void) diff --git a/tmk_core/common/matrix.c b/tmk_core/common/matrix.c index 9694bd1a..9939307a 100644 --- a/tmk_core/common/matrix.c +++ b/tmk_core/common/matrix.c @@ -33,7 +33,6 @@ uint8_t matrix_cols(void) __attribute__ ((weak)) void matrix_clear(void) { - matrix_init(); } __attribute__ ((weak)) @@ -55,23 +54,22 @@ void matrix_print(void) #elif (MATRIX_COLS <= 32) print("r/c 0123456789ABCDEF0123456789ABCDEF\n"); #endif + for (uint8_t row = 0; row < MATRIX_ROWS; row++) { - xprintf("%02X:", row); #if (MATRIX_COLS <= 8) - print_bin_reverse8(matrix_get_row(row)); + xprintf("%02X: %08b%s\n", row, bitrev(matrix_get_row(row)), #elif (MATRIX_COLS <= 16) - print_bin_reverse16(matrix_get_row(row)); + xprintf("%02X: %016b%s\n", row, bitrev16(matrix_get_row(row)), #elif (MATRIX_COLS <= 32) - print_bin_reverse32(matrix_get_row(row)); + xprintf("%02X: %032b%s\n", row, bitrev32(matrix_get_row(row)), #endif - #ifdef MATRIX_HAS_GHOST - if (matrix_has_ghost_in_row(row)) { - print(" 255) +#error "MATRIX_ROWS must not exceed 255" +#endif + #define MATRIX_IS_ON(row, col) (matrix_get_row(row) && (1<