CSPspEmu.Hle.Modules.power.scePower.scePowerRegisterCallback C# (CSharp) Метод

scePowerRegisterCallback() приватный Метод

private scePowerRegisterCallback ( int SlotIndex, int CallbackId ) : int
SlotIndex int
CallbackId int
Результат int
        public int scePowerRegisterCallback(int SlotIndex, int CallbackId)
        {
            CheckSlotIndex(SlotIndex, AllowMinusOne: true);

            // TODO: If cbId is invalid return PSP_POWER_ERROR_INVALID_CB.
            if (CallbackId == 0)
            {
                throw (new SceKernelException(SceKernelErrors.PSP_POWER_ERROR_INVALID_CB));
            }

            if (SlotIndex == -1)
            {
                try
                {
                    SlotIndex = Callbacks.First(Slot => Slot.CallbackId == 0).Index;
                }
                catch (InvalidOperationException)
                {
                    throw (new SceKernelException(SceKernelErrors.PSP_POWER_ERROR_SLOTS_FULL));
                }
            }

            if (Callbacks[SlotIndex].CallbackId != 0)
            {
                throw (new SceKernelException(SceKernelErrors.PSP_POWER_ERROR_TAKEN_SLOT));
            }

            Callbacks[SlotIndex].CallbackId = CallbackId;

            var Callback = CallbackManager.Callbacks.Get(CallbackId);
            var RegisteredCallback = HleCallback.Create(
                "scePowerRegisterCallback", Callback.Function,
                SlotIndex + 1, (int)(GetPowerCallbackFlags()), Callback.Arguments[0]
            );

            CallbackManager.ScheduleCallback(RegisteredCallback);

            //throw (new NotImplementedException());
            return SlotIndex;
        }