Re: [AD] Windows mouse patch |
[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
> The patch is, er, kinda fucked. (the last two chunks)
Not just those it seems...
I tried fixing it up, but should probably look into it a bit more. James
apparently used an older version to make the diff and his patch doesn't
apply cleanly.
Evert
---
Index: src/win/wmouse.c
===================================================================
RCS file: /cvsroot/alleg/allegro/src/win/wmouse.c,v
retrieving revision 1.37
diff -u -r1.37 wmouse.c
--- src/win/wmouse.c 20 Oct 2004 20:03:31 -0000 1.37
+++ src/win/wmouse.c 25 Oct 2004 08:30:53 -0000
@@ -92,8 +92,8 @@
#define MAF_DEFAULT 1 /* mouse acceleration parameters */
static int mouse_accel_fact = MAF_DEFAULT;
static int mouse_accel_mult = MAF_DEFAULT;
-static int mouse_accel_thr1 = 5;
-static int mouse_accel_thr2 = 16;
+static int mouse_accel_thr1 = 50; /* 50 = 5^2 *2 */
+static int mouse_accel_thr2 = 512; /* 512 = 16^2 *2 */
static int mouse_minx = 0; /* mouse range */
static int mouse_miny = 0;
@@ -208,17 +208,22 @@
*/
static void mouse_dinput_handle_event(int ofs, int data)
{
+ static int last_mickeyx=0;+ static int last_mickeyy=0;
+
switch (ofs) {
case DIMOFS_X:
if (!gfx_driver || !gfx_driver->windowed) {
if (mouse_accel_mult) {
- if (ABS(data) >= mouse_accel_thr2)
+ int mag = last_mickeyx*last_mickeyx +
last_mickeyy*last_mickeyy;
+ if (mag >= mouse_accel_thr2)
data *= (mouse_accel_mult<<1);
- else if (ABS(data) >= mouse_accel_thr1)
+ else if (mag >= mouse_accel_thr1)
data *= mouse_accel_mult;
}
+ last_mickeyx = data;
dinput_x += data;
}
break;
@@ -226,12 +231,14 @@
case DIMOFS_Y:
if (!gfx_driver || !gfx_driver->windowed) {
if (mouse_accel_mult) {
- if (ABS(data) >= mouse_accel_thr2)
+ int mag = last_mickeyx*last_mickeyx +
last_mickeyy*last_mickeyy;
+ if (mag >= mouse_accel_thr2)
data *= (mouse_accel_mult<<1);
- else if (ABS(data) >= mouse_accel_thr1)
+ else if (mag >= mouse_accel_thr1)
data *= mouse_accel_mult;
}
-
+
+ last_mickeyy = data;
dinput_y += data;
}
break;
@@ -427,6 +434,8 @@
DWORD level;
if (mouse_dinput_device) {
+ static int last_mickeyx=0;
+ static int last_mickeyy=0;
/* necessary in order to set the cooperative level */
mouse_dinput_unacquire();