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
ad8e3727
Commit
ad8e3727
authored
May 28, 2021
by
Rémi Bernon
Committed by
Alexandre Julliard
May 28, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dinput: Make device creation error handling consistent.
Signed-off-by:
Rémi Bernon
<
rbernon@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
e79fa186
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
40 additions
and
48 deletions
+40
-48
joystick_linux.c
dlls/dinput/joystick_linux.c
+7
-14
joystick_linuxinput.c
dlls/dinput/joystick_linuxinput.c
+8
-7
joystick_osx.c
dlls/dinput/joystick_osx.c
+7
-14
keyboard.c
dlls/dinput/keyboard.c
+9
-6
mouse.c
dlls/dinput/mouse.c
+9
-7
No files found.
dlls/dinput/joystick_linux.c
View file @
ad8e3727
...
...
@@ -451,8 +451,7 @@ static HRESULT joydev_enum_deviceW(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINS
return
S_FALSE
;
}
static
HRESULT
alloc_device
(
REFGUID
rguid
,
IDirectInputImpl
*
dinput
,
JoystickImpl
**
pdev
,
unsigned
short
index
)
static
HRESULT
alloc_device
(
REFGUID
rguid
,
IDirectInputImpl
*
dinput
,
JoystickImpl
**
out
,
unsigned
short
index
)
{
DWORD
i
;
JoystickImpl
*
newDevice
;
...
...
@@ -461,14 +460,10 @@ static HRESULT alloc_device(REFGUID rguid, IDirectInputImpl *dinput,
int
idx
=
0
;
DIDEVICEINSTANCEW
ddi
;
TRACE
(
"%s %p %p %hu
\n
"
,
debugstr_guid
(
rguid
),
dinput
,
pdev
,
index
);
TRACE
(
"%s %p %p %hu
\n
"
,
debugstr_guid
(
rguid
),
dinput
,
out
,
index
);
newDevice
=
HeapAlloc
(
GetProcessHeap
(),
HEAP_ZERO_MEMORY
,
sizeof
(
JoystickImpl
));
if
(
newDevice
==
0
)
{
WARN
(
"out of memory
\n
"
);
*
pdev
=
0
;
return
DIERR_OUTOFMEMORY
;
}
if
(
!
newDevice
)
return
DIERR_OUTOFMEMORY
;
newDevice
->
joydev
=
&
joystick_devices
[
index
];
newDevice
->
joyfd
=
-
1
;
...
...
@@ -564,8 +559,7 @@ static HRESULT alloc_device(REFGUID rguid, IDirectInputImpl *dinput,
_dump_DIDEVCAPS
(
&
newDevice
->
generic
.
devcaps
);
}
*
pdev
=
newDevice
;
*
out
=
newDevice
;
return
DI_OK
;
FAILED:
...
...
@@ -576,8 +570,6 @@ FAILED1:
release_DataFormat
(
&
newDevice
->
generic
.
base
.
data_format
);
HeapFree
(
GetProcessHeap
(),
0
,
newDevice
->
generic
.
axis_map
);
HeapFree
(
GetProcessHeap
(),
0
,
newDevice
);
*
pdev
=
0
;
return
hr
;
}
...
...
@@ -641,8 +633,9 @@ static HRESULT joydev_create_device(IDirectInputImpl *dinput, REFGUID rguid, REF
return
DIERR_NOINTERFACE
;
}
hr
=
alloc_device
(
rguid
,
dinput
,
&
This
,
index
);
if
(
!
This
)
return
hr
;
if
(
FAILED
(
hr
=
alloc_device
(
rguid
,
dinput
,
&
This
,
index
)))
return
hr
;
TRACE
(
"Created a Joystick device (%p)
\n
"
,
This
);
if
(
unicode
)
*
pdev
=
&
This
->
generic
.
base
.
IDirectInputDevice8W_iface
;
...
...
dlls/dinput/joystick_linuxinput.c
View file @
ad8e3727
...
...
@@ -444,7 +444,7 @@ static HRESULT joydev_enum_deviceW(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINS
return
S_FALSE
;
}
static
JoystickImpl
*
alloc_device
(
REFGUID
rguid
,
IDirectInputImpl
*
dinput
,
unsigned
short
index
)
static
HRESULT
alloc_device
(
REFGUID
rguid
,
IDirectInputImpl
*
dinput
,
JoystickImpl
**
out
,
unsigned
short
index
)
{
JoystickImpl
*
newDevice
;
LPDIDATAFORMAT
df
=
NULL
;
...
...
@@ -453,7 +453,7 @@ static JoystickImpl *alloc_device(REFGUID rguid, IDirectInputImpl *dinput, unsig
DIDEVICEINSTANCEW
ddi
;
newDevice
=
HeapAlloc
(
GetProcessHeap
(),
HEAP_ZERO_MEMORY
,
sizeof
(
JoystickImpl
));
if
(
!
newDevice
)
return
NULL
;
if
(
!
newDevice
)
return
DIERR_OUTOFMEMORY
;
newDevice
->
generic
.
base
.
IDirectInputDevice8A_iface
.
lpVtbl
=
&
JoystickAvt
;
newDevice
->
generic
.
base
.
IDirectInputDevice8W_iface
.
lpVtbl
=
&
JoystickWvt
;
...
...
@@ -584,14 +584,15 @@ static JoystickImpl *alloc_device(REFGUID rguid, IDirectInputImpl *dinput, unsig
IDirectInput_AddRef
(
&
newDevice
->
generic
.
base
.
dinput
->
IDirectInput7A_iface
);
return
newDevice
;
*
out
=
newDevice
;
return
DI_OK
;
failed:
if
(
df
)
HeapFree
(
GetProcessHeap
(),
0
,
df
->
rgodf
);
HeapFree
(
GetProcessHeap
(),
0
,
df
);
HeapFree
(
GetProcessHeap
(),
0
,
newDevice
->
generic
.
axis_map
);
HeapFree
(
GetProcessHeap
(),
0
,
newDevice
);
return
NULL
;
return
DIERR_OUTOFMEMORY
;
}
/******************************************************************************
...
...
@@ -630,6 +631,7 @@ static HRESULT joydev_create_device(IDirectInputImpl *dinput, REFGUID rguid, REF
have_joydevs
&&
index
<
have_joydevs
)
{
JoystickImpl
*
This
;
HRESULT
hr
;
if
(
riid
==
NULL
)
;
/* nothing */
...
...
@@ -653,10 +655,9 @@ static HRESULT joydev_create_device(IDirectInputImpl *dinput, REFGUID rguid, REF
return
DIERR_NOINTERFACE
;
}
This
=
alloc_device
(
rguid
,
dinput
,
index
);
TRACE
(
"Created a Joystick device (%p)
\n
"
,
This
);
if
(
FAILED
(
hr
=
alloc_device
(
rguid
,
dinput
,
&
This
,
index
)))
return
hr
;
if
(
!
This
)
return
DIERR_OUTOFMEMORY
;
TRACE
(
"Created a Joystick device (%p)
\n
"
,
This
)
;
if
(
unicode
)
*
pdev
=
&
This
->
generic
.
base
.
IDirectInputDevice8W_iface
;
...
...
dlls/dinput/joystick_osx.c
View file @
ad8e3727
...
...
@@ -1105,8 +1105,7 @@ static BOOL osx_axis_has_ff(FFCAPABILITIES *ffcaps, UInt8 axis)
return
FALSE
;
}
static
HRESULT
alloc_device
(
REFGUID
rguid
,
IDirectInputImpl
*
dinput
,
JoystickImpl
**
pdev
,
unsigned
short
index
)
static
HRESULT
alloc_device
(
REFGUID
rguid
,
IDirectInputImpl
*
dinput
,
JoystickImpl
**
out
,
unsigned
short
index
)
{
DWORD
i
;
IOHIDDeviceRef
device
;
...
...
@@ -1119,14 +1118,10 @@ static HRESULT alloc_device(REFGUID rguid, IDirectInputImpl *dinput,
int
slider_count
=
0
;
FFCAPABILITIES
ffcaps
;
TRACE
(
"%s %p %p %hu
\n
"
,
debugstr_guid
(
rguid
),
dinput
,
pdev
,
index
);
TRACE
(
"%s %p %p %hu
\n
"
,
debugstr_guid
(
rguid
),
dinput
,
out
,
index
);
newDevice
=
HeapAlloc
(
GetProcessHeap
(),
HEAP_ZERO_MEMORY
,
sizeof
(
JoystickImpl
));
if
(
newDevice
==
0
)
{
WARN
(
"out of memory
\n
"
);
*
pdev
=
0
;
return
DIERR_OUTOFMEMORY
;
}
if
(
!
newDevice
)
return
DIERR_OUTOFMEMORY
;
newDevice
->
id
=
index
;
...
...
@@ -1287,8 +1282,7 @@ static HRESULT alloc_device(REFGUID rguid, IDirectInputImpl *dinput,
_dump_DIDEVCAPS
(
&
newDevice
->
generic
.
devcaps
);
}
*
pdev
=
newDevice
;
*
out
=
newDevice
;
return
DI_OK
;
FAILED:
...
...
@@ -1300,8 +1294,6 @@ FAILED:
release_DataFormat
(
&
newDevice
->
generic
.
base
.
data_format
);
HeapFree
(
GetProcessHeap
(),
0
,
newDevice
->
generic
.
name
);
HeapFree
(
GetProcessHeap
(),
0
,
newDevice
);
*
pdev
=
0
;
return
hr
;
}
...
...
@@ -1380,8 +1372,9 @@ static HRESULT joydev_create_device(IDirectInputImpl *dinput, REFGUID rguid, REF
return
DIERR_NOINTERFACE
;
}
hr
=
alloc_device
(
rguid
,
dinput
,
&
This
,
index
);
if
(
!
This
)
return
hr
;
if
(
FAILED
(
hr
=
alloc_device
(
rguid
,
dinput
,
&
This
,
index
)))
return
hr
;
TRACE
(
"Created a Joystick device (%p)
\n
"
,
This
);
if
(
unicode
)
*
pdev
=
&
This
->
generic
.
base
.
IDirectInputDevice8W_iface
;
...
...
dlls/dinput/keyboard.c
View file @
ad8e3727
...
...
@@ -240,13 +240,15 @@ static HRESULT keyboarddev_enum_deviceW(DWORD dwDevType, DWORD dwFlags, LPDIDEVI
return
S_FALSE
;
}
static
SysKeyboardImpl
*
alloc_device
(
REFGUID
rguid
,
IDirectInputImpl
*
dinput
)
static
HRESULT
alloc_device
(
REFGUID
rguid
,
IDirectInputImpl
*
dinput
,
SysKeyboardImpl
**
out
)
{
SysKeyboardImpl
*
newDevice
;
LPDIDATAFORMAT
df
=
NULL
;
int
i
,
idx
=
0
;
newDevice
=
HeapAlloc
(
GetProcessHeap
(),
HEAP_ZERO_MEMORY
,
sizeof
(
SysKeyboardImpl
));
if
(
!
newDevice
)
return
DIERR_OUTOFMEMORY
;
newDevice
->
base
.
IDirectInputDevice8A_iface
.
lpVtbl
=
&
SysKeyboardAvt
;
newDevice
->
base
.
IDirectInputDevice8W_iface
.
lpVtbl
=
&
SysKeyboardWvt
;
newDevice
->
base
.
ref
=
1
;
...
...
@@ -278,13 +280,14 @@ static SysKeyboardImpl *alloc_device(REFGUID rguid, IDirectInputImpl *dinput)
newDevice
->
base
.
data_format
.
wine_df
=
df
;
IDirectInput_AddRef
(
&
newDevice
->
base
.
dinput
->
IDirectInput7A_iface
);
return
newDevice
;
*
out
=
newDevice
;
return
DI_OK
;
failed:
if
(
df
)
HeapFree
(
GetProcessHeap
(),
0
,
df
->
rgodf
);
HeapFree
(
GetProcessHeap
(),
0
,
df
);
HeapFree
(
GetProcessHeap
(),
0
,
newDevice
);
return
NULL
;
return
DIERR_OUTOFMEMORY
;
}
...
...
@@ -296,6 +299,7 @@ static HRESULT keyboarddev_create_device(IDirectInputImpl *dinput, REFGUID rguid
if
(
IsEqualGUID
(
&
GUID_SysKeyboard
,
rguid
))
/* Wine Keyboard */
{
SysKeyboardImpl
*
This
;
HRESULT
hr
;
if
(
riid
==
NULL
)
;
/* nothing */
...
...
@@ -319,10 +323,9 @@ static HRESULT keyboarddev_create_device(IDirectInputImpl *dinput, REFGUID rguid
return
DIERR_NOINTERFACE
;
}
This
=
alloc_device
(
rguid
,
dinput
);
TRACE
(
"Created a Keyboard device (%p)
\n
"
,
This
);
if
(
FAILED
(
hr
=
alloc_device
(
rguid
,
dinput
,
&
This
)))
return
hr
;
if
(
!
This
)
return
DIERR_OUTOFMEMORY
;
TRACE
(
"Created a Keyboard device (%p)
\n
"
,
This
)
;
if
(
unicode
)
*
pdev
=
&
This
->
base
.
IDirectInputDevice8W_iface
;
...
...
dlls/dinput/mouse.c
View file @
ad8e3727
...
...
@@ -184,7 +184,7 @@ static HRESULT mousedev_enum_deviceW(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEI
return
S_FALSE
;
}
static
SysMouseImpl
*
alloc_device
(
REFGUID
rguid
,
IDirectInputImpl
*
dinput
)
static
HRESULT
alloc_device
(
REFGUID
rguid
,
IDirectInputImpl
*
dinput
,
SysMouseImpl
**
out
)
{
SysMouseImpl
*
newDevice
;
LPDIDATAFORMAT
df
=
NULL
;
...
...
@@ -193,7 +193,8 @@ static SysMouseImpl *alloc_device(REFGUID rguid, IDirectInputImpl *dinput)
HKEY
hkey
,
appkey
;
newDevice
=
HeapAlloc
(
GetProcessHeap
(),
HEAP_ZERO_MEMORY
,
sizeof
(
SysMouseImpl
));
if
(
!
newDevice
)
return
NULL
;
if
(
!
newDevice
)
return
DIERR_OUTOFMEMORY
;
newDevice
->
base
.
IDirectInputDevice8A_iface
.
lpVtbl
=
&
SysMouseAvt
;
newDevice
->
base
.
IDirectInputDevice8W_iface
.
lpVtbl
=
&
SysMouseWvt
;
newDevice
->
base
.
ref
=
1
;
...
...
@@ -237,13 +238,14 @@ static SysMouseImpl *alloc_device(REFGUID rguid, IDirectInputImpl *dinput)
newDevice
->
base
.
raw_device
.
usUsage
=
2
;
/* HID generic mouse */
}
return
newDevice
;
*
out
=
newDevice
;
return
DI_OK
;
failed:
if
(
df
)
HeapFree
(
GetProcessHeap
(),
0
,
df
->
rgodf
);
HeapFree
(
GetProcessHeap
(),
0
,
df
);
HeapFree
(
GetProcessHeap
(),
0
,
newDevice
);
return
NULL
;
return
DIERR_OUTOFMEMORY
;
}
static
HRESULT
mousedev_create_device
(
IDirectInputImpl
*
dinput
,
REFGUID
rguid
,
REFIID
riid
,
LPVOID
*
pdev
,
int
unicode
)
...
...
@@ -254,6 +256,7 @@ static HRESULT mousedev_create_device(IDirectInputImpl *dinput, REFGUID rguid, R
if
(
IsEqualGUID
(
&
GUID_SysMouse
,
rguid
))
/* Wine Mouse */
{
SysMouseImpl
*
This
;
HRESULT
hr
;
if
(
riid
==
NULL
)
;
/* nothing */
...
...
@@ -277,10 +280,9 @@ static HRESULT mousedev_create_device(IDirectInputImpl *dinput, REFGUID rguid, R
return
DIERR_NOINTERFACE
;
}
This
=
alloc_device
(
rguid
,
dinput
);
TRACE
(
"Created a Mouse device (%p)
\n
"
,
This
);
if
(
FAILED
(
hr
=
alloc_device
(
rguid
,
dinput
,
&
This
)))
return
hr
;
if
(
!
This
)
return
DIERR_OUTOFMEMORY
;
TRACE
(
"Created a Mouse device (%p)
\n
"
,
This
)
;
if
(
unicode
)
*
pdev
=
&
This
->
base
.
IDirectInputDevice8W_iface
;
...
...
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