Implement drivers for microwindows#3624
Conversation
|
Thanks to @Acfboy for the work and this draft request for discussion and @ghaerr for consultations and support on Microwidows side. I am leaving for four days now, but there are some my thoughts, the NuttX Microwidows screen, mouse and keyboard drivers should be submitted with appropriate build enable options to the mainline Microwindows https://github.com/ghaerr/microwindows before the final nuttx-apps pull request. |
|
@Acfboy please fix the issues on mwdemo: |
|
Hi @Acfboy , could you also add support for building with CMake? |
Thank you for the reminder. I will add CMake support later. |
|
@Acfboy could you spend some time fixing and improving this PR? It still as Draft. It is important to get it merged and let more people to test and review it. Also please remember to include a proper nuttx/Documentation about nanox/microwindows support on NuttX |
|
Hi @acassis , thank for the reminder. I agree I should submit the previous work as a proper PR for the community to review. However, for it to be a proper PR, I think I need to merge the existing NuttX drivers into the Microwindows mainline first. I apologize for postponing this part of the work earlier. I will submit a PR for upstream MW review soon. |
|
Yes, this what I have proposed and expect as well. You should set something like Same for the As for the keyboard, there can be space to think how to map it the best way. The NnuttX provides its You provide translation in You should try even if Nano-X server and clients can be run on NuttX. I do not see X11 graphics option as the main priority, but it would prove that even complex setup can be build and check if it is stable on NuttX. |
Hi, @ppisa . I have a question about this statement. It seems to me that the ranges of the
Two drivers makes the code cleaner. But specify the device path/name via Kconfig risks inconsistency with the real device. Alternatively, if Microwindows auto-selects the device based on NuttX config, then we have to keep both sides in sync — which adds maintenance overhead.
Okay, I'll try server and client of NanoX. |
Yes, you are right, I expected that for where So this seems to be call for priority issue. @acassis @gregory-nutt Please, do you have some some insight what is right? The simple fix is to push
Yes but NuttX is based on configuration and it is better to fail then to do lot of testing of different device names and even deciding if it is raw driver or event based. But in general it seems that there is pace for some discussion and making KBD simple on the NuttX side.
Thanks. |
Hi @ppisa I don't know the right approach to keyboard input keys symbols. Actually @linguini1 faced similar issue when porting Doom to NuttX. Unfortunately NuttX doesn't have a standard keyboard symbols |
|
One option suggested by @cederom was to adopt the EVDEV codec: https://en.wikipedia.org/wiki/Evdev |
@linguini1 and @acassis, I propose simple fix include/nuttx/input/kbd_codec.h - KEYCODE_FWDDEL,
+ KEYCODE_FWDDEL = 128, Or even larger shift to something like 0xF800 as used on Microwindows. This would solve problem with overlap of letters and other ASCII codes with special keys. I can open issue for this. The question is if there is something, some other keyboard driver or application, which breaks by this shift of I think that that this is reasonable solution for NuttX and current model. |
|
I agree, and this was a solution I considered but ultimately did not have enough time to verify if it would break other things in the kernel. I think that is at least a good interim solution which is less invasive. |
Looking ahead at Unicode, Microwindows moved its key code base to F800 because that belongs to the Unicode BMP Private Use Area. This won't overlap other Unicode values if/when NuttX applications move to Unicode.
Possibly good idea, but pushes off actively looking through source for problems now, and not having to change them again perhaps later. FWIW, myself knowing very little about NuttX, if a small shift is thought better for now, choosing a base of 256 at least allows space for using the upper half of various 256-byte multilingual code pages for non-US (e.g. European) accented characters, etc. OTOH, if keycodes are stored in byte arrays, then 128/129 would likely be mandated. |
|
|
||
| include $(APPDIR)/Make.defs | ||
|
|
||
| # LVGL graphic library |
| MICROWINDOWS_DIR = . | ||
| MICROWINDOWS_DIR_NAME = microwindows | ||
|
|
||
| #-include ./lvgl/lvgl.mk |
|
|
||
| MICROWINDOWS_COMMIT_HASH := 8809effdd0dfe6c2ac8fd0f455a31407e8495a93 | ||
|
|
||
| #CONFIG_GRAPH_MICROWINDOWS_URL ?= "https://codeload.github.com/ghaerr/microwindows/zip/refs/heads/master" |
|
|
||
| CSRCS += $(MW_CORE_OBJS:%.o=%.c) | ||
|
|
||
| #$(error EXTOBJS=$(EXTOBJS)) |
| CXXFLAGS += ${INCDIR_PREFIX}$(APPDIR)/graphics/microwindows/microwindows/src/include | ||
| CFLAGS += ${INCDIR_PREFIX}$(APPDIR)/graphics/microwindows/microwindows/src/drivers | ||
|
|
||
| ifeq ($(CONFIG_VIDEO_FB),) |
There was a problem hiding this comment.
add the dependence to Kconfig
| # License for the specific language governing permissions and limitations | ||
| # under the License. | ||
| # | ||
| ############################################################################ |
…to NuttX The Microwidows/Nano-X (https://microwindows.org/) is project developed and maintained by Gregory Haerr. It is heavily extended from predecessor NanoGUI and supports multiple APIs. The initial integration build only core parts engine, drivers and basic/included precompiled bitmap fonts. The source files are derived from list provided by Objects.rules files in appropriate Microwindows directories. The build requires fix includes in src/engine/devfont.c where #include <strings.h> is missing for strcasecmp(). Only dummy keyboard and mouse drivers are compiled. Screen driver has to be implemented/ported for NuttX FrameBuffer device API. Signed-off-by: Pavel Pisa <ppisa@pikron.com>
Added scr_nuttx.c under mwin-local/, using /dev/fb0 via the NuttX framebuffer API. Added examples/microwindows Kconfig, Make.defs and Makefile with a simple mwexample.c test app. Signed-off-by: Acfboy <AcfboyU@outlook.com>
Added kbd_nuttx.c and mou_nuttx.c under mwin-local/ for keyboard and mouse input via NuttX input subsystem. Updated mwexample.c with a mouse/keyboard input demo. Signed-off-by: Acfboy <AcfboyU@outlook.com>
Replaced mwexample.c with mwdemo.c, the Microwindows Win32 API demo with 3D graphics, controls, timers and images. Added mwdemo_main.c as the NuttX entry point calling WinMain. Updated Makefile to include the mwin library sources. Signed-off-by: Acfboy <AcfboyU@outlook.com>
Renamed mwdemo_main() back to main() per POSIX convention; the NuttX build system handles the name transformation for builtins. Signed-off-by: Acfboy <AcfboyU@outlook.com>
Added car8, zion208, penguin, under4, cs1, rle8 and microwin images from mw demos to mwdemo. Signed-off-by: Acfboy <AcfboyU@outlook.com>
Fixed backspace/del handling in the raw keyboard driver by using lib_meminstream to properly decode escape sequences from USB HID keyboards. Signed-off-by: Acfboy <AcfboyU@outlook.com>
Fixed nxstyle violations in mwdemo.c reported by CI. Signed-off-by: Acfboy <AcfboyU@outlook.com>
Added CONFIG_LIBC_KBDCODEC guards around kbd_codec-dependent code in the raw keyboard driver to fix compilation when the library is not enabled. Signed-off-by: Acfboy <AcfboyU@outlook.com>
Check TOUCH_POS_VALID before using touch coordinates to avoid using uninitialized values when the flag is not set by the touchscreen driver. Signed-off-by: Acfboy <AcfboyU@outlook.com>
…ions Removed local mwin-local/ drivers; the NuttX screen, keyboard, mouse and touchscreen drivers are now pulled from upstream Microwindows (ghaerr/microwindows#193). Added Kconfig for keyboard and mouse driver selection. Use MWCONFIG_FILE mechanism instead of hardcoded CFLAGS defines. Signed-off-by: Acfboy <AcfboyU@outlook.com>
Added NOKBD/NOMOUSE and custom driver options to Kconfig so that display-only applications or BSP-level custom drivers can be used without compiling the built-in input drivers. Signed-off-by: Acfboy <AcfboyU@outlook.com>
fix some nxstyle errors in mwdemo.c Signed-off-by: Acfboy <AcfboyU@outlook.com>
Removed leftover LVGL comments and debug lines. Moved distclean block next to context download block under the same ifeq. Added depends on VIDEO_FB in Kconfig to replace the Make.defs error check. Changed MODULE = y to MODULE = $(CONFIG_EXAMPLES_MICROWINDOWS). Signed-off-by: Acfboy <AcfboyU@outlook.com>
|
Hi @xiaoxiang781216 @acassis thanks for the thorough review! I've addressed all your feedback and fixed the non-standard commit messages flagged by checkpatch. |
please merge your temp change. |

Hello the community! Here is the work I have done for the first half of GSoC, now complete and ready for review.
Work Completed
The GDI-level Microwindows core, drivers, and
mwdemoare functional on QEMU x86-64 and the simulator.Build System Integration
MWCONFIG_FILE="mwconfig.nuttx"to inject NuttX-specific configuration into Microwindows without touching upstream headers.mwdemo.care compiled into binary using theconvbmptool during the build.NuttX Hardware Drivers
Framebuffer driver (
scr_nuttx.c), keyboard drivers (kbd_nuttx_event.cfor event-mode andkbd_nuttx_raw.cfor raw byte-stream), mouse driver (mou_nuttx_mouse.c), and touchscreen driver (mou_nuttx_ts.c) have been implemented and submitted to upstream Microwindows mainline ghaerr/microwindows#193. Thegraphics/microwindows/Makefileselects the appropriate drivers viaARCH=NUTTXand Kconfig-drivenKEYBOARD/MOUSEvariables.Kconfig Options
Flexible Kconfig for keyboard driver: event-mode (
/dev/kbd), raw byte-stream via kbd_codec (/dev/kbda), none, or custom. For mouse/touchscreen: relative mouse (/dev/mouse0), touchscreen (/dev/input0), none, or custom. Custom options allow BSP/app-level overrides without modifying the Microwindows build logic.Demo Application
Ported
mwdemo.c(a complex Windows-like demo) into a standalone NuttX example application. The demo runs successfully on bothqemu-intel64:mwand the NuttX simulator (sim:mw).I have also tested the demo with
#define CONTROL 1enabled inmwdemo.c, which represents a more complex use case.Upstream Bug Fixes
Several issues were discovered, analysed, and most of them already fixed:
MwSelect()blocked forever when a timer had already expired, because the code assumed no timer existed whenGdGetNextTimeoutreturned false.timeout == 0and return immediately.#if defined(ELKS)inmwtypes.hforcedMWPIXELVALHWtounsigned chareven whenELKS=0(intended to disable it). This truncated 32-bit pixel values read from the framebuffer.#if ELKSMwSelectswitches to polling (select(…, timeout=0)). The USB input thread had a lower priority (50) than the application (100), so it never got CPU time to generate events.TOUCH_POS_VALIDflag was not being checked in the touchscreen driver, causing uninitialized coordinate values to be used.mou_nuttx.cby checkingTOUCH_POS_VALIDbefore using touch coordinates.KEYCODE_xxxmacros (e.g.,KEYCODE_PAUSE = 0x20) overlap with ASCII characters, making it impossible to distinguish special keys from normal input in the event-mode keyboard driver.How to Reproduce (QEMU / Simulator)
qemu-intel64:mw
Then create a bootable disk following the documentation and run:
sim:mw
Notice
#define CONTROL 1manually inmwdemo.cto test more complex case.nxstyleproblems in mwdemo.c are fixed, except the names of Win32 API.