Make bevy_winit::converters module public #22336
Merged
+16
−2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Objective
bevy_winit::convertersmodule public #5980Some of these converters are useful to users. I found myself needing to convert to a bevy KeyCode so i looked at all places its mentioned and found
convert_physical_key_code. Then i looked up why its not in a pub module and found #5980 and #5986In #5986 @mockersf expressed wanting these to be turned into From implementations, which Cart later argued against and instead wanted as Into implementations in bevy_winit. But the orphan rule disallows this, as the releavant types are implemented in bevy_input, bevy_window, bevy_math, etc.
Because of this, and the fact its been 3 years, i'm proposing just leaving them as converter functions. The usecases are rare enough that users can deal with some non-idiomatic code and unintuitive function names.
Solution
use converters;->pub use converters;I've also written basic docstrings.
Testing
Showcase
bevy_winit::convertersis now public, allowing access to the following functions:Newly exposed functions
convert_element_stateConverts a
winit::event::ElementStateto a BevyButtonStateconvert_enabled_buttonsConverts a Bevy
EnabledButtonsto awinit::window::WindowButtonsconvert_keyboard_inputConverts a
winit::event::KeyEventand a window Entity to a BevyKeyboardInputconvert_logical_keyConverts a
winit::keyboard::Keyto a Bevybevy_input::keyboard::Keyconvert_mouse_buttonConverts a
winit::event::MouseButtonto a BevyMouseButtonconvert_native_keyConverts a
winit::keyboard::NativeKeyto a BevyNativeKeyconvert_physical_key_codeConverts a
winit::keyboard::PhysicalKeyto a BevyKeyCodeconvert_physical_native_key_codeConverts a
winit::keyboard::NativeKeyCodeto a BevyNativeKeyCodeconvert_resize_directionConverts a Bevy
CompassOctantto awinit::window::ResizeDirectionconvert_system_cursor_iconConverts a Bevy
SystemCursorIconto awinit::window::CursorIcon.convert_touch_inputConverts a
winit::event::Touch,winit::dpi::LogicalPosition<f64>and windowEntityto a BevyTouchInputconvert_window_levelConverts a Bevy
WindowLevelto awinit::window::WindowLevelconvert_window_themeConverts a Bevy
WindowThemeto awinit::window::Themeconvert_winit_themeConverts a
winit::window::Themeto a BevyWindowTheme