Interpreting XKeyEvent - Xwindows

This is a discussion on Interpreting XKeyEvent - Xwindows ; Here is the basic overview of how I've been using XKeyEvent in my library: 1) Intercept KeyPress event 2) Call a function (I call it translateKeyCode) to translate the event.keycode field into a mapping defined by my program (it's just ...

+ Reply to Thread
Results 1 to 5 of 5

Thread: Interpreting XKeyEvent

  1. Interpreting XKeyEvent

    Here is the basic overview of how I've been using XKeyEvent in my library:

    1) Intercept KeyPress event

    2) Call a function (I call it translateKeyCode) to translate the
    event.keycode field into a mapping defined by my program (it's just a big
    switch statement). This is so I can port my library to other platforms
    which define keys differently than X.

    3) Use the translated keycode in my program.

    All was good up until now because I only cared about the raw keycode. Now I
    have a need to get the ASCII value of keys within the ASCII range.
    However, X does not provide this (which makes sense considering X is
    multinational).

    Do I have to do this myself? It's not terribly hard since I already have
    the switch statement with cases for each key, but I don't want to do that
    if X already has the facility for getting the ASCII value of the keycode.
    It would simply be a matter of setting another variable in each case.


  2. Re: Interpreting XKeyEvent

    Tony O'Bryan wrote:

    > Do I have to do this myself? It's not terribly hard since I already have
    > the switch statement with cases for each key, but I don't want to do that
    > if X already has the facility for getting the ASCII value of the keycode.
    > It would simply be a matter of setting another variable in each case.


    I assumed that I would get a "yes" answer, so I implemented code to
    explicitly track the ASCII range myself.


  3. Re: Interpreting XKeyEvent

    Tony O'Bryan wrote:
    > Here is the basic overview of how I've been using XKeyEvent in my library:
    >
    > 1) Intercept KeyPress event
    >
    > 2) Call a function (I call it translateKeyCode) to translate the
    > event.keycode field into a mapping defined by my program (it's just a big
    > switch statement). This is so I can port my library to other platforms
    > which define keys differently than X.
    >
    > 3) Use the translated keycode in my program.
    >
    > All was good up until now because I only cared about the raw keycode. Now I
    > have a need to get the ASCII value of keys within the ASCII range.
    > However, X does not provide this (which makes sense considering X is
    > multinational).
    >
    > Do I have to do this myself? It's not terribly hard since I already have
    > the switch statement with cases for each key, but I don't want to do that
    > if X already has the facility for getting the ASCII value of the keycode.
    > It would simply be a matter of setting another variable in each case.


    http://tronche.com/gui/x/xlib/utilit...kupString.html

  4. Re: Interpreting XKeyEvent

    Russell Shaw wrote:

    >> Do I have to do this myself? It's not terribly hard since I already have
    >> the switch statement with cases for each key, but I don't want to do that
    >> if X already has the facility for getting the ASCII value of the keycode.
    >> It would simply be a matter of setting another variable in each case.

    >
    > http://tronche.com/gui/x/xlib/utilit...kupString.html


    Thanks for the pointer. Some Google research uncovered XKeycodeToKeysym(),
    which (with some rewritten support code) gets me exactly what I want.


  5. Re: Interpreting XKeyEvent

    In comp.windows.x, Tony O'Bryan

    wrote
    on Mon, 04 Sep 2006 14:27:57 GMT
    :
    > Russell Shaw wrote:
    >
    >>> Do I have to do this myself? It's not terribly hard since I already have
    >>> the switch statement with cases for each key, but I don't want to do that
    >>> if X already has the facility for getting the ASCII value of the keycode.
    >>> It would simply be a matter of setting another variable in each case.

    >>
    >> http://tronche.com/gui/x/xlib/utilit...kupString.html

    >
    > Thanks for the pointer. Some Google research uncovered XKeycodeToKeysym(),
    > which (with some rewritten support code) gets me exactly what I want.
    >


    Especially since the actual keycode is machine-dependent. :-)

    --
    #191, ewill3@earthlink.net
    Windows Vista. Because it's time to refresh your hardware. Trust us.

+ Reply to Thread