Skip to contentSkip to conversation

Let the USB tablet reach the far bottom and right pixels

PATCH In review Samuel Thibault 2 participants 5 messages Feb 27, 2008 – Mar 5, 2008

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Let the USB tablet reach the far bottom and right pixels

Hello,

While using a virtual usbtablet, I noticed that I could not reach the extreme bottom and right pixels. That is because of the conversion from screen coordinates to 0..0x7FFF, below is a patch that fixes it.

Samuel

Index: cocoa.m
===================================================================
RCS file: /sources/qemu/qemu/cocoa.m,v
retrieving revision 1.15

cocoa.m +1 -1
diff -u -p -r1.15 cocoa.m
@@ -40,7 +40,7 @@
 #define cgrect(nsrect) (*(CGRect *)&(nsrect))
 #define COCOA_MOUSE_EVENT \
         if (isTabletEnabled) { \
-            kbd_mouse_event((int)(p.x * 0x7FFF / screen.width), (int)((screen.height - p.y) * 0x7FFF / screen.height), 0, buttons); \
+            kbd_mouse_event((int)(p.x * 0x7FFF / (screen.width - 1)), (int)((screen.height - p.y) * 0x7FFF / (screen.height - 1)), 0, buttons); \
         } else if (isMouseGrabed) { \
             kbd_mouse_event((int)[event deltaX], (int)[event deltaY], 0, buttons); \
         } else { \
vl.c +1 -1
@@ -588,7 +588,7 @@
             if (qemu_put_mouse_event_current->qemu_put_mouse_event_absolute)
                 width = 0x7fff;
             else
-                width = graphic_width;
+                width = graphic_width - 1;
             mouse_event(mouse_event_opaque,
                                  width - dy, dx, dz, buttons_state);
         } else
sdl.c +2 -2
@@ -311,8 +311,8 @@
 	    absolute_enabled = 1;
 	}
 
-	dx = dx * 0x7FFF / width;
-	dy = dy * 0x7FFF / height;
+	dx = dx * 0x7FFF / (width - 1);
+	dy = dy * 0x7FFF / (height - 1);
     } else if (absolute_enabled) {
 	sdl_show_cursor();
 	absolute_enabled = 0;

Index: vnc.c
===================================================================
RCS file: /sources/qemu/qemu/vnc.c,v

vnc.c +2 -2
@@ -879,8 +879,8 @@
 	dz = 1;
 
     if (vs->absolute) {
-	kbd_mouse_event(x * 0x7FFF / vs->ds->width,
-			y * 0x7FFF / vs->ds->height,
+	kbd_mouse_event(x * 0x7FFF / (vs->ds->width - 1),
+			y * 0x7FFF / (vs->ds->height - 1),
 			dz, buttons);
     } else if (vs->has_pointer_type_change) {
 	x -= 0x7FFF;
#1 lore raw

Hi,

cocoa.m line 43

Quoted 13 lines · Samuel Thibault

Index: cocoa.m
===================================================================
RCS file: /sources/qemu/qemu/cocoa.m,v
retrieving revision 1.15
diff -u -p -r1.15 cocoa.m

cocoa.m +1 -1
@@ -40,7 +40,7 @@
 #define cgrect(nsrect) (*(CGRect *)&(nsrect))
 #define COCOA_MOUSE_EVENT \
         if (isTabletEnabled) { \
-            kbd_mouse_event((int)(p.x * 0x7FFF / screen.width), (int)((screen.height - p.y) * 0x7FFF / screen.height), 0, buttons); \
+            kbd_mouse_event((int)(p.x * 0x7FFF / (screen.width - 1)), (int)((screen.height - p.y) * 0x7FFF / (screen.height - 1)), 0, buttons); \

Would it not be better to multiply with 0x8000 / screen.width? This seems "more correct" to me.

Ciao,
Dscho

#2 lore raw
Quoted 8 lines · Johannes Schindelin, le Wed 27 Feb 2008 15:35:01 +0000, a écrit :
Quoted 8 lines

Index: cocoa.m
===================================================================
RCS file: /sources/qemu/qemu/cocoa.m,v
retrieving revision 1.15
diff -u -p -r1.15 cocoa.m

cocoa.m +0 -0
@@ -40,7 +40,7 @@
Quoted 8 lines

cocoa.m line 43

Quoted 5 lines
cocoa.m +1 -1
 #define cgrect(nsrect) (*(CGRect *)&(nsrect))
 #define COCOA_MOUSE_EVENT \
         if (isTabletEnabled) { \
-            kbd_mouse_event((int)(p.x * 0x7FFF / screen.width), (int)((screen.height - p.y) * 0x7FFF / screen.height), 0, buttons); \
+            kbd_mouse_event((int)(p.x * 0x7FFF / (screen.width - 1)), (int)((screen.height - p.y) * 0x7FFF / (screen.height - 1)), 0, buttons); \

Would it not be better to multiply with 0x8000 / screen.width? This seems "more correct" to me.

No, because then you would not reach 0x7FFF:

(1023 * 0x8000) / 1024 -> 0x7fe0

And then the guest does not reach 1023 (tested on windows).

Samuel

#3 lore raw

Hi,

Quoted 18 lines · Samuel Thibault
Quoted 8 lines · Johannes Schindelin, le Wed 27 Feb 2008 15:35:01 +0000, a écrit :
Quoted 8 lines

Index: cocoa.m
===================================================================
RCS file: /sources/qemu/qemu/cocoa.m,v
retrieving revision 1.15
diff -u -p -r1.15 cocoa.m

cocoa.m +0 -0
@@ -40,7 +40,7 @@
Quoted 8 lines

cocoa.m line 43

Quoted 5 lines
cocoa.m +1 -1
 #define cgrect(nsrect) (*(CGRect *)&(nsrect))
 #define COCOA_MOUSE_EVENT \
         if (isTabletEnabled) { \
-            kbd_mouse_event((int)(p.x * 0x7FFF / screen.width), (int)((screen.height - p.y) * 0x7FFF / screen.height), 0, buttons); \
+            kbd_mouse_event((int)(p.x * 0x7FFF / (screen.width - 1)), (int)((screen.height - p.y) * 0x7FFF / (screen.height - 1)), 0, buttons); \

Would it not be better to multiply with 0x8000 / screen.width? This seems "more correct" to me.

Quoted 5 lines

No, because then you would not reach 0x7FFF:

(1023 * 0x8000) / 1024 -> 0x7fe0

And then the guest does not reach 1023 (tested on windows).

Ah, but of course!

Thanks,
Dscho

#4 lore raw
In reply to Samuel Thibault

Hello,

No news about this patch, could someone apply it?

Samuel

Quoted 62 lines · Samuel Thibault, le Wed 27 Feb 2008 14:45:55 +0000, a écrit :

While using a virtual usbtablet, I noticed that I could not reach the extreme bottom and right pixels. That is because of the conversion from screen coordinates to 0..0x7FFF, below is a patch that fixes it.

Samuel

Index: cocoa.m
===================================================================
RCS file: /sources/qemu/qemu/cocoa.m,v
retrieving revision 1.15
diff -u -p -r1.15 cocoa.m

cocoa.m +1 -1
@@ -40,7 +40,7 @@
 #define cgrect(nsrect) (*(CGRect *)&(nsrect))
 #define COCOA_MOUSE_EVENT \
         if (isTabletEnabled) { \
-            kbd_mouse_event((int)(p.x * 0x7FFF / screen.width), (int)((screen.height - p.y) * 0x7FFF / screen.height), 0, buttons); \
+            kbd_mouse_event((int)(p.x * 0x7FFF / (screen.width - 1)), (int)((screen.height - p.y) * 0x7FFF / (screen.height - 1)), 0, buttons); \
         } else if (isMouseGrabed) { \
             kbd_mouse_event((int)[event deltaX], (int)[event deltaY], 0, buttons); \
         } else { \
vl.c +1 -1
@@ -588,7 +588,7 @@
             if (qemu_put_mouse_event_current->qemu_put_mouse_event_absolute)
                 width = 0x7fff;
             else
-                width = graphic_width;
+                width = graphic_width - 1;
             mouse_event(mouse_event_opaque,
                                  width - dy, dx, dz, buttons_state);
         } else
sdl.c +2 -2
@@ -311,8 +311,8 @@
 	    absolute_enabled = 1;
 	}
 
-	dx = dx * 0x7FFF / width;
-	dy = dy * 0x7FFF / height;
+	dx = dx * 0x7FFF / (width - 1);
+	dy = dy * 0x7FFF / (height - 1);
     } else if (absolute_enabled) {
 	sdl_show_cursor();
 	absolute_enabled = 0;

Index: vnc.c
===================================================================
RCS file: /sources/qemu/qemu/vnc.c,v

vnc.c +2 -2
@@ -879,8 +879,8 @@
 	dz = 1;
 
     if (vs->absolute) {
-	kbd_mouse_event(x * 0x7FFF / vs->ds->width,
-			y * 0x7FFF / vs->ds->height,
+	kbd_mouse_event(x * 0x7FFF / (vs->ds->width - 1),
+			y * 0x7FFF / (vs->ds->height - 1),
 			dz, buttons);
     } else if (vs->has_pointer_type_change) {
 	x -= 0x7FFF;
Signature · 5 lines
Samuel
 PS> Salut ! J'ai un sujet de philo à vous soumettre : "Suffit-il
 PS> d'observer pour connaître" Idées + plan Merçi
 Oui, ya qu'a t'observer pour connaître le fait que tu es une feignasse.
 -+- FF in: Guide du Neuneu d'Usenet - Neuneu fait de la philo -+-