コード例 #1
0
        // Initialize(u64, u64, pid, buffer<unknown, 5>)
        public ResultCode Initialize(ServiceCtx context)
        {
            _appletResourceUserId = context.RequestData.ReadUInt64();
            _mcuVersionData       = context.RequestData.ReadUInt64();

            ulong inputPosition = context.Request.SendBuff[0].Position;
            ulong inputSize     = context.Request.SendBuff[0].Size;

            _mcuData = new byte[inputSize];

            context.Memory.Read(inputPosition, _mcuData);

            // TODO: The mcuData buffer seems to contains entries with a size of 0x40 bytes each. Usage of the data needs to be determined.

            // TODO: Handle this in a controller class directly.
            //       Every functions which use the Handle call nn::hid::system::GetXcdHandleForNpadWithNfc().
            NfpDevice devicePlayer1 = new NfpDevice
            {
                NpadIdType = NpadIdType.Player1,
                Handle     = HidUtils.GetIndexFromNpadIdType(NpadIdType.Player1),
                State      = NfpDeviceState.Initialized
            };

            context.Device.System.NfpDevices.Add(devicePlayer1);

            // TODO: It mounts 0x8000000000000020 save data and stores a random generate value inside. Usage of the data needs to be determined.

            _state = State.Initialized;

            return(ResultCode.Success);
        }
コード例 #2
0
ファイル: IUser.cs プロジェクト: ski982/Ryujinx-1
        // Initialize(u64, u64, pid, buffer<unknown, 5>)
        public ResultCode Initialize(ServiceCtx context)
        {
            long appletResourceUserId = context.RequestData.ReadInt64();
            long mcuVersionData       = context.RequestData.ReadInt64();

            long inputPosition = context.Request.SendBuff[0].Position;
            long inputSize     = context.Request.SendBuff[0].Size;

            byte[] unknownBuffer = new byte[inputSize];

            context.Memory.Read((ulong)inputPosition, unknownBuffer);

            // NOTE: appletResourceUserId, mcuVersionData and the buffer are stored inside an internal struct.
            //       The buffer seems to contains entries with a size of 0x40 bytes each.
            //       Sadly, this internal struct doesn't seems to be used in retail.

            // TODO: Add an instance of nn::nfc::server::Manager when it will be implemented.
            //       Add an instance of nn::nfc::server::SaveData when it will be implemented.

            // TODO: When we will be able to add multiple controllers add one entry by controller here.
            Device device1 = new Device
            {
                NpadIdType = NpadIdType.Player1,
                Handle     = HidUtils.GetIndexFromNpadIdType(NpadIdType.Player1),
                State      = DeviceState.Initialized
            };

            _devices.Add(device1);

            _state = State.Initialized;

            return(ResultCode.Success);
        }
コード例 #3
0
        protected void AddHidDevices(List <IMappableDevice> deviceList)
        {
            List <Device> devices = HidUtils.GetHidDevices();

            foreach (Device device in devices)
            {
                if (device.IsGamePad)
                {
                    deviceList.Add(new HidGameControl(device.VendorId, device.ProductId, device.FriendlyName));
                }
            }
        }
コード例 #4
0
        // GetNpadId(bytes<8, 4>) -> u32
        public ResultCode GetNpadId(ServiceCtx context)
        {
            uint deviceHandle = context.RequestData.ReadUInt32();

            for (int i = 0; i < context.Device.System.NfpDevices.Count; i++)
            {
                if ((uint)context.Device.System.NfpDevices[i].Handle == deviceHandle)
                {
                    context.ResponseData.Write((uint)HidUtils.GetNpadIdTypeFromIndex(context.Device.System.NfpDevices[i].Handle));

                    return(ResultCode.Success);
                }
            }

            return(ResultCode.DeviceNotFound);
        }
コード例 #5
0
        // GetNpadId(bytes<8, 4>) -> u32
        public long GetNpadId(ServiceCtx context)
        {
            uint deviceHandle = context.RequestData.ReadUInt32();

            for (int i = 0; i < _devices.Count; i++)
            {
                if ((uint)_devices[i].Handle == deviceHandle)
                {
                    context.ResponseData.Write((uint)HidUtils.GetNpadIdTypeFromIndex(_devices[i].Handle));

                    return(0);
                }
            }

            return(ErrorCode.MakeError(ErrorModule.Nfp, NfpError.DeviceNotFound));
        }
コード例 #6
0
        // GetNpadIrCameraHandle(u32) -> nn::irsensor::IrCameraHandle
        public ResultCode GetNpadIrCameraHandle(ServiceCtx context)
        {
            NpadIdType npadIdType = (NpadIdType)context.RequestData.ReadUInt32();

            if (npadIdType > NpadIdType.Player8 &&
                npadIdType != NpadIdType.Unknown &&
                npadIdType != NpadIdType.Handheld)
            {
                return(ResultCode.NpadIdOutOfRange);
            }

            ControllerId irCameraHandle = HidUtils.GetIndexFromNpadIdType(npadIdType);

            context.ResponseData.Write((int)irCameraHandle);

            // NOTE: If the irCameraHandle pointer is null this error is returned, Doesn't occur in our case.
            //       return ResultCode.HandlePointerIsNull;

            return(ResultCode.Success);
        }
コード例 #7
0
        // GetNpadIrCameraHandle(u32) -> nn::irsensor::IrCameraHandle
        public long GetNpadIrCameraHandle(ServiceCtx context)
        {
            NpadIdType npadIdType = (NpadIdType)context.RequestData.ReadUInt32();

            if (npadIdType > NpadIdType.Player8 &&
                npadIdType != NpadIdType.Unknown &&
                npadIdType != NpadIdType.Handheld)
            {
                return(ErrorCode.MakeError(ErrorModule.Irsensor, IrsError.NpadIdOutOfRange));
            }

            HidControllerId irCameraHandle = HidUtils.GetIndexFromNpadIdType(npadIdType);

            context.ResponseData.Write((int)irCameraHandle);

            // NOTE: If the irCameraHandle pointer is null this error is returned, Doesn't occur in our case.
            //       return ErrorCode.MakeError(ErrorModule.Irsensor, IrsError.HandlePointerIsNull);

            return(0);
        }