Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Mar 30, 2019. It is now read-only.
/SharpDXPublic archive

Commit7a1149c

Browse files
committed
RawInputEventArgs (and thus also HidInputEventArgs, KeyboardInputEventArgs, and MouseInputEventArgs) now has a WindowHandle property that can be used to retrieve the handle of the window that received the raw input event.
1 parentc5a6efa commit7a1149c

File tree

5 files changed

+29
-11
lines changed

5 files changed

+29
-11
lines changed

‎Source/SharpDX.RawInput/Device.cs‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -141,10 +141,11 @@ public static void RegisterDevice(UsagePage usagePage, UsageId usageId, DeviceFl
141141
/// Handles a RawInput message manually.
142142
/// </summary>
143143
/// <param name="rawInputMessagePointer">A pointer to a RawInput message.</param>
144+
/// <param name="hwnd">The handle of the window that received the RawInput message.</param>
144145
/// <remarks>
145146
/// This method can be used directly when handling RawInput messages from non-WinForms application.
146147
/// </remarks>
147-
publicstaticvoidHandleMessage(IntPtrrawInputMessagePointer)
148+
publicstaticvoidHandleMessage(IntPtrrawInputMessagePointer,IntPtrhwnd)
148149
{
149150
unsafe
150151
{
@@ -165,15 +166,15 @@ public static void HandleMessage(IntPtr rawInputMessagePointer)
165166
{
166167
caseDeviceType.HumanInputDevice:
167168
if(RawInput!=null)
168-
RawInput(null,newHidInputEventArgs(ref*rawInput));
169+
RawInput(null,newHidInputEventArgs(ref*rawInput,hwnd));
169170
break;
170171
caseDeviceType.Keyboard:
171172
if(KeyboardInput!=null)
172-
KeyboardInput(null,newKeyboardInputEventArgs(ref*rawInput));
173+
KeyboardInput(null,newKeyboardInputEventArgs(ref*rawInput,hwnd));
173174
break;
174175
caseDeviceType.Mouse:
175176
if(MouseInput!=null)
176-
MouseInput(null,newMouseInputEventArgs(ref*rawInput));
177+
MouseInput(null,newMouseInputEventArgs(ref*rawInput,hwnd));
177178
break;
178179
}
179180
}
@@ -193,7 +194,7 @@ public virtual bool PreFilterMessage(ref Message m)
193194
{
194195
// Handle only WM_INPUT messages
195196
if(m.Msg==WmInput)
196-
HandleMessage(m.LParam);
197+
HandleMessage(m.LParam,m.HWnd);
197198
returnfalse;
198199
}
199200
}

‎Source/SharpDX.RawInput/HidInputEventArgs.cs‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ public HidInputEventArgs()
3838
/// Initializes a new instance of the <see cref="HidInputEventArgs"/> class.
3939
/// </summary>
4040
/// <param name="rawInput">The raw input.</param>
41-
internalHidInputEventArgs(refRawInputrawInput):base(refrawInput)
41+
/// <param name="hwnd">The handle of the window that received the RawInput mesage.</param>
42+
internalHidInputEventArgs(refRawInputrawInput,IntPtrhwnd):base(refrawInput,hwnd)
4243
{
4344
Count=rawInput.Data.Hid.Count;
4445
DataSize=rawInput.Data.Hid.SizeHid;

‎Source/SharpDX.RawInput/KeyboardInputEventArgs.cs‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
1818
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
1919
// THE SOFTWARE.
20+
21+
usingSystem;
2022
usingSystem.Windows.Forms;
2123

2224
namespaceSharpDX.RawInput
@@ -37,8 +39,9 @@ public KeyboardInputEventArgs()
3739
/// Initializes a new instance of the <see cref="KeyboardInputEventArgs"/> class.
3840
/// </summary>
3941
/// <param name="rawInput">The raw input.</param>
40-
internalKeyboardInputEventArgs(refRawInputrawInput)
41-
:base(refrawInput)
42+
/// <param name="hwnd">The handle of the window that received the RawInput mesage.</param>
43+
internalKeyboardInputEventArgs(refRawInputrawInput,IntPtrhwnd)
44+
:base(refrawInput,hwnd)
4245
{
4346
Key=(Keys)rawInput.Data.Keyboard.VKey;
4447
MakeCode=rawInput.Data.Keyboard.MakeCode;

‎Source/SharpDX.RawInput/MouseInputEventArgs.cs‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
1818
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
1919
// THE SOFTWARE.
20+
21+
usingSystem;
22+
2023
namespaceSharpDX.RawInput
2124
{
2225
/// <summary>
@@ -35,8 +38,9 @@ public MouseInputEventArgs()
3538
/// Initializes a new instance of the <see cref="MouseInputEventArgs"/> class.
3639
/// </summary>
3740
/// <param name="rawInput">The raw input.</param>
38-
internalMouseInputEventArgs(refRawInputrawInput)
39-
:base(refrawInput)
41+
/// <param name="hwnd">The handle of the window that received the RawInput mesage.</param>
42+
internalMouseInputEventArgs(refRawInputrawInput,IntPtrhwnd)
43+
:base(refrawInput,hwnd)
4044
{
4145
Mode=(MouseMode)rawInput.Data.Mouse.Flags;
4246
ButtonFlags=(MouseButtonFlags)rawInput.Data.Mouse.ButtonsData.ButtonFlags;

‎Source/SharpDX.RawInput/RawInputEventArgs.cs‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,10 @@ protected RawInputEventArgs()
3030
{
3131
}
3232

33-
internalRawInputEventArgs(refRawInputrawInput)
33+
internalRawInputEventArgs(refRawInputrawInput,IntPtrhwnd)
3434
{
3535
Device=rawInput.Header.Device;
36+
WindowHandle=hwnd;
3637
}
3738

3839
/// <summary>
@@ -42,5 +43,13 @@ internal RawInputEventArgs(ref RawInput rawInput)
4243
/// The device.
4344
/// </value>
4445
publicIntPtrDevice{get;set;}
46+
47+
/// <summary>
48+
/// Gets or sets the handle of the window that received the RawInput mesage.
49+
/// </summary>
50+
/// <value>
51+
/// The window handle.
52+
/// </value>
53+
publicIntPtrWindowHandle{get;set;}
4554
}
4655
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp