Revert of b01aa72
Caused worker_thread to be stuck in Stage1Completed state until job's destruction.
This commit is contained in:
parent
04fa990b0c
commit
660c6bec22
|
@ -536,35 +536,39 @@ CalibrationConfigurationJob::CalibrationConfigurationJob(
|
||||||
std::function<void(u16, u16, u16, u16)> data_callback) {
|
std::function<void(u16, u16, u16, u16)> data_callback) {
|
||||||
|
|
||||||
std::thread([=, this] {
|
std::thread([=, this] {
|
||||||
Status current_status{Status::Initialized};
|
constexpr u16 CALIBRATION_THRESHOLD = 100;
|
||||||
SocketCallback callback{
|
|
||||||
[](Response::Version) {}, [](Response::PortInfo) {},
|
|
||||||
[&](Response::PadData data) {
|
|
||||||
static constexpr u16 CALIBRATION_THRESHOLD = 100;
|
|
||||||
static constexpr u16 MAX_VALUE = UINT16_MAX;
|
|
||||||
|
|
||||||
|
u16 min_x{UINT16_MAX};
|
||||||
|
u16 min_y{UINT16_MAX};
|
||||||
|
u16 max_x{};
|
||||||
|
u16 max_y{};
|
||||||
|
|
||||||
|
Status current_status{Status::Initialized};
|
||||||
|
SocketCallback callback{[](Response::Version) {}, [](Response::PortInfo) {},
|
||||||
|
[&](Response::PadData data) {
|
||||||
if (current_status == Status::Initialized) {
|
if (current_status == Status::Initialized) {
|
||||||
// Receiving data means the communication is ready now
|
// Receiving data means the communication is ready now
|
||||||
current_status = Status::Ready;
|
current_status = Status::Ready;
|
||||||
status_callback(current_status);
|
status_callback(current_status);
|
||||||
}
|
}
|
||||||
const auto& touchpad_0 = data.touch[0];
|
if (data.touch[0].is_active == 0) {
|
||||||
if (touchpad_0.is_active == 0) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
LOG_DEBUG(Input, "Current touch: {} {}", touchpad_0.x, touchpad_0.y);
|
LOG_DEBUG(Input, "Current touch: {} {}", data.touch[0].x,
|
||||||
const u16 min_x = std::min(MAX_VALUE, static_cast<u16>(touchpad_0.x));
|
data.touch[0].y);
|
||||||
const u16 min_y = std::min(MAX_VALUE, static_cast<u16>(touchpad_0.y));
|
min_x = std::min(min_x, static_cast<u16>(data.touch[0].x));
|
||||||
|
min_y = std::min(min_y, static_cast<u16>(data.touch[0].y));
|
||||||
if (current_status == Status::Ready) {
|
if (current_status == Status::Ready) {
|
||||||
// First touch - min data (min_x/min_y)
|
// First touch - min data (min_x/min_y)
|
||||||
current_status = Status::Stage1Completed;
|
current_status = Status::Stage1Completed;
|
||||||
status_callback(current_status);
|
status_callback(current_status);
|
||||||
}
|
}
|
||||||
if (touchpad_0.x - min_x > CALIBRATION_THRESHOLD &&
|
if (data.touch[0].x - min_x > CALIBRATION_THRESHOLD &&
|
||||||
touchpad_0.y - min_y > CALIBRATION_THRESHOLD) {
|
data.touch[0].y - min_y > CALIBRATION_THRESHOLD) {
|
||||||
// Set the current position as max value and finishes configuration
|
// Set the current position as max value and finishes
|
||||||
const u16 max_x = touchpad_0.x;
|
// configuration
|
||||||
const u16 max_y = touchpad_0.y;
|
max_x = data.touch[0].x;
|
||||||
|
max_y = data.touch[0].y;
|
||||||
current_status = Status::Completed;
|
current_status = Status::Completed;
|
||||||
data_callback(min_x, min_y, max_x, max_y);
|
data_callback(min_x, min_y, max_x, max_y);
|
||||||
status_callback(current_status);
|
status_callback(current_status);
|
||||||
|
|
Loading…
Reference in New Issue