1/* 2 * 3 * @APPLE_LICENSE_HEADER_START@ 4 * 5 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. 6 * 7 * This file contains Original Code and/or Modifications of Original Code 8 * as defined in and that are subject to the Apple Public Source License 9 * Version 2.0 (the 'License'). You may not use this file except in 10 * compliance with the License. Please obtain a copy of the License at 11 * http://www.opensource.apple.com/apsl/ and read it before using this 12 * file. 13 * 14 * The Original Code and all software distributed under the License are 15 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 16 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 17 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 18 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 19 * Please see the License for the specific language governing rights and 20 * limitations under the License. 21 * 22 * @APPLE_LICENSE_HEADER_END@ 23 */ 24 25#ifndef _IOKIT_HID_APPLEEMBEDDEDKEYBOARD_H 26#define _IOKIT_HID_APPLEEMBEDDEDKEYBOARD_H 27 28#include <IOKit/hidevent/IOHIDEventDriver.h> 29 30// Moved up to allow subclasses to use the same keys 31#define kFnFunctionUsageMapKey "FnFunctionUsageMap" 32#define kFnKeyboardUsageMapKey "FnKeyboardUsageMap" 33#define kNumLockKeyboardUsageMapKey "NumLockKeyboardUsageMap" 34#define kKeyboardUsageMapKey "KeyboardUsageMap" 35 36enum { 37 kSecondaryKeyFnFunction = 0x01, 38 kSecondaryKeyFnKeyboard = 0x02, 39 kSecondaryKeyNumLockKeyboard = 0x04 40}; 41 42typedef struct _SecondaryKey { 43 UInt8 bits; 44 UInt8 swapping; 45 UInt16 fnFunctionUsagePage; 46 UInt16 fnFunctionUsage; 47 UInt16 fnKeyboardUsagePage; 48 UInt16 fnKeyboardUsage; 49 UInt16 numLockKeyboardUsagePage; 50 UInt16 numLockKeyboardUsage; 51} SecondaryKey; 52 53class AppleEmbeddedKeyboard: public IOHIDEventDriver 54{ 55 OSDeclareDefaultStructors( AppleEmbeddedKeyboard ) 56 57 bool _fnKeyDownPhysical; 58 bool _fnKeyDownVirtual; 59 bool _numLockDown; 60 bool _virtualMouseKeysSupport; 61 UInt32 _fKeyMode; 62 SecondaryKey _secondaryKeys[255]; 63 IOHIDElement * _keyboardRollOverElement; 64 OSDictionary * _keyboardMap; 65 66 void findKeyboardRollOverElement(OSArray * reportElements); 67 68 void parseSecondaryUsages(); 69 70 bool filterSecondaryFnFunctionUsage( 71 UInt32 * usagePage, 72 UInt32 * usage, 73 bool down); 74 75 bool filterSecondaryFnKeyboardUsage( 76 UInt32 * usagePage, 77 UInt32 * usage, 78 bool down); 79 80 bool filterSecondaryNumLockKeyboardUsage( 81 UInt32 * usagePage, 82 UInt32 * usage, 83 bool down); 84 85 bool filterKeyboardUsage( 86 UInt32 * usagePage, 87 UInt32 * usage, 88 bool down); 89 90protected: 91 92 virtual bool handleStart( IOService * provider ); 93 94 virtual void setElementValue ( 95 UInt32 usagePage, 96 UInt32 usage, 97 UInt32 value ); 98 99 virtual void dispatchKeyboardEvent( 100 AbsoluteTime timeStamp, 101 UInt32 usagePage, 102 UInt32 usage, 103 UInt32 value, 104 IOOptionBits options = 0 ); 105 106public: 107 virtual bool init(OSDictionary * properties = 0); 108 virtual void free(); 109 110 virtual IOReturn setSystemProperties( OSDictionary * properties ); 111 112}; 113 114#endif /* !_IOKIT_HID_APPLEEMBEDDEDKEYBOARD_H */ 115