mirror of
https://github.com/dbarzin/pandora-box.git
synced 2025-07-18 21:09:41 +02:00
fix mouse or enter
This commit is contained in:
parent
414cd61569
commit
4efc3a4893
3 changed files with 71 additions and 32 deletions
|
@ -5,17 +5,18 @@ User interface
|
||||||
|
|
||||||
- [x] Animations during scan
|
- [x] Animations during scan
|
||||||
- [ ] Internationalisation
|
- [ ] Internationalisation
|
||||||
|
- [ ] Change display from text mode to graphic mode with function key
|
||||||
|
|
||||||
Technical
|
Technical
|
||||||
|
|
||||||
- [x] Multi threading
|
|
||||||
- [ ] ~~Deployment on Raspberry Pi~~ (too slow)
|
|
||||||
- [x] logrotate on pandora-box.log
|
- [x] logrotate on pandora-box.log
|
||||||
- [x] place logs in /var/logs
|
- [x] place logs in /var/logs
|
||||||
|
- [x] Multi threading
|
||||||
|
- [ ] ~~Deployment on Raspberry Pi~~ (too slow)
|
||||||
- [x] update procedure
|
- [x] update procedure
|
||||||
- [ ] Docker script for github continuous integration
|
|
||||||
- [x] Improve logs during scan
|
- [x] Improve logs during scan
|
||||||
|
- [ ] Docker script for github continuous integration
|
||||||
|
|
||||||
Known issues
|
Known issues
|
||||||
|
|
||||||
- [ ] mouse click not detcted in console mode on Ubuntu (see: tests/screen.py)
|
- [x] mouse click not detcted in console mode on Ubuntu (see: tests/screen.py)
|
||||||
|
|
|
@ -242,19 +242,6 @@ def display_image(status):
|
||||||
os.system(f"fim -qa {image} </dev/null 2>/dev/null >/dev/null &")
|
os.system(f"fim -qa {image} </dev/null 2>/dev/null >/dev/null &")
|
||||||
|
|
||||||
|
|
||||||
# -----------------------------------------------------------
|
|
||||||
|
|
||||||
def wait_mouse_click():
|
|
||||||
""" Wait for mouse click event """
|
|
||||||
with open("/dev/input/mice", "rb") as mouse:
|
|
||||||
down = False
|
|
||||||
while True:
|
|
||||||
buf = mouse.read(3)
|
|
||||||
if (buf[0] & 0x1) == 1:
|
|
||||||
down = True
|
|
||||||
if ((buf[0] & 0x1) == 0) and down:
|
|
||||||
break
|
|
||||||
|
|
||||||
# -----------------------------------------------------------
|
# -----------------------------------------------------------
|
||||||
# has_curses Screen
|
# has_curses Screen
|
||||||
# -----------------------------------------------------------
|
# -----------------------------------------------------------
|
||||||
|
@ -695,6 +682,59 @@ def error():
|
||||||
display_image("ERROR")
|
display_image("ERROR")
|
||||||
return "WAIT"
|
return "WAIT"
|
||||||
|
|
||||||
|
# -----------------------------------------------------------
|
||||||
|
# Wait for mouse click or enter
|
||||||
|
# -----------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
mouseEvent = threading.Event()
|
||||||
|
enterEvent = threading.Event()
|
||||||
|
mouseOrEnterCondition = threading.Condition()
|
||||||
|
|
||||||
|
|
||||||
|
def mouseClickThread():
|
||||||
|
mouse = open("/dev/input/mice", "rb")
|
||||||
|
os.set_blocking(mouse.fileno(), False)
|
||||||
|
|
||||||
|
down = False
|
||||||
|
while not enterEvent.is_set():
|
||||||
|
buf = mouse.read(3)
|
||||||
|
if not (buf is None):
|
||||||
|
if ((buf[0] & 0x1) == 1):
|
||||||
|
down = True
|
||||||
|
if (((buf[0] & 0x1) == 0) and down):
|
||||||
|
break
|
||||||
|
time.sleep(0.1)
|
||||||
|
mouse.close()
|
||||||
|
|
||||||
|
mouseEvent.set()
|
||||||
|
with mouseOrEnterCondition:
|
||||||
|
mouseOrEnterCondition.notify()
|
||||||
|
|
||||||
|
|
||||||
|
def enterKeyThread():
|
||||||
|
os.set_blocking(sys.stdin.fileno(), False)
|
||||||
|
|
||||||
|
while not mouseEvent.is_set():
|
||||||
|
input = sys.stdin.readline()
|
||||||
|
if (len(input) > 0):
|
||||||
|
break
|
||||||
|
time.sleep(0.1)
|
||||||
|
|
||||||
|
enterEvent.set()
|
||||||
|
with mouseOrEnterCondition:
|
||||||
|
mouseOrEnterCondition.notify()
|
||||||
|
|
||||||
|
|
||||||
|
def waitMouseOrEnter():
|
||||||
|
with mouseOrEnterCondition:
|
||||||
|
threading.Thread(target=mouseClickThread, args=()).start()
|
||||||
|
threading.Thread(target=enterKeyThread, args=()).start()
|
||||||
|
|
||||||
|
mouseEvent.clear()
|
||||||
|
enterEvent.clear()
|
||||||
|
while not (mouseEvent.is_set() or enterEvent.is_set()):
|
||||||
|
mouseOrEnterCondition.wait()
|
||||||
|
|
||||||
# --------------------------------------
|
# --------------------------------------
|
||||||
|
|
||||||
|
@ -709,7 +749,6 @@ def clean():
|
||||||
|
|
||||||
if not has_curses:
|
if not has_curses:
|
||||||
display_image("BAD")
|
display_image("BAD")
|
||||||
wait_mouse_click()
|
|
||||||
else:
|
else:
|
||||||
# print list of files
|
# print list of files
|
||||||
cnt = 0
|
cnt = 0
|
||||||
|
@ -721,7 +760,8 @@ def clean():
|
||||||
break
|
break
|
||||||
# wait for clean
|
# wait for clean
|
||||||
log('PRESS KEY TO CLEAN', flush=True)
|
log('PRESS KEY TO CLEAN', flush=True)
|
||||||
wait_mouse_click()
|
|
||||||
|
waitMouseOrEnter()
|
||||||
|
|
||||||
# TODO: check device is still present
|
# TODO: check device is still present
|
||||||
|
|
||||||
|
@ -793,8 +833,7 @@ def startup():
|
||||||
logo = file1.readlines()
|
logo = file1.readlines()
|
||||||
# Print logo screen
|
# Print logo screen
|
||||||
print_screen()
|
print_screen()
|
||||||
# First unmount remaining device
|
|
||||||
umount_device()
|
|
||||||
return "WAIT"
|
return "WAIT"
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -3,12 +3,11 @@
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
|
import threading
|
||||||
|
|
||||||
from threading import Thread, Event, Condition
|
mouseEvent = threading.Event()
|
||||||
|
enterEvent = threading.Event()
|
||||||
mouseEvent = Event()
|
mouseOrEnterCondition = threading.Condition()
|
||||||
enterEvent = Event()
|
|
||||||
mouseOrEnterCondition = Condition()
|
|
||||||
|
|
||||||
|
|
||||||
def mouseClickThread():
|
def mouseClickThread():
|
||||||
|
@ -23,7 +22,7 @@ def mouseClickThread():
|
||||||
down = True
|
down = True
|
||||||
if (((buf[0] & 0x1) == 0) and down):
|
if (((buf[0] & 0x1) == 0) and down):
|
||||||
break
|
break
|
||||||
time.sleep(0.5)
|
time.sleep(0.1)
|
||||||
mouse.close()
|
mouse.close()
|
||||||
|
|
||||||
mouseEvent.set()
|
mouseEvent.set()
|
||||||
|
@ -38,7 +37,7 @@ def enterKeyThread():
|
||||||
input = sys.stdin.readline()
|
input = sys.stdin.readline()
|
||||||
if (len(input) > 0):
|
if (len(input) > 0):
|
||||||
break
|
break
|
||||||
time.sleep(0.5)
|
time.sleep(0.1)
|
||||||
|
|
||||||
enterEvent.set()
|
enterEvent.set()
|
||||||
with mouseOrEnterCondition:
|
with mouseOrEnterCondition:
|
||||||
|
@ -46,17 +45,17 @@ def enterKeyThread():
|
||||||
|
|
||||||
|
|
||||||
def waitMouseOrEnter():
|
def waitMouseOrEnter():
|
||||||
print("Wait mouse click or enter")
|
|
||||||
with mouseOrEnterCondition:
|
with mouseOrEnterCondition:
|
||||||
Thread(target=mouseClickThread, args=()).start()
|
threading.Thread(target=mouseClickThread, args=()).start()
|
||||||
Thread(target=enterKeyThread, args=()).start()
|
threading.Thread(target=enterKeyThread, args=()).start()
|
||||||
|
|
||||||
mouseEvent.clear()
|
mouseEvent.clear()
|
||||||
enterEvent.clear()
|
enterEvent.clear()
|
||||||
while not (mouseEvent.is_set() or enterEvent.is_set()):
|
while not (mouseEvent.is_set() or enterEvent.is_set()):
|
||||||
mouseOrEnterCondition.wait()
|
mouseOrEnterCondition.wait()
|
||||||
|
|
||||||
print("Done.")
|
|
||||||
|
|
||||||
|
|
||||||
|
print("Wait mouse click or enter")
|
||||||
waitMouseOrEnter()
|
waitMouseOrEnter()
|
||||||
|
print("Done.")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue