예제 #1
0
        internal static void DispatchEvent(Native.SDL_Event e)
        {
            switch (e.Type)
            {
            case Native.SDL_EventType.MultiGesture:
            {
                MultiGesture?.Invoke(null, new MultiGestureEventArgs(e.Mgesture));
                break;
            }

            case Native.SDL_EventType.DollarGesture:
            {
                DollarGesture?.Invoke(null, new DollarGestureEventArgs(e.Dgesture));
                break;
            }

            case Native.SDL_EventType.DollarRecord:
            {
                DollarRecord?.Invoke(null, new DollarGestureEventArgs(e.Dgesture));
                break;
            }

            default:
                throw new InvalidOperationException();
            }
        }
예제 #2
0
        internal static void DispatchEvent(Native.SDL_Event e)
        {
            switch (e.Type)
            {
            case Native.SDL_EventType.JoystickAxisMotion:
            {
                var joystick = Get(e.Jaxis.Which);
                joystick?.AxisMotion?.Invoke(joystick, new JoystickAxisMotionEventArgs(e.Jaxis));
                break;
            }

            case Native.SDL_EventType.JoystickBallMotion:
            {
                var joystick = Get(e.Jball.Which);
                joystick?.BallMotion?.Invoke(joystick, new JoystickBallMotionEventArgs(e.Jball));
                break;
            }

            case Native.SDL_EventType.JoystickButtonDown:
            {
                var joystick = Get(e.Jbutton.Which);
                joystick?.ButtonDown?.Invoke(joystick, new JoystickButtonEventArgs(e.Jbutton));
                break;
            }

            case Native.SDL_EventType.JoystickButtonUp:
            {
                var joystick = Get(e.Jbutton.Which);
                joystick?.ButtonUp?.Invoke(joystick, new JoystickButtonEventArgs(e.Jbutton));
                break;
            }

            case Native.SDL_EventType.JoystickDeviceAdded:
            {
                Added?.Invoke(null, new JoystickAddedEventArgs(e.Jdevice));
                break;
            }

            case Native.SDL_EventType.JoystickDeviceRemoved:
            {
                var joystick = Get(new Native.SDL_JoystickID(e.Jdevice.Which));
                joystick.Removed?.Invoke(joystick, new SdlEventArgs(e.Common));
                break;
            }

            case Native.SDL_EventType.JoystickHatMotion:
            {
                var joystick = Get(e.Jhat.Which);
                joystick?.HatMotion?.Invoke(joystick, new JoystickHatMotionEventArgs(e.Jhat));
                break;
            }

            default:
                throw new InvalidOperationException();
            }
        }
예제 #3
0
        internal static void DispatchEvent(Native.SDL_Event e)
        {
            var sensor = Get(e.Sensor.Which);

            switch (e.Type)
            {
            case SdlSharp.Native.SDL_EventType.SensorUpdate:
                sensor.Updated?.Invoke(sensor, new SensorUpdatedEventArgs(e.Sensor));
                break;

            default:
                throw new InvalidOperationException();
            }
        }
예제 #4
0
        internal static void DispatchEvent(Native.SDL_Event e)
        {
            switch (e.Type)
            {
            case Native.SDL_EventType.ControllerAxisMotion:
            {
                var controller = Get(e.Caxis.Which);
                controller?.AxisMotion?.Invoke(controller, new GameControllerAxisMotionEventArgs(e.Caxis));
                break;
            }

            case Native.SDL_EventType.ControllerButtonDown:
            {
                var controller = Get(e.Cbutton.Which);
                controller?.ButtonDown?.Invoke(controller, new GameControllerButtonEventArgs(e.Cbutton));
                break;
            }

            case Native.SDL_EventType.ControllerButtonUp:
            {
                var controller = Get(e.Cbutton.Which);
                controller?.ButtonUp?.Invoke(controller, new GameControllerButtonEventArgs(e.Cbutton));
                break;
            }

            case Native.SDL_EventType.ControllerDeviceAdded:
            {
                Added?.Invoke(null, new GameControllerAddedEventArgs(e.Cdevice));
                break;
            }

            case Native.SDL_EventType.ControllerDeviceRemoved:
            {
                var controller = Get(new Native.SDL_JoystickID(e.Cdevice.Which));
                controller?.Removed?.Invoke(controller, new SdlEventArgs(e.Common));
                break;
            }

            case Native.SDL_EventType.ControllerDeviceRemapped:
            {
                var controller = Get(new Native.SDL_JoystickID(e.Cdevice.Which));
                controller?.Remapped?.Invoke(controller, new SdlEventArgs(e.Common));
                break;
            }

            default:
                throw new InvalidOperationException();
            }
        }
예제 #5
0
        internal static void DispatchEvent(Native.SDL_Event e)
        {
            switch (e.Type)
            {
            case Native.SDL_EventType.FingerDown:
            case Native.SDL_EventType.FingerUp:
            case Native.SDL_EventType.FingerMotion:
            {
                var    touch  = IndexToInstance(e.Tfinger.TouchId);
                Finger?finger = null;
                foreach (var indexedFinger in touch.Fingers)
                {
                    if (indexedFinger.Id.Id == e.Tfinger.FingerId.Id)
                    {
                        finger = indexedFinger;
                        break;
                    }
                }

                if (finger == null)
                {
                    throw new InvalidOperationException();
                }

                switch (e.Type)
                {
                case Native.SDL_EventType.FingerDown:
                    touch.FingerDown?.Invoke(touch, new TouchFingerEventArgs(e.Tfinger, finger));
                    break;

                case Native.SDL_EventType.FingerUp:
                    touch.FingerUp?.Invoke(touch, new TouchFingerEventArgs(e.Tfinger, finger));
                    break;

                case Native.SDL_EventType.FingerMotion:
                    touch.FingerMotion?.Invoke(touch, new TouchFingerEventArgs(e.Tfinger, finger));
                    break;
                }
                break;
            }

            default:
                throw new InvalidOperationException();
            }
        }
예제 #6
0
        internal static void DispatchEvent(Native.SDL_Event e)
        {
            switch (e.Type)
            {
            case Native.SDL_EventType.AudioDeviceAdded:
            {
                Added?.Invoke(null, new AudioDeviceAddedEventArgs(e.Adevice));
                break;
            }

            case Native.SDL_EventType.JoystickDeviceRemoved:
            {
                var device = IndexToInstance(new Native.SDL_AudioDeviceID(e.Adevice.Which));
                device.Removed?.Invoke(device, new SdlEventArgs(e.Common));
                break;
            }

            default:
                throw new InvalidOperationException();
            }
        }