]> git.tdb.fi Git - libs/gui.git/blobdiff - source/input/device.h
Add a dedicated exception class for unavailable input devices
[libs/gui.git] / source / input / device.h
index 6a436ab2d8a62f0318b893aefca0ac0b068592b1..b42ed3fde4991feb8d87b05258831585db57efec 100644 (file)
@@ -3,15 +3,24 @@
 
 #include <string>
 #include <vector>
+#include <stdexcept>
 #include <sigc++/signal.h>
 
 namespace Msp {
 namespace Input {
 
+class device_not_available: public std::runtime_error
+{
+public:
+       device_not_available(const std::string &w): std::runtime_error(w) { }
+       virtual ~device_not_available() throw() { }
+};
+
+
 /**
 Base class for input devices.  Input devices have two types of controls:
 buttons and axes.  Buttons are either on or off.  Axes have a floating point
-value in the range [-1, 1].
+value nominally in the range [-1, 1].
 
 Event handlers return a boolean indicating whether the event is considered
 processed.  If a handler returns true, no further handlers are invoked.
@@ -42,9 +51,10 @@ protected:
        std::vector<char> buttons;
        std::vector<float> axes;
 
-       Device() { }
+       Device();
 public:
-       virtual ~Device() { }
+       virtual ~Device();
+
        const std::string &get_name() const { return name; }
        bool get_button_state(unsigned) const;
        float get_axis_value(unsigned) const;