summaryrefslogtreecommitdiff
path: root/Features/Intel/UserInterface/VirtualKeyboardFeaturePkg/VirtualKeyboardDxe/VirtualKeyboard.h
blob: d7b734057401713477a75aa5c404762725332c49 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
/** @file
  Header file for Virtual Keyboard driver.

  Copyright (c) 2012 - 2020, Intel Corporation. All rights reserved.<BR>
  SPDX-License-Identifier: BSD-2-Clause-Patent

**/

#ifndef _VIRTUAL_KEYBOARD_H_
#define _VIRTUAL_KEYBOARD_H_

#include <Uefi.h>
#include <Library/BaseMemoryLib.h>
#include <Library/DebugLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/UefiDriverEntryPoint.h>
#include <Library/UefiLib.h>
#include <Library/BaseLib.h>
#include <Library/PcdLib.h>
#include <Library/HiiLib.h>
#include <Protocol/AbsolutePointer.h>
#include <Protocol/GraphicsOutput.h>
#include <Protocol/SimpleTextIn.h>
#include <Protocol/SimpleTextInEx.h>
#include <Protocol/SimpleTextOut.h>
#include <Protocol/HiiDatabase.h>
#include <Protocol/HiiImageEx.h>
#include <Protocol/HiiPackageList.h>
#include <Guid/ConsoleInDevice.h>
#include "ComponentName.h"

//
// Global Variables
//
extern EFI_DRIVER_BINDING_PROTOCOL   gVirtualKeyboardDriverBinding;
extern EFI_COMPONENT_NAME_PROTOCOL   gVirtualKeyboardComponentName;
extern EFI_COMPONENT_NAME2_PROTOCOL  gVirtualKeyboardComponentName2;

///
/// Debug raw data points
///
#define DEBUG_VK_POINTS               DEBUG_INFO

///
/// Debug data point scaling
///
#define DEBUG_VK_POINT_SCALING        DEBUG_INFO

///
/// Debug key press
///
#define DEBUG_VK_KEYS                 DEBUG_INFO

///
/// Debug routine entry and exit
///
#define DEBUG_VK_ROUTINE_ENTRY_EXIT   DEBUG_VERBOSE

///
/// Display the graphics info
///
#define DEBUG_VK_GRAPHICS_INFO        DEBUG_INFO

///
/// Display the timer entry and exit
///
#define DEBUG_VK_TIMER_ENTRY_EXIT     DEBUG_VERBOSE

///
/// Signature
///
#define VK_SIGNATURE                  SIGNATURE_32 ('V', 'K', 'e', 'y')
#define VK_NOTIFY_SIGNATURE           SIGNATURE_32 ('V', 'K', 'n', 's')

///
/// Poll interval
///
#define VK_POLL_INTERVAL              (1000 * 1000)

///
/// Define the touch timeout in poll intervals
///
#define VK_REPEAT_TIMEOUT             5

///
/// TPL used to synchronize add/remove from list
///
#define TPL_VK_SYNC                   TPL_NOTIFY

///
/// Dimension of an array ( number of elements )
///
#define DIM(x)      ( sizeof ( x ) / sizeof ( x [ 0 ]))

///
/// Define Key buffer
///
#define MAX_KEY_BUF_SIZE 64

///
/// Define Transparent Weight
///
#define TRANSPARENCY_WEIGHT 50

typedef struct _VK_CONTEXT VK_CONTEXT;

typedef enum _VK_KEY_TYPE {
  VkKeyNull         = 0x0000 | CHAR_NULL,
  VkKeyBackspace    = 0x0000 | CHAR_BACKSPACE,
  VkKeyTab          = 0x0000 | CHAR_TAB,
  VkKeyEnter        = 0x0000 | CHAR_CARRIAGE_RETURN,
  VkKeyScanMask     = 0x1000,
  VkKeyEsc          = 0x1000 | SCAN_ESC,
  VkKeyLeft         = 0x1000 | SCAN_LEFT,
  VkKeyRight        = 0x1000 | SCAN_RIGHT,
  VkKeyUp           = 0x1000 | SCAN_UP,
  VkKeyDown         = 0x1000 | SCAN_DOWN,
  VkKeyF1           = 0x1000 | SCAN_F1,
  VkKeyF2           = 0x1000 | SCAN_F2,
  VkKeyF3           = 0x1000 | SCAN_F3,
  VkKeyF4           = 0x1000 | SCAN_F4,
  VkKeyF5           = 0x1000 | SCAN_F5,
  VkKeyF6           = 0x1000 | SCAN_F6,
  VkKeyF7           = 0x1000 | SCAN_F7,
  VkKeyF8           = 0x1000 | SCAN_F8,
  VkKeyF9           = 0x1000 | SCAN_F9,
  VkKeyF10          = 0x1000 | SCAN_F10,
  VkKeyF11          = 0x1000 | SCAN_F11,
  VkKeyF12          = 0x1000 | SCAN_F12,
  VkKeySpecificMask = 0x2000,
  VkKeyShift        = 0x2000 | 0x0000,
  VkKeyCapslock     = 0x2000 | 0x0001,
  VkKeyTwoPage      = 0x2000 | 0x0002,
  VkKeyTypeMaximum  = 0xFFFF
} VK_KEY_TYPE;

typedef enum _VK_PAGE_TYPE {
  //
  // +---+---+---+---+---+---+---+---+---+---+---+
  // | q | w | e | r | t | y | u | i | o | p |<X|| Line 0
  // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  // | | a | s | d | f | g | h | j | k | l | F2| | Line 1
  // +-+---+---+---+---+---+---+---+---+---+---+-+
  // |Caps | z | x | c | v | b | n | m |aU |Enter| Line 2
  // +-----+---+---+---+---+---+---+---+---+---+-+
  // | Esc |12#|       Space       |aL |aD |aR | | Line 3
  // +-----+---+-------------------+---+---+---+-+
  //
  VkPage0,

  //
  // +---+---+---+---+---+---+---+---+---+---+---+
  // | Q | W | E | R | T | Y | U | I | O | P |<X|| Line 0
  // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  // | | A | S | D | F | G | H | J | K | L | F2| | Line 1
  // +-+---+---+---+---+---+---+---+---+---+---+-+
  // |Caps | Z | X | C | V | B | N | M |aU |Enter| Line 2
  // +-----+---+---+---+---+---+---+---+---+---+-+
  // | Esc |12#|       Space       |aL |aD |aR | | Line 3
  // +-----+---+-------------------+---+---+---+-+
  //
  VkPage1,

  //
  // +---+---+---+---+---+---+---+---+---+---+---+
  // | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 |<X|| Line 0
  // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  // | |F1 |F2 |F3 |F4 |F5 |F6 |F7 |F8 |F9 |F10| | Line 1
  // +-+---+---+---+---+---+---+---+---+---+---+-+
  // |Shift| . | ; | ' | , | . | / |F11|F12|Enter| Line 2
  // +-----+---+---+---+---+---+---+---+---+---+-+
  // | Esc |12#|       Space       | \ | - | = | | Line 3
  // +-----+---+-------------------+---+---+---+-+
  //
  VkPage2,

  //
  // +---+---+---+---+---+---+---+---+---+---+---+
  // | ! | @ | # | $ | % | ^ | & | * | ( | ) |<X|| Line 0
  // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  // | |F1 |F2 |F3 |F4 |F5 |F6 |F7 |F8 |F9 |F10| | Line 1
  // +-+---+---+---+---+---+---+---+---+---+---+-+
  // |Shift| ~ | : | " | < | > | ? |F11|F12|Enter| Line 2
  // +-----+---+---+---+---+---+---+---+---+---+-+
  // | Esc |12#|       Space       | | | _ | + | | Line 3
  // +-----+---+-------------------+---+---+---+-+
  //
  VkPage3,
  VkPageMaximum
} VK_PAGE_TYPE;

typedef enum VK_DISPLAY_ATTRIBUTE {
  VkDisplayAttributeNone,         /// No keyboard displayed
  VkDisplayAttributeFullTop,      /// Full keyboard display at top
  VkDisplayAttributeFullBottom,   /// Full keyboard display at bottom
  VkDisplayAttributeSimpleTop,    /// Simple keyboard display at top
  VkDisplayAttributeSimpleBottom, /// Simple keyboard display at bottom
  VkDisplayAttributeMaximum
} VK_DISPLAY_ATTRIBUTE;

typedef struct _VK_STRUCT {
  UINT16      DisStartX;
  UINT16      DisStartY;
  UINT16      DisEndX;
  UINT16      DisEndY;
  VK_KEY_TYPE PageFont[VkPageMaximum];
} VK_STRUCT;

typedef struct _VK_NOTIFY {
  UINTN                               Signature;
  EFI_KEY_DATA                        KeyData;
  EFI_KEY_NOTIFY_FUNCTION             KeyNotificationFn;
  LIST_ENTRY                          NotifyEntry;
} VK_NOTIFY;

///
/// Virtual Keyboard context
///
struct _VK_CONTEXT {
  ///
  /// Structure identification
  ///
  UINTN                             Signature;

  ///
  /// Controller Handle
  ///
  EFI_HANDLE                        Controller;

  ///
  /// Upper level API
  ///
  EFI_SIMPLE_TEXT_INPUT_PROTOCOL    SimpleTextIn;

  ///
  /// Simple Text In EX
  ///
  EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL SimpleTextInEx;

  ///
  /// Lower level APIs
  ///
  EFI_ABSOLUTE_POINTER_PROTOCOL     *AbsolutePointer;
  EFI_GRAPHICS_OUTPUT_PROTOCOL      *GraphicsOutput;

  ///
  /// Flag when the last poll indicated a touch event
  ///
  BOOLEAN                           TouchActive;

  ///
  /// Time to poll for touch input
  ///
  EFI_EVENT                         TimerEvent;

  ///
  /// HII handle to get image data used
  ///
  EFI_HII_HANDLE                    HiiHandle;
  EFI_HII_IMAGE_EX_PROTOCOL         *HiiImageEx;

  ///
  /// Keyboard body background buffer information
  ///
  EFI_GRAPHICS_OUTPUT_BLT_PIXEL     *VkBodyBackgroundBltBuffer;
  EFI_GRAPHICS_OUTPUT_BLT_PIXEL     *VkBodyCompoundBltBuffer;
  UINTN                             VkBodyBltSize;
  UINTN                             VkBodyBltStartX;
  UINTN                             VkBodyBltStartY;
  UINTN                             VkBodyBltHeight;
  UINTN                             VkBodyBltWidth;
  BOOLEAN                           IsBackgroundChanged;

  ///
  /// Icon buffer information
  ///
  EFI_GRAPHICS_OUTPUT_BLT_PIXEL     *IconBltBuffer;
  UINTN                             IconBltSize;
  UINTN                             IconBltHeight;
  UINTN                             IconBltWidth;

  ///
  /// Full icon background buffer information
  ///
  EFI_GRAPHICS_OUTPUT_BLT_PIXEL     *FullIconBackBuffer;
  UINTN                             FullIconBackStartX;
  UINTN                             FullIconBackStartY;
  UINTN                             FullIconBackHeight;
  UINTN                             FullIconBackWidth;
  UINTN                             FullIconBackSize;
  BOOLEAN                           FullIconUpdatedFlag;

  ///
  /// Simple icon background buffer information
  ///
  EFI_GRAPHICS_OUTPUT_BLT_PIXEL     *SimIconBackBuffer;
  UINTN                             SimIconBackStartX;
  UINTN                             SimIconBackStartY;
  UINTN                             SimIconBackHeight;
  UINTN                             SimIconBackWidth;
  UINTN                             SimIconBackSize;
  BOOLEAN                           SimIconUpdatedFlag;

  ///
  /// Small Icon
  ///
  EFI_IMAGE_INPUT                   *SmallIcon;

  ///
  /// Full Icon
  ///
  EFI_IMAGE_INPUT                   *FullIcon;

  ///
  /// Simple Key body
  ///
  EFI_IMAGE_INPUT                   *SimKeyBody;

  ///
  /// Digital key body
  ///
  EFI_IMAGE_INPUT                   *DigKeyBody;

  ///
  /// Capital Letter Key board
  ///
  EFI_IMAGE_INPUT                   *CapLeKeyBody;

  ///
  /// Screen check buffer.
  /// This is used to check if screen is kept scrolling up.
  ///
  EFI_GRAPHICS_OUTPUT_BLT_PIXEL     *ScreenCheckBuffer;
  UINTN                             ScreenCheckBufferSize;

  ///
  /// Key state
  ///
  BOOLEAN                           KeyPressed;

  ///
  /// Keyboard display status
  ///
  VK_DISPLAY_ATTRIBUTE              CurrentKeyboardDisplay;
  VK_DISPLAY_ATTRIBUTE              TargetKeyboardDisplay;

  ///
  /// Keyboard icon display status
  ///
  BOOLEAN                           IsIconShowed;
  UINT8                             IconReDrawCheck;

  ///
  /// Keyboard body Image address
  /// Size of KeyboardBodyPtr must larger than mFullKeyboardBody
  ///
  UINT32                            NumOfKeysInfo;
  VK_STRUCT                         KeyboardBodyPtr[50];

  ///
  /// KeyBuffer
  ///
  EFI_EVENT                         KeyNotifyProcessEvent;
  EFI_KEY_TOGGLE_STATE              KeyToggleState;
  EFI_KEY_DATA                      Keybuffer[MAX_KEY_BUF_SIZE];
  UINT8                             KeyStartIndex;
  UINT8                             KeyEndIndex;
  UINT16                            KeyTouchedTimeOut;
  BOOLEAN                           IsShiftKeyFlag;
  BOOLEAN                           IsCapsLockFlag;
  BOOLEAN                           IsSupportPartialKey;
  BOOLEAN                           IsRedrawUpdateUI;
  VK_PAGE_TYPE                      PageNumber;
  LIST_ENTRY                        NotifyList;

  ///
  /// Previous X and Y axis Buffer
  ///
  UINTN                             PreviousX;
  UINTN                             PreviousY;
};

///
/// Locate VK_CONTEXT from protocol
///
#define VK_CONTEXT_FROM_PROTOCOL(a)                CR (a, VK_CONTEXT, SimpleTextIn, VK_SIGNATURE)
#define VK_CONTEXT_FROM_SIMPLETEXTINEX_PROTOCOL(a) CR (a, VK_CONTEXT, SimpleTextInEx, VK_SIGNATURE)
#define VK_CONTEXT_FROM_VKBD_PROTOCOL(a)           CR (a, VK_CONTEXT, VkbdProtocol, VK_SIGNATURE)

/**
  Start the virtual keyboard driver

  This routine allocates the necessary resources for the driver.

  This routine is called by VirtualKeyboardDriverStart to complete the driver
  initialization.

  @param[in, out] VkContext        Address of an VK_CONTEXT structure
  @param[in] Controller            Handle of device to work with.

  @retval EFI_SUCCESS              Driver API properly initialized

**/
EFI_STATUS
VkApiStart (
  IN OUT VK_CONTEXT *VkContext,
  IN EFI_HANDLE Controller
  );

/**
  Stop the virtual keyboard driver

  This routine releases the resources allocated by VKApiStart.

  This routine is called by VirtualKeyboardDriverStop to initiate the driver
  shutdown.

  @param[in] VkContext        Address of an VK_CONTEXT structure

**/
VOID
VkApiStop (
  IN VK_CONTEXT *VkContext
  );

/**
  Resets the input device hardware.

  The Reset() function resets the input device hardware. As part
  of initialization process, the firmware/device will make a quick
  but reasonable attempt to verify that the device is functioning.
  If the ExtendedVerification flag is TRUE the firmware may take
  an extended amount of time to verify the device is operating on
  reset. Otherwise the reset operation is to occur as quickly as
  possible. The hardware verification process is not defined by
  this specification and is left up to the platform firmware or
  driver to implement.

  @param[in] This                 A pointer to the EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL instance.

  @param[in] ExtendedVerification Indicates that the driver may perform a more exhaustive
                                  verification operation of the device during reset.

  @retval EFI_SUCCESS             The device was reset.
  @retval EFI_DEVICE_ERROR        The device is not functioning correctly and could not be reset.

**/
EFI_STATUS
EFIAPI
VkKeyboardReset (
  IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This,
  IN BOOLEAN                        ExtendedVerification
  );

/**
  Reads the next keystroke from the input device. The WaitForKey Event can
  be used to test for existence of a keystroke via WaitForEvent () call.

  @param[in]  This         Protocol instance pointer.
  @param[out] Key          Driver may perform diagnostics on reset.

  @retval EFI_SUCCESS      The keystroke information was returned.
  @retval EFI_NOT_READY    There was no keystroke data available.
  @retval EFI_DEVICE_ERROR The keystroke information was not returned due to
                           hardware errors.
  @retval EFI_UNSUPPORTED  The device does not support the ability to read keystroke data.

**/
EFI_STATUS
EFIAPI
VkKeyboardReadKeyStroke (
  IN  EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This,
  OUT EFI_INPUT_KEY                  *Key
  );

/**
  Resets the input device hardware.

  The Reset() function resets the input device hardware. As part
  of initialization process, the firmware/device will make a quick
  but reasonable attempt to verify that the device is functioning.
  If the ExtendedVerification flag is TRUE the firmware may take
  an extended amount of time to verify the device is operating on
  reset. Otherwise the reset operation is to occur as quickly as
  possible. The hardware verification process is not defined by
  this specification and is left up to the platform firmware or
  driver to implement.

  @param[in] This                 A pointer to the EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL instance.

  @param[in] ExtendedVerification Indicates that the driver may perform a more exhaustive
                                  verification operation of the device during reset.

  @retval EFI_SUCCESS             The device was reset.
  @retval EFI_DEVICE_ERROR        The device is not functioning correctly and could not be reset.

**/
EFI_STATUS
EFIAPI
VkKeyboardResetEx (
  IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,
  IN BOOLEAN                           ExtendedVerification
  );

/**
  Reads the next keystroke from the input device.

  @param[in]  This               Protocol instance pointer.
  @param[out] KeyData            A pointer to a buffer that is filled in with the keystroke
                                 state data for the key that was pressed.

  @retval EFI_SUCCESS            The keystroke information was returned.
  @retval EFI_NOT_READY          There was no keystroke data available.
  @retval EFI_INVALID_PARAMETER  This or KeyData is NULL.
  @retval EFI_UNSUPPORTED        The device does not support the ability to read keystroke data.

**/
EFI_STATUS
EFIAPI
VkKeyboardReadKeyStrokeEx (
  IN  EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,
  OUT EFI_KEY_DATA                      *KeyData
  );

/**
  Set certain state for the input device.

  @param[in] This                 Protocol instance pointer.
  @param[in] KeyToggleState       A pointer to the EFI_KEY_TOGGLE_STATE to set the
                                  state for the input device.

  @retval EFI_SUCCESS             The device state was set appropriately.
  @retval EFI_INVALID_PARAMETER   This or KeyToggleState is NULL.

**/
EFI_STATUS
EFIAPI
VkKeyboardSetState (
  IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,
  IN EFI_KEY_TOGGLE_STATE              *KeyToggleState
  );

/**
  Register a notification function for a particular keystroke for the input device.

  @param[in]  This                        Protocol instance pointer.
  @param[in]  KeyData                     A pointer to a buffer that is filled in with the keystroke
                                          information data for the key that was pressed.
  @param[in]  KeyNotificationFunction     Points to the function to be called when the key
                                          sequence is typed specified by KeyData.
  @param[out] NotifyHandle                Points to the unique handle assigned to the registered notification.

  @retval EFI_SUCCESS                     The notification function was registered successfully.
  @retval EFI_OUT_OF_RESOURCES            Unable to allocate resources for necessary data structures.
  @retval EFI_INVALID_PARAMETER           KeyData or NotifyHandle or KeyNotificationFunction is NULL.

**/
EFI_STATUS
EFIAPI
VkKeyboardRegisterKeyNotify (
  IN  EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,
  IN  EFI_KEY_DATA                      *KeyData,
  IN  EFI_KEY_NOTIFY_FUNCTION           KeyNotificationFunction,
  OUT EFI_HANDLE                        *NotifyHandle
  );

/**
  Remove a registered notification function from a particular keystroke.

  @param[in] This                Protocol instance pointer.
  @param[in] NotificationHandle  The handle of the notification function being unregistered.

  @retval EFI_SUCCESS            The notification function was unregistered successfully.
  @retval EFI_INVALID_PARAMETER  The NotificationHandle is invalid

**/
EFI_STATUS
EFIAPI
VkKeyboardUnregisterKeyNotify (
  IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,
  IN EFI_HANDLE                        NotificationHandle
  );

/**
  Draw key board on the display

  @param[in] VkContext          Graphic Protocol for draw the alphabet.

  @retval EFI_SUCCESS           Draw keyboard was done.
  @retval EFI_UNSUPPORTED       Did not get key mapping table.

**/
EFI_STATUS
DrawKeyboardLayout (
  IN VK_CONTEXT *VkContext
  );

/**
  Clear the keyboard body

  @param[in] VkContext          Code context.

  @retval EFI_SUCCESS           Clear rectangle is done.

**/
EFI_STATUS
HideVkBody (
  IN VK_CONTEXT *VkContext
  );

/**
  Clear the keyboard icon

  @param[in] VkContext          Code context.

  @retval EFI_SUCCESS           Clear rectangle is done.

**/
EFI_STATUS
HideVkIcon (
  IN VK_CONTEXT *VkContext
  );

/**
  Use to draw the keyboard icon.

  @param[in] VkContext  Pointer to virtual keyboard's context
  @param[in] VkImage    Image of keyboard to display on the screen.
  @param[in] Attribute  Attribute of keyboard to display on the screen.

  @retval EFI_SUCCESS           ConsoleControl has been flipped to graphics and keyboard icon displayed.
  @retval EFI_UNSUPPORTED       KeyboardFile not found
  @retval EFI_INVALID_PARAMETER Attribute is unknown.

**/
EFI_STATUS
EFIAPI
DrawVkIcon (
  IN VK_CONTEXT                    *VkContext,
  IN EFI_IMAGE_INPUT               *VkImage,
  IN VK_DISPLAY_ATTRIBUTE          Attribute
  );

/**
  Use to draw the keyboard.

  @param[in] VkContext  Pointer to virtual keyboard's context
  @param[in] VkImage    Image of keyboard to display on the screen.
  @param[in] Attribute  Attribute of keyboard to display on the screen.

  @retval EFI_SUCCESS           ConsoleControl has been flipped to graphics and keyboard displayed.
  @retval EFI_UNSUPPORTED       KeyboardFile not found
  @retval EFI_INVALID_PARAMETER Attribute is unknown.

**/
EFI_STATUS
EFIAPI
DrawVkBody (
  IN VK_CONTEXT                    *VkContext,
  IN EFI_IMAGE_INPUT               *VkImage,
  IN VK_DISPLAY_ATTRIBUTE          Attribute
  );

/**
  Get unicode by VkContext->PageNumber and VkContext->KeyboardBodyPtr.

  @param[in]  VkContext            Address of an VK_CONTEXT structure.
  @param[in]  KeyItem              Key Item.
  @param[out] FontPtr              Follow VkContext->PageNumber to translate
                                   font unicode.

  @retval EFI_SUCCESS              Finish translating FontPtr.
  @retval EFI_INVALID_PARAMETER    VkContext or FontPtr is NULL.

**/
EFI_STATUS
VkGetMappingFont (
  IN  VK_CONTEXT *VkContext,
  IN  VK_STRUCT  KeyItem,
  OUT UINT32     *FontPtr
  );

/**
  This routine is used to check if icon has been cleared.

  @param[in] VkContext  Pointer to virtual keyboard's context

  @retval EFI_SUCCESS   Function completed.

**/
EFI_STATUS
CheckIconCleared (
  IN VK_CONTEXT *VkContext
  );

/**
  ConvertCoordinate - Convert the touch panel's coordinate to display's coordinate.

  @param[in]  VkContext             Virtual Keyboard context.
  @param[in]  Point                 The coordinate reported from touch panel.
  @param[out] TouchX                The coordinate X converted to display panel.
  @param[out] TouchY                The coordinate Y converted to display panel..

  @retval EFI_SUCCESS               Convert success.

**/
EFI_STATUS
ConvertCoordinate (
  IN  VK_CONTEXT                 *VkContext,
  IN  EFI_ABSOLUTE_POINTER_STATE Point,
  OUT UINT32                     *TouchX,
  OUT UINT32                     *TouchY
  );

/**
  This routine is used to check if screen has been cleared.

  @param[in] VkContext  Pointer to virtual keyboard's context

  @retval EFI_SUCCESS   Function completed.

**/
EFI_STATUS
CheckScreenCleared (
  IN VK_CONTEXT *VkContext
  );

/**
  This routine is used to check if background beneath virtual keyboard has been cleared.

  @param[in] VkContext  Pointer to virtual keyboard's context

  @retval EFI_SUCCESS   Function completed.

**/
EFI_STATUS
CheckBackgroundChanged (
  IN VK_CONTEXT *VkContext
  );

/**
  To prevent screen keyboard layout occur scroll up

  @param[in, out]  VkContext            Address of an VK_CONTEXT structure.

**/
VOID
PreventScreenScrollUp (
  IN OUT VK_CONTEXT *VkContext
  );

/**
  Set the position of character.

  @param[in] VkContext      Address of an VK_CONTEXT structure.
  @param[in] DestX          X position.
  @param[in] DestY          Y position.

  @retval EFI_SUCCESS       Success for the function.
  @retval Others            An unexpected error occurred.

**/
EFI_STATUS
SetCharacterPosition (
  IN VK_CONTEXT *VkContext,
  IN UINT32     DestX,
  IN UINT32     DestY
  );

/**
  Set the keyboard layout.

  @param[in] VkContext          Graphic Protocol for draw the alphabet.
  @param[in] Index              The layout selected.

  @retval EFI_SUCCESS           Draw keyboard was done.
  @retval Others                An unexpected error occurred.

**/
EFI_STATUS
KeyboardLayoutHandler (
  IN VK_CONTEXT *VkContext,
  IN UINT32     Index
  );

/**
  Save the background blt buffer.

  @param[in] VkContext           Address of an VK_CONTEXT structure.
  @param[in] BltSize             Size of blt.

  @retval EFI_SUCCESS            Success for the function.
  @retval EFI_OUT_OF_RESOURCES   Allocate memory failed.

**/
EFI_STATUS
EFIAPI
SaveVkBodyBackgroundBltBuffer (
  IN VK_CONTEXT *VkContext,
  IN UINTN      BltSize
  );

/**
  Restore the background blt buffer.

  @param[in] VkContext           Address of an VK_CONTEXT structure.

  @retval EFI_SUCCESS            Success for the function.
  @retval EFI_UNSUPPORTED        Input blt buffer is NULL.
  @retval Others                 An unexpected error occurred.

**/
EFI_STATUS
EFIAPI
RestoreVkBodyBackgroundBltBuffer (
  IN VK_CONTEXT *VkContext
  );

/**
  Save the icon background blt buffer.

  @param[in] VkContext      Address of an VK_CONTEXT structure.
  @param[in] IconType       The icon type.

  @retval EFI_SUCCESS            Success for the function.
  @retval EFI_OUT_OF_RESOURCES   Allocate memory failed.
  @retval Others                 An unexpected error occurred.

**/
EFI_STATUS
EFIAPI
SaveVkIconBackgroundBltBuffer (
  IN VK_CONTEXT           *VkContext,
  IN VK_DISPLAY_ATTRIBUTE IconType
  );
#endif