winehq.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2025
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
List overview
wine-commits
August 2009
----- 2025 -----
February 2025
January 2025
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
January 2004
----- 2003 -----
December 2003
November 2003
October 2003
September 2003
August 2003
July 2003
June 2003
May 2003
April 2003
March 2003
February 2003
January 2003
----- 2002 -----
December 2002
November 2002
October 2002
September 2002
August 2002
July 2002
June 2002
May 2002
April 2002
March 2002
February 2002
January 2002
----- 2001 -----
December 2001
November 2001
October 2001
September 2001
August 2001
July 2001
June 2001
May 2001
April 2001
March 2001
February 2001
wine-commits@winehq.org
4 participants
1042 discussions
Start a n
N
ew thread
Alexandre Julliard : tests: Make wine_dbgstr_w available in test. h for all tests.
by Alexandre Julliard
19 Aug '09
19 Aug '09
Module: wine Branch: master Commit: ee868cce5b412b103ff167deb59c3d5237363199 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=ee868cce5b412b103ff167deb…
Author: Alexandre Julliard <julliard(a)winehq.org> Date: Wed Aug 19 13:19:31 2009 +0200 tests: Make wine_dbgstr_w available in test.h for all tests. --- dlls/kernel32/tests/process.c | 17 -------- dlls/ntdsapi/tests/ntdsapi.c | 9 ---- dlls/oleaut32/tests/tmarshal.c | 80 -------------------------------------- dlls/shell32/tests/shlfolder.c | 9 ---- include/wine/test.h | 83 +++++++++++++++++++++++++++++++++++++++- 5 files changed, 82 insertions(+), 116 deletions(-) diff --git a/dlls/kernel32/tests/process.c b/dlls/kernel32/tests/process.c index 21f3c52..5d8f65b 100644 --- a/dlls/kernel32/tests/process.c +++ b/dlls/kernel32/tests/process.c @@ -54,23 +54,6 @@ wine_dbgstr_w(expected), wine_dbgstr_w(value)); \ } while (0) -/* A simpler version of wine_dbgstr_w. Note that the returned buffer will be - * invalid after 16 calls to this funciton. */ -static const char *wine_dbgstr_w(LPCWSTR wstr) -{ - static char *buffers[16]; - static int curr_buffer = 0; - - int size; - - curr_buffer = (curr_buffer + 1) % 16; - HeapFree(GetProcessHeap(), 0, buffers[curr_buffer]); - size = WideCharToMultiByte(CP_ACP, 0, wstr, -1, NULL, 0, NULL, NULL); - buffers[curr_buffer] = HeapAlloc(GetProcessHeap(), 0, size); - size = WideCharToMultiByte(CP_ACP, 0, wstr, -1, buffers[curr_buffer], size, NULL, NULL); - return buffers[curr_buffer]; -} - static HINSTANCE hkernel32; static LPVOID (WINAPI *pVirtualAllocEx)(HANDLE, LPVOID, SIZE_T, DWORD, DWORD); static BOOL (WINAPI *pVirtualFreeEx)(HANDLE, LPVOID, SIZE_T, DWORD); diff --git a/dlls/ntdsapi/tests/ntdsapi.c b/dlls/ntdsapi/tests/ntdsapi.c index 08436ae..8290ed2 100644 --- a/dlls/ntdsapi/tests/ntdsapi.c +++ b/dlls/ntdsapi/tests/ntdsapi.c @@ -28,15 +28,6 @@ #include "wine/test.h" -static const char *wine_dbgstr_w(LPCWSTR str) -{ - static char buf[512]; - if (!str) - return "(null)"; - WideCharToMultiByte(CP_ACP, 0, str, -1, buf, sizeof(buf), NULL, NULL); - return buf; -} - static void test_DsMakeSpn(void) { DWORD ret; diff --git a/dlls/oleaut32/tests/tmarshal.c b/dlls/oleaut32/tests/tmarshal.c index ec23204..80148ff 100644 --- a/dlls/oleaut32/tests/tmarshal.c +++ b/dlls/oleaut32/tests/tmarshal.c @@ -44,86 +44,6 @@ const MYSTRUCT MYSTRUCT_ARRAY[5] = { {0x5a5b5c5d, ULL_CONST(0x5e5f5051, 0x52535455)}, }; -/* Debugging functions from wine/libs/wine/debug.c */ - -/* allocate some tmp string space */ -/* FIXME: this is not 100% thread-safe */ -static char *get_tmp_space( int size ) -{ - static char *list[32]; - static long pos; - char *ret; - int idx; - - idx = ++pos % (sizeof(list)/sizeof(list[0])); - if (list[idx]) - ret = HeapReAlloc( GetProcessHeap(), 0, list[idx], size ); - else - ret = HeapAlloc( GetProcessHeap(), 0, size ); - if (ret) list[idx] = ret; - return ret; -} - -/* default implementation of wine_dbgstr_wn */ -static const char *default_dbgstr_wn( const WCHAR *str, int n ) -{ - char *dst, *res; - - if (!HIWORD(str)) - { - if (!str) return "(null)"; - res = get_tmp_space( 6 ); - sprintf( res, "#%04x", LOWORD(str) ); - return res; - } - if (n == -1) n = lstrlenW(str); - if (n < 0) n = 0; - else if (n > 200) n = 200; - dst = res = get_tmp_space( n * 5 + 7 ); - *dst++ = 'L'; - *dst++ = '"'; - while (n-- > 0) - { - WCHAR c = *str++; - switch (c) - { - case '\n': *dst++ = '\\'; *dst++ = 'n'; break; - case '\r': *dst++ = '\\'; *dst++ = 'r'; break; - case '\t': *dst++ = '\\'; *dst++ = 't'; break; - case '"': *dst++ = '\\'; *dst++ = '"'; break; - case '\\': *dst++ = '\\'; *dst++ = '\\'; break; - default: - if (c >= ' ' && c <= 126) - *dst++ = (char)c; - else - { - *dst++ = '\\'; - sprintf(dst,"%04x",c); - dst+=4; - } - } - } - *dst++ = '"'; - if (*str) - { - *dst++ = '.'; - *dst++ = '.'; - *dst++ = '.'; - } - *dst = 0; - return res; -} - -const char *wine_dbgstr_wn( const WCHAR *s, int n ) -{ - return default_dbgstr_wn(s, n); -} - -const char *wine_dbgstr_w( const WCHAR *s ) -{ - return default_dbgstr_wn( s, -1 ); -} - #define RELEASEMARSHALDATA WM_USER diff --git a/dlls/shell32/tests/shlfolder.c b/dlls/shell32/tests/shlfolder.c index 535c9ad..ed3a8b5 100644 --- a/dlls/shell32/tests/shlfolder.c +++ b/dlls/shell32/tests/shlfolder.c @@ -81,15 +81,6 @@ static void init_function_pointers(void) ok(hr == S_OK, "SHGetMalloc failed %08x\n", hr); } -static const char *wine_dbgstr_w(LPCWSTR str) -{ - static char buf[512]; - if (!str) - return "(null)"; - WideCharToMultiByte(CP_ACP, 0, str, -1, buf, sizeof(buf), NULL, NULL); - return buf; -} - static void test_ParseDisplayName(void) { HRESULT hr; diff --git a/include/wine/test.h b/include/wine/test.h index a8f6f03..42a56c0 100644 --- a/include/wine/test.h +++ b/include/wine/test.h @@ -62,6 +62,9 @@ extern void winetest_end_todo( const char* platform ); extern int winetest_get_mainargs( char*** pargv ); extern void winetest_wait_child_process( HANDLE process ); +extern const char *wine_dbgstr_wn( const WCHAR *str, int n ); +static inline const char *wine_dbgstr_w( const WCHAR *s ) { return wine_dbgstr_wn( s, -1 ); } + #ifdef STANDALONE #define START_TEST(name) \ static void func_##name(void); \ @@ -196,6 +199,8 @@ typedef struct int current_line; /* line of current check */ int todo_level; /* current todo nesting level */ int todo_do_loop; + char *str_pos; /* position in debug buffer */ + char strings[2000]; /* buffer for debug strings */ } tls_data; static DWORD tls_index; @@ -208,13 +213,33 @@ static tls_data* get_tls_data(void) data=TlsGetValue(tls_index); if (!data) { - data=HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(tls_data)); + data=HeapAlloc(GetProcessHeap(), 0, sizeof(tls_data)); + data->todo_level = 0; + data->str_pos = data->strings; TlsSetValue(tls_index,data); } SetLastError(last_error); return data; } +/* allocate some tmp space for a string */ +static char *get_temp_buffer( size_t n ) +{ + tls_data *data = get_tls_data(); + char *res = data->str_pos; + + if (res + n >= &data->strings[sizeof(data->strings)]) res = data->strings; + data->str_pos = res + n; + return res; +} + +/* release extra space that we requested in gimme1() */ +static void release_temp_buffer( char *ptr, size_t size ) +{ + tls_data *data = get_tls_data(); + data->str_pos = ptr + size; +} + static void exit_process( int code ) { fflush( stdout ); @@ -407,6 +432,62 @@ void winetest_wait_child_process( HANDLE process ) } } +const char *wine_dbgstr_wn( const WCHAR *str, int n ) +{ + char *dst, *res; + size_t size; + + if (!((ULONG_PTR)str >> 16)) + { + if (!str) return "(null)"; + res = get_temp_buffer( 6 ); + sprintf( res, "#%04x", LOWORD(str) ); + return res; + } + if (n == -1) + { + const WCHAR *end = str; + while (*end) end++; + n = end - str; + } + if (n < 0) n = 0; + size = 12 + min( 300, n * 5 ); + dst = res = get_temp_buffer( size ); + *dst++ = 'L'; + *dst++ = '"'; + while (n-- > 0 && dst <= res + size - 10) + { + WCHAR c = *str++; + switch (c) + { + case '\n': *dst++ = '\\'; *dst++ = 'n'; break; + case '\r': *dst++ = '\\'; *dst++ = 'r'; break; + case '\t': *dst++ = '\\'; *dst++ = 't'; break; + case '"': *dst++ = '\\'; *dst++ = '"'; break; + case '\\': *dst++ = '\\'; *dst++ = '\\'; break; + default: + if (c >= ' ' && c <= 126) + *dst++ = c; + else + { + *dst++ = '\\'; + sprintf(dst,"%04x",c); + dst+=4; + } + } + } + *dst++ = '"'; + if (n > 0) + { + *dst++ = '.'; + *dst++ = '.'; + *dst++ = '.'; + } + *dst++ = 0; + release_temp_buffer( res, dst - res ); + return res; +} + /* Find a test by name */ static const struct test *find_test( const char *name ) {
1
0
0
0
Vitaliy Margolen : dinput: Fix evdev POV mapping.
by Alexandre Julliard
19 Aug '09
19 Aug '09
Module: wine Branch: master Commit: 83172ecc828f6c48e2686b5aefe7791f8ca6b920 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=83172ecc828f6c48e2686b5ae…
Author: Vitaliy Margolen <wine-patches(a)kievinfo.com> Date: Sat Aug 15 12:43:38 2009 -0600 dinput: Fix evdev POV mapping. --- dlls/dinput/joystick_linuxinput.c | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-) diff --git a/dlls/dinput/joystick_linuxinput.c b/dlls/dinput/joystick_linuxinput.c index d2f8dc1..4409b73 100644 --- a/dlls/dinput/joystick_linuxinput.c +++ b/dlls/dinput/joystick_linuxinput.c @@ -425,9 +425,11 @@ static JoystickImpl *alloc_device(REFGUID rguid, const void *jvt, IDirectInputIm test_bit(newDevice->joydev->absbits, ABS_HAT0Y + i * 2)) { newDevice->generic.device_axis_count += 2; - newDevice->generic.props[idx].lDevMin = newDevice->joydev->axes[ABS_HAT0X + i * 2].minimum; + newDevice->generic.props[idx ].lDevMin = newDevice->joydev->axes[ABS_HAT0X + i * 2].minimum; + newDevice->generic.props[idx ].lDevMax = newDevice->joydev->axes[ABS_HAT0X + i * 2].maximum; newDevice->dev_axes_to_di[ABS_HAT0X + i * 2] = idx; - newDevice->generic.props[idx].lDevMax = newDevice->joydev->axes[ABS_HAT0Y + i * 2].maximum; + newDevice->generic.props[idx+1].lDevMin = newDevice->joydev->axes[ABS_HAT0Y + i * 2].minimum; + newDevice->generic.props[idx+1].lDevMax = newDevice->joydev->axes[ABS_HAT0Y + i * 2].maximum; newDevice->dev_axes_to_di[ABS_HAT0Y + i * 2] = idx + 1; default_axis_map[idx] = default_axis_map[idx + 1] = WINE_JOYSTICK_MAX_AXES + i;
1
0
0
0
Vitaliy Margolen : dinput: Get default axes configuration from the device for joydev.
by Alexandre Julliard
19 Aug '09
19 Aug '09
Module: wine Branch: master Commit: 0932f4a1137974f4326fbba8b2d68d8e9b2aed70 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=0932f4a1137974f4326fbba8b…
Author: Vitaliy Margolen <wine-patches(a)kievinfo.com> Date: Sat Aug 15 11:59:05 2009 -0600 dinput: Get default axes configuration from the device for joydev. --- dlls/dinput/joystick_linux.c | 29 ++++++++++++++++++++++++++++- 1 files changed, 28 insertions(+), 1 deletions(-) diff --git a/dlls/dinput/joystick_linux.c b/dlls/dinput/joystick_linux.c index 32f0314..d5f28a3 100644 --- a/dlls/dinput/joystick_linux.c +++ b/dlls/dinput/joystick_linux.c @@ -79,6 +79,9 @@ struct JoyDev { char device[MAX_PATH]; char name[MAX_PATH]; + + BYTE dev_axes_map[ABS_MAX + 1]; + int have_axes_map; }; typedef struct JoystickImpl JoystickImpl; @@ -133,6 +136,29 @@ static INT find_joystick_devices(void) WARN("ioctl(%s,JSIOCGNAME) failed: %s\n", joydev.device, strerror(errno)); #endif + if (ioctl(fd, JSIOCGAXMAP, joydev.dev_axes_map) < 0) + { + WARN("ioctl(%s,JSIOCGNAME) failed: %s\n", joydev.device, strerror(errno)); + joydev.have_axes_map = 0; + } + else + { + INT j; + joydev.have_axes_map = 1; + + /* Remap to DI numbers */ + for (j = 0; j < ABS_MAX; j++) + if (joydev.dev_axes_map[j] < 8) + /* Axis match 1-to-1 */ + joydev.dev_axes_map[j] = j; + else if (joydev.dev_axes_map[j] == 16 || + joydev.dev_axes_map[j] == 17) + /* POV axis */ + joydev.dev_axes_map[j] = 8; + else + joydev.dev_axes_map[j] = -1; + } + close(fd); if (!joystick_devices_count) @@ -296,7 +322,8 @@ static HRESULT alloc_device(REFGUID rguid, const void *jvt, IDirectInputImpl *di newDevice->generic.deadzone = 0; /* do any user specified configuration */ - hr = setup_dinput_options(&newDevice->generic, NULL); + hr = setup_dinput_options(&newDevice->generic, newDevice->joydev->have_axes_map ? + newDevice->joydev->dev_axes_map : NULL); if (hr != DI_OK) goto FAILED1;
1
0
0
0
Vitaliy Margolen : dinput: Expand joydev joystick discovery to query joystick name as well.
by Alexandre Julliard
19 Aug '09
19 Aug '09
Module: wine Branch: master Commit: 9a73798af8fb35430077cd0dd1b4f2e4ee757574 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=9a73798af8fb35430077cd0dd…
Author: Vitaliy Margolen <wine-patches(a)kievinfo.com> Date: Sat Aug 15 11:59:00 2009 -0600 dinput: Expand joydev joystick discovery to query joystick name as well. --- dlls/dinput/joystick_linux.c | 111 ++++++++++++++++++------------------------ 1 files changed, 48 insertions(+), 63 deletions(-) Diff:
http://source.winehq.org/git/wine.git/?a=commitdiff;h=9a73798af8fb35430077c…
1
0
0
0
Vitaliy Margolen : dinput: Set default joystick axes mapping for evdev.
by Alexandre Julliard
19 Aug '09
19 Aug '09
Module: wine Branch: master Commit: 2941cc72e5f650a9d113d33eaf30ccbb028d0173 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=2941cc72e5f650a9d113d33ea…
Author: Vitaliy Margolen <wine-patches(a)kievinfo.com> Date: Sat Aug 15 11:58:56 2009 -0600 dinput: Set default joystick axes mapping for evdev. --- dlls/dinput/joystick_linuxinput.c | 11 ++++++++--- 1 files changed, 8 insertions(+), 3 deletions(-) diff --git a/dlls/dinput/joystick_linuxinput.c b/dlls/dinput/joystick_linuxinput.c index 07524c0..d2f8dc1 100644 --- a/dlls/dinput/joystick_linuxinput.c +++ b/dlls/dinput/joystick_linuxinput.c @@ -378,6 +378,7 @@ static JoystickImpl *alloc_device(REFGUID rguid, const void *jvt, IDirectInputIm JoystickImpl* newDevice; LPDIDATAFORMAT df = NULL; int i, idx = 0; + BYTE default_axis_map[WINE_JOYSTICK_MAX_AXES + WINE_JOYSTICK_MAX_POVS*2]; newDevice = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(JoystickImpl)); if (!newDevice) return NULL; @@ -411,6 +412,7 @@ static JoystickImpl *alloc_device(REFGUID rguid, const void *jvt, IDirectInputIm newDevice->dev_axes_to_di[i] = idx; newDevice->generic.props[idx].lDevMin = newDevice->joydev->axes[i].minimum; newDevice->generic.props[idx].lDevMax = newDevice->joydev->axes[i].maximum; + default_axis_map[idx] = i; idx++; } else @@ -424,16 +426,19 @@ static JoystickImpl *alloc_device(REFGUID rguid, const void *jvt, IDirectInputIm { newDevice->generic.device_axis_count += 2; newDevice->generic.props[idx].lDevMin = newDevice->joydev->axes[ABS_HAT0X + i * 2].minimum; - newDevice->dev_axes_to_di[ABS_HAT0X + i * 2] = idx++; + newDevice->dev_axes_to_di[ABS_HAT0X + i * 2] = idx; newDevice->generic.props[idx].lDevMax = newDevice->joydev->axes[ABS_HAT0Y + i * 2].maximum; - newDevice->dev_axes_to_di[ABS_HAT0Y + i * 2] = idx++; + newDevice->dev_axes_to_di[ABS_HAT0Y + i * 2] = idx + 1; + + default_axis_map[idx] = default_axis_map[idx + 1] = WINE_JOYSTICK_MAX_AXES + i; + idx += 2; } else newDevice->dev_axes_to_di[ABS_HAT0X + i * 2] = newDevice->dev_axes_to_di[ABS_HAT0Y + i * 2] = -1; } /* do any user specified configuration */ - if (setup_dinput_options(&newDevice->generic, NULL) != DI_OK) goto failed; + if (setup_dinput_options(&newDevice->generic, default_axis_map) != DI_OK) goto failed; /* Create copy of default data format */ if (!(df = HeapAlloc(GetProcessHeap(), 0, c_dfDIJoystick2.dwSize))) goto failed;
1
0
0
0
Vitaliy Margolen : dinput: Let driver specify default axis mapping.
by Alexandre Julliard
19 Aug '09
19 Aug '09
Module: wine Branch: master Commit: fa9c11dad396cdabf7527f7aef94f2cd49efb888 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=fa9c11dad396cdabf7527f7ae…
Author: Vitaliy Margolen <wine-patches(a)kievinfo.com> Date: Sat Aug 15 11:58:52 2009 -0600 dinput: Let driver specify default axis mapping. --- dlls/dinput/joystick.c | 42 ++++++++++++++++++++++++++++-------- dlls/dinput/joystick_linux.c | 2 +- dlls/dinput/joystick_linuxinput.c | 2 +- dlls/dinput/joystick_private.h | 2 +- 4 files changed, 35 insertions(+), 13 deletions(-) diff --git a/dlls/dinput/joystick.c b/dlls/dinput/joystick.c index 158e4e0..e0be179 100644 --- a/dlls/dinput/joystick.c +++ b/dlls/dinput/joystick.c @@ -448,7 +448,7 @@ DWORD joystick_map_pov(POINTL *p) * Setup the dinput options. */ -HRESULT setup_dinput_options(JoystickGenericImpl *This) +HRESULT setup_dinput_options(JoystickGenericImpl *This, const BYTE *default_axis_map) { char buffer[MAX_PATH+16]; HKEY hkey, appkey; @@ -540,18 +540,40 @@ HRESULT setup_dinput_options(JoystickGenericImpl *This) } else { - /* No config - set default mapping. */ - for (tokens = 0; tokens < This->device_axis_count; tokens++) + int i; + + if (default_axis_map) { - if (tokens < 8) - This->axis_map[tokens] = axis++; - else if (tokens < 15) + /* Use default mapping from the driver */ + for (i = 0; i < This->device_axis_count; i++) { - This->axis_map[tokens++] = 8 + pov; - This->axis_map[tokens ] = 8 + pov++; + This->axis_map[i] = default_axis_map[i]; + tokens = default_axis_map[i]; + if (tokens >= 0 && tokens < 8) + axis++; + else if (tokens < 15) + { + i++; + pov++; + This->axis_map[i] = default_axis_map[i]; + } + } + } + else + { + /* No config - set default mapping. */ + for (i = 0; i < This->device_axis_count; i++) + { + if (i < 8) + This->axis_map[i] = axis++; + else if (i < 15) + { + This->axis_map[i++] = 8 + pov; + This->axis_map[i ] = 8 + pov++; + } + else + This->axis_map[i] = -1; } - else - This->axis_map[tokens] = -1; } } This->devcaps.dwAxes = axis; diff --git a/dlls/dinput/joystick_linux.c b/dlls/dinput/joystick_linux.c index 6e1988b..764931e 100644 --- a/dlls/dinput/joystick_linux.c +++ b/dlls/dinput/joystick_linux.c @@ -310,7 +310,7 @@ static HRESULT alloc_device(REFGUID rguid, const void *jvt, IDirectInputImpl *di newDevice->generic.deadzone = 0; /* do any user specified configuration */ - hr = setup_dinput_options(&newDevice->generic); + hr = setup_dinput_options(&newDevice->generic, NULL); if (hr != DI_OK) goto FAILED1; diff --git a/dlls/dinput/joystick_linuxinput.c b/dlls/dinput/joystick_linuxinput.c index 1dda212..07524c0 100644 --- a/dlls/dinput/joystick_linuxinput.c +++ b/dlls/dinput/joystick_linuxinput.c @@ -433,7 +433,7 @@ static JoystickImpl *alloc_device(REFGUID rguid, const void *jvt, IDirectInputIm } /* do any user specified configuration */ - if (setup_dinput_options(&newDevice->generic) != DI_OK) goto failed; + if (setup_dinput_options(&newDevice->generic, NULL) != DI_OK) goto failed; /* Create copy of default data format */ if (!(df = HeapAlloc(GetProcessHeap(), 0, c_dfDIJoystick2.dwSize))) goto failed; diff --git a/dlls/dinput/joystick_private.h b/dlls/dinput/joystick_private.h index 577bf5d..027e81a 100644 --- a/dlls/dinput/joystick_private.h +++ b/dlls/dinput/joystick_private.h @@ -53,7 +53,7 @@ typedef struct JoystickGenericImpl } JoystickGenericImpl; LONG joystick_map_axis(ObjProps *props, int val); -HRESULT setup_dinput_options(JoystickGenericImpl *This); +HRESULT setup_dinput_options(JoystickGenericImpl *This, const BYTE *default_axis_map); DWORD joystick_map_pov(POINTL *p);
1
0
0
0
Vitaliy Margolen : dinput: Evdev joystick driver - add ability to remap axis.
by Alexandre Julliard
19 Aug '09
19 Aug '09
Module: wine Branch: master Commit: 167457efc14c84292a9c2d31510b1d7d5fe81a7b URL:
http://source.winehq.org/git/wine.git/?a=commit;h=167457efc14c84292a9c2d315…
Author: Vitaliy Margolen <wine-patches(a)kievinfo.com> Date: Sat Aug 15 11:58:47 2009 -0600 dinput: Evdev joystick driver - add ability to remap axis. --- dlls/dinput/joystick_linuxinput.c | 120 +++++++++++++++++++++---------------- 1 files changed, 68 insertions(+), 52 deletions(-) diff --git a/dlls/dinput/joystick_linuxinput.c b/dlls/dinput/joystick_linuxinput.c index b82c4c7..1dda212 100644 --- a/dlls/dinput/joystick_linuxinput.c +++ b/dlls/dinput/joystick_linuxinput.c @@ -378,9 +378,6 @@ static JoystickImpl *alloc_device(REFGUID rguid, const void *jvt, IDirectInputIm JoystickImpl* newDevice; LPDIDATAFORMAT df = NULL; int i, idx = 0; - char buffer[MAX_PATH+16]; - HKEY hkey, appkey; - LONG def_deadzone = 0; newDevice = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(JoystickImpl)); if (!newDevice) return NULL; @@ -405,57 +402,73 @@ static JoystickImpl *alloc_device(REFGUID rguid, const void *jvt, IDirectInputIm InitializeCriticalSection(&newDevice->generic.base.crit); newDevice->generic.base.crit.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": JoystickImpl*->base.crit"); - /* get options */ - get_app_key(&hkey, &appkey); + /* Count number of available axes - supported Axis & POVs */ + for (i = 0; i < WINE_JOYSTICK_MAX_AXES; i++) + { + if (test_bit(newDevice->joydev->absbits, i)) + { + newDevice->generic.device_axis_count++; + newDevice->dev_axes_to_di[i] = idx; + newDevice->generic.props[idx].lDevMin = newDevice->joydev->axes[i].minimum; + newDevice->generic.props[idx].lDevMax = newDevice->joydev->axes[i].maximum; + idx++; + } + else + newDevice->dev_axes_to_di[i] = -1; + } - if (!get_config_key(hkey, appkey, "DefaultDeadZone", buffer, MAX_PATH)) + for (i = 0; i < WINE_JOYSTICK_MAX_POVS; i++) { - def_deadzone = atoi(buffer); - TRACE("setting default deadzone to: %d\n", def_deadzone); + if (test_bit(newDevice->joydev->absbits, ABS_HAT0X + i * 2) && + test_bit(newDevice->joydev->absbits, ABS_HAT0Y + i * 2)) + { + newDevice->generic.device_axis_count += 2; + newDevice->generic.props[idx].lDevMin = newDevice->joydev->axes[ABS_HAT0X + i * 2].minimum; + newDevice->dev_axes_to_di[ABS_HAT0X + i * 2] = idx++; + newDevice->generic.props[idx].lDevMax = newDevice->joydev->axes[ABS_HAT0Y + i * 2].maximum; + newDevice->dev_axes_to_di[ABS_HAT0Y + i * 2] = idx++; + } + else + newDevice->dev_axes_to_di[ABS_HAT0X + i * 2] = newDevice->dev_axes_to_di[ABS_HAT0Y + i * 2] = -1; } - if (appkey) RegCloseKey(appkey); - if (hkey) RegCloseKey(hkey); + + /* do any user specified configuration */ + if (setup_dinput_options(&newDevice->generic) != DI_OK) goto failed; /* Create copy of default data format */ if (!(df = HeapAlloc(GetProcessHeap(), 0, c_dfDIJoystick2.dwSize))) goto failed; memcpy(df, &c_dfDIJoystick2, c_dfDIJoystick2.dwSize); if (!(df->rgodf = HeapAlloc(GetProcessHeap(), 0, df->dwNumObjs * df->dwObjSize))) goto failed; - /* Supported Axis & POVs should map 1-to-1 */ - for (i = 0; i < WINE_JOYSTICK_MAX_AXES; i++) + + /* Construct internal data format */ + + /* Supported Axis & POVs */ + for (i = 0, idx = 0; i < newDevice->generic.device_axis_count; i++) { - if (!test_bit(newDevice->joydev->absbits, i)) { - newDevice->dev_axes_to_di[i] = -1; - continue; + int wine_obj = newDevice->generic.axis_map[i]; + + if (wine_obj < 0) continue; + + memcpy(&df->rgodf[idx], &c_dfDIJoystick2.rgodf[wine_obj], df->dwObjSize); + if (wine_obj < 8) + df->rgodf[idx].dwType = DIDFT_MAKEINSTANCE(wine_obj) | DIDFT_ABSAXIS; + else + { + df->rgodf[idx].dwType = DIDFT_MAKEINSTANCE(wine_obj - 8) | DIDFT_POV; + i++; /* POV takes 2 axes */ } - memcpy(&df->rgodf[idx], &c_dfDIJoystick2.rgodf[i], df->dwObjSize); - newDevice->dev_axes_to_di[i] = idx; - newDevice->generic.props[idx].lDevMin = newDevice->joydev->axes[i].minimum; - newDevice->generic.props[idx].lDevMax = newDevice->joydev->axes[i].maximum; - newDevice->generic.props[idx].lMin = 0; - newDevice->generic.props[idx].lMax = 0xffff; + newDevice->generic.props[idx].lMin = 0; + newDevice->generic.props[idx].lMax = 0xffff; newDevice->generic.props[idx].lSaturation = 0; - newDevice->generic.props[idx].lDeadZone = def_deadzone; + newDevice->generic.props[idx].lDeadZone = newDevice->generic.deadzone; /* Linux supports force-feedback on X & Y axes only */ if (newDevice->joydev->has_ff && (i == 0 || i == 1)) df->rgodf[idx].dwFlags |= DIDOI_FFACTUATOR; - df->rgodf[idx++].dwType = DIDFT_MAKEINSTANCE(newDevice->generic.devcaps.dwAxes++) | DIDFT_ABSAXIS; - } - - for (i = 0; i < WINE_JOYSTICK_MAX_POVS; i++) - { - if (!test_bit(newDevice->joydev->absbits, ABS_HAT0X + i * 2) || - !test_bit(newDevice->joydev->absbits, ABS_HAT0Y + i * 2)) { - newDevice->dev_axes_to_di[ABS_HAT0X + i * 2] = newDevice->dev_axes_to_di[ABS_HAT0Y + i * 2] = -1; - continue; - } - - memcpy(&df->rgodf[idx], &c_dfDIJoystick2.rgodf[i + WINE_JOYSTICK_MAX_AXES], df->dwObjSize); - newDevice->dev_axes_to_di[ABS_HAT0X + i * 2] = newDevice->dev_axes_to_di[ABS_HAT0Y + i * 2] = i; - df->rgodf[idx++].dwType = DIDFT_MAKEINSTANCE(newDevice->generic.devcaps.dwPOVs++) | DIDFT_POV; + idx++; } /* Buttons can be anywhere, so check all */ @@ -490,6 +503,7 @@ static JoystickImpl *alloc_device(REFGUID rguid, const void *jvt, IDirectInputIm 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; } @@ -752,25 +766,27 @@ static void joy_polldev(JoystickGenericImpl *iface) case EV_ABS: { int axis = This->dev_axes_to_di[ie.code]; - if (axis==-1) { - break; - } - inst_id = DIDFT_MAKEINSTANCE(axis) | (ie.code < ABS_HAT0X ? DIDFT_ABSAXIS : DIDFT_POV); + + /* User axis remapping */ + if (axis < 0) break; + axis = This->generic.axis_map[axis]; + if (axis < 0) break; + + inst_id = DIDFT_MAKEINSTANCE(axis) | (axis < 8 ? DIDFT_ABSAXIS : DIDFT_POV); value = joystick_map_axis(&This->generic.props[id_to_object(This->generic.base.data_format.wine_df, inst_id)], ie.value); - switch (ie.code) { - case ABS_X: This->generic.js.lX = value; break; - case ABS_Y: This->generic.js.lY = value; break; - case ABS_Z: This->generic.js.lZ = value; break; - case ABS_RX: This->generic.js.lRx = value; break; - case ABS_RY: This->generic.js.lRy = value; break; - case ABS_RZ: This->generic.js.lRz = value; break; - case ABS_THROTTLE: This->generic.js.rglSlider[0] = value; break; - case ABS_RUDDER: This->generic.js.rglSlider[1] = value; break; - case ABS_HAT0X: case ABS_HAT0Y: case ABS_HAT1X: case ABS_HAT1Y: - case ABS_HAT2X: case ABS_HAT2Y: case ABS_HAT3X: case ABS_HAT3Y: + switch (axis) { + case 0: This->generic.js.lX = value; break; + case 1: This->generic.js.lY = value; break; + case 2: This->generic.js.lZ = value; break; + case 3: This->generic.js.lRx = value; break; + case 4: This->generic.js.lRy = value; break; + case 5: This->generic.js.lRz = value; break; + case 6: This->generic.js.rglSlider[0] = value; break; + case 7: This->generic.js.rglSlider[1] = value; break; + case 8: case 9: case 10: case 11: { - int idx = (ie.code - ABS_HAT0X) / 2; + int idx = axis - 8; if (ie.code % 2) This->povs[idx].y = ie.value;
1
0
0
0
Vitaliy Margolen : dinput: Rename device axes to direct input axes mapping array to dev_axes_to_di.
by Alexandre Julliard
19 Aug '09
19 Aug '09
Module: wine Branch: master Commit: 3622b2d9261e9843b868c5c92b4489438a8e6e57 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=3622b2d9261e9843b868c5c92…
Author: Vitaliy Margolen <wine-patches(a)kievinfo.com> Date: Sat Aug 15 11:58:43 2009 -0600 dinput: Rename device axes to direct input axes mapping array to dev_axes_to_di. --- dlls/dinput/joystick_linuxinput.c | 16 ++++++++-------- 1 files changed, 8 insertions(+), 8 deletions(-) diff --git a/dlls/dinput/joystick_linuxinput.c b/dlls/dinput/joystick_linuxinput.c index f9f6146..b82c4c7 100644 --- a/dlls/dinput/joystick_linuxinput.c +++ b/dlls/dinput/joystick_linuxinput.c @@ -120,7 +120,7 @@ struct JoystickImpl /* joystick private */ int joyfd; - int axes[ABS_MAX]; + int dev_axes_to_di[ABS_MAX]; POINTL povs[4]; /* LUT for KEY_ to offset in rgbButtons */ @@ -425,12 +425,12 @@ static JoystickImpl *alloc_device(REFGUID rguid, const void *jvt, IDirectInputIm for (i = 0; i < WINE_JOYSTICK_MAX_AXES; i++) { if (!test_bit(newDevice->joydev->absbits, i)) { - newDevice->axes[i] = -1; + newDevice->dev_axes_to_di[i] = -1; continue; } memcpy(&df->rgodf[idx], &c_dfDIJoystick2.rgodf[i], df->dwObjSize); - newDevice->axes[i] = idx; + newDevice->dev_axes_to_di[i] = idx; newDevice->generic.props[idx].lDevMin = newDevice->joydev->axes[i].minimum; newDevice->generic.props[idx].lDevMax = newDevice->joydev->axes[i].maximum; newDevice->generic.props[idx].lMin = 0; @@ -449,12 +449,12 @@ static JoystickImpl *alloc_device(REFGUID rguid, const void *jvt, IDirectInputIm { if (!test_bit(newDevice->joydev->absbits, ABS_HAT0X + i * 2) || !test_bit(newDevice->joydev->absbits, ABS_HAT0Y + i * 2)) { - newDevice->axes[ABS_HAT0X + i * 2] = newDevice->axes[ABS_HAT0Y + i * 2] = -1; + newDevice->dev_axes_to_di[ABS_HAT0X + i * 2] = newDevice->dev_axes_to_di[ABS_HAT0Y + i * 2] = -1; continue; } memcpy(&df->rgodf[idx], &c_dfDIJoystick2.rgodf[i + WINE_JOYSTICK_MAX_AXES], df->dwObjSize); - newDevice->axes[ABS_HAT0X + i * 2] = newDevice->axes[ABS_HAT0Y + i * 2] = i; + newDevice->dev_axes_to_di[ABS_HAT0X + i * 2] = newDevice->dev_axes_to_di[ABS_HAT0Y + i * 2] = i; df->rgodf[idx++].dwType = DIDFT_MAKEINSTANCE(newDevice->generic.devcaps.dwPOVs++) | DIDFT_POV; } @@ -687,8 +687,8 @@ static HRESULT WINAPI JoystickAImpl_Unacquire(LPDIRECTINPUTDEVICE8A iface) * values on the axes */ #define CENTER_AXIS(a) \ - (ji->axes[a] == -1 ? 0 : joystick_map_axis( &ji->generic.props[ji->axes[a]], \ - ji->joydev->axes[a].value )) + (ji->dev_axes_to_di[a] == -1 ? 0 : joystick_map_axis( &ji->generic.props[ji->dev_axes_to_di[a]], \ + ji->joydev->axes[a].value )) static void fake_current_js_state(JoystickImpl *ji) { int i; @@ -751,7 +751,7 @@ static void joy_polldev(JoystickGenericImpl *iface) } case EV_ABS: { - int axis = This->axes[ie.code]; + int axis = This->dev_axes_to_di[ie.code]; if (axis==-1) { break; }
1
0
0
0
Vitaliy Margolen : dinput: Move setup_dinput_options into common place.
by Alexandre Julliard
19 Aug '09
19 Aug '09
Module: wine Branch: master Commit: 083d6e8474487484bf50b58e0a2f52f1235a8666 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=083d6e8474487484bf50b58e0…
Author: Vitaliy Margolen <wine-patches(a)kievinfo.com> Date: Sat Aug 15 11:58:39 2009 -0600 dinput: Move setup_dinput_options into common place. --- dlls/dinput/joystick.c | 120 ++++++++++++++++++++++++++++++++++++++++ dlls/dinput/joystick_linux.c | 118 +--------------------------------------- dlls/dinput/joystick_private.h | 1 + 3 files changed, 122 insertions(+), 117 deletions(-) diff --git a/dlls/dinput/joystick.c b/dlls/dinput/joystick.c index d57ef7b..158e4e0 100644 --- a/dlls/dinput/joystick.c +++ b/dlls/dinput/joystick.c @@ -28,6 +28,7 @@ #include "joystick_private.h" #include "wine/debug.h" +#include "winreg.h" WINE_DEFAULT_DEBUG_CHANNEL(dinput); @@ -442,3 +443,122 @@ DWORD joystick_map_pov(POINTL *p) else return p->y < 0 ? 0 : !p->y ? -1 : 18000; } + +/* + * Setup the dinput options. + */ + +HRESULT setup_dinput_options(JoystickGenericImpl *This) +{ + char buffer[MAX_PATH+16]; + HKEY hkey, appkey; + int tokens = 0; + int axis = 0; + int pov = 0; + + get_app_key(&hkey, &appkey); + + /* get options */ + + if (!get_config_key(hkey, appkey, "DefaultDeadZone", buffer, sizeof(buffer))) + { + This->deadzone = atoi(buffer); + TRACE("setting default deadzone to: \"%s\" %d\n", buffer, This->deadzone); + } + + This->axis_map = HeapAlloc(GetProcessHeap(), 0, This->device_axis_count * sizeof(int)); + if (!This->axis_map) return DIERR_OUTOFMEMORY; + + if (!get_config_key(hkey, appkey, This->name, buffer, sizeof(buffer))) + { + static const char *axis_names[] = {"X", "Y", "Z", "Rx", "Ry", "Rz", + "Slider1", "Slider2", + "POV1", "POV2", "POV3", "POV4"}; + const char *delim = ","; + char * ptr; + TRACE("\"%s\" = \"%s\"\n", This->name, buffer); + + if ((ptr = strtok(buffer, delim)) != NULL) + { + do + { + int i; + + for (i = 0; i < sizeof(axis_names) / sizeof(axis_names[0]); i++) + { + if (!strcmp(ptr, axis_names[i])) + { + if (!strncmp(ptr, "POV", 3)) + { + if (pov >= 4) + { + WARN("Only 4 POVs supported - ignoring extra\n"); + i = -1; + } + else + { + /* Pov takes two axes */ + This->axis_map[tokens++] = i; + pov++; + } + } + else + { + if (axis >= 8) + { + FIXME("Only 8 Axes supported - ignoring extra\n"); + i = -1; + } + else + axis++; + } + break; + } + } + + if (i == sizeof(axis_names) / sizeof(axis_names[0])) + { + ERR("invalid joystick axis type: \"%s\"\n", ptr); + i = -1; + } + + This->axis_map[tokens] = i; + tokens++; + } while ((ptr = strtok(NULL, delim)) != NULL); + + if (tokens != This->device_axis_count) + { + ERR("not all joystick axes mapped: %d axes(%d,%d), %d arguments\n", + This->device_axis_count, axis, pov, tokens); + while (tokens < This->device_axis_count) + { + This->axis_map[tokens] = -1; + tokens++; + } + } + } + } + else + { + /* No config - set default mapping. */ + for (tokens = 0; tokens < This->device_axis_count; tokens++) + { + if (tokens < 8) + This->axis_map[tokens] = axis++; + else if (tokens < 15) + { + This->axis_map[tokens++] = 8 + pov; + This->axis_map[tokens ] = 8 + pov++; + } + else + This->axis_map[tokens] = -1; + } + } + This->devcaps.dwAxes = axis; + This->devcaps.dwPOVs = pov; + + if (appkey) RegCloseKey(appkey); + if (hkey) RegCloseKey(hkey); + + return DI_OK; +} diff --git a/dlls/dinput/joystick_linux.c b/dlls/dinput/joystick_linux.c index 3a9da88..6e1988b 100644 --- a/dlls/dinput/joystick_linux.c +++ b/dlls/dinput/joystick_linux.c @@ -62,7 +62,6 @@ #include "windef.h" #include "winbase.h" #include "winerror.h" -#include "winreg.h" #include "dinput.h" #include "dinput_private.h" @@ -235,121 +234,6 @@ static BOOL joydev_enum_deviceW(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTAN return FALSE; } -/* - * Setup the dinput options. - */ - -static HRESULT setup_dinput_options(JoystickImpl * device) -{ - char buffer[MAX_PATH+16]; - HKEY hkey, appkey; - int tokens = 0; - int axis = 0; - int pov = 0; - - buffer[MAX_PATH]='\0'; - - get_app_key(&hkey, &appkey); - - /* get options */ - - if (!get_config_key( hkey, appkey, "DefaultDeadZone", buffer, MAX_PATH )) { - device->generic.deadzone = atoi(buffer); - TRACE("setting default deadzone to: \"%s\" %d\n", buffer, device->generic.deadzone); - } - - device->generic.axis_map = HeapAlloc(GetProcessHeap(), 0, device->generic.device_axis_count * sizeof(int)); - if (!device->generic.axis_map) return DIERR_OUTOFMEMORY; - - if (!get_config_key( hkey, appkey, device->generic.name, buffer, MAX_PATH )) { - static const char *axis_names[] = {"X", "Y", "Z", "Rx", "Ry", "Rz", - "Slider1", "Slider2", - "POV1", "POV2", "POV3", "POV4"}; - const char *delim = ","; - char * ptr; - TRACE("\"%s\" = \"%s\"\n", device->generic.name, buffer); - - if ((ptr = strtok(buffer, delim)) != NULL) { - do { - int i; - - for (i = 0; i < sizeof(axis_names) / sizeof(axis_names[0]); i++) - if (!strcmp(ptr, axis_names[i])) - { - if (!strncmp(ptr, "POV", 3)) - { - if (pov >= 4) - { - WARN("Only 4 POVs supported - ignoring extra\n"); - i = -1; - } - else - { - /* Pov takes two axes */ - device->generic.axis_map[tokens++] = i; - pov++; - } - } - else - { - if (axis >= 8) - { - FIXME("Only 8 Axes supported - ignoring extra\n"); - i = -1; - } - else - axis++; - } - break; - } - - if (i == sizeof(axis_names) / sizeof(axis_names[0])) - { - ERR("invalid joystick axis type: \"%s\"\n", ptr); - i = -1; - } - - device->generic.axis_map[tokens] = i; - tokens++; - } while ((ptr = strtok(NULL, delim)) != NULL); - - if (tokens != device->generic.device_axis_count) { - ERR("not all joystick axes mapped: %d axes(%d,%d), %d arguments\n", - device->generic.device_axis_count, axis, pov,tokens); - while (tokens < device->generic.device_axis_count) { - device->generic.axis_map[tokens] = -1; - tokens++; - } - } - } - } - else - { - for (tokens = 0; tokens < device->generic.device_axis_count; tokens++) - { - if (tokens < 8) - device->generic.axis_map[tokens] = axis++; - else if (tokens < 16) - { - device->generic.axis_map[tokens++] = 8 + pov; - device->generic.axis_map[tokens ] = 8 + pov++; - } - else - device->generic.axis_map[tokens] = -1; - } - } - device->generic.devcaps.dwAxes = axis; - device->generic.devcaps.dwPOVs = pov; - - if (appkey) - RegCloseKey( appkey ); - - if (hkey) - RegCloseKey( hkey ); - - return DI_OK; -} - static HRESULT alloc_device(REFGUID rguid, const void *jvt, IDirectInputImpl *dinput, LPDIRECTINPUTDEVICEA* pdev, unsigned short index) { @@ -426,7 +310,7 @@ static HRESULT alloc_device(REFGUID rguid, const void *jvt, IDirectInputImpl *di newDevice->generic.deadzone = 0; /* do any user specified configuration */ - hr = setup_dinput_options(newDevice); + hr = setup_dinput_options(&newDevice->generic); if (hr != DI_OK) goto FAILED1; diff --git a/dlls/dinput/joystick_private.h b/dlls/dinput/joystick_private.h index 494193b..577bf5d 100644 --- a/dlls/dinput/joystick_private.h +++ b/dlls/dinput/joystick_private.h @@ -53,6 +53,7 @@ typedef struct JoystickGenericImpl } JoystickGenericImpl; LONG joystick_map_axis(ObjProps *props, int val); +HRESULT setup_dinput_options(JoystickGenericImpl *This); DWORD joystick_map_pov(POINTL *p);
1
0
0
0
Vitaliy Margolen : dinput: Move axes count into base joystick class.
by Alexandre Julliard
19 Aug '09
19 Aug '09
Module: wine Branch: master Commit: 1362d15060449d6f7e8b44022da6a7775ca7ed6b URL:
http://source.winehq.org/git/wine.git/?a=commit;h=1362d15060449d6f7e8b44022…
Author: Vitaliy Margolen <wine-patches(a)kievinfo.com> Date: Sat Aug 15 11:58:34 2009 -0600 dinput: Move axes count into base joystick class. --- dlls/dinput/joystick_linux.c | 20 ++++++++++---------- dlls/dinput/joystick_private.h | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/dlls/dinput/joystick_linux.c b/dlls/dinput/joystick_linux.c index 0f9a691..3a9da88 100644 --- a/dlls/dinput/joystick_linux.c +++ b/dlls/dinput/joystick_linux.c @@ -87,7 +87,6 @@ struct JoystickImpl /* joystick private */ int joyfd; - int axes; POINTL povs[4]; }; @@ -259,7 +258,7 @@ static HRESULT setup_dinput_options(JoystickImpl * device) TRACE("setting default deadzone to: \"%s\" %d\n", buffer, device->generic.deadzone); } - device->generic.axis_map = HeapAlloc(GetProcessHeap(), 0, device->axes * sizeof(int)); + device->generic.axis_map = HeapAlloc(GetProcessHeap(), 0, device->generic.device_axis_count * sizeof(int)); if (!device->generic.axis_map) return DIERR_OUTOFMEMORY; if (!get_config_key( hkey, appkey, device->generic.name, buffer, MAX_PATH )) { @@ -314,9 +313,10 @@ static HRESULT setup_dinput_options(JoystickImpl * device) tokens++; } while ((ptr = strtok(NULL, delim)) != NULL); - if (tokens != device->axes) { - ERR("not all joystick axes mapped: %d axes(%d,%d), %d arguments\n", device->axes, axis, pov,tokens); - while (tokens < device->axes) { + if (tokens != device->generic.device_axis_count) { + ERR("not all joystick axes mapped: %d axes(%d,%d), %d arguments\n", + device->generic.device_axis_count, axis, pov,tokens); + while (tokens < device->generic.device_axis_count) { device->generic.axis_map[tokens] = -1; tokens++; } @@ -325,7 +325,7 @@ static HRESULT setup_dinput_options(JoystickImpl * device) } else { - for (tokens = 0; tokens < device->axes; tokens++) + for (tokens = 0; tokens < device->generic.device_axis_count; tokens++) { if (tokens < 8) device->generic.axis_map[tokens] = axis++; @@ -397,9 +397,9 @@ static HRESULT alloc_device(REFGUID rguid, const void *jvt, IDirectInputImpl *di strcpy(newDevice->generic.name, name); #ifdef JSIOCGAXES - if (ioctl(newDevice->joyfd,JSIOCGAXES,&newDevice->axes) < 0) { + if (ioctl(newDevice->joyfd, JSIOCGAXES, &newDevice->generic.device_axis_count) < 0) { WARN("ioctl(%s,JSIOCGAXES) failed: %s, defauting to 2\n", newDevice->dev, strerror(errno)); - newDevice->axes = 2; + newDevice->generic.device_axis_count = 2; } #endif #ifdef JSIOCGBUTTONS @@ -437,7 +437,7 @@ static HRESULT alloc_device(REFGUID rguid, const void *jvt, IDirectInputImpl *di df->dwNumObjs = newDevice->generic.devcaps.dwAxes + newDevice->generic.devcaps.dwPOVs + newDevice->generic.devcaps.dwButtons; if (!(df->rgodf = HeapAlloc(GetProcessHeap(), 0, df->dwNumObjs * df->dwObjSize))) goto FAILED; - for (i = 0; i < newDevice->axes; i++) + for (i = 0; i < newDevice->generic.device_axis_count; i++) { int wine_obj = newDevice->generic.axis_map[i]; @@ -486,7 +486,7 @@ static HRESULT alloc_device(REFGUID rguid, const void *jvt, IDirectInputImpl *di if (TRACE_ON(dinput)) { _dump_DIDATAFORMAT(newDevice->generic.base.data_format.wine_df); - for (i = 0; i < (newDevice->axes); i++) + for (i = 0; i < (newDevice->generic.device_axis_count); i++) TRACE("axis_map[%d] = %d\n", i, newDevice->generic.axis_map[i]); _dump_DIDEVCAPS(&newDevice->generic.devcaps); } diff --git a/dlls/dinput/joystick_private.h b/dlls/dinput/joystick_private.h index 18e03e6..494193b 100644 --- a/dlls/dinput/joystick_private.h +++ b/dlls/dinput/joystick_private.h @@ -45,7 +45,7 @@ typedef struct JoystickGenericImpl GUID guidProduct; GUID guidInstance; char *name; - + int device_axis_count; /* Total number of axes in the device */ int *axis_map; /* User axes remapping */ LONG deadzone; /* Default dead-zone */
1
0
0
0
← Newer
1
...
41
42
43
44
45
46
47
...
105
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
Results per page:
10
25
50
100
200