git: 9front

Download patch

ref: c4d3c02704eef6b2588244bd53ae953498d12044
parent: 933840fc7bf6f3aa4841df9d916ce5bc993bbac4
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;
--