MouseDelta - 2021/06/21 - beta.1

Post your working scripts, libraries and tools.
User avatar
TheArkive
Posts: 1027
Joined: 05 Aug 2016, 08:06
Location: The Construct
Contact:

MouseDelta - 2021/06/21 - beta.1

Post by TheArkive » 01 Jun 2021, 02:22

All credits go to @evilC and his original script here.

Highlights:
  • Create instance and assign a callback function to capture raw mouse input.
  • Methods:
    obj.Start()
    obj.Stop()
    obj.State(bool) - for toggling/setting a state
  • Track mouse delta movements.
  • Track mouse position globally (might not be useful for some games).
  • Track button states for up to 5 buttons
    LButton, RButton, MButton, XButton1, XButton2
  • Track WheelUp and WheelDown
evilC is more of an expert on gaming for this stuff, so I'm not sure if checking for button states gives a performance hit.

:arrow: Download on GibHub
vmech
Posts: 343
Joined: 25 Aug 2019, 13:03

Re: MouseDelta - 2021/06/21 - beta.1

Post by vmech » 11 Aug 2021, 03:10

I think you can put this into class variables initialisation part and that will be enough:

Code: Select all

Hwnd := (IsSet(oGui) && IsObject(oGui)) ? oGui.Hwnd : (this.localGui := Gui(), this.localGui.Hwnd)
In my program this works fine :thumbup:
Please place your script code into [code][/code] block. Thank you.
User avatar
TheArkive
Posts: 1027
Joined: 05 Aug 2016, 08:06
Location: The Construct
Contact:

Re: MouseDelta - 2021/06/21 - beta.1

Post by TheArkive » 11 Aug 2021, 06:03

I like it @vmech. Thanks :) changing/pushing now.
vmech
Posts: 343
Joined: 25 Aug 2019, 13:03

Re: MouseDelta - 2021/06/21 - beta.1

Post by vmech » 22 Aug 2021, 04:58

In this and original inplementation from EvilC critical state of message processing procedure is inherited by callback procedure, and by all procedures called from callback himself.

I looked at several implementations of RawInput processing on C++ and everywhere the critical section is closed immediately after getting required data from RawInputData. I suppose it will not be superfluous to apply the same approach in these implementations to avoid unnecessary critical inheritance.
Last edited by vmech on 22 Aug 2021, 16:51, edited 2 times in total.
Please place your script code into [code][/code] block. Thank you.
User avatar
TheArkive
Posts: 1027
Joined: 05 Aug 2016, 08:06
Location: The Construct
Contact:

Re: MouseDelta - 2021/06/21 - beta.1

Post by TheArkive » 22 Aug 2021, 05:02

Are you thinking to add Critical false right above this.callback(hwID, obj)?
vmech
Posts: 343
Joined: 25 Aug 2019, 13:03

Re: MouseDelta - 2021/06/21 - beta.1

Post by vmech » 22 Aug 2021, 05:04

TheArkive wrote:
22 Aug 2021, 05:02
Are you thinking to add Critical false right above this.callback(hwID, obj)?
Yep.
Please place your script code into [code][/code] block. Thank you.
User avatar
TheArkive
Posts: 1027
Joined: 05 Aug 2016, 08:06
Location: The Construct
Contact:

Re: MouseDelta - 2021/06/21 - beta.1

Post by TheArkive » 22 Aug 2021, 05:04

Makes sense to me, changing pushing now.
vmech
Posts: 343
Joined: 25 Aug 2019, 13:03

Re: MouseDelta - 2021/06/21 - beta.1

Post by vmech » 19 Sep 2021, 00:55

There is no need to do any kind of GUI manipulations, there is an even simpler option - A_ScriptHwnd :)
Please place your script code into [code][/code] block. Thank you.
User avatar
TheArkive
Posts: 1027
Joined: 05 Aug 2016, 08:06
Location: The Construct
Contact:

Re: MouseDelta - 2021/06/21 - beta.1

Post by TheArkive » 19 Sep 2021, 03:34

Thanks again @vmech :D Done.
Post Reply

Return to “Scripts and Functions (v2)”