[Linux] Mouse speed
miran

I noticed that the speed of the mouse cursor movement in Linux and Windows is different. I mean in 1280x960 (my desktop resolution) it's approximately the same, but when I run a 640x480 game in fullscreen mode there's a big difference. In Windows you physically have to move the same distance to get the cursor from left to right edge of the screen or from top to bottom as when you're in dektop mode. But on Linux the absolute speed of the cursor stays the same in fullscreen so in 640x480 you only need to move the mouse half as much as at 1280x960 to cover the entire screen. This makes the mouse feel twice as sensitive and it makes fullscreen Allegro games running at resolutions lower that 1280x960 (or similar) almost impossible to play.

Is there any way, either in the mouse settings in Linux or in Allegro, to fix this? If moving the mouse 4cm on my desk means the cursor to go from left edge to the right in the 1280x960 desktop, I want the same thing to happen in my 640x480 fullscreen game. Or am I asking too much?

Btw, set_mouse_speed() doesn't seem to have any effect.

Onewing

That's interesting. Perhaps you just need to translate the mouse coordinates to fit to whatever resolution you change to:

// Untested

// Base Resolution
#define GFX_W 640
#define GFX_H 480

// Translated onto new Resolution (NFX_W, NFX_H)
void draw_mouse(int NFX_W, int NFX_H, BITMAP *bMouse)
{
   double x_rate = GFX_W / NFX_W;
   double y_rate = GFX_H / NFX_H;

   draw_sprite(buffer, bMouse, mouse_x * x_rate, mouse_y * y_rate);
}

miran

Yeah, but my point is why does this happen on Linux? I googled a bit and read somewhere that X simply can't do relative mouse movement. If this is true, then that's lame.

Btw, how would one find the base resolution? Is there a get_desktop_resolution() function in Allegro or something. If there is, I can't find it in the manual...

Onewing
Quote:

Yeah, but my point is why does this happen on Linux?

Ah, I was wondering why you didn't put this in the programming forum.

Quote:

Btw, how would one find the base resolution?

Actually, I think you need to find the translated resolution. I was thinking the base resolution would be the resolution the game was set for. Of course, that doesn't answer how to get the desktop physical resolution. I'd do a search, but I'm sure you're perfectly capable of searching the manual and I'd only end up at the same dead end.

miran
Quote:

but I'm sure you're perfectly capable of searching the manual

Think again. :P I know how to use the .chm manual but there's no such thing on Linux...

kentl

Have you tried xchm? (I haven't.)

miran

Hmm, looks interesting. Hehe, that's one of the things I miss a lot in Linux. The chm allegro manual... :)

Kitty Cat
Quote:

Yeah, but my point is why does this happen on Linux?

Because when when using the XF86VidMode extension, it simply changes the physical screen resolution and leaves the virtual screen size, and everything else, alone (which is why you can't change color depths, because it'd mess up the pixel format on all the other running apps). There's a new(er) XRandR extension which may or may not help here (Allegro doesn't use this yet, though).

Quote:

Btw, how would one find the base resolution? Is there a get_desktop_resolution() function in Allegro or something. If there is, I can't find it in the manual...

It exists on my machine..
int get_desktop_resolution(int *width, int *height);
Returns 0 on success.

Thomas Fjellstrom

Actually, I find X's mouse speed different than Windows.. I think it sets the mouse DPI different or something. But then, KDE has a nice dialog for mouse acceleration and a nice Logitech config dialog, so everythings fine :)

Thread #563694. Printed from Allegro.cc