Phase 2
Some checks failed
ci-bundle.yml / Phase 2 (push) Failing after 0s
ci-copr.yml / Phase 2 (push) Failing after 0s
ci-homebrew.yml / Phase 2 (push) Failing after 0s

This commit is contained in:
Joey Yakimowich-Payne 2026-02-11 13:44:02 -07:00
commit 0c16e913da
11 changed files with 277 additions and 0 deletions

View file

@ -41,6 +41,18 @@ namespace input {
#define DISABLE_LEFT_BUTTON_DELAY ((thread_pool_util::ThreadPool::task_id_t) 0x01)
#define ENABLE_LEFT_BUTTON_DELAY nullptr
static uint64_t now_ms() {
return std::chrono::duration_cast<std::chrono::milliseconds>(
std::chrono::steady_clock::now().time_since_epoch()
).count();
}
static inline void touch_activity(std::atomic<uint64_t> *ts) {
if (ts) {
ts->store(now_ms(), std::memory_order_relaxed);
}
}
constexpr auto VKEY_SHIFT = 0x10;
constexpr auto VKEY_LSHIFT = 0xA0;
constexpr auto VKEY_RSHIFT = 0xA1;
@ -193,6 +205,10 @@ namespace input {
int32_t accumulated_vscroll_delta;
int32_t accumulated_hscroll_delta;
std::atomic<uint64_t> *activity_keyboard_ms = nullptr;
std::atomic<uint64_t> *activity_mouse_ms = nullptr;
std::atomic<uint64_t> *activity_gamepad_ms = nullptr;
};
/**
@ -446,6 +462,8 @@ namespace input {
return;
}
touch_activity(input->activity_mouse_ms);
input->mouse_left_button_timeout = DISABLE_LEFT_BUTTON_DELAY;
platf::move_mouse(platf_input, util::endian::big(packet->deltaX), util::endian::big(packet->deltaY));
}
@ -543,6 +561,8 @@ namespace input {
return;
}
touch_activity(input->activity_mouse_ms);
if (input->mouse_left_button_timeout == DISABLE_LEFT_BUTTON_DELAY) {
input->mouse_left_button_timeout = ENABLE_LEFT_BUTTON_DELAY;
}
@ -593,6 +613,8 @@ namespace input {
return;
}
touch_activity(input->activity_mouse_ms);
auto release = util::endian::little(packet->header.magic) == MOUSE_BUTTON_UP_EVENT_MAGIC_GEN5;
auto button = util::endian::big(packet->button);
if (button > 0 && button < mouse_press.size()) {
@ -757,6 +779,8 @@ namespace input {
return;
}
touch_activity(input->activity_keyboard_ms);
auto release = util::endian::little(packet->header.magic) == KEY_UP_EVENT_MAGIC;
auto keyCode = packet->keyCode & 0x00FF;
@ -817,6 +841,8 @@ namespace input {
return;
}
touch_activity(input->activity_mouse_ms);
if (config::input.high_resolution_scrolling) {
platf::scroll(platf_input, util::endian::big(packet->scrollAmt1));
} else {
@ -840,6 +866,8 @@ namespace input {
return;
}
touch_activity(input->activity_mouse_ms);
if (config::input.high_resolution_scrolling) {
platf::hscroll(platf_input, util::endian::big(packet->scrollAmount));
} else {
@ -872,6 +900,8 @@ namespace input {
return;
}
touch_activity(input->activity_gamepad_ms);
if (packet->controllerNumber < 0 || packet->controllerNumber >= input->gamepads.size()) {
BOOST_LOG(warning) << "ControllerNumber out of range ["sv << packet->controllerNumber << ']';
return;
@ -912,6 +942,8 @@ namespace input {
return;
}
touch_activity(input->activity_mouse_ms);
// Convert the client normalized coordinates to touchport coordinates
auto coords = client_to_touchport(input, {from_clamped_netfloat(packet->x, 0.0f, 1.0f) * 65535.f, from_clamped_netfloat(packet->y, 0.0f, 1.0f) * 65535.f}, {65535.f, 65535.f});
if (!coords) {
@ -968,6 +1000,8 @@ namespace input {
return;
}
touch_activity(input->activity_mouse_ms);
// Convert the client normalized coordinates to touchport coordinates
auto coords = client_to_touchport(input, {from_clamped_netfloat(packet->x, 0.0f, 1.0f) * 65535.f, from_clamped_netfloat(packet->y, 0.0f, 1.0f) * 65535.f}, {65535.f, 65535.f});
if (!coords) {
@ -1026,6 +1060,8 @@ namespace input {
return;
}
touch_activity(input->activity_gamepad_ms);
if (packet->controllerNumber < 0 || packet->controllerNumber >= input->gamepads.size()) {
BOOST_LOG(warning) << "ControllerNumber out of range ["sv << packet->controllerNumber << ']';
return;
@ -1059,6 +1095,8 @@ namespace input {
return;
}
touch_activity(input->activity_gamepad_ms);
if (packet->controllerNumber < 0 || packet->controllerNumber >= input->gamepads.size()) {
BOOST_LOG(warning) << "ControllerNumber out of range ["sv << packet->controllerNumber << ']';
return;
@ -1091,6 +1129,8 @@ namespace input {
return;
}
touch_activity(input->activity_gamepad_ms);
if (packet->controllerNumber < 0 || packet->controllerNumber >= input->gamepads.size()) {
BOOST_LOG(warning) << "ControllerNumber out of range ["sv << packet->controllerNumber << ']';
return;
@ -1116,6 +1156,8 @@ namespace input {
return;
}
touch_activity(input->activity_gamepad_ms);
if (packet->controllerNumber < 0 || packet->controllerNumber >= input->gamepads.size()) {
BOOST_LOG(warning) << "ControllerNumber out of range ["sv << packet->controllerNumber << ']';