[E² Plugin] KeymapAdaption

WaRp

(∩`-´)⊃━☆゚.*・。゚
Staff member
Administrator
Messages
30,056
KeymapAdaption - Extension for keymap to deactivate the function when the key is released after a long keystroke

WeFraJo wrote
If a function for long and normal keystrokes is defined for a remote control key, the function intended for normal keystrokes is also called after the long keystroke, especially if the activity to be carried out for the long keystroke only lasts a short time.
In the keymap, these are the flags 'l' and 'b'.
Programmers usually intercept this in the program routine, but this is somewhat tedious.

The KeymapAdaption plugin prevents the function defined with flag 'b' from being executed after the function defined with flag 'l' has been executed.

In addition, you can set that a long keystroke and/or the repeat function for the keys are generally prevented.

By default, the priority is set to -10 (input = 10). This prevents the function defined with flag 'b' from being executed after a long keystroke in all important keymaps - which are usually processed with priority 1 to -4. Exceptions known to me are the plugins ShootYourScreen and GrannyButton, which work with maximum priority -7FFFFFFFFF(hex). If you want to override these, you must also set the priority in KeymapAdaption to the maximum value.

For plugin developers:
This function should actually be integrated in the VTI. If you want to use it as a developer in your programs, you must also ensure that the plugin is installed and activated.
Temporarily (until the next restart or execution of the setup for the plugin), you can also control the functions with the following config parameters when the plugin is installed:
config.plugins.KeymapAdaption.activate_
config.plugins.KeymapAdaption.stopLong_
config.plugins.KeymapAdaption.stopRepeated_
Pay attention to the underscore! True = activated, False = deactivated, whereby the last two are deactivated in any case if ...activate_ is not activated.
It is important that the plugin is only installed once - so do not import and execute it in other plugins, because another key query routine would be created each time and the system would eventually go down.

The plugin would actually belong to the SystemPlugins. I'll put it in as an extension now.
If there is positive feedback, I will suggest the underlying function to the VTI team for implementation in future VTI versions.

PS:
Sometimes the problem described at the beginning can also be solved if you make an additional entry with flag 'm' in the keymap for the key and use it to call a function in the program that simply does nothing (pass or return). I haven't found out why this is the case, it shouldn't actually work. Perhaps it is defined somewhere that three functions with one keystroke are not permitted.

The good news:
The plugin reliably prevents the function defined in the keymap with flag 'b' from being executed after a long keystroke and also after the repeat function. Due to the higher priority, it simply pretends to the subsequent keymap actions that the key has not been released. The actual handling is done in Components/ActionMap.py. However, the information already prepared in the keymap is processed there; the flag is no longer available here.

The bad news:
When the box is started, the key assignments defined under context="GlobalActions" are read in from the keymap. These remain permanently in the system.
If you use one of the keys defined there in your own programs/plugins, you should deactivate the unneeded flag defined by GlobalActions with your own assignment (which does nothing). Otherwise, the function from 'GlobalActions' may be called before/after the desired keystroke, which may or may not do anything depending on the situation.
This affects the Power, Volume, Mute and Timer buttons.

It gets even worse if the self-defined function uses flag 'm' and this calls a program that uses other contexts from the keymap. If this happens quickly enough (within about 1/8 second) then flag 'b' is triggered when the key is released, which - if it has a definition in the called program - executes it there immediately.
In this case, you should start your own function with flag 'b'. You do not need to deactivate 'm' here because it does nothing in your own program anyway.

The priority for overriding the standard key function must be at least -2 or lower, but not higher than the definition in the KeymapAdaption plugin.

Thanks WeFraJo
 

Attachments

  • enigma2-plugin-extensions-keymapadaption_1.01-20240128_all.ipk
    4.9 KB · Views: 4
Top