mirror of
https://github.com/dekuNukem/USB4VC.git
synced 2025-10-31 11:26:46 -07:00
added event code display on OLED
This commit is contained in:
@@ -1,3 +1,13 @@
|
||||
axis_value_8bit = cat.event.value
|
||||
try:
|
||||
gamepad_status = usb4vc_usb_scan.gamepad_status_dict.get(usb4vc_usb_scan.opened_device_dict[device.path]['id'])
|
||||
axis_value_8bit = gamepad_status.get(cat.event.code)
|
||||
except:
|
||||
pass
|
||||
print(gamepad_status)
|
||||
# print(usb4vc_usb_scan.opened_device_dict[device.path]['axes_info'][cat.event.code])
|
||||
# print(cat.event.code)
|
||||
|
||||
def ev_loop(button_list):
|
||||
selector = selectors.DefaultSelector()
|
||||
opened_dict = {}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
RPI_APP_VERSION_TUPLE = (0, 0, 5)
|
||||
RPI_APP_VERSION_TUPLE = (0, 0, 6)
|
||||
|
||||
code_name_to_value_lookup = {
|
||||
'KEY_RESERVED':(0, 'kb_key'),
|
||||
|
||||
@@ -8,6 +8,7 @@ import selectors
|
||||
def ev_loop(button_list):
|
||||
selector = selectors.DefaultSelector()
|
||||
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)
|
||||
while 1:
|
||||
@@ -35,6 +36,16 @@ def ev_loop(button_list):
|
||||
value = cat.event.value
|
||||
except:
|
||||
pass
|
||||
try:
|
||||
gamepad_status = usb4vc_usb_scan.gamepad_status_dict.get(usb4vc_usb_scan.opened_device_dict[device.path]['id'])
|
||||
value = gamepad_status.get(cat.event.code)
|
||||
if 127 - 20 < value < 127 + 20:
|
||||
value = 127
|
||||
except:
|
||||
pass
|
||||
if value == last_value:
|
||||
continue
|
||||
last_value = value
|
||||
middle_line = f'{name}, {value}'
|
||||
elif 'key event' in ev_str.lower():
|
||||
keycode = '???'
|
||||
@@ -43,16 +54,18 @@ def ev_loop(button_list):
|
||||
keycode = cat.keycode
|
||||
elif isinstance(cat.keycode, list):
|
||||
keycode = cat.keycode[0]
|
||||
else:
|
||||
keycode = cat.scancode
|
||||
except:
|
||||
pass
|
||||
middle_line = f'{cat.scancode}, {keycode}, {cat.keystate}'
|
||||
middle_line = f'{keycode} {cat.keystate}'
|
||||
if middle_line is None:
|
||||
continue
|
||||
|
||||
top_line = str(device.name)
|
||||
with canvas(usb4vc_oled.oled_device) as draw:
|
||||
usb4vc_oled.oled_print_centered(top_line, usb4vc_oled.font_regular, 0, draw)
|
||||
if len(middle_line) <= 17:
|
||||
if len(middle_line) <= 15:
|
||||
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)
|
||||
|
||||
@@ -706,9 +706,11 @@ class usb4vc_menu(object):
|
||||
oled_device.clear()
|
||||
os._exit(0)
|
||||
elif page == 3:
|
||||
print("evtest!")
|
||||
usb4vc_show_ev.ev_loop(None)
|
||||
|
||||
try:
|
||||
usb4vc_show_ev.ev_loop(None)
|
||||
except Exception as e:
|
||||
print('ev_loop exception:', e)
|
||||
self.goto_level(0)
|
||||
elif page == 4:
|
||||
self.paired_devices_list = list(get_paired_devices())
|
||||
self.page_size[4] = len(self.paired_devices_list) + 1
|
||||
|
||||
@@ -739,11 +739,11 @@ def get_stick_axes(this_device):
|
||||
return ["ABS_X", "ABS_Y", "ABS_Z", "ABS_RZ"]
|
||||
return ["ABS_X", "ABS_Y", "ABS_RX", "ABS_RY"]
|
||||
|
||||
gamepad_status_dict = {}
|
||||
gamepad_hold_check_interval = 0.02
|
||||
def raw_input_event_worker():
|
||||
last_usb_event = 0
|
||||
mouse_status_dict = {'x': [0, 0], 'y': [0, 0], 'scroll': 0, 'hscroll': 0, BTN_LEFT:0, BTN_RIGHT:0, BTN_MIDDLE:0, BTN_SIDE:0, BTN_EXTRA:0, BTN_FORWARD:0, BTN_BACK:0, BTN_TASK:0}
|
||||
gamepad_status_dict = {}
|
||||
next_gamepad_hold_check = time.time() + gamepad_hold_check_interval
|
||||
last_mouse_msg = []
|
||||
last_gamepad_msg = None
|
||||
|
||||
Reference in New Issue
Block a user