Skip to content

Commit aecd253

Browse files
committed
InputService delays config
1 parent ed41bd1 commit aecd253

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

ext/xbot_framework

src/services/input_service/input_service.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ bool InputService::OnRegisterInputConfigsChanged(const void* data, size_t length
3232
lift_multiple_input_ = &all_inputs_.emplace_back();
3333
lift_multiple_input_->idx = Input::VIRTUAL;
3434
lift_multiple_input_->emergency_reason = EmergencyReason::LIFT_MULTIPLE | EmergencyReason::LATCH;
35-
lift_multiple_input_->emergency_delay_ms = 10;
35+
lift_multiple_input_->emergency_delay_ms = LiftMultipleDelay.value;
3636

3737
input_config_json_data_t json_data;
3838
json_data.callback = etl::make_delegate<InputService, &InputService::InputConfigsJsonCallback>(*this);
@@ -200,8 +200,13 @@ void InputService::OnInputChanged(Input& input, const bool active, const uint32_
200200
SendInputEventHelper(input, InputEventType::ACTIVE);
201201
} else {
202202
SendInputEventHelper(input, InputEventType::INACTIVE);
203-
// TODO: This obviously needs debouncing, more variants and configuration.
204-
SendInputEventHelper(input, duration >= 500'000 ? InputEventType::LONG : InputEventType::SHORT);
203+
if (duration >= LongPressTime.value) {
204+
SendInputEventHelper(input, InputEventType::LONG);
205+
} else if (duration >= DebounceTime.value) {
206+
// Note that debouncing works only one-way here.
207+
// If the input becomes inactive for just a nanosecond, it will interrupt the long press.
208+
SendInputEventHelper(input, InputEventType::SHORT);
209+
}
205210
}
206211
CommitTransaction();
207212
}

0 commit comments

Comments
 (0)