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