mirror of
https://git.naxdy.org/Mirror/Ryujinx.git
synced 2024-11-15 09:35:27 +00:00
a0720b5681
* Refactoring HOS folder structure Refactoring HOS folder structure: - Added some subfolders when needed (Following structure decided in private). - Added some `Types` folders when needed. - Little cleanup here and there. - Add services placeholders for every HOS services (close #766 and #753). * Remove Types namespaces
92 lines
4 KiB
C#
92 lines
4 KiB
C#
using Ryujinx.HLE.HOS.Kernel.Common;
|
|
using Ryujinx.HLE.HOS.Kernel.Threading;
|
|
using Ryujinx.HLE.HOS.Services.Bluetooth.BluetoothDriver;
|
|
using Ryujinx.HLE.HOS.Services.Settings;
|
|
using System;
|
|
|
|
namespace Ryujinx.HLE.HOS.Services.Bluetooth
|
|
{
|
|
[Service("btdrv")]
|
|
class IBluetoothDriver : IpcService
|
|
{
|
|
private string _unknownLowEnergy;
|
|
|
|
public IBluetoothDriver(ServiceCtx context) { }
|
|
|
|
[Command(46)]
|
|
// InitializeBluetoothLe() -> handle<copy>
|
|
public ResultCode InitializeBluetoothLe(ServiceCtx context)
|
|
{
|
|
NxSettings.Settings.TryGetValue("bluetooth_debug!skip_boot", out object debugMode);
|
|
|
|
if ((bool)debugMode)
|
|
{
|
|
if (BluetoothEventManager.InitializeBleDebugEventHandle == 0)
|
|
{
|
|
BluetoothEventManager.InitializeBleDebugEvent = new KEvent(context.Device.System);
|
|
|
|
if (context.Process.HandleTable.GenerateHandle(BluetoothEventManager.InitializeBleDebugEvent.ReadableEvent, out BluetoothEventManager.InitializeBleDebugEventHandle) != KernelResult.Success)
|
|
{
|
|
throw new InvalidOperationException("Out of handles!");
|
|
}
|
|
}
|
|
|
|
if (BluetoothEventManager.UnknownBleDebugEventHandle == 0)
|
|
{
|
|
BluetoothEventManager.UnknownBleDebugEvent = new KEvent(context.Device.System);
|
|
|
|
if (context.Process.HandleTable.GenerateHandle(BluetoothEventManager.UnknownBleDebugEvent.ReadableEvent, out BluetoothEventManager.UnknownBleDebugEventHandle) != KernelResult.Success)
|
|
{
|
|
throw new InvalidOperationException("Out of handles!");
|
|
}
|
|
}
|
|
|
|
if (BluetoothEventManager.RegisterBleDebugEventHandle == 0)
|
|
{
|
|
BluetoothEventManager.RegisterBleDebugEvent = new KEvent(context.Device.System);
|
|
|
|
if (context.Process.HandleTable.GenerateHandle(BluetoothEventManager.RegisterBleDebugEvent.ReadableEvent, out BluetoothEventManager.RegisterBleDebugEventHandle) != KernelResult.Success)
|
|
{
|
|
throw new InvalidOperationException("Out of handles!");
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
_unknownLowEnergy = "low_energy";
|
|
|
|
if (BluetoothEventManager.InitializeBleEventHandle == 0)
|
|
{
|
|
BluetoothEventManager.InitializeBleEvent = new KEvent(context.Device.System);
|
|
|
|
if (context.Process.HandleTable.GenerateHandle(BluetoothEventManager.InitializeBleEvent.ReadableEvent, out BluetoothEventManager.InitializeBleEventHandle) != KernelResult.Success)
|
|
{
|
|
throw new InvalidOperationException("Out of handles!");
|
|
}
|
|
}
|
|
|
|
if (BluetoothEventManager.UnknownBleEventHandle == 0)
|
|
{
|
|
BluetoothEventManager.UnknownBleEvent = new KEvent(context.Device.System);
|
|
|
|
if (context.Process.HandleTable.GenerateHandle(BluetoothEventManager.UnknownBleEvent.ReadableEvent, out BluetoothEventManager.UnknownBleEventHandle) != KernelResult.Success)
|
|
{
|
|
throw new InvalidOperationException("Out of handles!");
|
|
}
|
|
}
|
|
|
|
if (BluetoothEventManager.RegisterBleEventHandle == 0)
|
|
{
|
|
BluetoothEventManager.RegisterBleEvent = new KEvent(context.Device.System);
|
|
|
|
if (context.Process.HandleTable.GenerateHandle(BluetoothEventManager.RegisterBleEvent.ReadableEvent, out BluetoothEventManager.RegisterBleEventHandle) != KernelResult.Success)
|
|
{
|
|
throw new InvalidOperationException("Out of handles!");
|
|
}
|
|
}
|
|
}
|
|
|
|
return ResultCode.Success;
|
|
}
|
|
}
|
|
} |