Making special keyboard "driver" - Xwindows

This is a discussion on Making special keyboard "driver" - Xwindows ; I would like to use my keyboard as follows: sequences of a small subset of the keys will be used to simulate pressing every key on the keyboard Can someone point me to where I can learn more about implementing ...

+ Reply to Thread
Results 1 to 11 of 11

Thread: Making special keyboard "driver"

  1. Making special keyboard "driver"

    I would like to use my keyboard as follows:

    sequences of a small subset of the keys will be used to simulate
    pressing
    every key on the keyboard

    Can someone point me to where I can learn more about implementing a
    "driver"
    like this for X11?

    Mike


  2. Re: Making special keyboard "driver"

    michaelmossey@yahoo.com writes:

    > I would like to use my keyboard as follows:
    >
    > sequences of a small subset of the keys will be used to simulate
    > pressing
    > every key on the keyboard
    >
    > Can someone point me to where I can learn more about implementing a
    > "driver"
    > like this for X11?


    The normal mechanism for mapping several keystrokes to one character
    is Compose. Searching your system you will probably find Compose-files
    for various locales. Constructing your own Compose file from these
    examples should not be very hard. The file is used by the application
    (through the use of Xlib).

    From XFree 4.4 or XOrg 6.8.2 the mechanism for the application to find
    a Compose file were extended to the following:

    1. If the environment variable $XCOMPOSEFILE is set, its value is used as
    the name of the Compose file.

    2. If the user's home directory has a file named ".XCompose", it is used
    as the Compose file.

    3. The old method is used, and the compose file is "/ name>/Compose".

    --
    - Mårten

    mail: msv@kth.se *** ICQ: 4356928 *** mobile: +46 (0)707390385

  3. Re: Making special keyboard "driver"


    Mårten Svantesson wrote:
    > michaelmossey@yahoo.com writes:
    >
    > > I would like to use my keyboard as follows:
    > >
    > > sequences of a small subset of the keys will be used to simulate
    > > pressing
    > > every key on the keyboard
    > >
    > > Can someone point me to where I can learn more about implementing a
    > > "driver"
    > > like this for X11?

    >
    > The normal mechanism for mapping several keystrokes to one character
    > is Compose. Searching your system you will probably find Compose-files
    > for various locales. Constructing your own Compose file from these
    > examples should not be very hard. The file is used by the application
    > (through the use of Xlib).



    Hello,

    Thanks for the information. What I want to do is actually considerably
    more complicated than simply mapping several keystrokes to a character.
    I'm trying to implement a type of "chording" on a normal keyboard by
    recognizing temporally (time) grouped keystrokes. They will not arrive
    in any fixed order. I am pretty sure I will have to code this myself at
    a low level. Can you give me any pointers at this level?

    Mike


    >
    > From XFree 4.4 or XOrg 6.8.2 the mechanism for the application to find
    > a Compose file were extended to the following:
    >
    > 1. If the environment variable $XCOMPOSEFILE is set, its value is usedas
    > the name of the Compose file.
    >
    > 2. If the user's home directory has a file named ".XCompose", it is used
    > as the Compose file.
    >
    > 3. The old method is used, and the compose file is "/ > name>/Compose".
    >
    > --
    > - Mårten
    >
    > mail: msv@kth.se *** ICQ: 4356928 *** mobile: +46 (0)707390385



  4. Re: Making special keyboard "driver"

    michaelmossey@yahoo.com writes:

    > Mårten Svantesson wrote:
    >> michaelmossey@yahoo.com writes:
    >>
    >> > I would like to use my keyboard as follows:
    >> >
    >> > sequences of a small subset of the keys will be used to simulate
    >> > pressing
    >> > every key on the keyboard
    >> >
    >> > Can someone point me to where I can learn more about implementing a
    >> > "driver"
    >> > like this for X11?

    >>
    >> The normal mechanism for mapping several keystrokes to one character
    >> is Compose. Searching your system you will probably find Compose-files
    >> for various locales. Constructing your own Compose file from these
    >> examples should not be very hard. The file is used by the application
    >> (through the use of Xlib).

    >
    >
    > Hello,
    >
    > Thanks for the information. What I want to do is actually considerably
    > more complicated than simply mapping several keystrokes to a character.
    > I'm trying to implement a type of "chording" on a normal keyboard by
    > recognizing temporally (time) grouped keystrokes. They will not arrive
    > in any fixed order.


    You mean you can't simply insert the different possible orders in the
    Compose file? Sure, they might be many but it would be considerably
    easier that writing you own keyboard driver.

    > I am pretty sure I will have to code this myself at
    > a low level. Can you give me any pointers at this level?


    It seems to that if the Compose mechanism isn't enough then you could
    make an keyboard input server. There are several standards for these.
    I seems like the upcoming star is IIIMF - Internet Intranet Input
    Method Framework¹. Here you make a input method working the way you
    want. See
    http://www.openi18n.org/modules.php?...tid=100&page=1

    However, to use this the application needs to be prepared to use the
    server. Many programs are...

    --------------
    ¹ http://www.openi18n.org/modules.php?...rtid=30&page=1

    --
    - Mårten

    mail: msv@kth.se *** ICQ: 4356928 *** mobile: +46 (0)707390385

  5. Re: Making special keyboard "driver"

    On Fri, 26 Aug 2005 12:33:19 -0700, michaelmossey wrote:

    > Hello,
    >
    > Thanks for the information. What I want to do is actually considerably
    > more complicated than simply mapping several keystrokes to a character.
    > I'm trying to implement a type of "chording" on a normal keyboard by
    > recognizing temporally (time) grouped keystrokes. They will not arrive
    > in any fixed order. I am pretty sure I will have to code this myself at
    > a low level. Can you give me any pointers at this level?



    Your program could connect to the server as usual, and send XTest events.
    This is how virtual keyboards for touch screens work. There are some
    issues in getting it "right".

    If you want to sent an "A" how do you do it?

    Sending the keycode 38 (the "a" key on my system) will generate a
    lowercase a. In order to generate an uppercase `a', you could examine the
    mapping, send the relavent modifier keypress, then the `a' press and
    release, then the modifier release.

    A simpler hack (which I use) is to map a spare keycode to the keysym, and
    then send that keycode as a XTest event. This works fine for all normal
    keys, but you couldn't (for instance) properly emulate pressing of Lock
    correctly, since that keycode won't be in the modifier map. To this
    properly, you would have to alter the modifier map, or examine it so you
    could send the correct keycode (I never bothered with this part).

    If you need more information, then let me know, and I can dig out the code
    I have that does this.

    -Ed



    --
    (You can't go wrong with psycho-rats.) (er258)(@)(eng.cam)(.ac.uk)

    /d{def}def/f{/Times findfont s scalefont setfont}d/s{10}d/r{roll}d f 5/m
    {moveto}d -1 r 230 350 m 0 1 179{1 index show 88 rotate 4 mul 0 rmoveto}
    for /s 15 d f pop 240 420 m 0 1 3 { 4 2 1 r sub -1 r show } for showpage


  6. Re: Making special keyboard "driver"


    Mårten Svantesson wrote:
    > michaelmossey@yahoo.com writes:
    >
    > > Mårten Svantesson wrote:
    > >> michaelmossey@yahoo.com writes:
    > >>
    > >> > I would like to use my keyboard as follows:
    > >> >
    > >> > sequences of a small subset of the keys will be used to simulate
    > >> > pressing
    > >> > every key on the keyboard
    > >> >
    > >> > Can someone point me to where I can learn more about implementing a
    > >> > "driver"
    > >> > like this for X11?
    > >>
    > >> The normal mechanism for mapping several keystrokes to one character
    > >> is Compose. Searching your system you will probably find Compose-files
    > >> for various locales. Constructing your own Compose file from these
    > >> examples should not be very hard. The file is used by the application
    > >> (through the use of Xlib).

    > >
    > >
    > > Hello,
    > >
    > > Thanks for the information. What I want to do is actually considerably
    > > more complicated than simply mapping several keystrokes to a character.
    > > I'm trying to implement a type of "chording" on a normal keyboard by
    > > recognizing temporally (time) grouped keystrokes. They will not arrive
    > > in any fixed order.

    >
    > You mean you can't simply insert the different possible orders in the
    > Compose file? Sure, they might be many but it would be considerably
    > easier that writing you own keyboard driver.


    Well, I need to group the keys by time of arrival. Some key sequences
    will share the first N characters, but have different overall lengths,
    so they can't be distinguished by the arrival sequence alone. Is this
    possible in a Compose file?


    >
    > > I am pretty sure I will have to code this myself at
    > > a low level. Can you give me any pointers at this level?

    >
    > It seems to that if the Compose mechanism isn't enough then you could
    > make an keyboard input server. There are several standards for these.
    > I seems like the upcoming star is IIIMF - Internet Intranet Input
    > Method Framework¹. Here you make a input method working the way you
    > want. See
    > http://www.openi18n.org/modules.php?...tid=100&page=1
    >
    > However, to use this the application needs to be prepared to use the
    > server. Many programs are...


    Okay, thanks for the info.

    Mike


    >
    > --------------
    > ¹ http://www.openi18n.org/modules.php?...rtid=30&page=1
    >
    > --
    > - Mårten
    >
    > mail: msv@kth.se *** ICQ: 4356928 *** mobile: +46 (0)707390385



  7. Re: Making special keyboard "driver"


    E. Rosten wrote:
    > On Fri, 26 Aug 2005 12:33:19 -0700, michaelmossey wrote:
    >
    > > Hello,
    > >
    > > Thanks for the information. What I want to do is actually considerably
    > > more complicated than simply mapping several keystrokes to a character.
    > > I'm trying to implement a type of "chording" on a normal keyboard by
    > > recognizing temporally (time) grouped keystrokes. They will not arrive
    > > in any fixed order. I am pretty sure I will have to code this myself at
    > > a low level. Can you give me any pointers at this level?

    >
    >
    > Your program could connect to the server as usual, and send XTest events.
    > This is how virtual keyboards for touch screens work. There are some
    > issues in getting it "right".
    >
    > If you want to sent an "A" how do you do it?
    >
    > Sending the keycode 38 (the "a" key on my system) will generate a
    > lowercase a. In order to generate an uppercase `a', you could examine the
    > mapping, send the relavent modifier keypress, then the `a' press and
    > release, then the modifier release.
    >
    > A simpler hack (which I use) is to map a spare keycode to the keysym,


    What is the difference between a keycode and a kysym, if I may ask?

    > and
    > then send that keycode as a XTest event. This works fine for all normal
    > keys, but you couldn't (for instance) properly emulate pressing of Lock
    > correctly, since that keycode won't be in the modifier map. To this
    > properly, you would have to alter the modifier map, or examine it so you
    > could send the correct keycode (I never bothered with this part).
    >
    > If you need more information, then let me know, and I can dig out the code
    > I have that does this.


    Sure, I'd be interested. In essence, I need to recognize time-grouped
    keystrokes. I don't need to send a caps lock to the rest of the system;
    such a function would be handled at the level of my own decoding
    mechanism. That is, if I recognize the "chord" for caps lock, then I
    will send all subsequent keys as shift-modified. If your code will help
    me do this, then sure, I'm interested.

    Mike


    >
    > -Ed
    >
    >
    >
    > --
    > (You can't go wrong with psycho-rats.) (er258)(@)(eng.cam)(.ac.uk)
    >
    > /d{def}def/f{/Times findfont s scalefont setfont}d/s{10}d/r{roll}d f 5/m
    > {moveto}d -1 r 230 350 m 0 1 179{1 index show 88 rotate 4 mul 0 rmoveto}
    > for /s 15 d f pop 240 420 m 0 1 3 { 4 2 1 r sub -1 r show } for showpage



  8. Re: Making special keyboard "driver"

    On Wed, 31 Aug 2005 09:59:52 -0700, michaelmossey wrote:


    >> A simpler hack (which I use) is to map a spare keycode to the keysym,

    >
    > What is the difference between a keycode and a kysym, if I may ask?


    You may :-)

    A keycode is a low level code sent by the keyboard (in truth, lighly
    mangled by the kernel). Keycodes are simply a number corresponding to the
    key pressed, so there is no concept of modifiers etc.

    The keysym is a higher level abstraction of X which corresponds to the cap
    on top of the key, so "A" and "a" have different keysyms. There is a map
    which converts keycodes to keysyms: and the presence of modifiers
    effectively cause a different map to be used.

    For more information, run xev and look at the out put when you type A or a
    in the xev window.


    >> and
    >> then send that keycode as a XTest event. This works fine for all normal
    >> keys, but you couldn't (for instance) properly emulate pressing of Lock
    >> correctly, since that keycode won't be in the modifier map. To this
    >> properly, you would have to alter the modifier map, or examine it so
    >> you could send the correct keycode (I never bothered with this part).
    >>
    >> If you need more information, then let me know, and I can dig out the
    >> code I have that does this.

    >
    > Sure, I'd be interested. In essence, I need to recognize time-grouped
    > keystrokes. I don't need to send a caps lock to the rest of the system;
    > such a function would be handled at the level of my own decoding
    > mechanism. That is, if I recognize the "chord" for caps lock, then I
    > will send all subsequent keys as shift-modified. If your code will help
    > me do this, then sure, I'm interested.


    Sure. This is a program which recognises "strokes" (using libstroke) and
    generates a keysym corresponding to the stroke. As a result, I can write
    using a pen on a tablet PC. The X frontend is almost exactly what you need.

    http://mi.eng.cam.ac.uk/~er258/code/x11/index.html

    look at scribe.

    It's in C++, but it's 99% C.

    -Ed

    --
    (You can't go wrong with psycho-rats.) (er258)(@)(eng.cam)(.ac.uk)

    /d{def}def/f{/Times findfont s scalefont setfont}d/s{10}d/r{roll}d f 5/m
    {moveto}d -1 r 230 350 m 0 1 179{1 index show 88 rotate 4 mul 0 rmoveto}
    for /s 15 d f pop 240 420 m 0 1 3 { 4 2 1 r sub -1 r show } for showpage


  9. Re: Making special keyboard "driver"


    >
    > Sure. This is a program which recognises "strokes" (using libstroke) and
    > generates a keysym corresponding to the stroke. As a result, I can write
    > using a pen on a tablet PC. The X frontend is almost exactly what you need.
    >
    > http://mi.eng.cam.ac.uk/~er258/code/x11/index.html


    Okay, thanks. Is this a semi-permanent link? (that is, can I just save
    this as a bookmark, or should I grab the data off it)

    >
    > look at scribe.
    >
    > It's in C++, but it's 99% C.
    >
    > -Ed
    >
    > --
    > (You can't go wrong with psycho-rats.)


    I'm not sure what your signature means, but I have pet rats. I'm very
    fond of the little guys. Most people don't know that rats are very
    smart, loving pets that beg for human attention.

    Mike


  10. Re: Making special keyboard "driver"

    On Thu, 01 Sep 2005 13:33:56 -0700, michaelmossey wrote:

    >> http://mi.eng.cam.ac.uk/~er258/code/x11/index.html

    >
    > Okay, thanks. Is this a semi-permanent link? (that is, can I just save
    > this as a bookmark, or should I grab the data off it)


    Yep, semi permeant. When I move, I should be able to put up a more
    permenant redirect, but that won't be for a while, anyway.


    > I'm not sure what your signature means,


    That's generally the idea :-)

    Also, try copying the signature from -- downwards (not including the --)
    and view it in your facourite postscript viewer.

    > but I have pet rats. I'm very
    > fond of the little guys. Most people don't know that rats are very
    > smart, loving pets that beg for human attention.


    I do like rats. I also like my tagline. A man said it to me once. It stuck
    in my mind.


    -Ed

    --
    (You can't go wrong with psycho-rats.) (er258)(@)(eng.cam)(.ac.uk)

    /d{def}def/f{/Times findfont s scalefont setfont}d/s{10}d/r{roll}d f 5/m
    {moveto}d -1 r 230 350 m 0 1 179{1 index show 88 rotate 4 mul 0 rmoveto}
    for /s 15 d f pop 240 420 m 0 1 3 { 4 2 1 r sub -1 r show } for showpage


  11. Re: Making special keyboard "driver"

    michaelmossey@yahoo.com writes:

    > Well, I need to group the keys by time of arrival. Some key sequences
    > will share the first N characters, but have different overall lengths,
    > so they can't be distinguished by the arrival sequence alone. Is this
    > possible in a Compose file?


    If I understand you correctly, no.

    You can't have a combination of characters that is a prefix of
    another, say a+b+c and a+b+c+d.

    But you could distinguish between a+b+c+d, a+b+c+e+f and a+b+c+e+g.

    --
    - Mårten

    mail: msv@kth.se *** ICQ: 4356928 *** mobile: +46 (0)707390385

+ Reply to Thread