예제 #1
0
        public override void Connect()
        {
            base.Connect();

            //
            // Callback to event
            //
            _notificationCallback = (client, target, largeMotor, smallMotor, number) => FeedbackReceived?.Invoke(this,
                                                                                                                 new Xbox360FeedbackReceivedEventArgs(largeMotor, smallMotor, number));

            var error = ViGEmClient.vigem_target_x360_register_notification(Client.NativeHandle, NativeHandle,
                                                                            _notificationCallback);

            switch (error)
            {
            case ViGEmClient.VIGEM_ERROR.VIGEM_ERROR_BUS_NOT_FOUND:
                throw new VigemBusNotFoundException();

            case ViGEmClient.VIGEM_ERROR.VIGEM_ERROR_INVALID_TARGET:
                throw new VigemInvalidTargetException();

            case ViGEmClient.VIGEM_ERROR.VIGEM_ERROR_CALLBACK_ALREADY_REGISTERED:
                throw new VigemCallbackAlreadyRegisteredException();
            }
        }