/* * $Logfile: /DescentIII/Main/ddio_lnx/lnxkey_xwin.cpp $ * $Revision: 1.1.1.1 $ * $Date: 2000/04/18 00:00:33 $ * $Author: icculus $ * * Linux Xwindows routines * * $Log: lnxkey_xwin.cpp,v $ * Revision 1.1.1.1 2000/04/18 00:00:33 icculus * initial checkin * * * 6 8/19/99 3:45p Jeff * commented out mprintfs * * 5 8/19/99 1:32p Jeff * fixed o key. Added scroll lock, caps lock and print screen keys. * * 4 7/15/99 11:37a Jeff * moved autorepeat calls to lnxapp.cpp * * 3 7/14/99 9:06p Jeff * added comment header * * $NoKeywords: $ */ #include "pserror.h" #include "mono.h" #include "ddio.h" #include "ddio_lnx.h" #include "application.h" #include "../lib/linux/dyna_xwin.h" #include "../lib/linux/dyna_xext.h" //#include //#include #include extern volatile struct tLnxKeys { union{ int up_ticks; float up_time; }; union{ int down_ticks; float down_time; }; bool status; }LKeys[DDIO_MAX_KEYS]; // we need this for our XWindows calls. static Display *X_display = NULL; bool ddio_xwin_InternalKeyInit(ddio_init_info *init_info) { oeLnxApplication *app = (oeLnxApplication *)init_info->obj; X_display = app->m_Display; //reset key list for(int i=0;i= XK_a && rc <= XK_z) { rc = (rc - XK_a)+1; } else if (rc >= XK_A && rc <= XK_Z) { rc = (rc - XK_A)+1; } else { rc = 0; } ASSERT(rc >= 0 && rc <=26); rc = xkey_to_ddiocode[rc]; break; } return (ubyte)rc; } void ddio_xwin_InternalKeyFrame(void) { XEvent evt; // this is the big function. // we'll grab all the keyboard events from the event queue currently // and process them accordingly. while (XCheckMaskEvent(X_display,KeyPressMask|KeyReleaseMask,&evt)) { ubyte kc; switch(evt.type) { case KeyPress: kc = xkeycode_to_keycode(evt.xkey.keycode); LKeys[kc].down_time = timer_GetTime(); LKeys[kc].status = true; ddio_UpdateKeyState(kc, true); //mprintf((0, "key %x down (state=%d).\n", (int)kc, (int)evt.xkey.state)); break; case KeyRelease: kc = xkeycode_to_keycode(evt.xkey.keycode); if (LKeys[kc].status) { LKeys[kc].up_time = timer_GetTime(); LKeys[kc].status = false; ddio_UpdateKeyState(kc, false); //mprintf((0, "key %x up (state=%d).\n", (int)kc, (int)evt.xkey.state)); } break; } } }