Skip to content

fix(libretro): correct touch cursor in Hybrid (Focus Bottom) layouts#305

Open
DaVinciLord wants to merge 1 commit into
JesseTG:devfrom
DaVinciLord:fix/hybrid-cursor-render
Open

fix(libretro): correct touch cursor in Hybrid (Focus Bottom) layouts#305
DaVinciLord wants to merge 1 commit into
JesseTG:devfrom
DaVinciLord:fix/hybrid-cursor-render

Conversation

@DaVinciLord

@DaVinciLord DaVinciLord commented Apr 27, 2026

Copy link
Copy Markdown

I experienced at least one of the issues mentioned when trying to play with RetroArch on my linux desktop, so I decided to help a little with these issues.

Keep in mind, that the code was AI-Generated as I am not well versed with C++, OpenGL or shaders.
However, the test suite was run in my local environment and passed. Also, manual testing on my setup with alternating layout and renderer (Software/OpenGL) was performed as well and passed for me.

If this does not get merged, I understand and will take any feedback to help improve my knowledge and collaboration. 😄

Summary

  • OpenGL: Cursor position in framebuffer pixel coordinates (gl_FragCoord / uScreenSize) instead of a UV heuristic on the bottom half of the texture.
  • OpenGL & software: Same idea as screen placement — ConsoleTouchPosition() (same coordinates sent to the emulator) and hybrid vs bottom matrix depending on layout and “show opposite screen”.
  • Software: Cursor box from transforming touch ± cursorSize corners (same as OpenGL), instead of transformed center + buffer-space offset that was wrong under hybrid.
  • API: Expose GetHybridScreenMatrix() and plumb ConsoleTouchPosition() through InputState.

Issues

Issue Note
Cursor in empty area (software, Hybrid Focus Bottom + opposite screen) Fixes #288
Cursor / input mismatch (OpenGL) and wrong placement (software) in hybrid Closes #240
Touch vs on-screen indicator (#171) Related — this aligns drawing with console touch; confirm whether #171’s reported behavior is fully fixed.

Testing

  • Hybrid (Focus Bottom) + opposite screen, software: cursor on the large touch area.
  • Same setup, OpenGL: on-screen typing matches cursor.
  • Other hybrid / flipped layouts (quick regression pass).

OpenGL placed the cursor in UV space on the bottom half of the output
texture, which did not match hybrid layouts. Software rendering always
used the secondary touch-screen matrix.
Use ConsoleTouchPosition (same as nds.TouchScreen) and the hybrid or
bottom matrix as appropriate; draw the cursor in framebuffer pixels in
the fragment shader, or use the same transformed bounds as OpenGL in
software.
Fixes: JesseTG#288
Closes: JesseTG#240
@DaVinciLord DaVinciLord marked this pull request as ready for review April 27, 2026 20:04
@JesseTG

JesseTG commented Apr 27, 2026

Copy link
Copy Markdown
Owner

Thanks for your contribution! I'll test this personally and will merge it if I don't find any problems.

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.

2 participants