Author Topic: differences between LINUX and WINDOZE mouse routines?  (Read 4533 times)

0 Members and 1 Guest are viewing this topic.

Offline Colonel_Panic

  • Newbie
  • Posts: 54
    • View Profile
differences between LINUX and WINDOZE mouse routines?
« on: November 06, 2021, 08:48:41 pm »
phase 1 --- I begin to make retro games in QB64-WINdoze...
                  mouse *fine* in windoze.
                 
phase 2 --- compile SAME code to LINUX?
                  mouse is... drunk?

phase 3 --- decide to make retro games next in LINUX
                 mouse fine in LINUX

phase 4 --- compile to WINDOWS?
                  mouse is "sloppy drunk".

========================

now, I *am* a programmer; I have *some* logic to me, at least a little...
best I can explain? its as if, one is working on mouse UP, and the other on mouse DOWN...
and i have to PICK.

what am i missing, what am i describing?

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: differences between LINUX and WINDOZE mouse routines?
« Reply #1 on: November 06, 2021, 08:53:56 pm »

what am i missing, what am i describing?

A bad program?  Two computers with different settings?  Who knows!

Code, or it didn't happen.  😘   

We can't even attempt to diagnose problems without some sort of code to work off from.
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline Colonel_Panic

  • Newbie
  • Posts: 54
    • View Profile
Re: differences between LINUX and WINDOZE mouse routines?
« Reply #2 on: November 06, 2021, 09:20:10 pm »
okay... let me see...
Code: QB64: [Select]
  1. Sub PollMouseClicks ()
  2.   found_lc = 0
  3.   MS$ = ""
  4.       If _MouseButton(1) And _MouseButton(2) Then LR$ = "LR": GoTo around:
  5.       If _MouseButton(1) Then LR$ = "L"
  6.       If _MouseButton(2) Then LR$ = "R"
  7.       around:
  8.       For t = 1 To clix_cnt
  9.         If _MouseX >= clix!(t, 1) And _MouseX <= clix!(t, 3) Then
  10.           If _MouseY >= clix!(t, 2) And _MouseY <= clix!(t, 4) Then
  11.             Mx = _MouseX: My = _MouseY
  12.             found_lc = t 'we trapped our click, but first...
  13.             'if item *or parent* is not .visible, clix! needs to ignore
  14.             'note default is .visible ON, if the def'n file doesn't specify
  15.             nothing$ = GetMakeProperty$(proj$ + "." + clix_name$(t) + ".visible", "1")
  16.             nothing2$ = GetMakeProperty$(proj$ + "." + ExtractParent$(clix_name$(t)) + ".visible", "1")
  17.             If Val(nothing$) = 0 Or Val(nothing2$) = 0 Then found_lc = 0: GoTo cl_mouse:
  18.             'both control & parent must be .visible
  19.             'TXT$ = String$(64, " "): _PrintString (10, 10), TXT$
  20.             'TXT$ = "you clicked on: " + clix_name$(t)
  21.             '_PrintString (10, 10), TXT$
  22.             'clear the mouse
  23.             cl_mouse:
  24.             If _MouseInput Then GoTo cl_mouse: Else GoTo done_mouse:
  25.           End If
  26.         End If
  27.       Next t
  28.     End If
  29.   End If
  30.   done_mouse:
  31.   If ide_sw = 1 Then
  32.     If found_lc > 0 And LR$ = "L" Then AdjustProperties (clix_name$(t))
  33.     If found_lc > 0 And LR$ = "R" Then MoveObject (clix_name$(t))
  34.   End If
  35.  

if i did this right, the above "code" is the "mouse click trapping" routine for... my project.
fast and accurate in Linux Mint... compile the same exact program in Windows?
drunken mouse clicking, is the best way i can describe it.

I cant post the whole program that calls it... its 1,983 lines of QB64 code.
but... here's the "main program flow" that ends up calling it...
Code: QB64: [Select]
  1. _Title "CodeName:Takky 0.0.7 - preBETA"
  2.  
  3.  
  4. ide_sw = 0
  5.  
  6. proj$ = "demo"
  7.  
  8. OpenProject: _Font fhand&: SplashDemo
  9. PaintAllForms
  10. again1:
  11. If ide_sw = 1 Then
  12.   _PrintString (110, 10), "F1=SAVE; F2=MakeForm; F3=MakeObj; F4=KillForm; F5=KillObj"
  13.   _PrintString (110, 25), "L-Click=.props; R-Click=MoveObj"
  14. PollMouseClicks
  15. If ide_sw = 0 Then
  16.   If found_lc > 0 Then
  17.     Shell _DontWait "pacat --fix-format --fix-rate start.wav"
  18.     PerformMouseClicks
  19.   End If
  20.  
  21. 'BEGIN - KEY CALLS
  22. 'These are the ESC and F1-F5 calls. UNcomment for IDE, comment out for run time
  23. 'TIP: ESC is a handy "end" key,
  24. 'and F1-save + others can be handy at run time while                                                                                                                                                                                                                                                                                                                                                           working
  25. 'If _KeyDown(15104) Then UpdateDefn 'F1
  26. 'If _KeyDown(15360) Then MakeForm 'F2
  27. 'If _KeyDown(15616) Then MakeControl 'F3
  28. 'If _KeyDown(15872) Then KillForm 'F4
  29. 'If _KeyDown(16128) Then KillObject 'F5
  30. If _KeyDown(27) Then End 'OutputProjectBones 'ESC
  31. 'END - KEY CALLS
  32.  
  33. GoTo again1:

thats basically "the whole program"... the rest of the 1983 lines of code? is basically all the "support routines"

Offline Colonel_Panic

  • Newbie
  • Posts: 54
    • View Profile
Re: differences between LINUX and WINDOZE mouse routines?
« Reply #3 on: November 06, 2021, 09:53:47 pm »
in this particular case? the LINUX compiled 'demo.bas' runs perfect.
then the WIN compiled 'demo.bas', not one byte changed, compiles fine. slow but fine.
it executes on WIN fine, except for
"drunken mouse clicking"... other than that, everything is 100% accurate and technically runs fine.

in this case? the windows "drunken stupor" manifests itself with what I feel like are 'extra mouse clicks" after
the "real" mouse click has been picked up and acted upon. A couple extra clicks tend to get through.
the same "pixel" click, just one or two extra after the fact.

as I am not an expert in the matter, but it is a consistent ongoing issue (for me anyways) it would SEEM
to be as if the "clear the mouse" routine were not working under WIN, but running fine in LINUX.

PS - I deployed to MANJARO? and no extra clicks.

Offline Colonel_Panic

  • Newbie
  • Posts: 54
    • View Profile
Re: differences between LINUX and WINDOZE mouse routines?
« Reply #4 on: November 06, 2021, 09:59:07 pm »
@McNeill:
A bad program? (or a loose nut on the keyboard, lol) 

Two computers with different settings? (MINT is native install, WIN's are all VM land, but. so is MANJARO which was good)
seems to rule out VM as culprit?

  Who knows!
I figured someone else might have run across a same/similar mouse issue.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: differences between LINUX and WINDOZE mouse routines?
« Reply #5 on: November 06, 2021, 10:53:27 pm »
Code: QB64: [Select]
  1. Sub PollMouseClicks ()
  2.   found_lc = 0
  3.   MS$ = ""
  4.       If _MouseButton(1) And _MouseButton(2) Then LR$ = "LR": GoTo around:
  5.       If _MouseButton(1) Then LR$ = "L"
  6.       If _MouseButton(2) Then LR$ = "R"
  7.  

Unless you need mousewheel, poll mouse like this:
Code: QB64: [Select]
  1. While _MouseInput: Wend  ' update Mouse status
This will update your mouse x, y position and buttons. You don't need to get inside that loop unless you need mouse wheel updates.

Every noobie (including me) gets this wrong! because they think they should be getting mouse info from inside that loop.


Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: differences between LINUX and WINDOZE mouse routines?
« Reply #6 on: November 07, 2021, 01:05:50 am »
I'd suggest reading over the topic here for understanding: https://www.qb64.org/forum/index.php?topic=4312.0

The issue you're having is from reading more mouse events than your program is processing each loop.  As each OS is different on how often they poll the mouse drivers, that explains why you're getting different results on different systems.

My advice:

Instead of IF _MOUSEINPUT, go with a routine to clear that buffer at start:

WHILE _MOUSEINPUT: WEND
LB = _MOUSEBUTTON(1): RB = _MOUSEBUTTON(2)
IF LB AND RB THEN
    LR$ = "LR"
ELSEIF LB THEN
    LR$ = "L"
ELSEIF RB THEN
   LR$ = "R"
END IF

https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline Colonel_Panic

  • Newbie
  • Posts: 54
    • View Profile
Re: differences between LINUX and WINDOZE mouse routines?
« Reply #7 on: November 07, 2021, 02:22:14 pm »
awesome!

thanks mcneil, and everyone else who chimed in...
I just figured I wasn't alone. great.

FINAL ANALYSIS:
 loose nut on my keyboard.
 tightened up.
 
Yeah, I really dont know what goes on in the Mouse routines
I... "fiddle" with mouse code... it gets working... and i try not to TOUCH IT when its working.

I *suppose* its about time, I took a break and "played" with the mouse for something SMALL,
until I can get past "first base" with the MOUSE.

see how many OS's I can satisfy at once, for a tiny non-game.

Offline Colonel_Panic

  • Newbie
  • Posts: 54
    • View Profile
Re: differences between LINUX and WINDOZE mouse routines?
« Reply #8 on: November 07, 2021, 03:59:18 pm »
McNeill-----> kudos
Bplus-------> kudos

hopefully, I can help back or help forward over time.

its funny to me, when I was a "cool programmer" way back when?
honestly, someone else always did...

1) mouse
2) high end screen stuff
3) everyone's fun game "where the &^%$ is my FILE !!!" ("MAPped" network drive(s) ??)

I basically "unplugged" those 2 sections of code (mouse/screen), and "worked" with a very basic text list.
I sort of "plugged back in" the mouse and screen, so to speak, when i was done "working" for the day.

I am "circling around" and picking up graphics and mouse and stuff to go with "everything" I want to do now.