Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 18:20 23 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: 2163
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: 404
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: 2163
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
 
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