Increase default button timeout to 1000 milliseconds#720
Conversation
Many interfaces make use of long-press of buttons to open context menus. Auto-releasing buttons after just 500 ms is too short for most applications to detect this as a long-press.
|
The CEC specification defines press and hold repeat times of 200ms to 500ms, with a recommended value of 450ms, and this is one of the instances where the spec says |
|
The Youtube version for TVs [1] wants long-presses of 600ms. I'm using libcec to navigate this site with my TV remote, but because libcec injects a fake key release after just 500ms, it's not possible to ever do a long-press on Youtube TV. This probably affects other applications and websites too.
Might this be referring to something else? I don't expect any "repeat", just a single press followed by a single release, spread more than 500ms apart so that it can be interpreted as a long-press by Youtube or whatever other application. [1] https://www.youtube.com/tv, you need to change your User Agent to something like |
|
The CEC spec defines press & hold as:
Some devices didn't send any key release event, which is what this default timeout was supposed to address, automatically release if the CEC device "forgot" to send a key release, and this was kept as short as possible as default value in the library. Which frontend application are you using that interfaces with your Youtube app? Does it allow you to override the timeout? |
|
I run Youtube TV on a regular browser (with the User Agent trick) on a Raspberry PI. It seems my Samsung TV doesn't implement this "repeat within 200ms to 500ms", at least for the select and back buttons. The directional arrows do send repeated events. This is what I receive when I long-press select on my Samsung TV remote (I've raised the timeout to 5000 ms in this run, and I kept it pressed for longer than that): As you can see, my code only gets two non-log events: first a key down, and 5000ms (or whatever timeout I configure) later, the fake key up. There are some other events logged in-between, but that doesn't seem to prevent the fake key up from triggering. Btw, this is happening using libcec from master. In 7.1.1 the problem isn't there because that version wasn't generating the fake key up event (maybe due to a bug that got fixed?). In 7.1.1, after the 500 ms timeout there was simply no key up ever sent. This is the same long-press on 7.1.1 (the timeout was 500ms in this sample, but notice there's no |
|
Thanks for the detailed traffic logs — they made the root cause clear. Rather than raise the global default (
This should cover your YouTube TV case on the Pi (default non-repeat mode, a TV that releases but doesn't repeat select/back): after the first release libCEC observes, holds up to ~5s register as a long-press. One caveat — the very first hold of a session, before any release has been seen, is still cut at 500ms; in practice you'll have pressed something else first, so the flag is already set. Could you build |
|
Oh, I didn't know that this define was used for more stuff. Your solution looks good and I just tested it and works well. Closing this now :) |
Many interfaces make use of long-press of buttons, for example to open context menus.
Auto-releasing buttons after just 500 ms is too short for most applications to detect this as a long-press.
This change makes the default auto-release timeout long enough to not interfere with UIs that need long-press.
I am aware that this default has been like that for a long time, but I still think it is not a good default and, given we are going to release a new major version, it's a good opportunity to change it.