Merge remote-tracking branch 'tmk/master'

This commit is contained in:
Mark Sikora 2023-08-06 11:03:54 -04:00
commit 7ce4b5549f
15 changed files with 7752 additions and 3086 deletions

View file

@ -121,10 +121,17 @@ else
endif
ifdef KEYMAP
SRC := $(KEYMAP_FILE)_$(KEYMAP).c $(SRC)
TARGET := $(TARGET)_$(KEYMAP)
else
SRC := $(KEYMAP_FILE).c $(SRC)
endif
# Prefix key for unimap_TaranVH.c
ifdef PREFIX_KEY
OPT_DEFS += -DPREFIX_KEY=KC_$(PREFIX_KEY)
TARGET := $(TARGET)_$(PREFIX_KEY)
endif
CONFIG_H ?= config.h

View file

@ -1,9 +1,14 @@
USB to USB keyboard protocol converter
======================================
See for detail and discussion here.
See this for detail and discussion here.
- https://geekhack.org/index.php?topic=69169.0
See this for TMK general info.
- https://github.com/tmk/tmk_keyboard/wiki
Hardware requirement
--------------------
@ -17,88 +22,33 @@ You can buy a fully preassembled converter from me here.
### Arduino Leonardo + USB Host Shield
Buying Arduino Leonardo and USB Host Shield.
- https://store.arduino.cc/usa/leonardo
- https://store.arduino.cc/usa/arduino-usb-host-shield
- https://store.arduino.cc/products/arduino-leonardo-with-headers
- https://docs.arduino.cc/retired/shields/arduino-usb-host-shield
- https://www.sparkfun.com/products/9947
Build firmware
--------------
Build.
See wiki.
$ git clone https://github.com/tmk/tmk_keyboard.git
$ cd tmk_keyboard
$ git submodule init
$ git submodule update
$ cd converter/usb_usb
$ make
And Program converter. Push button on TMK converter and just run this.
$ make dfu
In case of Leonardo push reset button then run command. Serial port name(COM17) depends your system. On Linux I got /dev/ttyACM0.
$ DEV=COM17 make program
or
$ avrdude -patmega32u4 -cavr109 -b57600 -Uflash:w:usb_usb.hex -PCOM17
To build debug firmware use `master_debug` branch of `USB_Host_Shield_2.0-tmk` submodule
$ cd tmk_keyboard/tmk_core/protocol/usb_hid/USB_Host_Shield_2.0-tmk
$ git chceckout master_debug
$ cd tmk_keyboard/converter/usb_usb
$ make -f Makefile.debug
$ make -f Makefile.debug dfu
https://github.com/tmk/tmk_keyboard/wiki#build-firmware
Limitation
----------
Only supports 'HID Boot protocol'.
Note that the converter can host only USB "boot protocol" keyboard(6KRO), not NKRO, it is possible to support NKRO keyboard but you will need to write HID report parser for that. Every NKRO keyboard can have different HID report and it is difficult to support all kind of NKRO keyboards in the market.
Keymap editor
Keymap Editor
-------------
You can editor keymap and download firmware with web brwoser.
You can editor keymap and download firmware with web browser.
- http://www.tmk-kbd.com/tmk_keyboard/editor/unimap/?usb_usb
Update
------
- 2014/12/11 Added Hub support(confirmed with HHKB pro2)
- 2016/09/10 Unimap editor support
- 2016/10/18 Fix LED state at startup
- 2017/05/xx Fix startup code for FC660C(3eae475)
- 2018/02/xx Add Korean and Brazilian specific keys(ab6ddac,b2fa0ffa)
- 2018/07/xx Fix startup issue(c2ce617)
- 2018/10/xx Use fixed LUFA stack and update USB_Host_Shield_2.0
- 2019/09/18 Add BTLD(bootlader jump) key to unimap
Limitation
----------
The converter supports 'HID Boot protocol' only. This means it can host only standard USB keyboard(6KRO).
- Media/System control keys are not recognized.
- 'Fn' key itself cannot be remapped.
Resource
--------
### USB Host Sheild 2.0
- https://www.circuitsathome.com/products-page/arduino-shields/usb-host-shield-2-0-for-arduino
### USB Host Sheild 2.0 source
- https://github.com/felis/USB_Host_Shield_2.0
### Arduino USB Host Shield(with bootst converter)
- http://arduino.cc/en/Main/ArduinoUSBHostShield
### Arduino source
- https://github.com/arduino/Arduino/hardware/arduino/{cores,variants}
### Arduino-based hardware keyboard remapper - Colemak forum
- http://forum.colemak.com/viewtopic.php?id=1561
### Teensy + Host Shield
- http://www.pjrc.com/teensy/td_libs_USBHostShield.html
Many of NKRO keyboards still can work with the converter in 6KRO mode.

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,54 @@
// https://github.com/TaranVH/2nd-keyboard/blob/bf7a70def94538c8475dd928a59f7c603e72c94e/HASU_USB/NO_REPLUG_ISSUES/keymap.c
// https://geekhack.org/index.php?topic=69169.msg2781175#msg2781175
//
// how to build:
// $ make -f Makefile.unimap KEYMAP=TaranVH PREFIX_KEY=F24 clean
// $ make -f Makefile.unimap KEYMAP=TaranVH PREFIX_KEY=F24
#include "unimap_trans.h"
#include "action_layer.h"
#ifndef PREFIX_KEY
#define PREFIX_KEY KC_F24
#endif
#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
UNIMAP(
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, PSCR,SLCK,PCMM, VOLD,VOLU,MUTE,
GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, JYEN,BSPC, INS, HOME,PGUP, INT6,PSLS,PAST,PMNS,
TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC, BSLS, DEL, END, PGDN, P7, P8, P9, PPLS,
F20, A, S, D, F, G, H, J, K, L, SCLN,QUOT, NUHS,ENT, P4, P5, P6, PCMM,
INT2,NUBS,Z, X, C, V, B, N, M, COMM,DOT, SLSH, RO, INT3, UP, P1, P2, P3, PENT,
LANG2,LANG1,INT1,MHEN, SPC, HENK,KANA,LANG4,LANG3,INT4,INT5, LEFT,DOWN,RGHT, P0, PDOT,PEQL
),
};
bool hook_process_action(keyrecord_t *record) {
static uint8_t prefix_tracker;
action_t action = layer_switch_get_action(record->event);
switch (action.code) {
case KC_A ... KC_EXSEL:
if (record->event.pressed) {
register_code(PREFIX_KEY); //this means to send F24 down
prefix_tracker++;
register_code(action.code);
} else {
unregister_code(action.code);
prefix_tracker--;
if (!prefix_tracker) {
unregister_code(PREFIX_KEY); //this means to send F24 up
}
}
return true;
break;
}
return false;
}

View file

@ -454,6 +454,12 @@ void register_code(uint8_t code)
wait_ms(50);
bootloader_jump();
}
#ifdef MOUSEKEY_ENABLE
else if IS_MOUSEKEY(code) {
mousekey_on(code);
mousekey_send();
}
#endif
}
void unregister_code(uint8_t code)
@ -503,6 +509,12 @@ void unregister_code(uint8_t code)
else if IS_CONSUMER(code) {
host_consumer_send(0);
}
#ifdef MOUSEKEY_ENABLE
else if IS_MOUSEKEY(code) {
mousekey_off(code);
mousekey_send();
}
#endif
}
void type_code(uint8_t code)

View file

@ -229,7 +229,6 @@ enum usage_pages {
};
#define ACTION_USAGE_SYSTEM(id) ACTION(ACT_USAGE, PAGE_SYSTEM<<10 | (id))
#define ACTION_USAGE_CONSUMER(id) ACTION(ACT_USAGE, PAGE_CONSUMER<<10 | (id))
#define ACTION_MOUSEKEY(key) ACTION(ACT_MOUSEKEY, key)

View file

@ -287,22 +287,22 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define AC_BRIGHTNESS_DEC ACTION_USAGE_CONSUMER(BRIGHTNESS_DECREMENT)
/* Mousekey */
#define AC_MS_UP ACTION_MOUSEKEY(KC_MS_UP)
#define AC_MS_DOWN ACTION_MOUSEKEY(KC_MS_DOWN)
#define AC_MS_LEFT ACTION_MOUSEKEY(KC_MS_LEFT)
#define AC_MS_RIGHT ACTION_MOUSEKEY(KC_MS_RIGHT)
#define AC_MS_BTN1 ACTION_MOUSEKEY(KC_MS_BTN1)
#define AC_MS_BTN2 ACTION_MOUSEKEY(KC_MS_BTN2)
#define AC_MS_BTN3 ACTION_MOUSEKEY(KC_MS_BTN3)
#define AC_MS_BTN4 ACTION_MOUSEKEY(KC_MS_BTN4)
#define AC_MS_BTN5 ACTION_MOUSEKEY(KC_MS_BTN5)
#define AC_MS_WH_UP ACTION_MOUSEKEY(KC_MS_WH_UP)
#define AC_MS_WH_DOWN ACTION_MOUSEKEY(KC_MS_WH_DOWN)
#define AC_MS_WH_LEFT ACTION_MOUSEKEY(KC_MS_WH_LEFT)
#define AC_MS_WH_RIGHT ACTION_MOUSEKEY(KC_MS_WH_RIGHT)
#define AC_MS_ACCEL0 ACTION_MOUSEKEY(KC_MS_ACCEL0)
#define AC_MS_ACCEL1 ACTION_MOUSEKEY(KC_MS_ACCEL1)
#define AC_MS_ACCEL2 ACTION_MOUSEKEY(KC_MS_ACCEL2)
#define AC_MS_UP ACTION_KEY(KC_MS_UP)
#define AC_MS_DOWN ACTION_KEY(KC_MS_DOWN)
#define AC_MS_LEFT ACTION_KEY(KC_MS_LEFT)
#define AC_MS_RIGHT ACTION_KEY(KC_MS_RIGHT)
#define AC_MS_BTN1 ACTION_KEY(KC_MS_BTN1)
#define AC_MS_BTN2 ACTION_KEY(KC_MS_BTN2)
#define AC_MS_BTN3 ACTION_KEY(KC_MS_BTN3)
#define AC_MS_BTN4 ACTION_KEY(KC_MS_BTN4)
#define AC_MS_BTN5 ACTION_KEY(KC_MS_BTN5)
#define AC_MS_WH_UP ACTION_KEY(KC_MS_WH_UP)
#define AC_MS_WH_DOWN ACTION_KEY(KC_MS_WH_DOWN)
#define AC_MS_WH_LEFT ACTION_KEY(KC_MS_WH_LEFT)
#define AC_MS_WH_RIGHT ACTION_KEY(KC_MS_WH_RIGHT)
#define AC_MS_ACCEL0 ACTION_KEY(KC_MS_ACCEL0)
#define AC_MS_ACCEL1 ACTION_KEY(KC_MS_ACCEL1)
#define AC_MS_ACCEL2 ACTION_KEY(KC_MS_ACCEL2)
/* Command */
#define AC_BOOTLOADER ACTION_COMMAND(COMMAND_BOOTLOADER, 0)
@ -388,22 +388,22 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define AC_AGIN ACTION_KEY(KC_AGAIN)
#define AC_PSTE ACTION_KEY(KC_PASTE)
/* Mousekey */
#define AC_MS_U ACTION_MOUSEKEY(KC_MS_UP)
#define AC_MS_D ACTION_MOUSEKEY(KC_MS_DOWN)
#define AC_MS_L ACTION_MOUSEKEY(KC_MS_LEFT)
#define AC_MS_R ACTION_MOUSEKEY(KC_MS_RIGHT)
#define AC_BTN1 ACTION_MOUSEKEY(KC_MS_BTN1)
#define AC_BTN2 ACTION_MOUSEKEY(KC_MS_BTN2)
#define AC_BTN3 ACTION_MOUSEKEY(KC_MS_BTN3)
#define AC_BTN4 ACTION_MOUSEKEY(KC_MS_BTN4)
#define AC_BTN5 ACTION_MOUSEKEY(KC_MS_BTN5)
#define AC_WH_U ACTION_MOUSEKEY(KC_MS_WH_UP)
#define AC_WH_D ACTION_MOUSEKEY(KC_MS_WH_DOWN)
#define AC_WH_L ACTION_MOUSEKEY(KC_MS_WH_LEFT)
#define AC_WH_R ACTION_MOUSEKEY(KC_MS_WH_RIGHT)
#define AC_ACL0 ACTION_MOUSEKEY(KC_MS_ACCEL0)
#define AC_ACL1 ACTION_MOUSEKEY(KC_MS_ACCEL1)
#define AC_ACL2 ACTION_MOUSEKEY(KC_MS_ACCEL2)
#define AC_MS_U ACTION_KEY(KC_MS_UP)
#define AC_MS_D ACTION_KEY(KC_MS_DOWN)
#define AC_MS_L ACTION_KEY(KC_MS_LEFT)
#define AC_MS_R ACTION_KEY(KC_MS_RIGHT)
#define AC_BTN1 ACTION_KEY(KC_MS_BTN1)
#define AC_BTN2 ACTION_KEY(KC_MS_BTN2)
#define AC_BTN3 ACTION_KEY(KC_MS_BTN3)
#define AC_BTN4 ACTION_KEY(KC_MS_BTN4)
#define AC_BTN5 ACTION_KEY(KC_MS_BTN5)
#define AC_WH_U ACTION_KEY(KC_MS_WH_UP)
#define AC_WH_D ACTION_KEY(KC_MS_WH_DOWN)
#define AC_WH_L ACTION_KEY(KC_MS_WH_LEFT)
#define AC_WH_R ACTION_KEY(KC_MS_WH_RIGHT)
#define AC_ACL0 ACTION_KEY(KC_MS_ACCEL0)
#define AC_ACL1 ACTION_KEY(KC_MS_ACCEL1)
#define AC_ACL2 ACTION_KEY(KC_MS_ACCEL2)
/* Sytem Control */
#define AC_PWR ACTION_USAGE_SYSTEM(SYSTEM_POWER_DOWN)
#define AC_SLEP ACTION_USAGE_SYSTEM(SYSTEM_SLEEP)

View file

@ -149,7 +149,7 @@ static action_t keycode_to_action(uint8_t keycode)
return (action_t)ACTION_USAGE_CONSUMER(KEYCODE2CONSUMER(keycode));
break;
case KC_MS_UP ... KC_MS_ACCEL2:
return (action_t)ACTION_MOUSEKEY(keycode);
return (action_t)ACTION_KEY(keycode);
break;
case KC_TRNS:
return (action_t)ACTION_TRANSPARENT;

@ -1 +1 @@
Subproject commit a98e6f720683b2514cf4dfe0f04a65dfdcc508e1
Subproject commit 85af76f6c9967d7457dbf5aa442a6a67e3e9ecf1

View file

@ -12,6 +12,12 @@ void KBDReportParser::Parse(USBHID *hid, bool is_rpt_id, uint8_t len, uint8_t *b
}
xprintf("\r\n");
// boot keyboard report length should be 8
if (len != 8) {
xprintf(" ignored\r\n");
return;
}
// Rollover error
// Cherry: 0101010101010101
// https://geekhack.org/index.php?topic=69169.msg2638223#msg2638223

View file

@ -632,3 +632,9 @@ $(shell mkdir $(OBJDIR) 2>/dev/null)
build elf hex eep lss sym coff extcoff \
clean clean_list debug gdb-config show_path \
program teensy dfu flip dfu-ee flip-ee dfu-start
# Print out the value of a make variable.
# https://stackoverflow.com/questions/16467718/how-to-print-out-a-variable-in-makefile
print-%:
@echo $* = $($*)