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

feat: react-gamepad-navigation implementation #286

Open
wants to merge 57 commits into
base: main
Choose a base branch
from

Conversation

hectorjjb
Copy link
Contributor

Enabling gamepad navigation by using Gamepad Web API and useArrowNavigationGroup under the hood.
Dpad and left stick events are translated to MoverMoveFocusEvent (Arrow navigation)
and A & B buttons are translated into Enter & Escape GroupperMoveFocusEvent respectively.

@marcosmoura marcosmoura marked this pull request as ready for review January 23, 2025 11:36
@marcosmoura marcosmoura requested a review from a team as a code owner January 23, 2025 11:36
marcosmoura
marcosmoura previously approved these changes Jan 23, 2025
@marcosmoura marcosmoura dismissed their stale review January 23, 2025 11:38

Updated code

@hectorjjb hectorjjb requested a review from marcosmoura January 27, 2025 20:57
@hectorjjb
Copy link
Contributor Author

requesting review from @tudorpopams

@hectorjjb hectorjjb requested a review from a team as a code owner February 4, 2025 16:31
@marcosmoura marcosmoura requested a review from Hotell February 12, 2025 18:23
Copy link
Contributor

@dmytrokirpa dmytrokirpa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work @hectorjjb! I added a few comments after my initial review, here's a quick summary:

  • Avoid using TS enums; it's better to use type union or a map with values if you prefer.
  • Keep type imports consistent by using import type {} where needed.
  • Make sure side effects like adding/removing listeners happen in useEffect.

"options": {
"packageRoot": "dist\\{projectRoot}"
}
"publish": {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need this?

unstable_hasDefault,
});
const groupperAttr = useFocusableGroup({ tabBehavior, ignoreDefaultKeydown });
const gamepadNavDOMAttributes = useMergedTabsterAttributes_unstable(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// eslint-disable-next-line @typescript-eslint/no-namespace
namespace React {
interface KeyboardEvent {
readonly [syntheticKey]?: boolean;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure it's a good practice to change/augment external types

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.

3 participants