Skip to main content

map keypresses to OVOS bus events

Project description

Hotkeys PHAL plugin

plugin for Keyboard hotkeys, define key combos to trigger bus events

Install

you need to add your user to the tty and input groups

sudo usermod -a -G tty,input $USER

more info in this issue

Then install the plugin

pip install ovos-PHAL-plugin-hotkeys

Configuration

Add any bus message + key combo under "key_down" and "key_up"

You may want to react when a key is pressed, or when a key is released

A complete example based on events from a generic G20 USB remote

 "PHAL": {
    "ovos-PHAL-plugin-hotkeys": {
        "debug": false,
        "key_down": {
            "mycroft.mic.listen": 582,
            "mycroft.mic.mute.toggle": 190,
            "mycroft.mic.mute": "shift+m",
            "mycroft.mic.unmute": "shift+u",
            "mycroft.volume.increase": 115,
            "mycroft.volume.decrease": 114,
            "mycroft.volume.mute.toggle": 113,
            "mycroft.volume.mute": "ctrl+shift+m",
            "mycroft.volume.unmute": "ctrl+shift+u",
            "homescreen.manager.show_active": 144,
            "ovos.common_play.play_pause": 164
       }
    }
}

For the Mark2 drivers you can find the emitted key events in the sj201-buttons-overlay.dts file

 "PHAL": {
    "ovos-PHAL-plugin-hotkeys": {
        "key_down": {
            "mycroft.mic.listen": 582,
            "mycroft.mic.mute": 248,
            "mycroft.volume.increase": 115,
            "mycroft.volume.decrease": 114
       },
        "key_up": {
            "mycroft.mic.unmute": 248
       }
    }
}

gpios 22-24 are the momentary switches; 25 is MuteMic SW connected to 3.3v or GND

Finding keys

A list of valid key scancodes can be found here

Some key presses might not be correctly detected and show up as "unknown", some devices might also emit the wrong keycodes

In this case you can enable the debug flag in the config, then check the logs

DEBUG {"event_type": "down", "scan_code": 57, "name": "space", "time": 1711050758.24674, "device": "/dev/input/event4", "is_keypad": false, "modifiers": []}
DEBUG {"event_type": "down", "scan_code": 24, "name": "o", "time": 1711050758.510758, "device": "/dev/input/event4", "is_keypad": false, "modifiers": []}
DEBUG {"event_type": "down", "scan_code": 115, "name": "unknown", "time": 1711050858.940323, "device": "/dev/input/event3", "is_keypad": false, "modifiers": []}
DEBUG {"event_type": "down", "scan_code": 114, "name": "unknown", "time": 1711050864.262953, "device": "/dev/input/event3", "is_keypad": false, "modifiers": []}

You can then use the scan_code integer in your config instead of name string

Credits

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ovos_phal_plugin_hotkeys-0.1.2a5.tar.gz (68.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ovos_phal_plugin_hotkeys-0.1.2a5-py3-none-any.whl (72.5 kB view details)

Uploaded Python 3

File details

Details for the file ovos_phal_plugin_hotkeys-0.1.2a5.tar.gz.

File metadata

File hashes

Hashes for ovos_phal_plugin_hotkeys-0.1.2a5.tar.gz
Algorithm Hash digest
SHA256 322d058b355acf60b1798118144e5deca4c9f8fa23edf1066e0a57a97ecb3afd
MD5 a7d508ae3781e772be3acb28a2d9249c
BLAKE2b-256 97edcd15f46af9fe758311db25f5ea0dcf5eafe957f97b4dff55a2b26b8a958b

See more details on using hashes here.

File details

Details for the file ovos_phal_plugin_hotkeys-0.1.2a5-py3-none-any.whl.

File metadata

File hashes

Hashes for ovos_phal_plugin_hotkeys-0.1.2a5-py3-none-any.whl
Algorithm Hash digest
SHA256 e29e7abd29f3b99c4a66b187b144b1e9fe5b35317b4aa0e53daa65a289b1dbe4
MD5 3f1035ff9f9690e9d113f72d5d3ac872
BLAKE2b-256 0806a497a4f8c190efbc7ba42a3d764a01f66a116de8561078bc68c3574a8323

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page