3 This file is part of libmspgbase
4 Copyright © 2007 Mikko Rasa, Mikkosoft Productions
5 Distributed under the LGPL
8 #include "smoothcontrol.h"
13 SmoothControl::SmoothControl():
20 SmoothControl::SmoothControl(const ControlSource &s):
28 SmoothControl::SmoothControl(Device &d, ControlSrcType t, unsigned i):
36 SmoothControl::~SmoothControl()
41 void SmoothControl::set_dead_zone(float d)
46 void SmoothControl::set_threshold(float t)
51 void SmoothControl::pair(SmoothControl *ctrl)
58 SmoothControl *old_pair=paired_ctrl;
66 paired_ctrl->pair(this);
69 void SmoothControl::on_press()
71 on_motion(1, 1-value);
74 void SmoothControl::on_release()
80 void SmoothControl::on_motion(float v, float r)
87 value=(v+dead_zone)/(threshold-dead_zone);
89 value=(v-dead_zone)/(threshold-dead_zone);
93 signal_motion.emit(value);
95 if(paired_ctrl && (v>0 || (v==0 && paired_ctrl->value!=0)))
96 paired_ctrl->on_motion(-v, -r);