![]() |
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 StatesPosts: 405 |
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 KingdomPosts: 10310 |
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 StatesPosts: 405 |
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 KingdomPosts: 10310 |
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 KingdomPosts: 7937 |
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 StatesPosts: 405 |
Ya, I like CURSOR LINK MOUSE! -Bill |
||||
matherp Guru ![]() Joined: 11/12/2012 Location: United KingdomPosts: 10310 |
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 KingdomPosts: 7937 |
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: CanadaPosts: 1132 |
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: AustraliaPosts: 6283 |
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 KingdomPosts: 7937 |
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: AustraliaPosts: 6283 |
And provided it's optional, no problems. Jim VK7JH MMedit |
||||
Mixtel90![]() Guru ![]() Joined: 05/10/2019 Location: United KingdomPosts: 7937 |
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 |
||||
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |