Skip to content

Commit c6fd098

Browse files
committed
fixup! fixup! add gesture detection for qemu mouse
1 parent 7f16af2 commit c6fd098

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

examples/gesture.lua

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ local driver = {
88
}
99

1010
function driver:probe(devid)
11-
return { x = 0, y = 0, drag = false }
11+
return { x = 0, y = 0, drag = false, lock = false}
1212
end
1313

1414
function driver:raw_event(hdev, state, report, raw_data)
@@ -34,12 +34,25 @@ function driver:raw_event(hdev, state, report, raw_data)
3434
direction = state.y > 0 and "downly" or "uply"
3535
end
3636
print(string.format("Swipe %s with x=%d, y=%d", direction, state.x, state.y))
37+
if direction == "uply" then
38+
state.lock = true
39+
print("Locking mouse")
40+
end
41+
if direction == "downly" and state.lock then
42+
state.lock = false
43+
print("Unlocking mouse")
44+
end
3745
end
3846
state.x = 0
3947
state.y = 0
4048
state.drag = false
4149
end
4250
end
51+
if state.lock then
52+
raw_data:setbyte(0, 0)
53+
raw_data:setbyte(1, 0)
54+
raw_data:setbyte(2, 0)
55+
end
4356
return false
4457
end
4558

0 commit comments

Comments
 (0)