1 /*****************************************************************************/
2 /*                                                                           */
3 /*                                 KEYDEF.CC                                 */
4 /*                                                                           */
5 /* (C) 1993-95  Ullrich von Bassewitz                                        */
6 /*              Zwehrenbuehlstrasse 33                                       */
7 /*              D-72070 Tuebingen                                            */
8 /* EMail:       uz@ibb.schwaben.com                                          */
9 /*                                                                           */
10 /*****************************************************************************/
11 
12 
13 
14 // $Id$
15 //
16 // $Log$
17 //
18 //
19 
20 
21 
22 #include <stddef.h>
23 
24 #include "keydef.h"
25 
26 
27 
28 /*****************************************************************************/
29 /*                                   Data                                    */
30 /*****************************************************************************/
31 
32 
33 
34 struct {
35     Key Orig;           // Original key
36     Key Meta;           // Meta version
37 } MetaTable [] = {
38     {   '0',    kbMeta0         },
39     {   '1',    kbMeta1         },
40     {   '2',    kbMeta2         },
41     {   '3',    kbMeta3         },
42     {   '4',    kbMeta4         },
43     {   '5',    kbMeta5         },
44     {   '6',    kbMeta6         },
45     {   '7',    kbMeta7         },
46     {   '8',    kbMeta8         },
47     {   '9',    kbMeta9         },
48     {   'A',    kbMetaA         },
49     {   'B',    kbMetaB         },
50     {   'C',    kbMetaC         },
51     {   'D',    kbMetaD         },
52     {   'E',    kbMetaE         },
53     {   'F',    kbMetaF         },
54     {   'G',    kbMetaG         },
55     {   'H',    kbMetaH         },
56     {   'I',    kbMetaI         },
57     {   'J',    kbMetaJ         },
58     {   'K',    kbMetaK         },
59     {   'L',    kbMetaL         },
60     {   'M',    kbMetaM         },
61     {   'N',    kbMetaN         },
62     {   'O',    kbMetaO         },
63     {   'P',    kbMetaP         },
64     {   'Q',    kbMetaQ         },
65     {   'R',    kbMetaR         },
66     {   'S',    kbMetaS         },
67     {   'T',    kbMetaT         },
68     {   'U',    kbMetaU         },
69     {   'V',    kbMetaV         },
70     {   'W',    kbMetaW         },
71     {   'X',    kbMetaX         },
72     {   'Y',    kbMetaY         },
73     {   'Z',    kbMetaZ         }
74 };
75 
76 
77 
78 /*****************************************************************************/
79 /*                                   Code                                    */
80 /*****************************************************************************/
81 
82 
83 
GetMetaCode(Key K)84 Key GetMetaCode (Key K)
85 // Return the "meta version" of the given key K or kbNoKey if none exists
86 {
87     // Do a linear search (hmm..., is it worth a binary search?)
88     for (size_t I = 0; I < sizeof (MetaTable) / sizeof (MetaTable [0]); I++) {
89         if (MetaTable [I].Orig == K) {
90             return MetaTable [I].Meta;
91         }
92     }
93 
94     // Not found
95     return kbNoKey;
96 }
97 
98 
99 
GetMetaKey(Key K)100 Key GetMetaKey (Key K)
101 // Return the "normal key" of the meta key given key K or kbNoKey if none
102 // exists
103 {
104     // Do a linear search (hmm..., is it worth a binary search?)
105     for (size_t I = 0; I < sizeof (MetaTable) / sizeof (MetaTable [0]); I++) {
106         if (MetaTable [I].Meta == K) {
107             return MetaTable [I].Orig;
108         }
109     }
110 
111     // Not found
112     return kbNoKey;
113 }
114 
115 
116 
117