Skip to content
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

Character callback with modifiers that is ALWAYS invoked for chars with pressed mods #1618

Open
christianparpart opened this issue Jan 4, 2020 · 8 comments
Labels
input Keyboard, joystick or mouse

Comments

@christianparpart
Copy link

Hi,

It is currently not possible to receive character events with modifiers for all characters that were typed in.

My demo was: A user is typing in Ctrl+[ in standard (en_US) keyboard layout works just fine with key as well as char callback but if you use (for example) de_DE (German[y]) keyboard layout, then in order to send a Ctrl=[, what the user has to press is Ctrl+AltGr+8. This is captured by the key callback as Ctrl+Alt+8 (which is not helpful because the user app itself SHOULD NOT re-implement keyboard layout mapping nor do I know what keyboard mapping the user has) and more importantly, the character callback is not invoked for that, neither is the character-with-modifier callback being invoked for that.

My request basically is to let the character-with-mods callback know about ALL characters being typed in with all modifiers - it also feels like a bug to me that this callback isn't invoked on non-en_US keyboard layouts (my test-case: de_DE), so I'm not sure it actually is a bug or a feature request.

p.s.: I didn't find any resource telling me why glfwSetCharModsCallback is being deprecated. It seems this is the only function that makes sense for me to use (even though it's currently not really fully working); maybe someone knows where to look at for this decision?

Many thanks in advance,
Christian.

@dougbinks
Copy link
Contributor

If you take a look at the issues for glfwSetCharCallback you'll see that it didn't work for the use-case you've described.

Basically a key press such as CTRL+ALT+8 will not result in a character, so there will be no call to glfwSetCharCallback nor to glfwCharCallback. This is not because GLFW is doing something to remove it, but because no character exists to represent this key combination.

However, the key combination ALT+8 does represent a character, [ for the keyboard layout in your example.

So the solution I proposed on the forum is that we need to extent glfwGetKeyName to be able to handle translations in the presence of modifier keys. So the new version would be something like:

const char* glfwGetKeyName ( int key, int scancode, int mods );

Note that glfw would either have to ignore the CTRL mods, or users of the API would need to know that CTRL as a mod will result in no character. I would prefer the later as being more obvious.

@christianparpart
Copy link
Author

Many thanks for clarifying.

@elmindreda elmindreda added the input Keyboard, joystick or mouse label Jan 12, 2020
@zokrezyl
Copy link

zokrezyl commented Jun 13, 2020

Believe or not, working also on a C++ terminal emulator with OpenGL and facing exactly the same issue. Practically I am porting the work under https://github.com/zokrezyl/asciterm to C++.

Do we have any workaround atm? Btw. @christianparpart , would be happy to chat about your design approach if you are planning an open source implementation.

EDIT: @christianparpart I asume this is the source code: https://github.com/christianparpart/contour

@christianparpart
Copy link
Author

Hey @zokrezyl

That sounds amazing, I think it is best to just email me if you want details. I would be happy to chat. ... christian@parpart.family is how you can reach me .

But with regards to glfw. Kitty maintains its own fork and I just ported to QtGui. And to be honest, I don't regret it. :)

See you in your email,
Christian.

@xslendix
Copy link

Hello, any updates on this?

@christianparpart
Copy link
Author

Hello, any updates on this?

@xslendix I gave up on GLFW3 a long time ago. My way to fix all the input issues I had with GLFW was to simply move to Qt. While it may sound heavy, I only link against QtGui (and now also Qt's QML), because all I needed from it was Window creation and input handling. Qt can be quite slim. I also lately made use of QML and so far do not regret in having moved off GLFW for a project like a GUI terminal emulator. -- I keep the frontend connector code quite slim however, to be free to switch in the future just in case i feel like it must be done (again).

@ghost
Copy link

ghost commented Jan 5, 2024

any more updates in 2024?

@christianparpart
Copy link
Author

any more updates in 2024?

Port to QtOpenGL, seriously. Let go of glfw. I gave up on it. I do not regret it. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
input Keyboard, joystick or mouse
Projects
None yet
Development

No branches or pull requests

5 participants