-
Notifications
You must be signed in to change notification settings - Fork 163
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
Added support for gamepad #164
Conversation
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.
Nice, thanks! I haven't got a gamepad so I trust this works. :)
A couple of minor comments. I think this code could also generally do with some refactoring, which is already noted in #149.
.playerGamepadId || [null, null]; | ||
this.state.gamepadConfig.configs = this.state.gamepadConfig.configs || {}; | ||
|
||
this.state.controllerIcon = this.state.gamepadConfig.playerGamepadId.map( |
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 stuff seems to be calculated based on gamepadConfig
. Perhaps it makes more sense to just be a function or something instead of being on state.
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 am sorry, I don't get it, it is only a default initialization to ensure gamepadConfig starts in a not null state. Show me a code example if you want
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.
It's only a minor thing, no worries. From a cursory look at the code, it seems like controllerIcon
is just computed from gamepadConfig
. So, it's not really state, but just a function which would take gamepadConfig
as an argument.
I'll get this merged and then make some follow-up issues. :)
</th> | ||
<th> | ||
Player 2 | ||
<img |
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.
Have you tested that this works in the built production bundle? I think you might need to import the images to make sure the calculated paths are correct: https://facebook.github.io/create-react-app/docs/adding-images-fonts-and-files
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.
Great! I alredy tested it using developer run (yarn start) and production build on my local machine. I will test it again on the netlify deploy for this PR (https://deploy-preview-164--youthful-kepler-d6ba79.netlify.com/), only to be sure
Do you need a list of covered cases ?
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.
Nice okay. Sounds like it works then. :)
Come to think of it, perhaps some basic tests are a good idea. I'm never going to test this manually, so it will probably regress. |
Thanks @tario! ✨ |
See #165. |
Features:
Please let me know if this need fixes. I will work on them as soon as possible
Appendix:
Sample of localStorage item generated for gamepadConfig
gamepadConfig.txt
Screenshot of ControlsModal