1 #include <msp/strings/format.h>
7 Device::Device(DeviceType t):
14 bool Device::get_button_state(unsigned btn) const
16 if(btn>=buttons.size())
22 float Device::get_axis_value(unsigned axis) const
30 std::string Device::get_button_name(unsigned btn) const
32 return format("Button %d", btn);
35 std::string Device::get_axis_name(unsigned axis) const
37 return format("Axis %d", axis);
40 void Device::set_button_state(unsigned btn, bool state, bool event)
42 if(btn>=buttons.size())
43 buttons.resize(btn+1, false);
45 if(state!=buttons[btn])
52 signal_button_press.emit(btn);
54 signal_button_release.emit(btn);
59 void Device::set_axis_value(unsigned axis, float value, bool event)
62 axes.resize(axis+1, 0);
66 float old = axes[axis];
70 signal_axis_motion.emit(axis, value, value-old);