Mouse sensitivity [SOLVED]
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Mouse sensitivity [SOLVED]
Considering love2d has no love.mouse.setSensitivity() function, can I somehow change the sensitivity using love.mouse.set[X,Y]() functions?
Last edited by Chroteus on Tue Feb 11, 2014 12:46 pm, edited 1 time in total.
Github: https://github.com/chroteus
Re: Mouse sensitivity
To illustrate my point better, I'll upload the love file. My goal is to decrease sensitivity as you zoom-in.
- Attachments
-
- clay.love
- (7.32 MiB) Downloaded 176 times
Github: https://github.com/chroteus
Re: Mouse sensitivity
It should be possible to control the mouse speed using set functions, yes.
You have to remember the previous location, and then calculate how far the mouse would have moved and divide those by some amount to slow the mouse down.
Something like above should work, I think.
EDITED: Shouldn't use abs; speed can be negative.
You have to remember the previous location, and then calculate how far the mouse would have moved and divide those by some amount to slow the mouse down.
Code: Select all
love.load()
oldX, oldY = love.mouse.getPosition()
slow = 2 -- half as fast
end
love.update( dt )
x, y = love.mouse.getPosition()
xDiff = ( oldX - x ) / slow
yDiff = ( oldY - y ) / slow
love.mouse.setPosition( oldX + xDiff, oldY + yDiff )
oldX, oldY = love.mouse.getPosition()
end
EDITED: Shouldn't use abs; speed can be negative.
Last edited by Plu on Mon Feb 10, 2014 2:34 pm, edited 1 time in total.
Re: Mouse sensitivity
I got it to be faster, but it's harder than I thought to make it slower haha
I have this:
But it won't slow down too much for some reason...
Edit: It's really bugged btw.
Also, I'm not sure if it fits that well in love.draw, I put it there cause it seemed to be better.
I have this:
Code: Select all
function love.load(arg)
oldMouseX, oldMouseY = love.mouse.getPosition()
sensitivity = 5 -- 20% faster
end
function love.draw()
local newMouseX, newMouseY = love.mouse.getPosition()
dX, dY = ((newMouseX - oldMouseX)*sensitivity), ((newMouseY - oldMouseY)*sensitivity)
oldMouseX, oldMouseY = newMouseX + dX, newMouseY + dY
love.mouse.setPosition(oldMouseX, oldMouseY)
end
Edit: It's really bugged btw.
Also, I'm not sure if it fits that well in love.draw, I put it there cause it seemed to be better.
Last edited by Zarty55 on Mon Feb 10, 2014 2:20 pm, edited 2 times in total.
- Daniel Eakins
- Citizen
- Posts: 99
- Joined: Thu Jul 18, 2013 9:14 pm
- Location: France
Re: Mouse sensitivity
You can maybe slow it by limiting FPS (only for your mouse movement function, not all of the game obviously).
http://love2d.org/forums/viewtopic.php?p=57977#p57977
http://love2d.org/forums/viewtopic.php?p=57977#p57977
Re: Mouse sensitivity
Thanks for your contributions, but the mouse either was "slipping away" or was just stuck to my screen's right edge. Daniel, the mouse didn't slow down but just became choppy. After all, that's the point of delta time. To make entities move independent of framerate. Anyway, you guys gave me some ideas, and I'll try to come up with something of my own.
EDIT: Still, I'm open for suggestions.
EDIT: Still, I'm open for suggestions.
Last edited by Chroteus on Mon Feb 10, 2014 2:34 pm, edited 1 time in total.
Github: https://github.com/chroteus
Re: Mouse sensitivity
@Zarty: you are modifying the mouse by adding to the new coordinates, this is causing it to act weird. You have to discard the new coordinates and work from the old coordinates again if you're determining the position difference manually. Otherwise you're adding both the normal mouse speed and your recalculated one.
Also I spotted a bug in my own which I'm fixing now.
Also I spotted a bug in my own which I'm fixing now.
Re: Mouse sensitivity
Anyway, I decided to make my game fullscreen. Although, I still can't set the sensitivity of mouse, it's no longer a problem now.
Github: https://github.com/chroteus
Re: Mouse sensitivity
This is not a problem of sensitivity but the way you trace mouse coordinates to tile coordinates. You need to transform your mouse coordinates to correspond with your drawing transformations.
Re: Mouse sensitivity
While I was aware that mouse's real position and the way it is interpereted wasn't the same, I thought I had a bug somewhere and was trying to fix it for hours. Later, I read your post again and you gave me an idea to read the camera lib's documentation more carefully. And... there was a nifty function called worldCoords which converted the mouse coordinates. Alright, I'll mark it as solved, even though there isn't a proper way to set the mouse sensitivity yet.Azhukar wrote:This is not a problem of sensitivity but the way you trace mouse coordinates to tile coordinates. You need to transform your mouse coordinates to correspond with your drawing transformations.
Github: https://github.com/chroteus
Who is online
Users browsing this forum: Google [Bot] and 93 guests