http://bugs.winehq.org/show_bug.cgi?id=29366
Bug #: 29366 Summary: GTAIV native trainer doesn't catch some key presses Product: Wine Version: 1.3.35 Platform: x86 OS/Version: Linux Status: UNCONFIRMED Severity: normal Priority: P2 Component: user32 AssignedTo: wine-bugs@winehq.org ReportedBy: b7.10110111@gmail.com CC: julliard@winehq.org Classification: Unclassified Regression SHA1: cb3b7237925a24ba4c5696dd079fdc5d99a48577
Before this regression, keys like =_;] <ctrl>+F1 F3 and some others worked with GTAIV Native Trainer. After it, neither of =_;] work. Only Ctrl+F1 and F3 of this set do. So, results of regression testing:
cb3b7237925a24ba4c5696dd079fdc5d99a48577 is the first bad commit commit cb3b7237925a24ba4c5696dd079fdc5d99a48577 Author: Alexandre Julliard julliard@winehq.org Date: Thu Dec 15 14:30:41 2011 +0100
user32: Cache the global key state to avoid performance issues in applications that poll constantly.
:040000 040000 6fc9980517e631c9e7145313c1634713a36b11f4 dbc782b9be4295845ba663e5830b8114a67b290c M dlls
http://bugs.winehq.org/show_bug.cgi?id=29366
Ruslan b7.10110111@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Keywords| |regression
http://bugs.winehq.org/show_bug.cgi?id=29366
--- Comment #1 from Alexandre Julliard julliard@winehq.org 2011-12-17 14:05:37 CST --- Is there a demo that shows the problem?
http://bugs.winehq.org/show_bug.cgi?id=29366
--- Comment #2 from Ruslan b7.10110111@gmail.com 2011-12-17 14:11:46 CST --- (In reply to comment #1)
Is there a demo that shows the problem?
I'm afraid no. I check it on full install of GTAIV (version 1.0.3) with Native Trainer. (I might transfer a tarball of full game install to some server if you could provide storage space of about 16G).
http://bugs.winehq.org/show_bug.cgi?id=29366
--- Comment #3 from Ruslan b7.10110111@gmail.com 2012-01-13 17:20:36 CST --- New info: it appears that the button presses *are* catched, but only after several minutes passes since I press them. At least this is true as of wine-1.3.37.
http://bugs.winehq.org/show_bug.cgi?id=29366
--- Comment #4 from Ruslan b7.10110111@gmail.com 2012-01-13 18:33:40 CST --- OK, after some experiments it appeared that the trainer waits for 0th bit set for all these non-working keys. So, this line in GetAsyncKeyState(): return (thread_info->key_state[key] & 0x80) ? 0x8000 : 0; never gives the value it wants (i.e. 0x8001), no matter whether the user has pressed the key after last call to GetAsyncKeyState() or not. If I change the code to return 0x8001, then the keys work, and also one of the trainer features which didn't work in Wine before starts to work (Fast Run). Though, it seems to work *too* fast than I have seen it in windows, but this might be because of higher frame rate on this machine.
So, what about changing 0x8000 to 0x8001? Another solution would be to truely check if the key has been pressed between function calls.
http://bugs.winehq.org/show_bug.cgi?id=29366
--- Comment #5 from Alexandre Julliard julliard@winehq.org 2012-01-14 03:03:01 CST --- Created attachment 38345 --> http://bugs.winehq.org/attachment.cgi?id=38345 Return more flags
I suppose we could try something like this.
http://bugs.winehq.org/show_bug.cgi?id=29366
--- Comment #6 from Ruslan b7.10110111@gmail.com 2012-01-14 05:23:18 CST --- Created attachment 38350 --> http://bugs.winehq.org/attachment.cgi?id=38350 Return more flags, fixed return value
I've changed your patch a bit, so that the function didn't always return 0xffff. But it still doesn't work as it should. After I press a button (';', for example), the trainer gets return value 0x1 regularly even if I don't press it anymore. I'll add a test prog in the next comment.
http://bugs.winehq.org/show_bug.cgi?id=29366
--- Comment #7 from Ruslan b7.10110111@gmail.com 2012-01-14 05:27:30 CST --- Created attachment 38351 --> http://bugs.winehq.org/attachment.cgi?id=38351 Test program
Here's the test program. Apply the new patch, then run this program in virtual desktop (I compiled it with mingw, since I don't know how to use virtual desktop with winelib apps), press and release ';' key. See repeating 0x1 return value. This is just what the trainer sees with the patch.
http://bugs.winehq.org/show_bug.cgi?id=29366
--- Comment #8 from Alexandre Julliard julliard@winehq.org 2012-01-14 10:12:12 CST --- Created attachment 38354 --> http://bugs.winehq.org/attachment.cgi?id=38354 Clear key state
Probably it should be cleared on the server side, something like this.
http://bugs.winehq.org/show_bug.cgi?id=29366
--- Comment #9 from Ruslan b7.10110111@gmail.com 2012-01-14 12:26:59 CST --- This patch makes it work better, but autorepeat presses with 0th bit set are not reported to trainer (i.e. when you press a key and hold it). Also, if I press the button too frequently, it appears to not be returned as been pressed. The strange thing is that the test program does get autorepeat presses as expected, but the trainer doesn't.
One of the differences between how trainer gets presses and the test program is that trainer always gets them via if(thread_info->key_state) logic, and the test program gets some of the keys via if part, and others via else.
http://bugs.winehq.org/show_bug.cgi?id=29366
--- Comment #10 from Alexandre Julliard julliard@winehq.org 2012-01-17 06:24:59 CST --- Created attachment 38395 --> http://bugs.winehq.org/attachment.cgi?id=38395 Merge key states
Does this work better?
http://bugs.winehq.org/show_bug.cgi?id=29366
--- Comment #11 from Ruslan b7.10110111@gmail.com 2012-01-17 07:09:51 CST --- (In reply to comment #10)
Does this work better?
No, this doesn't improve things, and sometimes returns false presses to trainer (but again, invisible in test prog). (BTW, for some reason the patch didn't want to apply cleanly, I had to apply a hunk in input.c manually).
http://bugs.winehq.org/show_bug.cgi?id=29366
--- Comment #12 from Alexandre Julliard julliard@winehq.org 2012-01-17 07:31:41 CST --- The patch should apply cleanly to current git. Make sure you have removed the previous changes first.
http://bugs.winehq.org/show_bug.cgi?id=29366
--- Comment #13 from Ruslan b7.10110111@gmail.com 2012-01-17 08:33:49 CST --- Right, it was because I copy-pasted the patch and this converted tabs to spaces. Now it applies cleanly, but still I get several false key presses when I start the game, and all of these originate from the last 'return ret' in GetAsyncKeyState() (return value is 0x1). Anyway, this patch doesn't make it any better than the previous one.
http://bugs.winehq.org/show_bug.cgi?id=29366
--- Comment #14 from Alexandre Julliard julliard@winehq.org 2012-01-17 09:20:21 CST --- Created attachment 38397 --> http://bugs.winehq.org/attachment.cgi?id=38397 Yet another attempt
And this one?
http://bugs.winehq.org/show_bug.cgi?id=29366
--- Comment #15 from Ruslan b7.10110111@gmail.com 2012-01-17 09:38:46 CST --- (In reply to comment #14) Yeah, now it works as it did before the regression.
http://bugs.winehq.org/show_bug.cgi?id=29366
Alexandre Julliard julliard@winehq.org changed:
What |Removed |Added ---------------------------------------------------------------------------- Fixed by SHA1| |adad80f4bd4aba325549ad8747a | |2951e97209660 Status|UNCONFIRMED |RESOLVED Resolution| |FIXED
--- Comment #16 from Alexandre Julliard julliard@winehq.org 2012-01-17 13:46:17 CST --- Fixed then, thanks for your help!
http://bugs.winehq.org/show_bug.cgi?id=29366
Alexandre Julliard julliard@winehq.org changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |CLOSED
--- Comment #17 from Alexandre Julliard julliard@winehq.org 2012-01-27 14:16:34 CST --- Closing bugs fixed in 1.4-rc1.