Simple test¶
Ensure your device works with this simple test.
examples/absolute_mouse_simpletest.py¶
1# SPDX-FileCopyrightText: 2022 Neradoc
2# SPDX-License-Identifier: Unlicense
3
4import time
5import usb_hid
6from absolute_mouse import Mouse
7
8m = Mouse(usb_hid.devices)
9
10# mouse_abs accept value from 0 to 32767 for both X and Y
11# Note: Values are NOT pixels! 32767 = 100% (to right or to bottom)
12
13
14def transpose(x, y):
15 return ((x * 32767) // 1920, (y * 32767) // 1080)
16
17
18positions = [(10, 40), (800, 800), (1600, 200)]
19
20while True:
21 time.sleep(2)
22 for position in positions:
23 print("MOVE", position, transpose(*position))
24 m.move(*transpose(*position))
25 time.sleep(2)
26 # time.sleep(10)
27 break
Put this in boot.py¶
1# SPDX-FileCopyrightText: 2022 Neradoc
2# SPDX-License-Identifier: Unlicense
3
4import usb_hid
5from absolute_mouse.descriptor import device
6
7usb_hid.enable((usb_hid.Device.KEYBOARD, device))