Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Axis API #59

Closed
cart opened this issue Jul 18, 2020 · 2 comments
Closed

Axis API #59

cart opened this issue Jul 18, 2020 · 2 comments
Labels
A-Input Player input via keyboard, mouse, gamepad, and more C-Feature A new feature, making something new possible

Comments

@cart
Copy link
Member

cart commented Jul 18, 2020

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.

@karroffel karroffel added C-Feature A new feature, making something new possible A-Input Player input via keyboard, mouse, gamepad, and more labels Aug 12, 2020
@IceSentry
Copy link
Contributor

IceSentry commented Aug 18, 2020

Why would the cursor_position axis be named WindowId? I understand it comes from the window, but if the only axis is the cursor wouldn't it be better to call it CursorId or something like that?

Is it because it would also include the mouse wheel axis?

@cart
Copy link
Member Author

cart commented Oct 1, 2020

Resolved by #280

@cart cart closed this as completed Oct 1, 2020
tychedelia pushed a commit to tychedelia/bevy that referenced this issue Nov 23, 2024
This can be used to reduce the final binary size when a consumer only
needs WGSL support. I've enabled the feature by default for
backwards-compatibility

---------

Co-authored-by: robtfm <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Input Player input via keyboard, mouse, gamepad, and more C-Feature A new feature, making something new possible
Projects
None yet
Development

No branches or pull requests

3 participants