bevyengine / bevyengine/bevy

Switch Joy-Con (Left / Right) support on macOS

Open
#6,269 4 comments 0 reactions 0 assignees View on GitHub
A-Input C-Bug O-MacOS
Dominant language
Rust
Stars
48.2k
Forks
4.8k
Avg merge
3d 16h
Merged PRs (30d)
171

Description

## Bevy version

6b75589e2c91429eb6c35574840d47d39b2379b9

## \[Optional\] Relevant system information

macOS 12.6

## What you did

When I connect a single Switch Joy-Con (either left or right) to my Mac via bluetooth the D-Pad (left right up down) is not being registered. E.g. moving it doesn't generate any events in Bevy. The buttons (a, b, x, y) work fine.

## What went wrong

I tracked the issue down to two places:

- [gilrs did not register the `EvCode` for `Hat` types. I created a PR for that.](https://gitlab.com/gilrs-project/gilrs/-/merge_requests/68)
- [Bevy ignores all D-Pad events for reasons that I don't understand](https://github.com/bevyengine/bevy/blob/main/crates/bevy_gilrs/src/converter.rs#L43)

When I use my `gilrs` fork and when I change the `bevy_gilrs/converter.rs` locally to:

``` rs
gilrs::Axis::DPadX => Some(GamepadAxisType::LeftStickX),
gilrs::Axis::DPadY => Some(GamepadAxisType::LeftStickY),
// The `axis_dpad_to_button` gilrs filter should filter out all DPadX and DPadY events. If
// it doesn't then we probably need an entry added to the following repo and an update to
// GilRs to use the updated database: https://github.com/gabomdq/SDL_GameControllerDB
gilrs::Axis::Unknown => None,
```

Then I get the correct events and I can use my Joy-Con's for controlling a Bevy game. However I don't have enough knowledge about this code to know why the filter for D-Pad events existed in the first place. I'll happily create a PR with these changes if somebody who understands this can confirm that this is indeed a useful solution.

Contributor guide

Open the contributing guide

Research direction

Start by reading crates/bevy_gilrs/src/converter.rs around line 43 and compare its D-pad handling with the linked gilrs merge request. Reproduce the issue with a single left or right Joy-Con on macOS, then verify that D-pad events are emitted without breaking the existing gilrs filtering behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
macos, rust
Domain
game-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.