aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.HLE/HOS/Services/Hid/HidDevices/BaseDevice.cs
blob: 59d6dfa3ebe0b4cf0de660f0a70a66d74122be05 (plain)
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
using static Ryujinx.HLE.HOS.Services.Hid.Hid;

namespace Ryujinx.HLE.HOS.Services.Hid
{
    public abstract class BaseDevice
    {
        protected readonly Switch _device;
        public bool Active;

        public BaseDevice(Switch device, bool active)
        {
            _device = device;
            Active = active;
        }

        internal static int UpdateEntriesHeader(ref CommonEntriesHeader header, out int previousEntry)
        {
            header.NumEntries = SharedMemEntryCount;
            header.MaxEntryIndex = SharedMemEntryCount - 1;

            previousEntry = (int)header.LatestEntry;
            header.LatestEntry = (header.LatestEntry + 1) % SharedMemEntryCount;

            header.TimestampTicks = GetTimestampTicks();

            return (int)header.LatestEntry; // EntryCount shouldn't overflow int
        }
    }
}