VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/platform/win/WinKeyboard.h@ 74942

Last change on this file since 74942 was 71784, checked in by vboxsync, 6 years ago

FE/Qt: bugref:9049: VBoxGlobal library fixes for Windows.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.5 KB
Line 
1/* $Id: WinKeyboard.h 71784 2018-04-09 15:56:21Z vboxsync $ */
2/** @file
3 * VBox Qt GUI - Declarations of utility functions for handling Windows Keyboard specific tasks.
4 */
5
6/*
7 * Copyright (C) 2014-2018 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18#ifndef ___WinKeyboard_h___
19#define ___WinKeyboard_h___
20
21/* GUI includes: */
22#include "UILibraryDefs.h"
23
24/* Other VBox includes: */
25#include <iprt/win/windows.h>
26
27SHARED_LIBRARY_STUFF void * WinHidDevicesKeepLedsState(void);
28SHARED_LIBRARY_STUFF void WinHidDevicesApplyAndReleaseLedsState(void *pData);
29SHARED_LIBRARY_STUFF void WinHidDevicesBroadcastLeds(bool fNumLockOn, bool fCapsLockOn, bool fScrollLockOn);
30
31SHARED_LIBRARY_STUFF bool winHidLedsInSync(bool fNumLockOn, bool fCapsLockOn, bool fScrollLockOn);
32
33/** Helper class to deal with Windows AltGr handling.
34 *
35 * Background: Windows sends AltGr key down and up events as two events: a
36 * left control event and a right alt one. Since the left control event does
37 * not correspond to actually pressing or releasing the left control key we
38 * would like to detect it and handle it. This class monitors all key down and
39 * up events and if it detects that a left control down event has been sendt
40 * although left control should be up it tells us to insert a left control up
41 * event into the event stream. While this does not let us filter out the
42 * unwanted event at source, it should still make guest system keyboard handling
43 * work correctly. */
44class SHARED_LIBRARY_STUFF WinAltGrMonitor
45{
46public:
47
48 /** Constructor. */
49 WinAltGrMonitor() : m_enmFakeControlDetectionState(NONE), m_timeOfLastKeyEvent(0) {}
50
51 /** All key events should be fed to this method.
52 * @param iDownScanCode the scan code stripped of the make/break bit
53 * @param fKeyDown is this a key down event?
54 * @param fExtended is this an extended scan code? */
55 void updateStateFromKeyEvent(unsigned iDownScanCode, bool fKeyDown, bool fExtended);
56
57 /** Do we need to insert a left control up into the stream? */
58 bool isLeftControlReleaseNeeded() const;
59
60 /** Can we tell for sure at this point that the current message is a fake
61 * control event? This method might fail to recognise a fake event, but
62 * should never incorrectly flag a non-fake one.
63 * @note We deliberately do not call this from the host combination editor
64 * in an attempt to ensure that the other code path also gets enough
65 * test coverage.
66 */
67 bool isCurrentEventDefinitelyFake(unsigned iDownScanCode,
68 bool fKeyDown,
69 bool fExtendedKey) const;
70
71private:
72
73 /** State detection for fake control events which we may have missed. */
74 enum
75 {
76 /** No interesting state. */
77 NONE,
78 /** The last keypress might be a fake control. */
79 LAST_EVENT_WAS_LEFT_CONTROL_DOWN,
80 /** Left control is down, so we ignore fake control events. */
81 LEFT_CONTROL_DOWN,
82 /** A fake control down event and no up was passed to the guest. */
83 FAKE_CONTROL_DOWN
84 } m_enmFakeControlDetectionState;
85 LONG m_timeOfLastKeyEvent;
86};
87
88#endif
89
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use