VirtualBox

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

Last change on this file was 98103, checked in by vboxsync, 16 months ago

Copyright year updates by scm.

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

© 2023 Oracle
ContactPrivacy policyTerms of Use