mirror of
https://github.com/ryujinx-mirror/ryujinx.git
synced 2024-10-02 16:50:20 -07:00

* So much boilerplate * Slow and steady * Restructure + Ack suggestions * Restructure + Ack suggestions * Restructure * Clean * Propogate those fields i forgot about * It builds * Progress * Almost there * Fix stupid mistake * Fix more stupid mistakes * Actually fix fuck ups * Start localising * r/therestofthefuckingowl * Localise ButtonKeyAssigner * Are you feeling it now mr krabs * We’re done at last * Crimes against code * Try me in the Hague * Please be quiet * Crimes are here to stay * Dispose stuff * Cleanup a couple things * Visual fixes and improvements One weird bug * Fix rebase errors * Fixes * Ack Suggestions Remaining ack suggestions Update src/Ryujinx.Ava/UI/Models/Input/ControllerInputConfig.cs Co-authored-by: Ac_K <Acoustik666@gmail.com> Update src/Ryujinx.Ava/UI/Models/Input/ControllerInputConfig.cs Co-authored-by: Ac_K <Acoustik666@gmail.com> * Formatting and error More Ava 11-ness Whoops * Code style fixes * Style fixes * Analyzer fix * Remove all ReflectionBindings * Remove ambigious object * Remove redundant property * Old man yells at formatter * r e a d o n l y * Fix profiles * Use new Sliders --------- Co-authored-by: Ac_K <Acoustik666@gmail.com>
51 lines
1.2 KiB
C#
51 lines
1.2 KiB
C#
namespace Ryujinx.Input.Assigner
|
|
{
|
|
/// <summary>
|
|
/// <see cref="IButtonAssigner"/> implementation for <see cref="IKeyboard"/>.
|
|
/// </summary>
|
|
public class KeyboardKeyAssigner : IButtonAssigner
|
|
{
|
|
private readonly IKeyboard _keyboard;
|
|
|
|
private KeyboardStateSnapshot _keyboardState;
|
|
|
|
public KeyboardKeyAssigner(IKeyboard keyboard)
|
|
{
|
|
_keyboard = keyboard;
|
|
}
|
|
|
|
public void Initialize() { }
|
|
|
|
public void ReadInput()
|
|
{
|
|
_keyboardState = _keyboard.GetKeyboardStateSnapshot();
|
|
}
|
|
|
|
public bool HasAnyButtonPressed()
|
|
{
|
|
return GetPressedButton() is not null;
|
|
}
|
|
|
|
public bool ShouldCancel()
|
|
{
|
|
return _keyboardState.IsPressed(Key.Escape);
|
|
}
|
|
|
|
public ButtonValue? GetPressedButton()
|
|
{
|
|
ButtonValue? keyPressed = null;
|
|
|
|
for (Key key = Key.Unknown; key < Key.Count; key++)
|
|
{
|
|
if (_keyboardState.IsPressed(key))
|
|
{
|
|
keyPressed = new(key);
|
|
break;
|
|
}
|
|
}
|
|
|
|
return !ShouldCancel() ? keyPressed : null;
|
|
}
|
|
}
|
|
}
|