ref: 29468e518a88ae285a527cf0295be7be8e9ca08a
parent: 59d978eeb6d9f987d2c2b17d2799f3c15655284f
author: Sigrid Solveig Haflínudóttir <sigrid@ftrv.se>
date: Fri Oct 7 11:19:11 EDT 2022
reform/pm: power off via the keyboard first Now that we have a way to send HID reports, attempt to power off using the keyboard first, which should work even if LPC firmware has not been updated. It also animates a good bye message on the OLED ♥_♥
--- a/sys/src/cmd/reform/pm.c
+++ b/sys/src/cmd/reform/pm.c
@@ -446,8 +446,16 @@
}else if(aux == (void*)Pmctl){
p = -1;
if(nf >= 2 && strcmp(f[0], "power") == 0){
- if(nf == 2 && strcmp(f[1], "off") == 0)
- p = Psomoff;
+ if(nf == 2 && strcmp(f[1], "off") == 0){
+ /*
+ * LPC firmware might not be up to date so try
+ * shutting down through the keyboard first
+ */
+ if((kbdhidfd = openkbdhid()) >= 0){
+ write(kbdhidfd, "PWR0", 4);
+ sleep(2000); /* give it a chance */
+ }
+ }
}
if(p < 0)
goto Bad;