Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 02:13 24 Jul 2026 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 : Getting the mouse to work in the GUI

Author Message
Bryan1

Guru

Joined: 22/02/2006
Location: Australia
Posts: 2164
Posted: 04:48am 23 Jul 2026
Copy link to clipboard 
Print this post

Well guy's I am trying to get the mouse working in my first start on the pico 3 using MMBasic while I wait for the psram and wifi chips to arrive.

With the new GUI for HDMI just getting a mouse going is my first step and this is my code so far

OPTION EXPLICIT
OPTION DEFAULT NONE
option console serial
gui cursor on
colour rgb(grey), rgb(white)

cls

const topcaption= 1, btmcaption = 2, Memcar = 3, Memlog = 4, Memfin = 5
const topF = 6, list1 = 7
'fill = rgb(white)
gui frame #1, "", 4, 4, 636, 30,   rgb(grey)
gui frame #2, "", 4, 450, 636, 30, rgb(grey)

'gui frame #topF, "", 4, 4, 636, 30, rgb(red)
dim k$
dim club$(4) length 16
club$(0) = "Member Number" : club$(1) = "Member Name" :club$(2) = "Car"
club$(3) = "Logbook Number" : club$(4) = "Status"

gui listbox #list1, club$(), 5, 5, 200, 30,  rgb(white), rgb(red)
do
 
k$ = Inkey$
If k$ <> "" Then
' Default step 4 px; if the key arrived shifted, MMBasic delivers
' a different code. Keep it simple: hold Shift-equivalent on PS/2
' by using upper-case letters of D/U as "fast".
stepx = 4
Select Case Asc(k$)
Case &H82 ' LEFT
mx = mx - Stepx
Case &H83 ' RIGHT
mx = mx + Stepx
Case &H80 ' UP
my = my - Stepx
Case &H81 ' DOWN
my = my + Stepx
Case 32 ' SPACE -> momentary click
GUI Click mx, my
Case 100, 68 ' 'd' or 'D' -> press-and-hold
If held = 0 Then
GUI Cursor mx, my
GUI Click Down
held = 1
EndIf
Case 117, 85 ' 'u' or 'U' -> release
If held = 1 Then
GUI Click Up
held = 0
EndIf
Case 27, 113, 81 ' ESC / 'q' / 'Q' -> quit
Exit Do
End Select
' Clamp to screen.
If mx < 0 Then mx = 0
If my < 0 Then my = 0
If mx > cw - 1 Then mx = cw - 1
If my > ch - 1 Then my = ch - 1
GUI Cursor mx, my
endif


 pause 1000
 loop

sub touchdown
 local integer tx, ty
 tx = touch(x) : ty = touch(y)
 if not (tx = -1 or ty = -1) then
   gui cursor tx, ty
 ' mx = tx : my = ty
   endif



Now looking on search I did see the mouse option and I put the mouse dongle in the usb hub which works in edit but sadly not in my code.

> option mouse sensitivity  1.0000
> Mouse Type: Gaming 16-bit
 X/Y bits: 16/16
 Buttons: 5
 Report length: 7 bytes
 Has wheel: Yes (byte 5)
 Has pan: No
USB Mouse Connected on channel 2
> US USB Keyboard Connected on channel 1


> option list
PicoMiteHDMI MMBasic USB RP2350B Edition V6.03.00
OPTION SERIAL CONSOLE COM2,GP8,GP9
OPTION SYSTEM I2C GP20,GP21
OPTION FLASH SIZE 16777216
OPTION COLOURCODE ON
OPTION MOUSE SENSITIVITY     1.0000
OPTION KEYBOARD US
OPTION PICO OFF
OPTION RESOLUTION 640x480 @ 315000KHz
OPTION HDMI PINS  1, 3, 5, 7
OPTION GUI CONTROLS 75
OPTION SDCARD GP33, GP30, GP31, GP28
OPTION AUDIO I2S GP10,GP22', ON PWM CHANNEL 11
OPTION RTC AUTO ENABLE
OPTION COUNT GP34,GP35,GP36,GP37
OPTION MODBUFF ENABLE  512
OPTION PLATFORM PICO COMPUTER 3
OPTION HEARTBEAT PIN GP25
 
mozzie
Guru

Joined: 15/06/2020
Location: Australia
Posts: 406
Posted: 06:46am 23 Jul 2026
Copy link to clipboard 
Print this post

G'day Bryan,
I think the command you are looking for is:
GUI CURSOR LINK MOUSE

That should get it working with a bit of luck  

The PCB's arrived Monday, now I just need to find time to tinker with them.
Thanks again.

Regards, Lyle.
 
Bryan1

Guru

Joined: 22/02/2006
Location: Australia
Posts: 2164
Posted: 07:05am 23 Jul 2026
Copy link to clipboard 
Print this post

Nope that didn't work now I used the code from the Advanced Graphic's Manual which I got off Peter's github site and it is dated to 2015 where the GUI Cursor on is used.

Now using that code an arrow is displayed at the centre of the screen which is static so I did try using the arrow keys only to find

[64] GUI Cursor mx, my
Error : -1 is invalid (valid is 0 to 639)


So copying code from the manual has got me again

Also I'm going to get back my pico 2 as trying to play a mp.3 on this pico 3 in both micropython and MMBasic won't work where when I tried morning in MMBasic get a heap memory error when I tried a MP.3 where with the pico 2 it just worked.
Edited 2026-07-23 17:09 by Bryan1
 
JohnS
Guru

Joined: 18/11/2011
Location: United Kingdom
Posts: 4354
Posted: 07:23am 23 Jul 2026
Copy link to clipboard 
Print this post

Are you by accident looking at CMM2 manual  or the like instead of PicoMite manual?

John
 
phil99

Guru

Joined: 11/02/2018
Location: Australia
Posts: 3323
Posted: 08:23am 23 Jul 2026
Copy link to clipboard 
Print this post

  Quote  Peter's github site and it is dated to 2015
That is well before the PicoMite.
Latest PicoMite V6.03.00 firmware package on Geoff's site has Advanced Graphics Functions.pdf in the Extra Documentation folder.
  Quote  CLICK(DOWN) Will return true if the screen is currently being clicked on using the mouse.
CLICK(UP) Will return true if the screen is currently NOT being clicked on.
CLICK(LASTX) Will return the X coordinate of the last location that was clicked on.
CLICK(LASTY) Will return the Y coordinate of the last location that was clicked on.
CLICK(REF) Will return the reference number of the control that is currently being clicked on or zero if no control is currently being clicked on.
CLICK(LASTREF) Will return the reference number of the last control that was clicked on.

And there is the Keyboard/Mouse/Gamepad chapter in the main manual.
Edited 2026-07-23 18:33 by phil99
 
mozzie
Guru

Joined: 15/06/2020
Location: Australia
Posts: 406
Posted: 08:33am 23 Jul 2026
Copy link to clipboard 
Print this post

Hi Bryan,
You may just be over-thinking it, the GUI system looks after most of the mouse stuff.

Just tried this and it works on the Pico Computer 3 received Monday.

RESET Pico first to clear previous stuff in memory then at prompt:

GUI CURSOR LINK MOUSE
GUI CURSOR ON


And now the cursor is moving around the screen with the mouse  

Regards, Lyle.
 
Bryan1

Guru

Joined: 22/02/2006
Location: Australia
Posts: 2164
Posted: 08:50am 23 Jul 2026
Copy link to clipboard 
Print this post

First with that Advanced Graphics Manual I downloaded it off the github to get the newest version.

I went and grabbed my pico 2 so I can try both tomorrow.

Thanks for that tip Lyle   and it's the first thing I'll do in the morning now mate could you try playing a mp.3 to see if you get that heap error,

Regards Bryan
 
mozzie
Guru

Joined: 15/06/2020
Location: Australia
Posts: 406
Posted: 04:11pm 23 Jul 2026
Copy link to clipboard 
Print this post

Hi Bryan,
Tried playing 196kbps MP3 from FM and command prompt and both working fine, not sure why you are having trouble, our option list is almost the same.

I normally disable the MODBUFF as I have the game playing skill of a Sloth crossed with a Hippo but testing with it enabled makes no difference.

Perhaps try a flash-nuke / reflash and see if it makes a difference.

Also MP3 playback uses 81kb of memory and GUI controls use a bit as well, maybe PSRAM will help?

Regards, Lyle.
 
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 2026