#### Archived

This topic is now archived and is closed to further replies.

# keyboard input with Xlib

This topic is 5571 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Ok, so earlier in my post about Gtk, I mentioned trying to make a MessageBox utility function. Well for various reasons, I''m now attempting to use Xlib. But I''m hitting a snag in that for some reason, I can''t get keyboard input to work. Now, I''ve hardly done anything with Xlib, so I''m sure it''s a stupid mistake, but if anyone has any idea what''s wrong, the code is here. Alternatively, does anyone know of any in-depth articles about Xlib? I have only found a very few, and they don''t usually deal with the input so much, but more the graphics and setting up windows, etc. The Artist Formerly Known as CmndrM http://chaos.webhop.org

##### Share on other sites
Google for "Xlib tutorial". You get quite a few good results, though nothing really comprehensive.

Try to get your hands on a postscript version of the Xlib manual. It doesn''t get any more in depth than that.

##### Share on other sites
Yeah, I did Google "Xlib tutorial", and that''s how I got as far as I did. However, none of them that I''ve looked at really talked much about the keyboard input (it was all done in passing), which is the part that I''m having trouble with. I''ll definately be browsing through the manual later, but I don''t know how much that is going to help me out.

The Artist Formerly Known as CmndrM

http://chaos.webhop.org

##### Share on other sites
Well, now I''ve found something interesting out. For whatever reason, if I use the keycode instead of the keysym, I have no problem getting input. But why? It''s kind of a pain in the ass to have to manually find each integer value for the keys I need (luckily in this case there aren''t many).

My guess is it has to do with the index parameter in XLookupKeysym (the second one). But in every example I''ve ever seen, simply 0 is put there, and I can''t actually find anything detailing what exactly the index parameter is or does. Any ideas?

The Artist Formerly Known as CmndrM

http://chaos.webhop.org

##### Share on other sites
I don''t know what''s wrong specificially, but that second parameter has to do with the fact that there''s a many-to-one keysym to keycode relationship, and so the index specifies which of those many is desired.

The relevant sections are 12.7 and 16.1 in the Xlib manual.

##### Share on other sites
Well, with the help of a few people in #xlib on irc.freenode.net, I finally figured it out. It turns out that there are both XK_O and XK_o (for example). For some reason, even when I had the shift key and/or the caps lock on when pressing O (or anything else, for that matter), it didn''t work. While I don''t know why that is, it has been solved by having something like this:

case XK_O:case XK_o: // code here

The Artist Formerly Known as CmndrM

http://chaos.webhop.org

1. 1
Rutin
38
2. 2
3. 3
4. 4
5. 5

• 11
• 9
• 12
• 14
• 9
• ### Forum Statistics

• Total Topics
633350
• Total Posts
3011473
• ### Who's Online (See full list)

There are no registered users currently online

×