Input: Refactor Keyboard Handling To Use Physical Keys #13
No reviewers
Labels
No labels
audio
bug
confirmed
cpu
critical
development
enhancement
gpu
graphics-backend:opengl
graphics-backend:vulkan
gui
help wanted
horizon/hle
i18n
infra
input
kernel
linux
macos
suggestion
windows
No assignees
3 participants
Notifications
Due date
No due date set.
Reference
projects/Ryubing!13
Loading…
Reference in a new issue
No description provided.
Delete branch "Babib3l/Ryubing:physical-keyboard-refactor"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
This PR refactors keyboard handling to use physical key mappings for all gameplay input, ensuring controls remain consistent across different OS keyboard layouts.
I'd like to give out an ENORMOUS thank you to @Neo for his very generous help on getting MacOS caps lock behaviour working, but as well for taking the time for extensive testing, planning and discussions, and finally for writing this PR message :) Keep being awsome pal 👊
New Features :
KeyboardLayout.json.Improvements :
Fixes :
Current Limitations
These are planned on being fixed/improved upon in future PRs:
5aab5f205d38d49fd7cffdf1e38c8acd93017165WIP: Input: Refactor Keyboard Handling To Use Physical Keys + General input-related fixesto Input: Refactor Keyboard Handling To Use Physical Keys + General input-related fixes5b9cb52d2e8a1a248303f22f26c516a47f0fa9e2c8e78b729838d49fd7cf38d49fd7cff3474f65e434ca2e6c81f22f26c516f22f26c516ffbf28eb1bb9d02ae5bbaf71a60c41this MR is now complete, there are no more features to be added, and all bugs that have been reported are fixed 🥳
99183d4a932ba7646ae12ba7646ae17bb78fec4b7bb78fec4bc5d460809cc5d460809c9142eb2970e4b3aca925572585151d572585151da87f5c4fd3a87f5c4fd3c1ea970fecc1ea970fec8f181a7f8e8f181a7f8e166bf1c29f166bf1c29f81c5a3f76aInput: Refactor Keyboard Handling To Use Physical Keys + General input-related fixesto Input: Refactor Keyboard Handling To Use Physical Keys81c5a3f76a4699d4a4fa2b37da884dc2eda68f30c2eda68f30d63fb23a2cd63fb23a2c10cea611c410cea611c4d2ceda5416d2ceda5416548bb230dcA couple of things need to be changed before merge, and you need to sync your PR with master to resolve some conflicts that have cropped up.
@ -22,0 +40,4 @@{string source = buttonFromState is not null ? "state" : "buffered-press";Logger.Debug?.Print(LogClass.UI, $"Keyboard assigner registered key={_pressedButton.Value.AsHidType<Key>()}, source={source}, cancelPressed={ShouldCancel()}");}You have two of the same check here. I propose this instead:
Though I think you can get away with not having the second check? It's worth considering taking another look at this method, there's probably something you can do here.
I've refactored it to consolidate into two clear conditions : first initialise the button if null, then log if it's now set, which eliminates the duplicate check and makes the logic more readable.
commit b1ce9d62280db6a316b0922bc335bff99d90d9af
@ -97,0 +181,4 @@{if (OperatingSystem.IsMacOS()){var flags = CGEventSourceFlagsState(CGEventSourceStateID.HIDSystemState);Please change this to not use
var.@ -97,0 +195,4 @@}catch{// ignore and fallback to "not pressed"Not a good idea to swallow errors. I would recommend using UI debug logs here to note the "issue" and exception before moving forward.
commit d32b1b3088cafb6d7c63744293904a92abbb848e
@ -150,0 +287,4 @@AvaPhysicalKey.Backslash,// NOTE: invalidAvaPhysicalKey.NoneYou have several repeating
AvaPhysicalKey.nonelisted here, and only some are invalid? Why is that?The
AvaPhysicalKey.Noneentries are just placeholders in the mapping array forAvalonia.Input.Keyvalues that don’t have a corresponding physical key mapping.Only the first/last
Noneare explicitly marked as invalid sentinel values; the intermediate ones are simply unmapped gaps becauseKeyis not contiguous and some keys have no direct physical equivalent@ -0,0 +124,4 @@_observedLayoutLabelsLoaded = true;}}EnsureObservedLayoutLabelsLoaded()needs to be rewritten. We want to avoid nesting and swallowing errors.@ -0,0 +143,4 @@}catch{}See above.
@ -218,1 +235,4 @@}catch (NotSupportedException){}See above.
@ -285,0 +338,4 @@int deviceIndex = -1;for (int i = 0; i < Devices.Count; i++){var device = Devices[i];Please change this to not use
var.@ -535,0 +820,4 @@{// Avalonia bug: setting a newly instanced ComboBox to 0// causes the selected item to show up blank// Workaround: set the box to 1 and then 0I understand that you're refactoring here: please document the issue with a link to information on the issue if and when applicable.
Could be one of these (or another):
https://github.com/AvaloniaUI/Avalonia/issues/4610
https://github.com/AvaloniaUI/Avalonia/discussions/18834
@ -614,0 +909,4 @@selectedDeviceIndex = -1;for (int i = 0; i < Devices.Count; i++){var device = Devices[i];Please change this to not use
var.@ -723,3 +989,3 @@else if (activeDevice.Type == DeviceType.Controller){bool isNintendoStyle = Devices.ToList().FirstOrDefault(x => x.Id == activeDevice.Id).Name.Contains("Nintendo");bool isNintendoStyle = activeDevice.Name.Contains("Nintendo");I wonder if the SDL driver is active at this point? Might make more sense to check the vendor ID of the device.
commit 8ec4d5821bc1d7bcd304e92633fafc7b15f0b3ca
@ -15,0 +43,4 @@return;}var mainWindow = RyujinxApp.MainWindow;Please change this to not use
var.548bb230dccf3b6b29a9a83cf8084418be83cee18ec4d5821bcf27290dc4