home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-385-Vol-1of3.iso / x / xibm.zip / AIX / aixKeybd.c < prev    next >
C/C++ Source or Header  |  1991-09-20  |  5KB  |  217 lines

  1. /*
  2.  * $Id: aixKeybd.c,v 1.1 1991/09/20 17:58:56 mtranle Exp $
  3.  *
  4.  * Copyright IBM Corporation 1987,1988,1989
  5.  *
  6.  * All Rights Reserved
  7.  *
  8.  * Permission 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 AND FITNESS, IN NO EVENT SHALL
  18.  * IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  19.  * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  20.  * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  21.  * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  22.  * SOFTWARE.
  23.  *
  24. */
  25.  
  26. /* @(#)aixKeybd.c    3.6 88/10/03 10:01:20 */
  27.  
  28. #include <stdio.h>
  29. #include <sys/file.h>
  30. #include <sys/types.h>
  31. #include <sys/hft.h>
  32.  
  33. #include "X.h"
  34. #include "Xmd.h"
  35. #include "input.h"
  36. #include "miscstruct.h"
  37. #include "scrnintstr.h"
  38. #include "keysym.h"
  39. #include "cursorstr.h"
  40.  
  41. #include "aixModKeys.h"
  42. #include "aixKeymap.h"
  43.  
  44. #include "ibmIO.h"
  45. #include "ibmKeybd.h"
  46. #include "ibmScreen.h"
  47.  
  48. #include "hftUtils.h"
  49.  
  50. #include "ibmTrace.h"
  51.  
  52. /***============================================================***/
  53.  
  54. static void
  55. AIXChangeKeyboardControl(pDevice,ctrl)
  56.     DevicePtr pDevice;
  57.     KeybdCtrl *ctrl;
  58. {
  59.     int volume;
  60.  
  61.     TRACE(("AIXChangeKeyboardControl(pDev=0x%x,ctrl=0x%x)\n",pDevice,ctrl));
  62.  
  63.     ibmKeyClick =   ctrl->click;
  64.     hftSetKeyClick(ctrl->click);
  65.  
  66.     /* X specifies duration in milliseconds, RT in 1/128th's of a second */
  67.     ibmBellPitch=    ctrl->bell_pitch;
  68.     ibmBellDuration=     ((double)ctrl->bell_duration)*(128.0/1000.0);
  69.  
  70.     hftSetLEDS(0x7,(ibmLEDState=ctrl->leds));
  71.  
  72.     if (ibmKeyRepeat= ctrl->autoRepeat)
  73.     hftSetTypematicDelay( 400 );
  74.     else
  75.     hftSetTypematicDelay( 600 );
  76.  
  77.     return;
  78. }
  79.  
  80. /***============================================================***/
  81.  
  82. static void
  83. AIXBell(loud, pDevice)
  84.     int loud;
  85.     DevicePtr pDevice;
  86. {
  87.  
  88.     TRACE(("AIXBell(loud= %d, pDev= 0x%x)\n",loud,pDevice));
  89.     hftSound(loud,ibmBellDuration,ibmBellPitch);
  90.     return;
  91. }
  92.  
  93. /***============================================================***/
  94.  
  95. Bool 
  96. LegalModifier (key)
  97. BYTE    key;
  98. {
  99.  
  100.     TRACE(("LegalModifier(key= 0x%x)\n",key));
  101.     if ((key==Aix_Control_L) || (key==Aix_Shift_L) || (key==Aix_Shift_R) ||
  102.     (key==Aix_Caps_Lock) || (key==Aix_Alt_L) || (key==Aix_Alt_R))
  103.       return TRUE ;
  104. #ifdef notdef
  105. #if defined(AIXps2) 
  106.     else if (key==Aix_Control_R)
  107.       return TRUE;
  108. #endif
  109. #endif
  110.     else
  111.       return FALSE;
  112. }
  113.  
  114. /***============================================================***/
  115.  
  116. extern int ibmUsePCKeys;
  117. int kbdType ;
  118.  
  119. AIXGetKbdMappings(pKeySyms, pModMap)
  120. KeySymsPtr pKeySyms;
  121. CARD8 *pModMap;
  122. {
  123.     int i;
  124.     TRACE(("AIXGetKbdMappings( pKeySyms= 0x%x, pModMap= 0x%x )\n",
  125.                             pKeySyms,pModMap));
  126.     for (i = 0; i < MAP_LENGTH; i++)
  127.        pModMap[i] = NoSymbol;
  128.  
  129.     if (ibmUsePCKeys) {
  130.     pModMap[ Aix_Control_L ] = LockMask;
  131.     pModMap[ Aix_Caps_Lock ] = ControlMask;
  132.     }
  133.     else {
  134.     pModMap[ Aix_Caps_Lock ] = LockMask;
  135.     pModMap[ Aix_Control_L ] = ControlMask;
  136.     }
  137.  
  138.     /*
  139.      * 12/27/88 (ef) -- XXX!  Someday we should set this based on
  140.      *    a keyboard id, not on the operating system/processor.
  141.      *    (assuming the hft provides different keyboard id's for
  142.      *    the RT and 386 keyboards)
  143.      */
  144. #ifdef notdef
  145. #if defined(AIXps2) 
  146.     pModMap[ Aix_Control_R ] =    ControlMask;
  147. #endif
  148. #endif
  149.     pModMap[ Aix_Shift_L ] =    ShiftMask;
  150.     pModMap[ Aix_Shift_R ] =    ShiftMask;
  151.     pModMap[ Aix_Num_Lock ] =    NumLockMask;
  152.  
  153.     /*
  154.      * Theses define's should be removed once they are in 
  155.      * /usr/include/sys/hft.h.
  156.      */
  157. #define HF101KBD 0
  158. #define HF102KBD 1
  159.  
  160.     switch ( kbdType = hftGetKeyboardID() )
  161.     {
  162.     case HF101KBD :
  163.        pModMap[ Aix_Alt_L ] = Mod1Mask;
  164.        pModMap[ Aix_Alt_R ] = Mod1Mask;
  165.     break;
  166.     case HF102KBD :
  167.        pModMap[ Aix_Alt_L ] = Mod1Mask;
  168.        pModMap[ Aix_Alt_R ] = Mod2Mask;
  169.     break;
  170.     case HFT_ILLEGAL_KEYBOARD:
  171.     default :
  172.        pModMap[ Aix_Alt_L ] = Mod1Mask;
  173.        pModMap[ Aix_Alt_R ] = Mod1Mask;
  174.     break;
  175.     }
  176.  
  177.     pKeySyms->minKeyCode=       AIX_MIN_KEY;
  178.     pKeySyms->maxKeyCode=       AIX_MAX_KEY;
  179.     pKeySyms->mapWidth=         AIX_GLYPHS_PER_KEY;
  180.     pKeySyms->map=              aixmap;
  181. }
  182.  
  183. /***============================================================***/
  184.  
  185. int
  186. AIXKeybdProc(pDev, onoff, argc, argv)
  187.     DevicePtr      pDev;
  188.     int      onoff;
  189.     int         argc;
  190.     char    *argv[];
  191. {
  192.     KeySymsRec        keySyms;
  193.     CARD8         modMap[MAP_LENGTH];
  194.  
  195.     TRACE(("AIXKeybdProc( pDev= 0x%x, onoff= 0x%x )\n",pDev,onoff));
  196.  
  197.     switch (onoff)
  198.     {
  199.     case DEVICE_INIT: 
  200.         ibmKeybd = pDev;
  201.         AIXGetKbdMappings( &keySyms, modMap );
  202.         InitKeyboardDeviceStruct(
  203.             ibmKeybd, &keySyms, modMap, AIXBell,
  204.             AIXChangeKeyboardControl);
  205.         break;
  206.     case DEVICE_ON: 
  207.         pDev->on = TRUE;
  208.         break;
  209.     case DEVICE_OFF: 
  210.         pDev->on = FALSE;
  211.         break;
  212.     case DEVICE_CLOSE:
  213.         break;
  214.     }
  215.     return Success;
  216. }
  217.