Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 09:16 01 Aug 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : Need Help with using Mouse in a Program

Author Message
William Leue
Guru

Joined: 03/07/2020
Location: United States
Posts: 405
Posted: 03:54pm 15 Jul 2021
Copy link to clipboard 
Print this post

I have a new Gen 2 CMM2 loaded with 5.07.xx firmware. I am trying to use a mouse inside a BASIC program.

The mouse works fine in the file manager and editor.

In my code, I do

CONTROLLER MOUSE OPEN 2, LButton
GUI CURSOR ON
GUI CURSOR SHOW

This displays the standard 'arrow' mouse cursor at 0, 0 but the cursor does not move when the mouse is moved. The left click interrupt routine does work, however.

I must be missing something stupid that is needed to link up the cursor with the mouse, but I can't find anything in the 5.07 docs.

Any clues?
-BIll
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10310
Posted: 04:11pm 15 Jul 2021
Copy link to clipboard 
Print this post

CONTROLLER MOUSE OPEN 2, lbutton
GUI CURSOR ON
GUI CURSOR SHOW
settick 16,mousemove
do:loop
sub mousemove
 gui cursor mouse(X,2),mouse(Y,2)
end sub
sub lbutton
' whatever
end sub

Edited 2021-07-16 02:11 by matherp
 
William Leue
Guru

Joined: 03/07/2020
Location: United States
Posts: 405
Posted: 04:33pm 15 Jul 2021
Copy link to clipboard 
Print this post

Thanks, Peter! I was hoping that the firmware support for the mouse meant that we didn't have to poll for the mouse position to maintain the cursor position, but this will be fine.

-Bill
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10310
Posted: 04:39pm 15 Jul 2021
Copy link to clipboard 
Print this post

  Quote   I was hoping that the firmware support for the mouse meant that we didn't have to poll for the mouse position


Not something anyone has asked for before but a possibility for a future release

Something like GUI CURSOR LINK MOUSE [rate]
Edited 2021-07-16 02:40 by matherp
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 7937
Posted: 05:03pm 15 Jul 2021
Copy link to clipboard 
Print this post

Just an idea...

Is there any need *not* to always link the pointer cursor with the mouse?

All you probably need for simple mouse handling is an interrupt that happens on a button press and some returned functions. Just pseudo code - this won't run:


mouse_present = MOUSE(TEST)

If mouse_present then MOUSE ON, <mouse_interrupt_routine>
'   (we need to do this as there may not be a mouse present. Turns on cursor.)

do
 whatever it is that programs do
 Select Case b
 Case 1
   left button action : b=0
 Case 2
   middle button action : b=0
 Case 3
   right button action : b=0
 End Select
loop until fed up

MOUSE OFF
'  (turns off mouse interrupt and cursor)

do something else entirely

MOUSE ON, <mouse_interrupt_routine>  - (no real need to test if mouse present now)

... and carry on

End

Sub <mouse_interrupt_routine>
 x = MOUSE(X)
 y = MOUSE(Y)
 b = MOUSE(BUTTON) - (returns 1,2 or 3. scroll is ignored)
End Sub

Edited 2021-07-16 03:10 by Mixtel90
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
William Leue
Guru

Joined: 03/07/2020
Location: United States
Posts: 405
Posted: 05:05pm 15 Jul 2021
Copy link to clipboard 
Print this post

Ya, I like CURSOR LINK MOUSE!
-Bill
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10310
Posted: 05:49pm 15 Jul 2021
Copy link to clipboard 
Print this post

  Quote  Is there any need *not* to always link the pointer cursor with the mouse?


How many would you like

In games the mouse may be used for all sorts of things that don't involve a directly coupled cursor
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 7937
Posted: 06:05pm 15 Jul 2021
Copy link to clipboard 
Print this post

Lol - Ok. :)

Oh dear - I'll just have to introduce a GUI CURSOR MOUSE RELEASE command then. ;)
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
vegipete

Guru

Joined: 29/01/2013
Location: Canada
Posts: 1132
Posted: 06:53pm 15 Jul 2021
Copy link to clipboard 
Print this post

I continue to hope for an interrupt when mouse buttons (or just the left one) are released.
CONTROLLER MOUSE OPEN [n] [,LBinterrupt [,RBinterrupt [,LBUPinterrupt]]]

Visit Vegipete's *Mite Library for cool programs.
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6283
Posted: 10:01pm 15 Jul 2021
Copy link to clipboard 
Print this post

  Mixtel90 said  
Is there any need *not* to always link the pointer cursor with the mouse?


  Quote        mx = MOUSE(x,mouse_port)
     my =
MOUSE(y,mouse_port)
     my =
INT(my/cHt)*cHt+cHt   ' limit movement to text line steps
     GUI CURSOR mx, my
     
IF mx<>oldmx AND my<>oldmy THEN ' we have moved the mouse
       oldmx = mx


This moves the mouse in vertical steps rather than continuous. It gives a better feel to the mouse control.
I have other times when I want to keep the cursor on the one height and only move left to right.
Other times it is convenient to snap to the centre of an object
etc...

Jim
VK7JH
MMedit
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 7937
Posted: 10:03pm 15 Jul 2021
Copy link to clipboard 
Print this post

Oh well...  It was just an idea. :)
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6283
Posted: 10:16pm 15 Jul 2021
Copy link to clipboard 
Print this post

  Mixtel90 said  Oh well...  It was just an idea. :)

And provided it's optional, no problems.

Jim
VK7JH
MMedit
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 7937
Posted: 06:19am 16 Jul 2021
Copy link to clipboard 
Print this post

Perhaps I shouldn't be re-thinking things at this stage, Jim. The existing system seems to work and "if it's not broke...". :)

Of course... MOUSE ON <mouse_interrupt_routine>, <cursor_state>
fixes that one! <cursor_state> is 1 for displayed, 0 for not displayed.

( Stop it Mick... Leave it alone... ;) )
Edited 2021-07-16 16:24 by Mixtel90
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025