aboutsummaryrefslogtreecommitdiff
path: root/src/Ryujinx.HLE/HOS/Services/BluetoothManager
diff options
context:
space:
mode:
authorTSR Berry <20988865+TSRBerry@users.noreply.github.com>2023-04-08 01:22:00 +0200
committerMary <thog@protonmail.com>2023-04-27 23:51:14 +0200
commitcee712105850ac3385cd0091a923438167433f9f (patch)
tree4a5274b21d8b7f938c0d0ce18736d3f2993b11b1 /src/Ryujinx.HLE/HOS/Services/BluetoothManager
parentcd124bda587ef09668a971fa1cac1c3f0cfc9f21 (diff)
Move solution and projects to src
Diffstat (limited to 'src/Ryujinx.HLE/HOS/Services/BluetoothManager')
-rw-r--r--src/Ryujinx.HLE/HOS/Services/BluetoothManager/BtmUser/IBtmUserCore.cs128
-rw-r--r--src/Ryujinx.HLE/HOS/Services/BluetoothManager/IBtm.cs8
-rw-r--r--src/Ryujinx.HLE/HOS/Services/BluetoothManager/IBtmDebug.cs8
-rw-r--r--src/Ryujinx.HLE/HOS/Services/BluetoothManager/IBtmSystem.cs8
-rw-r--r--src/Ryujinx.HLE/HOS/Services/BluetoothManager/IBtmUser.cs19
-rw-r--r--src/Ryujinx.HLE/HOS/Services/BluetoothManager/ResultCode.cs10
6 files changed, 181 insertions, 0 deletions
diff --git a/src/Ryujinx.HLE/HOS/Services/BluetoothManager/BtmUser/IBtmUserCore.cs b/src/Ryujinx.HLE/HOS/Services/BluetoothManager/BtmUser/IBtmUserCore.cs
new file mode 100644
index 00000000..3c9938ad
--- /dev/null
+++ b/src/Ryujinx.HLE/HOS/Services/BluetoothManager/BtmUser/IBtmUserCore.cs
@@ -0,0 +1,128 @@
+using Ryujinx.Common.Logging;
+using Ryujinx.HLE.HOS.Ipc;
+using Ryujinx.HLE.HOS.Kernel.Threading;
+using Ryujinx.Horizon.Common;
+
+namespace Ryujinx.HLE.HOS.Services.BluetoothManager.BtmUser
+{
+ class IBtmUserCore : IpcService
+ {
+ public KEvent _bleScanEvent;
+ public int _bleScanEventHandle;
+
+ public KEvent _bleConnectionEvent;
+ public int _bleConnectionEventHandle;
+
+ public KEvent _bleServiceDiscoveryEvent;
+ public int _bleServiceDiscoveryEventHandle;
+
+ public KEvent _bleMtuConfigEvent;
+ public int _bleMtuConfigEventHandle;
+
+ public IBtmUserCore() { }
+
+ [CommandCmif(0)] // 5.0.0+
+ // AcquireBleScanEvent() -> (byte<1>, handle<copy>)
+ public ResultCode AcquireBleScanEvent(ServiceCtx context)
+ {
+ Result result = Result.Success;
+
+ if (_bleScanEventHandle == 0)
+ {
+ _bleScanEvent = new KEvent(context.Device.System.KernelContext);
+
+ result = context.Process.HandleTable.GenerateHandle(_bleScanEvent.ReadableEvent, out _bleScanEventHandle);
+
+ if (result != Result.Success)
+ {
+ // NOTE: We use a Logging instead of an exception because the call return a boolean if succeed or not.
+ Logger.Error?.Print(LogClass.ServiceBsd, "Out of handles!");
+ }
+ }
+
+ context.Response.HandleDesc = IpcHandleDesc.MakeCopy(_bleScanEventHandle);
+
+ context.ResponseData.Write(result == Result.Success ? 1 : 0);
+
+ return ResultCode.Success;
+ }
+
+ [CommandCmif(17)] // 5.0.0+
+ // AcquireBleConnectionEvent() -> (byte<1>, handle<copy>)
+ public ResultCode AcquireBleConnectionEvent(ServiceCtx context)
+ {
+ Result result = Result.Success;
+
+ if (_bleConnectionEventHandle == 0)
+ {
+ _bleConnectionEvent = new KEvent(context.Device.System.KernelContext);
+
+ result = context.Process.HandleTable.GenerateHandle(_bleConnectionEvent.ReadableEvent, out _bleConnectionEventHandle);
+
+ if (result != Result.Success)
+ {
+ // NOTE: We use a Logging instead of an exception because the call return a boolean if succeed or not.
+ Logger.Error?.Print(LogClass.ServiceBsd, "Out of handles!");
+ }
+ }
+
+ context.Response.HandleDesc = IpcHandleDesc.MakeCopy(_bleConnectionEventHandle);
+
+ context.ResponseData.Write(result == Result.Success ? 1 : 0);
+
+ return ResultCode.Success;
+ }
+
+ [CommandCmif(26)] // 5.0.0+
+ // AcquireBleServiceDiscoveryEvent() -> (byte<1>, handle<copy>)
+ public ResultCode AcquireBleServiceDiscoveryEvent(ServiceCtx context)
+ {
+ Result result = Result.Success;
+
+ if (_bleServiceDiscoveryEventHandle == 0)
+ {
+ _bleServiceDiscoveryEvent = new KEvent(context.Device.System.KernelContext);
+
+ result = context.Process.HandleTable.GenerateHandle(_bleServiceDiscoveryEvent.ReadableEvent, out _bleServiceDiscoveryEventHandle);
+
+ if (result != Result.Success)
+ {
+ // NOTE: We use a Logging instead of an exception because the call return a boolean if succeed or not.
+ Logger.Error?.Print(LogClass.ServiceBsd, "Out of handles!");
+ }
+ }
+
+ context.Response.HandleDesc = IpcHandleDesc.MakeCopy(_bleServiceDiscoveryEventHandle);
+
+ context.ResponseData.Write(result == Result.Success ? 1 : 0);
+
+ return ResultCode.Success;
+ }
+
+ [CommandCmif(33)] // 5.0.0+
+ // AcquireBleMtuConfigEvent() -> (byte<1>, handle<copy>)
+ public ResultCode AcquireBleMtuConfigEvent(ServiceCtx context)
+ {
+ Result result = Result.Success;
+
+ if (_bleMtuConfigEventHandle == 0)
+ {
+ _bleMtuConfigEvent = new KEvent(context.Device.System.KernelContext);
+
+ result = context.Process.HandleTable.GenerateHandle(_bleMtuConfigEvent.ReadableEvent, out _bleMtuConfigEventHandle);
+
+ if (result != Result.Success)
+ {
+ // NOTE: We use a Logging instead of an exception because the call return a boolean if succeed or not.
+ Logger.Error?.Print(LogClass.ServiceBsd, "Out of handles!");
+ }
+ }
+
+ context.Response.HandleDesc = IpcHandleDesc.MakeCopy(_bleMtuConfigEventHandle);
+
+ context.ResponseData.Write(result == Result.Success ? 1 : 0);
+
+ return ResultCode.Success;
+ }
+ }
+} \ No newline at end of file
diff --git a/src/Ryujinx.HLE/HOS/Services/BluetoothManager/IBtm.cs b/src/Ryujinx.HLE/HOS/Services/BluetoothManager/IBtm.cs
new file mode 100644
index 00000000..48a273a0
--- /dev/null
+++ b/src/Ryujinx.HLE/HOS/Services/BluetoothManager/IBtm.cs
@@ -0,0 +1,8 @@
+namespace Ryujinx.HLE.HOS.Services.BluetoothManager
+{
+ [Service("btm")]
+ class IBtm : IpcService
+ {
+ public IBtm(ServiceCtx context) { }
+ }
+} \ No newline at end of file
diff --git a/src/Ryujinx.HLE/HOS/Services/BluetoothManager/IBtmDebug.cs b/src/Ryujinx.HLE/HOS/Services/BluetoothManager/IBtmDebug.cs
new file mode 100644
index 00000000..259698af
--- /dev/null
+++ b/src/Ryujinx.HLE/HOS/Services/BluetoothManager/IBtmDebug.cs
@@ -0,0 +1,8 @@
+namespace Ryujinx.HLE.HOS.Services.BluetoothManager
+{
+ [Service("btm:dbg")]
+ class IBtmDebug : IpcService
+ {
+ public IBtmDebug(ServiceCtx context) { }
+ }
+} \ No newline at end of file
diff --git a/src/Ryujinx.HLE/HOS/Services/BluetoothManager/IBtmSystem.cs b/src/Ryujinx.HLE/HOS/Services/BluetoothManager/IBtmSystem.cs
new file mode 100644
index 00000000..c4210b78
--- /dev/null
+++ b/src/Ryujinx.HLE/HOS/Services/BluetoothManager/IBtmSystem.cs
@@ -0,0 +1,8 @@
+namespace Ryujinx.HLE.HOS.Services.BluetoothManager
+{
+ [Service("btm:sys")]
+ class IBtmSystem : IpcService
+ {
+ public IBtmSystem(ServiceCtx context) { }
+ }
+} \ No newline at end of file
diff --git a/src/Ryujinx.HLE/HOS/Services/BluetoothManager/IBtmUser.cs b/src/Ryujinx.HLE/HOS/Services/BluetoothManager/IBtmUser.cs
new file mode 100644
index 00000000..b00f0a2f
--- /dev/null
+++ b/src/Ryujinx.HLE/HOS/Services/BluetoothManager/IBtmUser.cs
@@ -0,0 +1,19 @@
+using Ryujinx.HLE.HOS.Services.BluetoothManager.BtmUser;
+
+namespace Ryujinx.HLE.HOS.Services.BluetoothManager
+{
+ [Service("btm:u")] // 5.0.0+
+ class IBtmUser : IpcService
+ {
+ public IBtmUser(ServiceCtx context) { }
+
+ [CommandCmif(0)] // 5.0.0+
+ // GetCore() -> object<nn::btm::IBtmUserCore>
+ public ResultCode GetCore(ServiceCtx context)
+ {
+ MakeObject(context, new IBtmUserCore());
+
+ return ResultCode.Success;
+ }
+ }
+} \ No newline at end of file
diff --git a/src/Ryujinx.HLE/HOS/Services/BluetoothManager/ResultCode.cs b/src/Ryujinx.HLE/HOS/Services/BluetoothManager/ResultCode.cs
new file mode 100644
index 00000000..0ad2c485
--- /dev/null
+++ b/src/Ryujinx.HLE/HOS/Services/BluetoothManager/ResultCode.cs
@@ -0,0 +1,10 @@
+namespace Ryujinx.HLE.HOS.Services.BluetoothManager
+{
+ enum ResultCode
+ {
+ ModuleId = 143,
+ ErrorCodeShift = 9,
+
+ Success = 0
+ }
+} \ No newline at end of file