diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2017-12-03 22:23:08 +0100 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2017-12-04 12:19:26 +0100 |
commit | b256886a5cb9f2ae3ebda70a2045b19ed9f4233e (patch) | |
tree | 4fa1e46de224cf834a05824dc1eb86001bdb3300 /proto-iokit-foohid | |
parent | e89709a801e7874bc02c66848c638c6a0ccc85c1 (diff) |
api: add status check for modules
Diffstat (limited to 'proto-iokit-foohid')
-rw-r--r-- | proto-iokit-foohid/iokitprotocol.cpp | 17 | ||||
-rw-r--r-- | proto-iokit-foohid/iokitprotocol.h | 2 |
2 files changed, 16 insertions, 3 deletions
diff --git a/proto-iokit-foohid/iokitprotocol.cpp b/proto-iokit-foohid/iokitprotocol.cpp index 4af6ad5b..693ce31e 100644 --- a/proto-iokit-foohid/iokitprotocol.cpp +++ b/proto-iokit-foohid/iokitprotocol.cpp @@ -20,9 +20,22 @@ IOKitProtocol::IOKitProtocol() qWarning("%s\n", qPrintable(joystick->errorMessage())); } -bool IOKitProtocol::correct() +module_status IOKitProtocol::check_status() { - return joystick && !joystick->hasError(); + if (!joystick) + return QCoreApplication::translate("foohid", "Load failure"); + + if (joystick->hasError()) + { + QString msg = joystick->errorMessage(); + + if (msg.isEmpty()) + msg = QCoreApplication::translate("foohid", "Unknown error"); + + return error(msg); + } + + return status_ok(); } static uint8_t valueToStick(FooHIDJoystick *stick, double min, double value, double max) diff --git a/proto-iokit-foohid/iokitprotocol.h b/proto-iokit-foohid/iokitprotocol.h index f3f4089f..4c5b13a4 100644 --- a/proto-iokit-foohid/iokitprotocol.h +++ b/proto-iokit-foohid/iokitprotocol.h @@ -18,7 +18,7 @@ class IOKitProtocol : public IProtocol public: IOKitProtocol(); - bool correct() final; + module_status check_status() override; void pose(const double *headpose) final; QString game_name() final; |