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
Refactor Input system - Config 1` of N #2112
Conversation
73ff5c1
to
433345e
Compare
433345e
to
e9e65ab
Compare
9e6b125
to
7823cf8
Compare
7823cf8
to
a69922c
Compare
a69922c
to
7d33482
Compare
* Speeds up InputSource::Update by removing indirections * Reduces memory footprint of buttons array. Measured desktop reduction to be a factor of 6x.
* Implement for Button -> Keys and Direction -> Button * Use same layout as raw vector * Sort buttons to improve locality in SourceUi::Update() and make modifications to button array faster. * Provide accesors and mutators, and tests.
* Store mappings in Input::Source * Pass them into Input::Init(), so later we can source them from other places.
7d33482
to
9063255
Compare
The "naive" implementation would use std::(unordered_)map -> std::vector but your data structure seems to be a flat vector containing the keys. That's okay, but I'm still annoyed that this needs this unreadable What is from an input point of view: A Can't you implemant |
lower_bound is the C++ binary search, it just has a different name.
Apologies. This was pretty manageable when I did the first pass and it was just built on the As soon as I added In C++
Code is nastier, but it's more efficient. I'd rather keep the faster code, despite it being harder to follow. I wrote a unit test suite around this because that is the only way you can ensure it works. This is one self contained bit where we need to write it once, test it to death, and then never touch it again. I can take another look at this and see if there is a way to make it more readable. |
Sorry this was not a criticism. I knew why you used std::vector and binary search here and it makes totally sense. I would just prefer if there would be a Would this data structure also be useful for the FileFinder in my refactor? I would need a sorted std::string -> std::string mapping and a "Find" function. So imo InputArray would fulfill this required? (just need a "Find"). And clang fails to resolve the enum type correctly. When I look in the debugger it shows negative numbers for some keys even though you specified uint8_t :( |
26d8306
to
36104b0
Compare
I factored out the map implementation into a Despite the code being more generic now, I think it's actually a lot more understandable.
Not exactly, this is one is mapping of keys to multiple values, where each (key, value) pair has to be unique. It's not a What you want is just a simple
I don't quite follow this? If the type is Is the bit pattern / hex the same as an unsigned |
36104b0
to
44785ce
Compare
Some numbers on map vs flat_map vs unordered_map |
44785ce
to
b2063a7
Compare
This PR refactors the Input subsystem.