[Rejected] Region Specific Keyboard Input#397
[Rejected] Region Specific Keyboard Input#397Perksey merged 8 commits intodotnet:masterfrom MatijaBrown:master
Conversation
|
I would like to see this be optional/configurable somehow. In games for example, Z typically means the bottom left key, instead of the character Z, similarly to how W/A/S/D are the arrow keys on the left, instead of the literal characters. |
Of course it will be possible to turn the adapting on and off. I am planning to make it so that it can either be set to a certain layout or be automatically adapted, so if, for example, one is developing a game and wants z to be the bottom left, just change the keyboard layout to US-Layout and it will work as usual. |
|
Agree with what Kai said. Please make sure you create a proposal we can review in documentation/proposals before working on the actual implementation. |
I do agree with what Kay said, sorry if it was not obvious from my reply. |
|
I have added a proposal a while ago. Is this what you expected Kai, or did I misunderstand the message? |
HurricanKai
left a comment
There was a problem hiding this comment.
We can discuss this with the ARB as-is, but some early comments for your consideration.
| /// <summary> | ||
| /// The different included layouts. | ||
| /// </summary> | ||
| public enum Layouts |
There was a problem hiding this comment.
I don't think an enum is the right choice here - I feel using inheritance for this would be better.
There was a problem hiding this comment.
One could definitely use inheritance there, the reason I put an enumeration is because this is only meant for the user to set the keyboard layout. I thought about each of the layouts being abstracted from the KeyboardLayout class, but that would mean having to write an own implementation for custom keyboards, while this way one can easily just set a flag. But I guess inheritance would be possible as well, if it fits better.
There was a problem hiding this comment.
My idea would've been that we have some pre-defined instances like KeyboardLayout.QWERTY which would just implement an interface. I think that'd make for the most flexibility while keeping usage equally simple. Of course some boilerplate on our side, but I don't think it's too much
There was a problem hiding this comment.
That's probably the best way, I agree, but what about custom layouts? Just have a KeyboardLayout.Custom? That would work, just be a lot different from the others.
There was a problem hiding this comment.
That'd be a problem with enums, but with static properties that just return different implementations of an interface, a custom layout would just not work via KeyboardLayout
instead I'd be something like Layout = new MyCustomKeyboardLayout()
There was a problem hiding this comment.
I'm guessing slkLyt is SilkLayout? So not some standard format?
Why is that favourable over
public sealed class MyCustomLayout : IKeyboardLayout
{
public Key MapKey(Key original)
{
// probably a switch statement or whatever
}
}I guess having those files mean the user of our user can modify it, but I'm not sure if that's a thing we want to force?
There was a problem hiding this comment.
That is just a way of storing the layout. (I just made up a file extension, in this case yes, silkLayout). It just maps a key code to another, just like that method. Only, instead of the giant switch statement, I thought one could use a Dictionary to map the keys and load the data from a file. That would mean not writing these long switch statements and easier configurabillity. Also, then it would be possible to have a generic Customlayout class that just takes in the file.
I could also just leave out the custom layouts for the beginning and only add the existing ones, then I wouldn't have to bother with that at all, and it wouldn't be to hard to implement later either.
There was a problem hiding this comment.
I mean I guess we can provide a separate type that loads a file - but I don't think the inbuilt ones should also be based on such files.
There was a problem hiding this comment.
Sounds good. So I guess I'll change the proposal documentation to be up to date, and then contact you again.
There was a problem hiding this comment.
I have committed a few changes to the proposal file. Is this better?
| ... | ||
|
|
||
| NoLayout, | ||
| LastLayout |
There was a problem hiding this comment.
NoLayout means using the standard layout (The same as QWERTY, but the standard layout, not QWERTY, they just happen to be the same).
LastLayout is just the count of layouts, if this would ever be requiered.
|
|
||
| ## KeyboardLayout | ||
| ```cs | ||
| public class KeyboardLayout |
There was a problem hiding this comment.
If we keep this class as-is, it can be static
There was a problem hiding this comment.
The Get() methods are static because I believe it to be nicer that way, but one could just as easily use a constructor.
documentation/proposals/Proposal - Region Specific Key Input.md
Outdated
Show resolved
Hide resolved
HurricanKai
left a comment
There was a problem hiding this comment.
Only thing I'm unsure about here is what does QWERTY mean? Will on, for example, a German keyboard Y be mapped to Z and Z to Y?
Unshure, just feels a bit weird.
QWERTY is the name of the keyboard layout (US) that GLFW uses. These (Also QWERTZ for germany) are the official names instead of having LayoutManager.GermanLayout. (Although, there might be QWERTY_Uk and QWERTY_Us, there are slight differences. Also, sorry for not congratulating you on videre, so I wanted to do it now. |
|
API needs work. Discussed in working group meeting 5th March 2021:
|
|
|
I think the general consensus was that this API of this scale just isn't necessary. As discussed in my notes from the meeting, the most we'll probably do is an extension package containing a bunch of region-specific enums which map scancodes to key names. |
|
How come this has been closed? Can you remove the changes from other files so that we can merge in the rejected proposal for future reference? |
I closed it as there doesn't seem anything more to discuss? Or did I miss something? |
|
We tend to merge in even rejected proposals (with |
Oh, alright - well, as far as I know there's no other change. |
|
Cool, once the other file changes have been reverted I'll merge this in. |
|
One small question here, how do I revert the file I accidentally changed? I can't seem to do it without leaving a new commit message, which is obviously not intended. |
|
Just leave a new commit message, we squash PRs down anyway. |
|
Then everything should be reverted. |
Summary of the PR
As I promised a while ago, I would be implementing a way to make the input API care about keyboard layouts, so that, for example, on a German keyboard Z is returned, when the z key is pressed and Y.
The primary intention is to add a base API so that it will be easy to implement new keyboard layouts and also implement a few myself.