bevy icon indicating copy to clipboard operation
bevy copied to clipboard

Added keyboard scan input event

Open Bleb1k opened this issue 1 year ago • 5 comments

Objective

  • I wanted to have controls independent from keyboard layout and found that bevy doesn't have a proper implementation for that

Solution

  • I created a ScanCode enum with two hundreds scan codes and updated keyboard_input_system to include and update ResMut<Input<ScanCode>>
  • closes both https://github.com/bevyengine/bevy/issues/2052 and https://github.com/bevyengine/bevy/issues/862

Bleb1k avatar Jul 30 '22 15:07 Bleb1k

also i added num_enum dependency for this to work

Bleb1k avatar Jul 30 '22 15:07 Bleb1k

Is there a need for the enum? Couldn't we just pass around the raw u32 wrapped in a newtype?

MrGVSV avatar Jul 30 '22 15:07 MrGVSV

Is there a need for the enum?

I don't know, this is the most obvious approach for me

Couldn't we just pass around the raw u32 wrapped in a newtype?

Maybe, but i'm very new to rust, like, i'm two weeks into it for now

Bleb1k avatar Jul 30 '22 15:07 Bleb1k

Maybe, but i'm very new to rust, like, i'm two weeks into it for now

No worries, glad you're contributing already. It's a great way to learn! 😄

I’d say we could replace the enum with struct ScanCode(u32) or something like that. It's easier for others to use and reason with imo

MrGVSV avatar Jul 30 '22 16:07 MrGVSV

Ok, thanks! This way there's no need in adding new dependencies, and code looks so much cleaner!

Bleb1k avatar Jul 30 '22 17:07 Bleb1k

bors r+

cart avatar Aug 05 '22 04:08 cart