OpenCore  1.0.4
OpenCore Bootloader
Loading...
Searching...
No Matches
OcAppleKeyMapLib.c File Reference
#include <AppleMacEfi.h>
#include <IndustryStandard/AppleHid.h>
#include <Protocol/AppleKeyMapAggregator.h>
#include <Protocol/AppleKeyMapDatabase.h>
#include <Library/BaseLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/DebugLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/OcAppleKeyMapLib.h>
#include <Library/OcMiscLib.h>
#include <Library/OcTimerLib.h>
#include <Library/TimerLib.h>
#include <Library/UefiBootServicesTableLib.h>

Go to the source code of this file.

Data Structures

struct  KEY_MAP_AGGREGATOR_DATA
 
struct  APPLE_KEY_STROKES_INFO
 

Macros

#define KEY_MAP_AGGREGATOR_DATA_SIGNATURE    SIGNATURE_32 ('K', 'e', 'y', 'A')
 
#define KEY_MAP_AGGREGATOR_DATA_FROM_AGGREGATOR_THIS(This)
 
#define KEY_MAP_AGGREGATOR_DATA_FROM_DATABASE_THIS(This)
 
#define APPLE_KEY_STROKES_INFO_SIGNATURE   SIGNATURE_32 ('K', 'e', 'y', 'S')
 
#define APPLE_KEY_STROKES_INFO_FROM_LIST_ENTRY(Entry)
 
#define SIZE_OF_APPLE_KEY_STROKES_INFO    OFFSET_OF (APPLE_KEY_STROKES_INFO, KeyCodes)
 

Functions

STATIC APPLE_KEY_STROKES_INFOInternalGetKeyStrokesByIndex (IN KEY_MAP_AGGREGATOR_DATA *KeyMapAggregatorData, IN UINTN Index)
 
STATIC EFI_STATUS EFIAPI InternalGetKeyStrokes (IN APPLE_KEY_MAP_AGGREGATOR_PROTOCOL *This, OUT APPLE_MODIFIER_MAP *Modifiers, IN OUT UINTN *NumberOfKeyCodes, OUT APPLE_KEY_CODE *KeyCodes OPTIONAL)
 
BOOLEAN OcKeyMapHasKeys (IN CONST APPLE_KEY_CODE *Keys, IN UINTN NumKeys, IN CONST APPLE_KEY_CODE *CheckKeys, IN UINTN NumCheckKeys, IN BOOLEAN ExactMatch)
 
BOOLEAN OcKeyMapHasKey (IN CONST APPLE_KEY_CODE *Keys, IN UINTN NumKeys, IN CONST APPLE_KEY_CODE KeyCode)
 
VOID OcKeyMapFlush (IN APPLE_KEY_MAP_AGGREGATOR_PROTOCOL *KeyMap, IN APPLE_KEY_CODE Key, IN BOOLEAN FlushConsole)
 
STATIC EFI_STATUS EFIAPI InternalContainsKeyStrokes (IN APPLE_KEY_MAP_AGGREGATOR_PROTOCOL *This, IN APPLE_MODIFIER_MAP Modifiers, IN UINTN NumberOfKeyCodes, IN OUT APPLE_KEY_CODE *KeyCodes, IN BOOLEAN ExactMatch)
 
STATIC EFI_STATUS EFIAPI InternalCreateKeyStrokesBuffer (IN APPLE_KEY_MAP_DATABASE_PROTOCOL *This, IN UINTN BufferLength, OUT UINTN *Index)
 
STATIC EFI_STATUS EFIAPI InternalRemoveKeyStrokesBuffer (IN APPLE_KEY_MAP_DATABASE_PROTOCOL *This, IN UINTN Index)
 
STATIC EFI_STATUS EFIAPI InternalSetKeyStrokeBufferKeys (IN APPLE_KEY_MAP_DATABASE_PROTOCOL *This, IN UINTN Index, IN APPLE_MODIFIER_MAP Modifiers, IN UINTN NumberOfKeyCodes, IN APPLE_KEY_CODE *KeyCodes)
 
APPLE_KEY_MAP_DATABASE_PROTOCOLOcAppleKeyMapGetDatabase (VOID)
 
APPLE_KEY_MAP_AGGREGATOR_PROTOCOLOcAppleKeyMapInstallProtocols (IN BOOLEAN Reinstall)
 

Variables

STATIC APPLE_KEY_MAP_DATABASE_PROTOCOLmKeyMapDatabase = NULL
 

Detailed Description

AppleKeyMapAggregator

Copyright (c) 2018, vit9696

All rights reserved.

This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php

THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.

Definition in file OcAppleKeyMapLib.c.

Macro Definition Documentation

◆ APPLE_KEY_STROKES_INFO_FROM_LIST_ENTRY

#define APPLE_KEY_STROKES_INFO_FROM_LIST_ENTRY ( Entry)
Value:
CR ( \
(Entry), \
Link, \
)
#define APPLE_KEY_STROKES_INFO_SIGNATURE

Definition at line 70 of file OcAppleKeyMapLib.c.

◆ APPLE_KEY_STROKES_INFO_SIGNATURE

#define APPLE_KEY_STROKES_INFO_SIGNATURE   SIGNATURE_32 ('K', 'e', 'y', 'S')

Definition at line 67 of file OcAppleKeyMapLib.c.

◆ KEY_MAP_AGGREGATOR_DATA_FROM_AGGREGATOR_THIS

#define KEY_MAP_AGGREGATOR_DATA_FROM_AGGREGATOR_THIS ( This)
Value:
CR ( \
(This), \
Aggregator, \
)
#define KEY_MAP_AGGREGATOR_DATA_SIGNATURE

Definition at line 38 of file OcAppleKeyMapLib.c.

◆ KEY_MAP_AGGREGATOR_DATA_FROM_DATABASE_THIS

#define KEY_MAP_AGGREGATOR_DATA_FROM_DATABASE_THIS ( This)
Value:
CR ( \
(This), \
Database, \
)

Definition at line 47 of file OcAppleKeyMapLib.c.

◆ KEY_MAP_AGGREGATOR_DATA_SIGNATURE

#define KEY_MAP_AGGREGATOR_DATA_SIGNATURE    SIGNATURE_32 ('K', 'e', 'y', 'A')

Definition at line 34 of file OcAppleKeyMapLib.c.

◆ SIZE_OF_APPLE_KEY_STROKES_INFO

#define SIZE_OF_APPLE_KEY_STROKES_INFO    OFFSET_OF (APPLE_KEY_STROKES_INFO, KeyCodes)

Definition at line 78 of file OcAppleKeyMapLib.c.

Function Documentation

◆ InternalContainsKeyStrokes()

STATIC EFI_STATUS EFIAPI InternalContainsKeyStrokes ( IN APPLE_KEY_MAP_AGGREGATOR_PROTOCOL * This,
IN APPLE_MODIFIER_MAP Modifiers,
IN UINTN NumberOfKeyCodes,
IN OUT APPLE_KEY_CODE * KeyCodes,
IN BOOLEAN ExactMatch )

Returns whether or not a list of keys and their modifiers are part of the database of pressed keys.

Parameters
[in]ThisA pointer to the protocol instance.
[in]ModifiersThe modifiers manipulating the given keys.
[in]NumberOfKeyCodesThe number of keys present in KeyCodes.
[in,out]KeyCodesThe list of keys to check for. The children may be sorted in the process.
[in]ExactMatchSpecifies whether Modifiers and KeyCodes should be exact matches or just contained.
Returns
Returns whether or not a list of keys and their modifiers are part of the database of pressed keys.
Return values
EFI_SUCCESSThe queried keys are part of the database.
EFI_NOT_FOUNDThe queried keys could not be found.

Definition at line 332 of file OcAppleKeyMapLib.c.

◆ InternalCreateKeyStrokesBuffer()

STATIC EFI_STATUS EFIAPI InternalCreateKeyStrokesBuffer ( IN APPLE_KEY_MAP_DATABASE_PROTOCOL * This,
IN UINTN BufferLength,
OUT UINTN * Index )

Creates a new key set with a given number of keys allocated. The index within the database is returned.

Parameters
[in]ThisA pointer to the protocol instance.
[in]BufferLengthThe amount of keys to allocate for the key set.
[out]IndexThe assigned index of the created key set.
Returns
Returned is the status of the operation.
Return values
EFI_SUCCESSA key set with the given number of keys allocated has been created.
EFI_OUT_OF_RESOURCESThe memory necessary to complete the operation could not be allocated.
otherAn error returned by a sub-operation.

Definition at line 400 of file OcAppleKeyMapLib.c.

◆ InternalGetKeyStrokes()

STATIC EFI_STATUS EFIAPI InternalGetKeyStrokes ( IN APPLE_KEY_MAP_AGGREGATOR_PROTOCOL * This,
OUT APPLE_MODIFIER_MAP * Modifiers,
IN OUT UINTN * NumberOfKeyCodes,
OUT APPLE_KEY_CODE *KeyCodes OPTIONAL )

Returns all pressed keys and key modifiers into the appropiate buffers.

Parameters
[in]ThisA pointer to the protocol instance.
[out]ModifiersThe modifiers manipulating the given keys.
[in,out]NumberOfKeyCodesOn input the number of keys allocated. On output the number of keys returned into KeyCodes.
[out]KeyCodesA Pointer to a caller-allocated buffer in which the pressed keys get returned.
Return values
EFI_SUCCESSThe pressed keys have been returned into KeyCodes.
EFI_BUFFER_TOO_SMALLThe memory required to return the value exceeds the size of the allocated Buffer. The required number of keys to allocate to complete the operation has been returned into NumberOfKeyCodes.
otherAn error returned by a sub-operation.

Definition at line 149 of file OcAppleKeyMapLib.c.

◆ InternalGetKeyStrokesByIndex()

STATIC APPLE_KEY_STROKES_INFO * InternalGetKeyStrokesByIndex ( IN KEY_MAP_AGGREGATOR_DATA * KeyMapAggregatorData,
IN UINTN Index )

Definition at line 95 of file OcAppleKeyMapLib.c.

◆ InternalRemoveKeyStrokesBuffer()

STATIC EFI_STATUS EFIAPI InternalRemoveKeyStrokesBuffer ( IN APPLE_KEY_MAP_DATABASE_PROTOCOL * This,
IN UINTN Index )

Removes a key set specified by its index from the database.

Parameters
[in]ThisA pointer to the protocol instance.
[in]IndexThe index of the key set to remove.
Returns
Returned is the status of the operation.
Return values
EFI_SUCCESSThe specified key set has been removed.
EFI_NOT_FOUNDNo key set could be found for the given index.
otherAn error returned by a sub-operation.

Definition at line 471 of file OcAppleKeyMapLib.c.

◆ InternalSetKeyStrokeBufferKeys()

STATIC EFI_STATUS EFIAPI InternalSetKeyStrokeBufferKeys ( IN APPLE_KEY_MAP_DATABASE_PROTOCOL * This,
IN UINTN Index,
IN APPLE_MODIFIER_MAP Modifiers,
IN UINTN NumberOfKeyCodes,
IN APPLE_KEY_CODE * KeyCodes )

Sets the keys of a key set specified by its index to the given KeyCodes Buffer.

Parameters
[in]ThisA pointer to the protocol instance.
[in]IndexThe index of the key set to edit.
[in]ModifiersThe key modifiers manipulating the given keys.
[in]NumberOfKeyCodesThe number of keys contained in KeyCodes.
[in]KeyCodesAn array of keys to add to the specified key set.
Returns
Returned is the status of the operation.
Return values
EFI_SUCCESSThe given keys were set for the specified key set.
EFI_OUT_OF_RESOURCESThe memory necessary to complete the operation could not be allocated.
EFI_NOT_FOUNDNo key set could be found for the given index.
otherAn error returned by a sub-operation.

Definition at line 525 of file OcAppleKeyMapLib.c.

◆ OcAppleKeyMapGetDatabase()

APPLE_KEY_MAP_DATABASE_PROTOCOL * OcAppleKeyMapGetDatabase ( VOID )

Returns the previously install Apple Key Map Database protocol.

Return values
installedor located protocol or NULL

Definition at line 575 of file OcAppleKeyMapLib.c.

◆ OcAppleKeyMapInstallProtocols()

APPLE_KEY_MAP_AGGREGATOR_PROTOCOL * OcAppleKeyMapInstallProtocols ( IN BOOLEAN Reinstall)

Install and initialise Apple Key Map protocols.

Parameters
[in]ReinstallOverwrite installed protocols.
Return values
installedor located protocol or NULL

Definition at line 590 of file OcAppleKeyMapLib.c.

◆ OcKeyMapFlush()

VOID OcKeyMapFlush ( IN APPLE_KEY_MAP_AGGREGATOR_PROTOCOL * KeyMap,
IN APPLE_KEY_CODE Key,
IN BOOLEAN FlushConsole )

Performs keyboard input flush.

Parameters
[in]KeyMapApple Key Map Aggregator protocol.
[in]KeyKey to wait for removal or 0.
[in]FlushConsoleAlso flush console input.

Definition at line 264 of file OcAppleKeyMapLib.c.

◆ OcKeyMapHasKey()

BOOLEAN OcKeyMapHasKey ( IN CONST APPLE_KEY_CODE * Keys,
IN UINTN NumKeys,
IN CONST APPLE_KEY_CODE KeyCode )

Checks whether or not a KeyCode is contained within Keys.

Parameters
[in]KeysThe reference keys.
[in]NumKeysThe number of keys in Keys.
[in]KeyCodeThe key to locate in Keys.
Returns
Whether the reference keys contain the checked key.

Definition at line 254 of file OcAppleKeyMapLib.c.

◆ OcKeyMapHasKeys()

BOOLEAN OcKeyMapHasKeys ( IN CONST APPLE_KEY_CODE * Keys,
IN UINTN NumKeys,
IN CONST APPLE_KEY_CODE * CheckKeys,
IN UINTN NumCheckKeys,
IN BOOLEAN ExactMatch )

Checks whether or not a list of keys is contained within another.

Parameters
[in]KeysThe reference keys.
[in]NumKeysThe number of keys in Keys.
[in]CheckKeysThe keys to locate in Keys.
[in]NumCheckKeysThe number of keys in CheckKeys.
[in]ExactMatchSpecifies whether matches must be exact.
Returns
Whether the reference keys contain the checked keys.

Definition at line 223 of file OcAppleKeyMapLib.c.

Variable Documentation

◆ mKeyMapDatabase

STATIC APPLE_KEY_MAP_DATABASE_PROTOCOL* mKeyMapDatabase = NULL

Definition at line 567 of file OcAppleKeyMapLib.c.