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_IOHIDKEYBOARD_H
26#define _IOKIT_HID_IOHIDKEYBOARD_H
27
28#include <IOKit/hidsystem/IOHIDTypes.h>
29#include "IOHIKeyboard.h"
30#include "IOHIDDevice.h"
31#include "IOHIDConsumer.h"
32#include "IOHIDElement.h"
33#include "IOHIDEventService.h"
34#include "IOHIDFamilyPrivate.h"
35
36enum {
37    kUSB_CAPSLOCKLED_SET = 2,
38    kUSB_NUMLOCKLED_SET = 1
39};
40
41#define ADB_CONVERTER_LEN       0xff + 1   //length of array def_usb_2_adb_keymap[]
42#define APPLE_ADB_CONVERTER_LEN 0xff + 1   //length of array def_usb_apple_2_adb_keymap[]
43
44class IOHIDKeyboard : public IOHIKeyboard
45{
46    OSDeclareDefaultStructors(IOHIDKeyboard)
47
48    IOHIDEventService *     _provider;
49
50	bool					_repeat;
51	bool					_resyncLED;
52
53    // LED Specific Members
54    UInt8                   _ledState;
55    thread_call_t           _asyncLEDThread;
56
57    // Scan Code Array Specific Members
58    unsigned int            _usb_2_adb_keymap[ADB_CONVERTER_LEN + 1];
59    unsigned int            _usb_apple_2_adb_keymap[APPLE_ADB_CONVERTER_LEN + 1];
60
61    // FN Key Member
62    bool                    _containsFKey;
63    bool                    _isDispatcher;
64
65    // *** PRIVATE HELPER METHODS ***
66    void                    Set_LED_States(UInt8);
67    UInt32                  handlerID();
68
69    // *** END PRIVATE HELPER METHODS ***
70
71    // static methods for callbacks, the command gate, new threads, etc.
72    static void             _asyncLED (OSObject *target);
73
74public:
75    // Allocator
76    static IOHIDKeyboard * 	Keyboard(UInt32 supportedModifiers, bool isDispatcher = false);
77
78    // IOService methods
79    virtual bool            init(OSDictionary * properties = 0);
80    virtual bool            start(IOService * provider);
81    virtual void            stop(IOService *  provider);
82    virtual void            free();
83
84    inline bool             isDispatcher() { return _isDispatcher;};
85
86    // IOHIDevice methods
87    UInt32                  interfaceID();
88    UInt32                  deviceType();
89
90    // IOHIKeyboard methods
91    const unsigned char * 	defaultKeymapOfLength(UInt32 * length);
92    void                    setAlphaLockFeedback(bool LED_state);
93    void                    setNumLockFeedback(bool LED_state);
94    unsigned                getLEDStatus();
95    IOReturn                setParamProperties( OSDictionary * dict );
96
97	void                    dispatchKeyboardEvent(
98                                AbsoluteTime                timeStamp,
99                                UInt32                      usagePage,
100                                UInt32                      usage,
101                                bool                        keyDown,
102                                IOOptionBits                options = 0);
103
104};
105
106
107#endif /* !_IOKIT_HID_IOHIDKEYBOARD_H */
108