#Translate key input.
--- xtux-0.2.030306.orig/src/client/input.c
+++ xtux-0.2.030306/src/client/input.c
@@ -242,10 +242,54 @@
}
+int get_translated_key(void)
+{
+ XEvent event;
+ KeySym ks;
+ int key, pressed;
+ static int shift = 0;
+ char keybuf[8];
+
+ while( XPending(win.d) ) {
+ XNextEvent(win.d, &event);
+ if( event.type == GraphicsExpose || event.type == Expose ) {
+ win.dirty = 1;
+ continue;
+ }
+
+ if( event.type == KeyPress )
+ pressed = 1;
+ else if( event.type == KeyRelease )
+ pressed = 0;
+ else
+ continue; /* Not a keypress or a release */
+
+ key = XLookupKeysym(&event.xkey, 0);
+ if( key == XK_Shift_L || key == XK_Shift_R ) {
+ shift = pressed;
+ continue;
+ }
+
+ if( pressed ) {
+ XLookupString( &event.xkey, keybuf, 8, &ks, NULL );
+ if( (int)keybuf[0] < 32 )
+ return key;
+ else
+ return (int)keybuf[0];
+ } else
+ continue; /* Don't return key releases */
+
+ }
+
+ return XK_VoidSymbol;
+
+}
+
+
void textentry_key_handle(int key, int action)
{
- while( (key = get_key()) != XK_VoidSymbol ) {
+ while( (key = get_translated_key()) != XK_VoidSymbol ) {
if( key == XK_BackSpace || key == XK_Delete ) {
if( textentry_pos > 0 ) {
textentry_input_buffer[--textentry_pos] = '\0';
--- xtux-0.2.030306.orig/src/client/menu.c
+++ xtux-0.2.030306/src/client/menu.c
@@ -1287,7 +1287,7 @@
while( get_key() != XK_VoidSymbol )
;
- while( (key = get_key()) != XK_Return && i < MAX_INPUT_SIZE ) {
+ while( (key = get_translated_key()) != XK_Return && i < MAX_INPUT_SIZE ) {
if( key != XK_VoidSymbol ) {
switch( key ) {
/* Delete a key */
--- xtux-0.2.030306.orig/src/client/input.h
+++ xtux-0.2.030306/src/client/input.h
@@ -35,3 +35,4 @@
byte get_input(void);
void input_clear(void);
int get_key(void);
+int get_translated_key(void);