jeremyletang / rust-sfml

SFML bindings for Rust
Other
638 stars 88 forks source link

window::keyboard is private, when it should be public. #318

Closed MrMagician closed 1 year ago

MrMagician commented 1 year ago

I am currently writing a test project using rust-sfml. And I'm aware that using the event system is a very messy way to do realtime input. However, there appears to be no equivalent to sf::Keyboard. The window module for these bindings appears to have what I need, including: clipboard, joystick, mouse, sensor, and touch. But there doesn't appear to be any keyboard module. As a test i wrote this code:

use sfml::window::keyboard

which gave me this error:

error[E0603]: module "keyboard" is private

It looks like you may have forgotten to label this module/struct as public.

Thank you for your time.

crumblingstatue commented 1 year ago

Using the event system is the recommended way to do input, because it responds to the window events. The method for directly querying keyboard input ignores whether the window is focused, which might not be what you want.

Regardless, if you're looking for Keyboard::isKeyPressed, then you want this: https://docs.rs/sfml/0.20.0/sfml/window/enum.Key.html#method.is_pressed

MrMagician commented 1 year ago

Alright, thank you so much!