Unverified Commit 32d78ab4 authored by Tong Mu's avatar Tong Mu Committed by GitHub

[Windows, Keyboard] Fix logical key for PrintScreen (#94454)

parent 418cd956
...@@ -46,75 +46,11 @@ abstract class KeyboardKey with Diagnosticable { ...@@ -46,75 +46,11 @@ abstract class KeyboardKey with Diagnosticable {
/// look at the physical key to make sure that regardless of the character the /// look at the physical key to make sure that regardless of the character the
/// key produces, you got the key that is in that location on the keyboard. /// key produces, you got the key that is in that location on the keyboard.
/// ///
/// {@tool dartpad --template=stateful_widget_scaffold} /// {@tool dartpad}
/// This example shows how to detect if the user has selected the logical "Q" /// This example shows how to detect if the user has selected the logical "Q"
/// key. /// key.
/// ///
/// ```dart imports /// ** See code in examples/api/lib/services/keyboard_key/logical_keyboard_key.0.dart **
/// import 'package:flutter/foundation.dart';
/// import 'package:flutter/services.dart';
/// ```
///
/// ```dart
/// // The node used to request the keyboard focus.
/// final FocusNode _focusNode = FocusNode();
/// // The message to display.
/// String? _message;
///
/// // Focus nodes need to be disposed.
/// @override
/// void dispose() {
/// _focusNode.dispose();
/// super.dispose();
/// }
///
/// // Handles the key events from the RawKeyboardListener and update the
/// // _message.
/// void _handleKeyEvent(RawKeyEvent event) {
/// setState(() {
/// if (event.logicalKey == LogicalKeyboardKey.keyQ) {
/// _message = 'Pressed the "Q" key!';
/// } else {
/// if (kReleaseMode) {
/// _message = 'Not a Q: Pressed 0x${event.logicalKey.keyId.toRadixString(16)}';
/// } else {
/// // The debugName will only print useful information in debug mode.
/// _message = 'Not a Q: Pressed ${event.logicalKey.debugName}';
/// }
/// }
/// });
/// }
///
/// @override
/// Widget build(BuildContext context) {
/// final TextTheme textTheme = Theme.of(context).textTheme;
/// return Container(
/// color: Colors.white,
/// alignment: Alignment.center,
/// child: DefaultTextStyle(
/// style: textTheme.headline4!,
/// child: RawKeyboardListener(
/// focusNode: _focusNode,
/// onKey: _handleKeyEvent,
/// child: AnimatedBuilder(
/// animation: _focusNode,
/// builder: (BuildContext context, Widget? child) {
/// if (!_focusNode.hasFocus) {
/// return GestureDetector(
/// onTap: () {
/// FocusScope.of(context).requestFocus(_focusNode);
/// },
/// child: const Text('Tap to focus'),
/// );
/// }
/// return Text(_message ?? 'Press a key');
/// },
/// ),
/// ),
/// ),
/// );
/// }
/// ```
/// {@end-tool} /// {@end-tool}
/// See also: /// See also:
/// ///
...@@ -318,9 +254,9 @@ class LogicalKeyboardKey extends KeyboardKey { ...@@ -318,9 +254,9 @@ class LogicalKeyboardKey extends KeyboardKey {
@override @override
void debugFillProperties(DiagnosticPropertiesBuilder properties) { void debugFillProperties(DiagnosticPropertiesBuilder properties) {
super.debugFillProperties(properties); super.debugFillProperties(properties);
properties.add(StringProperty('keyId', '0x${keyId.toRadixString(16).padLeft(8, '0')}', showName: true)); properties.add(StringProperty('keyId', '0x${keyId.toRadixString(16).padLeft(8, '0')}'));
properties.add(StringProperty('keyLabel', keyLabel, showName: true)); properties.add(StringProperty('keyLabel', keyLabel));
properties.add(StringProperty('debugName', debugName, showName: true, defaultValue: null)); properties.add(StringProperty('debugName', debugName, defaultValue: null));
} }
@@@MASK_CONSTANTS@@@ @@@MASK_CONSTANTS@@@
...@@ -365,69 +301,11 @@ class LogicalKeyboardKey extends KeyboardKey { ...@@ -365,69 +301,11 @@ class LogicalKeyboardKey extends KeyboardKey {
/// looking for "the key next to the TAB key", since on a French keyboard, /// looking for "the key next to the TAB key", since on a French keyboard,
/// the key next to the TAB key has an "A" on it. /// the key next to the TAB key has an "A" on it.
/// ///
/// {@tool dartpad --template=stateful_widget_scaffold} /// {@tool dartpad}
/// This example shows how to detect if the user has selected the physical key /// This example shows how to detect if the user has selected the physical key
/// to the right of the CAPS LOCK key. /// to the right of the CAPS LOCK key.
/// ///
/// ```dart imports /// ** See code in examples/api/lib/services/keyboard_key/physical_keyboard_key.0.dart **
/// import 'package:flutter/services.dart';
/// ```
///
/// ```dart
/// // The node used to request the keyboard focus.
/// final FocusNode _focusNode = FocusNode();
/// // The message to display.
/// String? _message;
///
/// // Focus nodes need to be disposed.
/// @override
/// void dispose() {
/// _focusNode.dispose();
/// super.dispose();
/// }
///
/// // Handles the key events from the RawKeyboardListener and update the
/// // _message.
/// void _handleKeyEvent(RawKeyEvent event) {
/// setState(() {
/// if (event.physicalKey == PhysicalKeyboardKey.keyA) {
/// _message = 'Pressed the key next to CAPS LOCK!';
/// } else {
/// _message = 'Wrong key.';
/// }
/// });
/// }
///
/// @override
/// Widget build(BuildContext context) {
/// final TextTheme textTheme = Theme.of(context).textTheme;
/// return Container(
/// color: Colors.white,
/// alignment: Alignment.center,
/// child: DefaultTextStyle(
/// style: textTheme.headline4!,
/// child: RawKeyboardListener(
/// focusNode: _focusNode,
/// onKey: _handleKeyEvent,
/// child: AnimatedBuilder(
/// animation: _focusNode,
/// builder: (BuildContext context, Widget? child) {
/// if (!_focusNode.hasFocus) {
/// return GestureDetector(
/// onTap: () {
/// FocusScope.of(context).requestFocus(_focusNode);
/// },
/// child: const Text('Tap to focus'),
/// );
/// }
/// return Text(_message ?? 'Press a key');
/// },
/// ),
/// ),
/// ),
/// );
/// }
/// ```
/// {@end-tool} /// {@end-tool}
/// ///
/// See also: /// See also:
...@@ -483,8 +361,8 @@ class PhysicalKeyboardKey extends KeyboardKey { ...@@ -483,8 +361,8 @@ class PhysicalKeyboardKey extends KeyboardKey {
@override @override
void debugFillProperties(DiagnosticPropertiesBuilder properties) { void debugFillProperties(DiagnosticPropertiesBuilder properties) {
super.debugFillProperties(properties); super.debugFillProperties(properties);
properties.add(StringProperty('usbHidUsage', '0x${usbHidUsage.toRadixString(16).padLeft(8, '0')}', showName: true)); properties.add(StringProperty('usbHidUsage', '0x${usbHidUsage.toRadixString(16).padLeft(8, '0')}'));
properties.add(StringProperty('debugName', debugName, showName: true, defaultValue: null)); properties.add(StringProperty('debugName', debugName, defaultValue: null));
} }
// Key constants for all keyboard keys in the USB HID specification at the // Key constants for all keyboard keys in the USB HID specification at the
......
...@@ -3075,6 +3075,9 @@ ...@@ -3075,6 +3075,9 @@
"gtk": [ "gtk": [
"3270_PrintScreen" "3270_PrintScreen"
], ],
"windows": [
"SNAPSHOT"
],
"android": [ "android": [
"SYSRQ" "SYSRQ"
], ],
...@@ -3086,6 +3089,9 @@ ...@@ -3086,6 +3089,9 @@
"gtk": [ "gtk": [
64797 64797
], ],
"windows": [
44
],
"android": [ "android": [
120 120
], ],
......
...@@ -80,6 +80,17 @@ ...@@ -80,6 +80,17 @@
"xkb": 641 "xkb": 641
} }
}, },
"MicrophoneMuteToggle": {
"names": {
"name": "MicrophoneMuteToggle",
"chromium": "MicrophoneMuteToggle"
},
"scanCodes": {
"usb": 24,
"linux": 248,
"xkb": 256
}
},
"Sleep": { "Sleep": {
"names": { "names": {
"name": "Sleep", "name": "Sleep",
......
...@@ -27,7 +27,6 @@ ...@@ -27,7 +27,6 @@
"Select": ["SELECT"], "Select": ["SELECT"],
"Print": ["PRINT"], "Print": ["PRINT"],
"Execute": ["EXECUTE"], "Execute": ["EXECUTE"],
"Snapshot": ["SNAPSHOT"],
"Insert": ["INSERT"], "Insert": ["INSERT"],
"Delete": ["DELETE"], "Delete": ["DELETE"],
"Help": ["HELP"], "Help": ["HELP"],
...@@ -36,6 +35,7 @@ ...@@ -36,6 +35,7 @@
"ContextMenu": ["APPS"], "ContextMenu": ["APPS"],
"PageDown": ["NEXT"], "PageDown": ["NEXT"],
"PageUp": ["PRIOR"], "PageUp": ["PRIOR"],
"PrintScreen": ["SNAPSHOT"],
"Numpad0": ["NUMPAD0"], "Numpad0": ["NUMPAD0"],
"Numpad1": ["NUMPAD1"], "Numpad1": ["NUMPAD1"],
"Numpad2": ["NUMPAD2"], "Numpad2": ["NUMPAD2"],
......
...@@ -3600,6 +3600,12 @@ class PhysicalKeyboardKey extends KeyboardKey { ...@@ -3600,6 +3600,12 @@ class PhysicalKeyboardKey extends KeyboardKey {
/// See the function [RawKeyEvent.physicalKey] for more information. /// See the function [RawKeyEvent.physicalKey] for more information.
static const PhysicalKeyboardKey privacyScreenToggle = PhysicalKeyboardKey(0x00000017); static const PhysicalKeyboardKey privacyScreenToggle = PhysicalKeyboardKey(0x00000017);
/// Represents the location of the "Microphone Mute Toggle" key on a
/// generalized keyboard.
///
/// See the function [RawKeyEvent.physicalKey] for more information.
static const PhysicalKeyboardKey microphoneMuteToggle = PhysicalKeyboardKey(0x00000018);
/// Represents the location of the "Sleep" key on a generalized keyboard. /// Represents the location of the "Sleep" key on a generalized keyboard.
/// ///
/// See the function [RawKeyEvent.physicalKey] for more information. /// See the function [RawKeyEvent.physicalKey] for more information.
...@@ -5031,6 +5037,7 @@ class PhysicalKeyboardKey extends KeyboardKey { ...@@ -5031,6 +5037,7 @@ class PhysicalKeyboardKey extends KeyboardKey {
0x00000015: resume, 0x00000015: resume,
0x00000016: turbo, 0x00000016: turbo,
0x00000017: privacyScreenToggle, 0x00000017: privacyScreenToggle,
0x00000018: microphoneMuteToggle,
0x00010082: sleep, 0x00010082: sleep,
0x00010083: wakeUp, 0x00010083: wakeUp,
0x000100b5: displayToggleIntExt, 0x000100b5: displayToggleIntExt,
...@@ -5304,6 +5311,7 @@ class PhysicalKeyboardKey extends KeyboardKey { ...@@ -5304,6 +5311,7 @@ class PhysicalKeyboardKey extends KeyboardKey {
0x00000015: 'Resume', 0x00000015: 'Resume',
0x00000016: 'Turbo', 0x00000016: 'Turbo',
0x00000017: 'Privacy Screen Toggle', 0x00000017: 'Privacy Screen Toggle',
0x00000018: 'Microphone Mute Toggle',
0x00010082: 'Sleep', 0x00010082: 'Sleep',
0x00010083: 'Wake Up', 0x00010083: 'Wake Up',
0x000100b5: 'Display Toggle Int Ext', 0x000100b5: 'Display Toggle Int Ext',
......
...@@ -784,6 +784,7 @@ const Map<int, PhysicalKeyboardKey> kFuchsiaToPhysicalKey = <int, PhysicalKeyboa ...@@ -784,6 +784,7 @@ const Map<int, PhysicalKeyboardKey> kFuchsiaToPhysicalKey = <int, PhysicalKeyboa
0x00000015: PhysicalKeyboardKey.resume, 0x00000015: PhysicalKeyboardKey.resume,
0x00000016: PhysicalKeyboardKey.turbo, 0x00000016: PhysicalKeyboardKey.turbo,
0x00000017: PhysicalKeyboardKey.privacyScreenToggle, 0x00000017: PhysicalKeyboardKey.privacyScreenToggle,
0x00000018: PhysicalKeyboardKey.microphoneMuteToggle,
0x00010082: PhysicalKeyboardKey.sleep, 0x00010082: PhysicalKeyboardKey.sleep,
0x00010083: PhysicalKeyboardKey.wakeUp, 0x00010083: PhysicalKeyboardKey.wakeUp,
0x000100b5: PhysicalKeyboardKey.displayToggleIntExt, 0x000100b5: PhysicalKeyboardKey.displayToggleIntExt,
...@@ -2108,6 +2109,7 @@ const Map<int, PhysicalKeyboardKey> kLinuxToPhysicalKey = <int, PhysicalKeyboard ...@@ -2108,6 +2109,7 @@ const Map<int, PhysicalKeyboardKey> kLinuxToPhysicalKey = <int, PhysicalKeyboard
0x000000f2: PhysicalKeyboardKey.save, 0x000000f2: PhysicalKeyboardKey.save,
0x000000f3: PhysicalKeyboardKey.launchDocuments, 0x000000f3: PhysicalKeyboardKey.launchDocuments,
0x000000fc: PhysicalKeyboardKey.brightnessAuto, 0x000000fc: PhysicalKeyboardKey.brightnessAuto,
0x00000100: PhysicalKeyboardKey.microphoneMuteToggle,
0x0000016e: PhysicalKeyboardKey.info, 0x0000016e: PhysicalKeyboardKey.info,
0x00000172: PhysicalKeyboardKey.programGuide, 0x00000172: PhysicalKeyboardKey.programGuide,
0x0000017a: PhysicalKeyboardKey.closedCaptionToggle, 0x0000017a: PhysicalKeyboardKey.closedCaptionToggle,
...@@ -2637,6 +2639,7 @@ const Map<String, PhysicalKeyboardKey> kWebToPhysicalKey = <String, PhysicalKeyb ...@@ -2637,6 +2639,7 @@ const Map<String, PhysicalKeyboardKey> kWebToPhysicalKey = <String, PhysicalKeyb
'MediaTrackPrevious': PhysicalKeyboardKey.mediaTrackPrevious, 'MediaTrackPrevious': PhysicalKeyboardKey.mediaTrackPrevious,
'MetaLeft': PhysicalKeyboardKey.metaLeft, 'MetaLeft': PhysicalKeyboardKey.metaLeft,
'MetaRight': PhysicalKeyboardKey.metaRight, 'MetaRight': PhysicalKeyboardKey.metaRight,
'MicrophoneMuteToggle': PhysicalKeyboardKey.microphoneMuteToggle,
'Minus': PhysicalKeyboardKey.minus, 'Minus': PhysicalKeyboardKey.minus,
'New': PhysicalKeyboardKey.newKey, 'New': PhysicalKeyboardKey.newKey,
'NonConvert': PhysicalKeyboardKey.nonConvert, 'NonConvert': PhysicalKeyboardKey.nonConvert,
...@@ -2806,6 +2809,7 @@ const Map<int, LogicalKeyboardKey> kWindowsToLogicalKey = <int, LogicalKeyboardK ...@@ -2806,6 +2809,7 @@ const Map<int, LogicalKeyboardKey> kWindowsToLogicalKey = <int, LogicalKeyboardK
41: LogicalKeyboardKey.select, 41: LogicalKeyboardKey.select,
42: LogicalKeyboardKey.print, 42: LogicalKeyboardKey.print,
43: LogicalKeyboardKey.execute, 43: LogicalKeyboardKey.execute,
44: LogicalKeyboardKey.printScreen,
45: LogicalKeyboardKey.insert, 45: LogicalKeyboardKey.insert,
46: LogicalKeyboardKey.delete, 46: LogicalKeyboardKey.delete,
47: LogicalKeyboardKey.help, 47: LogicalKeyboardKey.help,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment