Any way to change OS Mouse Sensitivity?

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

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.

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.

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).

That does indeed sound like just what I need. Thanks for that.

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.

would you mind mailing me a copy of the dll? me@...

Done.

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

ok, here's the dll, it is UUEncoded, it can be Decoded with any UUDecode utility (here's one for windows)
begin 0666 mouse.dll
M35J0``,````$````__\``+@`````````0```````````````````````````
M````````````````````@`````X?N@X`M`G-(;@!3,TA5&AI<R!P<F]G<F%M
M(&-A;FYO="!B92!R=6X@:6X@1$]3(&UO9&4N#0T*)`````````!010``3`$%
M`*)]DT(``````````.``#B$+`0(R``0````&`````````!`````0````(```
M````$``0`````@``!``````````$``````````!@````!`````````,`````
M`!```!``````$```$````````!``````(```;@`````P``!0````````````
M`````````````````````````%```"@`````````````````````````````
M``````````````````````````````````````!T,```)```````````````
M`````````````````````"YT97AT````B`$````0`````@````0`````````
M`````````"```&`N<F1A=&$``&X`````(`````(````&````````````````
M``!```!`+F1A=&$````D`0```#`````"````"```````````````````0```
MP"YF;&%T````6@````!``````@...
M;V,``"@`````4`````(````,``````````````````!```!"````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M`````````````````````````````````````````````(-\)`@!=0Z+1"0$
MHQPQ`!#H(@```(-\)`@"=0"#?"0(`'4%Z,0```"#?"0(`W4`N`$```#"#`!H
M`````&B@#P``:`````#H'P$``*,8,0`0ZTY345565XGF@^P$B>")PH/"!,<`
M`````(/`!#G0=?/'!"0`````:`(```"-1"0$4&@`````:'````#H\@```(L$
M).L",<"#Q`1?7EU96\/K25-15597B>:#[`2)X(G"@\($QP``````@...
M\XM&&(D$)&@"````_W0D!&@`````:'$```#HI````#'`@\0$7UY=65O"!`##
MZ`P```#_-1@Q`!#H=````,/#S,Q5B>535E>+70B+?0Q0ZT>#/_YU)3'VZQ?_
M=Q")\`^O1PR+5P@!V@'04.C2____1CMW!'SD@...#
M:@#_-1@Q`!#H*0```(/'!(,__W6T6%]>6UW""```_R5T,``0_R5\,``0_R6`
M,``0_R6$,``0_R6(,``0_R60,``0````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M`````````````*)]DT(`````/"````$````"`````@```"@@```P(```."``
M`%(0``"B$```1B```%H@``````$`;6]U<V4N9&QL`$=E=$UO=7-E4V5N<VET
M:79I='D`4V5T36]U<V5396YS:71I=FET>0``````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M``````````````````````````````!0,`````````````"B,```=#```%@P
M`````````````.0P``!\,```;#``````````````"C$``)`P````````````
M`````````````````)@P````````KC```+PP``#*,```V#````````#R,```
M`````)@P````````KC```+PP``#*,```V#````````#R,```````````;65M
M<V5T``!#4E1$3$PN9&QL`````$AE87!#<F5A=&4`````2&5A<$1E<W1R;WD`
M``!%>&ET4')O8V5S<P```$AE87!&<F5E``!+15).14PS,BY$3$P`````4WES
M=&5M4&%R86UE=&5R<TEN9F]!`%5315(S,BYD;&P`````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M`````````````````````````````````````````````````````%`)TG04
M@^H44F@`````_S48,0`0Z&/1__]8P\S,S,S,4`G2=#.#ZA125E>+0@2+<@R+
M.H/"%%)04%+HP=#__UA:`?I.=?!?7F@`````_S48,0`0Z"31__]8PP``````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M`````````````````!```!P````,,$PP\S!*,68Q;#%R,7@Q?C&$,0!````,
M````$#!/,```````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
=````````````````````````````````````````
`
end


Neat, thanks for that.

might be a good idea to post it in the code archives in case there's a forum purge at some point.

Oh yeah, good idea. Just done it.