Simplify the Focus commands

Instead of having a getter and a setter command, have one with an
optional argument instead. Less code, less docs, easier to use and
understand.

Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
pull/389/head
Gergely Nagy 8 years ago committed by Gergely Nagy
parent d9da70c2f4
commit 4615c048d1

@ -23,28 +23,14 @@ namespace KaleidoscopePlugins {
namespace HostOS {
bool
Focus (const char *command) {
enum {
GET,
SET,
} subCommand;
if (strncmp_P (command, PSTR ("hostos."), 7) != 0)
return false;
if (strcmp_P (command + 7, PSTR ("type")) == 0)
subCommand = GET;
else if (strcmp_P (command + 7, PSTR ("set")) == 0)
subCommand = SET;
else
if (strcmp_P (command, PSTR ("hostos.type")) != 0)
return false;
switch (subCommand) {
case GET:
if (Serial.peek () == '\n') {
Serial.println (::HostOS.os ());
break;
case SET:
} else {
uint8_t os = Serial.parseInt ();
::HostOS.os ((KaleidoscopePlugins::HostOS::Type) os);
break;
}
Serial.read ();

@ -28,9 +28,7 @@ namespace KaleidoscopePlugins {
#define FOCUS_HOOK_HOSTOS \
FOCUS_HOOK(KaleidoscopePlugins::HostOS::Focus, \
"hostos.type\n" \
"-----------\n" \
"Display the OS type, as known to the plugin.\n\n" \
"hostos.set type\n" \
"---------------\n" \
"Set the OS type.")
"hostos.type [TYPE]\n" \
"------------------\n" \
"Set the OS type to `TYPE`; or display the " \
"type, when called without arguments.")

Loading…
Cancel
Save