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

Add Overlay Mouse, Lightgun, and Pointer #16343

Merged
merged 1 commit into from
Mar 16, 2024

Conversation

neil4
Copy link
Contributor

@neil4 neil4 commented Mar 9, 2024

Add Overlay Mouse, Lightgun, and Pointer

This creates mouse, lightgun, and pointer input as the overlay is polled. When enabled, touch inputs not in a hitbox are assumed to be pointing device input for the core.

The main benefit is that overlay buttons can be used simultaneously, so things like mouse-controlled 1st-person shooters and touchscreen emulation are more natural.

Mouse behavior

1/2/3-finger taps are LMB/RMB/MMB clicks. A 0.2s long press begins holding a button, and you'll feel haptic feedback when it starts. A double-tap hold method is also available but adds latency to clicks. Dragging 2/3 fingers immediately holds the RMB/MMB.

There are settings for mouse speed, long-press and double-tap time thresholds, and a "swipe threshold" to distinguish swipes from taps and long presses.

Lightgun behavior

Lightgun x, y, and trigger are normally sent together to every lightgun port. There are settings to choose the port, disable the trigger, delay the trigger, and clamp off-screen aim to the in-bounds edge. The trigger delay is needed for content that doesn't instantly move the gun cursor to a screen tap.

More lightgun buttons can be assigned to 2/3/4-finger inputs. The trigger delay is used to wait for the correct multi-touch count. A 1-frame delay is usually enough to distinguish these inputs.

Notes

  • A few cores have a "touchscreen" option for lightgun input. That needs to be set to "lightgun" for this. I expect some confusion over that.
  • This does not implement the deprecated relative x/y IDs, and I haven't seen any problems from it.

Related Pull Requests

The lite/SNES and lite/SNES_2 overlays in libretro/common-overlays#111 each include a lightgun overlay with buttons on the perimeter.

Worth a note: The existing lite/DOS and lite/DOS_2 overlays are already set up for 1st-person shooters, since each can hide the ABXY buttons.

Related Issues

Fixes #15452 #15749 #15973

- When enabled, any touch inputs not in a hitbox are used to create pointing device input for the core.
- Mouse: 1-, 2-, 3-touch inputs are LMB, RMB, and MMB
- Lightgun: allows input from overlay buttons or multi-touch mappings
@hizzlekizzle
Copy link
Contributor

This sounds great. We should probably copy this commit description to the docs site, as it will get lost in the shuffle here, and there's a lot of obscure knowledge (like the multi-finger tap commands) that users will never figure out on their own.

@neil4
Copy link
Contributor Author

neil4 commented Mar 10, 2024

Sure. I don't think it's so obscure, but I wrote it. I'll find a place to add this in the docs.

static void input_overlay_poll_lightgun(settings_t *settings,
input_overlay_t *ol, const int old_ptr_count)
{
input_overlay_state_t *ol_state = &ol->overlay_state;
Copy link
Contributor

Choose a reason for hiding this comment

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

This variable is unused

@warmenhoven
Copy link
Contributor

The combined overlay/touchscreen input is working on iOS as I would have expected. Very nice, thanks!

@neil4
Copy link
Contributor Author

neil4 commented Mar 11, 2024

@warmenhoven Oh thanks, iOS is always the platform I wish I could test with this kind of thing

@neil4
Copy link
Contributor Author

neil4 commented Mar 11, 2024

It looks like I should explain the mouse buttons in a sublabel, and remove an unused variable.

In the docs I only saw the touchscreen mouse explained for the Switch, and it's very different from Android's which this PR roughly follows.

@LibretroAdmin LibretroAdmin merged commit cc97df7 into libretro:master Mar 16, 2024
27 checks passed
@neil4 neil4 deleted the overlay-mouse-lightgun-pointer branch March 16, 2024 19:16
Sunderland93 pushed a commit to Sunderland93/RetroArch that referenced this pull request Dec 26, 2024
- When enabled, any touch inputs not in a hitbox are used to create pointing device input for the core.
- Mouse: 1-, 2-, 3-touch inputs are LMB, RMB, and MMB
- Lightgun: allows input from overlay buttons or multi-touch mappings
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.

ds bug
4 participants