Eric Nam's Open Source Library Brings Game-Style Virtual Joysticks to LVGL
Available under the permissive MIT license, Nam's new library delivers customizable analog joysticks and buttons in a snap.
Maker Eric Nam has released a library that delivers a customizable virtual joystick, designed for anyone using a touchscreen with the LVGL graphics library — with multi-touch support projected for a future release.
"This is a virtual joystick that works on LVGL," Nam explains of his creation. "This is similar to what you often see in mobile games. By touching and holding the middle handle and moving it, the user can move the character as desired. The reason I made this is because I don't think there is a joystick that works on LVGL yet, so I wanted to give it a try."
LVGL is a graphics library designed specifically for embedded use on microcontrollers and microprocessors, typically used to deliver anything from a countdown timer to a full smartphone-like user interface. In Nam's case, LVGL is being used primary to drive simple games — though a joystick interface is also applicable to other use-cases, from remote drone control to driving a robot arm.
While there are plenty of LVGL widgets available, both built in and from third parties, Nam has yet to find a working virtual joystick — hence his project to build one. The size, appearance, and position of the joystick on-screen can be adjusted, buttons added, and it's also possible to have two joysticks for twin-stick control — though this comes with the caveat that LVGL itself doesn't yet support multiple simultaneous touch events.
"Since LVGL (the current version 9.2.0) does not support multi-touch," Nam explains of this latter restriction, "you cannot fire two touch events at the same time. More than two joysticks will be available as soon as LVGL is updated."
The library code has been released on GitHub under the permissive MIT license.
Freelance journalist, technical author, hacker, tinkerer, erstwhile sysadmin. For hire: freelance@halfacree.co.uk.