home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 2 BBS / 02-BBS.zip / BSRC_250.LZH / KEYMAP.C < prev    next >
C/C++ Source or Header  |  1991-09-15  |  5KB  |  108 lines

  1. /*--------------------------------------------------------------------------*/
  2. /*                                                                          */
  3. /*                                                                          */
  4. /*      ------------         Bit-Bucket Software, Co.                       */
  5. /*      \ 10001101 /         Writers and Distributors of                    */
  6. /*       \ 011110 /          Freely Available<tm> Software.                 */
  7. /*        \ 1011 /                                                          */
  8. /*         ------                                                           */
  9. /*                                                                          */
  10. /*  (C) Copyright 1987-91, Bit Bucket Software Co., a Delaware Corporation. */
  11. /*                                                                          */
  12. /*                                                                          */
  13. /*                This module was written by Greylock Software              */
  14. /*                                                                          */
  15. /*                                                                          */
  16. /*                        Keyboard Remapping Routine                        */
  17. /*                                                                          */
  18. /*                                                                          */
  19. /*    For complete  details  of the licensing restrictions, please refer    */
  20. /*    to the License  agreement,  which  is published in its entirety in    */
  21. /*    the MAKEFILE and BT.C, and also contained in the file LICENSE.250.    */
  22. /*                                                                          */
  23. /*    USE  OF THIS FILE IS SUBJECT TO THE  RESTRICTIONS CONTAINED IN THE    */
  24. /*    BINKLEYTERM  LICENSING  AGREEMENT.  IF YOU DO NOT FIND THE TEXT OF    */
  25. /*    THIS  AGREEMENT IN ANY OF THE  AFOREMENTIONED FILES,  OR IF YOU DO    */
  26. /*    NOT HAVE THESE FILES,  YOU  SHOULD  IMMEDIATELY CONTACT BIT BUCKET    */
  27. /*    SOFTWARE CO.  AT ONE OF THE  ADDRESSES  LISTED BELOW.  IN NO EVENT    */
  28. /*    SHOULD YOU  PROCEED TO USE THIS FILE  WITHOUT HAVING  ACCEPTED THE    */
  29. /*    TERMS  OF  THE  BINKLEYTERM  LICENSING  AGREEMENT,  OR  SUCH OTHER    */
  30. /*    AGREEMENT AS YOU ARE ABLE TO REACH WITH BIT BUCKET SOFTWARE, CO.      */
  31. /*                                                                          */
  32. /*                                                                          */
  33. /* You can contact Bit Bucket Software Co. at any one of the following      */
  34. /* addresses:                                                               */
  35. /*                                                                          */
  36. /* Bit Bucket Software Co.        FidoNet  1:104/501, 1:343/491             */
  37. /* P.O. Box 460398                AlterNet 7:491/0                          */
  38. /* Aurora, CO 80046               BBS-Net  86:2030/1                        */
  39. /*                                Internet f491.n343.z1.fidonet.org         */
  40. /*                                                                          */
  41. /* Please feel free to contact us at any time to share your comments about  */
  42. /* our software and/or licensing policies.                                  */
  43. /*                                                                          */
  44. /*--------------------------------------------------------------------------*/
  45.  
  46. /* Include this file before any other includes or defines! */
  47.  
  48. #include "includes.h"
  49.  
  50.  
  51. static struct _key_fnc_hdr *CrntKeyFncHdr;
  52.  
  53.  
  54. struct _key_fnc_hdr *KbMapSet (struct _key_fnc_hdr *KeyFncHdr)
  55. {
  56.    struct _key_fnc_hdr  *OldKeyFncHdr = CrntKeyFncHdr;
  57.  
  58.    CrntKeyFncHdr = KeyFncHdr;
  59.    return OldKeyFncHdr;
  60. }
  61.  
  62. #ifndef MILQ
  63.  
  64. int ScanCompare (struct _key_fnc *x, struct _key_fnc *y)
  65. {
  66.    return (x->ScanCode - y->ScanCode);
  67. }
  68.  
  69. unsigned pascal KbRemap (unsigned ScanCode)
  70. {
  71.    struct _key_fnc InFnc;
  72.    struct _key_fnc *KeyFnc;
  73.    int i;
  74.  
  75. /*
  76.  * FOSSIL keyboarding is so wierd.
  77.  *
  78.  * The spec is really clear about what you're supposed to do with
  79.  * letter and function keys. Some of the IBM FOSSILs didn't give a
  80.  * damn and put scan codes in the high order part of the character
  81.  * keys. That breaks this guy utterly. So we'll get rid of the 
  82.  * bits if they happen to be there.
  83.  */
  84.  
  85.    if (ScanCode & 0xff)
  86.        ScanCode &= 0xff;                /* Clean up after Opus!Comm */
  87.  
  88. /* If the table is empty, searching it is sort of pointless.        */
  89.  
  90.    if (!CrntKeyFncHdr->KeyFncCnt)
  91.        return ScanCode;
  92.  
  93.    InFnc.ScanCode = ScanCode;
  94.  
  95.    KeyFnc = CrntKeyFncHdr->KeyFncTbl;
  96.  
  97.    for (i = CrntKeyFncHdr->KeyFncCnt; i > 0; i--, KeyFnc++)
  98.        {
  99.        if (ScanCompare (KeyFnc, &InFnc) == 0)
  100.            return KeyFnc->FncIdx;
  101.        }
  102.  
  103.    return ScanCode;
  104. }
  105.  
  106. #endif
  107.  
  108.