![]() |
Forum Index : Microcontroller and PC projects : Possible Bug in CONTROLLER MOUSE OPEN?
Author | Message | ||||
William Leue Guru ![]() Joined: 03/07/2020 Location: United StatesPosts: 405 |
I ran across this problem today when checking for the existence of a mouse on some I2C port: sub CheckMouse local i, hasMouse hasMouse = 0 for i = 1 to 3 on error skip 1 controller mouse open, LeftClick if MM.ERRNO = 0 then hasMouse = 1 exit for next i if hasMouse then gui cursor on 1 end if end sub sub LeftClick 'blah blah end sub I was surprised to find hasMouse being set to 1, even though there is no mouse and in fact no HobbyTronics interface. I wonder if the absence of the interface is confusing the mouse test, and that I indeed had the HobbyTronics interface but no mouse plugged in, then it would work? Using version 5.6.00 firmware on a 'vanilla' CMM2. (BTW this code works perfectly on my CMM2 Deluxe, which does have the HobbyTronics interface.) -Bill |
||||
matherp Guru ![]() Joined: 11/12/2012 Location: United KingdomPosts: 10310 |
Check the mouse open syntax |
||||
William Leue Guru ![]() Joined: 03/07/2020 Location: United StatesPosts: 405 |
Oops! Actually my test is correct, I just left out the channel when I copied the code over to the forum. Should have said: sub CheckMouse local i, hasMouse hasMouse = 0 for i = 1 to 3 on error skip 1 controller mouse open i, LeftClick if MM.ERRNO = 0 then hasMouse = 1 exit for next i if hasMouse then gui cursor on 1 end if end sub sub LeftClick 'blah blah end sub -Bill |
||||
TassyJim![]() Guru ![]() Joined: 07/08/2011 Location: AustraliaPosts: 6283 |
You are missing an ENDIF This works (On 5.7Beta) CheckMouse sub CheckMouse local i, hasMouse hasMouse = 0 for i = 1 to 3 on error skip 1 controller mouse open i, LeftClick if MM.ERRNO = 0 then hasMouse = 1 exit for endif ' this was missing next i if hasMouse then gui cursor on 1 print i end if end sub sub LeftClick 'blah blah end sub Jim VK7JH MMedit |
||||
vegipete![]() Guru ![]() Joined: 29/01/2013 Location: CanadaPosts: 1132 |
Because of start-up timing and interrupts and stuff, I would recommend NOT setting an interrupt while searching for a mouse. Instead, use "CONTROLLER MOUSE OPEN i" to find a possible mouse. If one is found, close it again, set up everything else, such as GUI CURSOR ON, and then finally re-open the mouse channel with the desired interrupt routine specified. Edited 2021-02-04 17:22 by vegipete Visit Vegipete's *Mite Library for cool programs. |
||||
William Leue Guru ![]() Joined: 03/07/2020 Location: United StatesPosts: 405 |
Good idea, thanks! -Bill |
||||
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |