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 { namespace HostOS {
bool bool
Focus (const char *command) { Focus (const char *command) {
enum { if (strcmp_P (command, PSTR ("hostos.type")) != 0)
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
return false; return false;
switch (subCommand) { if (Serial.peek () == '\n') {
case GET:
Serial.println (::HostOS.os ()); Serial.println (::HostOS.os ());
break; } else {
case SET:
uint8_t os = Serial.parseInt (); uint8_t os = Serial.parseInt ();
::HostOS.os ((KaleidoscopePlugins::HostOS::Type) os); ::HostOS.os ((KaleidoscopePlugins::HostOS::Type) os);
break;
} }
Serial.read (); Serial.read ();

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

Loading…
Cancel
Save