Tylemagne / Gopher360

Gopher360 is a free zero-config app that instantly turns your Xbox 360, Xbox One, or even DualShock controller into a mouse and keyboard. Just download, run, and relax.
GNU General Public License v3.0
924 stars 166 forks source link

[FIXED] UI elements not responding on mouse movement #56

Open mike1084 opened 6 years ago

mike1084 commented 6 years ago

As the title says, I have been having some issues with UI elements reacting when I move the mouse with the left stick. So far, I've had these issues with the Windows 10 calculator, and Civilization VI (haven't tried any other games, though the Battle.net launcher works just fine). I could get the elements to update when I moved my right stick, but that wasn't a real pleasant way of playing the game...

After some looks at the code, I noticed mouse movement used SetCursorPos, rather than SendInput, and after some minor tweaks I've created an input from the mouse movement and that is being sent, now correctly providing me with UI elements working inside Civ, yay! (and also the calculator!)

I'm not sure how to go about now adding this code to the project, but it seems to me like this minor fix did something that (for me) broke the experience somewhat, but as I couldn't see any others with the issue, I'm not sure if I just have something weird going on at my end. ;p

TL;DR: I could get my UI elements to work correctly in-game with just a minor code tweak.

Zero3K commented 6 years ago

You can post the tweak as a comment and see if someone can implement it.

mike1084 commented 6 years ago

Right, would be great to hear if this does help others. Basically, all I did was change the function handleMouseMovement(), specifically at line 269, which I commented out, and instead placed:

        // Create new input to send, by mouse data, with a mouse movement event.
        INPUT input;
    input.type = INPUT_MOUSE;
    input.mi.dx = dx;
    input.mi.dy = dy * -1;
    input.mi.dwFlags = MOUSEEVENTF_MOVE;
    input.mi.time = 0;
    SendInput(1, &input, sizeof(INPUT));

It seemed the use of SetCursorPos() didn't actually send the input, therefore only changing the location of the mouse but not really making the program aware of it other than that. Just my guess though.

Tylemagne commented 6 years ago

Interesting, I remember writing that and not being aware of any alternative input methods.

Does switching to SendInput() from SetCursorPos() negatively effect any applications as far as you can tell? Further, does the program work properly now without the need to be ran as an administrator? Previously, I had to detect elevation and put a warning in the intro text if it wasn't, because it wasn't able to do anything with the Windows keyboard or games. I feel like this new function might negate the need for elevation (as well as the warning) if this achieves everything.

Zero3K commented 6 years ago

Well, you can test it yourself.

KevTheRev13 commented 5 years ago

I'm having this issue as well - why is this marked as fixed? It seems there was never a commit of this change. Exactly as OP describes - I can get the mouse to move, but cant click on any UI elements in CIV 6. Functionality outside of the game seems to be flawless. I guess I need to download the code, make the edits, and rebuild this myself to get these changes? Is this considered a good fix? Or does the issue need further research ?