Implement Bluetooth, Btm, Hid and Nsd services and calls. (#761)
- Implement `btdrv` service (IBluetoothDriver).
Implement call `InitializeBluetoothLe` for initialize events of `bt` service according to RE.
- Implement `bt` service (IBluetoothUser).
Implement call `RegisterBleEvent` according to RE.
- Add a placeholder for the `btm` service (close #750).
- Implement `btm:u` service (IBtmUser) (close #751).
Implement call `GetCore` according to RE (close #752).
- Implement `IBtmUserCore` and calls `AcquireBleScanEvent`, `AcquireBleConnectionEvent`, `AcquireBleServiceDiscoveryEvent` and `AcquireBleMtuConfigEvent` according to RE.
- Implement `SetPalmaBoostMode` in `IHidServer` according to RE.
- Add stub for `SetIsPalmaAllConnectable` in `IHidServer` because we will not support Palma devices soon.
- Implement `nsd:a` and `nsd:u` service (IManager) (close #755).
Implement call `ResolveEx` according to RE (close #756).
Implement calls `GetSettingName`, `GetEnvironmentIdentifier`, `GetDeviceId`, `DeleteSettings`, `Resolve`, `ReadSaveDataFromFsForTest`, `WriteSaveDataToFsForTest` and `DeleteSaveDataOfFsForTest` according to RE.
2019-09-06 10:58:50 -04:00
|
|
|
|
using Ryujinx.HLE.HOS.Kernel.Common;
|
|
|
|
|
using Ryujinx.HLE.HOS.Kernel.Threading;
|
2019-09-18 20:45:11 -04:00
|
|
|
|
using Ryujinx.HLE.HOS.Services.Bluetooth.BluetoothDriver;
|
|
|
|
|
using Ryujinx.HLE.HOS.Services.Settings;
|
Implement Bluetooth, Btm, Hid and Nsd services and calls. (#761)
- Implement `btdrv` service (IBluetoothDriver).
Implement call `InitializeBluetoothLe` for initialize events of `bt` service according to RE.
- Implement `bt` service (IBluetoothUser).
Implement call `RegisterBleEvent` according to RE.
- Add a placeholder for the `btm` service (close #750).
- Implement `btm:u` service (IBtmUser) (close #751).
Implement call `GetCore` according to RE (close #752).
- Implement `IBtmUserCore` and calls `AcquireBleScanEvent`, `AcquireBleConnectionEvent`, `AcquireBleServiceDiscoveryEvent` and `AcquireBleMtuConfigEvent` according to RE.
- Implement `SetPalmaBoostMode` in `IHidServer` according to RE.
- Add stub for `SetIsPalmaAllConnectable` in `IHidServer` because we will not support Palma devices soon.
- Implement `nsd:a` and `nsd:u` service (IManager) (close #755).
Implement call `ResolveEx` according to RE (close #756).
Implement calls `GetSettingName`, `GetEnvironmentIdentifier`, `GetDeviceId`, `DeleteSettings`, `Resolve`, `ReadSaveDataFromFsForTest`, `WriteSaveDataToFsForTest` and `DeleteSaveDataOfFsForTest` according to RE.
2019-09-06 10:58:50 -04:00
|
|
|
|
using System;
|
|
|
|
|
|
|
|
|
|
namespace Ryujinx.HLE.HOS.Services.Bluetooth
|
|
|
|
|
{
|
|
|
|
|
[Service("btdrv")]
|
|
|
|
|
class IBluetoothDriver : IpcService
|
|
|
|
|
{
|
2020-04-20 17:59:59 -04:00
|
|
|
|
#pragma warning disable CS0169
|
Implement Bluetooth, Btm, Hid and Nsd services and calls. (#761)
- Implement `btdrv` service (IBluetoothDriver).
Implement call `InitializeBluetoothLe` for initialize events of `bt` service according to RE.
- Implement `bt` service (IBluetoothUser).
Implement call `RegisterBleEvent` according to RE.
- Add a placeholder for the `btm` service (close #750).
- Implement `btm:u` service (IBtmUser) (close #751).
Implement call `GetCore` according to RE (close #752).
- Implement `IBtmUserCore` and calls `AcquireBleScanEvent`, `AcquireBleConnectionEvent`, `AcquireBleServiceDiscoveryEvent` and `AcquireBleMtuConfigEvent` according to RE.
- Implement `SetPalmaBoostMode` in `IHidServer` according to RE.
- Add stub for `SetIsPalmaAllConnectable` in `IHidServer` because we will not support Palma devices soon.
- Implement `nsd:a` and `nsd:u` service (IManager) (close #755).
Implement call `ResolveEx` according to RE (close #756).
Implement calls `GetSettingName`, `GetEnvironmentIdentifier`, `GetDeviceId`, `DeleteSettings`, `Resolve`, `ReadSaveDataFromFsForTest`, `WriteSaveDataToFsForTest` and `DeleteSaveDataOfFsForTest` according to RE.
2019-09-06 10:58:50 -04:00
|
|
|
|
private string _unknownLowEnergy;
|
2020-04-20 17:59:59 -04:00
|
|
|
|
#pragma warning restore CS0169
|
Implement Bluetooth, Btm, Hid and Nsd services and calls. (#761)
- Implement `btdrv` service (IBluetoothDriver).
Implement call `InitializeBluetoothLe` for initialize events of `bt` service according to RE.
- Implement `bt` service (IBluetoothUser).
Implement call `RegisterBleEvent` according to RE.
- Add a placeholder for the `btm` service (close #750).
- Implement `btm:u` service (IBtmUser) (close #751).
Implement call `GetCore` according to RE (close #752).
- Implement `IBtmUserCore` and calls `AcquireBleScanEvent`, `AcquireBleConnectionEvent`, `AcquireBleServiceDiscoveryEvent` and `AcquireBleMtuConfigEvent` according to RE.
- Implement `SetPalmaBoostMode` in `IHidServer` according to RE.
- Add stub for `SetIsPalmaAllConnectable` in `IHidServer` because we will not support Palma devices soon.
- Implement `nsd:a` and `nsd:u` service (IManager) (close #755).
Implement call `ResolveEx` according to RE (close #756).
Implement calls `GetSettingName`, `GetEnvironmentIdentifier`, `GetDeviceId`, `DeleteSettings`, `Resolve`, `ReadSaveDataFromFsForTest`, `WriteSaveDataToFsForTest` and `DeleteSaveDataOfFsForTest` according to RE.
2019-09-06 10:58:50 -04:00
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|