Skip to content
Snippets Groups Projects
Commit 91ee268c authored by benjamin.sitbon's avatar benjamin.sitbon
Browse files

Terminé

parent f5a95ca0
No related branches found
No related tags found
No related merge requests found
File deleted
# coding: utf-8
import threading
import time
import uinput
class Gamepad:
def __init__(
self, x_min: int = -100, x_max: int = 100, y_min: int = -100, y_max: int = 100
):
self.events = (
uinput.ABS_X + (x_min, x_max, 0, 0),
uinput.ABS_Y + (y_min, y_max, 0, 0),
)
self.x_min = x_min
self.x_max = x_max
self.y_min = y_min
self.y_max = y_max
self.x_val = 0
self.y_val = 0
def pt(self):
with uinput.Device(self.events) as device:
while True:
device.emit(uinput.ABS_X, self.x_val)
device.emit(uinput.ABS_Y, self.y_val)
time.sleep(0.1)
def start(self):
threading.Thread(target=self.pt).start()
pad = Gamepad()
pad.start()
while True:
for i in range(10):
pad.x_val = i * 10
time.sleep(1)
\ No newline at end of file
...@@ -169,8 +169,8 @@ while True: ...@@ -169,8 +169,8 @@ while True:
while(1): while(1):
if cv2.waitKey(1) & 0xFF == ord ('p'): if cv2.waitKey(1) & 0xFF == ord ('p'):
break break
elif cv2.waitKey(1) & 0xFF == ord ('q'): if cv2.waitKey(1) & 0xFF == ord ('q'):
break exit()
cap.release() cap.release()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment