libretro-mirrors / scummvm

ScummVM with libretro backend.
http://www.scummvm.org/
GNU General Public License v2.0
22 stars 31 forks source link

Mouse: Allow use of Pointer API #101

Open RobLoach opened 6 years ago

RobLoach commented 6 years ago

The Pointer API seems to reference everything as an absolute value, rather than relative. It may make the Operating Systems mouse match where the ScummVM mouse is for clearly? Perhaps this is not the correct approach?

https://github.com/libretro/libretro-common/blob/master/include/libretro.h#L149-L179

/* Abstracts the concept of a pointing mechanism, e.g. touch.
 * This allows libretro to query in absolute coordinates where on the
 * screen a mouse (or something similar) is being placed.
 * For a touch centric device, coordinates reported are the coordinates
 * of the press.
 *
 * Coordinates in X and Y are reported as:
 * [-0x7fff, 0x7fff]: -0x7fff corresponds to the far left/top of the screen,
 * and 0x7fff corresponds to the far right/bottom of the screen.
 * The "screen" is here defined as area that is passed to the frontend and
 * later displayed on the monitor.
 *
 * The frontend is free to scale/resize this screen as it sees fit, however,
 * (X, Y) = (-0x7fff, -0x7fff) will correspond to the top-left pixel of the
 * game image, etc.
 *
 * To check if the pointer coordinates are valid (e.g. a touch display
 * actually being touched), PRESSED returns 1 or 0.
 *
 * If using a mouse on a desktop, PRESSED will usually correspond to the
 * left mouse button, but this is a frontend decision.
 * PRESSED will only return 1 if the pointer is inside the game screen.
 *
 * For multi-touch, the index variable can be used to successively query
 * more presses.
 * If index = 0 returns true for _PRESSED, coordinates can be extracted
 * with _X, _Y for index = 0. One can then query _PRESSED, _X, _Y with
 * index = 1, and so on.
 * Eventually _PRESSED will return false for an index. No further presses
 */
#define RETRO_DEVICE_POINTER      6
i30817 commented 6 years ago

I originally had some problems with the mouse with game focus toggle on on the scummvm core but recently it seems better (except for a little bit after loading the core, the mouse can be 'restricted' to a imaginary y-axis zone of the screen)

But this is much better than it was before, where that imaginary line didn't stop and the actual scummvm cursor had no relation to what was being clicked. Then i had to use game focus toggle and that fixed it.

Game focus toggle appears to bind the Scummvm cursor to the 'real mouse cursor'.

One thing i noticed is that the OS cursor and the Scummvm cursor don't actually have any relation (except in game focus toggle mode). Even their vertical speed is different (the original cause of the offset cursor click bug was probably that it was clicking under the 'real OS mouse' not the scummvm).

NelsonRosenberg commented 6 years ago

Also had good results with both game and mouse toggle, both seem to work fine and make the sucmmvm core much more enjoyable.

i30817 commented 6 years ago

Not on KMS as i found recently. It's just as bad (even worse) there. For instance, mouse (touchpad actually) buttons don't actually work. Mapped to retropad or not.

RobLoach commented 6 years ago

Thanks for the feedback! Going to close this one for now. The Mouse is working just fine.

Ferk commented 6 years ago

If I was to improve anything would be to make the mouse toggle a per core option from the Controls quick menu. But that would be a frontend thing.

RobLoach commented 4 years ago

Added the ability to toggle the Pointer API on TIC-80, and found it very effective when RetroArch is not in fullscreen mode. Like you recommended, it's a core option: https://github.com/libretro/TIC-80/blob/master/src/system/libretro/tic80_libretro.c#L422-L446

Looks like this, and I think it would really improve mouse usage in the ScummVM core, so going to re-open this... Screenshot at 2020-02-27 12-51-15