|
|
1.1 root 1: /*
2: * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
3: *
4: * @APPLE_LICENSE_HEADER_START@
5: *
6: * The contents of this file constitute Original Code as defined in and
7: * are subject to the Apple Public Source License Version 1.1 (the
8: * "License"). You may not use this file except in compliance with the
9: * License. Please obtain a copy of the License at
10: * http://www.apple.com/publicsource and read it before using this file.
11: *
12: * This Original Code and all software distributed under the License are
13: * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14: * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15: * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16: * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17: * License for the specific language governing rights and limitations
18: * under the License.
19: *
20: * @APPLE_LICENSE_HEADER_END@
21: */
22: #ifndef _IOHIKEYBOARDMAPPER_H
23: #define _IOHIKEYBOARDMAPPER_H
24:
25: #include <IOKit/hidsystem/ev_keymap.h>
26:
27: class IOHIKeyboard;
28:
29: /*
30: * Key ip/down state is tracked in a bit list. Bits are set
31: * for key-down, and cleared for key-up. The bit vector and macros
32: * for it's manipulation are defined here.
33: */
34:
35: typedef UInt32 * kbdBitVector;
36:
37: #define EVK_BITS_PER_UNIT 32
38: #define EVK_BITS_MASK 31
39: #define EVK_BITS_SHIFT 5 // 1<<5 == 32, for cheap divide
40:
41: #define EVK_KEYDOWN(n, bits) \
42: (bits)[((n)>>EVK_BITS_SHIFT)] |= (1 << ((n) & EVK_BITS_MASK))
43:
44: #define EVK_KEYUP(n, bits) \
45: (bits)[((n)>>EVK_BITS_SHIFT)] &= ~(1 << ((n) & EVK_BITS_MASK))
46:
47: #define EVK_IS_KEYDOWN(n, bits) \
48: (((bits)[((n)>>EVK_BITS_SHIFT)] & (1 << ((n) & EVK_BITS_MASK))) != 0)
49:
50: class IOHIKeyboardMapper : public OSObject
51: {
52: OSDeclareDefaultStructors(IOHIKeyboardMapper);
53:
54: private:
55: IOHIKeyboard * _delegate; // KeyMap delegate
56: bool _mappingShouldBeFreed; // true if map can be IOFree'd
57: NXParsedKeyMapping _parsedMapping; // current system-wide keymap
58:
59: public:
60: static IOHIKeyboardMapper * keyboardMapper(
61: IOHIKeyboard * delegate,
62: const UInt8 * mapping,
63: UInt32 mappingLength,
64: bool mappingShouldBeFreed );
65:
66: virtual bool init(IOHIKeyboard * delegate,
67: const UInt8 * mapping,
68: UInt32 mappingLength,
69: bool mappingShouldBeFreed);
70: virtual void free();
71:
72: virtual const UInt8 * mapping();
73: virtual UInt32 mappingLength();
74: virtual bool serialize(OSSerialize *s) const;
75:
76: virtual void translateKeyCode(UInt8 key, bool keyDown, kbdBitVector keyBits);
77:
78: private:
79: virtual bool parseKeyMapping(const UInt8 * mapping,
80: UInt32 mappingLength,
81: NXParsedKeyMapping * parsedMapping) const;
82:
83: virtual void calcModBit(int bit, kbdBitVector keyBits);
84: virtual void doModCalc(int key, kbdBitVector keyBits);
85: virtual void doCharGen(int keyCode, bool down);
86: };
87:
88: #endif _IOHIKEYBOARDMAPPER_H
89:
90: /*
91: * HISTORICAL NOTE:
92: * The "delegate" object had to respond to the following protocol;
93: * this protocol has since been merged into the IOHIKeyboard class.
94: *
95: * @protocol KeyMapDelegate
96: *
97: * - keyboardEvent :(unsigned)eventType
98: * flags :(unsigned)flags
99: * keyCode :(unsigned)keyCode
100: * charCode:(unsigned)charCode
101: * charSet :(unsigned)charSet
102: * originalCharCode:(unsigned)origCharCode
103: * originalCharSet:(unsigned)origCharSet;
104: *
105: * - keyboardSpecialEvent:(unsigned)eventType
106: * flags :(unsigned)flags
107: * keyCode :(unsigned)keyCode
108: * specialty:(unsigned)flavor;
109: *
110: * - updateEventFlags:(unsigned)flags; // Does not generate events
111: *
112: * - (unsigned)eventFlags; // Global event flags
113: * - (unsigned)deviceFlags; // per-device event flags
114: * - setDeviceFlags:(unsigned)flags; // Set device event flags
115: * - (bool)alphaLock; // current alpha-lock state
116: * - setAlphaLock:(bool)val; // Set current alpha-lock state
117: * - (bool)charKeyActive; // Is a character gen. key down?
118: * - setCharKeyActive:(bool)val; // Note that a char gen key is down.
119: *
120: * @end
121: */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.