home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / X / mit / server / ddx / ibm / AIX / aixKeybd.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-07-16  |  4.7 KB  |  192 lines

  1. /*
  2.  * $XConsortium: aixKeybd.c,v 1.3 91/07/16 13:00:11 jap Exp $
  3.  *
  4.  * Copyright IBM Corporation 1987,1988,1989,1990,1991
  5.  *
  6.  * All Rights Reserved
  7.  *
  8.  * License to use, copy, modify, and distribute this software and its
  9.  * documentation for any purpose and without fee is hereby granted,
  10.  * provided that the above copyright notice appear in all copies and that
  11.  * both that copyright notice and this permission notice appear in
  12.  * supporting documentation, and that the name of IBM not be
  13.  * used in advertising or publicity pertaining to distribution of the
  14.  * software without specific, written prior permission.
  15.  *
  16.  * IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  17.  * ALL IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS, AND 
  18.  * NONINFRINGEMENT OF THIRD PARTY RIGHTS, IN NO EVENT SHALL
  19.  * IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  20.  * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  21.  * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  22.  * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  23.  * SOFTWARE.
  24.  *
  25. */
  26.  
  27. #include <stdio.h>
  28. #include <sys/hft.h>
  29.  
  30. #include "X.h"
  31. #include "aixInput.h"
  32. #include "Xmd.h"
  33. #include "input.h"
  34. #include "miscstruct.h"
  35. #include "scrnintstr.h"
  36. #include "keysym.h"
  37. #include "cursorstr.h"
  38.  
  39. #include "aixKeymap.h"
  40.  
  41. #include "ibmIO.h"
  42. #include "ibmKeybd.h"
  43. #include "ibmScreen.h"
  44.  
  45. #include "hftUtils.h"
  46.  
  47. #include "ibmTrace.h"
  48.  
  49. /***============================================================***/
  50.  
  51. static void
  52. rtChangeKeyboardControl(pDevice,ctrl)
  53.     DevicePtr pDevice;
  54.     KeybdCtrl *ctrl;
  55. {
  56.     int volume;
  57.  
  58.     TRACE(("rtChangeKeyboardControl(pDev=0x%x,ctrl=0x%x)\n",pDevice,ctrl));
  59.  
  60.     ibmKeyClick =   ctrl->click;
  61.     hftSetKeyClick(ctrl->click);
  62.  
  63.     /* X specifies duration in milliseconds, RT in 1/128th's of a second */
  64.     ibmBellPitch=    ctrl->bell_pitch;
  65.     ibmBellDuration=     ((double)ctrl->bell_duration)*(128.0/1000.0);
  66.  
  67.     hftSetLEDS(0x7,(ibmLEDState=ctrl->leds));
  68.  
  69.     if (ibmKeyRepeat= ctrl->autoRepeat)
  70.     hftSetTypematicDelay( 400 );
  71.     else
  72.     hftSetTypematicDelay( 600 );
  73.  
  74.     return;
  75. }
  76.  
  77. /***============================================================***/
  78.  
  79. static void
  80. rtBell(loud, pDevice)
  81.     int loud;
  82.     DevicePtr pDevice;
  83. {
  84.  
  85.     TRACE(("rtBell(loud= %d, pDev= 0x%x)\n",loud,pDevice));
  86.     hftSound(loud,ibmBellDuration,ibmBellPitch);
  87.     return;
  88. }
  89.  
  90. /***============================================================***/
  91.  
  92. Bool LegalModifier (key)
  93.  
  94.     BYTE    key;
  95. {
  96.     TRACE(("LegalModifier(key= 0x%x)\n",key));
  97.     if ( (key==Aix_Control_L) || (key==Aix_Shift_L) || (key==Aix_Shift_R) ||
  98.     (key==Aix_Caps_Lock) || (key==Aix_Alt_L) || (key==Aix_Alt_R) ||
  99.         (key==Aix_Num_Lock) )
  100.       return TRUE ;
  101.     else
  102.       return FALSE;
  103. }
  104.  
  105. /***============================================================***/
  106.  
  107. extern int ibmUsePCKeys;
  108. int kbdType ;
  109.  
  110. rtGetKbdMappings(pKeySyms, pModMap)
  111. KeySymsPtr pKeySyms;
  112. CARD8 *pModMap;
  113. {
  114.     register int i;
  115.     TRACE(("rtGetKbdMappings( pKeySyms= 0x%x, pModMap= 0x%x )\n",
  116.                             pKeySyms,pModMap));
  117.     for (i = 0; i < MAP_LENGTH; i++)
  118.        pModMap[i] = NoSymbol;
  119.  
  120.     if (ibmUsePCKeys) {
  121.     pModMap[ Aix_Control_L ] = LockMask;
  122.     pModMap[ Aix_Caps_Lock ] = ControlMask;
  123.     }
  124.     else {
  125.     pModMap[ Aix_Caps_Lock ] = LockMask;
  126.     pModMap[ Aix_Control_L ] = ControlMask;
  127.     }
  128.  
  129.     pModMap[ Aix_Shift_L ] = ShiftMask;
  130.     pModMap[ Aix_Shift_R ] = ShiftMask;
  131.     pModMap[ Aix_Num_Lock ] = NumLockMask;
  132.  
  133.     switch ( kbdType = hftGetKeyboardID() )
  134.     {
  135.     case HF101KBD :
  136.        pModMap[ Aix_Alt_L ] = Mod1Mask;
  137.        pModMap[ Aix_Alt_R ] = Mod1Mask;
  138.     break;
  139.     case HF102KBD :
  140.        pModMap[ Aix_Alt_L ] = Mod1Mask;
  141.        pModMap[ Aix_Alt_R ] = Mod2Mask;
  142.     break;
  143.     case HF106KBD :
  144.        pModMap[ Aix_Alt_R ] = Mod1Mask;
  145.     case HFT_ILLEGAL_KEYBOARD:
  146.     default :
  147.        pModMap[ Aix_Alt_L ] = Mod1Mask;
  148.        pModMap[ Aix_Alt_R ] = Mod1Mask;
  149.     break;
  150.     }
  151.  
  152.     pKeySyms->minKeyCode=       AIX_MIN_KEY;
  153.     pKeySyms->maxKeyCode=       AIX_MAX_KEY;
  154.     pKeySyms->mapWidth=         AIX_GLYPHS_PER_KEY;
  155.     pKeySyms->map=              aixmap;
  156. }
  157.  
  158. /***============================================================***/
  159.  
  160. int
  161. AIXKeybdProc(pDev, onoff, argc, argv)
  162.     DevicePtr      pDev;
  163.     int      onoff;
  164.     int         argc;
  165.     char    *argv[];
  166. {
  167.     KeySymsRec        keySyms;
  168.     CARD8         modMap[MAP_LENGTH];
  169.  
  170.     TRACE(("AIXKeybdProc( pDev= 0x%x, onoff= 0x%x )\n",pDev,onoff));
  171.  
  172.     switch (onoff)
  173.     {
  174.     case DEVICE_INIT: 
  175.         ibmKeybd = pDev;
  176.         rtGetKbdMappings( &keySyms, modMap );
  177.         InitKeyboardDeviceStruct(
  178.             ibmKeybd, &keySyms, modMap, rtBell,
  179.             rtChangeKeyboardControl);
  180.         break;
  181.     case DEVICE_ON: 
  182.         pDev->on = TRUE;
  183.         break;
  184.     case DEVICE_OFF: 
  185.         pDev->on = FALSE;
  186.         break;
  187.     case DEVICE_CLOSE:
  188.         break;
  189.     }
  190.     return Success;
  191. }
  192.