esrille / new-keyboard

The Esrille New Keyboard
https://www.esrille.com/keyboard/
47 stars 22 forks source link

emitKey() doesn't allow shifted keys (only lowercase keys) #9

Closed listx closed 6 years ago

listx commented 8 years ago

From initial testing, it appears that it is currently not possible to have a key send modifier keys togother with regular keys. For example, I'd like to have a key that sends ~/ (KEY_LEFTSHIFT + KEY_GRAVE_ACCENT, KEY_SLASH) but

emitKey(KEY_LEFTSHIFT)
emitKey(KEY_GRAVE_ACCENT)
emitKey(KEY_SLASH)

does not work. The current default layouts for the vanilla FN layer have some "mini" macros like CTRL+C but it seems to apply the modifier key to all keys (If I put those three keys in an FN layer, then I get ~? instead of ~/).

I think this feature could benefit existing macros like FN-F1 that could really use some SHIFT-layer keys.

ShikiOkasaka commented 8 years ago

Your understanding about the current implementation is correct.

If you need to support only a few characters that require modifier keys together, please refer to APP_KeyboardScan() and see how KEYPAD_PERCENT is decomposed into KEY_5 and leftShift in, https://github.com/esrille/new-keyboard/blob/master/firmware/third_party/mla_v2013_12_20/apps/usb/device/hid_keyboard/firmware/src/app_device_keyboard.c

Note it is difficult to add more features to the standard USB NISSE firmware due to the limited flash memory size of PIC18F4550. The Bluetooth/USB NISSE, currently available only in Japan, uses PIC18F47J53 which has larger flash memory, and maybe we will introduce a richer framework that eases your keymap customization in the future.

listx commented 8 years ago

To clarify, the KEYPAD_PERCENT decomposition code is an example of appending additional modifier keys to a single "report" --- I've tried this an it affects the keys that follow KEYPAD_PERCENT to be shifted as well.

I suppose it will be an interesting challenge to add this feature into the existing USB NISSE, given the memory constraints you've mentioned.

ShikiOkasaka commented 8 years ago

Please note the current KEYPAD_PERCENT decomposition code is only for the specific needs for the default firmware. Please use it as an implementation hint for your customization.

In your case, please try modifying the code like:

            if (inputReport.keys[0] == KEYPAD_PERCENT) {
                inputReport.keys[0] = KEY_5;
                inputReport.modifiers.bits.leftShift = 1;
            } else
                inputReport.modifiers.bits.leftShift = 0;
ShikiOkasaka commented 8 years ago

The above behavior is now default at 4ac50d3 and refined at 3f7a62d for more customization.

listx commented 8 years ago

Thanks for the changes. I had to do

emitKey(0);
emitKey(KEY_ZQ_TILDE_MACRO);
emitKey(KEY_SLASH);

because otherwise the first key KEY_ZQ_TILDE_MACRO (which gets decomposed just like KEYPAD_PERCENT) would get ignored. I think this is because of https://github.com/esrille/new-keyboard/commit/3f7a62dee7011b9e7dcee4d7e41b03690755ba73#diff-1b6e285f254a8377a7cfaa8768785732R569 whose purpose I cannot figure out. Otherwise, this works as expected and I can get it to input ~/ as I originally wanted.

ShikiOkasaka commented 8 years ago

Thanks for the report. The first macro key is processed differently at, https://github.com/esrille/new-keyboard/blob/3f7a62dee7011b9e7dcee4d7e41b03690755ba73/firmware/third_party/mla_v2013_12_20/apps/usb/device/hid_keyboard/firmware/src/app_device_keyboard.c#L605-L610 and the decomposition steps are not included; you may add the similar decomposition steps there, but you're right and emitting 0 as the first macro key achieves basically the same result.

Sylk commented 7 years ago

Update?

ShikiOkasaka commented 7 years ago

We're likely to release a new USB NISSE firmware with more free space mainly for the customers in the United States. Also if you have a specific request, feel free to open another issue.