StrokesPlus.net
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
Ju87  
#1 Posted : Tuesday, December 1, 2020 9:55:23 AM(UTC)
Ju87

Rank: Newbie

Reputation:

Groups: Approved
Joined: 12/1/2020(UTC)
Posts: 5

Thanks: 6 times
Hello. Games using mouse to camera control (for example, FPS) do not allow to do gestures. Cursor just locked in center of screen. Is there a way to use S+ in such games?

Thanks and sorry for my English :)
Rob  
#2 Posted : Tuesday, December 1, 2020 1:56:30 PM(UTC)
Rob

Rank: Administration

Reputation:

Groups: Translators, Members, Administrators
Joined: 1/11/2018(UTC)
Posts: 1,349
United States
Location: Tampa, FL

Thanks: 28 times
Was thanked: 416 time(s) in 354 post(s)
Gestures and games do not always work together nicely. Some games also look to see if any automation/macro programs are running and reject their input (to prevent bots/cheats).

It's hard to know if the game will allow S+ to be used.

So does the gesture line draw at all?
When you hold the stroke button, does anything happen?
When you let go of the stroke button, does the game then start working normally?
thanks 1 user thanked Rob for this useful post.
Ju87 on 12/10/2020(UTC)
Ju87  
#3 Posted : Thursday, December 3, 2020 11:47:39 AM(UTC)
Ju87

Rank: Newbie

Reputation:

Groups: Approved
Joined: 12/1/2020(UTC)
Posts: 5

Thanks: 6 times
Thank you for response! No, this is a simple singleplayer games without any anticheat (I guess). Detroit: Become Human, Lifeless Planet – these games completely attach cursor in center of screen and restricts gesturing. I press stroke button, process starts, I try to draw a gesture, but the cursor does not moves, just camera in the game moves. The cursor fluctuates slightly in the center of the screen and draws short chaotic stroke instead of a gesture.

The screenshot shows an attempt to draw a gesture:

Screenshot

By the way, in some other games the system interface for taking screenshots helps with a similar problem. When you press PrtScr, the screenshot overlay opens (Windows 10) and after that the cursor detached from the center of the screen in the game and you can easily draw gestures.

Edited by user Thursday, December 3, 2020 11:51:46 AM(UTC)  | Reason: Not specified

Rob  
#4 Posted : Thursday, December 3, 2020 2:29:11 PM(UTC)
Rob

Rank: Administration

Reputation:

Groups: Translators, Members, Administrators
Joined: 1/11/2018(UTC)
Posts: 1,349
United States
Location: Tampa, FL

Thanks: 28 times
Was thanked: 416 time(s) in 354 post(s)
Okay I see now.

So does this cursor locking happen for other mouse buttons? Like if you used the middle button as a stroke button, for example.

This is a challenging scenario, because the game itself is moving the mouse; S+ simply processes the mouse movement messages and responds no differently than if you were making those movements.

The screenshot overlay is taking focus away from the game (it's no longer the active window and doesn't move the mouse), which is why that works. S+ intentionally does not remove focus from the active application, to be a seamless experience in general.

The only thing I can think of is complicated and may or may not work - but essentially using the mouse event hook event to capture all mouse movement input when you press the stroke button down and consume the injected input. On release, deactivate the mouse event hook.

This will capture the mouse movements when you press down the Right button (set as your stroke button), and if the mouse movement is injected, but not injected by S+, it will consume (ignore) the event so it doesn't propagate.
When you release the Right button, the mouse move hook is disconnected.



Options > Advanced

Check the Enable Mouse Hook Event Subscription option


Global Actions > Mouse Events > Right Click
Code:
//If event already bound, disconnect
var mouseMoveEventObj = sp.GetStoredObject("mouseMoveEvent");
if(mouseMoveEventObj.GetType().FullName.includes('EventConnection'))
{
    mouseMoveEventObj.disconnect();
    sp.DeleteStoredObject("mouseMoveEvent");
} 

if(click.Down)
{
    //Create the synchronous event binding
    var mouseMoveEvent = MouseHook.OnMouseHookMoveEvent.connect(
        function (sender, mouseHookEvent) {
            //Wrap all code in try/catch, exceptions will crash S+
            try
            {
                //If the move event is injected (not physical mouse movement)
                //and it was not injected by S+, consume (ignore) the movement event
                if(mouseHookEvent.Injected && !mouseHookEvent.InjectedByHost)
                {
                    mouseHookEvent.Consume = true;
                }
            }
            catch {}
        });
    //Note that on S+ reload, events in Stored Object list have disconnect called on them
    sp.StoreObject("mouseMoveEvent", mouseMoveEvent);
}  

Global Actions > Mouse Events > Release
Code:
if(click.Button == MouseButtons.Right) {
    //If event already bound, disconnect
    var mouseMoveEventObj = sp.GetStoredObject("mouseMoveEvent");
    if(mouseMoveEventObj.GetType().FullName.includes('EventConnection'))
    {
        mouseMoveEventObj.disconnect();
        sp.DeleteStoredObject("mouseMoveEvent");
    } 
}
thanks 1 user thanked Rob for this useful post.
Ju87 on 12/10/2020(UTC)
Rob  
#5 Posted : Thursday, December 3, 2020 2:58:37 PM(UTC)
Rob

Rank: Administration

Reputation:

Groups: Translators, Members, Administrators
Joined: 1/11/2018(UTC)
Posts: 1,349
United States
Location: Tampa, FL

Thanks: 28 times
Was thanked: 416 time(s) in 354 post(s)
Things to consider!

If you were to try to remote control your PC, you would not be able to press the right button and move the mouse, since that would be injected input.

You could use the Global Actions > Window Events > Foreground Window Change script to selectively enable/disable this logic - for example if the foreground window is the game, the hook is allowed to function, otherwise it does not execute.
thanks 1 user thanked Rob for this useful post.
Ju87 on 12/10/2020(UTC)
Ju87  
#6 Posted : Tuesday, December 8, 2020 3:39:21 PM(UTC)
Ju87

Rank: Newbie

Reputation:

Groups: Approved
Joined: 12/1/2020(UTC)
Posts: 5

Thanks: 6 times
Did not help. The script works (I tested it using the remote control app), but it has no effect in problem games. The cursor is locked in the center, no any change is felt.

Quote:
So does this cursor locking happen for other mouse buttons? Like if you used the middle button as a stroke button, for example.


I usually use the X1 button. The cursor is locked. Now I tested your script with the right mouse button. Doesn't work either. I just tested the left and middle buttons as well - the cursor still locked. So I guess it's not about the buttons.
Rob  
#7 Posted : Tuesday, December 8, 2020 3:53:48 PM(UTC)
Rob

Rank: Administration

Reputation:

Groups: Translators, Members, Administrators
Joined: 1/11/2018(UTC)
Posts: 1,349
United States
Location: Tampa, FL

Thanks: 28 times
Was thanked: 416 time(s) in 354 post(s)
Just to make sure, you did enable this option, right?

Options > Advanced

Check the Enable Mouse Hook Event Subscription option
thanks 1 user thanked Rob for this useful post.
Ju87 on 12/10/2020(UTC)
Rob  
#8 Posted : Tuesday, December 8, 2020 4:00:01 PM(UTC)
Rob

Rank: Administration

Reputation:

Groups: Translators, Members, Administrators
Joined: 1/11/2018(UTC)
Posts: 1,349
United States
Location: Tampa, FL

Thanks: 28 times
Was thanked: 416 time(s) in 354 post(s)
Sorry, I missed this "I tested it using the remote control app"

Hmm, it's difficult to say how the game is taking control of the mouse and would require a much deeper look into the internals and monitoring of Windows messages (e.g. Spy++)
thanks 1 user thanked Rob for this useful post.
Ju87 on 12/10/2020(UTC)
Rob  
#9 Posted : Tuesday, December 8, 2020 4:02:26 PM(UTC)
Rob

Rank: Administration

Reputation:

Groups: Translators, Members, Administrators
Joined: 1/11/2018(UTC)
Posts: 1,349
United States
Location: Tampa, FL

Thanks: 28 times
Was thanked: 416 time(s) in 354 post(s)
If the game is installing a low-level mouse hook or using some device driver, there probably isn't anything you can do about it.
thanks 1 user thanked Rob for this useful post.
Ju87 on 12/10/2020(UTC)
Ju87  
#10 Posted : Wednesday, December 9, 2020 11:25:22 AM(UTC)
Ju87

Rank: Newbie

Reputation:

Groups: Approved
Joined: 12/1/2020(UTC)
Posts: 5

Thanks: 6 times
I got it. Well, thanks for trying to help.
Users browsing this topic
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.