summaryrefslogtreecommitdiffhomepage
path: root/proto-vjoystick
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2017-12-03 22:23:08 +0100
committerStanislaw Halik <sthalik@misaki.pl>2017-12-04 12:19:26 +0100
commitb256886a5cb9f2ae3ebda70a2045b19ed9f4233e (patch)
tree4fa1e46de224cf834a05824dc1eb86001bdb3300 /proto-vjoystick
parente89709a801e7874bc02c66848c638c6a0ccc85c1 (diff)
api: add status check for modules
Diffstat (limited to 'proto-vjoystick')
-rw-r--r--proto-vjoystick/vjoystick.cpp15
-rw-r--r--proto-vjoystick/vjoystick.h2
2 files changed, 16 insertions, 1 deletions
diff --git a/proto-vjoystick/vjoystick.cpp b/proto-vjoystick/vjoystick.cpp
index 557b5e99..9ff64998 100644
--- a/proto-vjoystick/vjoystick.cpp
+++ b/proto-vjoystick/vjoystick.cpp
@@ -125,6 +125,21 @@ vjoystick_proto::~vjoystick_proto()
{
}
+module_status vjoystick_proto::check_status()
+{
+ switch (h.get_state())
+ {
+ case state_notent:
+ return error("vjoystick #1 doesn't exist");
+ case state_fail:
+ return error("can't initialize vjoystick");
+ case state_success:
+ return status_ok();
+ default:
+ return error("unknown error");
+ }
+}
+
void vjoystick_proto::pose(const double *pose)
{
if (h.get_state() != state_success)
diff --git a/proto-vjoystick/vjoystick.h b/proto-vjoystick/vjoystick.h
index 49302030..0eac2ed2 100644
--- a/proto-vjoystick/vjoystick.h
+++ b/proto-vjoystick/vjoystick.h
@@ -53,7 +53,7 @@ class vjoystick_proto : public IProtocol
public:
vjoystick_proto();
~vjoystick_proto() override;
- bool correct() override { return h.get_state() == state_success; }
+ module_status check_status() override;
void pose( const double *headpose ) override;
QString game_name() override { return "Virtual joystick"; }
private: