VirtualBox

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

Last change on this file since 76553 was 76553, checked in by vboxsync, 5 years ago

scm --update-copyright-year

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

© 2023 Oracle
ContactPrivacy policyTerms of Use