makerdiary / python-keyboard

A hand-wired USB & Bluetooth keyboard powered by Python and more
https://makerdiary.com/m60
MIT License
486 stars 61 forks source link

AltGr is invoking Left Ctrl, and AltGr #20

Closed CGMossa closed 3 years ago

CGMossa commented 3 years ago

Hello!

Based on correspondence back and forth with store@makerdiary.com (Zelin), I'm making this issue: Whenever I press AltGr, I get both AltGr and Left Control. Here's an excerpt:

KEY-UP   - QMK: KC_LCTL Event key: Control     Code: ControlLeft   KeyCode: 17 in 56.365ms
KEY-UP   - QMK: KC_RALT Event key: AltGraph    Code: AltRight      KeyCode: 18 in 55.965ms
KEY-DOWN - QMK: KC_LCTL Event key: Control     Code: ControlLeft   KeyCode: 17
KEY-DOWN - QMK: KC_RALT Event key: AltGraph    Code: AltRight      KeyCode: 18
KEY-UP   - QMK: KC_LCTL Event key: Control     Code: ControlLeft   KeyCode: 17 in 46.915ms
KEY-UP   - QMK: KC_RALT Event key: AltGraph    Code: AltRight      KeyCode: 18 in 46.910ms

These come from Keyboard Configurator

I think this is an issue. Does anyone have comments on this?

xiongyihui commented 3 years ago

Did you change the keymap? Does pressing Left Control also output both AltGr and Left Control?

CGMossa commented 3 years ago

If I press left control, I get this:

17
KEY-DOWN - QMK: KC_LCTL Event key: Control     Code: ControlLeft   KeyCode: 17
KEY-UP   - QMK: KC_LCTL Event key: Control     Code: ControlLeft   KeyCode: 17 in 186.025ms
KEY-DOWN - QMK: KC_LCTL Event key: Control     Code: ControlLeft   KeyCode: 17
KEY-UP   - QMK: KC_LCTL Event key: Control     Code: ControlLeft   KeyCode: 17 in 153.425ms

And I've got this file atm:


from PYKB import *

keyboard = Keyboard()

___ = TRANSPARENT
BOOT = BOOTLOADER
L1 = LAYER_TAP(1)
L2D = LAYER_TAP(2, D)
L3B = LAYER_TAP(3, B)
LSFT4 = LAYER_MODS(4, MODS(LSHIFT))
RSFT4 = LAYER_MODS(4, MODS(RSHIFT))

# Semicolon & Ctrl
SCC = MODS_TAP(MODS(RCTRL), ';')

keyboard.keymap = (
    # layer 0
    (
        ESC,   1,   2,   3,   4,   5,   6,   7,   8,   9,   0, '-', '=', BACKSPACE,
        TAB,   Q,   W,   E,   R,   T,   Y,   U,   I,   O,   P, '[', ']', '|',
        LCTRL,  A,   S, L2D,   F,   G,   H,   J,   K,   L, SCC, '"',    ENTER,
        LSFT4, Z,   X,   C,   V, L3B,   N,   M, ',', '.', '/',         RSFT4,
        LCTRL, LGUI, LALT,          SPACE,            RALT, L1,  LGUI, RCTRL
    ),

    # layer 1
    (
        '`',  F1,  F2,  F3,  F4,  F5,  F6,  F7,  F8,  F9, F10, F11, F12, DEL,
        ___, ___,  UP, ___, ___, ___, ___, ___, ___, ___,SUSPEND,___,___,___,
        CAPS,LEFT,DOWN,RIGHT,___, ___, ___, ___, ___, ___, ___, ___,      ___,
        ___, ___, ___, ___, ___,BOOT, ___,MACRO(0), ___, ___, ___,       ___,
        ___, ___, ___,                ___,               ___, ___, ___,  ___
    ),

    # layer 2
    (
        '`',  F1,  F2,  F3,  F4,  F5,  F6,  F7,  F8,  F9, F10, F11, F12, DEL,
        ___, ___, ___, ___, ___, ___, ___,PGUP, ___, ___, ___,AUDIO_VOL_DOWN,AUDIO_VOL_UP,AUDIO_MUTE,
        ___, ___, ___, ___, ___, ___,LEFT,DOWN, UP,RIGHT, ___, ___,      ___,
        ___, ___, ___, ___, ___, ___,PGDN, ___, ___, ___, ___,           ___,
        ___, ___, ___,                ___,               ___, ___, ___,  ___
    ),

    # layer 3
    (
        BT_TOGGLE,BT1,BT2, BT3,BT4,BT5,BT6,BT7, BT8, BT9, BT0, ___, ___, ___,
        ___, ___, ___, ___, ___, ___,___,USB_TOGGLE,___,___,___,___,___, ___,
        ___, ___, ___, ___, ___, ___, ___, ___, ___, ___, ___, ___,      ___,
        ___, ___, ___, ___, ___, ___, ___, ___, ___, ___, ___,           ___,
        ___, ___, ___,                ___,               ___, ___, ___,  ___
    ),

    # layer 4
    (
        '`', ___, ___, ___, ___, ___, ___, ___, ___, ___, ___, ___, ___, ___,
        ___, ___, ___, ___, ___, ___, ___, ___, ___, ___, ___, ___, ___, ___,
        ___, ___, ___,   D, ___, ___, ___, ___, ___, ___, ';', ___,      ___,
        ___, ___, ___, ___, ___,   B, ___, ___, ___, ___, ___,           ___,
        ___, ___, ___,                ___,               ___, ___, ___,  ___
    ),
)

# def macro_handler(dev, n, is_down):
#     if is_down:
#         dev.send_text('You pressed macro #{}\n'.format(n))
#     else:
#         dev.send_text('You released macro #{}\n'.format(n))

# def pairs_handler(dev, n):
#     dev.send_text('You just triggered pair keys #{}\n'.format(n))

# keyboard.macro_handler = macro_handler
# keyboard.pairs_handler = pairs_handler

# Pairs: J & K, U & I
# keyboard.pairs = [{35, 36}, {20, 19}]

keyboard.verbose = False

keyboard.run()

It is weird, right? I've changed switches, looked at everything..

xiongyihui commented 3 years ago

Very weird! How about changing RALT to A in layer 0? If pressing it outputs Ctrl and A, it is likely to be an issue of hardware.

CGMossa commented 3 years ago

Hey! I just did that but then it works as you'd expect:


keyboard.keymap = (
    # layer 0
    (
        ESC,   1,   2,   3,   4,   5,   6,   7,   8,   9,   0, '-', '=', BACKSPACE,
        TAB,   Q,   W,   E,   R,   T,   Y,   U,   I,   O,   P, '[', ']', '|',
        LCTRL,  A,   S, L2D,   F,   G,   H,   J,   K,   L, SCC, '"',    ENTER,
        LSFT4, Z,   X,   C,   V, L3B,   N,   M, ',', '.', '/',         RSFT4,
        # LCTRL, LGUI, LALT,          SPACE,            RALT, L1,  LGUI, RCTRL
        LCTRL, LGUI, LALT,          SPACE,            A, L1,  LGUI, RCTRL
    ),

results in

KEY-DOWN - QMK: KC_A    Event key: a           Code: KeyA          KeyCode: 65
KEY-UP   - QMK: KC_A    Event key: a           Code: KeyA          KeyCode: 65 in 84.740ms
KEY-DOWN - QMK: KC_A    Event key: a           Code: KeyA          KeyCode: 65
KEY-UP   - QMK: KC_A    Event key: a           Code: KeyA          KeyCode: 65 in 77.745ms
KEY-DOWN - QMK: KC_A    Event key: a           Code: KeyA          KeyCode: 65
KEY-UP   - QMK: KC_A    Event key: a           Code: KeyA          KeyCode: 65 in 86.895ms

(Yeah, I pressed it three times).

I don't know what is going on 🗡️

xiongyihui commented 3 years ago

That's super weird! You can also change LALT to RALT to check if it is an issue of RALT keycode.

CGMossa commented 3 years ago

You're right!

KEY-DOWN - QMK: KC_LALT Event key: Alt         Code: AltLeft       KeyCode: 18
KEY-UP   - QMK: KC_LALT Event key: Alt         Code: AltLeft       KeyCode: 18 in 66.650ms
KEY-DOWN - QMK: KC_LALT Event key: Alt         Code: AltLeft       KeyCode: 18
KEY-UP   - QMK: KC_LALT Event key: Alt         Code: AltLeft       KeyCode: 18 in 45.265ms
KEY-DOWN - QMK: KC_LALT Event key: Alt         Code: AltLeft       KeyCode: 18

I'm not using the modified anything, as I checked the version, i.e.: boot_out.txt contains

Adafruit CircuitPython 6.0.0-alpha.1-110-g121d78ec9 on 2020-08-27; Makerdiary M60 Keyboard with nRF52840

And this was the latest version..

xiongyihui commented 3 years ago

Have you tried this keyboard on another computer? Have no idea why RALT outputs LCTRL and RALT.

CGMossa commented 3 years ago

This is the third computer I'm testing this on.

So I'm sure this is happening. I can also Zoom and show it live if you'd like :D It is pretty strange..

Note, I do need AltGr, as I am US International layout pretty regularly..

On Fri, 9 Oct 2020 at 16:04, Yihui Xiong notifications@github.com wrote:

Have you tried this keyboard on another computer? Have no idea why RALT outputs LCTRL and RALT.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/makerdiary/python-keyboard/issues/20#issuecomment-706200640, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAIDVSGCUGHL3UYWM4KFUOTSJ4J5BANCNFSM4SJZQW6A .

xiongyihui commented 3 years ago

I found a hint on wikipedia - https://en.wikipedia.org/wiki/AltGr_key

On a typical, Windows-compatible PC keyboard, the AltGr key, when present, takes the place of the right-hand Alt key: if not engraved as such, that key may still be remapped to behave as though it is,[1] (or emulated using a chord such as Ctrl+Alt).

CGMossa commented 3 years ago

This is it. All of my machines are on Windows. I just tried AltGr on my Drop High-Profile Ctrl, but using the keyboard tester, and I get this:

KEY-UP - QMK: KC_LCTL Event key: Control Code: ControlLeft KeyCode: 17 in
54.505ms KEY-UP - QMK: KC_RALT Event key: AltGraph Code: AltRight KeyCode:
18 in 38.910ms KEY-DOWN - QMK: KC_LCTL Event key: Control Code:
ControlLeft KeyCode:
17 KEY-DOWN - QMK: KC_RALT Event key: AltGraph Code: AltRight KeyCode: 18
KEY-UP - QMK: KC_LCTL Event key: Control Code: ControlLeft KeyCode: 17 in
69.605ms KEY-UP - QMK: KC_RALT Event key: AltGraph Code: AltRight KeyCode:
18 in 65.110ms

So case closed!

On Fri, 9 Oct 2020 at 16:20, Yihui Xiong notifications@github.com wrote:

I found a hint on wikipedia - https://en.wikipedia.org/wiki/AltGr_key

On a typical, Windows-compatible PC keyboard, the AltGr key, when present, takes the place of the right-hand Alt key: if not engraved as such, that key may still be remapped to behave as though it is,[1] (or emulated using a chord such as Ctrl+Alt).

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/makerdiary/python-keyboard/issues/20#issuecomment-706210364, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAIDVSDYGEZMZIXU7Q4KY5LSJ4L3PANCNFSM4SJZQW6A .

xiongyihui commented 3 years ago

So AltGr is remapped to Ctrl + Alt by the web browser :joy: