OpenCore  1.0.4
OpenCore Bootloader
Loading...
Searching...
No Matches
KeyHandler.c
Go to the documentation of this file.
1
19#include <AppleMacEfi.h>
20
22
25
27#include <Library/BaseMemoryLib.h>
28#include <Library/DebugLib.h>
29#include <Library/MemoryAllocationLib.h>
30#include <Library/UefiBootServicesTableLib.h>
31#include <Library/UefiLib.h>
32
33#include "AppleEventInternal.h"
34
35// KEY_STROKE_DELAY
36#define KEY_STROKE_DELAY 5
37
38// KEY_STROKE_POLL_FREQUENCY
39#define KEY_STROKE_POLL_FREQUENCY EFI_TIMER_PERIOD_MILLISECONDS (10)
40
41// KEY_STROKE_INFORMATION
47
48// mCLockOn
49STATIC BOOLEAN mCLockOn = FALSE;
50
51// mKeyStrokePollEvent
52STATIC EFI_EVENT mKeyStrokePollEvent = NULL;
53
54// mModifiers
56
57// mPreviousModifiers
59
60// mInitialized
61STATIC BOOLEAN mInitialized = FALSE;
62
63// mKeyInformation
65
66// mCLockChanged
67STATIC BOOLEAN mCLockChanged = FALSE;
68
69// mKeyInitialDelay
70// mKeySubsequentDelay
71// Apple implementation default values
72STATIC UINTN mKeyInitialDelay = 50;
73STATIC UINTN mKeySubsequentDelay = 5;
74
75// mGraphicsInputMirroring
76STATIC BOOLEAN mGraphicsInputMirroring = FALSE;
77
78// mAppleKeyMapAggregator
80
81// InternalSetKeyBehaviour
82VOID
84 IN BOOLEAN CustomDelays,
85 IN UINT16 KeyInitialDelay,
86 IN UINT16 KeySubsequentDelay,
87 IN BOOLEAN GraphicsInputMirroring
88 )
89{
90 if (CustomDelays) {
91 //
92 // Zero is meaningful
93 //
94 mKeyInitialDelay = KeyInitialDelay;
95
96 //
97 // Zero is meaningless (also div by zero expception): warn and use 1
98 //
99 if (KeySubsequentDelay == 0) {
100 KeySubsequentDelay = 1;
101 DEBUG ((DEBUG_WARN, "OCAE: Illegal KeySubsequentDelay value 0, using 1\n"));
102 }
103
104 mKeySubsequentDelay = KeySubsequentDelay;
105
106 DEBUG ((DEBUG_INFO, "OCAE: Using key delays %d (%d0ms) and %d (%d0ms)\n", mKeyInitialDelay, mKeyInitialDelay, mKeySubsequentDelay, mKeySubsequentDelay));
107 }
108
109 mGraphicsInputMirroring = GraphicsInputMirroring;
110}
111
112// InternalGetAppleKeyStrokes
113STATIC
114EFI_STATUS
116 OUT APPLE_MODIFIER_MAP *Modifiers,
117 OUT UINTN *NumberOfKeyCodes,
118 OUT APPLE_KEY_CODE **KeyCodes
119 )
120{
121 EFI_STATUS Status;
122
123 DEBUG ((DEBUG_VERBOSE, "InternalGetAppleKeyStrokes\n"));
124
125 Status = EFI_UNSUPPORTED;
126
127 if (mKeyMapAggregator != NULL) {
128 Status = EFI_INVALID_PARAMETER;
129
130 if ( (Modifiers != NULL)
131 && (NumberOfKeyCodes != NULL)
132 && (KeyCodes != NULL))
133 {
134 *NumberOfKeyCodes = 0;
135 *KeyCodes = NULL;
138 Modifiers,
139 NumberOfKeyCodes,
140 NULL
141 );
142
143 if (!EFI_ERROR (Status) || (Status == EFI_BUFFER_TOO_SMALL)) {
144 if (*NumberOfKeyCodes == 0) {
145 *KeyCodes = NULL;
146 } else {
147 *KeyCodes = AllocateZeroPool (
148 *NumberOfKeyCodes * sizeof (**KeyCodes)
149 );
150
151 if (*KeyCodes == NULL) {
152 *NumberOfKeyCodes = 0;
153 Status = EFI_OUT_OF_RESOURCES;
154 DEBUG ((DEBUG_VERBOSE, "InternalGetAppleKeyStrokes alloc failure\n"));
155 } else {
158 Modifiers,
159 NumberOfKeyCodes,
160 *KeyCodes
161 );
162
163 if (EFI_ERROR (Status)) {
164 FreePool ((VOID *)*KeyCodes);
165
166 *KeyCodes = NULL;
167 *NumberOfKeyCodes = 0;
168 }
169 }
170 }
171 }
172 }
173 }
174
175 return Status;
176}
177
178// InternalGetModifierStrokes
181 VOID
182 )
183{
184 APPLE_MODIFIER_MAP Modifiers;
185 EFI_STATUS Status;
186 UINTN NumberOfKeyCodes;
187 APPLE_KEY_CODE *KeyCodes;
188
189 DEBUG ((DEBUG_VERBOSE, "InternalGetModifierStrokes\n"));
190
192 &Modifiers,
193 &NumberOfKeyCodes,
194 &KeyCodes
195 );
196
197 if (!EFI_ERROR (Status)) {
198 if (KeyCodes != NULL) {
199 FreePool ((VOID *)KeyCodes);
200 }
201 } else {
202 Modifiers = 0;
203 }
204
205 return Modifiers;
206}
207
208// InternalAppleKeyEventDataFromInputKey
209STATIC
210EFI_STATUS
212 OUT APPLE_EVENT_DATA *EventData,
214 IN EFI_INPUT_KEY *InputKey
215 )
216{
217 EFI_STATUS Status;
218 APPLE_KEY_EVENT_DATA *KeyEventData;
219
220 DEBUG ((DEBUG_VERBOSE, "InternalAppleKeyEventDataFromInputKey\n"));
221
222 Status = EFI_INVALID_PARAMETER;
223
224 if ((EventData != NULL) && (AppleKeyCode != NULL) && (InputKey != NULL)) {
225 KeyEventData = AllocateZeroPool (sizeof (*KeyEventData));
226 Status = EFI_OUT_OF_RESOURCES;
227
228 if (KeyEventData != NULL) {
229 KeyEventData->NumberOfKeyPairs = 1;
230 KeyEventData->InputKey = *InputKey;
231
232 CopyMem (
233 (VOID *)&KeyEventData->AppleKeyCode,
234 (VOID *)AppleKeyCode,
235 sizeof (*AppleKeyCode)
236 );
237
238 EventData->KeyData = KeyEventData;
239
240 Status = EFI_SUCCESS;
241 }
242 }
243
244 return Status;
245}
246
247// InternalGetAndRemoveReleasedKeys
248STATIC
249UINTN
251 IN CONST UINTN *NumberOfKeyCodes,
252 IN CONST APPLE_KEY_CODE *KeyCodes,
253 OUT APPLE_KEY_CODE **ReleasedKeys
254 )
255{
256 UINTN NumberOfReleasedKeys;
257 UINTN Index;
258 UINTN Index2;
259 APPLE_KEY_CODE ReleasedKeysBuffer[12];
260 UINTN ReleasedKeysSize;
261
262 DEBUG ((DEBUG_VERBOSE, "InternalGetAndRemoveReleasedKeys\n"));
263
264 NumberOfReleasedKeys = 0;
265
266 for (Index = 0; Index < ARRAY_SIZE (mKeyStrokeInfo); ++Index) {
267 for (Index2 = 0; Index2 < *NumberOfKeyCodes; ++Index2) {
268 if (mKeyStrokeInfo[Index].AppleKeyCode == KeyCodes[Index2]) {
269 break;
270 }
271 }
272
273 if (*NumberOfKeyCodes == Index2) {
274 if (mKeyStrokeInfo[Index].AppleKeyCode != 0) {
275 ReleasedKeysBuffer[NumberOfReleasedKeys] = mKeyStrokeInfo[Index].AppleKeyCode;
276 ++NumberOfReleasedKeys;
277 }
278
279 ZeroMem (
280 &mKeyStrokeInfo[Index],
281 sizeof (mKeyStrokeInfo[Index])
282 );
283 }
284 }
285
286 // Add CLock to released keys if applicable and set bool to FALSE.
287
288 if (mCLockChanged) {
289 for (Index = 0; Index < *NumberOfKeyCodes; ++Index) {
290 if (KeyCodes[Index] == AppleHidUsbKbUsageKeyCLock) {
291 break;
292 }
293 }
294
295 if (*NumberOfKeyCodes == Index) {
296 mCLockChanged = FALSE;
297
298 ReleasedKeysBuffer[NumberOfReleasedKeys] = AppleHidUsbKbUsageKeyCLock;
299 ++NumberOfReleasedKeys;
300 }
301 }
302
303 // Allocate a heap buffer to return.
304
305 *ReleasedKeys = NULL;
306
307 if (NumberOfReleasedKeys > 0) {
308 ReleasedKeysSize = (sizeof (**ReleasedKeys) * NumberOfReleasedKeys);
309 *ReleasedKeys = AllocateZeroPool (ReleasedKeysSize);
310
311 if (*ReleasedKeys != NULL) {
312 CopyMem (
313 (VOID *)*ReleasedKeys,
314 (VOID *)&ReleasedKeysBuffer[0],
315 ReleasedKeysSize
316 );
317 } else {
318 NumberOfReleasedKeys = 0;
319 }
320 }
321
322 return NumberOfReleasedKeys;
323}
324
325// InternalIsCLockOn
326STATIC
327BOOLEAN
329 IN CONST UINTN *NumberOfKeyCodes,
330 IN CONST APPLE_KEY_CODE *KeyCodes
331 )
332{
333 BOOLEAN CLockOn;
334 UINTN Index;
335 UINTN Index2;
336 KEY_STROKE_INFORMATION *KeyInfo;
337
338 DEBUG ((DEBUG_VERBOSE, "InternalIsCLockOn\n"));
339
340 //
341 // Check against invalid usage
342 //
343 if ( (NumberOfKeyCodes == NULL)
344 || ((*NumberOfKeyCodes != 0) && (KeyCodes == NULL)))
345 {
346 return FALSE;
347 }
348
349 //
350 // Return the previous value by default
351 //
352 CLockOn = mCLockOn;
353
354 for (Index = 0; Index < *NumberOfKeyCodes; ++Index) {
355 KeyInfo = NULL;
356
357 for (Index2 = 0; Index2 < ARRAY_SIZE (mKeyStrokeInfo); ++Index2) {
358 if (mKeyStrokeInfo[Index2].AppleKeyCode == KeyCodes[Index]) {
359 KeyInfo = &mKeyStrokeInfo[Index2];
360 break;
361 }
362 }
363
364 if ( (KeyInfo == NULL)
365 && (KeyCodes[Index] == AppleHidUsbKbUsageKeyCLock)
366 && !mCLockChanged)
367 {
368 CLockOn = (BOOLEAN)mCLockOn == FALSE;
369 break;
370 }
371 }
372
373 return CLockOn;
374}
375
376// InternalGetCurrentStroke
377STATIC
380 VOID
381 )
382{
383 KEY_STROKE_INFORMATION *KeyInfo;
384 UINTN Index;
385
386 DEBUG ((DEBUG_VERBOSE, "InternalGetCurrentStroke\n"));
387
388 KeyInfo = NULL;
389
390 for (Index = 0; Index < ARRAY_SIZE (mKeyStrokeInfo); ++Index) {
391 if (mKeyStrokeInfo[Index].CurrentStroke) {
392 KeyInfo = &mKeyStrokeInfo[Index];
393 break;
394 }
395 }
396
397 return KeyInfo;
398}
399
400// InternalGetCurrentKeyStroke
401STATIC
402EFI_STATUS
404 IN APPLE_MODIFIER_MAP Modifiers,
405 IN OUT UINTN *NumberOfKeyCodes,
406 IN OUT APPLE_KEY_CODE *KeyCodes,
407 IN OUT EFI_INPUT_KEY *Key
408 )
409{
410 EFI_STATUS Status;
411 KEY_STROKE_INFORMATION *KeyInfo;
412 UINTN Index;
413 UINTN NumberOfReleasedKeys;
414 APPLE_KEY_CODE *ReleasedKeys;
415 BOOLEAN CLockOn;
416 APPLE_MODIFIER_MAP AppleModifiers;
417 BOOLEAN ShiftPressed;
418 EFI_INPUT_KEY InputKey;
419 APPLE_EVENT_DATA AppleEventData;
420 UINTN NewKeyIndex;
421 BOOLEAN AcceptStroke;
422 BOOLEAN Shifted;
423
424 DEBUG ((DEBUG_VERBOSE, "InternalGetCurrentKeyStroke\n"));
425
426 if (mModifiers != Modifiers) {
427 for (Index = 0; Index < ARRAY_SIZE (mKeyStrokeInfo); ++Index) {
428 mKeyStrokeInfo[Index].CurrentStroke = FALSE;
429 }
430 }
431
432 NumberOfReleasedKeys = InternalGetAndRemoveReleasedKeys (
433 NumberOfKeyCodes,
434 KeyCodes,
435 &ReleasedKeys
436 );
437
438 CLockOn = InternalIsCLockOn (NumberOfKeyCodes, KeyCodes);
439
440 AppleModifiers = Modifiers;
441
442 if (CLockOn) {
443 AppleModifiers |= APPLE_MODIFIERS_SHIFT;
444 }
445
446 ShiftPressed = (BOOLEAN)((AppleModifiers & APPLE_MODIFIERS_SHIFT) != 0);
447
448 for (Index = 0; Index < NumberOfReleasedKeys; ++Index) {
450 ReleasedKeys[Index],
451 &InputKey,
452 ShiftPressed
453 );
454
455 AppleEventData.KeyData = NULL;
457 &AppleEventData,
458 &ReleasedKeys[Index],
459 &InputKey
460 );
461
462 if (EFI_ERROR (Status)) {
463 break;
464 }
465
467 AppleEventData,
469 AppleModifiers
470 );
471 }
472
473 if (ReleasedKeys != NULL) {
474 FreePool ((VOID *)ReleasedKeys);
475 }
476
477 if (CLockOn != mCLockOn) {
478 mCLockOn = CLockOn;
479 mCLockChanged = TRUE;
480 }
481
482 //
483 // Increase the number of strokes for all currently pressed keys.
484 //
485 for (NewKeyIndex = 0; NewKeyIndex < *NumberOfKeyCodes; ++NewKeyIndex) {
486 KeyInfo = NULL;
487
488 for (Index = 0; Index < ARRAY_SIZE (mKeyStrokeInfo); ++Index) {
489 if (mKeyStrokeInfo[Index].AppleKeyCode == KeyCodes[NewKeyIndex]) {
490 KeyInfo = &mKeyStrokeInfo[Index];
491 KeyInfo->NumberOfStrokes++;
492 break;
493 }
494 }
495
496 //
497 // Indicates a key has been pressed which is not part of mKeyInformation.
498 //
499 if (KeyInfo == NULL) {
500 //
501 // If a new key is pressed, cancel all previous inputs.
502 //
503 for (Index = 0; Index < ARRAY_SIZE (mKeyStrokeInfo); ++Index) {
504 mKeyStrokeInfo[Index].CurrentStroke = FALSE;
505 }
506
507 //
508 // Insert the new key into a buffer
509 //
510 for (Index = 0; Index < ARRAY_SIZE (mKeyStrokeInfo); ++Index) {
511 if (mKeyStrokeInfo[Index].AppleKeyCode == 0) {
512 KeyInfo = &mKeyStrokeInfo[Index];
513 KeyInfo->AppleKeyCode = KeyCodes[NewKeyIndex];
514 KeyInfo->CurrentStroke = TRUE;
515 KeyInfo->NumberOfStrokes = 0;
516 break;
517 }
518 }
519
520 // CHECKME: is it intentional?
521 break;
522 }
523 }
524
525 KeyInfo = InternalGetCurrentStroke ();
526
527 Status = EFI_NOT_READY;
528
529 if ((KeyInfo != NULL) || (mModifiers != Modifiers)) {
530 mModifiers = Modifiers;
531
532 //
533 // Verify the timeframe the key has been pressed.
534 //
535
536 if (KeyInfo != NULL) {
537 AcceptStroke = (BOOLEAN)(
539 ? (KeyInfo->NumberOfStrokes == 0)
541 );
542
543 if (AcceptStroke) {
544 *NumberOfKeyCodes = 1;
545 *KeyCodes = KeyInfo->AppleKeyCode;
546
547 Shifted = (BOOLEAN)(
548 (IS_APPLE_KEY_LETTER (KeyInfo->AppleKeyCode) && CLockOn)
550 );
551
553 KeyInfo->AppleKeyCode,
554 Key,
555 Shifted
556 );
557
558 Status = EFI_SUCCESS;
559 }
560 } else {
561 //
562 // Report that no keys were pressed.
563 //
564 *NumberOfKeyCodes = 0;
565 Status = EFI_SUCCESS;
566 }
567 }
568
569 return Status;
570}
571
572// CreateAppleKeyCodeDescriptorsFromKeyStrokes
573STATIC
574EFI_STATUS
576 IN OUT APPLE_EVENT_DATA *EventData,
577 IN OUT APPLE_MODIFIER_MAP *Modifiers
578 )
579{
580 EFI_STATUS Status;
581 EFI_INPUT_KEY InputKey;
582 APPLE_KEY_CODE *KeyCodes;
583 APPLE_MODIFIER_MAP AppleModifiers;
584 UINTN NumberOfKeyCodes;
585 EFI_CONSOLE_CONTROL_PROTOCOL *ConsoleControl;
587 UINTN Index;
588
589 DEBUG ((DEBUG_VERBOSE, "InternalAppleEventDataFromCurrentKeyStroke\n"));
590
591 ZeroMem (&InputKey, sizeof (InputKey));
592
593 KeyCodes = NULL;
594
595 Status = EFI_UNSUPPORTED;
596
597 if ( (mKeyMapAggregator != NULL)
598 && (EventData != NULL)
599 && (Modifiers != NULL))
600 {
601 AppleModifiers = 0;
602 NumberOfKeyCodes = 0;
603
605 &AppleModifiers,
606 &NumberOfKeyCodes,
607 &KeyCodes
608 );
609
611 //
612 // Apple OEM AppleEvent unconditionally includes this logic, but
613 // when an AppleEvent handler such as CrScreenshotDxe is active
614 // this code will run and (not entirely consistently across different
615 // firmware) may prevent keystrokes from reaching ConIn-based UEFI GUI
616 // apps such as Windows BitLocker.
617 // REF: https://github.com/acidanthera/bugtracker/issues/1716
618 //
620 Status = gBS->LocateProtocol (
622 NULL,
623 (VOID *)&ConsoleControl
624 );
625
626 if (!EFI_ERROR (Status)) {
627 ConsoleControl->GetMode (ConsoleControl, &Mode, NULL, NULL);
628 }
629
631 for (Index = 0; Index < (NumberOfKeyCodes + 1); ++Index) {
632 Status = gST->ConIn->ReadKeyStroke (gST->ConIn, &InputKey);
633
634 if (EFI_ERROR (Status)) {
635 break;
636 }
637 }
638 }
639 }
640
641 *Modifiers = AppleModifiers;
643 AppleModifiers,
644 &NumberOfKeyCodes,
645 KeyCodes,
646 &InputKey
647 );
648
649 if (!EFI_ERROR (Status)) {
650 Status = EFI_SUCCESS;
651 if (NumberOfKeyCodes > 0) {
652 InternalAppleKeyEventDataFromInputKey (EventData, KeyCodes, &InputKey);
653 }
654 }
655
656 if (KeyCodes) {
657 FreePool (KeyCodes);
658 }
659 }
660
661 return Status;
662}
663
664// InternalKeyStrokePollNotifyFunction
665STATIC
666VOID
667EFIAPI
669 IN EFI_EVENT Event,
670 IN VOID *Context
671 )
672{
673 EFI_STATUS Status;
674 APPLE_EVENT_DATA EventData;
675 APPLE_MODIFIER_MAP Modifiers;
676 APPLE_MODIFIER_MAP PartialModifers;
677
678 DEBUG ((DEBUG_VERBOSE, "InternalKeyStrokePollNotifyFunction\n"));
679
680 EventData.KeyData = NULL;
681 Modifiers = 0;
683 &EventData,
684 &Modifiers
685 );
686
687 if (!EFI_ERROR (Status)) {
688 if (EventData.KeyData != NULL) {
689 EventCreateEventQueue (EventData, APPLE_EVENT_TYPE_KEY_DOWN, Modifiers);
690 }
691
692 if (mPreviousModifiers != Modifiers) {
693 PartialModifers = ((mPreviousModifiers ^ Modifiers) & mPreviousModifiers);
694
695 if (PartialModifers != 0) {
696 EventData.KeyData = NULL;
697
699 EventData,
701 PartialModifers
702 );
703 }
704
705 PartialModifers = ((mPreviousModifiers ^ Modifiers) & Modifiers);
706
707 if (PartialModifers != 0) {
708 EventData.KeyData = NULL;
709
711 EventData,
713 PartialModifers
714 );
715 }
716
717 mPreviousModifiers = Modifiers;
718 }
719 }
720}
721
722// InternalInitializeKeyHandler
723STATIC
724VOID
726 VOID
727 )
728{
729 DEBUG ((DEBUG_VERBOSE, "InternalInitializeKeyHandler\n"));
730
731 if (!mInitialized) {
732 mInitialized = TRUE;
733
734 ZeroMem ((VOID *)&mKeyStrokeInfo[0], sizeof (mKeyStrokeInfo));
735
736 mModifiers = 0;
737 mCLockOn = FALSE;
738 mCLockChanged = FALSE;
739 }
740}
741
742// EventCreateKeyStrokePollEvent
743EFI_STATUS
745 VOID
746 )
747{
748 EFI_STATUS Status;
749
750 DEBUG ((DEBUG_VERBOSE, "EventCreateKeyStrokePollEvent\n"));
751
752 Status = gBS->LocateProtocol (
754 NULL,
755 (VOID **)&mKeyMapAggregator
756 );
757
758 if (!EFI_ERROR (Status)) {
760
763 NULL,
765 TRUE
766 );
767
768 Status = ((mKeyStrokePollEvent == NULL)
769 ? EFI_OUT_OF_RESOURCES
770 : EFI_SUCCESS);
771 }
772
773 return Status;
774}
775
776// EventCancelKeyStrokePollEvent
777VOID
779 VOID
780 )
781{
782 DEBUG ((DEBUG_VERBOSE, "EventCancelKeyStrokePollEvent\n"));
783
785
786 mKeyStrokePollEvent = NULL;
787}
788
789// EventIsCapsLockOnImpl
790
800EFI_STATUS
801EFIAPI
803 IN OUT BOOLEAN *CLockOn
804 )
805{
806 EFI_STATUS Status;
807
808 DEBUG ((DEBUG_VERBOSE, "EventIsCapsLockOnImpl\n"));
809
810 Status = EFI_INVALID_PARAMETER;
811
812 if (CLockOn != NULL) {
813 *CLockOn = mCLockOn;
814
815 Status = EFI_SUCCESS;
816 }
817
818 return Status;
819}
#define APPLE_EVENT_TYPE_MODIFIER_UP
Definition AppleEvent.h:32
#define APPLE_EVENT_TYPE_KEY_DOWN
Definition AppleEvent.h:29
#define APPLE_EVENT_TYPE_MODIFIER_DOWN
Definition AppleEvent.h:31
#define APPLE_EVENT_TYPE_KEY_UP
Definition AppleEvent.h:30
VOID EventInputKeyFromAppleKeyCode(IN APPLE_KEY_CODE AppleKeyCode, OUT EFI_INPUT_KEY *InputKey, IN BOOLEAN Shifted)
EFI_STATUS EventCreateEventQueue(IN APPLE_EVENT_DATA EventData, IN APPLE_EVENT_TYPE EventType, IN APPLE_MODIFIER_MAP Modifiers)
Definition EventQueue.c:226
EFI_EVENT EventLibCreateNotifyTimerEvent(IN EFI_EVENT_NOTIFY NotifyFunction, IN VOID *NotifyContext, IN UINT64 TriggerTime, IN BOOLEAN SignalPeriodic)
VOID EventLibCancelEvent(IN EFI_EVENT Event)
@ AppleHidUsbKbUsageKeyCLock
Definition AppleHid.h:160
#define IS_APPLE_KEY_LETTER(Usage)
Definition AppleHid.h:31
APPLE_HID_USAGE APPLE_KEY_CODE
Definition AppleHid.h:317
UINT16 APPLE_MODIFIER_MAP
Definition AppleHid.h:102
#define APPLE_MODIFIERS_SHIFT
Definition AppleHid.h:89
EFI_GUID gAppleKeyMapAggregatorProtocolGuid
#define ARRAY_SIZE(Array)
Definition AppleMacEfi.h:34
EFI_CONSOLE_CONTROL_SCREEN_MODE
@ EfiConsoleControlScreenGraphics
EFI_GUID gEfiConsoleControlProtocolGuid
EFI_STATUS EFIAPI EventIsCapsLockOnImpl(IN OUT BOOLEAN *CLockOn)
Definition KeyHandler.c:802
VOID InternalSetKeyBehaviour(IN BOOLEAN CustomDelays, IN UINT16 KeyInitialDelay, IN UINT16 KeySubsequentDelay, IN BOOLEAN GraphicsInputMirroring)
Definition KeyHandler.c:83
STATIC BOOLEAN mGraphicsInputMirroring
Definition KeyHandler.c:76
STATIC APPLE_MODIFIER_MAP mPreviousModifiers
Definition KeyHandler.c:58
STATIC UINTN mKeySubsequentDelay
Definition KeyHandler.c:73
STATIC UINTN InternalGetAndRemoveReleasedKeys(IN CONST UINTN *NumberOfKeyCodes, IN CONST APPLE_KEY_CODE *KeyCodes, OUT APPLE_KEY_CODE **ReleasedKeys)
Definition KeyHandler.c:250
STATIC BOOLEAN InternalIsCLockOn(IN CONST UINTN *NumberOfKeyCodes, IN CONST APPLE_KEY_CODE *KeyCodes)
Definition KeyHandler.c:328
STATIC KEY_STROKE_INFORMATION * InternalGetCurrentStroke(VOID)
Definition KeyHandler.c:379
STATIC EFI_STATUS InternalGetAppleKeyStrokes(OUT APPLE_MODIFIER_MAP *Modifiers, OUT UINTN *NumberOfKeyCodes, OUT APPLE_KEY_CODE **KeyCodes)
Definition KeyHandler.c:115
STATIC EFI_STATUS InternalAppleKeyEventDataFromInputKey(OUT APPLE_EVENT_DATA *EventData, IN APPLE_KEY_CODE *AppleKeyCode, IN EFI_INPUT_KEY *InputKey)
Definition KeyHandler.c:211
STATIC BOOLEAN mCLockOn
Definition KeyHandler.c:49
#define KEY_STROKE_POLL_FREQUENCY
Definition KeyHandler.c:39
STATIC APPLE_KEY_MAP_AGGREGATOR_PROTOCOL * mKeyMapAggregator
Definition KeyHandler.c:79
STATIC EFI_STATUS InternalAppleEventDataFromCurrentKeyStroke(IN OUT APPLE_EVENT_DATA *EventData, IN OUT APPLE_MODIFIER_MAP *Modifiers)
Definition KeyHandler.c:575
STATIC EFI_EVENT mKeyStrokePollEvent
Definition KeyHandler.c:52
STATIC BOOLEAN mCLockChanged
Definition KeyHandler.c:67
VOID EventCancelKeyStrokePollEvent(VOID)
Definition KeyHandler.c:778
EFI_STATUS EventCreateKeyStrokePollEvent(VOID)
Definition KeyHandler.c:744
STATIC UINTN mKeyInitialDelay
Definition KeyHandler.c:72
STATIC EFI_STATUS InternalGetCurrentKeyStroke(IN APPLE_MODIFIER_MAP Modifiers, IN OUT UINTN *NumberOfKeyCodes, IN OUT APPLE_KEY_CODE *KeyCodes, IN OUT EFI_INPUT_KEY *Key)
Definition KeyHandler.c:403
STATIC APPLE_MODIFIER_MAP mModifiers
Definition KeyHandler.c:55
STATIC BOOLEAN mInitialized
Definition KeyHandler.c:61
STATIC VOID InternalInitializeKeyHandler(VOID)
Definition KeyHandler.c:725
STATIC KEY_STROKE_INFORMATION mKeyStrokeInfo[10]
Definition KeyHandler.c:64
STATIC VOID EFIAPI InternalKeyStrokePollNotifyFunction(IN EFI_EVENT Event, IN VOID *Context)
Definition KeyHandler.c:668
APPLE_MODIFIER_MAP InternalGetModifierStrokes(VOID)
Definition KeyHandler.c:180
EFI_SYSTEM_TABLE * gST
EFI_BOOT_SERVICES * gBS
APPLE_KEY_CODE AppleKeyCode
Definition OcTypingLib.h:37
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
VOID *EFIAPI ZeroMem(OUT VOID *Buffer, IN UINTN Length)
EFI_INPUT_KEY InputKey
Definition AppleEvent.h:53
APPLE_KEY_CODE AppleKeyCode
Definition AppleEvent.h:54
APPLE_KEY_CODE AppleKeyCode
Definition KeyHandler.c:43
APPLE_KEY_EVENT_DATA * KeyData
Definition AppleEvent.h:58