mirror of
https://github.com/Ryujinx/Ryujinx.git
synced 2024-11-10 22:46:39 +00:00
Implement IIrSensorServer GetNpadIrCameraHandle (#663)
* Implement IIrSensorServer GetNpadIrCameraHandle Resolves #618 * Throw ArgumentOutOfRange instead of IOE * Revise for changes in later firmware Based on RE work from 6.1.0 * Nits
This commit is contained in:
parent
6b23a2c125
commit
bea73895f5
1 changed files with 45 additions and 4 deletions
|
@ -1,5 +1,7 @@
|
||||||
using Ryujinx.Common.Logging;
|
using Ryujinx.Common.Logging;
|
||||||
|
using Ryujinx.HLE.Exceptions;
|
||||||
using Ryujinx.HLE.HOS.Ipc;
|
using Ryujinx.HLE.HOS.Ipc;
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace Ryujinx.HLE.HOS.Services.Irs
|
namespace Ryujinx.HLE.HOS.Services.Irs
|
||||||
|
@ -10,14 +12,13 @@ namespace Ryujinx.HLE.HOS.Services.Irs
|
||||||
|
|
||||||
public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands;
|
public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands;
|
||||||
|
|
||||||
private bool _activated;
|
|
||||||
|
|
||||||
public IIrSensorServer()
|
public IIrSensorServer()
|
||||||
{
|
{
|
||||||
_commands = new Dictionary<int, ServiceProcessRequest>
|
_commands = new Dictionary<int, ServiceProcessRequest>
|
||||||
{
|
{
|
||||||
{ 302, ActivateIrsensor },
|
{ 302, ActivateIrsensor },
|
||||||
{ 303, DeactivateIrsensor }
|
{ 303, DeactivateIrsensor },
|
||||||
|
{ 311, GetNpadIrCameraHandle }
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,5 +41,45 @@ namespace Ryujinx.HLE.HOS.Services.Irs
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetNpadIrCameraHandle(u32) -> nn::irsensor::IrCameraHandle
|
||||||
|
public long GetNpadIrCameraHandle(ServiceCtx context)
|
||||||
|
{
|
||||||
|
uint npadId = context.RequestData.ReadUInt32();
|
||||||
|
|
||||||
|
if (npadId >= 8 && npadId != 16 && npadId != 32)
|
||||||
|
{
|
||||||
|
return ErrorCode.MakeError(ErrorModule.Hid, 0x2c5);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (((1 << (int)npadId) & 0x1000100FF) == 0)
|
||||||
|
{
|
||||||
|
return ErrorCode.MakeError(ErrorModule.Hid, 0x2c5);
|
||||||
|
}
|
||||||
|
|
||||||
|
int npadTypeId = GetNpadTypeId(npadId);
|
||||||
|
|
||||||
|
context.ResponseData.Write(npadTypeId);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
private int GetNpadTypeId(uint npadId)
|
||||||
|
{
|
||||||
|
switch(npadId)
|
||||||
|
{
|
||||||
|
case 0: return 0;
|
||||||
|
case 1: return 1;
|
||||||
|
case 2: return 2;
|
||||||
|
case 3: return 3;
|
||||||
|
case 4: return 4;
|
||||||
|
case 5: return 5;
|
||||||
|
case 6: return 6;
|
||||||
|
case 7: return 7;
|
||||||
|
case 32: return 8;
|
||||||
|
case 16: return 9;
|
||||||
|
default: throw new ArgumentOutOfRangeException(nameof(npadId));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue