3 This file is part of libmspgbase
4 Copyright © 2007 Mikko Rasa, Mikkosoft Productions
5 Distributed under the LGPL
8 #include <msp/strings/formatter.h>
9 #include "inputdevice.h"
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);
70 signal_axis_motion.emit(axis, value, value-old);