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
Fix Ctrl keycodes #7191
base: master
Are you sure you want to change the base?
Fix Ctrl keycodes #7191
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I was too quick to react. It's probably okay, so long as everyone's using the constants rather than hardcoding the values. Just add something in the CHANGES
file such as [BREAKING CHANGE] CONTROL_LEFT and CONTROL_RIGHT are now keycodes 113 and 114 for all platforms, to match Android
so it's less likely to catch someone out by surprise.
I checked these files, so it looks okay for all platforms:
Could be a big problem for users that store key mapping in a file. Maybe having a mapping for these keys in DefaultAndroidInput would be better no? |
Depends how they store their mapping. If it's just the raw values and not a human-readable format, it's a minor inconvenience. // Psuedocode of sorts for updating outdated key mapping
if (userKey == 129) userKey = Input.Keys.CONTROL_LEFT;
if (userKey == 130) userKey = Input.Keys.CONTROL_RIGHT; Remapping in |
We could add a note about storing key mapping in a file to An alternative is to keep the current keycodes and add a check like this one to int keycode = e.getKeyCode();
if (keycode == 113) {
keycode = Input.Keys.CONTROL_LEFT; //129
} else if (keycode == 114) {
keycode = Input.Keys.CONTROL_RIGHT; //130
} |
If someone maps the key values by configuration, it should be no problem as the real key values were saved. |
I don't quite understand, how this does not break. If I write |
Usually you write custom key mapping configuration in a way that users press the keys they want. The bug here is that a constant in our framework has the wrong value. Independent from that, if a user presses a key, the system gives the real value and not a wrong value from our framework. If you really wrote the old value 129 in your mapping file, the mapping just did not work before the change and after the change. At least it did not work when the user pressed Ctrl key |
How I understand it is the following: libgdx/backends/gdx-backend-lwjgl3/src/com/badlogic/gdx/backends/lwjgl3/DefaultLwjgl3Input.java Lines 137 to 138 in 75612da
I then receive the gdx keycode the user pressed for the custom mapping and write it to a file. After that I can compare the saved gdx keycode to the pressed gdx keycode. If now the pressed gdx keycode changes, this wont work anymore in my understanding. I can test this pr someday later.
I just tested it, mapping the Ctrl key works on desktop. |
My fault, I only thought about Android and forgot that all other platforms use the constants for internal mapping. Sorry. |
In fact, I did not think about the key mappings being saved in a file while preparing this PR. On platforms other than Android, there might be problems when saving the old values (129 and 130) from an old libGDX version, upgrading libGDX, and then loading the values, which will no longer correspond to those of Does anyone prefer the approach suggested here? #7191 (comment) |
Fixes #7189.