Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
2d6776e8
Commit
2d6776e8
authored
Feb 05, 2022
by
Rémi Bernon
Committed by
Alexandre Julliard
Feb 15, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dinput: Introduce keyboard_handle_key_event helper.
parent
d384e858
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
20 deletions
+27
-20
keyboard.c
dlls/dinput/keyboard.c
+27
-20
No files found.
dlls/dinput/keyboard.c
View file @
2d6776e8
...
...
@@ -83,22 +83,13 @@ static BYTE map_dik_code(DWORD scanCode, DWORD vkCode, DWORD subType, DWORD vers
return
(
BYTE
)
scanCode
;
}
int
dinput_keyboard_hook
(
IDirectInputDevice8W
*
iface
,
WPARAM
wparam
,
LPARAM
lparam
)
static
void
keyboard_handle_event
(
struct
keyboard
*
impl
,
DWORD
vkey
,
DWORD
scan_code
,
BOOL
up
)
{
struct
keyboard
*
impl
=
impl_from_IDirectInputDevice8W
(
iface
);
BYTE
new_diks
,
subtype
=
GET_DIDEVICE_SUBTYPE
(
impl
->
base
.
instance
.
dwDevType
);
int
dik_code
,
ret
=
impl
->
base
.
dwCoopLevel
&
DISCL_EXCLUSIVE
;
KBDLLHOOKSTRUCT
*
hook
=
(
KBDLLHOOKSTRUCT
*
)
lparam
;
DWORD
scan_code
;
if
(
wparam
!=
WM_KEYDOWN
&&
wparam
!=
WM_KEYUP
&&
wparam
!=
WM_SYSKEYDOWN
&&
wparam
!=
WM_SYSKEYUP
)
return
0
;
IDirectInputDevice8W
*
iface
=
&
impl
->
base
.
IDirectInputDevice8W_iface
;
int
dik_code
;
TRACE
(
"iface %p, wparam %#Ix, lparam %#Ix, vkCode %#lx, scanCode %#lx.
\n
"
,
iface
,
wparam
,
lparam
,
hook
->
vkCode
,
hook
->
scanCode
);
switch
(
hook
->
vkCode
)
switch
(
vkey
)
{
/* R-Shift is special - it is an extended key with separate scan code */
case
VK_RSHIFT
:
dik_code
=
DIK_RSHIFT
;
break
;
...
...
@@ -106,25 +97,41 @@ int dinput_keyboard_hook( IDirectInputDevice8W *iface, WPARAM wparam, LPARAM lpa
case
VK_NUMLOCK
:
dik_code
=
DIK_NUMLOCK
;
break
;
case
VK_SUBTRACT
:
dik_code
=
DIK_SUBTRACT
;
break
;
default:
scan_code
=
hook
->
scanCode
&
0xff
;
if
(
hook
->
flags
&
LLKHF_EXTENDED
)
scan_code
|=
0x100
;
dik_code
=
map_dik_code
(
scan_code
,
hook
->
vkCode
,
subtype
,
impl
->
base
.
dinput
->
dwVersion
);
dik_code
=
map_dik_code
(
scan_code
,
vkey
,
subtype
,
impl
->
base
.
dinput
->
dwVersion
);
break
;
}
new_diks
=
hook
->
flags
&
LLKHF_UP
?
0
:
0x80
;
new_diks
=
(
up
?
0
:
0x80
)
;
/* returns now if key event already known */
if
(
new_diks
==
impl
->
base
.
device_state
[
dik_code
])
return
ret
;
if
(
new_diks
==
impl
->
base
.
device_state
[
dik_code
])
return
;
impl
->
base
.
device_state
[
dik_code
]
=
new_diks
;
TRACE
(
"
setting key %02x to %02x
\n
"
,
dik_code
,
impl
->
base
.
device_state
[
dik_code
]
);
TRACE
(
"setting key %02x to %02x
\n
"
,
dik_code
,
impl
->
base
.
device_state
[
dik_code
]
);
EnterCriticalSection
(
&
impl
->
base
.
crit
);
queue_event
(
iface
,
DIDFT_MAKEINSTANCE
(
dik_code
)
|
DIDFT_PSHBUTTON
,
new_diks
,
GetCurrentTime
(),
impl
->
base
.
dinput
->
evsequence
++
);
if
(
impl
->
base
.
hEvent
)
SetEvent
(
impl
->
base
.
hEvent
);
LeaveCriticalSection
(
&
impl
->
base
.
crit
);
}
int
dinput_keyboard_hook
(
IDirectInputDevice8W
*
iface
,
WPARAM
wparam
,
LPARAM
lparam
)
{
struct
keyboard
*
impl
=
impl_from_IDirectInputDevice8W
(
iface
);
KBDLLHOOKSTRUCT
*
hook
=
(
KBDLLHOOKSTRUCT
*
)
lparam
;
DWORD
scan_code
;
TRACE
(
"iface %p, wparam %#Ix, lparam %#Ix, vkCode %#lx, scanCode %#lx.
\n
"
,
iface
,
wparam
,
lparam
,
hook
->
vkCode
,
hook
->
scanCode
);
if
(
wparam
!=
WM_KEYDOWN
&&
wparam
!=
WM_KEYUP
&&
wparam
!=
WM_SYSKEYDOWN
&&
wparam
!=
WM_SYSKEYUP
)
return
0
;
scan_code
=
hook
->
scanCode
&
0xff
;
if
(
hook
->
flags
&
LLKHF_EXTENDED
)
scan_code
|=
0x100
;
keyboard_handle_event
(
impl
,
hook
->
vkCode
,
scan_code
,
hook
->
flags
&
LLKHF_UP
);
return
ret
;
return
impl
->
base
.
dwCoopLevel
&
DISCL_EXCLUSIVE
;
}
static
DWORD
get_keyboard_subtype
(
void
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment