メモ
- RaspberryPi zero + Pythonでアクションカメラを作る
- https://qiita.com/masushin/items/8206bee55c71111813b1
- を参考に以下で動作を確認した。
import evdev from evdev import InputDevice, categorize, ecodes devices = [evdev.InputDevice(path) for path in evdev.list_devices()] for device in devices: print(device.path, device.name, device.phys) dev = evdev.InputDevice('/dev/input/event0') print(dev) dev.capabilities() dev.capabilities(verbose=True) for event in dev.read_loop(): if event.type == ecodes.EV_KEY: print(categorize(event))
pi@raspberrypi:~/bluetooth_shutter $ python evdev_shutter.py ('/dev/input/event0', 'AB Shutter3 ', 'B8:27:EB:xx:xx:xx') device /dev/input/event0, name "AB Shutter3 ", phys "B8:27:EB:xx:xx:xx" key event at 1533192623.166096, 28 (KEY_ENTER), down key event at 1533192623.203584, 115 (KEY_VOLUMEUP), down key event at 1533192623.278570, 115 (KEY_VOLUMEUP), up key event at 1533192623.353599, 28 (KEY_ENTER), up key event at 1533192628.003608, 115 (KEY_VOLUMEUP), down key event at 1533192628.256591, 115 (KEY_VOLUMEUP), hold
- Introduction — Python-evdev
- わずか300円でIoTボタンを作る方法