2 * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
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.
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
20 * @APPLE_LICENSE_HEADER_END@
23 #ifndef _APPLEPS2KEYBOARD_H
24 #define _APPLEPS2KEYBOARD_H
26 #include <IOKit/ps2/ApplePS2KeyboardDevice.h>
27 #include <IOKit/hidsystem/IOHIKeyboard.h>
29 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
30 // Definitions used to keep track of key state. Key up/down state is tracked
31 // in a bit list. Bits are set for key-down, and cleared for key-up. The bit
32 // vector and macros for it's manipulation are defined here.
35 #define KBV_NUM_KEYCODES 128
36 #define KBV_BITS_PER_UNIT 32 // for UInt32
37 #define KBV_BITS_MASK 31
38 #define KBV_BITS_SHIFT 5 // 1<<5 == 32, for cheap divide
39 #define KBV_NUNITS ((KBV_NUM_KEYCODES + \
40 (KBV_BITS_PER_UNIT-1))/KBV_BITS_PER_UNIT)
42 #define KBV_KEYDOWN(n, bits) \
43 (bits)[((n)>>KBV_BITS_SHIFT)] |= (1 << ((n) & KBV_BITS_MASK))
45 #define KBV_KEYUP(n, bits) \
46 (bits)[((n)>>KBV_BITS_SHIFT)] &= ~(1 << ((n) & KBV_BITS_MASK))
48 #define KBV_IS_KEYDOWN(n, bits) \
49 (((bits)[((n)>>KBV_BITS_SHIFT)] & (1 << ((n) & KBV_BITS_MASK))) != 0)
51 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
52 // ApplePS2Keyboard Class Declaration
55 class ApplePS2Keyboard
: public IOHIKeyboard
57 OSDeclareDefaultStructors(ApplePS2Keyboard
);
60 ApplePS2KeyboardDevice
* _device
;
61 UInt32 _keyBitVector
[KBV_NUNITS
];
63 UInt8 _interruptHandlerInstalled
:1;
66 virtual bool dispatchKeyboardEventWithScancode(UInt8 scanCode
);
67 virtual void setCommandByte(UInt8 setBits
, UInt8 clearBits
);
68 virtual void setLEDs(UInt8 ledState
);
69 virtual void setKeyboardEnable(bool enable
);
72 virtual const unsigned char * defaultKeymapOfLength(UInt32
* length
);
73 virtual void setAlphaLockFeedback(bool locked
);
74 virtual UInt32
maxKeyCodes();
77 virtual bool init(OSDictionary
* properties
);
78 virtual ApplePS2Keyboard
* probe(IOService
* provider
, SInt32
* score
);
80 virtual bool start(IOService
* provider
);
81 virtual void stop(IOService
* provider
);
83 virtual void interruptOccurred(UInt8 scanCode
);
85 virtual UInt32
deviceType();
86 virtual UInt32
interfaceID();
89 #endif /* _APPLEPS2KEYBOARD_H */