View Single Post
Old November 21st, 2007   #112 (permalink)
ChickenLiver
Plugin author
 
Join Date: Apr 2006
Location: Perdition
Posts: 557
It's a threading issue. I capture the mouse and hide the cursor in the thread that calls PADopen() as this is where pads are supposed to initialize input. The other thread is the GS thread and has control of the window, however. Running in single threaded mode and it works fine. Apparently ShowCursor(0) only affects windows owned by the currently running thread. (Note - could be wrong about this, but this is what seems to be the issue, as I both hide the cursor and set it to be a completely transparent image, and perfectly explains all behavior I've observed, like working in single threaded mode)

The work around is to bind a key to the "mouse" button using Windows messaging or raw keyboard input mode. Then either press it twice whenever you start PCSX2 running or check "start without mouse focus" and press it once, so mouse initialization occurs in the GS Window's thread (DirectInput key presses are handled in the primary thread).

Alternatively, modify GSopen() in GSDX to call ShowCursor(0) like ZeroGS does. Or modify PCSX2 to call PADopen() in the GS thread. In the latter case, however, changing mouse input modes while pausing emulation could cause issues. I'd really class this issue as a PCSX2 MTGS bug/oversight.

There are a number of complete workarounds I could manage, but I consider all of them to be pretty hackish, and don't like them (Always subclass the GS's window and check for initialization every message - but I like to keep the option of not monitoring input from the GS window open. Alternatively, I could just blindly hide the cursor whenever a new thread is started, from the new thread (Not sure that would work, though)...Or I could implement PADupdate() just to hide the cursor the first time its called, which seems a bit silly, though I could also show the cursor when I don't have capture that way).

Edit: Ahh...what the hell? Why not another hack...Not going to bother with a new version number. Unlike pretty much every other LilyPad setting, modifying the new setting if you escape out of emulation will have no effect. Has to be set when the GS window is created to work. Not bothering to increment the version number for now.

Edit 2+ (Hmm...I do edit a lot): Also, bind a key to the "mouse" button. That'll free the mouse for working with other windows. I use tilde for it, myself. About the alt tab thing - enable a hack or use Windows messaging mode to get around that. I have to get rid of the clipping rectangle when the window loses focus, but I only learn about that when I'm stealing events from the window (Which I only do if you have a non-DirectInput mode set or a hack enabled. Any of the hacks will do). There is a bug that will still cause that behavior when you have background monitoring enabled. I forgot about the mouse capture thing when I added the option (Which, currently, doesn't release any input when you alt-tab out). I'll fix it in the next release, though no real rush, as the "Mouse" button works great.

<Removed. 0.8.3 has the changes>

Last edited by ChickenLiver; November 23rd, 2007 at 19:12.
ChickenLiver is offline   Reply With Quote