added exiting event code display, updated version number

This commit is contained in:
dekunukem
2022-03-08 00:43:33 +00:00
parent 48bd979826
commit 7bb1838831
3 changed files with 23 additions and 13 deletions

View File

@@ -7,7 +7,14 @@
print(gamepad_status)
# print(usb4vc_usb_scan.opened_device_dict[device.path]['axes_info'][cat.event.code])
# print(cat.event.code)
# print(cat.event.code)
os.set_blocking(device.fileno(), False)
usb4vc_oled.oled_print_centered("Press any key to exit", usb4vc_oled.font_regular, 20, draw)
for button in button_list:
print(button)
if button.is_pressed():
print("HHHHHHH")
return
def ev_loop(button_list):
selector = selectors.DefaultSelector()
opened_dict = {}

View File

@@ -1,4 +1,5 @@
import time
import os
import usb4vc_oled
from luma.core.render import canvas
import usb4vc_usb_scan
@@ -10,11 +11,15 @@ def ev_loop(button_list):
opened_dict = {}
last_value = 127
with canvas(usb4vc_oled.oled_device) as draw:
usb4vc_oled.oled_print_centered('Listening...', usb4vc_oled.font_medium, 10, draw)
usb4vc_oled.oled_print_centered("HOLD + during", usb4vc_oled.font_medium, 0, draw)
usb4vc_oled.oled_print_centered("input to exit", usb4vc_oled.font_medium, 15, draw)
time.sleep(0.5)
while 1:
for button in button_list:
if button.is_pressed():
return
for dev_path in usb4vc_usb_scan.opened_device_dict:
if dev_path not in opened_dict:
print(dev_path)
opened_dict[dev_path] = evdev.InputDevice(dev_path)
selector.register(opened_dict[dev_path], selectors.EVENT_READ)
for key, mask in selector.select():
@@ -69,4 +74,3 @@ def ev_loop(button_list):
usb4vc_oled.oled_print_centered(middle_line, usb4vc_oled.font_medium, 15, draw)
else:
usb4vc_oled.oled_print_centered(middle_line, usb4vc_oled.font_regular, 15, draw)
time.sleep(0.05)

View File

@@ -461,7 +461,7 @@ class usb4vc_menu(object):
def __init__(self, pboard, conf_dict):
super(usb4vc_menu, self).__init__()
self.current_level = 0
self.current_page = 3
self.current_page = 0
self.level_size = 6
self.page_size = [5, 6, 4, 1, 1, 5]
self.kb_protocol_list = list(pboard['protocol_list_keyboard'])
@@ -531,8 +531,7 @@ class usb4vc_menu(object):
usb4vc_oled.oled_print_centered("USB Flashdrive", usb4vc_oled.font_medium, 16, draw)
if page == 3:
with canvas(usb4vc_oled.oled_device) as draw:
usb4vc_oled.oled_print_centered("Show Event Codes", usb4vc_oled.font_medium, 0, draw)
usb4vc_oled.oled_print_centered("Press any key to exit", usb4vc_oled.font_regular, 20, draw)
usb4vc_oled.oled_print_centered("Show Event Codes", usb4vc_oled.font_medium, 10, draw)
if page == 4:
with canvas(usb4vc_oled.oled_device) as draw:
usb4vc_oled.oled_print_centered("Remove BT Device", usb4vc_oled.font_medium, 10, draw)
@@ -703,11 +702,11 @@ class usb4vc_menu(object):
usb4vc_oled.oled_print_centered("Update complete!", usb4vc_oled.font_medium, 0, draw)
usb4vc_oled.oled_print_centered("Relaunching...", usb4vc_oled.font_medium, 16, draw)
time.sleep(3)
oled_device.clear()
usb4vc_oled.oled_device.clear()
os._exit(0)
elif page == 3:
try:
usb4vc_show_ev.ev_loop(None)
usb4vc_show_ev.ev_loop([plus_button, minus_button, enter_button])
except Exception as e:
print('ev_loop exception:', e)
self.goto_level(0)
@@ -780,7 +779,7 @@ class usb4vc_menu(object):
while 1:
time.sleep(1)
if page == 1:
oled_device.clear()
usb4vc_oled.oled_device.clear()
os._exit(0)
if page == 2:
with canvas(usb4vc_oled.oled_device) as draw:
@@ -789,7 +788,7 @@ class usb4vc_menu(object):
while 1:
time.sleep(1)
if page == 3:
oled_device.clear()
usb4vc_oled.oled_device.clear()
os._exit(169)
if page == 4:
self.goto_level(0)
@@ -822,7 +821,7 @@ def get_mouse_sensitivity():
def ui_init():
global pboard_info_spi_msg
global this_pboard_id
# load_config()
load_config()
pboard_info_spi_msg = usb4vc_usb_scan.get_pboard_info()
print("PB INFO:", pboard_info_spi_msg)
this_pboard_id = pboard_info_spi_msg[3]
@@ -855,7 +854,7 @@ class oled_sleep_control(object):
def sleep(self):
if self.is_sleeping is False:
print("sleeping!")
oled_device.clear()
usb4vc_oled.oled_device.clear()
self.is_sleeping = True
def wakeup(self):
if self.is_sleeping: