I've just ordered a small PiTFT touchscreen HAT for my headless RPi to do simple tasks such as connecting the RPi to a new network or start a specific program etc. To save resources I want to avoid using X Server and instead create a simple text-based GUI program using something like ncurses or newt. However, I don't want to have to attach a keyboard to control the program when I have a touchscreen available (which I assume just acts as a mouse).
Is it possible for the RPi console to capture the mouse input (and subsequently use that input in a program like ncurses or newt)?
I have also seen you can use PyGame to write directly to the Framebuffer. Is it still possible to capture the mouse events in PyGame if writing directly to the Framebuffer?
I'm not sure if I need an X Server to do anything mouse related....
Anyway, thanks in advance for any input on this. =)
Re: Possible to capture mouse input on the CLI?
Yes it is. With Pygame. I have a webradio with touchscreen doing this. I followed this adafruit guide: https://learn.adafruit.com/raspberry-pi ... n/overviewgeekman92 wrote:Is it still possible to capture the mouse events in PyGame if writing directly to the Framebuffer?
You can adapt the code to your needs.
--
Jmp0
Re: Possible to capture mouse input on the CLI?
For other ways of reading mouse position, there's the old gpm mouse daemon, and you can also send Mousetraps in a shell script.
‘Remember the Golden Rule of Selling: “Do not resort to violence.”’ — McGlashan.
Pronouns: he/him
Pronouns: he/him
Re: Possible to capture mouse input on the CLI?
ncurses supports mouse operations seehttp://www.tldp.org/HOWTO/NCURSES-Progr ... mouse.html. Alternatively you can read the mouse device /dev/input/mice
Re: Possible to capture mouse input on the CLI?
Sorry for not replying to this before, NYE prep and the start of 2017 put this project on hold!
I am very grateful for all your answers. Think I am going to look into ncurses as there is a Python library I can use. =)
I am very grateful for all your answers. Think I am going to look into ncurses as there is a Python library I can use. =)
Re: Possible to capture mouse input on the CLI?
There's always another way 
Raw mouse events can also be read from appropriate devices in /dev/input. /dev/input/by-id has more "User friendly" symlinks to the devices.
https://www.kernel.org/doc/Documentatio ... /input.txt has details of how to interpret the event stream.
PeterO

Raw mouse events can also be read from appropriate devices in /dev/input. /dev/input/by-id has more "User friendly" symlinks to the devices.
https://www.kernel.org/doc/Documentatio ... /input.txt has details of how to interpret the event stream.
PeterO
Discoverer of the PI2 XENON DEATH FLASH!
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson
Re: Possible to capture mouse input on the CLI?
What ever happened to /dev/mouse ?
I recall a time when I could do:
$ cat /dev/mouse
Cat, mouse, get it
Then a lot of random junk would be printed as I wiggled the mouse.
Basically any program could read that device and interpret the data.
This debian machine has:
/dev/input/mice
/dev/input/mouse0
/dev/input/mouse1
I can't cat any of those, permission denied, even as root.
I recall a time when I could do:
$ cat /dev/mouse
Cat, mouse, get it

Basically any program could read that device and interpret the data.
This debian machine has:
/dev/input/mice
/dev/input/mouse0
/dev/input/mouse1
I can't cat any of those, permission denied, even as root.
Memory in C++ is a leaky abstraction .
Re: Possible to capture mouse input on the CLI?
It got replaced by the "input" system which unifies different input devices.Heater wrote:What ever happened to /dev/mouse ?
Works fine as root on my Mint-17.3 box
I can't cat any of those, permission denied, even as root.
On Mint the ownership is root:root. On Raspbian it is root:input so "pi" can read them.
I used /dev/input for my rubik's cube demo http://www.peteronion.org.uk/video/RubikTouch.mpeg
PeterO
Discoverer of the PI2 XENON DEATH FLASH!
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson
Re: Possible to capture mouse input on the CLI?
You're right. Just tried it again and cat /dev/input/mouse0 does indeed work on my Debian PC. It just hangs there because I'm logged in remotely, to far away to wiggle the mouse !
I must have got that wrong, half asleep as I was at the time.
I must have got that wrong, half asleep as I was at the time.
Memory in C++ is a leaky abstraction .