PistonDevelopers / input

DEPRECATED - moved into the piston repo
MIT License
7 stars 11 forks source link

Add text input variant #35

Closed bvssvni closed 10 years ago

bvssvni commented 10 years ago

rust-sdl2 has a TextInputEvent(uint, Window, String)

glfw-rs has a CharEvent(char)

bvssvni commented 10 years ago

rust-sdl2 has a start_text_input and stop_text_input.

This is probably to not allocate on each event.

bvssvni commented 10 years ago

Could add a new variant to InputEvent:

CharInput { ch: char }
bvssvni commented 10 years ago

It will work if we enable text input by default in sdl2_game_window and use String:

Text(String)
bvssvni commented 10 years ago

The cost of allocating a String will be small compared to checking the time.

Source: http://stackoverflow.com/questions/7612292/how-bad-it-is-to-keep-calling-malloc-and-free

bvssvni commented 10 years ago

I think we should just enable text input by default in sdl2_game_window allocate a String. In glfw_game_window we should convert the char to a String.