From b87fc6b140772ba3017de311c7063c259424264c Mon Sep 17 00:00:00 2001 From: Alex Date: Mon, 15 Aug 2016 17:11:31 +0200 Subject: First public release. Used by VeraCrypt 1.18. --- DcsCfg/DcsCfgTouch.c | 95 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 DcsCfg/DcsCfgTouch.c (limited to 'DcsCfg/DcsCfgTouch.c') diff --git a/DcsCfg/DcsCfgTouch.c b/DcsCfg/DcsCfgTouch.c new file mode 100644 index 0000000..3553052 --- /dev/null +++ b/DcsCfg/DcsCfgTouch.c @@ -0,0 +1,95 @@ +/** @file +DCS configuration. Touch devices. + +Copyright (c) 2016. Disk Cryptography Services for EFI (DCS), Alex Kolotnikov +Copyright (c) 2016. VeraCrypt, Mounir IDRASSI + +This program and the accompanying materials +are licensed and made available under the terms and conditions +of the GNU Lesser General Public License, version 3.0 (LGPL-3.0). + +The full text of the license may be found at +https://opensource.org/licenses/LGPL-3.0 +**/ + +#include +#include +#include +#include +#include + +#include "DcsCfg.h" + +////////////////////////////////////////////////////////////////////////// +// Touch +////////////////////////////////////////////////////////////////////////// +UINTN TouchIndex = 0; + +void TouchPrintDevicePath(EFI_HANDLE handle) { + EFI_ABSOLUTE_POINTER_PROTOCOL* absio = NULL; + EfiPrintDevicePath(handle); + TouchGetIO(handle, &absio); + if (absio != NULL) { + EFI_STATUS res; + EFI_ABSOLUTE_POINTER_STATE aps; + SetMem(&aps, sizeof(aps), 0); + res = absio->GetState(absio, &aps); + OUT_PRINT(L" - X[%lld,%lld] Y[%lld,%lld] Z[%lld,%lld] A[0x%x] S[%r (%lld,%lld,%lld), 0x%x]", + absio->Mode->AbsoluteMinX, absio->Mode->AbsoluteMaxX, + absio->Mode->AbsoluteMinY, absio->Mode->AbsoluteMaxY, + absio->Mode->AbsoluteMinZ, absio->Mode->AbsoluteMaxZ, + absio->Mode->Attributes, + res, aps.CurrentX, aps.CurrentY, aps.CurrentZ, aps.ActiveButtons + ); + } +} + +void TouchPrintDevicePathByIndex(UINTN touchIndex) { + OUT_PRINT(L"%V%d%N ", touchIndex); + TouchPrintDevicePath(gTouchHandles[touchIndex]); +} + +void TouchPrintDevicePaths(CHAR16* msg) { + UINTN i; + OUT_PRINT(msg); + for (i = 0; i < gTouchCount; ++i) { + TouchPrintDevicePathByIndex(i); + OUT_PRINT(L"\n"); + } +} + +VOID +PrintTouchList() { + InitTouch(); + TouchPrintDevicePaths(L"%HTouch handles%N\n"); +} + +VOID +TestTouch() { + EFI_ABSOLUTE_POINTER_PROTOCOL* absio = NULL; + EFI_HANDLE handle; + EFI_STATUS res; + + InitTouch(); + if (TouchIndex >= gTouchCount) return; + handle = gTouchHandles[TouchIndex]; + EfiPrintDevicePath(handle); + TouchGetIO(handle, &absio); + if (absio != NULL) { + EFI_ABSOLUTE_POINTER_STATE aps; + EFI_EVENT events[2]; + UINTN EventIndex; + + events[0] = gST->ConIn->WaitForKey; + events[1] = absio->WaitForInput; + do { + gBS->WaitForEvent(2, events, &EventIndex); + SetMem(&aps, sizeof(aps), 0); + res = absio->GetState(absio, &aps); + OUT_PRINT(L" S[%r (%lld,%lld,%lld), 0x%x]", + res, aps.CurrentX, aps.CurrentY, aps.CurrentZ, aps.ActiveButtons + ); + } while (EventIndex == 1); + } +} + -- cgit v1.2.3