aboutsummaryrefslogtreecommitdiff
path: root/src/Ryujinx.Input.SDL2/SDLKeyboardDriver.cs
blob: 965f7935aa793e8aa38ec893f70008efa43cf5d7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
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()
        {
            GC.SuppressFinalize(this);
            Dispose(true);
        }

        public IGamepad GetGamepad(string id)
        {
            if (!_keyboardIdentifers[0].Equals(id))
            {
                return null;
            }

            return new SDL2Keyboard(this, _keyboardIdentifers[0], "All keyboards");
        }
    }
}