Posts by cs301

    [HOW-TO] Filter unwanted key repeats from 2.4 GHz USB HID remotes on LibreELEC

    Deutsche Version weiter unten / German version below

    Tested on LibreELEC x86_64 with a 2.4 GHz USB HID receiver (0406:2814).

    Some 2.4 GHz remotes occasionally generate unwanted keyboard repeat events. In Kodi this can result in one key press producing several characters.

    This script grabs the physical HID keyboard, filters unwanted EV_KEY value=2 repeat events and forwards the remaining input through a virtual uinput keyboard.

    1. Find your USB IDs

    Run:

    Code
    lsusb

    Example:

    Code
    Bus 001 Device 002: ID 0406:2814 2.4G Composite Device

    Here:

    0406 = Vendor ID
    2814 = Product ID

    2. Create the script

    Create:

    Code
    nano /storage/.config/remote-filter.py

    Paste the Python script below and change only:

    Code
    VENDOR_ID = "0406"
    PRODUCT_ID = "2814"

    to match your own receiver.

    Make it executable:

    Code
    chmod +x /storage/.config/remote-filter.py

    3. Test it

    Stop Kodi:

    Code
    systemctl stop kodi

    Start the script:

    Code
    /storage/.config/remote-filter.py

    You should see something similar to:

    Code
    [remote-filter] Keyboard found: ...
    [remote-filter] Receiver grabbed: ...
    [remote-filter] Virtual keyboard created

    If repeat events are filtered, the log will contain lines like:

    Code
    [remote-filter] Repeat discarded: keycode=35 total=1

    Then start Kodi again:

    Code
    systemctl start kodi

    Stop the manually started script afterwards with Ctrl+C.

    4. Start automatically

    Create or edit:

    Code
    nano /storage/.config/autostart.sh

    Add:

    Code
    /storage/.config/remote-filter.py \
        >> /storage/.config/remote-filter.log 2>&1 &

    If autostart.sh already contains other commands, just add these lines.

    Then:

    Code
    chmod +x /storage/.config/autostart.sh
    reboot

    Check the log afterwards:

    Code
    tail -50 /storage/.config/remote-filter.log

    Notes

    This is not traditional mechanical switch debouncing. The script specifically filters EV_KEY value=2 repeat events from the physical keyboard interface.

    If one physical key press produces DOWN → UP → DOWN → UP, a time-based debounce solution would be required instead.

    Composite receivers may expose multimedia and volume buttons through a separate Consumer Control interface. Those keys may therefore not pass through this script.

    The files are stored under /storage/.config/ and should normally survive standard LibreELEC updates. Keeping a backup is still recommended.


    Deutsche Version

    Getestet mit LibreELEC x86_64 und einem 2,4-GHz-USB-HID-Empfänger (0406:2814).

    Bei manchen 2,4-GHz-Fernbedienungen entstehen gelegentlich unerwünschte Tastatur-Wiederholungen. Aus einem einzelnen h kann in Kodi beispielsweise hhhhhh werden.

    Das Script übernimmt das Keyboard-Interface des USB-Empfängers, filtert unerwünschte EV_KEY value=2-Events und gibt die übrigen Tastendrücke über eine virtuelle uinput-Tastatur an Kodi weiter.

    1. USB-ID ermitteln

    Code
    lsusb

    Beispiel:

    Code
    Bus 001 Device 002: ID 0406:2814 2.4G Composite Device

    0406 ist die Vendor-ID, 2814 die Product-ID.

    2. Script installieren

    Code
    nano /storage/.config/remote-filter.py

    Den Python-Code aus der englischen Anleitung oben einfügen.

    Dort nur diese beiden Werte an den eigenen Empfänger anpassen:

    Code
    VENDOR_ID = "0406"
    PRODUCT_ID = "2814"

    Dann:

    Code
    chmod +x /storage/.config/remote-filter.py

    3. Testen

    Kodi stoppen:

    Code
    systemctl stop kodi

    Script starten:

    Code
    /storage/.config/remote-filter.py

    Erwartet wird ungefähr:

    Code
    [remote-filter] Keyboard found: ...
    [remote-filter] Receiver grabbed: ...
    [remote-filter] Virtual keyboard created

    Bei verworfenen Wiederholungen erscheint beispielsweise:

    Code
    [remote-filter] Repeat discarded: keycode=35 total=1

    Kodi anschließend wieder starten:

    Code
    systemctl start kodi

    Den manuell gestarteten Filter danach mit Ctrl+C beenden.

    4. Autostart

    Code
    nano /storage/.config/autostart.sh

    Folgendes ergänzen:

    Code
    /storage/.config/remote-filter.py \
        >> /storage/.config/remote-filter.log 2>&1 &

    Falls bereits andere Befehle in autostart.sh stehen, diese natürlich nicht löschen.

    Dann:

    Code
    chmod +x /storage/.config/autostart.sh
    reboot

    Log prüfen:

    Code
    tail -50 /storage/.config/remote-filter.log

    Hinweise

    Das Script filtert gezielt EV_KEY value=2-Events. Es ist daher kein klassischer zeitbasierter Entpreller.

    Wenn ein einzelner physischer Tastendruck stattdessen DOWN → UP → DOWN → UP erzeugt, benötigt man eine andere Lösung.

    Bei Composite-Empfängern können Multimedia- und Lautstärketasten über ein separates Consumer-Control-Interface laufen und werden dann von diesem Script nicht erfasst.

    Die Dateien liegen unter /storage/.config/ und bleiben bei normalen LibreELEC-Updates üblicherweise erhalten.

    Die Lösung wurde mit Unterstützung von ChatGPT erarbeitet und auf meinem LibreELEC-x86_64-System getestet.

    Hello,

    I can reproducibly crash Kodi on LibreELEC 12.2.1 by repeatedly navigating
    back while using a Python video addon.

    I originally encountered the problem with another Python addon, but I have
    now reproduced it independently using the 3sat Mediathek addon (v5.0.2).

    Hardware:
    - CPU: Intel Celeron J4005 @ 2.00 GHz
    - GPU: Intel Gemini Lake UHD Graphics 600
    - Architecture: x86_64

    Software:
    - LibreELEC: 12.2.1
    - Kodi: 21.3 (Omega)
    - Kernel: Linux 6.16.12
    - Addon used for reproduction: 3sat Mediathek 5.0.2

    Steps to reproduce:

    1. Start Kodi.
    2. Open the "3sat Mediathek" addon.
    3. Navigate through several directory levels.
    4. Press Back repeatedly in quick succession.
    5. Kodi eventually crashes.

    The crash is a SIGSEGV in PyEval_ReleaseThread():

    #0 PyEval_ReleaseThread()
    #1 CPythonInvoker::stop(bool)
    #2 CLanguageInvokerThread::stop(bool)
    #3 CScriptInvocationManager::Stop(int, bool)
    #4 CScriptRunner::WaitOnScriptResult(...)

    The Kodi debug log records Back actions while navigating in the addon.

    Shortly before the crash, Kodi cancels the running 3sat Mediathek Python
    invocation:

    CScriptRunner: cancelling add-on script 3sat Mediathek (id = 12)
    CPythonInvoker(...): script successfully run
    onExecutionDone(...)
    Python interpreter interrupted by user
    CPythonInvoker(...): trigger Monitor abort request

    The same type of crash can therefore be reproduced without using the addon
    with which I originally noticed the problem.

    I have attached the full debug-enabled Kodi log and the corresponding
    crash log:

    kodi_crashlog_20260810121320.log

    kodi.log

    The issue has also been reported to the Kodi developers.

    Please let me know if additional logs, system information or tests are
    required.