* [Qemu-devel] [PATCH] Let the USB tablet reach the far bottom and right pixels
@ 2008-02-27 14:45 Samuel Thibault
2008-02-27 15:35 ` Johannes Schindelin
2008-03-05 10:46 ` [Qemu-devel] " Samuel Thibault
0 siblings, 2 replies; 5+ messages in thread
From: Samuel Thibault @ 2008-02-27 14:45 UTC (permalink / raw)
To: qemu-devel
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
diff -u -p -r1.15 cocoa.m
--- cocoa.m 22 Jan 2008 23:25:15 -0000 1.15
+++ cocoa.m 27 Feb 2008 14:42:02 -0000
@@ -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 17 Feb 2008 11:42:19 -0000 1.406
+++ vl.c 27 Feb 2008 14:42:04 -0000
@@ -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 17 Nov 2007 17:14:38 -0000 1.45
+++ sdl.c 27 Feb 2008 14:42:04 -0000
@@ -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 10 Feb 2008 16:33:13 -0000 1.35
+++ vnc.c 27 Feb 2008 14:42:04 -0000
@@ -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;
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH] Let the USB tablet reach the far bottom and right pixels
2008-02-27 14:45 [Qemu-devel] [PATCH] Let the USB tablet reach the far bottom and right pixels Samuel Thibault
@ 2008-02-27 15:35 ` Johannes Schindelin
2008-02-27 16:41 ` Samuel Thibault
2008-03-05 10:46 ` [Qemu-devel] " Samuel Thibault
1 sibling, 1 reply; 5+ messages in thread
From: Johannes Schindelin @ 2008-02-27 15:35 UTC (permalink / raw)
To: Samuel Thibault; +Cc: qemu-devel
Hi,
On Wed, 27 Feb 2008, Samuel Thibault wrote:
> Index: cocoa.m
> ===================================================================
> RCS file: /sources/qemu/qemu/cocoa.m,v
> retrieving revision 1.15
> diff -u -p -r1.15 cocoa.m
> --- cocoa.m 22 Jan 2008 23:25:15 -0000 1.15
> +++ cocoa.m 27 Feb 2008 14:42:02 -0000
> @@ -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
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH] Let the USB tablet reach the far bottom and right pixels
2008-02-27 15:35 ` Johannes Schindelin
@ 2008-02-27 16:41 ` Samuel Thibault
2008-02-27 16:56 ` Johannes Schindelin
0 siblings, 1 reply; 5+ messages in thread
From: Samuel Thibault @ 2008-02-27 16:41 UTC (permalink / raw)
To: Johannes Schindelin; +Cc: qemu-devel
Johannes Schindelin, le Wed 27 Feb 2008 15:35:01 +0000, a écrit :
> > Index: cocoa.m
> > ===================================================================
> > RCS file: /sources/qemu/qemu/cocoa.m,v
> > retrieving revision 1.15
> > diff -u -p -r1.15 cocoa.m
> > --- cocoa.m 22 Jan 2008 23:25:15 -0000 1.15
> > +++ cocoa.m 27 Feb 2008 14:42:02 -0000
> > @@ -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.
No, because then you would not reach 0x7FFF:
(1023 * 0x8000) / 1024 -> 0x7fe0
And then the guest does not reach 1023 (tested on windows).
Samuel
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH] Let the USB tablet reach the far bottom and right pixels
2008-02-27 16:41 ` Samuel Thibault
@ 2008-02-27 16:56 ` Johannes Schindelin
0 siblings, 0 replies; 5+ messages in thread
From: Johannes Schindelin @ 2008-02-27 16:56 UTC (permalink / raw)
To: Samuel Thibault; +Cc: qemu-devel
[-- Attachment #1: Type: TEXT/PLAIN, Size: 1161 bytes --]
Hi,
On Wed, 27 Feb 2008, Samuel Thibault wrote:
> Johannes Schindelin, le Wed 27 Feb 2008 15:35:01 +0000, a écrit :
> > > Index: cocoa.m
> > > ===================================================================
> > > RCS file: /sources/qemu/qemu/cocoa.m,v
> > > retrieving revision 1.15
> > > diff -u -p -r1.15 cocoa.m
> > > --- cocoa.m 22 Jan 2008 23:25:15 -0000 1.15
> > > +++ cocoa.m 27 Feb 2008 14:42:02 -0000
> > > @@ -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.
>
> 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
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Qemu-devel] Re: [PATCH] Let the USB tablet reach the far bottom and right pixels
2008-02-27 14:45 [Qemu-devel] [PATCH] Let the USB tablet reach the far bottom and right pixels Samuel Thibault
2008-02-27 15:35 ` Johannes Schindelin
@ 2008-03-05 10:46 ` Samuel Thibault
1 sibling, 0 replies; 5+ messages in thread
From: Samuel Thibault @ 2008-03-05 10:46 UTC (permalink / raw)
To: qemu-devel
Hello,
No news about this patch, could someone apply it?
Samuel
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 22 Jan 2008 23:25:15 -0000 1.15
> +++ cocoa.m 27 Feb 2008 14:42:02 -0000
> @@ -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 17 Feb 2008 11:42:19 -0000 1.406
> +++ vl.c 27 Feb 2008 14:42:04 -0000
> @@ -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 17 Nov 2007 17:14:38 -0000 1.45
> +++ sdl.c 27 Feb 2008 14:42:04 -0000
> @@ -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 10 Feb 2008 16:33:13 -0000 1.35
> +++ vnc.c 27 Feb 2008 14:42:04 -0000
> @@ -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;
--
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 -+-
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2008-03-05 10:47 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-02-27 14:45 [Qemu-devel] [PATCH] Let the USB tablet reach the far bottom and right pixels Samuel Thibault
2008-02-27 15:35 ` Johannes Schindelin
2008-02-27 16:41 ` Samuel Thibault
2008-02-27 16:56 ` Johannes Schindelin
2008-03-05 10:46 ` [Qemu-devel] " Samuel Thibault
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).