From ebe7d8742b813f66b64b147084c920cc647cf1a8 Mon Sep 17 00:00:00 2001 From: Didier Date: Thu, 30 Jun 2022 08:30:43 +0000 Subject: [PATCH] new mouse click --- tests/mouse-click.py | 26 +++++++------------------- 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/tests/mouse-click.py b/tests/mouse-click.py index 49f2273..d1c1902 100755 --- a/tests/mouse-click.py +++ b/tests/mouse-click.py @@ -1,24 +1,12 @@ #!/usr/bin/python3 -import curses +mouse = open( "/dev/input/mice", "rb" ) -screen = curses.initscr() -screen.keypad(1) -curses.curs_set(0) -curses.mousemask(curses.ALL_MOUSE_EVENTS | curses.REPORT_MOUSE_POSITION) -curses.flushinp() -curses.noecho() -screen.clear() +def waitMouseClick(): + while True: + buf = mouse.read(3) + if ((buf[0] & 0x1)==1): + break; -while True: - key = screen.getch() - screen.clear() - screen.addstr(0, 0, "key: {}".format(key)) - if key == curses.KEY_MOUSE: - _, x, y, _, button = curses.getmouse() - screen.addstr(1, 0, "x, y, button = {}, {}, {}".format(x, y, button)) - elif key == 27: - break +waitMouseClick() -curses.endwin() -curses.flushinp()