/ src / settings-ui / Settings.UI / Helpers / NativeKeyboardHelper.cs
NativeKeyboardHelper.cs
 1  // Copyright (c) Microsoft Corporation
 2  // The Microsoft Corporation licenses this file to you under the MIT license.
 3  // See the LICENSE file in the project root for more information.
 4  
 5  using System;
 6  using System.Runtime.InteropServices;
 7  
 8  namespace Microsoft.PowerToys.Settings.UI.Helpers
 9  {
10      internal static class NativeKeyboardHelper
11      {
12          [StructLayout(LayoutKind.Sequential)]
13          [System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.NamingRules", "SA1307:Accessible fields should begin with upper-case letter", Justification = "Matching Native Structure")]
14          internal struct INPUT
15          {
16              internal INPUTTYPE type;
17              internal InputUnion data;
18  
19              internal static int Size
20              {
21                  get { return Marshal.SizeOf<INPUT>(); }
22              }
23          }
24  
25          [StructLayout(LayoutKind.Explicit)]
26          [System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.NamingRules", "SA1307:Accessible fields should begin with upper-case letter", Justification = "Matching Native Structure")]
27          internal struct InputUnion
28          {
29              [FieldOffset(0)]
30              internal MOUSEINPUT mi;
31              [FieldOffset(0)]
32              internal KEYBDINPUT ki;
33              [FieldOffset(0)]
34              internal HARDWAREINPUT hi;
35          }
36  
37          [StructLayout(LayoutKind.Sequential)]
38          [System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.NamingRules", "SA1307:Accessible fields should begin with upper-case letter", Justification = "Matching Native Structure")]
39          internal struct MOUSEINPUT
40          {
41              internal int dx;
42              internal int dy;
43              internal int mouseData;
44              internal uint dwFlags;
45              internal uint time;
46              internal UIntPtr dwExtraInfo;
47          }
48  
49          [StructLayout(LayoutKind.Sequential)]
50          [System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.NamingRules", "SA1307:Accessible fields should begin with upper-case letter", Justification = "Matching Native Structure")]
51          internal struct KEYBDINPUT
52          {
53              internal short wVk;
54              internal short wScan;
55              internal uint dwFlags;
56              internal int time;
57              internal UIntPtr dwExtraInfo;
58          }
59  
60          [StructLayout(LayoutKind.Sequential)]
61          [System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.NamingRules", "SA1307:Accessible fields should begin with upper-case letter", Justification = "Matching Native Structure")]
62          internal struct HARDWAREINPUT
63          {
64              internal int uMsg;
65              internal short wParamL;
66              internal short wParamH;
67          }
68  
69          internal enum INPUTTYPE : uint
70          {
71              INPUT_MOUSE = 0,
72              INPUT_KEYBOARD = 1,
73              INPUT_HARDWARE = 2,
74          }
75  
76          [Flags]
77          internal enum KeyEventF
78          {
79              KeyDown = 0x0000,
80              ExtendedKey = 0x0001,
81              KeyUp = 0x0002,
82              Unicode = 0x0004,
83              Scancode = 0x0008,
84          }
85      }
86  }