3 This file is part of libmspgbase
4 Copyright © 2007 Mikko Rasa, Mikkosoft Productions
5 Distributed under the LGPL
8 #include <msp/core/except.h>
10 #include "inputdevice.h"
15 ControlSource::ControlSource():
21 ControlSource::ControlSource(Device &d, ControlSrcType t, unsigned i):
32 Control::Control(const ControlSource &s):
37 Control::Control(Device &d, ControlSrcType t, unsigned i):
44 Control::Control(const Control &c):
52 Control &Control::operator=(const Control &c)
62 void Control::capture(Device &d)
66 capture_dev->signal_button_press.connect(sigc::mem_fun(this, &Control::button_press));
67 capture_dev->signal_axis_motion.connect(sigc::mem_fun(this, &Control::axis_motion));
70 void Control::cancel_capture()
77 void Control::connect_signals()
84 src.dev->signal_button_press.connect(sigc::mem_fun(this, &Control::button_press));
85 src.dev->signal_button_release.connect(sigc::mem_fun(this, &Control::button_release));
89 src.dev->signal_axis_motion.connect(sigc::mem_fun(this, &Control::axis_motion));
92 throw Exception("Invalid source in Control");
96 void Control::button_press(unsigned i)
107 capture_complete.emit();
109 else if(src.type==BUTTON && i==src.index)
113 void Control::button_release(unsigned i)
115 if(src.type==BUTTON && i==src.index)
119 void Control::axis_motion(unsigned i, float v, float r)
123 ControlSrcType type=NONE;
124 if(v<-src.dev->get_axis_threshold())
126 else if(v>src.dev->get_axis_threshold())
136 capture_complete.emit();
139 else if(src.type==AXIS_POS && i==src.index && v>=0)
141 else if(src.type==AXIS_NEG && i==src.index && v<=0)