GLBasic forum

Main forum => Bug Reports => Topic started by: adaz on 2018-Feb-08

Title: MOUSESTATE and GETMOUSECOUNT work oddly on Win8,Win10
Post by: adaz on 2018-Feb-08
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

Title: Re: MOUSESTATE and GETMOUSECOUNT work oddly on Win8,Win10
Post by: adaz on 2018-Feb-08
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.
Title: Re: MOUSESTATE and GETMOUSECOUNT work oddly on Win8,Win10
Post by: dreamerman on 2018-Feb-08
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 (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
 
Title: Re: MOUSESTATE and GETMOUSECOUNT work oddly on Win8,Win10
Post by: spacefractal on 2018-Feb-09
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.
Title: Re: MOUSESTATE and GETMOUSECOUNT work oddly on Win8,Win10
Post by: adaz on 2018-Feb-10
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.
Title: Re: MOUSESTATE and GETMOUSECOUNT work oddly on Win8,Win10
Post by: spacefractal on 2018-Feb-19
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.
Title: Re: MOUSESTATE and GETMOUSECOUNT work oddly on Win8,Win10
Post by: 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

Title: Re: MOUSESTATE and GETMOUSECOUNT work oddly on Win8,Win10
Post by: adaz 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
Title: Re: MOUSESTATE and GETMOUSECOUNT work oddly on Win8,Win10
Post by: MrPlow on 2018-Mar-14
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

 

Title: Re: MOUSESTATE and GETMOUSECOUNT work oddly on Win8,Win10
Post by: spacefractal on 2018-Mar-14
I'm my self only checks max to touches. I'm did not require more than that. Rest is just skipped.