Vixen
02b45cc4
csharp
public sealed class InputDeviceSet

Every device the process can see, and the frame's worth of change to them.

No guide page documents this yet — the page shows what the code says about itself.

Remarks

The bottom of this assembly, and it is fed rather than polling. Nothing here knows what a PlatformEvent is: Vixen.Input is a Core/ assembly and Vixen.Platform is above it, so the host owns the twenty-line translation and this owns the state machine. That is also what makes a headless test possible — a test submits a key press directly, with no platform, no window and no event loop.

The frame is the unit. BeginFrame clears the motion deltas and the change flags, then the host submits everything that happened, then the actions read. A value read twice in a frame gives the same answer twice, which is what a simulation wants and what an event stream on its own cannot promise.

Belongs to the thread that pumps it, which is the thread that owns the platform.

Fields and properties (7)

  • public KeyboardDevice Keyboard

    The keyboard.

  • public MouseDevice Mouse

    The pointer.

  • public TouchDevice Touch

    The touchscreen.

  • public IReadOnlyList<GamepadDevice> Gamepads

    Every connected gamepad, in the order they arrived.

  • public InputDeviceKind LastUsedDevice

    Which family of device was last used.

  • public int LastUsedGamepadSlot

    The slot of the gamepad last used, or -1.

  • public bool ChangedThisFrame

    Whether anything at all changed since the last BeginFrame.

Events (1)

  • public Action<GamepadDevice>? DeviceChanged

    Raised when a gamepad is connected or disconnected.

Methods (16)

  • public void BeginFrame()

    Starts a frame: clears the motion deltas and the change flags.

  • public void SubmitKey(InputKey key, bool pressed)

    Submits a key press or release.

  • public void SubmitMouseButton(MouseControl button, bool pressed)

    Submits a mouse button press or release.

  • public void SubmitMouseMove(Vector2 position, Vector2 delta)

    Submits pointer motion.

  • public void SubmitMouseScroll(Vector2 delta)

    Submits a wheel or trackpad scroll, in notches.

  • public void SubmitTouch(int finger, TouchPhase phase, Vector2 position, Vector2 delta = default(Vector2), float pressure = 1)

    Submits a touch.

  • public GamepadDevice ConnectGamepad(int deviceId, string name = "Gamepad")

    Adds a gamepad, or marks a previously seen one connected again.

  • public bool DisconnectGamepad(int deviceId)

    Marks a gamepad gone, keeping its slot.

  • public void RemoveDisconnected()

    Drops the gamepads that are gone, renumbering the slots of those that remain.

  • public void SubmitGamepadButton(int deviceId, GamepadControl button, bool pressed)

    Submits a gamepad button press or release.

  • public void SubmitGamepadAxis(int deviceId, GamepadControl axis, float value)

    Submits a gamepad axis position, raw.

  • public bool TryGetGamepad(int deviceId, out GamepadDevice? device)

    Finds a gamepad by the id its events carry.

  • public float ReadValue(InputControl control, int gamepadSlot = 0)

    Reads one control, for the gamepad slot the caller is paired to.

  • public void ResetHeldState()

    Releases everything held, without reporting a release for any of it.

  • public IReadOnlyList<InputControl> Actuated(float threshold = 0.5)

    Every control that is actuated right now.

  • public bool Has(InputDeviceKind kind)

    Whether a family of device is present.

Used by (14)

  • GeneratedAccessorTestsVixen.Input.Tests
  • InputActionVixen.Input
  • InputActionMapVixen.Input
  • InputActionTestsVixen.Input.Tests
  • InputActionsVixen.Input
  • InputBindingVixen.Input
  • InputBindingPartVixen.Input
  • InputControlSchemeVixen.Input
  • InputRebindingOperationVixen.Input
  • InputRebindingTestsVixen.Input.Tests
  • InputServiceVixen.Input
  • PlatformInputVixen.App.Hosting
  • PlayerInputTestsVixen.Engine.Tests
  • PlatformInputTestsVixen.App.Tests