A game framework written with osu! in mind.
at master 1.3 kB view raw
1// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. 2// See the LICENCE file in the repository root for full licence text. 3 4using osu.Framework.Statistics; 5using System.Collections.Generic; 6using osu.Framework.Development; 7 8namespace osu.Framework.Threading 9{ 10 public class InputThread : GameThread 11 { 12 public InputThread() 13 : base(name: "Input") 14 { 15 } 16 17 internal override IEnumerable<StatisticsCounterType> StatisticsCounters => new[] 18 { 19 StatisticsCounterType.MouseEvents, 20 StatisticsCounterType.KeyEvents, 21 StatisticsCounterType.JoystickEvents, 22 StatisticsCounterType.MidiEvents, 23 StatisticsCounterType.TabletEvents, 24 }; 25 26 protected override void PrepareForWork() 27 { 28 // Intentionally inhibiting the base implementation which spawns a native thread. 29 // Therefore, we need to run Initialize inline. 30 Initialize(true); 31 } 32 33 public override bool IsCurrent => ThreadSafety.IsInputThread; 34 35 internal sealed override void MakeCurrent() 36 { 37 base.MakeCurrent(); 38 39 ThreadSafety.IsInputThread = true; 40 } 41 } 42}