kkaja123 / Gopher360

Gopher360 is a free and open source zero-configuration-needed application that 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
6 stars 2 forks source link

[FIXED?] UI elements not responding on mouse movement #32

Open kkaja123 opened 4 years ago

kkaja123 commented 4 years ago

Originally posted by @mike1084 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.

kkaja123 commented 4 years ago

Originally posted by @Zero3K You can post the tweak as a comment and see if someone can implement it.

kkaja123 commented 4 years ago

Originally posted by @mike1084 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.

kkaja123 commented 4 years ago

Originally posted by @Tylemagne 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.

kkaja123 commented 4 years ago

Originally posted by @Zero3K Well, you can test it yourself.

kkaja123 commented 4 years ago

Originally posted by @KevTheRev13 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 ?

KevTheRev13 commented 4 years ago

For what it's worth - I was able to use software other than gopher360 to achieve my goals. Steams "Controller Companion" worked out of the box, or just using the Steam controller interface and selecting XBOX config mode (worked great with a cheap EasySMX controller).

I use the latter approach (steam interface settings) on a daily basis.

Just an alternative for those struggling to make gopher360 work.