2018-12-18 05:33:36 +00:00
|
|
|
using Ryujinx.HLE.HOS.Kernel.Threading;
|
2019-09-19 01:45:11 +01:00
|
|
|
using Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.SystemAppletProxy;
|
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
|
|
|
{
|
2021-06-21 17:41:37 +01:00
|
|
|
public ConcurrentQueue<AppletMessage> Messages { get; }
|
2018-03-19 18:58:46 +00:00
|
|
|
|
|
|
|
public FocusState FocusState { get; private set; }
|
|
|
|
|
2020-12-01 23:23:43 +00:00
|
|
|
public KEvent MessageEvent { get; }
|
|
|
|
|
|
|
|
public IdDictionary AppletResourceUserIds { get; }
|
2018-03-19 18:58:46 +00:00
|
|
|
|
2021-10-12 20:54:21 +01:00
|
|
|
public IdDictionary IndirectLayerHandles { get; }
|
|
|
|
|
2018-12-06 11:16:24 +00:00
|
|
|
public AppletStateMgr(Horizon system)
|
2018-03-19 18:58:46 +00:00
|
|
|
{
|
2021-06-21 17:41:37 +01:00
|
|
|
Messages = new ConcurrentQueue<AppletMessage>();
|
2020-05-04 04:41:29 +01:00
|
|
|
MessageEvent = new KEvent(system.KernelContext);
|
2020-12-01 23:23:43 +00:00
|
|
|
|
|
|
|
AppletResourceUserIds = new IdDictionary();
|
2021-10-12 20:54:21 +01:00
|
|
|
IndirectLayerHandles = new IdDictionary();
|
2018-03-19 18:58:46 +00:00
|
|
|
}
|
|
|
|
|
2018-12-06 11:16:24 +00:00
|
|
|
public void SetFocus(bool isFocused)
|
2018-03-19 18:58:46 +00:00
|
|
|
{
|
2020-12-16 00:41:42 +00:00
|
|
|
FocusState = isFocused ? FocusState.InFocus : FocusState.OutOfFocus;
|
2018-03-19 18:58:46 +00:00
|
|
|
|
2021-06-21 17:41:37 +01:00
|
|
|
Messages.Enqueue(AppletMessage.FocusStateChanged);
|
|
|
|
|
|
|
|
if (isFocused)
|
|
|
|
{
|
|
|
|
Messages.Enqueue(AppletMessage.ChangeIntoForeground);
|
|
|
|
}
|
|
|
|
|
2018-09-23 19:11:46 +01:00
|
|
|
MessageEvent.ReadableEvent.Signal();
|
2018-03-19 18:58:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|