help on linux keyboard driver coding - Linux

This is a discussion on help on linux keyboard driver coding - Linux ; hi all, actually i m workin on a project on linux keyboard driver and facing some problem with the coding work. please help me with this here r some lines extracted from the source code of keyboard driver given in ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: help on linux keyboard driver coding

  1. help on linux keyboard driver coding

    hi all,
    actually i m workin on a project on linux keyboard driver and facing
    some problem with the coding work. please help me with this

    here r some lines extracted from the source code of keyboard
    driver given in usr/src/linux-2.4.20-8/drivers/char/keyboard.c

    Can u tel me the meaning of the following lines and significance of the
    inline macros?

    (the macros used in the below lines are:
    KT_SPEC=2,KT_SHIFT=7k_SAK=k(KT_SPEC,15))

    #define TYPES_ALLOWED_IN_RAW_MODE ((1 << KT_SPEC) | (1
    << KT_SHIFT))

    #define SPECIALS_ALLOWED_IN_RAW_MODE (1 <<
    KVAL(K_SAK))

    void to_utf8(ushort c) {
    if (c < 0x80)
    put_queue(c); /* 0******* */
    else if (c < 0x800) {
    put_queue(0xc0 | (c >> 6)); /* 110***** 10******
    */
    put_queue(0x80 | (c & 0x3f));
    } else {
    put_queue(0xe0 | (c >> 12)); /* 1110**** 10******
    10****** */
    put_queue(0x80 | ((c >> 6) & 0x3f));
    put_queue(0x80 | (c & 0x3f));
    }
    /* UTF-8 is defined for words of up to 31 bits,
    but we need only 16 bits here */
    }


  2. Re: help on linux keyboard driver coding

    h.silent57@gmail.com said:
    >hi all,
    > actually i m workin on a project on linux keyboard driver and facing
    >some problem with the coding work. please help me with this
    >
    >here r some lines extracted from the source code of keyboard
    >driver given in usr/src/linux-2.4.20-8/drivers/char/keyboard.c
    >
    >Can u tel me the meaning of the following lines and significance of the
    >inline macros?


    Cld u us a bt mre ltrs, plse?

    >(the macros used in the below lines are:
    >KT_SPEC=2,KT_SHIFT=7k_SAK=k(KT_SPEC,15))
    >
    >#define TYPES_ALLOWED_IN_RAW_MODE ((1 << KT_SPEC) | (1
    ><< KT_SHIFT))
    >
    >#define SPECIALS_ALLOWED_IN_RAW_MODE (1 <<
    >KVAL(K_SAK))


    No idea about the macros - but then, they're not used here; just defined.
    You could look at the code around where they are used, and try to
    extract the meaning from the surrounding code.

    >void to_utf8(ushort c) {
    > if (c < 0x80)
    > put_queue(c); /* 0******* */
    > else if (c < 0x800) {
    > put_queue(0xc0 | (c >> 6)); /* 110***** 10******
    >*/
    > put_queue(0x80 | (c & 0x3f));
    > } else {
    > put_queue(0xe0 | (c >> 12)); /* 1110**** 10******
    >10****** */
    > put_queue(0x80 | ((c >> 6) & 0x3f));
    > put_queue(0x80 | (c & 0x3f));
    > }
    > /* UTF-8 is defined for words of up to 31 bits,
    > but we need only 16 bits here */
    >}


    This is just converting a 16-bit character code (would that be in
    UCS-16 encoding?) to a UTF-8 byte sequence. Nothing to do with
    the keyboard as such - just a standard conversion from one character
    encoding to another. Apparently the keyboard hardware can send
    16-bit sequences, so encoding everything as UCS-16 makes sense;
    on the other hand, software much more commonly uses UTF-8 as the
    "international/universal" character encoding, so it's good to have
    code within the kernel to provide the application layer with UTF-8
    streams.
    --
    Wolf a.k.a. Juha Laiho Espoo, Finland
    (GC 3.0) GIT d- s+: a C++ ULSH++++$ P++@ L+++ E- W+$@ N++ !K w !O !M V
    PS(+) PE Y+ PGP(+) t- 5 !X R !tv b+ !DI D G e+ h---- r+++ y++++
    "...cancel my subscription to the resurrection!" (Jim Morrison)

+ Reply to Thread