aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Input.SDL2/SDLKeyboardDriver.cs
diff options
context:
space:
mode:
authorMary <me@thog.eu>2021-05-21 01:16:34 +0200
committerGitHub <noreply@github.com>2021-05-21 01:16:34 +0200
commit2c3dab69860e8a7b23cfaba603b3bb31b75a168b (patch)
tree1ee5dd5849ee4dbccc03da2dbf6884c89d66d241 /Ryujinx.Input.SDL2/SDLKeyboardDriver.cs
parent5271cfe70b88d4dc5feb3f5be71ffc3951e9a354 (diff)
input: Implement a SDL2 keyboard backend (#2277)
* input: Implement a SDL2 keyboard backend Add a new keyboard backend to the Ryujinx.Input.SDL2 project. This is currently unused. * Address Ac_k's comments * Address gdkchan's comments
Diffstat (limited to 'Ryujinx.Input.SDL2/SDLKeyboardDriver.cs')
-rw-r--r--Ryujinx.Input.SDL2/SDLKeyboardDriver.cs54
1 files changed, 54 insertions, 0 deletions
diff --git a/Ryujinx.Input.SDL2/SDLKeyboardDriver.cs b/Ryujinx.Input.SDL2/SDLKeyboardDriver.cs
new file mode 100644
index 00000000..e9361c24
--- /dev/null
+++ b/Ryujinx.Input.SDL2/SDLKeyboardDriver.cs
@@ -0,0 +1,54 @@
+using Ryujinx.SDL2.Common;
+using System;
+
+namespace Ryujinx.Input.SDL2
+{
+ public class SDL2KeyboardDriver : IGamepadDriver
+ {
+ public SDL2KeyboardDriver()
+ {
+ SDL2Driver.Instance.Initialize();
+ }
+
+ public string DriverName => "SDL2";
+
+ private static readonly string[] _keyboardIdentifers = new string[1] { "0" };
+
+ public ReadOnlySpan<string> GamepadsIds => _keyboardIdentifers;
+
+ public event Action<string> OnGamepadConnected
+ {
+ add { }
+ remove { }
+ }
+
+ public event Action<string> OnGamepadDisconnected
+ {
+ add { }
+ remove { }
+ }
+
+ protected virtual void Dispose(bool disposing)
+ {
+ if (disposing)
+ {
+ SDL2Driver.Instance.Dispose();
+ }
+ }
+
+ public void Dispose()
+ {
+ Dispose(true);
+ }
+
+ public IGamepad GetGamepad(string id)
+ {
+ if (!_keyboardIdentifers[0].Equals(id))
+ {
+ return null;
+ }
+
+ return new SDL2Keyboard(this, _keyboardIdentifers[0], "All keyboards");
+ }
+ }
+} \ No newline at end of file