SPI_GETMOUSE : goto wits(end)

Blitz3D Forums/Blitz3D Beginners Area/SPI_GETMOUSE : goto wits(end)

Stoop Solo(Posted 2004) [#1]
I crave wisdom. I just cannot seem to suss this thing out.

I am needing to retrieve and set mouse acceleration from within Blitz. Basically this functionality is available via user32.dll's SystemParametersInfo function, using SPI_GETMOUSE and SPI_SETMOUSE :


SystemParametersInfo


BOOL SystemParametersInfo(
UINT uiAction,
UINT uiParam,
PVOID pvParam,
UINT fWinIni
);

Parameters

uiAction
[in] System-wide parameter to be retrieved or set. This parameter can be one of the following values. They are organized in tables of related parameters.

uiParam
[in] Depends on the system parameter being queried or set. For more information about system-wide parameters, see the uiAction parameter. If not otherwise indicated, you must specify zero for this parameter.

pvParam
[in, out] Depends on the system parameter being queried or set. For more information about system-wide parameters, see the uiAction parameter. If not otherwise indicated, you must specify NULL for this parameter.

fWinIni
[in] If a system parameter is being set, specifies whether the user profile is to be updated, and if so, whether the WM_SETTINGCHANGE message is to be broadcast to all top-level windows to notify them of the change.

This parameter can be zero if you don't want to update the user profile or broadcast the WM_SETTINGCHANGE message, or it can be one or more of the following values.

Value Meaning
SPIF_UPDATEINIFILE Writes the new system-wide parameter setting to the user profile.
SPIF_SENDCHANGE Broadcasts the WM_SETTINGCHANGE message after updating the user profile.
SPIF_SENDWININICHANGE Same as SPIF_SENDCHANGE.




the uiAction parameters I am interested in are:


SPI_GETMOUSE - Retrieves the two mouse threshold values and the mouse acceleration. The pvParam parameter must point to an array of three integers that receives these values. See mouse_event for further information.

SPI_SETMOUSE - Sets the two mouse threshold values and the mouse acceleration. The pvParam parameter must point to an array of three integers that specifies these values. See mouse_event for further information.




I have a user32.decls containing the following:


.lib "user32.dll"

SystemParametersInfo%(uAction%, uParam%, lpvParam*, fuWinIni%) : "SystemParametersInfoA"




and finally, a bit of test blitz code:



Type mouseparams
Field amouse
Field bmouse
Field cmouse
End Type


workdammit.mouseparams=New mouseparams

SystemParametersInfo(????????, 0, workdammit, 0)

Print workdammit\amouse
Print workdammit\bmouse
Print workdammit\cmouse


I've done dll calls before, but this one just seems to be getting the better of me. Everything else seems to pretty much make sense except the uiAction. I cannot suss out how to retrieve the SPI_GETMOUSE and SPI_SETMOUSE parameters. I'm probably off the mark here, but isn't 'uiAction' an integer, as denoted by the '%'? In which case, how on earth can it equal SPI_GETMOUSE?

To cut a long story short, what do I have to change '????????' in the example in order for it to work?

SystemParametersInfo hates me.

Thanks.


Perturbatio(Posted 2004) [#2]
const SPI_GETMOUSE = 3
const SPI_SETMOUSE = 4



Stoop Solo(Posted 2004) [#3]
Much obliged to you, Perturbatio.

Just out of interest, where did those figures come from?

And am I doing something else wrong, as the only values I seem to get back from the function call are zero?


soja(Posted 2004) [#4]
As it says at the bottom of the documentation, they're declared in winuser.h. That is an include file that comes with the Win32 SDK (included with Visual C++, for example). You can get the SDK by itself here (for free):
http://www.microsoft.com/msdownload/platformsdk/sdkupdate/

Alternatively, you can get something like APIViewer to tell you the values of constants. http://www.activevb.de/rubriken/apiviewer/index-apiviewer.html#anchor3.


soja(Posted 2004) [#5]
As for your example, it works fine on my system:

;SystemParametersInfo%(uiAction%, uiParam%, pvParam*, fWinIni%):"SystemParametersInfoA"

Type mouseparams
Field amouse
Field bmouse
Field cmouse
End Type


workdammit.mouseparams=New mouseparams

Print SystemParametersInfo(3, 0, workdammit, 0)

Print workdammit\amouse
Print workdammit\bmouse
Print workdammit\cmouse
WaitKey



Stoop Solo(Posted 2004) [#6]
Ah, I missed that bit of the document. Thanks for the info. I'll check APIViewer out at a more sociable hour.

Unfortunately, on my system, that example still produces:

----------------------------------------
1 (indicating successful call)
0
0
0
----------------------------------------

Curses! Still no closer to temporarily disabling mouse acceleration within Dragon Chaser...


soja(Posted 2004) [#7]
So the function call is working, but you probably specified 4 (SPI_SETMOUSE) as the first parameter once, and set the values to workdammit\amouse, ..\bmouse, and ..\cmouse (which were all 0). So now whenever you use 3 (SPI_GETMOUSE), it returns 0, 0, and 0 like it should, but not as you're expecting.

Doesn't your mouse movement seem weird or a little different than it used to now? =)


Stoop Solo(Posted 2004) [#8]
My mouse is unaffected. Unfortunately, I definitely tried '3'; I copied and pasted the above example you quoted.

I'll have to see what it does on another machine, although if I cannot rely on it to work on all systems, I cannot... er... rely on it to work on all systems...

How odd...


Perturbatio(Posted 2004) [#9]
it works for me, I get :

1
6
10
1


soja(Posted 2004) [#10]
Why don't you go into the control panel, change your mouse settings, and try it again just to make sure?


Stoop Solo(Posted 2004) [#11]
Hmm...

It seems to produce results on a different machine.

Interestingly, it seems if I turn mouse acceleration off on the other machine, all the results are returned as zero. If I turn it back on again, the results change.

As fas as my machine is concerned, the results remain as zero whatever I do to it. If I SETMOUSE them to something else, I get those values back, although it makes no alteration to any of the parameters in the control panel, nor to the mouse.

I wonder if this is something to do with not using MS mouse drivers?


soja(Posted 2004) [#12]
Strange indeed. I'm stumped; I got the same results as Perturbatio (I guess we both use the defaults).

My mouse driver is just the standard PS/2 mouse driver included with Windows XP.


Stoop Solo(Posted 2004) [#13]
If its behavior is uncertain, I'd best leave alone. I could just set them to zero upon game launch and put them back to whatever upon exit, and satisfy probably the majority of windows configurations, but I guess that still brings the possibility of adverse effects. Perhaps I'll just stick with the note in dragon chaser's readme file.

Thanks Perturbatio / soja.