code: plan9front

Download patch

ref: 0d0a879d7e8f372f7bb3c29bf55318fcbe92f32f
parent: 4f6e074f979e185f093f44b20a1021714c479b3b
author: Sigrid Solveig Haflínudóttir <sigrid@ftrv.se>
date: Fri Oct 7 22:10:05 EDT 2022

reform/pm: kbdoled: clear the OLED on zero-length write

--- a/sys/man/1/reform
+++ b/sys/man/1/reform
@@ -111,7 +111,8 @@
 .TP
 .B kbdoled
 An image can be displayed on the keyboard OLED by writing a 126x32x1
-uncompressed Plan 9 image (with or without a header).
+uncompressed Plan 9 image (with or without a header).  Zero-length
+write clears the display.
 .TP
 .B light
 Provides a way to control the backlight of the built-in LCD by
--- a/sys/src/cmd/reform/pm.c
+++ b/sys/src/cmd/reform/pm.c
@@ -157,6 +157,11 @@
 	int x, y, i, k, v, bpl;
 	u8int *p, q;
 
+	if(openkbdhid() != 0)
+		return -1;
+	if(size == 0)
+		return write(kbdhidfd, "WCLR", 4);
+
 	bpl = bytesperline(kbdoled->r, kbdoled->depth);
 	if(size == 60+bpl*KbdoledH){
 		data = (u8int*)data + 60;