Enable/Disable all input by button press

  • Hello,

    Is there any way to enable/disable all other keys by pressing one key/button?

    Im currenlty using a remote mapped by a FLIRC dongle, but it happens that i use the same remote of my TV, and when im not using LibreELEC i dont wanna mess with any configuration by pressing the Keys i mapped (mostly direction, back and enter) on Kodi.

    So i thought i could use something to block all input in Kodi and only enable it by pressing a Key button (Blue as example)

    If it helps, Im on a RPI2 with latest LibreELEC.

    ps: HDMI-CEC is not an option since im using a Hyperion Setup behind some HDMI splitter and switches.

  • The active keymap can be defined in /storage/.config/rc_maps.cfg and you can reload the config via ir-keytable; so you could write a shell script to toggle between a keymap that only has one control defined (for the on/off switch) and one with all the normal controls present. Assign the button to something on the remote that doesn't do anything on the TV (there's usually at least one button that's harmless). Or do it the easy way and just get a second remote; or a proper smart/learning remote that can switch modes.

  • I think i'm gonna try the hard way.

    I dont have this file: /storage/.config/rc_maps.cfg just a sample file: rc_maps.cfg.sample

    I suppose i can write the script to switch between keymaps, can you point me just how to reload config via ir-keytable please?


    i tried the following from Infrared Remotes [LibreELEC.wiki]

    Code
    LibreELEC:~/.kodi/userdata/keymaps # ir-keytable -c -w /usr/lib/udev/rc_keymaps/samsung
    Read samsung table
    /sys/class/rc/: No such file or directory

    but it didn't work

    And i shouldn't have a rc_maps.cfg file?

    If it matters, i mapped my remote via Flirc Ubuntu app, so it is recognized in Kodi as a keyboard, right?

    Thank you anyway for the reply.

    Edited 3 times, last by dishins (August 30, 2018 at 3:05 AM).

  • Maybe you could disable/enable USB port where Flirc is connected?

    Follow How to enable and disable a USB port using the terminal in Linux Kernel Version 3.11.1 - Quora

    For me this works

  • I think enabling/disabling USB port wont work for me cause i need to enable my mapping again by pressing a button on the very same remote, and if the USB port is disabled that wont work.

    Is there any way i could swap keyboard mappings in Kodi?

  • If you use a python script linked to a remote button or shortcut / favourite to move keymaps in and out of storage/.kodi/userdata/keymaps you can then use xbmc.executebuiltin('Action(reloadkeymaps)') to load the new map. Hacky but it works reliably.

  • Default keyboard file is /usr/share/kodi/system/keymaps/keyboard.xml.

    But I think all keys (or at least problematic ones) should be redefined to work this. Like

    and having python script to switch between keyboard files and execute reloadkeymap.

  • Might be wrong, but I was under the impression you needed to use noop, eg

    <up>noop</up>

    to specify no action (ie override the default).

    I'd use one keymap that was just something like:

    XML
    <?xml version="1.0" encoding="UTF-8"?>
    <keymap>
    <global>
    <keyboard>
    <blue>XBMC.RunScript(/storage/switch_keyboard.py)</blue>
    </keyboard>
    </global>
    </keymap>

    and make another one like vpeter's example full of 'noop's (ie disabling keys) that you could either move in / out or rename (the extension) before reloading keymaps. Then have your script bring up a notification to say the remote's been enabled or disabled as appropriate.

  • Could be. I used empty and it worked too :) Maybe noop is better (worth to check).

    Quote

    An empty action removes the corresponding mapping from default and parent keymaps

    This is different from a "noop" action, which disables a button.

  • Thanks again to everyone replying to this topic.

    Allright, so i put the following script in my Kodi Favourites entry:

    Bash
    #!/bin/sh
    rm /storage/.kodi/userdata/keymaps/keyboard.xml
    sleep 1
    xbmc.executebuiltin('Action(reloadkeymaps)')
    sleep 1
    kodi-send -a "Notification(Kodi Info,Keyboard Disabled,7000,http://powerpi.de/wp-content/uploads/powerpi/powerpi_ambi_thumb_off.jpg)"
    </dev/null >/dev/null 2>&1 &

    However, the reloadkeymaps function is not working. The script does remove my file from the keymaps, but is not reloading my full keyboard after and neither pops up the notification. If if remove the reloadkeymaps line, the removal off keyboard file and notification works.

    Any tips?

  • if you're using a shell script I'm pretty sure you have to use kodi-send to run a built-in function.

    xbmc.executebuiltin('Action(reloadkeymaps)') will work directly from python - I'd use a python script myself.