|Grarh! I just spent hours trying to decipher why my programming's mouse-control was moving sluggishly. First I added some debug output - that, ridiculously, fixed the problem. Then I took it away, and the sluggishness returned. I tried a release build; sluggish. Release build with debug output; not sluggish. Release build with debug output but run not under the debugger; sluggish. This data pattern makes no sense at all, as it should be, if anything, the other way around. Adding debug output should never ever speed up a program.|
So, I thought perhaps it might be some sort of weird display thing, that changing the display outside the DirectX area was making screen updates occur faster. I added a frame-rate display; 450fps with or without debug output, sluggishness as before. I checked my mouse-data-getting code to ensure that it was getting all the buffered input each frame, rather than trickling a little each frame; it was. I tried changing the window's title bar with debug output instead of doing it as debug output; that made the sluggishness go away too. I tried putting the debug output on the screen like the frame rate; sluggish again. I tried displaying the current frame number, in case it was something weird with the screen not actually updating when a frame was counted - it wasn't, the screen was updating very very fast, the mouse was still sluggish.
I exploded my brain with a delicious mix of sulphuric acid and sugar. That made no difference. So I asked Google about DirectX sluggish mouse. Lo and behold, a 44K patch from Microsoft to resolve "known issues causing mouse behaviour to be very sluggish when using DirectInput and foreground exclusive mode mouse access".
Ooh, it makes me cross when I spend hours debugging stuff only to find out there wasn't a bug in my code at all. I didn't even need to apply the patch, since I had been downloading the DirectX 9 SDK meanwhile, to get my SDK to match my runtime, so as to be able to use the DirectX control panel again, which would have been one of my debugging steps had it been available.
It's time to send in the pusher robots.