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
a2a80136
Commit
a2a80136
authored
Nov 26, 2022
by
Rémi Bernon
Committed by
Alexandre Julliard
Nov 29, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
joy.cpl: Use a notification event rather than polling state.
parent
eb00dd0d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
29 deletions
+26
-29
main.c
dlls/joy.cpl/main.c
+26
-29
No files found.
dlls/joy.cpl/main.c
View file @
a2a80136
...
...
@@ -113,6 +113,8 @@ static IDirectInputEffect *effect_selected;
static
struct
list
devices
=
LIST_INIT
(
devices
);
static
IDirectInputDevice8W
*
device_selected
;
static
HANDLE
device_state_event
;
/*********************************************************************
* DllMain
*/
...
...
@@ -292,10 +294,17 @@ static void set_selected_device( IDirectInputDevice8W *device )
set_selected_effect
(
NULL
);
if
(
device
)
IDirectInputDevice8_AddRef
(
device
);
previous
=
device_selected
;
device_selected
=
device
;
if
(
previous
)
IDirectInputEffect_Release
(
previous
);
if
((
previous
=
device_selected
))
{
IDirectInputDevice8_SetEventNotification
(
previous
,
NULL
);
IDirectInputDevice8_Release
(
previous
);
}
if
((
device_selected
=
device
))
{
IDirectInputDevice8_AddRef
(
device
);
IDirectInputDevice8_SetEventNotification
(
device
,
device_state_event
);
IDirectInputDevice8_Acquire
(
device
);
}
LeaveCriticalSection
(
&
joy_cs
);
}
...
...
@@ -601,24 +610,6 @@ static void dump_joy_state(DIJOYSTATE* st)
TRACE
(
"
\n
"
);
}
static
void
poll_input
(
IDirectInputDevice8W
*
device
,
DIJOYSTATE
*
state
)
{
HRESULT
hr
;
hr
=
IDirectInputDevice8_Poll
(
device
);
/* If it failed, try to acquire the joystick */
if
(
FAILED
(
hr
))
{
hr
=
IDirectInputDevice8_Acquire
(
device
);
while
(
hr
==
DIERR_INPUTLOST
)
hr
=
IDirectInputDevice8_Acquire
(
device
);
}
if
(
hr
==
DIERR_OTHERAPPHASPRIO
)
return
;
IDirectInputDevice8_GetDeviceState
(
device
,
sizeof
(
DIJOYSTATE
),
state
);
}
static
DWORD
WINAPI
input_thread
(
void
*
param
)
{
int
axes_pos
[
TEST_MAX_AXES
][
2
];
...
...
@@ -647,9 +638,11 @@ static DWORD WINAPI input_thread(void *param)
memset
(
&
state
,
0
,
sizeof
(
state
)
);
if
(
WaitForSingleObject
(
device_state_event
,
TEST_POLL_TIME
)
==
WAIT_TIMEOUT
)
continue
;
if
((
device
=
get_selected_device
()))
{
poll_input
(
device
,
&
state
);
IDirectInputDevice8_GetDeviceState
(
device
,
sizeof
(
state
)
,
&
state
);
IDirectInputDevice8_Release
(
device
);
}
...
...
@@ -688,8 +681,6 @@ static DWORD WINAPI input_thread(void *param)
SetWindowPos
(
data
->
graphics
.
axes
[
i
],
0
,
r
.
left
,
r
.
top
,
0
,
0
,
SWP_NOZORDER
|
SWP_NOSIZE
);
}
Sleep
(
TEST_POLL_TIME
);
}
return
0
;
...
...
@@ -981,11 +972,13 @@ static DWORD WINAPI ff_input_thread(void *param)
};
RECT
r
;
Sleep
(
TEST_POLL_TIME
)
;
if
(
WaitForSingleObject
(
device_state_event
,
TEST_POLL_TIME
)
==
WAIT_TIMEOUT
)
continue
;
if
(
!
(
device
=
get_selected_device
()))
continue
;
poll_input
(
device
,
&
state
);
IDirectInputDevice8_Release
(
device
);
if
((
device
=
get_selected_device
()))
{
IDirectInputDevice8_GetDeviceState
(
device
,
sizeof
(
state
),
&
state
);
IDirectInputDevice8_Release
(
device
);
}
if
(
!
(
effect
=
get_selected_effect
()))
continue
;
...
...
@@ -1214,6 +1207,8 @@ LONG CALLBACK CPlApplet(HWND hwnd, UINT command, LPARAM lParam1, LPARAM lParam2)
{
HRESULT
hr
;
device_state_event
=
CreateEventW
(
NULL
,
FALSE
,
FALSE
,
NULL
);
/* Initialize dinput */
hr
=
DirectInput8Create
(
GetModuleHandleW
(
NULL
),
DIRECTINPUT_VERSION
,
&
IID_IDirectInput8W
,
(
void
**
)
&
data
.
di
,
NULL
);
...
...
@@ -1251,6 +1246,8 @@ LONG CALLBACK CPlApplet(HWND hwnd, UINT command, LPARAM lParam1, LPARAM lParam2)
/* And destroy dinput too */
IDirectInput8_Release
(
data
.
di
);
CloseHandle
(
device_state_event
);
break
;
}
...
...
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