Wine-Devel
By thread
wine-devel@list.winehq.org
By month
Messages by month
- ----- 2026 -----
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2003 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2002 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2001 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
October 2021
- 81 participants
- 2597 messages
[PATCH] dxva2: Remove AYUV from accepted input formats.
by Nikolay Sivov
It was added for completeness only, and it appears to be not universally
support on Windows via regular d3d9 API. DXVA might be using different path
to present video frames, but we don't make such distinction at the moment.
Signed-off-by: Nikolay Sivov <nsivov(a)codeweavers.com>
---
dlls/dxva2/main.c | 3 +--
dlls/dxva2/tests/dxva2.c | 2 ++
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/dlls/dxva2/main.c b/dlls/dxva2/main.c
index f91b033055c..2fab82ff476 100644
--- a/dlls/dxva2/main.c
+++ b/dlls/dxva2/main.c
@@ -381,8 +381,7 @@ static BOOL dxva_is_supported_stream_format(const DXVA2_VideoDesc *video_desc)
{
return video_desc->Format == D3DFMT_A8R8G8B8 ||
video_desc->Format == D3DFMT_X8R8G8B8 ||
- video_desc->Format == D3DFMT_YUY2 ||
- video_desc->Format == MAKEFOURCC('A','Y','U','V');
+ video_desc->Format == D3DFMT_YUY2;
}
static HRESULT WINAPI device_manager_processor_service_GetVideoProcessorDeviceGuids(
diff --git a/dlls/dxva2/tests/dxva2.c b/dlls/dxva2/tests/dxva2.c
index 4b09e93e87a..ab0a2769bd2 100644
--- a/dlls/dxva2/tests/dxva2.c
+++ b/dlls/dxva2/tests/dxva2.c
@@ -356,7 +356,9 @@ static void test_device_manager(void)
count = 0;
hr = IDirectXVideoProcessorService_GetVideoProcessorDeviceGuids(proc_service, &video_desc, &count, &guids);
+ todo_wine_if(rt_formats[i] == MAKEFOURCC('A','Y','U','V'))
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
+ if (FAILED(hr)) continue;
ok(count > 0, "Unexpected device count.\n");
CoTaskMemFree(guids);
--
2.33.0
Oct. 29, 2021
[PATCH 4/4] include: Add IDeviceWatcher interface.
by Jactry Zeng
Signed-off-by: Jactry Zeng <jzeng(a)codeweavers.com>
---
include/windows.devices.enumeration.idl | 50 +++++++++++++++++++++++++
1 file changed, 50 insertions(+)
diff --git a/include/windows.devices.enumeration.idl b/include/windows.devices.enumeration.idl
index 20e4df9d33d..7cde49224a1 100644
--- a/include/windows.devices.enumeration.idl
+++ b/include/windows.devices.enumeration.idl
@@ -30,6 +30,7 @@ import "windows.foundation.idl";
namespace Windows {
namespace Devices {
namespace Enumeration {
+ typedef enum DeviceWatcherStatus DeviceWatcherStatus;
typedef enum Panel Panel;
interface IDeviceInformation;
@@ -41,6 +42,7 @@ namespace Windows {
runtimeclass DeviceInformation;
runtimeclass DeviceInformationUpdate;
runtimeclass DeviceThumbnail;
+ runtimeclass DeviceWatcher;
runtimeclass EnclosureLocation;
}
}
@@ -59,6 +61,9 @@ namespace Windows
interface Windows.Foundation.Collections.IMapView<HSTRING, IInspectable *>;
interface Windows.Foundation.IAsyncOperation<Windows.Devices.Enumeration.DeviceInformation *>;
interface Windows.Foundation.IAsyncOperation<Windows.Devices.Enumeration.DeviceThumbnail *>;
+ interface Windows.Foundation.TypedEventHandler<Windows.Devices.Enumeration.DeviceWatcher *, IInspectable *>;
+ interface Windows.Foundation.TypedEventHandler<Windows.Devices.Enumeration.DeviceWatcher *, Windows.Devices.Enumeration.DeviceInformation *>;
+ interface Windows.Foundation.TypedEventHandler<Windows.Devices.Enumeration.DeviceWatcher *, Windows.Devices.Enumeration.DeviceInformationUpdate *>;
}
}
}
@@ -82,6 +87,16 @@ namespace Windows
namespace Windows {
namespace Devices {
namespace Enumeration {
+ enum DeviceWatcherStatus
+ {
+ Created = 0,
+ Started = 1,
+ EnumerationCompleted = 2,
+ Stopping = 3,
+ Stopped = 4,
+ Aborted = 5
+ };
+
enum Panel
{
Unknown = 0,
@@ -120,6 +135,32 @@ namespace Windows {
[propget] HRESULT Properties([out, retval] Windows.Foundation.Collections.IMapView<HSTRING, IInspectable *> **value);
}
+ [
+ exclusiveto(Windows.Devices.Enumeration.DeviceWatcher),
+ uuid(c9eab97d-8f6b-4f96-a9f4-abc814e22271),
+ ]
+ interface IDeviceWatcher : IInspectable
+ {
+ [eventadd] HRESULT Added([in] Windows.Foundation.TypedEventHandler<Windows.Devices.Enumeration.DeviceWatcher*,
+ Windows.Devices.Enumeration.DeviceInformation *> *handler, [out, retval] EventRegistrationToken *token);
+ [eventremove] HRESULT Added([in] EventRegistrationToken token);
+ [eventadd] HRESULT Updated([in] Windows.Foundation.TypedEventHandler<Windows.Devices.Enumeration.DeviceWatcher *,
+ Windows.Devices.Enumeration.DeviceInformationUpdate *> *handler, [out, retval] EventRegistrationToken *token);
+ [eventremove] HRESULT Updated([in] EventRegistrationToken token);
+ [eventadd] HRESULT Removed([in] Windows.Foundation.TypedEventHandler<Windows.Devices.Enumeration.DeviceWatcher *,
+ Windows.Devices.Enumeration.DeviceInformationUpdate *> *handler, [out, retval] EventRegistrationToken *token);
+ [eventremove] HRESULT Removed([in] EventRegistrationToken token);
+ [eventadd] HRESULT EnumerationCompleted([in] Windows.Foundation.TypedEventHandler<Windows.Devices.Enumeration.DeviceWatcher *,
+ IInspectable *> *handler, [out, retval] EventRegistrationToken *token);
+ [eventremove] HRESULT EnumerationCompleted([in] EventRegistrationToken token);
+ [eventadd] HRESULT Stopped([in] Windows.Foundation.TypedEventHandler<Windows.Devices.Enumeration.DeviceWatcher *,
+ IInspectable *> *handler, [out, retval] EventRegistrationToken *token);
+ [eventremove] HRESULT Stopped([in] EventRegistrationToken token);
+ [propget] HRESULT Status([out, retval] Windows.Devices.Enumeration.DeviceWatcherStatus *status);
+ HRESULT Start();
+ HRESULT Stop();
+ }
+
[
exclusiveto(Windows.Devices.Enumeration.EnclosureLocation),
uuid(42340a27-5810-459c-aabb-c65e1f813ecf)
@@ -166,6 +207,15 @@ namespace Windows {
interface Windows.Storage.Streams.IInputStream;
}
+ [
+ marshaling_behavior(agile),
+ ]
+ runtimeclass DeviceWatcher
+ {
+ [default] interface Windows.Devices.Enumeration.IDeviceWatcher;
+ interface Windows.Devices.Enumeration.IDeviceWatcher2;
+ }
+
[
marshaling_behavior(agile)
]
--
2.33.0
Oct. 29, 2021
[PATCH 3/4] include: Add IDeviceInformation interface.
by Jactry Zeng
Signed-off-by: Jactry Zeng <jzeng(a)codeweavers.com>
---
include/windows.devices.enumeration.idl | 123 ++++++++++++++++++++++++
1 file changed, 123 insertions(+)
diff --git a/include/windows.devices.enumeration.idl b/include/windows.devices.enumeration.idl
index 9aa2aaba441..20e4df9d33d 100644
--- a/include/windows.devices.enumeration.idl
+++ b/include/windows.devices.enumeration.idl
@@ -24,13 +24,57 @@ import "inspectable.idl";
import "asyncinfo.idl";
import "eventtoken.idl";
import "windowscontracts.idl";
+import "windows.storage.streams.idl";
import "windows.foundation.idl";
namespace Windows {
namespace Devices {
namespace Enumeration {
+ typedef enum Panel Panel;
+
+ interface IDeviceInformation;
interface IDeviceInformationStatics;
interface IDeviceInformationStatics2;
+ interface IDeviceInformationUpdate;
+ interface IEnclosureLocation;
+
+ runtimeclass DeviceInformation;
+ runtimeclass DeviceInformationUpdate;
+ runtimeclass DeviceThumbnail;
+ runtimeclass EnclosureLocation;
+ }
+ }
+}
+
+namespace Windows
+{
+ namespace Devices
+ {
+ namespace Enumeration
+ {
+ declare
+ {
+ interface Windows.Foundation.AsyncOperationCompletedHandler<Windows.Devices.Enumeration.DeviceInformation *>;
+ interface Windows.Foundation.AsyncOperationCompletedHandler<Windows.Devices.Enumeration.DeviceThumbnail *>;
+ interface Windows.Foundation.Collections.IMapView<HSTRING, IInspectable *>;
+ interface Windows.Foundation.IAsyncOperation<Windows.Devices.Enumeration.DeviceInformation *>;
+ interface Windows.Foundation.IAsyncOperation<Windows.Devices.Enumeration.DeviceThumbnail *>;
+ }
+ }
+ }
+}
+
+namespace Windows
+{
+ namespace Storage
+ {
+ namespace Streams
+ {
+ interface IContentTypeProvider;
+ interface IInputStream;
+ interface IOutputStream;
+ interface IRandomAccessStream;
+ interface IRandomAccessStreamWithContentType;
}
}
}
@@ -38,6 +82,55 @@ namespace Windows {
namespace Windows {
namespace Devices {
namespace Enumeration {
+ enum Panel
+ {
+ Unknown = 0,
+ Front = 1,
+ Back = 2,
+ Top = 3,
+ Bottom = 4,
+ Left = 5,
+ Right = 6
+ };
+
+ [
+ exclusiveto(Windows.Devices.Enumeration.DeviceInformation),
+ uuid(aba0fb95-4398-489d-8e44-e6130927011f)
+ ]
+ interface IDeviceInformation : IInspectable
+ {
+ [propget] HRESULT Id([out, retval] HSTRING *value);
+ [propget] HRESULT Name([out, retval] HSTRING *value);
+ [propget] HRESULT IsEnabled([out, retval] boolean *value);
+ [propget] HRESULT IsDefault([out, retval] boolean *value);
+ [propget] HRESULT EnclosureLocation([out, retval] Windows.Devices.Enumeration.EnclosureLocation **value);
+ [propget] HRESULT Properties([out, retval] Windows.Foundation.Collections.IMapView<HSTRING, IInspectable *> **value);
+ HRESULT Update([in] Windows.Devices.Enumeration.DeviceInformationUpdate *info);
+ HRESULT GetThumbnailAsync([out, retval] Windows.Foundation.IAsyncOperation<Windows.Devices.Enumeration.DeviceThumbnail *> **operation);
+ HRESULT GetGlyphThumbnailAsync([out, retval] Windows.Foundation.IAsyncOperation<Windows.Devices.Enumeration.DeviceThumbnail *> **operation);
+ }
+
+ [
+ exclusiveto(Windows.Devices.Enumeration.DeviceInformationUpdate),
+ uuid(8f315305-d972-44b7-a37e-9e822c78213b)
+ ]
+ interface IDeviceInformationUpdate : IInspectable
+ {
+ [propget] HRESULT Id([out, retval] HSTRING *value);
+ [propget] HRESULT Properties([out, retval] Windows.Foundation.Collections.IMapView<HSTRING, IInspectable *> **value);
+ }
+
+ [
+ exclusiveto(Windows.Devices.Enumeration.EnclosureLocation),
+ uuid(42340a27-5810-459c-aabb-c65e1f813ecf)
+ ]
+ interface IEnclosureLocation : IInspectable
+ {
+ [propget] HRESULT InDock([out, retval] boolean *value);
+ [propget] HRESULT InLid([out, retval] boolean *value);
+ [propget] HRESULT Panel([out, retval] Windows.Devices.Enumeration.Panel *value);
+ }
+
[
contract(Windows.Foundation.UniversalApiContract, 1.0),
marshaling_behavior(agile),
@@ -50,6 +143,36 @@ namespace Windows {
[default] interface Windows.Devices.Enumeration.IDeviceInformation;
[contract(Windows.Foundation.UniversalApiContract, 1.0)] interface Windows.Devices.Enumeration.IDeviceInformation2;
}
+
+ [
+ marshaling_behavior(agile),
+ ]
+ runtimeclass DeviceInformationUpdate
+ {
+ [default] interface Windows.Devices.Enumeration.IDeviceInformationUpdate;
+ interface Windows.Devices.Enumeration.IDeviceInformationUpdate2;
+ }
+
+ [
+ marshaling_behavior(agile),
+ ]
+ runtimeclass DeviceThumbnail
+ {
+ [default] interface Windows.Storage.Streams.IRandomAccessStreamWithContentType;
+ interface Windows.Storage.Streams.IContentTypeProvider;
+ interface Windows.Storage.Streams.IRandomAccessStream;
+ interface Windows.Storage.Streams.IOutputStream;
+ interface Windows.Foundation.IClosable;
+ interface Windows.Storage.Streams.IInputStream;
+ }
+
+ [
+ marshaling_behavior(agile)
+ ]
+ runtimeclass EnclosureLocation
+ {
+ [default] interface Windows.Devices.Enumeration.IEnclosureLocation;
+ }
}
}
}
--
2.33.0
Oct. 29, 2021
[PATCH 2/4] include: Add IRandomAccessStreamWithContentType interface.
by Jactry Zeng
Signed-off-by: Jactry Zeng <jzeng(a)codeweavers.com>
---
include/Makefile.in | 1 +
include/windows.storage.streams.idl | 70 +++++++++++++++++++++++++++++
2 files changed, 71 insertions(+)
create mode 100644 include/windows.storage.streams.idl
diff --git a/include/Makefile.in b/include/Makefile.in
index 71d1b497b6d..ff7aa1b0ff5 100644
--- a/include/Makefile.in
+++ b/include/Makefile.in
@@ -776,6 +776,7 @@ SOURCES = \
windows.h \
windows.media.devices.idl \
windows.media.speechsynthesis.idl \
+ windows.storage.streams.idl \
windows.system.idl \
windows.system.userprofile.idl \
windowscontracts.idl \
diff --git a/include/windows.storage.streams.idl b/include/windows.storage.streams.idl
new file mode 100644
index 00000000000..59b15761af0
--- /dev/null
+++ b/include/windows.storage.streams.idl
@@ -0,0 +1,70 @@
+/*
+ * Copyright 2021 Jactry Zeng for CodeWeavers
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#ifdef __WIDL__
+#pragma winrt ns_prefix
+#endif
+
+import "inspectable.idl";
+import "eventtoken.idl";
+import "windows.foundation.idl";
+
+namespace Windows
+{
+ namespace Foundation
+ {
+ interface IClosable;
+ }
+}
+
+namespace Windows
+{
+ namespace Storage
+ {
+ namespace Streams
+ {
+ interface IContentTypeProvider;
+ interface IInputStream;
+ interface IOutputStream;
+ interface IRandomAccessStream;
+ interface IRandomAccessStreamWithContentType;
+ }
+ }
+}
+
+namespace Windows
+{
+ namespace Storage
+ {
+ namespace Streams
+ {
+ [
+ uuid(cc254827-4b3d-438f-9232-10c76bc7e038),
+ ]
+ interface IRandomAccessStreamWithContentType : IInspectable
+ requires
+ Windows.Storage.Streams.IRandomAccessStream,
+ Windows.Foundation.IClosable,
+ Windows.Storage.Streams.IInputStream,
+ Windows.Storage.Streams.IOutputStream,
+ Windows.Storage.Streams.IContentTypeProvider
+ {
+ }
+ }
+ }
+}
--
2.33.0
Oct. 29, 2021
[PATCH 1/4] include: Add IMapView interface.
by Jactry Zeng
Signed-off-by: Jactry Zeng <jzeng(a)codeweavers.com>
---
include/windows.foundation.collections.idl | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/include/windows.foundation.collections.idl b/include/windows.foundation.collections.idl
index b0b9430048b..876e15336a2 100644
--- a/include/windows.foundation.collections.idl
+++ b/include/windows.foundation.collections.idl
@@ -74,6 +74,18 @@ cpp_quote("#endif")
namespace Collections
{
+ [
+ contract(Windows.Foundation.FoundationContract, 1.0),
+ uuid(e480ce40-a338-4ada-adcf-272272e48cb9)
+ ]
+ interface IMapView<K, V> : IInspectable
+ {
+ HRESULT Lookup([in] K key, [out] V *value);
+ [propget] HRESULT Size([out] unsigned int *size);
+ HRESULT HasKey([in] K key, [out] boolean *found);
+ HRESULT Split([out] IMapView<K, V> **first, [out] IMapView<K, V> **second);
+ }
+
[
contract(Windows.Foundation.FoundationContract, 1.0),
uuid(6a79e863-4300-459a-9966-cbb660963ee1)
--
2.33.0
Oct. 29, 2021
Re: [PATCH v2 2/6] secur32/tests: Check supported DTLS protocols.
by Hans Leidekker
On Thu, 2021-10-28 at 13:27 -0500, Marvin wrote:
> === w1064 (32 bit report) ===
>
> secur32:
> schannel.c:1360: Test failed: got 00090317
> schannel.c:1370: Test failed: DecryptMessage failed: 80090317
>
> === w1064 (64 bit report) ===
>
> secur32:
> schannel.c:1360: Test failed: got 00090317
> schannel.c:1370: Test failed: DecryptMessage failed: 80090317
These failures also occur without these patches:
https://testbot.winehq.org/JobDetails.pl?Key=100997
Oct. 29, 2021
Re: [PATCH] po: Update Traditional Chinese translation.
by Jactry Zeng
Hi,
On 10/28/21 4:14 PM, Chilung Chan wrote:
> #: dlls/shell32/shell32.rc:336
> msgid ""
> "Type the name of a program, folder, document, or Internet resource, and Wine "
> "will open it for you."
> -msgstr "輸入程式,目錄,檔案或者 Internet 資源名,Wine 將為您開啟它。"
> +msgstr "輸入程式、資料夾,文件或網際網路資源名稱。Wine 將為您開啟它。"
The ',' here should be a '、' as well?
>
> #: dlls/shell32/shell32.rc:249
> msgid "Confirm overwrite"
> @@ -10619,16 +10193,16 @@ msgid ""
> "along with Wine; if not, write to the Free Software Foundation, Inc., 51 "
> "Franklin St, Fifth Floor, Boston, MA 02110-1301, USA."
> msgstr ""
> -"Wine 是自由軟體;您可以遵循由自由軟體基金會發布的 GNU 較寬鬆通用公共授權,再"
> -"次散布它和/或修改它;您可以採用版本 2.1 的授權,或 (您自行選擇的) 任何後續的"
> +"Wine 是自由軟體; 您可以遵循由自由軟體基金會發布的 GNU 較寬鬆通用公共授權,再"
> +"次散布它和/或修改它; 您可以採用版本 2.1 的授權,或 (您自行選擇的) 任何後續的"
> "版本。\n"
> "\n"
> -"Wine 的發行是希望它能夠有用,但是沒有任何擔保;亦無對於某一特定目的之適售性與"
> +"Wine 的發行是希望它能夠有用,但是沒有任何擔保; 亦無對於某一特定目的之適售性與"
> "適用性的暗示性擔保。參看 GNU 較寬鬆通用公共授權以獲得更多細節。\n"
> "\n"
> -"您應該已收到隨附於 Wine 的 GNU 較寬鬆通用公共授權複本;若無則請寫信到 Free "
> +"您應該已收到隨附於 Wine 的 GNU 較寬鬆通用公共授權複本;若無則請寫信到 Free "
Missed a space after ';' here.
Oct. 29, 2021
[PATCH 3/3] dinput: Move device data format to struct dinput_device.
by Rémi Bernon
Signed-off-by: Rémi Bernon <rbernon(a)codeweavers.com>
---
dlls/dinput/device.c | 26 +++++++++++++-------------
dlls/dinput/device_private.h | 7 +------
dlls/dinput/joystick_hid.c | 4 ++--
3 files changed, 16 insertions(+), 21 deletions(-)
diff --git a/dlls/dinput/device.c b/dlls/dinput/device.c
index 1eed223f51c..d375229e2c0 100644
--- a/dlls/dinput/device.c
+++ b/dlls/dinput/device.c
@@ -268,7 +268,7 @@ static BOOL match_device_object( DIDATAFORMAT *device_format, DIDATAFORMAT *user
static HRESULT dinput_device_init_user_format( struct dinput_device *impl, const DIDATAFORMAT *format )
{
- DIDATAFORMAT *user_format, *device_format = impl->data_format.wine_df;
+ DIDATAFORMAT *user_format, *device_format = impl->device_format;
DIOBJECTDATAFORMAT *user_obj, *match_obj;
DWORD i;
@@ -314,7 +314,7 @@ failed:
static int id_to_offset( struct dinput_device *impl, int id )
{
- DIDATAFORMAT *device_format = impl->data_format.wine_df, *user_format = impl->user_format;
+ DIDATAFORMAT *device_format = impl->device_format, *user_format = impl->user_format;
DIOBJECTDATAFORMAT *user_obj;
if (!user_format) return -1;
@@ -338,9 +338,9 @@ static DWORD semantic_to_obj_id( struct dinput_device *This, DWORD dwSemantic )
DWORD instance;
int i;
- for (i = 0; i < This->data_format.wine_df->dwNumObjs && !found; i++)
+ for (i = 0; i < This->device_format->dwNumObjs && !found; i++)
{
- LPDIOBJECTDATAFORMAT odf = dataformat_to_odf(This->data_format.wine_df, i);
+ LPDIOBJECTDATAFORMAT odf = dataformat_to_odf( This->device_format, i );
if (byofs && value != odf->dwOfs) continue;
if (!byofs && value != DIDFT_GETINSTANCE(odf->dwType)) continue;
@@ -747,8 +747,8 @@ void dinput_device_destroy( IDirectInputDevice8W *iface )
free( This->data_queue );
/* Free data format */
- free( This->data_format.wine_df->rgodf );
- free( This->data_format.wine_df );
+ free( This->device_format->rgodf );
+ free( This->device_format );
dinput_device_release_user_format( This );
/* Free action mapping */
@@ -884,7 +884,7 @@ static HRESULT WINAPI dinput_device_EnumObjects( IDirectInputDevice8W *iface,
static HRESULT enum_object_filter_init( struct dinput_device *impl, DIPROPHEADER *filter )
{
- DIDATAFORMAT *device_format = impl->data_format.wine_df, *user_format = impl->user_format;
+ DIDATAFORMAT *device_format = impl->device_format, *user_format = impl->user_format;
DIOBJECTDATAFORMAT *device_obj, *user_obj;
if (filter->dwHow > DIPH_BYUSAGE) return DIERR_INVALIDPARAM;
@@ -1224,7 +1224,7 @@ static HRESULT WINAPI dinput_device_GetObjectInfo( IDirectInputDevice8W *iface,
static HRESULT WINAPI dinput_device_GetDeviceState( IDirectInputDevice8W *iface, DWORD size, void *data )
{
struct dinput_device *impl = impl_from_IDirectInputDevice8W( iface );
- DIDATAFORMAT *device_format = impl->data_format.wine_df, *user_format;
+ DIDATAFORMAT *device_format = impl->device_format, *user_format;
DIOBJECTDATAFORMAT *device_obj, *user_obj;
BYTE *user_state = data;
DIPROPHEADER filter =
@@ -1595,7 +1595,7 @@ static HRESULT WINAPI dinput_device_BuildActionMap( IDirectInputDevice8W *iface,
break;
default:
devMask = DIGENRE_ANY;
- df = impl->data_format.wine_df;
+ df = impl->device_format;
break;
}
@@ -1684,7 +1684,7 @@ static HRESULT WINAPI dinput_device_SetActionMap( IDirectInputDevice8W *iface, D
df = &c_dfDIMouse2;
break;
default:
- df = impl->data_format.wine_df;
+ df = impl->device_format;
break;
}
@@ -1843,7 +1843,7 @@ HRESULT dinput_device_alloc( SIZE_T size, const struct dinput_device_vtbl *vtbl,
This->instance.dwSize = sizeof(DIDEVICEINSTANCEW);
This->caps.dwSize = sizeof(DIDEVCAPS);
This->caps.dwFlags = DIDC_ATTACHED | DIDC_EMULATED;
- This->data_format.wine_df = format;
+ This->device_format = format;
InitializeCriticalSection( &This->crit );
This->dinput = dinput;
IDirectInput_AddRef( &dinput->IDirectInput7A_iface );
@@ -1871,7 +1871,7 @@ static const GUID *object_instance_guid( const DIDEVICEOBJECTINSTANCEW *instance
static BOOL CALLBACK enum_objects_init( const DIDEVICEOBJECTINSTANCEW *instance, void *data )
{
struct dinput_device *impl = impl_from_IDirectInputDevice8W( data );
- DIDATAFORMAT *format = impl->data_format.wine_df;
+ DIDATAFORMAT *format = impl->device_format;
DIOBJECTDATAFORMAT *obj_format;
if (!format->rgodf)
@@ -1904,7 +1904,7 @@ static BOOL CALLBACK enum_objects_init( const DIDEVICEOBJECTINSTANCEW *instance,
HRESULT dinput_device_init( IDirectInputDevice8W *iface )
{
struct dinput_device *impl = impl_from_IDirectInputDevice8W( iface );
- DIDATAFORMAT *format = impl->data_format.wine_df;
+ DIDATAFORMAT *format = impl->device_format;
ULONG i, size;
IDirectInputDevice8_EnumObjects( iface, enum_objects_init, iface, DIDFT_ALL );
diff --git a/dlls/dinput/device_private.h b/dlls/dinput/device_private.h
index 190e2c16ffe..e77d0190a48 100644
--- a/dlls/dinput/device_private.h
+++ b/dlls/dinput/device_private.h
@@ -28,11 +28,6 @@
#include "wine/list.h"
#include "dinput_private.h"
-typedef struct
-{
- LPDIDATAFORMAT wine_df; /* wine internal data format */
-} DataFormat;
-
typedef struct
{
unsigned int offset;
@@ -88,7 +83,7 @@ struct dinput_device
BOOL overflow; /* return DI_BUFFEROVERFLOW in 'GetDeviceData' */
DWORD buffersize; /* size of the queue - set in 'SetProperty' */
- DataFormat data_format; /* user data format and wine to user format converter */
+ DIDATAFORMAT *device_format;
DIDATAFORMAT *user_format;
/* Action mapping */
diff --git a/dlls/dinput/joystick_hid.c b/dlls/dinput/joystick_hid.c
index 13d71a270b6..d7e64af9928 100644
--- a/dlls/dinput/joystick_hid.c
+++ b/dlls/dinput/joystick_hid.c
@@ -1115,7 +1115,7 @@ static HRESULT hid_joystick_read( IDirectInputDevice8W *iface )
};
struct hid_joystick *impl = impl_from_IDirectInputDevice8W( iface );
ULONG i, count, report_len = impl->caps.InputReportByteLength;
- DIDATAFORMAT *format = impl->base.data_format.wine_df;
+ DIDATAFORMAT *format = impl->base.device_format;
struct parse_device_state_params params = {{0}};
char *report_buf = impl->input_report_buf;
USAGE_AND_PAGE *usages;
@@ -2009,7 +2009,7 @@ static BOOL get_parameters_object_id( struct hid_joystick *impl, struct hid_valu
static BOOL get_parameters_object_ofs( struct hid_joystick *impl, struct hid_value_caps *caps,
DIDEVICEOBJECTINSTANCEW *instance, void *data )
{
- DIDATAFORMAT *device_format = impl->base.data_format.wine_df, *user_format = impl->base.user_format;
+ DIDATAFORMAT *device_format = impl->base.device_format, *user_format = impl->base.user_format;
DIOBJECTDATAFORMAT *device_obj, *user_obj;
if (!user_format) return DIENUM_CONTINUE;
--
2.33.0
Oct. 29, 2021
[PATCH 2/3] dinput: Rewrite and simplify user data format object matching.
by Rémi Bernon
Signed-off-by: Rémi Bernon <rbernon(a)codeweavers.com>
---
dlls/dinput/device.c | 282 +++++++----------------------------
dlls/dinput/device_private.h | 8 -
dlls/dinput8/tests/hid.c | 5 -
3 files changed, 56 insertions(+), 239 deletions(-)
diff --git a/dlls/dinput/device.c b/dlls/dinput/device.c
index ed9bdee98ea..1eed223f51c 100644
--- a/dlls/dinput/device.c
+++ b/dlls/dinput/device.c
@@ -107,138 +107,6 @@ static void _dump_cooperativelevel_DI(DWORD dwFlags) {
}
}
-static void _dump_ObjectDataFormat_flags(DWORD dwFlags) {
- unsigned int i;
- static const struct {
- DWORD mask;
- const char *name;
- } flags[] = {
-#define FE(x) { x, #x}
- FE(DIDOI_FFACTUATOR),
- FE(DIDOI_FFEFFECTTRIGGER),
- FE(DIDOI_POLLED),
- FE(DIDOI_GUIDISUSAGE)
-#undef FE
- };
-
- if (!dwFlags) return;
-
- TRACE("Flags:");
-
- /* First the flags */
- for (i = 0; i < ARRAY_SIZE(flags); i++) {
- if (flags[i].mask & dwFlags)
- TRACE(" %s",flags[i].name);
- }
-
- /* Now specific values */
-#define FE(x) case x: TRACE(" "#x); break
- switch (dwFlags & DIDOI_ASPECTMASK) {
- FE(DIDOI_ASPECTACCEL);
- FE(DIDOI_ASPECTFORCE);
- FE(DIDOI_ASPECTPOSITION);
- FE(DIDOI_ASPECTVELOCITY);
- }
-#undef FE
-
-}
-
-static void _dump_EnumObjects_flags(DWORD dwFlags) {
- if (TRACE_ON(dinput)) {
- unsigned int i;
- DWORD type, instance;
- static const struct {
- DWORD mask;
- const char *name;
- } flags[] = {
-#define FE(x) { x, #x}
- FE(DIDFT_RELAXIS),
- FE(DIDFT_ABSAXIS),
- FE(DIDFT_PSHBUTTON),
- FE(DIDFT_TGLBUTTON),
- FE(DIDFT_POV),
- FE(DIDFT_COLLECTION),
- FE(DIDFT_NODATA),
- FE(DIDFT_FFACTUATOR),
- FE(DIDFT_FFEFFECTTRIGGER),
- FE(DIDFT_OUTPUT),
- FE(DIDFT_VENDORDEFINED),
- FE(DIDFT_ALIAS),
- FE(DIDFT_OPTIONAL)
-#undef FE
- };
- type = (dwFlags & 0xFF0000FF);
- instance = ((dwFlags >> 8) & 0xFFFF);
- TRACE("Type:");
- if (type == DIDFT_ALL) {
- TRACE(" DIDFT_ALL");
- } else {
- for (i = 0; i < ARRAY_SIZE(flags); i++) {
- if (flags[i].mask & type) {
- type &= ~flags[i].mask;
- TRACE(" %s",flags[i].name);
- }
- }
- if (type) {
- TRACE(" (unhandled: %08x)", type);
- }
- }
- TRACE(" / Instance: ");
- if (instance == ((DIDFT_ANYINSTANCE >> 8) & 0xFFFF)) {
- TRACE("DIDFT_ANYINSTANCE");
- } else {
- TRACE("%3d", instance);
- }
- }
-}
-
-/* This function is a helper to convert a GUID into any possible DInput GUID out there */
-static const char *_dump_dinput_GUID( const GUID *guid )
-{
- unsigned int i;
- static const struct {
- const GUID *guid;
- const char *name;
- } guids[] = {
-#define FE(x) { &x, #x}
- FE(GUID_XAxis),
- FE(GUID_YAxis),
- FE(GUID_ZAxis),
- FE(GUID_RxAxis),
- FE(GUID_RyAxis),
- FE(GUID_RzAxis),
- FE(GUID_Slider),
- FE(GUID_Button),
- FE(GUID_Key),
- FE(GUID_POV),
- FE(GUID_Unknown),
- FE(GUID_SysMouse),
- FE(GUID_SysKeyboard),
- FE(GUID_Joystick),
- FE(GUID_ConstantForce),
- FE(GUID_RampForce),
- FE(GUID_Square),
- FE(GUID_Sine),
- FE(GUID_Triangle),
- FE(GUID_SawtoothUp),
- FE(GUID_SawtoothDown),
- FE(GUID_Spring),
- FE(GUID_Damper),
- FE(GUID_Inertia),
- FE(GUID_Friction),
- FE(GUID_CustomForce)
-#undef FE
- };
- if (guid == NULL)
- return "null GUID";
- for (i = 0; i < ARRAY_SIZE(guids); i++) {
- if (IsEqualGUID(guids[i].guid, guid)) {
- return guids[i].name;
- }
- }
- return debugstr_guid(guid);
-}
-
/******************************************************************************
* Get the default and the app-specific config keys.
*/
@@ -370,116 +238,78 @@ LPDIOBJECTDATAFORMAT dataformat_to_odf_by_type(LPCDIDATAFORMAT df, int n, DWORD
return NULL;
}
-static HRESULT dinput_device_init_user_format( struct dinput_device *impl, const DIDATAFORMAT *asked_format )
+static BOOL match_device_object( DIDATAFORMAT *device_format, DIDATAFORMAT *user_format,
+ const DIDATAFORMAT *format, const DIOBJECTDATAFORMAT *match_obj )
{
+ DWORD i, device_instance, instance = DIDFT_GETINSTANCE( match_obj->dwType );
DIOBJECTDATAFORMAT *device_obj, *user_obj;
- DataFormat *format = &impl->data_format;
- DIDATAFORMAT *user_format = NULL;
- unsigned int i, j;
- int *done;
- if (!format->wine_df) return DIERR_INVALIDPARAM;
- done = calloc( asked_format->dwNumObjs, sizeof(int) );
- if (!done) goto failed;
-
- if (!(user_format = malloc( sizeof(DIDATAFORMAT) ))) goto failed;
- *user_format = *format->wine_df;
- user_format->dwFlags = asked_format->dwFlags;
- user_format->dwDataSize = asked_format->dwDataSize;
- user_format->dwNumObjs += asked_format->dwNumObjs;
- if (!(user_format->rgodf = calloc( user_format->dwNumObjs, sizeof(DIOBJECTDATAFORMAT) ))) goto failed;
-
- TRACE("Creating DataTransform :\n");
-
- for (i = 0; i < format->wine_df->dwNumObjs; i++)
+ for (i = 0; i < device_format->dwNumObjs; i++)
{
- device_obj = format->wine_df->rgodf + i;
user_obj = user_format->rgodf + i;
+ device_obj = device_format->rgodf + i;
+ device_instance = DIDFT_GETINSTANCE( device_obj->dwType );
- for (j = 0; j < asked_format->dwNumObjs; j++)
+ if (!(user_obj->dwType & DIDFT_OPTIONAL)) continue; /* already matched */
+ if (match_obj->pguid && device_obj->pguid && !IsEqualGUID( device_obj->pguid, match_obj->pguid )) continue;
+ if (instance != DIDFT_GETINSTANCE( DIDFT_ANYINSTANCE ) && instance != device_instance) continue;
+ if (!(DIDFT_GETTYPE( match_obj->dwType ) & DIDFT_GETTYPE( device_obj->dwType ))) continue;
+
+ TRACE( "match %s with device %s\n", debugstr_diobjectdataformat( match_obj ),
+ debugstr_diobjectdataformat( device_obj ) );
+
+ *user_obj = *device_obj;
+ user_obj->dwOfs = match_obj->dwOfs;
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+static HRESULT dinput_device_init_user_format( struct dinput_device *impl, const DIDATAFORMAT *format )
+{
+ DIDATAFORMAT *user_format, *device_format = impl->data_format.wine_df;
+ DIOBJECTDATAFORMAT *user_obj, *match_obj;
+ DWORD i;
+
+ if (!device_format) return DIERR_INVALIDPARAM;
+ if (!(user_format = malloc( sizeof(DIDATAFORMAT) ))) return DIERR_OUTOFMEMORY;
+ *user_format = *device_format;
+ user_format->dwFlags = format->dwFlags;
+ user_format->dwDataSize = format->dwDataSize;
+ user_format->dwNumObjs += format->dwNumObjs;
+ if (!(user_format->rgodf = calloc( user_format->dwNumObjs, sizeof(DIOBJECTDATAFORMAT) )))
+ {
+ free( user_format );
+ return DIERR_OUTOFMEMORY;
+ }
+
+ user_obj = user_format->rgodf + user_format->dwNumObjs;
+ while (user_obj-- > user_format->rgodf) user_obj->dwType |= DIDFT_OPTIONAL;
+
+ for (i = 0; i < format->dwNumObjs; ++i)
+ {
+ match_obj = format->rgodf + i;
+
+ if (!match_device_object( device_format, user_format, format, match_obj ))
{
- if (done[j] == 1) continue;
-
- if (/* Check if the application either requests any GUID and if not, it if matches
- * the GUID of the Wine object.
- */
- ((asked_format->rgodf[j].pguid == NULL) ||
- (format->wine_df->rgodf[i].pguid == NULL) ||
- (IsEqualGUID(format->wine_df->rgodf[i].pguid, asked_format->rgodf[j].pguid)))
- &&
- (/* Then check if it accepts any instance id, and if not, if it matches Wine's
- * instance id.
- */
- ((asked_format->rgodf[j].dwType & DIDFT_INSTANCEMASK) == DIDFT_ANYINSTANCE) ||
- (DIDFT_GETINSTANCE(asked_format->rgodf[j].dwType) == 0x00FF) || /* This is mentioned in no DX docs, but it works fine - tested on WinXP */
- (DIDFT_GETINSTANCE(asked_format->rgodf[j].dwType) == DIDFT_GETINSTANCE(format->wine_df->rgodf[i].dwType)))
- &&
- ( /* Then if the asked type matches the one Wine provides */
- DIDFT_GETTYPE(asked_format->rgodf[j].dwType) & format->wine_df->rgodf[i].dwType))
- {
- done[j] = 1;
-
- TRACE("Matching :\n");
- TRACE(" - Asked (%d) :\n", j);
- TRACE(" * GUID: %s ('%s')\n",
- debugstr_guid(asked_format->rgodf[j].pguid),
- _dump_dinput_GUID(asked_format->rgodf[j].pguid));
- TRACE(" * Offset: %3d\n", asked_format->rgodf[j].dwOfs);
- TRACE(" * dwType: 0x%08x\n", asked_format->rgodf[j].dwType);
- TRACE(" "); _dump_EnumObjects_flags(asked_format->rgodf[j].dwType); TRACE("\n");
- TRACE(" * dwFlags: 0x%08x\n", asked_format->rgodf[j].dwFlags);
- TRACE(" "); _dump_ObjectDataFormat_flags(asked_format->rgodf[j].dwFlags); TRACE("\n");
-
- TRACE(" - Wine (%d) :\n", i);
- TRACE(" * GUID: %s ('%s')\n",
- debugstr_guid(format->wine_df->rgodf[i].pguid),
- _dump_dinput_GUID(format->wine_df->rgodf[i].pguid));
- TRACE(" * Offset: %3d\n", format->wine_df->rgodf[i].dwOfs);
- TRACE(" * dwType: 0x%08x\n", format->wine_df->rgodf[i].dwType);
- TRACE(" "); _dump_EnumObjects_flags(format->wine_df->rgodf[i].dwType); TRACE("\n");
- TRACE(" * dwFlags: 0x%08x\n", format->wine_df->rgodf[i].dwFlags);
- TRACE(" "); _dump_ObjectDataFormat_flags(format->wine_df->rgodf[i].dwFlags); TRACE("\n");
-
- *user_obj = *device_obj;
- user_obj->dwOfs = asked_format->rgodf[j].dwOfs;
- break;
- }
+ WARN( "object %s not found\n", debugstr_diobjectdataformat( match_obj ) );
+ if (!(match_obj->dwType & DIDFT_OPTIONAL)) goto failed;
+ user_obj = user_format->rgodf + device_format->dwNumObjs + i;
+ *user_obj = *match_obj;
}
}
- TRACE("Setting to default value :\n");
- for (j = 0; j < asked_format->dwNumObjs; j++) {
- user_obj = user_format->rgodf + format->wine_df->dwNumObjs + j;
-
- if (done[j] == 0) {
- TRACE(" - Asked (%d) :\n", j);
- TRACE(" * GUID: %s ('%s')\n",
- debugstr_guid(asked_format->rgodf[j].pguid),
- _dump_dinput_GUID(asked_format->rgodf[j].pguid));
- TRACE(" * Offset: %3d\n", asked_format->rgodf[j].dwOfs);
- TRACE(" * dwType: 0x%08x\n", asked_format->rgodf[j].dwType);
- TRACE(" "); _dump_EnumObjects_flags(asked_format->rgodf[j].dwType); TRACE("\n");
- TRACE(" * dwFlags: 0x%08x\n", asked_format->rgodf[j].dwFlags);
- TRACE(" "); _dump_ObjectDataFormat_flags(asked_format->rgodf[j].dwFlags); TRACE("\n");
-
- if (!(asked_format->rgodf[j].dwType & DIDFT_POV))
- continue; /* fill_DataFormat memsets the buffer to 0 */
-
- *user_obj = asked_format->rgodf[j];
- }
- }
-
- free( done );
+ user_obj = user_format->rgodf + user_format->dwNumObjs;
+ while (user_obj-- > user_format->rgodf) user_obj->dwType &= ~DIDFT_OPTIONAL;
impl->user_format = user_format;
return DI_OK;
failed:
- free( done );
- if (user_format) free( user_format->rgodf );
+ free( user_format->rgodf );
free( user_format );
-
- return DIERR_OUTOFMEMORY;
+ return DIERR_INVALIDPARAM;
}
static int id_to_offset( struct dinput_device *impl, int id )
diff --git a/dlls/dinput/device_private.h b/dlls/dinput/device_private.h
index 3f07a3a0f8a..190e2c16ffe 100644
--- a/dlls/dinput/device_private.h
+++ b/dlls/dinput/device_private.h
@@ -28,14 +28,6 @@
#include "wine/list.h"
#include "dinput_private.h"
-typedef struct
-{
- int size;
- int offset_in;
- int offset_out;
- int value;
-} DataTransform;
-
typedef struct
{
LPDIDATAFORMAT wine_df; /* wine internal data format */
diff --git a/dlls/dinput8/tests/hid.c b/dlls/dinput8/tests/hid.c
index dab6ea4478e..c6d01b8bee7 100644
--- a/dlls/dinput8/tests/hid.c
+++ b/dlls/dinput8/tests/hid.c
@@ -4475,26 +4475,21 @@ static void test_simple_joystick(void)
objdataformat[3].dwType = 0xff|DIDFT_ANYINSTANCE;
objdataformat[3].dwFlags = 0;
hr = IDirectInputDevice8_SetDataFormat( device, &dataformat );
- todo_wine
ok( hr == DIERR_INVALIDPARAM, "SetDataFormat returned: %#x\n", hr );
objdataformat[1].dwType = DIDFT_AXIS|DIDFT_MAKEINSTANCE( 12 );
hr = IDirectInputDevice8_SetDataFormat( device, &dataformat );
- todo_wine
ok( hr == DIERR_INVALIDPARAM, "SetDataFormat returned: %#x\n", hr );
objdataformat[1].dwType = DIDFT_AXIS|DIDFT_MAKEINSTANCE( 0xff );
hr = IDirectInputDevice8_SetDataFormat( device, &dataformat );
- todo_wine
ok( hr == DIERR_INVALIDPARAM, "SetDataFormat returned: %#x\n", hr );
objdataformat[1].dwType = DIDFT_AXIS|DIDFT_MAKEINSTANCE( 1 );
hr = IDirectInputDevice8_SetDataFormat( device, &dataformat );
ok( hr == DI_OK, "SetDataFormat returned: %#x\n", hr );
objdataformat[1].pguid = &GUID_RzAxis;
hr = IDirectInputDevice8_SetDataFormat( device, &dataformat );
- todo_wine
ok( hr == DIERR_INVALIDPARAM, "SetDataFormat returned: %#x\n", hr );
objdataformat[1].pguid = &GUID_Unknown;
hr = IDirectInputDevice8_SetDataFormat( device, &dataformat );
- todo_wine
ok( hr == DIERR_INVALIDPARAM, "SetDataFormat returned: %#x\n", hr );
objdataformat[1].pguid = &GUID_YAxis;
hr = IDirectInputDevice8_SetDataFormat( device, &dataformat );
--
2.33.0
Oct. 29, 2021
[PATCH 1/3] dinput: Use user object data format array to keep user offsets.
by Rémi Bernon
Signed-off-by: Rémi Bernon <rbernon(a)codeweavers.com>
---
dlls/dinput/device.c | 229 +++++++++++++----------------------
dlls/dinput/device_private.h | 4 -
dlls/dinput/joystick_hid.c | 21 ++--
dlls/dinput8/tests/hid.c | 1 -
4 files changed, 99 insertions(+), 156 deletions(-)
diff --git a/dlls/dinput/device.c b/dlls/dinput/device.c
index 6601d705462..ed9bdee98ea 100644
--- a/dlls/dinput/device.c
+++ b/dlls/dinput/device.c
@@ -334,73 +334,9 @@ BOOL device_instance_is_disabled( DIDEVICEINSTANCEW *instance, BOOL *override )
return disable;
}
-/* Conversion between internal data buffer and external data buffer */
-static void fill_DataFormat( void *out, DWORD size, const void *in, const DataFormat *df )
-{
- int i;
- const char *in_c = in;
- char *out_c = out;
-
- memset(out, 0, size);
- for (i = 0; i < df->size; i++) {
- if (df->dt[i].offset_in >= 0) {
- switch (df->dt[i].size) {
- case 1:
- TRACE("Copying (c) to %d from %d (value %d)\n",
- df->dt[i].offset_out, df->dt[i].offset_in, *(in_c + df->dt[i].offset_in));
- *(out_c + df->dt[i].offset_out) = *(in_c + df->dt[i].offset_in);
- break;
-
- case 2:
- TRACE("Copying (s) to %d from %d (value %d)\n",
- df->dt[i].offset_out, df->dt[i].offset_in, *((const short *)(in_c + df->dt[i].offset_in)));
- *((short *)(out_c + df->dt[i].offset_out)) = *((const short *)(in_c + df->dt[i].offset_in));
- break;
-
- case 4:
- TRACE("Copying (i) to %d from %d (value %d)\n",
- df->dt[i].offset_out, df->dt[i].offset_in, *((const int *)(in_c + df->dt[i].offset_in)));
- *((int *)(out_c + df->dt[i].offset_out)) = *((const int *)(in_c + df->dt[i].offset_in));
- break;
-
- default:
- memcpy((out_c + df->dt[i].offset_out), (in_c + df->dt[i].offset_in), df->dt[i].size);
- break;
- }
- } else {
- switch (df->dt[i].size) {
- case 1:
- TRACE("Copying (c) to %d default value %d\n",
- df->dt[i].offset_out, df->dt[i].value);
- *(out_c + df->dt[i].offset_out) = (char) df->dt[i].value;
- break;
-
- case 2:
- TRACE("Copying (s) to %d default value %d\n",
- df->dt[i].offset_out, df->dt[i].value);
- *((short *) (out_c + df->dt[i].offset_out)) = (short) df->dt[i].value;
- break;
-
- case 4:
- TRACE("Copying (i) to %d default value %d\n",
- df->dt[i].offset_out, df->dt[i].value);
- *((int *) (out_c + df->dt[i].offset_out)) = df->dt[i].value;
- break;
-
- default:
- memset((out_c + df->dt[i].offset_out), 0, df->dt[i].size);
- break;
- }
- }
- }
-}
-
static void dinput_device_release_user_format( struct dinput_device *impl )
{
- free( impl->data_format.dt );
- impl->data_format.dt = NULL;
- free( impl->data_format.offsets );
- impl->data_format.offsets = NULL;
+ if (impl->user_format) free( impl->user_format->rgodf );
free( impl->user_format );
impl->user_format = NULL;
}
@@ -436,33 +372,35 @@ LPDIOBJECTDATAFORMAT dataformat_to_odf_by_type(LPCDIDATAFORMAT df, int n, DWORD
static HRESULT dinput_device_init_user_format( struct dinput_device *impl, const DIDATAFORMAT *asked_format )
{
+ DIOBJECTDATAFORMAT *device_obj, *user_obj;
DataFormat *format = &impl->data_format;
- DataTransform *dt;
+ DIDATAFORMAT *user_format = NULL;
unsigned int i, j;
int *done;
- int index = 0;
- DWORD next = 0;
if (!format->wine_df) return DIERR_INVALIDPARAM;
done = calloc( asked_format->dwNumObjs, sizeof(int) );
- dt = malloc( asked_format->dwNumObjs * sizeof(DataTransform) );
- if (!dt || !done) goto failed;
+ if (!done) goto failed;
- if (!(format->offsets = malloc( format->wine_df->dwNumObjs * sizeof(int) ))) goto failed;
- if (!(impl->user_format = malloc( asked_format->dwSize ))) goto failed;
- memcpy( impl->user_format, asked_format, asked_format->dwSize );
+ if (!(user_format = malloc( sizeof(DIDATAFORMAT) ))) goto failed;
+ *user_format = *format->wine_df;
+ user_format->dwFlags = asked_format->dwFlags;
+ user_format->dwDataSize = asked_format->dwDataSize;
+ user_format->dwNumObjs += asked_format->dwNumObjs;
+ if (!(user_format->rgodf = calloc( user_format->dwNumObjs, sizeof(DIOBJECTDATAFORMAT) ))) goto failed;
TRACE("Creating DataTransform :\n");
for (i = 0; i < format->wine_df->dwNumObjs; i++)
{
- format->offsets[i] = -1;
+ device_obj = format->wine_df->rgodf + i;
+ user_obj = user_format->rgodf + i;
- for (j = 0; j < asked_format->dwNumObjs; j++) {
- if (done[j] == 1)
- continue;
-
- if (/* Check if the application either requests any GUID and if not, it if matches
+ for (j = 0; j < asked_format->dwNumObjs; j++)
+ {
+ if (done[j] == 1) continue;
+
+ if (/* Check if the application either requests any GUID and if not, it if matches
* the GUID of the Wine object.
*/
((asked_format->rgodf[j].pguid == NULL) ||
@@ -501,26 +439,19 @@ static HRESULT dinput_device_init_user_format( struct dinput_device *impl, const
TRACE(" "); _dump_EnumObjects_flags(format->wine_df->rgodf[i].dwType); TRACE("\n");
TRACE(" * dwFlags: 0x%08x\n", format->wine_df->rgodf[i].dwFlags);
TRACE(" "); _dump_ObjectDataFormat_flags(format->wine_df->rgodf[i].dwFlags); TRACE("\n");
-
- if (format->wine_df->rgodf[i].dwType & DIDFT_BUTTON)
- dt[index].size = sizeof(BYTE);
- else
- dt[index].size = sizeof(DWORD);
- dt[index].offset_in = format->wine_df->rgodf[i].dwOfs;
- dt[index].offset_out = asked_format->rgodf[j].dwOfs;
- format->offsets[i] = asked_format->rgodf[j].dwOfs;
- dt[index].value = 0;
- next = next + dt[index].size;
- index++;
- break;
- }
- }
+ *user_obj = *device_obj;
+ user_obj->dwOfs = asked_format->rgodf[j].dwOfs;
+ break;
+ }
+ }
}
TRACE("Setting to default value :\n");
for (j = 0; j < asked_format->dwNumObjs; j++) {
- if (done[j] == 0) {
+ user_obj = user_format->rgodf + format->wine_df->dwNumObjs + j;
+
+ if (done[j] == 0) {
TRACE(" - Asked (%d) :\n", j);
TRACE(" * GUID: %s ('%s')\n",
debugstr_guid(asked_format->rgodf[j].pguid),
@@ -534,55 +465,40 @@ static HRESULT dinput_device_init_user_format( struct dinput_device *impl, const
if (!(asked_format->rgodf[j].dwType & DIDFT_POV))
continue; /* fill_DataFormat memsets the buffer to 0 */
- if (asked_format->rgodf[j].dwType & DIDFT_BUTTON)
- dt[index].size = sizeof(BYTE);
- else
- dt[index].size = sizeof(DWORD);
- dt[index].offset_in = -1;
- dt[index].offset_out = asked_format->rgodf[j].dwOfs;
- dt[index].value = -1;
- index++;
- }
+ *user_obj = asked_format->rgodf[j];
+ }
}
- format->size = index;
- format->dt = dt;
-
free( done );
+ impl->user_format = user_format;
return DI_OK;
failed:
free( done );
- free( dt );
- format->dt = NULL;
- free( format->offsets );
- format->offsets = NULL;
- free( impl->user_format );
- impl->user_format = NULL;
+ if (user_format) free( user_format->rgodf );
+ free( user_format );
return DIERR_OUTOFMEMORY;
}
-static int id_to_object( LPCDIDATAFORMAT df, int id )
+static int id_to_offset( struct dinput_device *impl, int id )
{
- int i;
+ DIDATAFORMAT *device_format = impl->data_format.wine_df, *user_format = impl->user_format;
+ DIOBJECTDATAFORMAT *user_obj;
- id &= 0x00ffffff;
- for (i = 0; i < df->dwNumObjs; i++)
- if ((dataformat_to_odf(df, i)->dwType & 0x00ffffff) == id)
- return i;
+ if (!user_format) return -1;
+
+ user_obj = user_format->rgodf + device_format->dwNumObjs;
+ while (user_obj-- > user_format->rgodf)
+ {
+ if (!user_obj->dwType) continue;
+ if ((user_obj->dwType & 0x00ffffff) == (id & 0x00ffffff)) return user_obj->dwOfs;
+ }
return -1;
}
-static int id_to_offset(const DataFormat *df, int id)
-{
- int obj = id_to_object(df->wine_df, id);
-
- return obj >= 0 && df->offsets ? df->offsets[obj] : -1;
-}
-
static DWORD semantic_to_obj_id( struct dinput_device *This, DWORD dwSemantic )
{
DWORD type = (0x0000ff00 & dwSemantic) >> 8;
@@ -769,7 +685,7 @@ void queue_event( IDirectInputDevice8W *iface, int inst_id, DWORD data, DWORD ti
{
static ULONGLONG notify_ms = 0;
struct dinput_device *This = impl_from_IDirectInputDevice8W( iface );
- int next_pos, ofs = id_to_offset(&This->data_format, inst_id);
+ int next_pos, ofs = id_to_offset( This, inst_id );
ULONGLONG time_ms = GetTickCount64();
if (time_ms - notify_ms > 1000)
@@ -1138,19 +1054,25 @@ static HRESULT WINAPI dinput_device_EnumObjects( IDirectInputDevice8W *iface,
static HRESULT enum_object_filter_init( struct dinput_device *impl, DIPROPHEADER *filter )
{
- DIDATAFORMAT *format = impl->data_format.wine_df;
- int i, *offsets = impl->data_format.offsets;
+ DIDATAFORMAT *device_format = impl->data_format.wine_df, *user_format = impl->user_format;
+ DIOBJECTDATAFORMAT *device_obj, *user_obj;
if (filter->dwHow > DIPH_BYUSAGE) return DIERR_INVALIDPARAM;
if (filter->dwHow == DIPH_BYUSAGE && !(impl->instance.dwDevType & DIDEVTYPE_HID)) return DIERR_UNSUPPORTED;
if (filter->dwHow != DIPH_BYOFFSET) return DI_OK;
- if (!offsets) return DIERR_NOTFOUND;
+ if (!impl->user_format) return DIERR_NOTFOUND;
- for (i = 0; i < format->dwNumObjs; ++i) if (offsets[i] == filter->dwObj) break;
- if (i == format->dwNumObjs) return DIERR_NOTFOUND;
+ user_obj = user_format->rgodf + device_format->dwNumObjs;
+ device_obj = device_format->rgodf + device_format->dwNumObjs;
+ while (user_obj-- > user_format->rgodf && device_obj-- > device_format->rgodf)
+ {
+ if (!user_obj->dwType) continue;
+ if (user_obj->dwOfs == filter->dwObj) break;
+ }
+ if (user_obj < user_format->rgodf) return DIERR_NOTFOUND;
- filter->dwObj = format->rgodf[i].dwOfs;
+ filter->dwObj = device_obj->dwOfs;
return DI_OK;
}
@@ -1397,7 +1319,7 @@ static HRESULT WINAPI dinput_device_SetProperty( IDirectInputDevice8W *iface, co
hr = impl->vtbl->enum_objects( iface, &filter, object_mask, find_object, &instance );
if (FAILED(hr)) return hr;
if (hr == DIENUM_CONTINUE) return DIERR_OBJECTNOTFOUND;
- if ((user_offset = id_to_offset( &impl->data_format, instance.dwType )) < 0) return DIERR_OBJECTNOTFOUND;
+ if ((user_offset = id_to_offset( impl, instance.dwType )) < 0) return DIERR_OBJECTNOTFOUND;
if (!set_app_data( impl, user_offset, value->uData )) return DIERR_OUTOFMEMORY;
return DI_OK;
}
@@ -1469,15 +1391,12 @@ static HRESULT WINAPI dinput_device_GetObjectInfo( IDirectInputDevice8W *iface,
return DI_OK;
}
-static BOOL CALLBACK reset_axis_data( const DIDEVICEOBJECTINSTANCEW *instance, void *data )
-{
- *(ULONG *)((char *)data + instance->dwOfs) = 0;
- return DIENUM_CONTINUE;
-}
-
static HRESULT WINAPI dinput_device_GetDeviceState( IDirectInputDevice8W *iface, DWORD size, void *data )
{
struct dinput_device *impl = impl_from_IDirectInputDevice8W( iface );
+ DIDATAFORMAT *device_format = impl->data_format.wine_df, *user_format;
+ DIOBJECTDATAFORMAT *device_obj, *user_obj;
+ BYTE *user_state = data;
DIPROPHEADER filter =
{
.dwSize = sizeof(filter),
@@ -1496,13 +1415,37 @@ static HRESULT WINAPI dinput_device_GetDeviceState( IDirectInputDevice8W *iface,
EnterCriticalSection( &impl->crit );
if (!impl->acquired)
hr = DIERR_NOTACQUIRED;
- else if (size != impl->user_format->dwDataSize)
+ else if (!(user_format = impl->user_format))
+ hr = DIERR_INVALIDPARAM;
+ else if (size != user_format->dwDataSize)
hr = DIERR_INVALIDPARAM;
else
{
- fill_DataFormat( data, size, impl->device_state, &impl->data_format );
- if (!(impl->user_format->dwFlags & DIDF_ABSAXIS))
- impl->vtbl->enum_objects( iface, &filter, DIDFT_RELAXIS, reset_axis_data, impl->device_state );
+ memset( user_state, 0, size );
+
+ user_obj = user_format->rgodf + device_format->dwNumObjs;
+ device_obj = device_format->rgodf + device_format->dwNumObjs;
+ while (user_obj-- > user_format->rgodf && device_obj-- > device_format->rgodf)
+ {
+ if (user_obj->dwType & DIDFT_BUTTON)
+ user_state[user_obj->dwOfs] = impl->device_state[device_obj->dwOfs];
+ }
+
+ /* reset optional POVs to their default */
+ user_obj = user_format->rgodf + user_format->dwNumObjs;
+ while (user_obj-- > user_format->rgodf + device_format->dwNumObjs)
+ if (user_obj->dwType & DIDFT_POV) *(ULONG *)(user_state + user_obj->dwOfs) = 0xffffffff;
+
+ user_obj = user_format->rgodf + device_format->dwNumObjs;
+ device_obj = device_format->rgodf + device_format->dwNumObjs;
+ while (user_obj-- > user_format->rgodf && device_obj-- > device_format->rgodf)
+ {
+ if (user_obj->dwType & (DIDFT_POV | DIDFT_AXIS))
+ *(ULONG *)(user_state + user_obj->dwOfs) = *(ULONG *)(impl->device_state + device_obj->dwOfs);
+ if (!(user_format->dwFlags & DIDF_ABSAXIS) && (device_obj->dwType & DIDFT_RELAXIS))
+ *(ULONG *)(impl->device_state + device_obj->dwOfs) = 0;
+ }
+
hr = DI_OK;
}
LeaveCriticalSection( &impl->crit );
diff --git a/dlls/dinput/device_private.h b/dlls/dinput/device_private.h
index 1b81a374058..3f07a3a0f8a 100644
--- a/dlls/dinput/device_private.h
+++ b/dlls/dinput/device_private.h
@@ -38,10 +38,6 @@ typedef struct
typedef struct
{
- int size;
- DataTransform *dt;
-
- int *offsets; /* object offsets */
LPDIDATAFORMAT wine_df; /* wine internal data format */
} DataFormat;
diff --git a/dlls/dinput/joystick_hid.c b/dlls/dinput/joystick_hid.c
index 3a8c7213ebc..13d71a270b6 100644
--- a/dlls/dinput/joystick_hid.c
+++ b/dlls/dinput/joystick_hid.c
@@ -2009,16 +2009,21 @@ static BOOL get_parameters_object_id( struct hid_joystick *impl, struct hid_valu
static BOOL get_parameters_object_ofs( struct hid_joystick *impl, struct hid_value_caps *caps,
DIDEVICEOBJECTINSTANCEW *instance, void *data )
{
- DIDATAFORMAT *format = impl->base.data_format.wine_df;
- int *offsets = impl->base.data_format.offsets;
- ULONG i;
+ DIDATAFORMAT *device_format = impl->base.data_format.wine_df, *user_format = impl->base.user_format;
+ DIOBJECTDATAFORMAT *device_obj, *user_obj;
- if (!offsets) return DIENUM_CONTINUE;
- for (i = 0; i < format->dwNumObjs; ++i)
- if (format->rgodf[i].dwOfs == instance->dwOfs) break;
- if (i == format->dwNumObjs) return DIENUM_CONTINUE;
- *(DWORD *)data = offsets[i];
+ if (!user_format) return DIENUM_CONTINUE;
+ user_obj = user_format->rgodf + device_format->dwNumObjs;
+ device_obj = device_format->rgodf + device_format->dwNumObjs;
+ while (user_obj-- > user_format->rgodf && device_obj-- > device_format->rgodf)
+ {
+ if (!user_obj->dwType) continue;
+ if (device_obj->dwType == instance->dwType) break;
+ }
+ if (user_obj < user_format->rgodf) return DIENUM_CONTINUE;
+
+ *(DWORD *)data = user_obj->dwOfs;
return DIENUM_STOP;
}
diff --git a/dlls/dinput8/tests/hid.c b/dlls/dinput8/tests/hid.c
index 2f2efbe09e3..dab6ea4478e 100644
--- a/dlls/dinput8/tests/hid.c
+++ b/dlls/dinput8/tests/hid.c
@@ -4539,7 +4539,6 @@ static void test_simple_joystick(void)
hr = IDirectInputDevice8_GetDeviceState( device, dataformat.dwDataSize, buffer );
ok( hr == DI_OK, "GetDeviceState returned: %#x\n", hr );
- todo_wine
ok( ((ULONG *)buffer)[0] == 0x512b, "got %#x, expected %#x\n", ((ULONG *)buffer)[0], 0x512b );
ok( ((ULONG *)buffer)[1] == 0, "got %#x, expected %#x\n", ((ULONG *)buffer)[1], 0 );
ok( ((ULONG *)buffer)[2] == 0x7fff, "got %#x, expected %#x\n", ((ULONG *)buffer)[2], 0x7fff );
--
2.33.0
Oct. 29, 2021