2018-08-17 00:47:36 +01:00
|
|
|
using Ryujinx.HLE.HOS.Kernel;
|
|
|
|
using Ryujinx.HLE.HOS.Services.Am;
|
2018-03-19 18:58:46 +00:00
|
|
|
using System.Collections.Concurrent;
|
|
|
|
|
2018-08-17 00:47:36 +01:00
|
|
|
namespace Ryujinx.HLE.HOS.SystemState
|
2018-03-19 18:58:46 +00:00
|
|
|
{
|
2018-09-19 00:36:43 +01:00
|
|
|
class AppletStateMgr
|
2018-03-19 18:58:46 +00:00
|
|
|
{
|
2018-12-05 00:52:39 +00:00
|
|
|
private ConcurrentQueue<MessageInfo> Messages;
|
2018-03-19 18:58:46 +00:00
|
|
|
|
|
|
|
public FocusState FocusState { get; private set; }
|
|
|
|
|
2018-12-05 00:52:39 +00:00
|
|
|
public KEvent MessageEvent { get; private set; }
|
2018-03-19 18:58:46 +00:00
|
|
|
|
2018-12-05 00:52:39 +00:00
|
|
|
public AppletStateMgr(Horizon System)
|
2018-03-19 18:58:46 +00:00
|
|
|
{
|
2018-12-05 00:52:39 +00:00
|
|
|
Messages = new ConcurrentQueue<MessageInfo>();
|
2018-03-19 18:58:46 +00:00
|
|
|
|
2018-12-05 00:52:39 +00:00
|
|
|
MessageEvent = new KEvent(System);
|
2018-03-19 18:58:46 +00:00
|
|
|
}
|
|
|
|
|
2018-12-05 00:52:39 +00:00
|
|
|
public void SetFocus(bool IsFocused)
|
2018-03-19 18:58:46 +00:00
|
|
|
{
|
2018-12-05 00:52:39 +00:00
|
|
|
FocusState = IsFocused
|
2018-03-19 18:58:46 +00:00
|
|
|
? FocusState.InFocus
|
|
|
|
: FocusState.OutOfFocus;
|
|
|
|
|
|
|
|
EnqueueMessage(MessageInfo.FocusStateChanged);
|
|
|
|
}
|
|
|
|
|
2018-12-05 00:52:39 +00:00
|
|
|
public void EnqueueMessage(MessageInfo Message)
|
2018-03-19 18:58:46 +00:00
|
|
|
{
|
2018-12-05 00:52:39 +00:00
|
|
|
Messages.Enqueue(Message);
|
2018-03-19 18:58:46 +00:00
|
|
|
|
2018-09-23 19:11:46 +01:00
|
|
|
MessageEvent.ReadableEvent.Signal();
|
2018-03-19 18:58:46 +00:00
|
|
|
}
|
|
|
|
|
2018-12-05 00:52:39 +00:00
|
|
|
public bool TryDequeueMessage(out MessageInfo Message)
|
2018-03-19 18:58:46 +00:00
|
|
|
{
|
2018-12-05 00:52:39 +00:00
|
|
|
if (Messages.Count < 2)
|
2018-03-19 18:58:46 +00:00
|
|
|
{
|
2018-09-23 19:11:46 +01:00
|
|
|
MessageEvent.ReadableEvent.Clear();
|
2018-03-19 18:58:46 +00:00
|
|
|
}
|
|
|
|
|
2018-12-05 00:52:39 +00:00
|
|
|
return Messages.TryDequeue(out Message);
|
2018-03-19 18:58:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|