Keyboard codes F1 & F2 sometimes handled as ASCII keys

Issue #639 resolved
prl created an issue

If the keyboard mode is set to eRCInput::kmAscii, then keyboard keypresses of F1 and F2 are incorrectly handled as ASCII codes, and return KEY_ASCII, with getPrevAsciiCode() returning 0 (NUL) and 1 (SOH) respectively.

The issue can be seen in screens and components that expect to handle ASCII codes as well as codes from the remote. The screens include: all screens that inherit from Components.ConfigList (like Setup), and in MovieSelection, ChannelSelection, PacketManager (PLUGIN>Software management>Advanced options>Package management), InputBox, FileCommander.InputBoxmod and VirtualKeyBoard.

The problem is in lib/driver/rcinput.cpp:

void eRCDeviceInputDev::handleCode(long rccode)
{
    struct input_event *ev = (struct input_event *)rccode;
    ...
    if (km == eRCInput::kmAscii)
    {
        bool ignore = false;
        bool ascii = (ev->code > 0 && ev->code < 61);

where:

#define KEY_F1          59
#define KEY_F2          60
#define KEY_F3          61

So that F1 and F2 are processed as ASCII keys, while F3 and th other function keys correctly handled as non-ASCII.

Replication steps

Connect a keyboard with at least the F1, F2 and F3 function keys and enable debug logging.

Enter a screen where the keyboard mode is set to eRCInput::kmAscii, for example Setup: MENU>Setup>AV Setup>AV settings. In that screen leave the focus on Video output (or any setting where ASCII keyboard entry is ignored) to reduce clutter in the log.

Press F1, F2 and F3 in sequence.

Examine the end of the debug log:

{1778}<  1602.218> KEY: 510 make KEY_ASCII None
{1778}<  1602.218> [ActionMap] InputAsciiActions gotAsciiCode
{1778}<  1602.738> KEY: 510 make KEY_ASCII None
{1778}<  1602.738> [ActionMap] InputAsciiActions gotAsciiCode
{1778}<  1603.354> KEY: 61 make KEY_F3 None
{1778}<  1603.546> KEY: 61 break KEY_F3 None
{1778}<  1603.546> [SCREENNAME]  UnhandledKey

The keypresses of F1 and F2 appear as KEY: 510 make KEY_ASCII (original codes 59 and 60), the press of F3 (code 61) is handled correctly.

Comments (3)

  1. Peter Urbanec

    Fix bug #639: Keyboard codes F1 & F2 sometimes handled as ASCII keys

    Change the test for the top of the range of ASCII keycodes from 61 to 59 so that F1 and F2 aren't treated as ACSII keys in keyboard mode eRCInput::kmAscii.

    → <<cset f3700c62bc81>>

  2. Log in to comment