diff --git a/ev3dev2/_platform/pistorms.py b/ev3dev2/_platform/pistorms.py index 1dfa0b2..8653549 100644 --- a/ev3dev2/_platform/pistorms.py +++ b/ev3dev2/_platform/pistorms.py @@ -2,6 +2,13 @@ An assortment of classes modeling specific features of the PiStorms. """ from collections import OrderedDict +from evdev import InputDevice, list_devices + +def find_filename(device_name): + for path in list_devices(): + dev = InputDevice(path) + if device_name in dev.name: + return dev.fn OUTPUT_A = 'pistorms:BAM1' OUTPUT_B = 'pistorms:BAM2' @@ -13,8 +20,8 @@ INPUT_3 = 'pistorms:BBS1' INPUT_4 = 'pistorms:BBS2' -BUTTONS_FILENAME = '/dev/input/by-path/platform-3f804000.i2c-event' EVDEV_DEVICE_NAME = 'PiStorms' +BUTTONS_FILENAME = find_filename(EVDEV_DEVICE_NAME) LEDS = OrderedDict() LEDS['red_left'] = 'pistorms:BB:red:brick-status' @@ -38,3 +45,5 @@ LED_COLORS['MAGENTA'] = (1, 0, 1) LED_DEFAULT_COLOR = 'GREEN' + +