-
Notifications
You must be signed in to change notification settings - Fork 137
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
WIP - Reorganize the input system (no merg, feedback plz) #364
Conversation
) | ||
|
||
var ( | ||
// Time is the active FPS counter | ||
Time *Clock | ||
|
||
// Input handles all input: mouse, keyboard and touch | ||
Input *InputManager | ||
Input *InputMgr |
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.
I think these Mgr
should be Manager
. More semantic and as such easier to understand.
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.
Hmm, using consistent suffixes (like Mgr) is helpful for someone maintaining the code, using Manager is annoying for a maintainer (More typing and longer, more complex lines to read). Using the full word is only helpful for people reading the code for the first time, learning the meaning of a consistent set of suffixes happens fast.
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.
Well, I don't agree. I'm against things like variable names as o
or s
because then I have to search for signatures or whatever. Even when I'm the guy who did the code. I always prefer things a little more verbose but easier to understand what they are.
Anyway, just my humble opinion!
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.
I agree that variable names need to be verbose, but I prefer using a short suffixes to add extra info on a object name.
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.
I'm not a fan of this sort of shortening. I'd strongly prefer having InputManager
.
Changes Unknown when pulling 644bb9a on nitya-dev:nitya-input into * on EngoEngine:master*. |
Changes Unknown when pulling a1e400b on nitya-dev:nitya-input into * on EngoEngine:master*. |
Changes Unknown when pulling a1e400b on nitya-dev:nitya-input into * on EngoEngine:master*. |
const StateJustIdle = State(2) | ||
const StateJustActive = State(3) | ||
|
||
//////////////// |
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.
This isn't idiomatic godoc commenting
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.
I disagree, from the go docs:
Comments that are not adjacent to a top-level declaration are omitted from godoc's output, with one notable exception.
So godoc allows the user to add top level comments that are ignored. If they are not ignored this is a bug or they need to adjust there documentation. Now I do understand you do not like this comment style, I remember that from the last pr and I was planning to remove it when it was ready to be merged.
I tried, I'm to old for this social media bullshit. I have 5.5 months left to finish the port of the two games to golang. If that is done I will setup a repo with MIT code you can backport. gl |
Changes Unknown when pulling f76fb58 on nitya-dev:nitya-input into * on EngoEngine:master*. |
Changes Unknown when pulling 25dfab6 on nitya-dev:nitya-input into * on EngoEngine:master*. |
This was my last push, if you want the changes I suggest you clone my repo and adjust/patch/doc it your self. I now remember why I dislike the github culture and I will be removing my account again soon. |
Wip: Looking for feedback, Basically I want to know if this has a chance to be merged, if it needs some big changes or if you prefer to keep the old setup and backport the fixes ?
ToDo: Add docs back where needed
ToDo: Check if there is no obsolete code left
ToDo: Remove remaining 'Nitya Note: and ToDo:"
Generalize the core input
Input to a game can be many things and has some specialized requirements depending on the game and/or the platform. As it stand now the input is a core part of engo and it is hard to modify or extend.
The changes in this pull request isolate the core of the input and then provide a safe and clean way to use it. By doing this there is a cleaner path to extend, swap out or setup a secondary input system when required.
@Sendoushi mentioned this desire in gitter and it is used by me to push and pop input behavior depending on the game state, when attempting to do this in the old system it became messy due to the use of global variables that link it all up.
Minimizes string lookups
When looking at the benchmarks of the old system there is a big diffidence between the most optimal way of doing things and the worst way of doing things. This is mostly due to the string based lookups that happen every frame.
The new system ditches the string lookups in the game loop and moves them to the setup and loading section of the game. Once running all lookups are based on id's.
Note: The optimal benchmarks where possible because the axes and buttons (ab)-used global variables. The new system no longer has an optimal or sub-optimal path, performance wise that benchmark would now sit between the two extremes
Other changes worth mentioning
Edge cases mentioned above are added to the new testing
Things I played with but left out
Leaving these out of the engine and adding some specialized demos on how to achieve these behaviors would be preferable to me.