BASIC

Author Topic: MOUSESTATE and GETMOUSECOUNT work oddly on Win8,Win10  (Read 1291 times)

Offline adaz

  • Mc. Print
  • *
  • Posts: 48
    • View Profile
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

« Last Edit: 2018-Feb-08 by adaz »

Offline adaz

  • Mc. Print
  • *
  • Posts: 48
    • View Profile
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.

Offline dreamerman

  • Mr. Polyvector
  • ***
  • Posts: 198
    • View Profile
    • my personal website
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

Offline spacefractal

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 3473
    • View Profile
    • Space Fractal
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.
Greedy Mouse - Karma Miwa - Spot Race - CatchOut - Android Extras - is on a vacation trip, home before end of few days in jan.

Offline adaz

  • Mc. Print
  • *
  • Posts: 48
    • View Profile
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.

Offline spacefractal

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 3473
    • View Profile
    • Space Fractal
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.
Greedy Mouse - Karma Miwa - Spot Race - CatchOut - Android Extras - is on a vacation trip, home before end of few days in jan.

Offline MrPlow

  • Prof. Inline
  • *****
  • Posts: 1314
    • View Profile
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

Offline adaz

  • Mc. Print
  • *
  • Posts: 48
    • View Profile
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

Offline MrPlow

  • Prof. Inline
  • *****
  • Posts: 1314
    • View Profile
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

 

« Last Edit: 2018-Mar-14 by MrPlow »
Comp:
Speccy-48k, Speccy-128k, Amigas, PCs

Offline spacefractal

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 3473
    • View Profile
    • Space Fractal
I'm my self only checks max to touches. I'm did not require more than that. Rest is just skipped.
Greedy Mouse - Karma Miwa - Spot Race - CatchOut - Android Extras - is on a vacation trip, home before end of few days in jan.