<div dir="ltr"><div dir="ltr">Thank you very much for all the tips. They were great. I will rework my patch according to your directions, it will take probably a few days or weeks though.<br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, May 18, 2020 at 2:52 PM Andrew Eikum <<a href="mailto:aeikum@codeweavers.com">aeikum@codeweavers.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hey Cláudio,<br>
<br>
Thanks for working on this. I think you're on the right track. I have<br>
some thoughts below.<br>
<br>
On Sun, May 17, 2020 at 12:24:07PM +0200, Cláudio Sampaio wrote:<br>
> Hi all, I am a heavy user of wine and proton for games and for some time<br>
> the failures some games had with my HOTAS (Hands On Throttle-And-Stick)<br>
> have been bothering me. I tried to take a look at wine code and found out<br>
> that the maximum numbers of buttons for a single device was hardwired to 32<br>
> and the maximum number of analog axes was hardwired to 4 pairs (8 axes). My<br>
> own HOTAS, a very common Logitech X52 Pro, has a bigger number of buttons<br>
> -- 39, so the higher buttons would "carry over" to register like they were<br>
> lower buttons -- and this prevented it from working on games. I increased<br>
> these hardwired numbers to 64 and 8 respectively, and the patch seems to<br>
> have largely worked on all games I used it -- for example, I am only able<br>
> to play Elite: Dangerous with my patched proton version.<br>
> <br>
<br>
Maybe you know this, but one thing to be careful of when working with<br>
both Proton and upstream is that Proton uses an SDL backend for dinput<br>
which is not in upstream Wine. If you're working in upstream, you'll<br>
be using the Linux input API backend. If you're making changes in<br>
dinput (see below), you'll likely need to implement your fix in both<br>
places, once in joystick_linux.c for upstream, and again in<br>
joystick_sdl.c for Proton.<br>
<br>
(The correct fix for this is to implement dinput on top of hidapi, but<br>
that's a whole huge task in itself.)<br>
<br>
> However, there have been some problems, like a few sliders not working --<br>
> slider 7 (you could check the numbering of axes with a program like<br>
> antimicro on Linux) does not seem to register in Star Citizen, for example.<br>
> I noticed from joystick.c that the analog axes seem to have specific names<br>
> and functionality, like DIJOFS_RX and DIJOFS_SLIDER, and if I understood<br>
> what's going on, it might prevent the code to work generally with obscure<br>
> devices that have a couple number of sliders, is that correct? How could I<br>
> get the code to recognize and translate my axes to games?<br>
> <br>
<br>
Dinput has a concept of "data formats", which map hardware values<br>
(axis N) to logical values (left joystick X position). The most<br>
commonly used format is called "dfDIJoystick2", which you can find in<br>
<dlls/dinput/data_formats.c>. Unfortunately this gets super<br>
complicated and Wine's support here isn't great. Notice that it has 6<br>
axes and 2 sliders up at the top, and then a bunch more down at the<br>
bottom.c.  A lot of the Wine handling for data formats assumes that<br>
we'll only be using those top few items, for example see the axis<br>
handling in <dlls/dinput/joystick_linux.c:alloc_device>. I think these<br>
will need to be corrected to use the correct data formats for these<br>
extra axes.<br>
<br>
You're right that there's likely more assumptions like that made<br>
elsewhere in dinput. The code there is very old and not the best<br>
quality.<br>
<br>
> Also, for this patch to be complete I will also need to change the GUI for<br>
> testing joystick via "wine control", and I do not have much experience with<br>
> Windows programming. Any help would be welcome.<br>
> <br>
<br>
This would be nice, but I don't think it's a requirement to fix the<br>
problem in upstream.<br>
<br>
Some further comments on your patch follow...<br>
<br>
> I have also described the problem on this forum post:<br>
> <a href="https://forum.winehq.org/viewtopic.php?f=2&t=33615&p=126895#p126895" rel="noreferrer" target="_blank">https://forum.winehq.org/viewtopic.php?f=2&t=33615&p=126895#p126895</a><br>
> And the bug report for it at <a href="https://bugs.winehq.org/show_bug.cgi?id=48799" rel="noreferrer" target="_blank">https://bugs.winehq.org/show_bug.cgi?id=48799</a><br>
> And I have also talked about it on gamingonlinux:<br>
> <a href="https://www.gamingonlinux.com/forum/topic/4330" rel="noreferrer" target="_blank">https://www.gamingonlinux.com/forum/topic/4330</a><br>
> <br>
> This patch has around 50 to 60 hours of testing.<br>
> -- <br>
> Cláudio "Patola" Sampaio<br>
> MakerLinux Labs - Campinas, SP<br>
> Resume <<a href="https://github.com/Patola/resume" rel="noreferrer" target="_blank">https://github.com/Patola/resume</a>> Gmail <<a href="mailto:patola@gmail.com" target="_blank">patola@gmail.com</a>> -<br>
> MakerLinux <<a href="mailto:patola@makerlinux.com.br" target="_blank">patola@makerlinux.com.br</a>> - YOUTUBE<br>
> <<a href="https://www.youtube.com/user/makerlinux" rel="noreferrer" target="_blank">https://www.youtube.com/user/makerlinux</a>>!<br>
> Facebook <<a href="https://www.facebook.com/patolinux" rel="noreferrer" target="_blank">https://www.facebook.com/patolinux</a>> - Facebook da MakerLinux<br>
> <<a href="https://www.facebook.com/makerlinux" rel="noreferrer" target="_blank">https://www.facebook.com/makerlinux</a>> - Lattes<br>
> <<a href="http://buscatextual.cnpq.br/buscatextual/visualizacv.do?id=K4763932Z5" rel="noreferrer" target="_blank">http://buscatextual.cnpq.br/buscatextual/visualizacv.do?id=K4763932Z5</a>><br>
<br>
> diff --git a/dlls/joy.cpl/joy.h b/dlls/joy.cpl/joy.h<br>
> index ec7af4f787..672e8995e1 100644<br>
> --- a/dlls/joy.cpl/joy.h<br>
> +++ b/dlls/joy.cpl/joy.h<br>
> @@ -47,8 +47,8 @@ struct Joystick {<br>
>      struct Effect *effects;<br>
>  };<br>
>  <br>
> -#define TEST_MAX_BUTTONS    32<br>
> -#define TEST_MAX_AXES       4<br>
> +#define TEST_MAX_BUTTONS    64<br>
> +#define TEST_MAX_AXES       8<br>
>  <br>
>  struct Graphics {<br>
>      HWND hwnd;<br>
> diff --git a/dlls/joy.cpl/main.c b/dlls/joy.cpl/main.c<br>
> index 4ad9cf848c..35dba75978 100644<br>
> --- a/dlls/joy.cpl/main.c<br>
> +++ b/dlls/joy.cpl/main.c<br>
> @@ -414,6 +414,16 @@ static DWORD WINAPI input_thread(void *param)<br>
>          axes_pos[1][1] = state.lRy;<br>
>          axes_pos[2][0] = state.lZ;<br>
>          axes_pos[2][1] = state.lRz;<br>
> +     axes_pos[3][0] = 0;<br>
> +     axes_pos[3][1] = 0;<br>
> +     axes_pos[4][0] = 0;<br>
> +     axes_pos[4][1] = 0;<br>
> +     axes_pos[5][0] = 0;<br>
> +     axes_pos[5][1] = 0;<br>
> +     axes_pos[6][0] = 0;<br>
> +     axes_pos[6][1] = 0;<br>
> +     axes_pos[7][0] = 0;<br>
> +     axes_pos[7][1] = 0;<br>
>  <br>
<br>
Small point here, since this is an RFC patch, but in general be<br>
careful about tabs vs spaces and following nearby formatting.<br>
<br>
>          /* Set pov values */<br>
>          for (j = 0; j < ARRAY_SIZE(pov_val); j++)<br>
> diff --git a/dlls/winebus.sys/bus_sdl.c b/dlls/winebus.sys/bus_sdl.c<br>
> index 0560e4bb12..13d3377b03 100644<br>
> --- a/dlls/winebus.sys/bus_sdl.c<br>
> +++ b/dlls/winebus.sys/bus_sdl.c<br>
> @@ -402,10 +402,10 @@ static BOOL build_report_descriptor(struct platform_private *ext)<br>
>      report_size = 0;<br>
>  <br>
>      axis_count = pSDL_JoystickNumAxes(ext->sdl_joystick);<br>
> -    if (axis_count > 6)<br>
> +    if (axis_count > 16)<br>
>      {<br>
> -        FIXME("Clamping joystick to 6 axis\n");<br>
> -        axis_count = 6;<br>
> +        FIXME("Clamping joystick to 16 axis\n");<br>
> +        axis_count = 16;<br>
>      }<br>
>  <br>
>      ext->axis_start = report_size;<br>
> @@ -421,9 +421,9 @@ static BOOL build_report_descriptor(struct platform_private *ext)<br>
>      ext->ball_start = report_size;<br>
>      if (ball_count)<br>
>      {<br>
> -        if ((ball_count*2) + axis_count > 9)<br>
> +        if ((ball_count*2) + axis_count > 19)<br>
>          {<br>
> -            FIXME("Capping ball + axis at 9\n");<br>
> +            FIXME("Capping ball + axis at 19\n");<br>
>              ball_count = (9-axis_count)/2;<br>
>          }<br>
>          descript_size += sizeof(REPORT_AXIS_HEADER);<br>
<br>
These are clamped to those values because they access the<br>
joystick_usages array, which is only 9 members long. Increasing those<br>
without changing that array usage will cause invalid accesses.<br>
Probably it should be rewritten not to use a hard-coded array, or<br>
generate useful values past the array.<br>
<br>
> diff --git a/dlls/winejoystick.drv/joystick_linux.c b/dlls/winejoystick.drv/joystick_linux.c<br>
> index 8d1a7b1a25..e579d99aa7 100644<br>
> --- a/dlls/winejoystick.drv/joystick_linux.c<br>
> +++ b/dlls/winejoystick.drv/joystick_linux.c<br>
<br>
These driver files are only used by the winmm joystick driver, which<br>
is probably not relevant to your problem.<br>
<br>
> @@ -260,9 +260,9 @@ LRESULT driver_joyGetDevCaps(DWORD_PTR dwDevID, LPJOYCAPSW lpCaps, DWORD dwSize)<br>
>       lpCaps->wUmax = 0xFFFF;<br>
>       lpCaps->wVmin = 0;<br>
>       lpCaps->wVmax = 0xFFFF;<br>
> -     lpCaps->wMaxAxes = 6; /* same as MS Joystick Driver */<br>
> +     lpCaps->wMaxAxes = 16; /* same as MS Joystick Driver */<br>
>       lpCaps->wNumAxes = 0; /* nr of axes in use */<br>
> -     lpCaps->wMaxButtons = 32; /* same as MS Joystick Driver */<br>
> +     lpCaps->wMaxButtons = 64; /* same as MS Joystick Driver */<br>
>       lpCaps->szRegKey[0] = 0;<br>
>       lpCaps->szOEMVxD[0] = 0;<br>
>       lpCaps->wCaps = 0;<br>
> @@ -326,6 +326,7 @@ LRESULT driver_joyGetPosEx(DWORD_PTR dwDevID, LPJOYINFOEX lpInfo)<br>
>           switch (jstck->axesMap[ev.number]) {<br>
>           case 0: /* X */<br>
>           case 8: /* Wheel */<br>
> +            case 40: /* Mouse-like */<br>
>               jstck->x = ev.value;<br>
>               break;<br>
>           case 1: /* Y */<br>
<br>
Andrew<br>
</blockquote></div><br clear="all"><br>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div>Cláudio "Patola" Sampaio<br>MakerLinux Labs - Campinas, SP</div><div><a href="https://github.com/Patola/resume" target="_blank">Resume</a> <a href="mailto:patola@gmail.com" target="_blank">Gmail</a> - <a href="mailto:patola@makerlinux.com.br" target="_blank">MakerLinux</a> - <a href="https://www.youtube.com/user/makerlinux" target="_blank">YOUTUBE</a>!<br><a href="https://www.facebook.com/patolinux" target="_blank">Facebook</a> - <a href="https://www.facebook.com/makerlinux" target="_blank">Facebook da MakerLinux</a> -<a href="http://buscatextual.cnpq.br/buscatextual/visualizacv.do?id=K4763932Z5" target="_blank"> Lattes</a><br><br></div></div></div></div></div></div></div></div></div></div>