-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[adb2usb] weird Keyboard recognition #640
Comments
Can you test with default firmware downloaded from TMK keymap editor without edit? And share output from hid_listen when the problems occurs. And show me pic of your ISO AEK, I don't know much where the § is. |
Sure, will try on weekend and let you know :) |
I wasn't able to run the PJRC debug tool, I got an error stating I have a bad CPU (???) However after flashing the rev1 you linked I got similar results:
Bad news is that |
I tried the second revision from the editor, but I got nothing, the keyboard wasn't even recognized as a HID, so I'm back to my version for now, but open to experiments to help identify the issue |
hmm, I guess your hardware of converter has something wrong. Show me photo of your pro micro and wiring this time. Rev2 firmware is not for your converter, it features different controller ATmega32u2. And how did you change files when you built firmware? Patch output of diff command would be helpful if the difference is slight. |
And I am just curious, the AEK layout is for German or other language? |
Here are changes Index: converter/adb_usb/Makefile
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- converter/adb_usb/Makefile (revision 3b21f85e9bb731adcbd40be1b93b7d39ef7748c5)
+++ converter/adb_usb/Makefile (date 1579631679439)
@@ -1,5 +1,5 @@
# Target file name (without extension).
-TARGET ?= adb_usb
+TARGET ?= adb_usb_pro_micro
# Directory common source filess exist
TMK_DIR ?= ../../tmk_core
@@ -18,7 +18,7 @@
# atmega32u4 Teensy2.0
# atemga32u4 TMK Converter rev.1
# atemga32u2 TMK Converter rev.2
-MCU ?= atmega32u2
+MCU ?= atmega32u4
# Processor frequency.
# This will define a symbol, F_CPU, in all source code files equal to the
Index: converter/adb_usb/config.h
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- converter/adb_usb/config.h (revision 3b21f85e9bb731adcbd40be1b93b7d39ef7748c5)
+++ converter/adb_usb/config.h (date 1580189587373)
@@ -19,12 +19,12 @@
#define CONFIG_H
-#define VENDOR_ID 0xFEED
-#define PRODUCT_ID 0x0ADB
+#define VENDOR_ID 0x05AC
+#define PRODUCT_ID 0x020C
#define DEVICE_VER 0x0101
-#define MANUFACTURER t.m.k.
-#define PRODUCT ADB keyboard converter
-#define DESCRIPTION convert ADB keyboard to USB
+#define MANUFACTURER Apple
+#define PRODUCT Extended Keyboard II
+#define DESCRIPTION ISO Apple Extended Keyboard II
/* matrix size */
#define MATRIX_ROWS 16 // keycode bit: 3-0
Index: converter/adb_usb/unimap_plain.c
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- converter/adb_usb/unimap_plain.c (revision 3b21f85e9bb731adcbd40be1b93b7d39ef7748c5)
+++ converter/adb_usb/unimap_plain.c (date 1580298227427)
@@ -16,10 +16,33 @@
*/
#include "unimap_common.h"
+/* id for user defined functions */
+enum function_id {
+ LSHIFT_LPAREN,
+};
+
+enum macro_id {
+ RAMBOX,
+ TEAMS,
+ ITERM,
+ WSTORM,
+ DEEZ,
+};
-#define AC_FN0 ACTION_LAYER_TAP_KEY(1, KC_GRV)
+#define SPOTLIGHT I(0), D(LGUI), T(SPC), U(LGUI)
+
+#define AC_FN0 ACTION_LAYER_TAP_KEY(1, KC_NUBS)
#define AC_FN1 ACTION_LAYER_TAP_KEY(2, KC_BSLS)
#define AC_PKEY ACTION_MODS_TAP_KEY(MOD_NONE, KC_POWER)
+// Function: LShift with tap '('
+#define AC_LSOP ACTION_FUNCTION_TAP(LSHIFT_LPAREN)
+
+// Macros:
+#define AC_RMBX ACTION_MACRO(RAMBOX)
+#define AC_TIMS ACTION_MACRO(TEAMS)
+#define AC_ITRM ACTION_MACRO(ITERM)
+#define AC_STRM ACTION_MACRO(WSTORM)
+#define AC_DEEZ ACTION_MACRO(DEEZ)
#ifdef KEYMAP_SECTION_ENABLE
const action_t actionmaps[][UNIMAP_ROWS][UNIMAP_COLS] __attribute__ ((section (".keymap.keymaps"))) = {
@@ -31,13 +54,13 @@
* |Esc| |F1 |F2 |F3 |F4 | |F5 |F6 |F7 |F8 | |F9 |F10|F11|F12| |PrS|ScL|Pau| |Pwr|
* `---' `---------------' `---------------' `---------------' `-----------' `---'
* ,-----------------------------------------------------------. ,-----------. ,---------------. ,---.
- * | `| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backspa| |Ins|Hom|PgU| |NmL| =| /| *| |VUp|
+ * | §| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backspa| |Ins|Hom|PgU| |NmL| =| /| *| |VUp|
* |-----------------------------------------------------------| |-----------| |---------------| |---|
- * |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \| |Del|End|PgD| | 7| 8| 9| -| |VDn|
- * |-----------------------------------------------------------| `-----------' |---------------| |---|
- * |CapsLo| A| S| D| F| G| H| J| K| L| ;| '|# |Retn| | 4| 5| 6| +| |Mut|
+ * |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| | |Del|End|PgD| | 7| 8| 9| -| |VDn|
+ * |------------------------------------------------------| Ret| `-----------' |---------------| |---|
+ * |CapsLo| A| S| D| F| G| H| J| K| L| ;| '| \ | | | 4| 5| 6| +| |Mut|
* |-----------------------------------------------------------| ,---. |---------------| `---'
- * |Shif|\ | Z| X| C| V| B| N| M| ,| ,| /|Shift | |Up | | 1| 2| 3| |
+ * |Sft(|` | Z| X| C| V| B| N| M| ,| ,| /|Shift | |Up | | 1| 2| 3| |
* |-----------------------------------------------------------| ,-----------. |-----------|Ent| ,---.
* |Ctrl |Opt |Gui | Space |Gui* |Opt |Ctrl | |Lef|Dow|Rig| | 0| .| | |Ply|
* `-----------------------------------------------------------' `-----------' `---------------' `---'
@@ -47,10 +70,10 @@
*/
[0] = UNIMAP_ADB(
ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR,SLCK,PAUS, PKEY,
- FN0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSPC, INS, HOME,PGUP, NLCK,PEQL,PSLS,PAST, VOLU,
+ GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSPC, INS, HOME,PGUP, NLCK,PEQL,PSLS,PAST, VOLU,
TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC, FN1, DEL, END, PGDN, P7, P8, P9, PMNS, VOLD,
LCAP,A, S, D, F, G, H, J, K, L, SCLN,QUOT, NUHS,ENT, P4, P5, P6, PPLS, MUTE,
- LSFT,NUBS,Z, X, C, V, B, N, M, COMM,DOT, SLSH, RSFT, UP, P1, P2, P3, PENT,
+ LSOP,FN0 ,Z, X, C, V, B, N, M, COMM,DOT, SLSH, RSFT, UP, P1, P2, P3, PENT,
LCTL,LALT,LGUI, SPC, RALT,RCTL, LEFT,DOWN,RGHT, P0, PDOT, MPLY
),
@@ -65,7 +88,7 @@
* |-----------------------------------------------------------| `-----------' |---------------| |---|
* |CapsLo|VoD|VoU|Mut| | | | |Hom|PgU|Lef|Rig|# |Retn| | | | | | | |
* |-----------------------------------------------------------| ,---. |---------------| `---'
- * | | | | | | | | | |End|PgD|Dow|Shift | |PgU| | | | | |
+ * | | |<< | |>| >>| | | | |End|PgD|Dow|Shift | |PgU| | | | | |
* |-----------------------------------------------------------| ,-----------. |-----------| | ,---.
* | | | | | | | | |Hom|PgD|End| | | | | | |
* `-----------------------------------------------------------' `-----------' `---------------' `---'
@@ -75,7 +98,7 @@
ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, DEL, TRNS,TRNS,TRNS, TRNS,TRNS,TRNS,TRNS, TRNS,
TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,PSCR,SLCK,PAUS,UP, INS, TRNS, TRNS,TRNS,TRNS, TRNS,TRNS,TRNS,TRNS, TRNS,
TRNS,VOLD,VOLU,MUTE,TRNS,TRNS,TRNS,TRNS,HOME,PGUP,LEFT,RGHT, TRNS,TRNS, TRNS,TRNS,TRNS,TRNS, TRNS,
- TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,END, PGDN,DOWN, TRNS, PGUP, TRNS,TRNS,TRNS,TRNS,
+ TRNS,TRNS,MRWD,MPLY,MFFD,TRNS,TRNS,TRNS,TRNS,END, PGDN,DOWN, TRNS, PGUP, TRNS,TRNS,TRNS,TRNS,
TRNS,TRNS,TRNS, TRNS, TRNS,TRNS, HOME,PGDN,END, TRNS, TRNS, TRNS
),
@@ -86,9 +109,9 @@
* ,-----------------------------------------------------------. ,-----------. ,---------------. ,---.
* |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Delete | | | | | | | | | | | |
* |-----------------------------------------------------------| |-----------| |---------------| |---|
- * | | | | | | | | |PrS|ScL|Pau|Up |INS| | | | | | | | | | | | |
+ * | | | | |RBX|TMS| | |ITM|ScL|Pau|Up |INS| | | | | | | | | | | | |
* |-----------------------------------------------------------| `-----------' |---------------| |---|
- * |CapsLo|VoD|VoU|Mut| | | | |Hom|PgU|Lef|Rig|# |Retn| | | | | | | |
+ * |CapsLo|VoD|VoU|Dzr| | | | |Hom|PgU|Lef|Rig|# |Retn| | | | | | | |
* |-----------------------------------------------------------| ,---. |---------------| `---'
* | | | | | | | | | |End|PgD|Dow|Shift | |PgU| | | | | |
* |-----------------------------------------------------------| ,-----------. |-----------| | ,---.
@@ -98,9 +121,71 @@
[2] = UNIMAP_ADB(
GRV, 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, DEL, TRNS,TRNS,TRNS, TRNS,TRNS,TRNS,TRNS, TRNS,
- TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,PSCR,SLCK,PAUS,UP, INS, TRNS, TRNS,TRNS,TRNS, TRNS,TRNS,TRNS,TRNS, TRNS,
- TRNS,VOLD,VOLU,MUTE,TRNS,TRNS,TRNS,TRNS,HOME,PGUP,LEFT,RGHT, TRNS,TRNS, TRNS,TRNS,TRNS,TRNS, TRNS,
+ TRNS,TRNS,STRM,TRNS,RMBX,TIMS,TRNS,TRNS,ITRM,SLCK,PAUS,UP, INS, TRNS, TRNS,TRNS,TRNS, TRNS,TRNS,TRNS,TRNS, TRNS,
+ TRNS,VOLD,VOLU,DEEZ,TRNS,TRNS,TRNS,TRNS,HOME,PGUP,LEFT,RGHT, TRNS,TRNS, TRNS,TRNS,TRNS,TRNS, TRNS,
TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,END, PGDN,DOWN, TRNS, PGUP, TRNS,TRNS,TRNS,TRNS,
TRNS,TRNS,TRNS, TRNS, TRNS,TRNS, HOME,PGDN,END, TRNS, TRNS, TRNS
),
};
+
+/*
+ * Macro definition
+ */
+const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
+{
+ switch (id) {
+ case RAMBOX:
+ return (record->event.pressed ?
+ MACRO( SPOTLIGHT, T(R), T(A), T(M), W(100), T(ENT), END ) :
+ MACRO_NONE );
+ case TEAMS:
+ return (record->event.pressed ?
+ MACRO( SPOTLIGHT, T(T), T(E), T(A), T(M), T(S), W(100), T(ENT), END ) :
+ MACRO_NONE );
+ case ITERM:
+ return (record->event.pressed ?
+ MACRO( SPOTLIGHT, T(I), T(T), T(E), T(R), W(100), T(ENT), END ) :
+ MACRO_NONE );
+ case WSTORM:
+ return (record->event.pressed ?
+ MACRO( SPOTLIGHT, T(W), T(E), T(B), T(S), T(T), W(100), T(ENT), END ) :
+ MACRO_NONE );
+ case DEEZ:
+ return (record->event.pressed ?
+ MACRO( SPOTLIGHT, T(D), T(E), T(E), T(Z), T(E), T(R), W(100), T(ENT), END ) :
+ MACRO_NONE );
+ }
+ return MACRO_NONE;
+}
+
+/*
+ * user defined action function
+ */
+void action_function(keyrecord_t *record, uint8_t id, uint8_t opt)
+{
+ switch (id) {
+ case LSHIFT_LPAREN:
+ // XXX: doesn't work with other tap key. iffy at least
+ // Shift parentheses example: LShft + tap '('
+ // http://stevelosh.com/blog/2012/10/a-modern-space-cadet/#shift-parentheses
+ // http://geekhack.org/index.php?topic=41989.msg1304899#msg1304899
+ if (record->event.pressed) {
+ if (record->tap.count == 0 || record->tap.interrupted) {
+ register_mods(MOD_BIT(KC_LSHIFT));
+ }
+ return;
+ }
+ if (record->tap.count == 0 || record->tap.interrupted) {
+ return unregister_mods(MOD_BIT(KC_LSHIFT));
+ }
+ add_weak_mods(MOD_BIT(KC_LSHIFT));
+ send_keyboard_report();
+ register_code(KC_9);
+ unregister_code(KC_9);
+ del_weak_mods(MOD_BIT(KC_LSHIFT));
+ send_keyboard_report();
+ record->tap.count = 0; // ad hoc: cancel tap
+
+ break;
+ }
+}
|
This is the version I hardwired later on, with 1KOhm resistor connecting 5V and the 3rd pin |
Ah, It is 3.3V version, you have to close J1 solder jumper to supply 5V probably. |
It's 5v version, I double-checked that with a multimeter before the whole operation |
How did you checked? |
yup, and it showed me 4.9V which I consider close enough since my multimeter tend's to lower the results, also, it has 16MHz quartz and AFAIK they are only made in 8MHz/3.3v and 16MHz/5v variants |
Are you sure? Pro Micro is totally mess for users unless you got it from Sparkfun or reliable sources. With Pro Micro you can save little money but often waste time :( |
Well, anywhere I check there's info that 16MHz (present in my model) requires 5v to be reliable, when powering of USB I get the readings mentioned above, but I'll short the J1 just in case, after all it can't hurt it with the desired 5v, can it? :) I'll let you know tomorrow how it went |
And you had better not to use the Apple's vendor/product ID with this converter, perticular on MacOS. It may make the OS confused. |
well my goal was to make it actually work as an apple keyboard so the OS won't ask me to go through that silly layout check routine, however I only changed it recently already after I noticed the issue with the keymap scramble (sounds like a title of some adventure movie :D) |
Yes, if the problem still be there, your firmware setup causes probably. Then, I don't know why the default firmware didn't work for your converter. The converter detects if keyboard is ANSI or ISO only when startup and MacOS does dirty trick under the hood to hide their trivial keyboard wierdness from users. See HID driver source code from Apple in this comments, it may explain. The converter does the trick for you, so that it will be problem if MacOS does it again. The default firmware or plain built firmware(without the VID/PID setting) should work on MacOS. |
But the thing is not only the characters are messed up on macOS, it seems that the controller itself messes up the keymap, as the momentary layer key changes places, so I don't think that it's the OS's thing. Also, modifiers are nod being distinguished properly in some cases, but after reboot they are, so there must be something in the detection mechanism. If there only was some way to actually debug it in code... I'll try the stock firmware on the bridged J1 at home and let you know if it changes anything.
|
Huh, funny thing, I tried stock firmware on another board and a fresh controller with J1 open, now it acts like this, but I'm unsure if this occurred on my main board, didn't test it, but probably acts the same:
Edit: |
tested on my main board with J1 closed and actually... it seems to work properly when quickly reconnected, but when slowly, the keymap is scrambled... the behavior of this seems so random... I don't actually know if the J1 is actually doing anything now. |
I tried to flash my firmware with stock config on J1 closed and now GRV is being read as actual GRV, but the overall behavior hasn't changed, keys are swapped and modifiers are mixed on long reconnect and correct on quick |
What do you mean by 'reconnect'? Plug into USB port or hot-plug keyboard into the converter? You better connect keyboard to converter first and then plug into USB port every time. Stock firmware should work for the grave and ISO key when you plug as mentioned above. For ISO keyboard, hot-plugging(without power cycle of the converter) is not supported at this time. Bootloader of ProMicro by magic command is not officially supported yet, it is another issue. Use reset pin or button for a while. |
And output from hid_listen would be helpful. The tool shoul work if your setup is ok. Test with Windows and Linux and know difference from MacOS, that would be helpful to understnad the problem also. I don't have any MacOS to test, btw. I'm assuming you are testing this on MacOS, is that right? |
yup, testing on macOS |
Sooo I tried many ways on many macs, but the only version of hid_listen I got working is the one wrapped in node.js Couldn't find any info on what should normally be expected on the output, but I hope this will be somewhat informational. I can parse the data returned from hid_listen ofc and make id read anything you want |
hmm, it looks something wrong with hid_listen on MacOS. What's is your MacOS version? I guess the tools is not compatible with the latest MacOS, pherhaps. But I never heard it from the comunity yet. Compiling hid_listen yourself on your MacOS may solve this. You can get soruce of the tool here: https://github.com/PaulStoffregen/hid_listen Also test on Windows may tell you something useful. For example, this is output from the tool when the converter start up with M0116 keyboard.
|
I'm on Catalina 10.15.3 |
well, I got this darn thing compiled and working
and this is that I see after quickly reconnecting the keyboard:
just after this I made a soft reboot and this version came up:
after normal, slow replug, result of which can be seen in the first paste, soft reboot seems to result in exactly the same situation as directly after hot-replug:
|
It doesn't recognize your keyobard as ISO correctly for some reason. R in the first log means connection is not stable basically, I also see a few R when plugin-in keyboard but the R's in the log seem to me be too many. If you don't use proper connector and solder them, instead of using jumper wires. Also pro micro's startup sequence may causes. Pro micro has two variant of its bootloader, old bootloader requires 8sec before start user application or converter firmware in our case while new Sparkfun one takes only 750ms. I think pro Micro is shipped with new one even if it is a clone but I'm sure. Meanwhile, Teensy and my TMK converters start up user application immediately without bootloader intervention. I'm not sure this causes acctually, though. Keyboard is recognized by this part of code, and you can tweak its timing by changing this wait line. I don't have any Pro Micro, MacOS and ISO ADB keyboard to test this ufnortunately. You may want to ask help from other ISO keyboard users with MacOS in the thread in Geekhack. Let us know if you have some clue.
Are you including your change for this test? |
Can you share hid_listen binary you built? |
I'll test with stock firmware. One tap on reset has no visible effect, only doubletap lands me in bootloader on my board, so I guess I have the newer version. I also have everything soldered with short wires to the board itself. |
Sure, how do you want it shared? I can either host it on Mega and share a link or put it somewhere else |
stock firmware from editor:
after hot-replug:
Soft reboot directly after that:
slow plugin, soft reboot (like hot-replug):
|
freshly pulled master, built from scratch, completely clean, built using makefile.rev1:
after hot-replug:
Soft reboot directly after that ( this time the listener catches the boot loader command)
slow plugin, soft reboot (like hot-replug):
|
ok, The initialization wait time seems to be a viable workaround for me for now. I've tried 150 ms but 1 oof 3 times the keyboard wouldn't boot properly, so I set it to 200ms and now it works like magic, no hiccups, every boot, hard or soft, is correct with handler 5 and iso detected :D |
Great to hear that. And again, could you share your hid_listen binary you built and run on Catalina? |
Without proper delay keyboard the converter starts talking too early before keyboard wakes up. ISO recognition and enabling Extention protocol would be failed in the result. #640 (comment) 200ms is enough for AEKs but 1000ms is used here for safety.
In my experience 200ms would be just enough, I don't see a single |
I confirmed that there is the problem even with US ANSI layout AEK/AEKII, and 200ms is enough for AEKs. AEK startup is a bit slower than other ADB keyboards for some reason. I updated the delay codes in repo with commit ce5e565 for AEKS using 1000ms for safety of unknown devices. And thanks for the hid_listen binary. That would be helpful for users on the latest MacOS. |
Built on Mac OS Catalina 10.15 tmk/tmk_keyboard#640 (comment)
Hello,
I have built the adb2tmk converter using Pro Micro Arduino compatible and TMK with the
unimap_plain
slightly tailored to suit my needs andconfig.h
suited with VID and DEV_ID to match my ISO AEK II directly soldered to the pro micro with 1KOhm pull-up resistor.There are 3 scenarios which occur:
§
and grave keys are swappedjumping to bootloader and back has no effect
§
and grave keys are still swappedat this stage, jumping to bootloader and waiting 8 seconds for the controller to reboot brings us to scenario Debouncing support #3
§
and grave keys seem to be in their placesrebooting gives no further effect safely looping us back to scenario Debouncing support #3
Another weird thing is that the
§
is being sent when the GRV is set in keymap and the grave key is emitted when defined as KC_NUBS, but that's a small thing I can cope with and don't mind as long as I can just set the keymap and rely on itAny way I can at least try to find out what happened?
The text was updated successfully, but these errors were encountered: