@@ -44,19 +44,29 @@ AxisGesture::AxisGesture(Device* device, config::AxisGesture& config,
4444 const auto & axis = std::get<std::string>(_config.axis .value ());
4545 try {
4646 _input_axis = _device->virtualInput ()->toAxisCode (axis);
47+ logPrintf (INFO, " axis %d %s" , _input_axis, axis.c_str ());
4748 } catch (InputDevice::InvalidEventCode& e) {
48- logPrintf (WARN, " Invalid axis %s." );
49+ logPrintf (WARN, " Invalid axis %s." , axis. c_str () );
4950 }
5051 }
5152
5253 }
5354
5455 if (_input_axis.has_value ())
55- _device->virtualInput ()->registerAxis (_input_axis.value ());
56+ registerAxis (_input_axis.value ());
57+ }
58+
59+ void AxisGesture::registerAxis (uint axis) {
60+ _device->virtualInput ()->registerAxis (axis);
61+ int low_res_axis = InputDevice::getLowResAxis (axis);
62+ if (low_res_axis != -1 ) {
63+ _device->virtualInput ()->registerAxis (low_res_axis);
64+ }
5665}
5766
5867void AxisGesture::press (bool init_threshold) {
5968 std::shared_lock lock (_config_mutex);
69+ logPrintf (RAWREPORT, " press %d %d\n " , _axis, init_threshold);
6070 if (init_threshold) {
6171 _axis = (int32_t ) (_config.threshold .value_or (defaults::gesture_threshold));
6272 } else {
@@ -76,12 +86,14 @@ void AxisGesture::move(int16_t axis) {
7686 if (!_input_axis.has_value ())
7787 return ;
7888
89+
7990 const auto threshold = _config.threshold .value_or (
8091 defaults::gesture_threshold);
8192 int32_t new_axis = _axis + axis;
82- int low_res_axis = InputDevice::getLowResAxis (axis );
93+ int low_res_axis = InputDevice::getLowResAxis (_input_axis. value () );
8394 int hires_remainder = _hires_remainder;
8495
96+
8597 if (new_axis > threshold) {
8698 double move = axis;
8799 if (_axis < threshold)
@@ -102,21 +114,34 @@ void AxisGesture::move(int16_t axis) {
102114 _axis_remainder -= int_remainder;
103115 }
104116
105- if (negative_multiplier)
106- move_floor = -move_floor;
107-
108117 if (low_res_axis != -1 ) {
109- int lowres_movement, hires_movement = (int ) move_floor;
118+ int lowres_movement = 0 ;
119+ int hires_movement = (int ) move_floor;
110120 _device->virtualInput ()->moveAxis (_input_axis.value (), hires_movement);
111121 hires_remainder += hires_movement;
112- if (abs (hires_remainder) >= 60 ) {
122+ if (abs (hires_remainder) >= 1 ) {
113123 lowres_movement = hires_remainder / 120 ;
114- if (lowres_movement == 0 )
124+ if (lowres_movement == 0 ) {
115125 lowres_movement = hires_remainder > 0 ? 1 : -1 ;
126+ }
127+
128+ if ((lowres_movement > 0 && negative_multiplier) ||
129+ (lowres_movement < 0 && !negative_multiplier))
130+ {
131+ lowres_movement = 0 ;
132+ }
133+
116134 hires_remainder -= lowres_movement * 120 ;
135+
117136 _device->virtualInput ()->moveAxis (low_res_axis, lowres_movement);
118137 }
119138
139+ logPrintf (RAWREPORT, " move %ld [%.2f], l_mv:%d h_mv:%d code:%d/%d;"
140+ " axis %d/%d; new_axis %d; hires_rem %d th %d neg %d mv %.1f\n " ,
141+ time (NULL ), _config.axis_multiplier .value_or (1 ), lowres_movement, hires_movement,
142+ _input_axis.value (), low_res_axis, axis, _axis, new_axis, hires_remainder,
143+ threshold, negative_multiplier, move);
144+
120145 _hires_remainder = hires_remainder;
121146 } else {
122147 _device->virtualInput ()->moveAxis (_input_axis.value (), (int ) move_floor);
@@ -164,7 +189,7 @@ void AxisGesture::setAxis(const std::string& axis) {
164189 } else {
165190 _input_axis = _device->virtualInput ()->toAxisCode (axis);
166191 _config.axis = axis;
167- _device-> virtualInput ()-> registerAxis (_input_axis.value ());
192+ registerAxis (_input_axis.value ());
168193 }
169194 setHiresMultiplier (_hires_multiplier);
170195}
0 commit comments