C++ class for device-specific code

Replace the device-specific functions with a class.  Move some of the
key handling (for log visibility toggling and rebooting) into the UI
class.  Fix up the key handling so there is less crosstalk between the
immediate keys and the queued keys (an increasing annoyance on
button-limited devices).

Change-Id: I8bdea6505da7974631bf3d9ac3ee308f8c0f76e1
diff --git a/ui.h b/ui.h
index 6150bfd..3ca99a6 100644
--- a/ui.h
+++ b/ui.h
@@ -64,6 +64,13 @@
     // Erase any queued-up keys.
     virtual void FlushKeys() = 0;
 
+    // Called on each keypress, even while operations are in progress.
+    // Return value indicates whether an immediate operation should be
+    // triggered (toggling the display, rebooting the device), or if
+    // the key should be enqueued for use by the main thread.
+    enum KeyAction { ENQUEUE, TOGGLE, REBOOT };
+    virtual KeyAction CheckKey(int key) = 0;
+
     // --- menu display ---
 
     // Display some header text followed by a menu of items, which appears