Skip to content
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

Allow Users to Customize Key Mapping #136

Merged
merged 8 commits into from Dec 8, 2018
Merged

Conversation

ezrayoung
Copy link
Contributor

Having the directional buttons on the right and action buttons on the left did not feel natural.

This PR allows users to customize what keys are mapped to each player's controller buttons and saves those changes to localStorage. Although it wasn't made to fix the issue, it does adequately address #65.

It's definitely not as cleanly implemented as I would like, but it's a joy to play with the keys I prefer. I didn't want to hold out from others being able to have the same experience.

Note

If browser does not allow access to localStorage, it will silently fail and maintain the default key mapping. We could get past that, but I'm not sure it would maintain those preferences past a refresh or ROM change.

I was only able to test these changes on recent versions of Chrome and Firefox. Bandwidth limitations kept me from downloading other browsers for testing.

@bfirsh
Copy link
Owner

bfirsh commented Dec 5, 2018

Hi @ezrayoung! This is awesome. Thanks so much for the contribution. Also apologies for the slow review... I've been travelling in Central Asia and tied up with other projects. :)

I think I shall merge this as it is, because it works fine, and as you say it would be good to let people use this functionality.

A couple of thoughts:

  • Did you consider lifting the state up? I think this might make the implmentation a bit neater. keyboardController.keys could be passed to ControlsModal. You could then have a setKey method on KeyboardController that was passed all the way down to each row. That way the state management and business logic is all in KeyboardController.
  • Is there a reason why it is persisted on unload rather than on every key change? I would have thought setting local storage is pretty cheap. That way you wouldn't have to check if state were modified and the keys would still persist if unload wasn't called for whatever reason.

@bfirsh
Copy link
Owner

bfirsh commented Dec 5, 2018

I think this will close #69 and #65

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants