MOUSESTATE and GETMOUSECOUNT work oddly on Win8,Win10

Previous topic - Next topic

adaz

Hi,


GETMOUSECOUNT  returns 32 on Win8 and Win10. When I run my exe with Win7 compatibility mode, it returns 1.
It slows down my program a lot when I check if all mouse buttons are released.

In some circumstances MOUSESTATE returns that mouse button 2 is always TRUE. It happens in a very big code, but in a small FUNCTION:

Code (glbasic) Select

FUNCTION No_Click:
LOCAL mx,my,mb1,mb2
FOR i=0 TO GETMOUSECOUNT()-1
SETACTIVEMOUSE i
REPEAT
MOUSESTATE mx,my,mb1,mb2
UNTIL mb1=FALSE AND mb2=FALSE
NEXT
SETACTIVEMOUSE 0
ENDFUNCTION


The REPEAT loop never ends.

Are these bugs, or deliberate changes in OS?

GLBasic Precompiler V.14.721
GLBasic IDE, Version: 15.089

Thank you,
Adaz


adaz

More information:
My app does not work even on Android, the command returns false positive reply on that platform as well.
Strange, but if I start the IDE with Win7 compatibility mode, the compiled executables work on both platform. But this is obviously not a resolution.

dreamerman

Hey, some time ago I posted topic about similar (or same) issue with mouse functions, take a look: https://www.glbasic.com/forum/index.php?topic=10855
Generally I had problems on Win8.1 but Android was working ok. For workaround as my apps didn't require multi-mouse input on pc I just forced them to use standard single mouse input only.
Wasn't sure but now as you confirmed it, that really looks like a bug.
btw. your function isn't perfect, better to use something like this:
Code (glbasic) Select

FUNCTION No_Click:
        LOCAL i%,mx%,my%,mb1%,mb2%,mc% = GETMOUSECOUNT() - 1, clicks%
        REPEAT
                clicks% = 0
FOR i=0 TO mc
                        SETACTIVEMOUSE i
                        MOUSESTATE mx,my,mb1,mb2
IF (mb1 or mb2) THEN INC clicks%
NEXT
        UNTIL clicks% = 0
        SETACTIVEMOUSE 0
ENDFUNCTION
Check my source code editor for GLBasic - link Update: 20.04.2020

spacefractal

GETMOUSECOUNT can report much more than its is in system. so to opmize the code, only perform that number of touches your game required and then break out of the loop.
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/

adaz

That's OK, but under Windows 10 the MOUSESTATE of the buttons are still wrong sometimes. There IS a bug, so these commands has to be tested on Windows 10 a lot more times.

spacefractal

im have not have the issue here. just dont use more number of mouse you can use. on Windows, most player use keyboard and joypad, if its that such a game.
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/

MrPlow

I usually add a BREAK out of the FOR loop if the count (i) goes above the number of touches I want.

IF i>4 then BREAK

Comp:
Speccy-48k, Speccy-128k, Amigas, PCs

adaz

Quote from: MrPlow on 2018-Mar-14
I usually add a BREAK out of the FOR loop if the count (i) goes above the number of touches I want.

IF i>4 then BREAK

Then why don't use user FOR i=0 to 4? :-D

MrPlow

Its in case the there is no Mousecount to analyse...

It only BREAKs within a valid mousecount count.

I was not sure if 'SETMOUSECOUNT i' would fail or raise error if there were no mouse touches.

I have also used ...

Code (glbasic) Select


mcount% = GETMOUSECOUNT()-1

if mcount>4 then mcount = 4

FOR i = 0 TO mcount
...
NEXT



Comp:
Speccy-48k, Speccy-128k, Amigas, PCs

spacefractal

I'm my self only checks max to touches. I'm did not require more than that. Rest is just skipped.
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/