diff options
| author | Ac_K <Acoustik666@gmail.com> | 2019-09-06 16:58:50 +0200 |
|---|---|---|
| committer | Thomas Guillemard <me@thog.eu> | 2019-09-06 16:58:50 +0200 |
| commit | 333651d346db30d6db0f157150d12209ca9120f9 (patch) | |
| tree | 80c975a5cf1ffce27ed590debf336a22cb2bebe4 /Ryujinx.HLE/HOS/Services/Bluetooth | |
| parent | ad40c6a1823773e836a8b2a25e109c92397bfbe4 (diff) | |
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.
Diffstat (limited to 'Ryujinx.HLE/HOS/Services/Bluetooth')
3 files changed, 145 insertions, 0 deletions
diff --git a/Ryujinx.HLE/HOS/Services/Bluetooth/BluetoothEventManager.cs b/Ryujinx.HLE/HOS/Services/Bluetooth/BluetoothEventManager.cs new file mode 100644 index 00000000..9b7ca4c1 --- /dev/null +++ b/Ryujinx.HLE/HOS/Services/Bluetooth/BluetoothEventManager.cs @@ -0,0 +1,25 @@ +using Ryujinx.HLE.HOS.Kernel.Threading; + +namespace Ryujinx.HLE.HOS.Services.Bluetooth +{ + static class BluetoothEventManager + { + public static KEvent InitializeBleDebugEvent; + public static int InitializeBleDebugEventHandle; + + public static KEvent UnknownBleDebugEvent; + public static int UnknownBleDebugEventHandle; + + public static KEvent RegisterBleDebugEvent; + public static int RegisterBleDebugEventHandle; + + public static KEvent InitializeBleEvent; + public static int InitializeBleEventHandle; + + public static KEvent UnknownBleEvent; + public static int UnknownBleEventHandle; + + public static KEvent RegisterBleEvent; + public static int RegisterBleEventHandle; + } +}
\ No newline at end of file diff --git a/Ryujinx.HLE/HOS/Services/Bluetooth/IBluetoothDriver.cs b/Ryujinx.HLE/HOS/Services/Bluetooth/IBluetoothDriver.cs new file mode 100644 index 00000000..4cee67cd --- /dev/null +++ b/Ryujinx.HLE/HOS/Services/Bluetooth/IBluetoothDriver.cs @@ -0,0 +1,91 @@ +using Ryujinx.HLE.HOS.Kernel.Common; +using Ryujinx.HLE.HOS.Kernel.Threading; +using Ryujinx.HLE.HOS.Services.Set; +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; + } + } +}
\ No newline at end of file diff --git a/Ryujinx.HLE/HOS/Services/Bluetooth/IBluetoothUser.cs b/Ryujinx.HLE/HOS/Services/Bluetooth/IBluetoothUser.cs new file mode 100644 index 00000000..d070e18f --- /dev/null +++ b/Ryujinx.HLE/HOS/Services/Bluetooth/IBluetoothUser.cs @@ -0,0 +1,29 @@ +using Ryujinx.HLE.HOS.Ipc; +using Ryujinx.HLE.HOS.Services.Set; + +namespace Ryujinx.HLE.HOS.Services.Bluetooth +{ + [Service("bt")] + class IBluetoothUser : IpcService + { + public IBluetoothUser(ServiceCtx context) { } + + [Command(9)] + // RegisterBleEvent(pid) -> handle<copy> + public ResultCode RegisterBleEvent(ServiceCtx context) + { + NxSettings.Settings.TryGetValue("bluetooth_debug!skip_boot", out object debugMode); + + if ((bool)debugMode) + { + context.Response.HandleDesc = IpcHandleDesc.MakeCopy(BluetoothEventManager.RegisterBleDebugEventHandle); + } + else + { + context.Response.HandleDesc = IpcHandleDesc.MakeCopy(BluetoothEventManager.RegisterBleEventHandle); + } + + return ResultCode.Success; + } + } +}
\ No newline at end of file |
