Key Converter

This is a discussion on Key Converter within the C Programming forums, part of the General Programming Boards category; I have recently switched to the DVORAK keyboard layout, and find it quite pleasing. I have derided to stick with ...

  1. #1
    Registered User
    Join Date
    May 2005
    Posts
    13

    Key Converter

    I have recently switched to the DVORAK keyboard layout, and find it quite pleasing. I have derided to stick with it. This is where the programming comes in.

    I use the computers allot at school, and ofcorse like every other place on the planet, use QWERTY keyboards. I am still pretty new to C, but decided to I want to tackle a key converter to convert QWERTY keystrokes to DVORAK keystrokes, thus letting me use DVORAK at school. I however am a little stumped.

    How would I go about getting keystrokes from the input buffer for the entire system, as they are hit, and then how would I place them back it the input buffer for whichever application that has focus to grab, without disturbind the processs of getting the next key?

    This is obviously the most important part of the program, as without it, it dosn't do what I want it too.

    Got any ideas?

  2. #2
    Sr. Software Engineer filker0's Avatar
    Join Date
    Sep 2005
    Location
    West Virginia
    Posts
    235
    This is very system dependent. In windows, you'd set up a keyboard hook and translate the scan codes as they come in. In X-Windows, you do something very similar, though there are easier ways to do it in X-Windws (just set up a keymap, load it, and let the existing keyboard handling do the magic for you). I suspect that it is possible to load alternative keymaps for the Linux console as well, but I'm not sure how to do it. Dvorak keyboards are sufficiently well known that there may be some way already provided in the linux distro to switch to that layout.

    This, at the heart of it, is not a C programming question, but a Linux and Windows programming question, and since the solution for each of those platforms will be quite different, it is probably best asked in one of the non-language specific tech boards (so you don't have to ask it in multiple places.) Once you know how it is done, then you can ask language specific questions (like "How do I set up a mapping from one set of non-contiguous integers to another set?").

    Good luck with it.

    [edit]
    For Linux, the loadkeys command lets you load the kernel keymap. Read the loadkeys manpage, along with the man pages that it lists in its "see also" section.
    [/edit]
    Last edited by filker0; 02-02-2006 at 04:50 PM. Reason: Add newly found information
    Insert obnoxious but pithy remark here

  3. #3
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    In XP: Control Panel->Regional and Language Options->Languages Tab->Details...->Add->United States-Dvorak

    You can set this as the default or define a key sequence to switch between input layouts.

  4. #4
    Registered User
    Join Date
    May 2005
    Posts
    13
    Quote Originally Posted by filker0
    This is very system dependent. In windows, you'd set up a keyboard hook and translate the scan codes as they come in. In X-Windows, you do something very similar, though there are easier ways to do it in X-Windws (just set up a keymap, load it, and let the existing keyboard handling do the magic for you). I suspect that it is possible to load alternative keymaps for the Linux console as well, but I'm not sure how to do it. Dvorak keyboards are sufficiently well known that there may be some way already provided in the linux distro to switch to that layout.
    I figured i would be OS dependant. But it dosn't affect me that much, as I really only need this for the windows (98/xp) OS. The only place I run Linux is at home, and I have controll over everything here. I was told before I posted here to look up hooks in C, as they ore used in keyloggers, and may have relavance. I however didn't see allot with my search, and still am not sure how I would go about using them for this.

    Quote Originally Posted by filker0
    This, at the heart of it, is not a C programming question, but a Linux and Windows programming question, and since the solution for each of those platforms will be quite different, it is probably best asked in one of the non-language specific tech boards (so you don't have to ask it in multiple places.) Once you know how it is done, then you can ask language specific questions (like "How do I set up a mapping from one set of non-contiguous integers to another set?").
    I am not sure why you say it should be posted in a non language specific forum. It could be done hundreds of different ways in many languages, but I am trying to figure out how to do it in C for windows. Maybe I am over looking somthing.

    Quote Originally Posted by filker0
    [edit]
    For Linux, the loadkeys command lets you load the kernel keymap. Read the loadkeys manpage, along with the man pages that it lists in its "see also" section.
    [/edit]
    I will keep that in mind if I ever want to do somthing similar for linux.

    Quote Originally Posted by anonytmouse
    In XP: Control Panel->Regional and Language Options->Languages Tab->Details...->Add->United States-Dvorak

    You can set this as the default or define a key sequence to switch between input layouts.
    Not what I was looking for. I am wanting to program this for use on systems where I do not have access to those panels. Plus it is a nice learning expierence.

  5. #5
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,262
    Not what I was looking for. I am wanting to program this for use on systems where I do not have access to those panels.
    Setting global hooks in Windows requires administrator privileges.

  6. #6
    old man
    Join Date
    Dec 2005
    Posts
    90
    Quote Originally Posted by bithub
    Setting global hooks in Windows requires administrator privileges.
    Isn't there a user profile? I'd expect to find a keyboard layout option there. (I'm not usually an mswin user, so I could easily be wrong.)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 16
    Last Post: 11-23-2007, 01:48 PM
  2. Virtual keys
    By Arkanos in forum Windows Programming
    Replies: 4
    Last Post: 12-12-2005, 10:00 AM
  3. Directional Keys - Useing in Console
    By RoD in forum C++ Programming
    Replies: 38
    Last Post: 10-06-2002, 05:42 PM
  4. FAQ: Directional Keys - Useing in Console
    By RoD in forum FAQ Board
    Replies: 38
    Last Post: 10-06-2002, 05:42 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21