libretro / RetroArch

Cross-platform, sophisticated frontend for the libretro API. Licensed GPLv3.
http://www.libretro.com
GNU General Public License v3.0
10.21k stars 1.82k forks source link

RETRO_DEVICE_MOUSE and RETRO_DEVICE_POINTER not working properly with OSX #3190

Open dankcushions opened 8 years ago

dankcushions commented 8 years ago

In the test core I only get readings readings from the mouse retrieval code (https://github.com/libretro/RetroArch/blob/master/cores/libretro-test/libretro-test.c#L219) when either the left mouse button (for RETRO_DEVICE_MOUSE) is held, or the trackpad (RETRO_DEVICE_POINTER) is held.

This behaviour is wrong for RETRO_DEVICE_MOUSE - according to https://github.com/libretro/RetroArch/blob/master/libretro-common/include/libretro.h#L119 it should report the delta as long as the mouse cursor is in the window. You shouldn't need to click and hold.

It is also wrong for RETRO_DEVICE_MOUSE - according to https://github.com/libretro/RetroArch/blob/master/libretro-common/include/libretro.h#L158 it should report as long as the touchpad is touched. On a mac trackpad, you can touch to move the cursor around without having to click the pad. So, RETRO_DEVICE_POINTER_PRESSED should be set as long as there is a touch event.

As far as I can tell, the problem is that the current cocoa input driver only reads out the x/y of pointer/mouse, when touch_count > 1 (see https://github.com/libretro/RetroArch/blob/0a613c04a6758ac4ba5ead79f5ad651ec5f816af/input/drivers/cocoa_input.c#L150 for mouse and https://github.com/libretro/RetroArch/blob/0a613c04a6758ac4ba5ead79f5ad651ec5f816af/input/drivers/cocoa_input.c#L227 for pointer), but, it only sets touch_count = 1 when the mouse is clicked: https://github.com/libretro/RetroArch/blob/35b48bca2cb4783218056a77bcba82c5a29eb835/ui/drivers/ui_cocoa.m#L148

I think the mouse could be fixed in the existing code - I will try that soon, but the pointer is different - current driver doesn't handle trackpad touch events at all, really, just the behaviour of the mouse when you use the trackpad (which is why it doesn't set touch_count until the pad is clicked rather than touched, as the mouse has no concept of touching).

Really it should be using the NSTouch object, which contains all the touch data (if it's touched, how many figures, etc), but I couldn't get it working :)

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/35739299-retro_device_mouse-and-retro_device_pointer-not-working-properly-with-osx?utm_campaign=plugin&utm_content=tracker%2F296058&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F296058&utm_medium=issues&utm_source=github).
dankcushions commented 8 years ago

I've updated this issue with some new findings, but I'm not able to get anywhere with the trackpad stuff as it requires objective-c and cocoa knowledge, which i'm struggling with! Hopefully someone else does!