Any way to change OS Mouse Sensitivity?

Blitz3D Forums/Blitz3D Programming/Any way to change OS Mouse Sensitivity?

Gabriel(Posted 2005) [#1]
I believe Direct Input can do this, but it either isn't in DInput7 or it was left out of Blitz. I was wondering if there is any way to do it via the WinAPI or something like that? Bit of a long shot, I guess, but it would be very useful.

Note: I'm not talking about something you can do with internal Blitz commands. This would have to be heigher than that, either interfacing with Direct Input, or the OS itself.


Perturbatio(Posted 2005) [#2]
Apparently you need to use SystemParametersInfo using SPI_SETMOUSE and passing an array of 3 ints representing the two mouse limits and the mouse speed/acceleration.


Perturbatio(Posted 2005) [#3]
It would appear you actually need to use SystemParametersInfo in conjunction with SPI_SETMOUSESPEED, and instad of a pointer to the value (pvParam), you specify an int in the range 1 to 20 (1 least, 20 most sensitive).


Gabriel(Posted 2005) [#4]
That does indeed sound like just what I need. Thanks for that.


Gabriel(Posted 2005) [#5]
Ok, SPI_GETMOUSESPEED ( which I need to use in order to be able to set the value back once set ) seems to require an integer pointer, so since Blitz doesn't support pointers, I've done it as a PureBasic DLL.

The PB Source looks like this :

#SPI_GETMOUSESPEED=112
#SPI_SETMOUSESPEED=113

ProcedureDLL.l GetMouseSensitivity()
  MouseSpeed.l=0
  SystemParametersInfo_(#SPI_GETMOUSESPEED,0,@MouseSpeed,#SPIF_SENDWININICHANGE)
  ProcedureReturn MouseSpeed
EndProcedure 

ProcedureDLL SetMouseSensitivity(Sense.l)
  SystemParametersInfo_(#SPI_SETMOUSESPEED,0,Sense,#SPIF_SENDWININICHANGE)
EndProcedure



And the DECLS looks like this :

.lib "mouse.dll"

GetMouseSensitivity%()          :"GetMouseSensitivity"
SetMouseSensitivity%(Sense%)    :"SetMouseSensitivity"



I've tested these and they seem to work just fine. If there's a site that hosts Blitz-specific DLL's, I'd be happy to upload the compiled DLL for anyone who wants this and doesn't have PB. If I uploaded it to my own space, I'd only forget about it, delete it and leave a broken link for everyone in the future.


Perturbatio(Posted 2005) [#6]
would you mind mailing me a copy of the dll? me@...


Gabriel(Posted 2005) [#7]
Done.

( And before anyone reminds me of the PureBasic license, it only forbids wrapping PureBasic commands. This is not wrapping any PureBasic commands. )


Perturbatio(Posted 2005) [#8]
ok, here's the dll, it is UUEncoded, it can be Decoded with any UUDecode utility (here's one for windows)



Gabriel(Posted 2005) [#9]
Neat, thanks for that.


Perturbatio(Posted 2005) [#10]
might be a good idea to post it in the code archives in case there's a forum purge at some point.


Gabriel(Posted 2005) [#11]
Oh yeah, good idea. Just done it.