Skip to content

Axis API #59

Closed
Closed
@cart

Description

@cart

Axes (like mice and joysticks) should have a high level api that don't require managing events directly (much like keyboard / mouse input events have a higher level Input<MouseButton> api).

It could look something like this:

fn system(joystick_axis: Res<Axis<JoystickId>>, window_axis: Res<Axis<WindowId>>) {
  let x: Option<f32> = joystick_axis.x(joystick_id);
  let y: Option<f32> = joystick_axis.y(joystick_id);
  let xy: Option<Vec2> = joystick_axis.xy(joystick_id);
  // the legendary 3D joystick
  let xyz: Option<Vec3> = joystick_axis.xyz(joystick_id);

  let cursor_position: Option<Vec2> = window_axis.xy(window_id);
}

In this case, Some(result) is returned when that axis is available (device exists and value is a real number). Ex: if a cursor is not currently on a window, a joystick with the given id does not exist, or an xy joystick does not have a requested z-axis, none would be returned because there is no defined value.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-InputPlayer input via keyboard, mouse, gamepad, and moreC-FeatureA new feature, making something new possible

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions