#include <msp/strings/format.h>
#include "device.h"
+using namespace std;
+
namespace Msp {
namespace Input {
-Device::Device()
+Device::Device(DeviceType t):
+ type(t)
{ }
Device::~Device()
{ }
+Device *Device::find_subdevice(const string &n)
+{
+ return (n==name ? this : 0);
+}
+
+Device *Device::find_subdevice(DeviceType t, unsigned i)
+{
+ return (t==type && i==0 ? this : 0);
+}
+
bool Device::get_button_state(unsigned btn) const
{
if(btn>=buttons.size())
}
}
+
+void operator>>(const LexicalConverter &conv, DeviceType &type)
+{
+ if(conv.get()=="UNSPECIFIED")
+ type = UNSPECIFIED;
+ else if(conv.get()=="KEYBOARD")
+ type = KEYBOARD;
+ else if(conv.get()=="MOUSE")
+ type = MOUSE;
+ else if(conv.get()=="TOUCH_SURFACE")
+ type = TOUCH_SURFACE;
+ else if(conv.get()=="GAME_CONTROLLER")
+ type = GAME_CONTROLLER;
+ else
+ throw lexical_error(format("conversion of '%s' to DeviceType", conv.get()));
+}
+
+void operator<<(LexicalConverter &conv, DeviceType type)
+{
+ switch(type)
+ {
+ case UNSPECIFIED: conv.result("UNSPECIFIED"); break;
+ case KEYBOARD: conv.result("KEYBOARD"); break;
+ case MOUSE: conv.result("MOUSE"); break;
+ case TOUCH_SURFACE: conv.result("TOUCH_SURFACE"); break;
+ case GAME_CONTROLLER: conv.result("GAME_CONTROLLER"); break;
+ default: conv.result(format("DeviceType(%#x)", static_cast<int>(type)));
+ }
+}
+
} // namespace Input
} // namespace Msp