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 mouse relative check and set appropiatley to fix issue #12994

Merged
merged 5 commits into from Sep 24, 2021
Merged

add mouse relative check and set appropiatley to fix issue #12994

merged 5 commits into from Sep 24, 2021

Conversation

ghost
Copy link

@ghost ghost commented Sep 15, 2021

The old code was traced and it returned zero values. The relative check was added to make the code clear and its a mouse as well. This should put the issue to sleep. Will test on the pi at the weekend cant see there being any issues.

@jdgleaver @twinaphex @bozothegeek

@ghost
Copy link
Author

ghost commented Sep 15, 2021

This has been tested in x and kms with ./configure --disable-discord --disable-qt --disable-cdrom --disable-x11 --disable-caca --disable-sdl --disable-sdl2 --disable-opengl1 --disable-ffmpeg --disable-flac --disable-wayland --enable-kms --enable-opengl --enable-vulkan

@inactive123 inactive123 added this to the full review milestone Sep 16, 2021
@i30817
Copy link
Contributor

i30817 commented Sep 17, 2021

What will this do? Fix restricted mouse areas in cores like puae and scummvm?

edit: oh lightguns. FYI a very similar problem occurs since forever for other mouse cores where you have to move the mouse using the touchpad and it occasionally 'changes' the area of the screen available if you keep trying. It's unusable but i guess there are not many people reporting or complaining or using a mouse core in retroarch and not on windows, because people have no taste.

@ghost
Copy link
Author

ghost commented Sep 18, 2021

It would be nice to clarify something though.

static int16_t udev_mouse_get_pointer_x(const udev_input_mouse_t *mouse, bool screen)
{
video_viewport_t vp;
double src_min;
double src_width;
int32_t x;
if (!video_driver_get_viewport_info(&vp))
return 0;
if (mouse->x_min < mouse->x_max) /* mouse coords are absolute */
{
src_min = mouse->x_min;
src_width = mouse->x_max - mouse->x_min + 1;
}
else /* mouse coords are viewport relative */
{
src_min = vp.x;
if (screen)
src_width = vp.full_width;
else
src_width = vp.width;
}
x = -32767.0 + 65535.0 / src_width * (mouse->x_abs - src_min);
x += (x < 0 ? -0.5 : 0.5);
if (x < -0x7fff)
return -0x7fff;
else if(x > 0x7fff)
return 0x7fff;
return x;
}
static int16_t udev_mouse_get_pointer_y(const udev_input_mouse_t *mouse, bool screen)
{
video_viewport_t vp;
double src_min;
double src_height;
int32_t y;
if (!video_driver_get_viewport_info(&vp))
return 0;
if (mouse->y_min < mouse->y_max) /* mouse coords are absolute */
{
src_min = mouse->y_min;
src_height = mouse->y_max - mouse->y_min + 1;
}
else /* mouse coords are viewport relative */
{
src_min = vp.y;
if (screen)
src_height = vp.full_height;
else
src_height = vp.height;
}
y = -32767.0 + 65535.0 / src_height * (mouse->y_abs - src_min);
y += (y < 0 ? -0.5 : 0.5);
if (y < -0x7fff)
return -0x7fff;
else if(y > 0x7fff)
return 0x7fff;
return y;
}

the pointer and lightgun use this.

Now correct me if im wrong the pointer and lightgun should be absolute devices yet its falling back to relative if its not abs should we really be doing this that my only confusion on this matter.

@ i30817
unfortunately my touchpad is toast but I can still test. If you try this and you still have them issues please open another issue with details of how to reproduce the issue and ill certainly try take a look if I can do anything or at least trace the issue to give you some clarification.

@i30817
Copy link
Contributor

i30817 commented Sep 18, 2021

It happens in all cores that need a computer mouse and you're using a touchpad. PUAE, or scummvm for instance.

The area where the touchpad can operate doesn't fill in the whole game screen or is offset from the center. The weird part is that that area can change so if you frenetically push back and forwards along a axis you sometimes can 'drag' that area to other parts of the screen.

It's unusable. But i don't see anyone else complaining so i assume it only doesn't work in linux and every user is on windows or something. This is with the X input driver in X11, and with udev for controllers (which i don't use and i don't think matters for mouse, but who knows).

@ghost
Copy link
Author

ghost commented Sep 18, 2021

@i30817 the udev input driver is what this applies too. Change that to udev. I'm going to get a laptop hopefully today I need to test some things there are two issues. I need to check properly. I would definitely open an issue if I was you and report if udev and x11 are doing the same. A restart is needed when changed. Wayland you can't change the input driver.

@ghost ghost closed this Sep 19, 2021
@ghost
Copy link
Author

ghost commented Sep 19, 2021

There are still some issues in this driver that will need more time. The hotplug add remove isint setting /setting removing mouse names and touchpad devices are starting at zero as they are called separately from mice in udev_input_init(). Obviously static wasnt the way to fix it since its called more than once and it was only originally added for logging now it setting the name for ra it will need fixed.

[INFO] [udev]: Keyboard #0: "Power Button" (/dev/input/event3).
[INFO] [udev]: Keyboard #1: "Video Bus" (/dev/input/event6).
[INFO] [udev]: Keyboard #2: "Acer Wireless Radio Control" (/dev/input/event5).
[INFO] [udev]: Keyboard #3: "Power Button" (/dev/input/event0).
[INFO] [udev]: Keyboard #4: "Sleep Button" (/dev/input/event1).
[INFO] [udev]: Keyboard #5: "HD User Facing: HD User Facing" (/dev/input/event13).
[INFO] [udev]: Keyboard #6: "AT Translated Set 2 keyboard" (/dev/input/event4).
[INFO] [udev]: Keyboard #7: "Acer WMI hotkeys" (/dev/input/event12).
[INFO] [udev] REL MOUSE
[INFO] [udev]: Mouse #0: "ELAN050A:00 04F3:3158 Mouse" (/dev/input/event7).
[INFO] [udev] ABS MOUSE
[INFO] [udev]: Mouse #0: "ELAN050A:00 04F3:3158 Touchpad" (/dev/input/event8).

@ghost ghost reopened this Sep 19, 2021
@ghost
Copy link
Author

ghost commented Sep 23, 2021

@jdgleaver @twinaphex the code is complete now. The hotplug will add names now and a relative check. Sorry it took so long have been really busy with work.

@inactive123
Copy link
Contributor

OK, we'll merge as is. I will be doing some style nits later on but nothing that will affect anything on a fundamental level. Thanks for all your efforts.

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