fromPointer static method

SdlxEvent fromPointer(
  1. Pointer<SdlEvent> pointer
)

Implementation

static SdlxEvent fromPointer(Pointer<SdlEvent> pointer) {
  if (pointer.type >= SDL_EVENT_DISPLAY_FIRST &&
      pointer.type <= SDL_EVENT_DISPLAY_LAST) {
    return SdlxDisplayEvent.fromPointer(pointer);
  } else if (pointer.type >= SDL_EVENT_WINDOW_FIRST &&
      pointer.type <= SDL_EVENT_WINDOW_LAST) {
    return SdlxWindowEvent.fromPointer(pointer);
  } else if (pointer.type >= SDL_EVENT_USER &&
      pointer.type <= SDL_EVENT_LAST) {
    return SdlxUserEvent.fromPointer(pointer);
  } else {
    switch (pointer.type) {
      case SDL_EVENT_KEYBOARD_ADDED:
      case SDL_EVENT_KEYBOARD_REMOVED:
        return SdlxKeyboardDeviceEvent.fromPointer(pointer);
      case SDL_EVENT_KEY_DOWN:
      case SDL_EVENT_KEY_UP:
        return SdlxKeyboardEvent.fromPointer(pointer);
      case SDL_EVENT_TEXT_EDITING:
        return SdlxTextEditingEvent.fromPointer(pointer);
      case SDL_EVENT_TEXT_EDITING_CANDIDATES:
        return SdlxTextEditingCandidatesEvent.fromPointer(pointer);
      case SDL_EVENT_TEXT_INPUT:
        return SdlxTextInputEvent.fromPointer(pointer);
      case SDL_EVENT_MOUSE_ADDED:
      case SDL_EVENT_MOUSE_REMOVED:
        return SdlxMouseDeviceEvent.fromPointer(pointer);
      case SDL_EVENT_MOUSE_MOTION:
        return SdlxMouseMotionEvent.fromPointer(pointer);
      case SDL_EVENT_MOUSE_BUTTON_DOWN:
      case SDL_EVENT_MOUSE_BUTTON_UP:
        return SdlxMouseButtonEvent.fromPointer(pointer);
      case SDL_EVENT_MOUSE_WHEEL:
        return SdlxMouseWheelEvent.fromPointer(pointer);
      case SDL_EVENT_JOYSTICK_AXIS_MOTION:
        return SdlxJoyAxisEvent.fromPointer(pointer);
      case SDL_EVENT_JOYSTICK_BALL_MOTION:
        return SdlxJoyBallEvent.fromPointer(pointer);
      case SDL_EVENT_JOYSTICK_HAT_MOTION:
        return SdlxJoyHatEvent.fromPointer(pointer);
      case SDL_EVENT_JOYSTICK_BUTTON_DOWN:
      case SDL_EVENT_JOYSTICK_BUTTON_UP:
        return SdlxJoyButtonEvent.fromPointer(pointer);
      case SDL_EVENT_JOYSTICK_ADDED:
      case SDL_EVENT_JOYSTICK_REMOVED:
      case SDL_EVENT_JOYSTICK_UPDATE_COMPLETE:
        return SdlxJoyDeviceEvent.fromPointer(pointer);
      case SDL_EVENT_JOYSTICK_BATTERY_UPDATED:
        return SdlxJoyBatteryEvent.fromPointer(pointer);
      case SDL_EVENT_GAMEPAD_AXIS_MOTION:
        return SdlxGamepadAxisEvent.fromPointer(pointer);
      case SDL_EVENT_GAMEPAD_BUTTON_DOWN:
      case SDL_EVENT_GAMEPAD_BUTTON_UP:
        return SdlxGamepadButtonEvent.fromPointer(pointer);
      case SDL_EVENT_GAMEPAD_ADDED:
      case SDL_EVENT_GAMEPAD_REMOVED:
      case SDL_EVENT_GAMEPAD_REMAPPED:
      case SDL_EVENT_GAMEPAD_UPDATE_COMPLETE:
      case SDL_EVENT_GAMEPAD_STEAM_HANDLE_UPDATED:
        return SdlxGamepadDeviceEvent.fromPointer(pointer);
      case SDL_EVENT_GAMEPAD_TOUCHPAD_DOWN:
      case SDL_EVENT_GAMEPAD_TOUCHPAD_MOTION:
      case SDL_EVENT_GAMEPAD_TOUCHPAD_UP:
        return SdlxGamepadTouchpadEvent.fromPointer(pointer);
      case SDL_EVENT_GAMEPAD_SENSOR_UPDATE:
        return SdlxGamepadSensorEvent.fromPointer(pointer);
      case SDL_EVENT_GAMEPAD_CAPSENSE_TOUCH:
      case SDL_EVENT_GAMEPAD_CAPSENSE_RELEASE:
        return SdlxGamepadCapSenseEvent.fromPointer(pointer);
      case SDL_EVENT_AUDIO_DEVICE_ADDED:
      case SDL_EVENT_AUDIO_DEVICE_REMOVED:
      case SDL_EVENT_AUDIO_DEVICE_FORMAT_CHANGED:
        return SdlxAudioDeviceEvent.fromPointer(pointer);
      case SDL_EVENT_CAMERA_DEVICE_ADDED:
      case SDL_EVENT_CAMERA_DEVICE_REMOVED:
      case SDL_EVENT_CAMERA_DEVICE_APPROVED:
      case SDL_EVENT_CAMERA_DEVICE_DENIED:
        return SdlxCameraDeviceEvent.fromPointer(pointer);
      case SDL_EVENT_RENDER_TARGETS_RESET:
      case SDL_EVENT_RENDER_DEVICE_RESET:
      case SDL_EVENT_RENDER_DEVICE_LOST:
        return SdlxRenderEvent.fromPointer(pointer);
      case SDL_EVENT_FINGER_DOWN:
      case SDL_EVENT_FINGER_UP:
      case SDL_EVENT_FINGER_MOTION:
      case SDL_EVENT_FINGER_CANCELED:
        return SdlxTouchFingerEvent.fromPointer(pointer);
      case SDL_EVENT_PINCH_BEGIN:
      case SDL_EVENT_PINCH_UPDATE:
      case SDL_EVENT_PINCH_END:
        return SdlxPinchFingerEvent.fromPointer(pointer);
      case SDL_EVENT_PEN_PROXIMITY_IN:
      case SDL_EVENT_PEN_PROXIMITY_OUT:
        return SdlxPenProximityEvent.fromPointer(pointer);
      case SDL_EVENT_PEN_MOTION:
        return SdlxPenMotionEvent.fromPointer(pointer);
      case SDL_EVENT_PEN_DOWN:
      case SDL_EVENT_PEN_UP:
        return SdlxPenButtonEvent.fromPointer(pointer);
      case SDL_EVENT_PEN_BUTTON_DOWN:
      case SDL_EVENT_PEN_BUTTON_UP:
        return SdlxPenButtonEvent.fromPointer(pointer);
      case SDL_EVENT_PEN_AXIS:
        return SdlxPenAxisEvent.fromPointer(pointer);
      case SDL_EVENT_DROP_BEGIN:
      case SDL_EVENT_DROP_FILE:
      case SDL_EVENT_DROP_TEXT:
      case SDL_EVENT_DROP_COMPLETE:
      case SDL_EVENT_DROP_POSITION:
        return SdlxDropEvent.fromPointer(pointer);
      case SDL_EVENT_CLIPBOARD_UPDATE:
        return SdlxClipboardEvent.fromPointer(pointer);
      case SDL_EVENT_SENSOR_UPDATE:
        return SdlxSensorEvent.fromPointer(pointer);
      case SDL_EVENT_QUIT:
        return SdlxQuitEvent.fromPointer(pointer);
      default:
        return SdlxCommonEvent.fromPointer(pointer);
    }
  }
}