Saturday, August 8, 2015

ReadKey.py

Description

ReadKey.py has these samples, EDKII event (EFI_EVENT), SimpleTextIn protocol and function return value.

In ReadKey.py file, it waits EfiPy.gST.ConIn[0].WaitForKey event in while loop.
EfiPy.gST.ConIn[0] protocol read user input key while event function return EFI_SUCCESS.

In output message, it output EFI_INPUT_KEY data.

source code - WaitForEvent

  # while (RETURN_ERROR (Status)) {
  while EfiPy.RETURN_ERROR (Status):


    # Status = gBS->
WaitForEvent (
    #                 1,
    #                 & (EFI_EVENT)(gST->ConIn[0].WaitForKey),
    #                 & EventIndex,
    #                 );
    Status = EfiPy.gBS.WaitForEvent (
            1,
            EfiPy.byref(EfiPy.EFI_EVENT(EfiPy.gST.ConIn[0].WaitForKey)),
            EfiPy.byref(EventIndex)
            )

source code - ReadKeyStroke

  # Status = gST->ConIn[0].ReadKeyStroke (
  #                 gST.ConIn, &InputKey
  #                 );
  Status = EfiPy.gST.ConIn[0].ReadKeyStroke (
             EfiPy.gST.ConIn, EfiPy.byref (InputKey)
             )

source code - EFI_INPUT_KEY

  if InputKey.ScanCode != Si.SCAN_NULL:

    EfiPy.gST.ConOut[0].OutputString (
      EfiPy.gST.ConOut,
      u"Scan code 0x%04X is input\r\n" % InputKey.ScanCode
      )

  else:

    EfiPy.gST.ConOut[0].OutputString (
      EfiPy.gST.ConOut,
      u"Input key \"%c\"\r\n" % InputKey.UnicodeChar
      )

screenshot
Sample code from screenshot is uploaded to sourceforge

No comments:

Post a Comment