Dewb / monome-rack

VCV Rack plugin for monome Eurorack modules
GNU General Public License v2.0
225 stars 13 forks source link

Support for Non-US keyboards in Teletype #84

Closed jpnielsen closed 9 months ago

jpnielsen commented 2 years ago

What operating system and version are you running?

Windows 11

What version of Rack are you running?

Rack 2.0.4 pre-release

What's the behavior you observed?

My DK keyboard is not mapped correctly in Teletype. _ on my KBD is ? in teletype.

etc.

What should have happened instead?

The keyboard should be mapped correctly, (like in VCV Fundamental Notes)

http://kbdlayout.info/KBDDA/

Dewb commented 2 years ago

Can you try this build and let me know how it works for you? https://github.com/Dewb/monome-rack/actions/runs/1599525521

I initially added international keyboard support (based on Rack 2.0's interpretation of int'l support, which appears to be limited to printable characters) to alpha5, but I got feedback from an ES keyboard user that they strongly preferred the previous behavior of assuming en-US layout (which is what the hardware module does.)

This probably needs to be a switchable option, but I want to understand the user needs a bit more so the configurable behavior actually solves people's problems.

jpnielsen commented 2 years ago

monome-2.0.0-alpha5-e99cc69-win.vcvplugin

"[" and "]" dont work - On my keyboard they are right-alt 8 and 9 "?" don't work - on my KBD it's shift and the key two keys left of backspace.

Didn't test all relevant keys.

Just keep US mapping -it's no biggie - I'll just print the keymap and note what keys they are on a DK keyboard.

vanicat commented 1 year ago

This problem could stop me from using this module: I found it very difficult to not use my keyboard configuration. That said, I can completely understand this is not your priority, and I could also print the en-us layout and use the it. But it will slow me.

iacs commented 1 year ago

I came here to report this issue as well. Currently, it's extremely cumbersome to use this module when it assumes you have an american layout, which most people outside of the US don't.

It would be great to see an update that respected the system's keyboard layout, since this looks like a very deep module

Dewb commented 1 year ago

Absolutely, this is top priority for an update. Unfortunately, given the way the firmware works, changes are needed to both the VCV and the firmware side to make keystroke assignment more flexible. It might make sense to go all the way and add international support to both the hardware and software at the same time. Which is good, it will help both VCV and hardware users, but it means a bit more work.

(Some technical background: USB keyboards do not have a built-in locale; they unfortunately all return the same scancodes based on the default US layout. Interpretation is left up to the operating system. The Teletype firmware does not have an operating system, so it acts directly on the scancodes. We essentially need to add that OS translation layer into the hardware. The VCV Rack version does have the OS translation layer, but it also has the GLFW abstraction layer and Rack's own international translation tools, which help in some ways but make the problem of supporting both environments harder.)

gregdl commented 1 year ago

Thanks for explaining the technical details behind why this is difficult to implement at the moment. I'm also a user with a non-US keyboard. Just curious --- could one workaround be a separate "sketchpad/notepad" module that would default to system keyboard settings (or allow for users to change keyboard settings) and allow users to write teletype scripts within vcv rack? I'm not sure if it'd be possible to have these scripts then passed / uploaded to the teletype behind the scenes or they'd have to upload it manually.

Just an idea that came to mind!

Dewb commented 1 year ago

That's a good approach for a workaround. It's not as convenient as in-Rack editing obviously, but you can write scripts in your favorite text editor, and then right-click Teletype and choose Import scenes > Active scene > Paste and merge clipboard into current scene. You'll need to observe the limits of the Teletype text import format -- keep lines under 30-31 characters, and prefix each clipboard paste with which script you want it to go into. So you could write something like

# M

TR.P 1
L 1 4: CV I P - I 1

in your text editor, and then copy and paste that to populate the M script.

gregdl commented 1 year ago

Thanks for the formatting tips and instructions on importing from an external editor. I suppose my idea was more for something within vcv rack itself? Would it be possible for a text editor in vcv rack to do this with an "upload to teletype" button (for example) that would call this "Import scenes > Active scene > Paste and merge clipboard into current scene" from behind the scenes?

Dewb commented 12 months ago

I started thinking about possible strategies to automate the workaround as you describe, but I think it makes much more sense to apply that energy towards proper international support rather than workarounds. Adding support for both hardware & software is the long-term goal, but I believe we can get some form of VCV Rack-only international support in place as a stepping-stone. What keyboard locale are you using, and are you willing to beta test a custom keyboard map feature?

gregdl commented 12 months ago

that's very generous of you to consider this! i'd be happy to beta test something, i'm using a mac with a standard japanese/JIS keyboard

jpnielsen commented 12 months ago

I have ordered a US keyboard, the issue is solved for me.

Dewb commented 12 months ago

The GLFW to HID mapping is now data-driven rather than hardcoded. You can define custom layout/maps by authoring JSON files. Details are here: https://github.com/Dewb/monome-rack/tree/main/res/keymaps

This seems sufficient to create, as examples, US Dvorak and UK/GB standard layouts. I think it should also be enough to cover the Danish Windows layout mentioned by @jpnielsen. I'm a little less clear on whether this is enough flexibility to make a good layout for the Mac JIS keyboard; I can set my US Mac to Japanese layout, but it doesn't seem to match the behavior of an actual JIS hardware layout.

Does this system, and the instructions linked above, make sense? If anyone is willing to try it out and let me know if it covers your layout needs, I'd appreciate it. It's probably not a good idea for me to guess at international layouts without the ability to try them myself, but I will happily merge additional layouts that folks are able to create and test.

gregdl commented 12 months ago

Thanks for this! It looks great. I had a bit of trouble getting Rack to recognize a manually installed plugin, but it seems like the new version got pushed to the library so it's finally there, but that lost me time. I will try to revisit on the weekend.

I am trying to wrap my head a little around the Mac JIS keyboard and the relevant GLFW & HID keys...