[Bug 5036] New: showkey shows wrong raw scancodes

bugzilla at busybox.net bugzilla at busybox.net
Wed Apr 4 12:05:39 UTC 2012


https://bugs.busybox.net/show_bug.cgi?id=5036

           Summary: showkey shows wrong raw scancodes
           Product: Busybox
           Version: unspecified
          Platform: All
        OS/Version: Linux
            Status: NEW
          Severity: enhancement
          Priority: P5
         Component: Other
        AssignedTo: unassigned at busybox.net
        ReportedBy: sdaoden at googlemail.com
                CC: busybox-cvs at busybox.net
   Estimated Hours: 0.0


When i try out the code from the showkey applet in busybox it gives
me completely wrong scancodes.
The following code gives correct scancodes, but since i've never
read the kernel sources it may not get all cases correctly.
(It's from my own showkey.c that works on {Open,Free}BSD and Linux.
The "kernel sources" is still true though..)


static ssize_t
mode_keycode(unsigned char *buf, ssize_t len)
{
    unsigned char *cursor;

    for (cursor = buf; --len >= 0;) {
        unsigned int isplain = 1, kc = *cursor++, rc = kc, isdown;

        if ((rc & 0xF0) == 0xE0 || (rc & 0xF8) == 0xF0) {
            isplain = 0;
            if (--len < 0) {
                *buf = (unsigned char)rc;
                len = 1;
                break;
            }

            kc <<= 8;
            kc |= *cursor++;
            rc = kc;
            kc &= ((kc & 0xF000) == 0xE000) ? 0x0FFF : 0x00FF;
        }

        isdown = (0 == (kc & 0x80));
        kc &= ~0x0080;
        if (! isplain)
            kc |= 0x80;

        printf("keycode %3u %-7s (0x%04X: 0x%04X | %c)\r\n",
            kc, (isdown ? "press" : "release"),
            rc, kc, (isdown ? 'v' : '^'));
    }

    return ((len <= 0) ? 0 : len);
}

-- 
Configure bugmail: https://bugs.busybox.net/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


More information about the busybox-cvs mailing list