@ -2,6 +2,11 @@
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
# include "common/swap.h"
# include "core/core.h"
# include "core/core_timing.h"
# include "core/hle/ipc_helpers.h"
# include "core/hle/kernel/shared_memory.h"
# include "core/hle/service/hid/irs.h"
namespace Service : : HID {
@ -9,28 +14,145 @@ namespace Service::HID {
IRS : : IRS ( ) : ServiceFramework { " irs " } {
// clang-format off
static const FunctionInfo functions [ ] = {
{ 302 , nullpt r, " ActivateIrsensor " } ,
{ 303 , nullpt r, " DeactivateIrsensor " } ,
{ 304 , nullptr , " GetIrsensorSharedMemoryHandle " } ,
{ 305 , nullpt r, " StopImageProcessor " } ,
{ 306 , nullpt r, " RunMomentProcessor " } ,
{ 307 , nullpt r, " RunClusteringProcessor " } ,
{ 308 , nullpt r, " RunImageTransferProcessor " } ,
{ 309 , nullptr , " GetImageTransferProcessorState " } ,
{ 310 , nullpt r, " RunTeraPluginProcessor " } ,
{ 311 , nullptr , " GetNpadIrCameraHandle " } ,
{ 312 , nullpt r, " RunPointingProcessor " } ,
{ 313 , nullpt r, " SuspendImageProcessor " } ,
{ 314 , nullptr , " CheckFirmwareVersion " } ,
{ 315 , nullptr , " SetFunctionLevel " } ,
{ 316 , nullpt r, " RunImageTransferExProcessor " } ,
{ 317 , nullpt r, " RunIrLedProcessor " } ,
{ 318 , nullptr , " StopImageProcessorAsync " } ,
{ 319 , nullptr , " ActivateIrsensorWithFunctionLevel " } ,
{ 302 , & IRS : : ActivateIrsenso r, " ActivateIrsensor " } ,
{ 303 , & IRS : : DeactivateIrsenso r, " DeactivateIrsensor " } ,
{ 304 , & IRS : : GetIrsensorSharedMemoryHandle , " GetIrsensorSharedMemoryHandle " } ,
{ 305 , & IRS : : StopImageProcesso r, " StopImageProcessor " } ,
{ 306 , & IRS : : RunMomentProcesso r, " RunMomentProcessor " } ,
{ 307 , & IRS : : RunClusteringProcesso r, " RunClusteringProcessor " } ,
{ 308 , & IRS : : RunImageTransferProcesso r, " RunImageTransferProcessor " } ,
{ 309 , & IRS : : GetImageTransferProcessorState , " GetImageTransferProcessorState " } ,
{ 310 , & IRS : : RunTeraPluginProcesso r, " RunTeraPluginProcessor " } ,
{ 311 , & IRS : : GetNpadIrCameraHandle , " GetNpadIrCameraHandle " } ,
{ 312 , & IRS : : RunPointingProcesso r, " RunPointingProcessor " } ,
{ 313 , & IRS : : SuspendImageProcesso r, " SuspendImageProcessor " } ,
{ 314 , & IRS : : CheckFirmwareVersion , " CheckFirmwareVersion " } ,
{ 315 , & IRS : : SetFunctionLevel , " SetFunctionLevel " } ,
{ 316 , & IRS : : RunImageTransferExProcesso r, " RunImageTransferExProcessor " } ,
{ 317 , & IRS : : RunIrLedProcesso r, " RunIrLedProcessor " } ,
{ 318 , & IRS : : StopImageProcessorAsync , " StopImageProcessorAsync " } ,
{ 319 , & IRS : : ActivateIrsensorWithFunctionLevel , " ActivateIrsensorWithFunctionLevel " } ,
} ;
// clang-format on
RegisterHandlers ( functions ) ;
auto & kernel = Core : : System : : GetInstance ( ) . Kernel ( ) ;
shared_mem = Kernel : : SharedMemory : : Create (
kernel , nullptr , 0x8000 , Kernel : : MemoryPermission : : ReadWrite ,
Kernel : : MemoryPermission : : Read , 0 , Kernel : : MemoryRegion : : BASE , " IRS:SharedMemory " ) ;
}
void IRS : : ActivateIrsensor ( Kernel : : HLERequestContext & ctx ) {
IPC : : ResponseBuilder rb { ctx , 2 } ;
rb . Push ( RESULT_SUCCESS ) ;
LOG_WARNING ( Service_IRS , " (STUBBED) called " ) ;
}
void IRS : : DeactivateIrsensor ( Kernel : : HLERequestContext & ctx ) {
IPC : : ResponseBuilder rb { ctx , 2 } ;
rb . Push ( RESULT_SUCCESS ) ;
LOG_WARNING ( Service_IRS , " (STUBBED) called " ) ;
}
void IRS : : GetIrsensorSharedMemoryHandle ( Kernel : : HLERequestContext & ctx ) {
IPC : : ResponseBuilder rb { ctx , 2 , 1 } ;
rb . Push ( RESULT_SUCCESS ) ;
rb . PushCopyObjects ( shared_mem ) ;
LOG_DEBUG ( Service_IRS , " called " ) ;
}
void IRS : : StopImageProcessor ( Kernel : : HLERequestContext & ctx ) {
IPC : : ResponseBuilder rb { ctx , 2 } ;
rb . Push ( RESULT_SUCCESS ) ;
LOG_WARNING ( Service_IRS , " (STUBBED) called " ) ;
}
void IRS : : RunMomentProcessor ( Kernel : : HLERequestContext & ctx ) {
IPC : : ResponseBuilder rb { ctx , 2 } ;
rb . Push ( RESULT_SUCCESS ) ;
LOG_WARNING ( Service_IRS , " (STUBBED) called " ) ;
}
void IRS : : RunClusteringProcessor ( Kernel : : HLERequestContext & ctx ) {
IPC : : ResponseBuilder rb { ctx , 2 } ;
rb . Push ( RESULT_SUCCESS ) ;
LOG_WARNING ( Service_IRS , " (STUBBED) called " ) ;
}
void IRS : : RunImageTransferProcessor ( Kernel : : HLERequestContext & ctx ) {
IPC : : ResponseBuilder rb { ctx , 2 } ;
rb . Push ( RESULT_SUCCESS ) ;
LOG_WARNING ( Service_IRS , " (STUBBED) called " ) ;
}
void IRS : : GetImageTransferProcessorState ( Kernel : : HLERequestContext & ctx ) {
IPC : : ResponseBuilder rb { ctx , 5 } ;
rb . Push ( RESULT_SUCCESS ) ;
rb . PushRaw < u64 > ( CoreTiming : : GetTicks ( ) ) ;
rb . PushRaw < u32 > ( 0 ) ;
LOG_WARNING ( Service_IRS , " (STUBBED) called " ) ;
}
void IRS : : RunTeraPluginProcessor ( Kernel : : HLERequestContext & ctx ) {
IPC : : ResponseBuilder rb { ctx , 2 } ;
rb . Push ( RESULT_SUCCESS ) ;
LOG_WARNING ( Service_IRS , " (STUBBED) called " ) ;
}
void IRS : : GetNpadIrCameraHandle ( Kernel : : HLERequestContext & ctx ) {
IPC : : ResponseBuilder rb { ctx , 3 } ;
rb . Push ( RESULT_SUCCESS ) ;
rb . PushRaw < u32 > ( device_handle ) ;
LOG_WARNING ( Service_IRS , " (STUBBED) called " ) ;
}
void IRS : : RunPointingProcessor ( Kernel : : HLERequestContext & ctx ) {
IPC : : ResponseBuilder rb { ctx , 2 } ;
rb . Push ( RESULT_SUCCESS ) ;
LOG_WARNING ( Service_IRS , " (STUBBED) called " ) ;
}
void IRS : : SuspendImageProcessor ( Kernel : : HLERequestContext & ctx ) {
IPC : : ResponseBuilder rb { ctx , 2 } ;
rb . Push ( RESULT_SUCCESS ) ;
LOG_WARNING ( Service_IRS , " (STUBBED) called " ) ;
}
void IRS : : CheckFirmwareVersion ( Kernel : : HLERequestContext & ctx ) {
IPC : : ResponseBuilder rb { ctx , 2 } ;
rb . Push ( RESULT_SUCCESS ) ;
LOG_WARNING ( Service_IRS , " (STUBBED) called " ) ;
}
void IRS : : SetFunctionLevel ( Kernel : : HLERequestContext & ctx ) {
IPC : : ResponseBuilder rb { ctx , 2 } ;
rb . Push ( RESULT_SUCCESS ) ;
LOG_WARNING ( Service_IRS , " (STUBBED) called " ) ;
}
void IRS : : RunImageTransferExProcessor ( Kernel : : HLERequestContext & ctx ) {
IPC : : ResponseBuilder rb { ctx , 2 } ;
rb . Push ( RESULT_SUCCESS ) ;
LOG_WARNING ( Service_IRS , " (STUBBED) called " ) ;
}
void IRS : : RunIrLedProcessor ( Kernel : : HLERequestContext & ctx ) {
IPC : : ResponseBuilder rb { ctx , 2 } ;
rb . Push ( RESULT_SUCCESS ) ;
LOG_WARNING ( Service_IRS , " (STUBBED) called " ) ;
}
void IRS : : StopImageProcessorAsync ( Kernel : : HLERequestContext & ctx ) {
IPC : : ResponseBuilder rb { ctx , 2 } ;
rb . Push ( RESULT_SUCCESS ) ;
LOG_WARNING ( Service_IRS , " (STUBBED) called " ) ;
}
void IRS : : ActivateIrsensorWithFunctionLevel ( Kernel : : HLERequestContext & ctx ) {
IPC : : ResponseBuilder rb { ctx , 2 } ;
rb . Push ( RESULT_SUCCESS ) ;
LOG_WARNING ( Service_IRS , " (STUBBED) called " ) ;
}
IRS : : ~ IRS ( ) = default ;