修复识别到鼠标事件后无法响应的问题

This commit is contained in:
2026-08-24 13:23:37 +08:00
parent 75727afd24
commit 471935a966
6 changed files with 582 additions and 562 deletions
+2
View File
@@ -46,5 +46,7 @@ check_save
.codewhale
.mimocode
.claude
src/demo
*.deb
+1 -1
View File
@@ -1,5 +1,5 @@
Package: ktouch
Version: 2.1
Version: 2.1.1
Architecture: arm64
Maintainer: Kushidou <kushidou@small09.top>
Depends: xinput, python3
+18 -18
View File
@@ -1,18 +1,18 @@
MIT License
Copyright (c) 2026 kushidou
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
associated documentation files (the "Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the
following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial
portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
USE OR OTHER DEALINGS IN THE SOFTWARE.
MIT License
Copyright (c) 2026 kushidou
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
associated documentation files (the "Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the
following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial
portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
USE OR OTHER DEALINGS IN THE SOFTWARE.
+6
View File
@@ -1,3 +1,9 @@
ktouch (2.1.1) unstable; urgency=medium
* 适配只支持鼠标事件的屏幕
-- Kushidou <kushidou@small09.top> Mon, 24 Aug 2026 13:00:00 +0800
ktouch (2.1) unstable; urgency=medium
* 适配只支持鼠标事件的屏幕
File diff suppressed because it is too large Load Diff
+14 -2
View File
@@ -180,6 +180,7 @@ void close_touch_devices() {
void process_input_event(struct input_event *ev, struct touch_device *device,
struct touch_event *touch_ev) {
static int x = 0, y = 0, pressure = 0, touch_id = 0;
static int pending_button = 0; // 鼠标模拟屏: BTN_LEFT 状态待定, 延迟到 SYN_REPORT 上报 (0=无, 1=待按下, -1=待释放)
touch_ev->device_id = hash_string(device->path);
strncpy(touch_ev->device_name, device->name, sizeof(touch_ev->device_name));
@@ -241,17 +242,28 @@ void process_input_event(struct input_event *ev, struct touch_device *device,
if (event_callback) {
event_callback(*touch_ev);
}
} else if (ev->code == BTN_LEFT) {
// 鼠标模拟触摸屏: 只记录按键状态, 按下/释放延迟到随后的 SYN_REPORT 上报(此时坐标已更新)
pending_button = ev->value ? 1 : -1;
}
break;
case EV_SYN:
if (ev->code == SYN_REPORT) {
// 报告同步事件,表示一组事件完成
touch_ev->event_type = 1; // 移动
touch_ev->x = x;
touch_ev->y = y;
touch_ev->pressure = pressure;
touch_ev->touch_id = touch_id;
if (event_callback && (x != 0 || y != 0)) {
// 鼠标模拟触摸屏: 把待定的按下/释放在此刻上报(此时该帧坐标已更新完毕)
if (pending_button != 0) {
touch_ev->event_type = (pending_button == 1) ? 0 : 2; // 按下/释放
pending_button = 0;
if (event_callback) {
event_callback(*touch_ev);
}
} else if (event_callback && (x != 0 || y != 0)) {
touch_ev->event_type = 1; // 移动
event_callback(*touch_ev);
}
}