Close

Touch Screen & Right Click

A project log for Pickle Pi

Combines a Pi Zero 2 W (now a Pi 4), a 7 ins Waveshare 1024 x 600 display and a Gherkin 30% ortholinear keyboard in a portable tablet.

jefmerjefmer 03/26/2024 at 13:350 Comments

With a clam shell device, use of a touch screen to me feels awkward and unnatural, so I normally use a mouse with Portable Pi since I typically use it when seated at a table. In contrast, I normally use Pickle Pad with it on my lap and so I have been forced to use the touchscreen. The difficulty with this is, with a standard installation of the Raspberry Pi software, there is no way of doing the equivalent of a mouse right click. Following the usually googling, I tried the following four ways of doing right click:

evdev-rce

This right click emulation program creates a right click event for a long touch. This worked OK when I first ran it but then after a while the right click menus only stayed open with finger on the screen - on lifting the finger the menu closed making it impossible to select anything.

xdotool

You can create a right click event with the command xdotool click 3 and then activate it with a keyboard shortcut. This did not work for me in all contexts. For example, it did not bring up the menu on the task bar.

touchegg

This is a program available from GitHub - JoseExposito/touchegg which runs in the background to support multi-finger touch gestures. A two-finger touch creates a right-click and this worked for me. However, it is really intended to work with touch pads and the problem with using it on a touch screen is that it is difficult to accurately locate your two finger touch over a target object such as the task bar.

QMK Mouse Emulation

This is the solution I should have thought of from the outset! The QMK keyboard software that the Gherkin controller runs, has a complete mouse emulation feature. It is only necessary to allocate keys to the mouse movement and button functions. I can upload the keyboard map if anyone is interested. The great advantage of this solution for tablets with keyboards is that it is independent of the Window manager and so will also work with Wayland.

I had to reflash the keyboard controller after recompiling QMK with the modified key map. All of the videos I watched only mention grounding the reset pin to put the controller into bootstrap mode for reflashing. This would have meant dismantling the Pickle Pi - undoing twenty screws. Luckily, before I did this, I realised that there is a (configurable) key combination to put the Gherkin into bootstrap mode - hold B press ESC.

Discussions