-
Notifications
You must be signed in to change notification settings - Fork 5
Initial implementation of InputManager #28
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
base: master
Are you sure you want to change the base?
Initial implementation of InputManager #28
Conversation
7b85a1d to
eafdeb8
Compare
This time fixing merge problems on GitHub and any build jobs.
eafdeb8 to
6a8c66e
Compare
kasmacioma
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small review
|
Thanks for the helpful review, will work on fixing all of it. |
- Use enum class instead of enum - Add const and noexcept qualifiers - Make isPrintable private - Rename m_will_quit and m_isLocked to m_quitState and m_lockState - Simplify clearing m_printable in update()
|
Hm, |
This is absolutely NOT complete. Still a lot of work to be done, but this should act as a starting point.
Something like this? If this is a good direction, I'll continue to work on this. Else I'll try another method. EDIT: Several improvements were made in the next two commits. |
- Move all input staff to `bloom::input` namespace - Move Keyboard and Mouse classes to separate file - Rename Keyboard to KeyboardEvent and Mouse to MouseEvent - Add set and clear methods for event classes (private methods) - Add enum for event types - Add reset() for InputManager to reset all events (private method) - Mark isUp and isDown as deprecated (check comments for them)
|
@LumpBloom7, check my implementation https://github.com/xapdkop/BloomFramework/commit/2177f7135e7c4ee23e84bc8c2feee40c84987f8a |
- Add ctors for KeyboardEvent and MouseEvent - Rename clear to reset in KeyboardEvent and MouseEvent - Add messages for deprecated funcs - Store printable character as char - Use pairs for pos, movement and scroll in MouseEvent - Make enter and backspace printable - Rework the logic of events handing - Add flag for prevention the handling of [unhandled] events if quit event was handled - Now InputManager::update will return current quit state w/o resetting it (to reset use resetQuit) - Turn off InputManager::getType
- Adjust KeyboardKey::KEYBOARD_SIZE - Add MOUSE_X1 and MOUSE_X2 to MouseButton - Simplify `set` in MouseEvent and KeyboardEvent - Add NoEvent to EventType - Use std::bitset instead of std::array in KeyboardEvent - Record all printable chars (and make m_printable as std::string) - Add `getPos`, `getOffset` and `getScroll` to MouseEvent - Add `wait` to InputManager to wait event (SDL_WaitEvent and SDL_WaitEventTimeout) - Now `InputManager::update ` will return true if at least one event was handled, otherwise false will be returned - Add internal SDL_Event to prevent creating new one each time `update` or `wait` is called - Update getting mod keys (capslock, numlock) state - Add `KeyboardEvent::capsLock` to check caps lock's state - Move main handler from InputManager::update to InputManager::handle
- Rename isUp and isDown to wasDown and wasUp - Add control of state change - Now wasDown and wasUp will check if state was changed - Add stateChanged func You may check how wasUp and wasDown work by pressing 0, caps lock and LMB in the Test Bench
|
I want to get this merged in as soon as possible. It has been on hold for way too long. Do you think this is ready? |
* Remove old code * [InputEvents] Use constexpr functions instead of macros * Update and simplify keys and buttons naming Use PascalCase (CamelCase) instead of UpperCase. For keys naming was used https://docs.rs/sdl2/0.32.2/sdl2/keyboard/enum.Scancode.html * Add KeyboardEvent::getPrintableRef * Small simplifications * Implement SymRecorder for KeyboardEvent And store only last event char ('\0' if event is not printable) SymRecorder [disabled by default] records all chars from events on demand (after it was activated) to printable user-friendly (means no more '\b' chars and all 'Enter' will be converted to "\r\n") string. 'Backspace' deletes last char.
This PR adds the ability to handle user input
InputManageris an object which takes all keyboard and mouse input and makes it easy to use.InputDefinitionsis an enum list of all usable keys(keyboard and mouse has one each) named in a simple format.