* [Qemu-devel] VNC terminal server? @ 2006-04-08 16:20 Samuel Hunt 2006-04-08 18:12 ` Brad Campbell 2006-04-08 18:24 ` Johannes Schindelin 0 siblings, 2 replies; 68+ messages in thread From: Samuel Hunt @ 2006-04-08 16:20 UTC (permalink / raw) To: qemu-devel It occurs to me that this program would make an excellent basis for a VNC terminal server. What I'm basically after is something that I can have several clients connect into one server, and the server does all the work and just outputs the screen and stuff over the network and recieves the input over the network. VNC does all the I/O that's needed, would it be possible to set Qemu up though so it works with VNC as the I/O and simply sits on something like Linux as a server, starting a new instance every time another client connects? Thanks all! Sam ^ permalink raw reply [flat|nested] 68+ messages in thread
* Re: [Qemu-devel] VNC terminal server? 2006-04-08 16:20 [Qemu-devel] VNC terminal server? Samuel Hunt @ 2006-04-08 18:12 ` Brad Campbell 2006-04-21 15:31 ` Troy Benjegerdes 2006-04-08 18:24 ` Johannes Schindelin 1 sibling, 1 reply; 68+ messages in thread From: Brad Campbell @ 2006-04-08 18:12 UTC (permalink / raw) To: qemu-devel Samuel Hunt wrote: > It occurs to me that this program would make an excellent basis for a > VNC terminal server. > > > What I'm basically after is something that I can have several clients > connect into one server, and the server does all the work and just > outputs the screen and stuff over the network and recieves the input > over the network. > > VNC does all the I/O that's needed, would it be possible to set Qemu up > though so it works with VNC as the I/O and simply sits on something like > Linux as a server, starting a new instance every time another client > connects? If you use the vnc patch you kinda get a large part of this already. Major issue is still mouse synch, but to be honest if you turn of all acceleration in the guest it stays pretty well synced up now as it is. I use it all the time on my server to host a win2k session when I need to access windows only stuff.. Coupled with kqemu it makes for a pretty quick combination. I *suspect* this is sort of how win4lin terminal server works, though they use funky additions to keep the mouse sync rock solid and other groovy bits to make life really easy to manage. I've been meaning to try and get my hands on an eval version to try it out.. as <plug here> the desktop version makes life dead easy for almost anyone to just install and go. (like it used to with the old win9x version) Currently I run gentoo, freebsd-6 and win2k sessions on my server.. they just sit there idle until I connect to them with vnc.. works a treat. (server is debian) Brad -- "Human beings, who are almost unique in having the ability to learn from the experience of others, are also remarkable for their apparent disinclination to do so." -- Douglas Adams ^ permalink raw reply [flat|nested] 68+ messages in thread
* Re: [Qemu-devel] VNC terminal server? 2006-04-08 18:12 ` Brad Campbell @ 2006-04-21 15:31 ` Troy Benjegerdes 2006-04-21 15:58 ` WaxDragon 0 siblings, 1 reply; 68+ messages in thread From: Troy Benjegerdes @ 2006-04-21 15:31 UTC (permalink / raw) To: qemu-devel On Sat, Apr 08, 2006 at 10:12:07PM +0400, Brad Campbell wrote: > Samuel Hunt wrote: > >It occurs to me that this program would make an excellent basis for a > >VNC terminal server. [...] > If you use the vnc patch you kinda get a large part of this already. Major > issue is still mouse synch, but to be honest if you turn of all > acceleration in the guest it stays pretty well synced up now as it is. > I use it all the time on my server to host a win2k session when I need to > access windows only stuff.. Coupled with kqemu it makes for a pretty quick > combination. [...] > Currently I run gentoo, freebsd-6 and win2k sessions on my server.. they > just sit there idle until I connect to them with vnc.. works a treat. > > (server is debian) Have you tried the vnc patch with current CVS? I'm seeing some issues with -vnc-and-sdl, and with -vnc only, it looks like something is not getting initialized, and I only see the qemu console in the vnc window. It appears the guest is running, but no video is going to VNC. ^ permalink raw reply [flat|nested] 68+ messages in thread
* Re: [Qemu-devel] VNC terminal server? 2006-04-21 15:31 ` Troy Benjegerdes @ 2006-04-21 15:58 ` WaxDragon 0 siblings, 0 replies; 68+ messages in thread From: WaxDragon @ 2006-04-21 15:58 UTC (permalink / raw) To: qemu-devel On 4/21/06, Troy Benjegerdes <hozer@hozed.org> wrote: > Have you tried the vnc patch with current CVS? I'm seeing some issues > with -vnc-and-sdl, and with -vnc only, it looks like something is not > getting initialized, and I only see the qemu console in the vnc window. > It appears the guest is running, but no video is going to VNC. > > > _______________________________________________ > Qemu-devel mailing list > Qemu-devel@nongnu.org > http://lists.nongnu.org/mailman/listinfo/qemu-devel > I'm using either 13 or my hacked 12 version of the rfb patch with current CVS. I can't tell which at the moment. Both -vnc-and-sdl and -vnc work for me, but I do see some initalization wierdness when using -S. Switching to the monitor and back seems to clear it. I haven't investigated why. WD -- ReactOS is a hub, follow the spokes and you'll immediately find absolutely everything you need to know about Windows. ReactOS is not just software, it's people. kjk_hyperion ^ permalink raw reply [flat|nested] 68+ messages in thread
* Re: [Qemu-devel] VNC terminal server? 2006-04-08 16:20 [Qemu-devel] VNC terminal server? Samuel Hunt 2006-04-08 18:12 ` Brad Campbell @ 2006-04-08 18:24 ` Johannes Schindelin 2006-04-08 18:37 ` Leonardo E. Reiter ` (4 more replies) 1 sibling, 5 replies; 68+ messages in thread From: Johannes Schindelin @ 2006-04-08 18:24 UTC (permalink / raw) To: qemu-devel Hi, On Sat, 8 Apr 2006, Samuel Hunt wrote: > It occurs to me that this program would make an excellent basis for a VNC > terminal server. Yeah, something like that has been done already: http://libvncserver.sourceforge.net/qemu/qemu-rfb13.patch.gz There is a notable update since rfb12 (which is a bit out of date _cough_): Nis Jorgensen has sent a patch to support scroll mice. IMHO the biggest obstacle to inclusion in mainline QEmu is that the mouse support is rather flakey: You have to disable mouse acceleration of the guest OS. I had that cunning plan to write a virtual Wacom tablet, but I just don't find the time. Ciao, Dscho ^ permalink raw reply [flat|nested] 68+ messages in thread
* Re: [Qemu-devel] VNC terminal server? 2006-04-08 18:24 ` Johannes Schindelin @ 2006-04-08 18:37 ` Leonardo E. Reiter 2006-04-08 19:04 ` Johannes Schindelin 2006-04-08 20:19 ` Brad Campbell 2006-04-08 18:38 ` [Qemu-devel] VNC terminal server? Mark Williamson ` (3 subsequent siblings) 4 siblings, 2 replies; 68+ messages in thread From: Leonardo E. Reiter @ 2006-04-08 18:37 UTC (permalink / raw) To: qemu-devel Hi Dscho, this virtual Wacom tablet you refer to... is there a [free or built-in] Windows 2000/XP driver associated with it that supports either no acceleration and/or absolute positioning? If so, perhaps I can look at implementing it in QEMU in my "spare" time ;) Do you have a link to documentation and/or drivers? If the guest OS can't be easily told to not do any acceleration and/or use absolute cursor positioning rather than relative moves, it's not that helpful to have a new type of input device. I suspect a tablet driver can be easily configured this way since design people who probably use these devices want perfect precision between pointer and screen - otherwise they'd probably just use a mouse/trackball. But you can never be sure how Microsoft (or Wacom) decided to implement the Windows version of the driver. The mouse sync solution we have in Win4Lin Pro is okay, but it's a bit slow and I'd like to do something much cleaner. Of course if I do the wacom tablet implementation, it will be open source and part of QEMU itself. Thanks! - Leo Reiter Johannes Schindelin wrote: > I had that cunning plan to write a virtual Wacom tablet, but I just don't > find the time. > > Ciao, > Dscho -- Leonardo E. Reiter Vice President of Product Development, CTO Win4Lin, Inc. Virtual Computing from Desktop to Data Center Main: +1 512 339 7979 Fax: +1 512 532 6501 http://www.win4lin.com ^ permalink raw reply [flat|nested] 68+ messages in thread
* Re: [Qemu-devel] VNC terminal server? 2006-04-08 18:37 ` Leonardo E. Reiter @ 2006-04-08 19:04 ` Johannes Schindelin 2006-04-08 19:15 ` Leonardo E. Reiter 2006-04-09 2:54 ` Anthony Liguori 2006-04-08 20:19 ` Brad Campbell 1 sibling, 2 replies; 68+ messages in thread From: Johannes Schindelin @ 2006-04-08 19:04 UTC (permalink / raw) To: qemu-devel Hi, On Sat, 8 Apr 2006, Leonardo E. Reiter wrote: > this virtual Wacom tablet you refer to... is there a [free or built-in] > Windows 2000/XP driver associated with it that supports either no > acceleration and/or absolute positioning? Frankly, I do not know if they are free. But as nobody pays me to play with QEmu, I do not care about Windows so much. And the Wacom drivers for Linux are free. BTW I prefer a virtual wacom tablet to Summagraphics, since kudzu (the hardware detection which is used in Knoppix) can detect it. Unfortunately just the USB version :-( > If so, perhaps I can look at implementing it in QEMU in my "spare" time > ;) Do you have a link to documentation and/or drivers? Wow! What an offer! I have some documentation somewhere, I just had a look, and only found the Summagraphics documentation. I will look harder. > If the guest OS can't be easily told to not do any acceleration and/or > use absolute cursor positioning rather than relative moves, it's not > that helpful to have a new type of input device. I suspect a tablet > driver can be easily configured this way since design people who > probably use these devices want perfect precision between pointer and > screen - otherwise they'd probably just use a mouse/trackball. But you > can never be sure how Microsoft (or Wacom) decided to implement the > Windows version of the driver. My favourite cartoonist, Jamiri, is very proud of his Wacom tablet. IIRC, it has an integrated LCD display. So, I assume absolute positioning is automatically switched on with that tablet. > The mouse sync solution we have in Win4Lin Pro is okay, but it's a bit > slow and I'd like to do something much cleaner. Of course if I do the > wacom tablet implementation, it will be open source and part of QEMU > itself. > > Thanks! Thank you! Ciao, Dscho ^ permalink raw reply [flat|nested] 68+ messages in thread
* Re: [Qemu-devel] VNC terminal server? 2006-04-08 19:04 ` Johannes Schindelin @ 2006-04-08 19:15 ` Leonardo E. Reiter 2006-04-09 2:54 ` Anthony Liguori 1 sibling, 0 replies; 68+ messages in thread From: Leonardo E. Reiter @ 2006-04-08 19:15 UTC (permalink / raw) To: qemu-devel Johannes Schindelin wrote: > Frankly, I do not know if they are free. But as nobody pays me to play > with QEmu, I do not care about Windows so much. And the Wacom drivers for > Linux are free. Yes, I understand. I've been looking at the XFree86 version of the driver already. Unfortunately any time I spend on this will have to apply to Windows guests as well, as you can imagine. My company sells Windows-on-Linux software that uses QEMU, so it has to play with Windows guests ;) In fact, there was a recent PS/2 mouse patch on this list and a hack for XFree86 which was very simple. I didn't try it, but if you are using Linux guests you can probably get absolute positioning very easily. I don't recall who posted the patch - it was recent. The fix for the guest X server is very simple as well. > > BTW I prefer a virtual wacom tablet to Summagraphics, since kudzu (the > hardware detection which is used in Knoppix) can detect it. Unfortunately > just the USB version :-( Yes, given the state of USB in QEMU it's probably best to stick to serial for now if you want something that works very reliably and soon. Serial would be my intention. The only issue may be how this plays with Windows guests - again, this is very important to me. > Wow! What an offer! I have some documentation somewhere, I just had a > look, and only found the Summagraphics documentation. I will look harder. Thanks! > My favourite cartoonist, Jamiri, is very proud of his Wacom tablet. IIRC, > it has an integrated LCD display. So, I assume absolute positioning is > automatically switched on with that tablet. I would think so too. But, in looking at the XFree86 version of the driver, it's apparently configurable and my fear is that Windows will flick it to relative mode so it can play acceleration tricks. But anyway, it's worth investigating. Actually Jim C. Brown just posted a note that there is an existing patch, but I can't seem to find it. Jim, I'd be glad to look at it even though you are saying that it is still flaky - perhaps it can be fixed. Thanks, Leo Reiter -- Leonardo E. Reiter Vice President of Product Development, CTO Win4Lin, Inc. Virtual Computing from Desktop to Data Center Main: +1 512 339 7979 Fax: +1 512 532 6501 http://www.win4lin.com ^ permalink raw reply [flat|nested] 68+ messages in thread
* Re: [Qemu-devel] VNC terminal server? 2006-04-08 19:04 ` Johannes Schindelin 2006-04-08 19:15 ` Leonardo E. Reiter @ 2006-04-09 2:54 ` Anthony Liguori 1 sibling, 0 replies; 68+ messages in thread From: Anthony Liguori @ 2006-04-09 2:54 UTC (permalink / raw) To: qemu-devel Johannes Schindelin wrote: > Hi, > > On Sat, 8 Apr 2006, Leonardo E. Reiter wrote: > > >> this virtual Wacom tablet you refer to... is there a [free or built-in] >> Windows 2000/XP driver associated with it that supports either no >> acceleration and/or absolute positioning? >> > > Frankly, I do not know if they are free. But as nobody pays me to play > with QEmu, I do not care about Windows so much. And the Wacom drivers for > Linux are free. > > BTW I prefer a virtual wacom tablet to Summagraphics, since kudzu (the > hardware detection which is used in Knoppix) can detect it. Unfortunately > just the USB version :-( > The USB version of the wacom tablet is not documented. Only the older serial tablets are. Regards, Anthony Liguori >> If so, perhaps I can look at implementing it in QEMU in my "spare" time >> ;) Do you have a link to documentation and/or drivers? >> > > Wow! What an offer! I have some documentation somewhere, I just had a > look, and only found the Summagraphics documentation. I will look harder. > > >> If the guest OS can't be easily told to not do any acceleration and/or >> use absolute cursor positioning rather than relative moves, it's not >> that helpful to have a new type of input device. I suspect a tablet >> driver can be easily configured this way since design people who >> probably use these devices want perfect precision between pointer and >> screen - otherwise they'd probably just use a mouse/trackball. But you >> can never be sure how Microsoft (or Wacom) decided to implement the >> Windows version of the driver. >> > > My favourite cartoonist, Jamiri, is very proud of his Wacom tablet. IIRC, > it has an integrated LCD display. So, I assume absolute positioning is > automatically switched on with that tablet. > > >> The mouse sync solution we have in Win4Lin Pro is okay, but it's a bit >> slow and I'd like to do something much cleaner. Of course if I do the >> wacom tablet implementation, it will be open source and part of QEMU >> itself. >> >> Thanks! >> > > Thank you! > > Ciao, > Dscho > > > > _______________________________________________ > Qemu-devel mailing list > Qemu-devel@nongnu.org > http://lists.nongnu.org/mailman/listinfo/qemu-devel > ^ permalink raw reply [flat|nested] 68+ messages in thread
* Re: [Qemu-devel] VNC terminal server? 2006-04-08 18:37 ` Leonardo E. Reiter 2006-04-08 19:04 ` Johannes Schindelin @ 2006-04-08 20:19 ` Brad Campbell 2006-04-08 20:29 ` Leonardo E. Reiter 2006-04-08 21:06 ` [Qemu-devel] Absolute USB-HID device musings (was Re: VNC Terminal Server) Leonardo E. Reiter 1 sibling, 2 replies; 68+ messages in thread From: Brad Campbell @ 2006-04-08 20:19 UTC (permalink / raw) To: qemu-devel Leonardo E. Reiter wrote: > The mouse sync solution we have in Win4Lin Pro is okay, but it's a bit > slow and I'd like to do something much cleaner. Of course if I do the > wacom tablet implementation, it will be open source and part of QEMU > itself. > This link might or might not be intersting http://72.14.203.104/search?q=cache:fZ3xQJYOy6UJ:www.codecomments.com/archive421-2005-5-499360.html+hid+mouse+absolute+support&hl=en&ct=clnk&cd=1&lr=lang_en Apparently USB HID supports absolute input devices natively. Given we have a HID mouse driver of sorts in qemu I wonder if that is another avenue perhaps ? -- "Human beings, who are almost unique in having the ability to learn from the experience of others, are also remarkable for their apparent disinclination to do so." -- Douglas Adams ^ permalink raw reply [flat|nested] 68+ messages in thread
* Re: [Qemu-devel] VNC terminal server? 2006-04-08 20:19 ` Brad Campbell @ 2006-04-08 20:29 ` Leonardo E. Reiter 2006-04-08 21:06 ` [Qemu-devel] Absolute USB-HID device musings (was Re: VNC Terminal Server) Leonardo E. Reiter 1 sibling, 0 replies; 68+ messages in thread From: Leonardo E. Reiter @ 2006-04-08 20:29 UTC (permalink / raw) To: qemu-devel I saw something like this once but dismissed it for some reason (like it was questionable whether or not Windows supported these types of devices)... it's quite interesting. Thanks, - Leo Reiter Brad Campbell wrote: > This link might or might not be intersting > > http://72.14.203.104/search?q=cache:fZ3xQJYOy6UJ:www.codecomments.com/archive421-2005-5-499360.html+hid+mouse+absolute+support&hl=en&ct=clnk&cd=1&lr=lang_en > > > Apparently USB HID supports absolute input devices natively. Given we > have a HID mouse driver of sorts in qemu I wonder if that is another > avenue perhaps ? > > -- Leonardo E. Reiter Vice President of Product Development, CTO Win4Lin, Inc. Virtual Computing from Desktop to Data Center Main: +1 512 339 7979 Fax: +1 512 532 6501 http://www.win4lin.com ^ permalink raw reply [flat|nested] 68+ messages in thread
* [Qemu-devel] Absolute USB-HID device musings (was Re: VNC Terminal Server) 2006-04-08 20:19 ` Brad Campbell 2006-04-08 20:29 ` Leonardo E. Reiter @ 2006-04-08 21:06 ` Leonardo E. Reiter 2006-04-08 21:18 ` Leonardo E. Reiter ` (3 more replies) 1 sibling, 4 replies; 68+ messages in thread From: Leonardo E. Reiter @ 2006-04-08 21:06 UTC (permalink / raw) To: qemu-devel This is by no means a complete patch (do not apply it as it will break usb-hid.c), but it adjusts the report descriptor in usb-hid.c to provide position in 16-bits, and in absolute coordinates: Index: usb-hid.c =================================================================== RCS file: /cvsroot/qemu/qemu/hw/usb-hid.c,v retrieving revision 1.1 diff -a -u -r1.1 usb-hid.c --- usb-hid.c 5 Nov 2005 16:57:08 -0000 1.1 +++ usb-hid.c 8 Apr 2006 20:56:02 -0000 @@ -117,7 +117,7 @@ 0x15, 0x00, 0x25, 0x01, 0x95, 0x03, 0x75, 0x01, 0x81, 0x02, 0x95, 0x01, 0x75, 0x05, 0x81, 0x01, 0x05, 0x01, 0x09, 0x30, 0x09, 0x31, 0x15, 0x81, - 0x25, 0x7F, 0x75, 0x08, 0x95, 0x02, 0x81, 0x06, + 0x25, 0x7F, 0x75, 0x16, 0x95, 0x02, 0x81, 0x02, 0xC0, 0xC0, }; According to: http://72.14.203.104/search?q=cache:wVYUTwc33f8J:www.usb.org/developers/devclass_docs/HID1_11.pdf+usb+hid+specification+absolute+relative&hl=en&gl=us&ct=clnk&cd=1 I'm still trying to figure out how the logical min/max apply if we are to report absolute (unsigned) positions in 16-bits. Obviously 8-bits is not enough for absolute coordinates. You could theoretically use only 12-bits per coordinate but that would make life difficult I think, and probably unnecessarily frugal in a software emulation. It's not clear to me [yet] how the scroll wheel comes into play, and whether or not it (the dz coordinate) can be kept relative for ease of implementation. Also the code would need to be changed to report coordinates in 16-bits rather than 8, and of course made to report absolute coordinates (like from sdl.c, etc.) Still it looks fairly easy to implement - the USB spec is pretty simple. So to reiterate, my patch does virtually nothing - in fact it will break usb-hid.c so please don't use it. I was just illustrating how to get it to report the device as providing 16-bit absolute coordinates instead of 8-bit relative ones. If anyone wants to chime in with more info, I'd be glad to make this a discussion. *If* using the USB HID device only, not any real USB devices, can be done without slowing down QEMU, then I think this is a great way to get a tablet emulated without having to deal with drivers on either side. Plus, in the long run, it probably means other neat stuff like being able to get away from ISA bus emulation, and also it's portable to other targets (for example, OS-X on PPC would talk to the USB HID device the same way theoretically), so it's likely the most portable and cleanest option. Regards, Leo Reiter Brad Campbell wrote: > Apparently USB HID supports absolute input devices natively. Given we > have a HID mouse driver of sorts in qemu I wonder if that is another > avenue perhaps ? > > -- Leonardo E. Reiter Vice President of Product Development, CTO Win4Lin, Inc. Virtual Computing from Desktop to Data Center Main: +1 512 339 7979 Fax: +1 512 532 6501 http://www.win4lin.com ^ permalink raw reply [flat|nested] 68+ messages in thread
* Re: [Qemu-devel] Absolute USB-HID device musings (was Re: VNC Terminal Server) 2006-04-08 21:06 ` [Qemu-devel] Absolute USB-HID device musings (was Re: VNC Terminal Server) Leonardo E. Reiter @ 2006-04-08 21:18 ` Leonardo E. Reiter 2006-04-08 21:22 ` Brad Campbell ` (2 subsequent siblings) 3 siblings, 0 replies; 68+ messages in thread From: Leonardo E. Reiter @ 2006-04-08 21:18 UTC (permalink / raw) To: qemu-devel Sorry, the patch is not only incomplete, but totally wrong :( The 0x16 should be 0x10, like this: > - 0x25, 0x7F, 0x75, 0x08, 0x95, 0x02, 0x81, 0x06, > + 0x25, 0x7F, 0x75, 0x10, 0x95, 0x02, 0x81, 0x02, I must have had a momentary lapse of [radix] reason :) - Leo Reiter -- Leonardo E. Reiter Vice President of Product Development, CTO Win4Lin, Inc. Virtual Computing from Desktop to Data Center Main: +1 512 339 7979 Fax: +1 512 532 6501 http://www.win4lin.com ^ permalink raw reply [flat|nested] 68+ messages in thread
* Re: [Qemu-devel] Absolute USB-HID device musings (was Re: VNC Terminal Server) 2006-04-08 21:06 ` [Qemu-devel] Absolute USB-HID device musings (was Re: VNC Terminal Server) Leonardo E. Reiter 2006-04-08 21:18 ` Leonardo E. Reiter @ 2006-04-08 21:22 ` Brad Campbell 2006-04-08 21:36 ` Leonardo E. Reiter 2006-04-09 4:36 ` Anthony Liguori 2006-04-09 18:35 ` Brad Campbell 3 siblings, 1 reply; 68+ messages in thread From: Brad Campbell @ 2006-04-08 21:22 UTC (permalink / raw) To: qemu-devel Leonardo E. Reiter wrote: > This is by no means a complete patch (do not apply it as it will break > usb-hid.c), but it adjusts the report descriptor in usb-hid.c to provide > position in 16-bits, and in absolute coordinates: > > Index: usb-hid.c > =================================================================== > RCS file: /cvsroot/qemu/qemu/hw/usb-hid.c,v > retrieving revision 1.1 > diff -a -u -r1.1 usb-hid.c > --- usb-hid.c 5 Nov 2005 16:57:08 -0000 1.1 > +++ usb-hid.c 8 Apr 2006 20:56:02 -0000 > @@ -117,7 +117,7 @@ > 0x15, 0x00, 0x25, 0x01, 0x95, 0x03, 0x75, 0x01, > 0x81, 0x02, 0x95, 0x01, 0x75, 0x05, 0x81, 0x01, > 0x05, 0x01, 0x09, 0x30, 0x09, 0x31, 0x15, 0x81, > - 0x25, 0x7F, 0x75, 0x08, 0x95, 0x02, 0x81, 0x06, > + 0x25, 0x7F, 0x75, 0x16, 0x95, 0x02, 0x81, 0x02, > 0xC0, 0xC0, > }; > > According to: > http://72.14.203.104/search?q=cache:wVYUTwc33f8J:www.usb.org/developers/devclass_docs/HID1_11.pdf+usb+hid+specification+absolute+relative&hl=en&gl=us&ct=clnk&cd=1 > > > I'm still trying to figure out how the logical min/max apply if we are > to report absolute (unsigned) positions in 16-bits. Obviously 8-bits is > not enough for absolute coordinates. You could theoretically use only > 12-bits per coordinate but that would make life difficult I think, and > probably unnecessarily frugal in a software emulation. From what I have managed to read up on thus far, the absolute coordinates are pretty much fed directly to the application as mouse move events. Now it's a long time since I've hacked on it but I wrote a userspace touch screen driver for win9x years ago that did just this.. I seem to recall having to scale the real touchscreen values to between 0x0 and 0xffff before feeding them in to the windows message queue. From memory 0,0 was top left and ffff,ffff was bottom right.. as applied to the current screen resolution. Windows worked the rest out itself.. Like I said.. very hazy memory.. I'll have a look in the morning and see if I can dig that code out to figure out what I did, but given the way windows mouse events work that seems logical and would be relatively easy to do in qemu. As for the wheel.. I have no idea. An idea I had a while back was to feed the wheel and buttons to the ps2 port and get the positioning info in some other fashion. Ugly.. very ugly.. -- "Human beings, who are almost unique in having the ability to learn from the experience of others, are also remarkable for their apparent disinclination to do so." -- Douglas Adams ^ permalink raw reply [flat|nested] 68+ messages in thread
* Re: [Qemu-devel] Absolute USB-HID device musings (was Re: VNC Terminal Server) 2006-04-08 21:22 ` Brad Campbell @ 2006-04-08 21:36 ` Leonardo E. Reiter 0 siblings, 0 replies; 68+ messages in thread From: Leonardo E. Reiter @ 2006-04-08 21:36 UTC (permalink / raw) To: qemu-devel Brad Campbell wrote: > Now it's a long time since I've hacked on it but I wrote a userspace > touch screen driver for win9x years ago that did just this.. I seem to > recall having to scale the real touchscreen values to between 0x0 and > 0xffff before feeding them in to the windows message queue. > From memory 0,0 was top left and ffff,ffff was bottom right.. as > applied to the current screen resolution. Windows worked the rest out > itself.. Like I said.. very hazy memory.. There's actually a GDI call you can make if you are in user space that will allow you to do absolute cursor addressing. The problem is that you have be in user space, and you have to be able to talk to the display. By the time this happens, it's way too late in general - for example, you already got past the Windows login screen, etc. It's basically what we do on Win4Lin Pro now, but it's not really adequate for the long run and it's not too fast. Ideally, a USB HID device would "just work" with the Windows HID "class" driver, and the rest will be history. HID device drivers are ubiquotous and work on every major OS, not just Windows obviously (Linux, *BSD, OS-X, etc.), so it truly would be the most universal solution. And, keeping with the spirit of QEMU, this solution would mean not having to modify anything in the guest either. Not too mention how it's 100 times easier (at least) to hack QEMU than to code a Windows device driver of any sort (IMHO anyway.) > I'll have a look in the morning and see if I can dig that code out to > figure out what I did, but given the way windows mouse events work that > seems logical and would be relatively easy to do in qemu. As for the > wheel.. I have no idea. An idea I had a while back was to feed the wheel > and buttons to the ps2 port and get the positioning info in some other > fashion. Ugly.. very ugly.. Actually the usb-hid.c already seems to be sending Z axis events (the wheel most likely)... it's just not clear, from reading the USB HID spec, how this relates to the data, or how this event is described. I admit I'm pretty new to deciphering USB, and also I haven't actually played with QEMU's usb-hid device either. As for the X and Y coordinate, they would have to be sent in some precision greater than 8-bits because screen resolutions are so high. A touchscreen is an ideal example of the type of device we need, even more so than a tablet. Thankfully USB makes us not really care what type of physical device it actually is, as long as we can describe it properly to the consumer (Windows/etc.). But anyway, we would want to be able to describe coordinates up to at least 1600x1200 since that is the max that cirrus_vga accepts, and that would require at least 11 bits per axis. You'd have to add 2 padding bits in the descriptor if you did it that way - easier would be 12-bits per axis. Then [I assume], when you send the motion packet, you would need to send the 24-bits packed rather than 8 and 8 as is done now. I just am not sure what happens to the dz part, since it's not really described anywhere that I can see. The code I'm referring to is in hw/usb-hid.c, in the function usb_mouse_poll(). It looks like the VM requests the Z axis value selectively, and the code handles this. I'm starting to believe that your dual-device idea makes good sense, because for example, a touchscreen doesn't have a Z axis. It will take some trial and error I suspect. - Leo -- Leonardo E. Reiter Vice President of Product Development, CTO Win4Lin, Inc. Virtual Computing from Desktop to Data Center Main: +1 512 339 7979 Fax: +1 512 532 6501 http://www.win4lin.com ^ permalink raw reply [flat|nested] 68+ messages in thread
* Re: [Qemu-devel] Absolute USB-HID device musings (was Re: VNC Terminal Server) 2006-04-08 21:06 ` [Qemu-devel] Absolute USB-HID device musings (was Re: VNC Terminal Server) Leonardo E. Reiter 2006-04-08 21:18 ` Leonardo E. Reiter 2006-04-08 21:22 ` Brad Campbell @ 2006-04-09 4:36 ` Anthony Liguori 2006-04-09 15:14 ` Jim C. Brown 2006-04-09 16:03 ` Leonardo E. Reiter 2006-04-09 18:35 ` Brad Campbell 3 siblings, 2 replies; 68+ messages in thread From: Anthony Liguori @ 2006-04-09 4:36 UTC (permalink / raw) To: qemu-devel I was looking through the Xorg evdev driver and it doesn't appear to support absolute coordinate reporting. evdev is how the USB mouse would show up to userspace. A little googling confirmed it for me: http://lists.freedesktop.org/archives/xorg/2005-September/010140.html USB wacom still seems the most promising to me but I fear getting it to work under Windows will be a pain. Regards, Anthony Liguori Leonardo E. Reiter wrote: > This is by no means a complete patch (do not apply it as it will break > usb-hid.c), but it adjusts the report descriptor in usb-hid.c to > provide position in 16-bits, and in absolute coordinates: > > Index: usb-hid.c > =================================================================== > RCS file: /cvsroot/qemu/qemu/hw/usb-hid.c,v > retrieving revision 1.1 > diff -a -u -r1.1 usb-hid.c > --- usb-hid.c 5 Nov 2005 16:57:08 -0000 1.1 > +++ usb-hid.c 8 Apr 2006 20:56:02 -0000 > @@ -117,7 +117,7 @@ > 0x15, 0x00, 0x25, 0x01, 0x95, 0x03, 0x75, 0x01, > 0x81, 0x02, 0x95, 0x01, 0x75, 0x05, 0x81, 0x01, > 0x05, 0x01, 0x09, 0x30, 0x09, 0x31, 0x15, 0x81, > - 0x25, 0x7F, 0x75, 0x08, 0x95, 0x02, 0x81, 0x06, > + 0x25, 0x7F, 0x75, 0x16, 0x95, 0x02, 0x81, 0x02, > 0xC0, 0xC0, > }; > > According to: > http://72.14.203.104/search?q=cache:wVYUTwc33f8J:www.usb.org/developers/devclass_docs/HID1_11.pdf+usb+hid+specification+absolute+relative&hl=en&gl=us&ct=clnk&cd=1 > > > I'm still trying to figure out how the logical min/max apply if we are > to report absolute (unsigned) positions in 16-bits. Obviously 8-bits > is not enough for absolute coordinates. You could theoretically use > only 12-bits per coordinate but that would make life difficult I > think, and probably unnecessarily frugal in a software emulation. > > It's not clear to me [yet] how the scroll wheel comes into play, and > whether or not it (the dz coordinate) can be kept relative for ease of > implementation. Also the code would need to be changed to report > coordinates in 16-bits rather than 8, and of course made to report > absolute coordinates (like from sdl.c, etc.) Still it looks fairly > easy to implement - the USB spec is pretty simple. > > So to reiterate, my patch does virtually nothing - in fact it will > break usb-hid.c so please don't use it. I was just illustrating how > to get it to report the device as providing 16-bit absolute > coordinates instead of 8-bit relative ones. If anyone wants to chime > in with more info, I'd be glad to make this a discussion. *If* using > the USB HID device only, not any real USB devices, can be done without > slowing down QEMU, then I think this is a great way to get a tablet > emulated without having to deal with drivers on either side. Plus, in > the long run, it probably means other neat stuff like being able to > get away from ISA bus emulation, and also it's portable to other > targets (for example, OS-X on PPC would talk to the USB HID device the > same way theoretically), so it's likely the most portable and cleanest > option. > > Regards, > > Leo Reiter > > Brad Campbell wrote: >> Apparently USB HID supports absolute input devices natively. Given we >> have a HID mouse driver of sorts in qemu I wonder if that is another >> avenue perhaps ? >> >> > ^ permalink raw reply [flat|nested] 68+ messages in thread
* Re: [Qemu-devel] Absolute USB-HID device musings (was Re: VNC Terminal Server) 2006-04-09 4:36 ` Anthony Liguori @ 2006-04-09 15:14 ` Jim C. Brown 2006-04-09 16:03 ` Leonardo E. Reiter 1 sibling, 0 replies; 68+ messages in thread From: Jim C. Brown @ 2006-04-09 15:14 UTC (permalink / raw) To: qemu-devel On Sat, Apr 08, 2006 at 11:36:19PM -0500, Anthony Liguori wrote: > I was looking through the Xorg evdev driver and it doesn't appear to > support absolute coordinate reporting. evdev is how the USB mouse would > show up to userspace. A little googling confirmed it for me: Doesn't look like a major issue. Sounds like someone is working on making evdev support absolute coordinates, and in the worse case it would be really trival to use something like malc_'s patch in order to make it work. As long as the closed source OSes support it, I think we should go for it. > > Regards, > > Anthony Liguori > -- Infinite complexity begets infinite beauty. Infinite precision begets infinite perfection. ^ permalink raw reply [flat|nested] 68+ messages in thread
* Re: [Qemu-devel] Absolute USB-HID device musings (was Re: VNC Terminal Server) 2006-04-09 4:36 ` Anthony Liguori 2006-04-09 15:14 ` Jim C. Brown @ 2006-04-09 16:03 ` Leonardo E. Reiter 2006-04-09 16:49 ` Brad Campbell 2006-04-09 18:07 ` andrzej zaborowski 1 sibling, 2 replies; 68+ messages in thread From: Leonardo E. Reiter @ 2006-04-09 16:03 UTC (permalink / raw) To: qemu-devel Yeah, the min/max value thing would be a pain for sure. The X server config method seems to be the best bet. On another note, I am trying to imagine what would make logical sense for say, a touch screen. For example, an LCD panel has a native resolution, say 1024x768. It would then emulate (or transparently expand) other VESA resolutions, such as 640x480, on the fly. I would think that if it had touchscreen capabilities, the coordinates would always be reported in native mode. So the guest OS must have to scale them down... especially if the device reports the range early on in the identification process. If this were done in QEMU, we'd have to pick an arbitrary "native" resolution - for example, 1600x1200, the max the cirrus device can go. We would then have to scale it down automatically based on the set resolution, so that the guest OS can scale it up. I'm just thinking out loud. The good news is that making changes to the open source bits on guests (like Xorg) is trivial... it's, as been said, the closed source guests that would be the most problematic. So sticking to the HID protocol to make this happen would be best. - Leo Anthony Liguori wrote: > I was looking through the Xorg evdev driver and it doesn't appear to > support absolute coordinate reporting. evdev is how the USB mouse would > show up to userspace. A little googling confirmed it for me: > > http://lists.freedesktop.org/archives/xorg/2005-September/010140.html > > USB wacom still seems the most promising to me but I fear getting it to > work under Windows will be a pain. > > Regards, > > Anthony Liguori > > > Leonardo E. Reiter wrote: > >> This is by no means a complete patch (do not apply it as it will break >> usb-hid.c), but it adjusts the report descriptor in usb-hid.c to >> provide position in 16-bits, and in absolute coordinates: >> >> Index: usb-hid.c >> =================================================================== >> RCS file: /cvsroot/qemu/qemu/hw/usb-hid.c,v >> retrieving revision 1.1 >> diff -a -u -r1.1 usb-hid.c >> --- usb-hid.c 5 Nov 2005 16:57:08 -0000 1.1 >> +++ usb-hid.c 8 Apr 2006 20:56:02 -0000 >> @@ -117,7 +117,7 @@ >> 0x15, 0x00, 0x25, 0x01, 0x95, 0x03, 0x75, 0x01, >> 0x81, 0x02, 0x95, 0x01, 0x75, 0x05, 0x81, 0x01, >> 0x05, 0x01, 0x09, 0x30, 0x09, 0x31, 0x15, 0x81, >> - 0x25, 0x7F, 0x75, 0x08, 0x95, 0x02, 0x81, 0x06, >> + 0x25, 0x7F, 0x75, 0x16, 0x95, 0x02, 0x81, 0x02, >> 0xC0, 0xC0, >> }; >> >> According to: >> http://72.14.203.104/search?q=cache:wVYUTwc33f8J:www.usb.org/developers/devclass_docs/HID1_11.pdf+usb+hid+specification+absolute+relative&hl=en&gl=us&ct=clnk&cd=1 >> >> >> I'm still trying to figure out how the logical min/max apply if we are >> to report absolute (unsigned) positions in 16-bits. Obviously 8-bits >> is not enough for absolute coordinates. You could theoretically use >> only 12-bits per coordinate but that would make life difficult I >> think, and probably unnecessarily frugal in a software emulation. >> >> It's not clear to me [yet] how the scroll wheel comes into play, and >> whether or not it (the dz coordinate) can be kept relative for ease of >> implementation. Also the code would need to be changed to report >> coordinates in 16-bits rather than 8, and of course made to report >> absolute coordinates (like from sdl.c, etc.) Still it looks fairly >> easy to implement - the USB spec is pretty simple. >> >> So to reiterate, my patch does virtually nothing - in fact it will >> break usb-hid.c so please don't use it. I was just illustrating how >> to get it to report the device as providing 16-bit absolute >> coordinates instead of 8-bit relative ones. If anyone wants to chime >> in with more info, I'd be glad to make this a discussion. *If* using >> the USB HID device only, not any real USB devices, can be done without >> slowing down QEMU, then I think this is a great way to get a tablet >> emulated without having to deal with drivers on either side. Plus, in >> the long run, it probably means other neat stuff like being able to >> get away from ISA bus emulation, and also it's portable to other >> targets (for example, OS-X on PPC would talk to the USB HID device the >> same way theoretically), so it's likely the most portable and cleanest >> option. >> >> Regards, >> >> Leo Reiter >> >> Brad Campbell wrote: >> >>> Apparently USB HID supports absolute input devices natively. Given we >>> have a HID mouse driver of sorts in qemu I wonder if that is another >>> avenue perhaps ? >>> >>> >> > > > > _______________________________________________ > Qemu-devel mailing list > Qemu-devel@nongnu.org > http://lists.nongnu.org/mailman/listinfo/qemu-devel -- Leonardo E. Reiter Vice President of Product Development, CTO Win4Lin, Inc. Virtual Computing from Desktop to Data Center Main: +1 512 339 7979 Fax: +1 512 532 6501 http://www.win4lin.com ^ permalink raw reply [flat|nested] 68+ messages in thread
* Re: [Qemu-devel] Absolute USB-HID device musings (was Re: VNC Terminal Server) 2006-04-09 16:03 ` Leonardo E. Reiter @ 2006-04-09 16:49 ` Brad Campbell 2006-04-09 18:07 ` andrzej zaborowski 1 sibling, 0 replies; 68+ messages in thread From: Brad Campbell @ 2006-04-09 16:49 UTC (permalink / raw) To: qemu-devel Leonardo E. Reiter wrote: > Yeah, the min/max value thing would be a pain for sure. The X server > config method seems to be the best bet. > > On another note, I am trying to imagine what would make logical sense > for say, a touch screen. For example, an LCD panel has a native > resolution, say 1024x768. It would then emulate (or transparently > expand) other VESA resolutions, such as 640x480, on the fly. I would > think that if it had touchscreen capabilities, the coordinates would > always be reported in native mode. So the guest OS must have to scale > them down... especially if the device reports the range early on in the > identification process. Every touchscreen I've ever used (which would be serial and USB Intellitouch and serial MicroTouch) used to report fixed absolute positions and the driver scaled them after a simple 2 or 5 point calibration routine. So they were indexed to the position on the monitor glass, not what was underneath it. We never changed screen resolutions so that was never an issue itself.. On LCD's it worked great and never needed recalibrating as the pixels don't move. On CRT's we needed to recalibrate every time some donkey fiddled with the H&V pos/scale knobs. Interestingly enough the Intellitouch reports z axis as well. It delivers an 8 bit force value. From what I've been able to figure thus far, the min/max thing seems to be the device telling the OS what it's minimum and maximum values are on each axis. It's then up to the OS to relate that to the current screen resolution. And after finding my old code buried under many TB of other garbage.. I note my memory failed me partially. The mouse events were poked directly into the windows message queue with MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE and the X and Y values were calculated from the touchscreen calibration values, scaled to be 0x0->0xffff and poked in as dwords. This was all cool as I had the cursor turned off. If the cursor needed to be displayed/moved also then it was set with SetCursorPos() which of course uses resolution dependent coordinates. Nice of windows to be consistent! Time to do some 'sperimenting I guess.. -- "Human beings, who are almost unique in having the ability to learn from the experience of others, are also remarkable for their apparent disinclination to do so." -- Douglas Adams ^ permalink raw reply [flat|nested] 68+ messages in thread
* Re: [Qemu-devel] Absolute USB-HID device musings (was Re: VNC Terminal Server) 2006-04-09 16:03 ` Leonardo E. Reiter 2006-04-09 16:49 ` Brad Campbell @ 2006-04-09 18:07 ` andrzej zaborowski 1 sibling, 0 replies; 68+ messages in thread From: andrzej zaborowski @ 2006-04-09 18:07 UTC (permalink / raw) To: qemu-devel On 09/04/06, Leonardo E. Reiter <lreiter@win4lin.com> wrote: > Yeah, the min/max value thing would be a pain for sure. The X server > config method seems to be the best bet. > > On another note, I am trying to imagine what would make logical sense > for say, a touch screen. For example, an LCD panel has a native > resolution, say 1024x768. It would then emulate (or transparently > expand) other VESA resolutions, such as 640x480, on the fly. I would > think that if it had touchscreen capabilities, the coordinates would > always be reported in native mode. So the guest OS must have to scale > them down... especially if the device reports the range early on in the > identification process. > As Brad Campbell noted, touchscreens always report absolute coordinates that need to be scaled by the OS. I have a working emulation for the TSC2301 touchscreen controller (used in PDAs) in QEMU and what this chipset does is simply report raw voltage values from the three wires that connect the touchscreen device and chipset (through a configurable 12-bit A/D converter). These three signals (X, Y and pressure) usually take values in the range from about 300 to about 4000 (while the LCD resolution is 320x320) and contain some noise, but still the resolution of the touchscreen is much higher than the LCD's. Under Linux, userspace can read these values using either evdev or tsdev (deprecated), both of which report only absolute coordinates. X compiled with tslib support works really nice with this touchscreen (both in QEMU and on real devices). Tslib performs the calibration, noise reduction (averaging) and other tricks. In QEMU I use parts of Anthony Liguori's WACOM patch for absolute coordinates, except the cursor hiding, because the guest doesn't know where the cursor is until it receives the pen-down event (i.e until you click on QEMU window). > If this were done in QEMU, we'd have to pick an arbitrary "native" > resolution - for example, 1600x1200, the max the cirrus device can go. > We would then have to scale it down automatically based on the set > resolution, so that the guest OS can scale it up. > > I'm just thinking out loud. The good news is that making changes to the > open source bits on guests (like Xorg) is trivial... it's, as been said, > the closed source guests that would be the most problematic. So > sticking to the HID protocol to make this happen would be best. > > - Leo > > Anthony Liguori wrote: > > I was looking through the Xorg evdev driver and it doesn't appear to > > support absolute coordinate reporting. evdev is how the USB mouse would > > show up to userspace. A little googling confirmed it for me: > > > > http://lists.freedesktop.org/archives/xorg/2005-September/010140.html > > > > USB wacom still seems the most promising to me but I fear getting it to > > work under Windows will be a pain. > > > > Regards, > > > > Anthony Liguori > > > > > > Leonardo E. Reiter wrote: > > > >> This is by no means a complete patch (do not apply it as it will break > >> usb-hid.c), but it adjusts the report descriptor in usb-hid.c to > >> provide position in 16-bits, and in absolute coordinates: > >> > >> Index: usb-hid.c > >> =================================================================== > >> RCS file: /cvsroot/qemu/qemu/hw/usb-hid.c,v > >> retrieving revision 1.1 > >> diff -a -u -r1.1 usb-hid.c > >> --- usb-hid.c 5 Nov 2005 16:57:08 -0000 1.1 > >> +++ usb-hid.c 8 Apr 2006 20:56:02 -0000 > >> @@ -117,7 +117,7 @@ > >> 0x15, 0x00, 0x25, 0x01, 0x95, 0x03, 0x75, 0x01, > >> 0x81, 0x02, 0x95, 0x01, 0x75, 0x05, 0x81, 0x01, > >> 0x05, 0x01, 0x09, 0x30, 0x09, 0x31, 0x15, 0x81, > >> - 0x25, 0x7F, 0x75, 0x08, 0x95, 0x02, 0x81, 0x06, > >> + 0x25, 0x7F, 0x75, 0x16, 0x95, 0x02, 0x81, 0x02, > >> 0xC0, 0xC0, > >> }; > >> > >> According to: > >> http://72.14.203.104/search?q=cache:wVYUTwc33f8J:www.usb.org/developers/devclass_docs/HID1_11.pdf+usb+hid+specification+absolute+relative&hl=en&gl=us&ct=clnk&cd=1 > >> > >> > >> I'm still trying to figure out how the logical min/max apply if we are > >> to report absolute (unsigned) positions in 16-bits. Obviously 8-bits > >> is not enough for absolute coordinates. You could theoretically use > >> only 12-bits per coordinate but that would make life difficult I > >> think, and probably unnecessarily frugal in a software emulation. > >> > >> It's not clear to me [yet] how the scroll wheel comes into play, and > >> whether or not it (the dz coordinate) can be kept relative for ease of > >> implementation. Also the code would need to be changed to report > >> coordinates in 16-bits rather than 8, and of course made to report > >> absolute coordinates (like from sdl.c, etc.) Still it looks fairly > >> easy to implement - the USB spec is pretty simple. > >> > >> So to reiterate, my patch does virtually nothing - in fact it will > >> break usb-hid.c so please don't use it. I was just illustrating how > >> to get it to report the device as providing 16-bit absolute > >> coordinates instead of 8-bit relative ones. If anyone wants to chime > >> in with more info, I'd be glad to make this a discussion. *If* using > >> the USB HID device only, not any real USB devices, can be done without > >> slowing down QEMU, then I think this is a great way to get a tablet > >> emulated without having to deal with drivers on either side. Plus, in > >> the long run, it probably means other neat stuff like being able to > >> get away from ISA bus emulation, and also it's portable to other > >> targets (for example, OS-X on PPC would talk to the USB HID device the > >> same way theoretically), so it's likely the most portable and cleanest > >> option. > >> > >> Regards, > >> > >> Leo Reiter > >> > >> Brad Campbell wrote: > >> > >>> Apparently USB HID supports absolute input devices natively. Given we > >>> have a HID mouse driver of sorts in qemu I wonder if that is another > >>> avenue perhaps ? > >>> > >>> > >> > > > > > > > > _______________________________________________ > > Qemu-devel mailing list > > Qemu-devel@nongnu.org > > http://lists.nongnu.org/mailman/listinfo/qemu-devel > > -- > Leonardo E. Reiter > Vice President of Product Development, CTO > > Win4Lin, Inc. > Virtual Computing from Desktop to Data Center > Main: +1 512 339 7979 > Fax: +1 512 532 6501 > http://www.win4lin.com > > > _______________________________________________ > Qemu-devel mailing list > Qemu-devel@nongnu.org > http://lists.nongnu.org/mailman/listinfo/qemu-devel > Regards, Andrew -- balrog 2oo6 Dear Outlook users: Please remove me from your address books http://www.newsforge.com/article.pl?sid=03/08/21/143258 ^ permalink raw reply [flat|nested] 68+ messages in thread
* Re: [Qemu-devel] Absolute USB-HID device musings (was Re: VNC Terminal Server) 2006-04-08 21:06 ` [Qemu-devel] Absolute USB-HID device musings (was Re: VNC Terminal Server) Leonardo E. Reiter ` (2 preceding siblings ...) 2006-04-09 4:36 ` Anthony Liguori @ 2006-04-09 18:35 ` Brad Campbell 2006-04-09 18:41 ` Lonnie Mendez 3 siblings, 1 reply; 68+ messages in thread From: Brad Campbell @ 2006-04-09 18:35 UTC (permalink / raw) To: qemu-devel Leonardo E. Reiter wrote: > This is by no means a complete patch (do not apply it as it will break > usb-hid.c), but it adjusts the report descriptor in usb-hid.c to provide > position in 16-bits, and in absolute coordinates: > > Index: usb-hid.c > =================================================================== > RCS file: /cvsroot/qemu/qemu/hw/usb-hid.c,v > retrieving revision 1.1 > diff -a -u -r1.1 usb-hid.c > --- usb-hid.c 5 Nov 2005 16:57:08 -0000 1.1 > +++ usb-hid.c 8 Apr 2006 20:56:02 -0000 > @@ -117,7 +117,7 @@ > 0x15, 0x00, 0x25, 0x01, 0x95, 0x03, 0x75, 0x01, > 0x81, 0x02, 0x95, 0x01, 0x75, 0x05, 0x81, 0x01, > 0x05, 0x01, 0x09, 0x30, 0x09, 0x31, 0x15, 0x81, > - 0x25, 0x7F, 0x75, 0x08, 0x95, 0x02, 0x81, 0x06, > + 0x25, 0x7F, 0x75, 0x16, 0x95, 0x02, 0x81, 0x02, > 0xC0, 0xC0, > }; > > According to: > http://72.14.203.104/search?q=cache:wVYUTwc33f8J:www.usb.org/developers/devclass_docs/HID1_11.pdf+usb+hid+specification+absolute+relative&hl=en&gl=us&ct=clnk&cd=1 > I can't get the existing usb-hid mouse to work in win2k. It sees a device but it marks it as non-functional. After wrapping my head around this descriptor I can't really seem to reconcile what is here with the data we are passing in usb_mouse_poll() I'm sure it works with a linux guest.. has anyone had -usb -usbdevice mouse working under windows ? This descriptor seems slightly whacky compared to most mouse examples I've seen floating about on the net. static const uint8_t qemu_mouse_hid_report_descriptor[] = { 0x05, 0x01, /* Usage Page Generic Desktop */ 0x09, 0x02, /* Usage Mouse */ 0xA1, 0x01 /* Collection Application */ 0x09, 0x01, /* Usage Pointer */ 0xA1, 0x00, /* Collection Physical */ 0x05, 0x09, /* Usage Page Button */ 0x19, 0x01, /* Usage Minimum Button 1 */ 0x29, 0x03, /* Usage Maximum Button 3 */ 0x15, 0x00, /* Logical Minimum 0 */ 0x25, 0x01, /* Logical Maximum 1 */ 0x95, 0x03, /* Report Count 3 */ 0x75, 0x01, /* Report Size 1 */ 0x81, 0x02, /* Input (Data, Var, Abs) */ 0x95, 0x01, /* Report Count 1 */ 0x75, 0x05, /* Report Size 5 */ 0x81, 0x01, /* Input (Cnst, Var, Abs) */ 0x05, 0x01, /* Usage Page Generic Desktop */ 0x09, 0x30, /* Usage X */ 0x09, 0x31, /* Usage Y */ 0x15, 0x81, /* Logical Minimum -127 */ 0x25, 0x7F, /* Logical Maximum 127 */ 0x75, 0x08, /* Report Size 8 */ 0x95, 0x02, /* Report Count 2 */ 0x81, 0x06, /* Input (Data, Var, Rel) */ 0xC0, /* End Collection */ 0xC0, /* End Collection */ }; I have recompiled this through a HID compiler and the analysis seems correct. So we are not describing a Z axis anywhere at all there.. This one passes a parse test and should give X & Y as 0->FFFF ABS while leaving Z as 8 bit relative. static const uint8_t qemu_mouse_hid_report_descriptor[] = { 0x05, 0x01, /* Usage Page Generic Desktop */ 0x09, 0x02, /* Usage Mouse */ 0xA1, 0x01 /* Collection Application */ 0x09, 0x01, /* Usage Pointer */ 0xA1, 0x00, /* Collection Physical */ 0x05, 0x09, /* Usage Page Button */ 0x19, 0x01, /* Usage Minimum Button 1 */ 0x29, 0x03, /* Usage Maximum Button 3 */ 0x15, 0x00, /* Logical Minimum 0 */ 0x25, 0x01, /* Logical Maximum 1 */ 0x95, 0x03, /* Report Count 3 */ 0x75, 0x01, /* Report Size 1 */ 0x81, 0x02, /* Input (Data, Var, Abs) */ 0x95, 0x01, /* Report Count 1 */ 0x75, 0x05, /* Report Size 5 */ 0x81, 0x01, /* Input (Cnst, Var, Abs) */ 0x05, 0x01, /* Usage Page Generic Desktop */ 0x09, 0x30, /* Usage X */ 0x09, 0x31, /* Usage Y */ 0x15, 0x00, /* Logical Minimum 0 */ 0x27, 0xFF, 0xFF, 0x00, 0x00, /* Logical Maximum 0xffff */ 0x75, 0x32, /* Report Size 32 */ 0x95, 0x02, /* Report Count 2 */ 0x81, 0x06, /* Input (Data, Var, Rel) */ 0x09, 0x32, /* Usage Z */ 0x15, 0x81, /* Logical Minimum -127 */ 0x25, 0x7F, /* Logical Maximum 127 */ 0x75, 0x08, /* Report Size 8 */ 0x95, 0x01, /* Report Count 1 */ 0xC0, /* End Collection */ 0xC0, /* End Collection */ }; I'm beginning to rate HID right up there with ACPI for complete brain melting factor.. (Not even compile tested yet.. still trying to fix the 1st one!) -- "Human beings, who are almost unique in having the ability to learn from the experience of others, are also remarkable for their apparent disinclination to do so." -- Douglas Adams ^ permalink raw reply [flat|nested] 68+ messages in thread
* Re: [Qemu-devel] Absolute USB-HID device musings (was Re: VNC Terminal Server) 2006-04-09 18:35 ` Brad Campbell @ 2006-04-09 18:41 ` Lonnie Mendez 2006-04-09 19:22 ` Brad Campbell 0 siblings, 1 reply; 68+ messages in thread From: Lonnie Mendez @ 2006-04-09 18:41 UTC (permalink / raw) To: qemu-devel Brad Campbell wrote: > Leonardo E. Reiter wrote: > >> This is by no means a complete patch (do not apply it as it will >> break usb-hid.c), but it adjusts the report descriptor in usb-hid.c >> to provide position in 16-bits, and in absolute coordinates: >> >> Index: usb-hid.c >> =================================================================== >> RCS file: /cvsroot/qemu/qemu/hw/usb-hid.c,v >> retrieving revision 1.1 >> diff -a -u -r1.1 usb-hid.c >> --- usb-hid.c 5 Nov 2005 16:57:08 -0000 1.1 >> +++ usb-hid.c 8 Apr 2006 20:56:02 -0000 >> @@ -117,7 +117,7 @@ >> 0x15, 0x00, 0x25, 0x01, 0x95, 0x03, 0x75, 0x01, >> 0x81, 0x02, 0x95, 0x01, 0x75, 0x05, 0x81, 0x01, >> 0x05, 0x01, 0x09, 0x30, 0x09, 0x31, 0x15, 0x81, >> - 0x25, 0x7F, 0x75, 0x08, 0x95, 0x02, 0x81, 0x06, >> + 0x25, 0x7F, 0x75, 0x16, 0x95, 0x02, 0x81, 0x02, >> 0xC0, 0xC0, >> }; >> >> According to: >> http://72.14.203.104/search?q=cache:wVYUTwc33f8J:www.usb.org/developers/devclass_docs/HID1_11.pdf+usb+hid+specification+absolute+relative&hl=en&gl=us&ct=clnk&cd=1 >> > > > I can't get the existing usb-hid mouse to work in win2k. It sees a > device but it marks it as non-functional. After wrapping my head > around this descriptor I can't really seem to reconcile what is here > with the data we are passing in usb_mouse_poll() > > I'm sure it works with a linux guest.. has anyone had -usb -usbdevice > mouse working under windows ? > > This descriptor seems slightly whacky compared to most mouse examples > I've seen floating about on the net. Please see the patch posted yesterday to this mailing list: http://gnome.dnsalias.net/patches/qemu-hidmousexp.patch ^ permalink raw reply [flat|nested] 68+ messages in thread
* Re: [Qemu-devel] Absolute USB-HID device musings (was Re: VNC Terminal Server) 2006-04-09 18:41 ` Lonnie Mendez @ 2006-04-09 19:22 ` Brad Campbell 2006-04-09 20:27 ` [Qemu-devel] Gentlemen we have absolute movement! was:Absolute " Brad Campbell 0 siblings, 1 reply; 68+ messages in thread From: Brad Campbell @ 2006-04-09 19:22 UTC (permalink / raw) To: qemu-devel Lonnie Mendez wrote: > Please see the patch posted yesterday to this mailing list: > > http://gnome.dnsalias.net/patches/qemu-hidmousexp.patch Ta for that.. not sure how I missed it. Now to try and get it to work.. Sprinkling printf's around the place it inits the usb controller and mouse, registers that mouse as the mouse handler.. then promptly registers the ps2 mouse over the top.. so it's not working in any case. Having disabled the ps2 mouse in windows.. I need to get friendly with keyboard navigation of the device manager again ;) -- "Human beings, who are almost unique in having the ability to learn from the experience of others, are also remarkable for their apparent disinclination to do so." -- Douglas Adams ^ permalink raw reply [flat|nested] 68+ messages in thread
* [Qemu-devel] Gentlemen we have absolute movement! was:Absolute USB-HID device musings (was Re: VNC Terminal Server) 2006-04-09 19:22 ` Brad Campbell @ 2006-04-09 20:27 ` Brad Campbell 2006-04-09 20:31 ` Anthony Liguori 2006-04-09 20:57 ` Anthony Liguori 0 siblings, 2 replies; 68+ messages in thread From: Brad Campbell @ 2006-04-09 20:27 UTC (permalink / raw) To: qemu-devel Brad Campbell wrote: > Lonnie Mendez wrote: > >> Please see the patch posted yesterday to this mailing list: >> >> http://gnome.dnsalias.net/patches/qemu-hidmousexp.patch > > Ta for that.. not sure how I missed it. > Now to try and get it to work.. > Ok.. 1st cut.. it's not great, and it's not hooked up to anything at the moment (the mouse just tootles around the screen on a timer) BUT! we have absolute movement. The *stunning* news is it's resolution independent.. 640x480 - 800x600 - 1024x768 0,0 is top left and 7fff.7fff is bottom right.. no client scaling required.. Think I've figured out the Z axis thing also.. and we are good for relative movement on that still (The Z axis below is way wrong, but I think I have figured it out) static const uint8_t qemu_mouse_hid_report_descriptor[] = { 0x05, 0x01, /* Usage Page Generic Desktop */ 0x09, 0x01, /* Usage Mouse */ 0xA1, 0x01, /* Collection Application */ 0x09, 0x01, /* Usage Pointer */ 0xA1, 0x00, /* Collection Physical */ 0x05, 0x09, /* Usage Page Button */ 0x19, 0x01, /* Usage Minimum Button 1 */ 0x29, 0x03, /* Usage Maximum Button 3 */ 0x15, 0x00, /* Logical Minimum 0 */ 0x25, 0x01, /* Logical Maximum 1 */ 0x95, 0x03, /* Report Count 3 */ 0x75, 0x01, /* Report Size 1 */ 0x81, 0x02, /* Input (Data, Var, Abs) */ 0x95, 0x01, /* Report Count 1 */ 0x75, 0x05, /* Report Size 5 */ 0x81, 0x01, /* Input (Cnst, Var, Abs) */ 0x05, 0x01, /* Usage Page Generic Desktop */ 0x09, 0x30, /* Usage X */ 0x09, 0x31, /* Usage Y */ 0x15, 0x00, /* Logical Minimum 0 */ 0x27, 0xFF, 0xFF, 0x00, 0x00, /* Logical Maximum 0xffff */ 0x75, 0x10, /* Report Size 32 */ 0x95, 0x02, /* Report Count 2 */ 0x81, 0x02, /* Input (Data, Var, Abs) */ // 0x09, 0x32, /* Usage Z */ // 0x15, 0x81, /* Logical Minimum -127 */ // 0x25, 0x7F, /* Logical Maximum 127 */ // 0x75, 0x08, /* Report Size 8 */ // 0x95, 0x01, /* Report Count 1 */ 0xC0, /* End Collection */ 0xC0, /* End Collection */ }; #endif static int usb_mouse_poll(USBMouseState *s, uint8_t *buf, int len) { int dx, dy, dz, b, l, aa, bb, cc, dd; dx = int_clamp(s->dx, -128, 127); dy = int_clamp(s->dy, -128, 127); dz = int_clamp(s->dz, -128, 127); s->dx -= dx; s->dy -= dy; s->dz -= dz; b = 0; if (s->buttons_state & MOUSE_EVENT_LBUTTON) b |= 0x01; if (s->buttons_state & MOUSE_EVENT_RBUTTON) b |= 0x02; if (s->buttons_state & MOUSE_EVENT_MBUTTON) b |= 0x04; buf[0] = b; buf[1] = s->X & 0xff; buf[2] = s->X >> 8; buf[3] = s->Y & 0xff; buf[4] = s->Y >> 8; aa=buf[1]; bb=buf[2]; cc=buf[3]; dd=buf[4]; l = 5; return l; } -- "Human beings, who are almost unique in having the ability to learn from the experience of others, are also remarkable for their apparent disinclination to do so." -- Douglas Adams ^ permalink raw reply [flat|nested] 68+ messages in thread
* Re: [Qemu-devel] Gentlemen we have absolute movement! was:Absolute USB-HID device musings (was Re: VNC Terminal Server) 2006-04-09 20:27 ` [Qemu-devel] Gentlemen we have absolute movement! was:Absolute " Brad Campbell @ 2006-04-09 20:31 ` Anthony Liguori 2006-04-09 20:57 ` Anthony Liguori 1 sibling, 0 replies; 68+ messages in thread From: Anthony Liguori @ 2006-04-09 20:31 UTC (permalink / raw) To: qemu-devel That's absolutely awesome Brad! Good job! I'll see how it works with the new Xorg driver. Regards, Anthony Liguori Brad Campbell wrote: > Brad Campbell wrote: >> Lonnie Mendez wrote: >> >>> Please see the patch posted yesterday to this mailing list: >>> >>> http://gnome.dnsalias.net/patches/qemu-hidmousexp.patch >> >> Ta for that.. not sure how I missed it. >> Now to try and get it to work.. >> > > Ok.. 1st cut.. it's not great, and it's not hooked up to anything at > the moment (the mouse just tootles around the screen on a timer) BUT! > we have absolute movement. > > The *stunning* news is it's resolution independent.. 640x480 - 800x600 > - 1024x768 > 0,0 is top left and 7fff.7fff is bottom right.. no client scaling > required.. > > Think I've figured out the Z axis thing also.. and we are good for > relative movement on that still > (The Z axis below is way wrong, but I think I have figured it out) > > static const uint8_t qemu_mouse_hid_report_descriptor[] = { > 0x05, 0x01, /* Usage Page Generic Desktop */ > 0x09, 0x01, /* Usage Mouse */ > 0xA1, 0x01, /* Collection Application */ > 0x09, 0x01, /* Usage Pointer */ > 0xA1, 0x00, /* Collection Physical */ > 0x05, 0x09, /* Usage Page Button */ > 0x19, 0x01, /* Usage Minimum Button 1 */ > 0x29, 0x03, /* Usage Maximum Button 3 */ > 0x15, 0x00, /* Logical Minimum 0 */ > 0x25, 0x01, /* Logical Maximum 1 */ > 0x95, 0x03, /* Report Count 3 */ > 0x75, 0x01, /* Report Size 1 */ > 0x81, 0x02, /* Input (Data, Var, Abs) */ > 0x95, 0x01, /* Report Count 1 */ > 0x75, 0x05, /* Report Size 5 */ > 0x81, 0x01, /* Input (Cnst, Var, Abs) */ > 0x05, 0x01, /* Usage Page Generic Desktop */ > 0x09, 0x30, /* Usage X */ > 0x09, 0x31, /* Usage Y */ > 0x15, 0x00, /* Logical Minimum 0 */ > 0x27, 0xFF, 0xFF, 0x00, 0x00, /* Logical Maximum 0xffff */ > 0x75, 0x10, /* Report Size 32 */ > 0x95, 0x02, /* Report Count 2 */ > 0x81, 0x02, /* Input (Data, Var, Abs) */ > // 0x09, 0x32, /* Usage Z */ > // 0x15, 0x81, /* Logical Minimum -127 */ > // 0x25, 0x7F, /* Logical Maximum 127 */ > // 0x75, 0x08, /* Report Size 8 */ > // 0x95, 0x01, /* Report Count 1 */ > 0xC0, /* End Collection */ > 0xC0, /* End Collection */ > }; > #endif > > static int usb_mouse_poll(USBMouseState *s, uint8_t *buf, int len) > { > int dx, dy, dz, b, l, aa, bb, cc, dd; > > dx = int_clamp(s->dx, -128, 127); > dy = int_clamp(s->dy, -128, 127); > dz = int_clamp(s->dz, -128, 127); > > s->dx -= dx; > s->dy -= dy; > s->dz -= dz; > b = 0; > if (s->buttons_state & MOUSE_EVENT_LBUTTON) > b |= 0x01; > if (s->buttons_state & MOUSE_EVENT_RBUTTON) > b |= 0x02; > if (s->buttons_state & MOUSE_EVENT_MBUTTON) > b |= 0x04; > > buf[0] = b; > buf[1] = s->X & 0xff; > buf[2] = s->X >> 8; > buf[3] = s->Y & 0xff; > buf[4] = s->Y >> 8; > aa=buf[1]; > bb=buf[2]; > cc=buf[3]; > dd=buf[4]; > l = 5; > > return l; > } > ^ permalink raw reply [flat|nested] 68+ messages in thread
* Re: [Qemu-devel] Gentlemen we have absolute movement! was:Absolute USB-HID device musings (was Re: VNC Terminal Server) 2006-04-09 20:27 ` [Qemu-devel] Gentlemen we have absolute movement! was:Absolute " Brad Campbell 2006-04-09 20:31 ` Anthony Liguori @ 2006-04-09 20:57 ` Anthony Liguori 2006-04-09 21:02 ` Brad Campbell 2006-04-09 21:10 ` Brad Campbell 1 sibling, 2 replies; 68+ messages in thread From: Anthony Liguori @ 2006-04-09 20:57 UTC (permalink / raw) To: qemu-devel [-- Attachment #1: Type: text/plain, Size: 3343 bytes --] Hi Brad, I have your patch applied and the previous one and it doesn't seem to work under win2k. Can you post a patch of what you have? I've got what I have attached. I did a little bit of SDL plumbing based on my touchscreen patch. Regards, Anthony Liguori Brad Campbell wrote: > Brad Campbell wrote: >> Lonnie Mendez wrote: >> >>> Please see the patch posted yesterday to this mailing list: >>> >>> http://gnome.dnsalias.net/patches/qemu-hidmousexp.patch >> >> Ta for that.. not sure how I missed it. >> Now to try and get it to work.. >> > > Ok.. 1st cut.. it's not great, and it's not hooked up to anything at > the moment (the mouse just tootles around the screen on a timer) BUT! > we have absolute movement. > > The *stunning* news is it's resolution independent.. 640x480 - 800x600 > - 1024x768 > 0,0 is top left and 7fff.7fff is bottom right.. no client scaling > required.. > > Think I've figured out the Z axis thing also.. and we are good for > relative movement on that still > (The Z axis below is way wrong, but I think I have figured it out) > > static const uint8_t qemu_mouse_hid_report_descriptor[] = { > 0x05, 0x01, /* Usage Page Generic Desktop */ > 0x09, 0x01, /* Usage Mouse */ > 0xA1, 0x01, /* Collection Application */ > 0x09, 0x01, /* Usage Pointer */ > 0xA1, 0x00, /* Collection Physical */ > 0x05, 0x09, /* Usage Page Button */ > 0x19, 0x01, /* Usage Minimum Button 1 */ > 0x29, 0x03, /* Usage Maximum Button 3 */ > 0x15, 0x00, /* Logical Minimum 0 */ > 0x25, 0x01, /* Logical Maximum 1 */ > 0x95, 0x03, /* Report Count 3 */ > 0x75, 0x01, /* Report Size 1 */ > 0x81, 0x02, /* Input (Data, Var, Abs) */ > 0x95, 0x01, /* Report Count 1 */ > 0x75, 0x05, /* Report Size 5 */ > 0x81, 0x01, /* Input (Cnst, Var, Abs) */ > 0x05, 0x01, /* Usage Page Generic Desktop */ > 0x09, 0x30, /* Usage X */ > 0x09, 0x31, /* Usage Y */ > 0x15, 0x00, /* Logical Minimum 0 */ > 0x27, 0xFF, 0xFF, 0x00, 0x00, /* Logical Maximum 0xffff */ > 0x75, 0x10, /* Report Size 32 */ > 0x95, 0x02, /* Report Count 2 */ > 0x81, 0x02, /* Input (Data, Var, Abs) */ > // 0x09, 0x32, /* Usage Z */ > // 0x15, 0x81, /* Logical Minimum -127 */ > // 0x25, 0x7F, /* Logical Maximum 127 */ > // 0x75, 0x08, /* Report Size 8 */ > // 0x95, 0x01, /* Report Count 1 */ > 0xC0, /* End Collection */ > 0xC0, /* End Collection */ > }; > #endif > > static int usb_mouse_poll(USBMouseState *s, uint8_t *buf, int len) > { > int dx, dy, dz, b, l, aa, bb, cc, dd; > > dx = int_clamp(s->dx, -128, 127); > dy = int_clamp(s->dy, -128, 127); > dz = int_clamp(s->dz, -128, 127); > > s->dx -= dx; > s->dy -= dy; > s->dz -= dz; > b = 0; > if (s->buttons_state & MOUSE_EVENT_LBUTTON) > b |= 0x01; > if (s->buttons_state & MOUSE_EVENT_RBUTTON) > b |= 0x02; > if (s->buttons_state & MOUSE_EVENT_MBUTTON) > b |= 0x04; > > buf[0] = b; > buf[1] = s->X & 0xff; > buf[2] = s->X >> 8; > buf[3] = s->Y & 0xff; > buf[4] = s->Y >> 8; > aa=buf[1]; > bb=buf[2]; > cc=buf[3]; > dd=buf[4]; > l = 5; > > return l; > } > [-- Attachment #2: qemu-usb-abs.diff --] [-- Type: text/plain, Size: 7547 bytes --] diff -r 8937c657c23f hw/usb-hid.c --- a/hw/usb-hid.c Sun Mar 26 01:31:22 2006 +0000 +++ b/hw/usb-hid.c Sun Apr 9 15:57:13 2006 -0500 @@ -33,6 +33,7 @@ typedef struct USBMouseState { USBDevice dev; int dx, dy, dz, buttons_state; + int X, Y; } USBMouseState; /* mostly the same values as the Bochs USB Mouse device */ @@ -92,14 +93,6 @@ 0x01, /* u8 if_bInterfaceSubClass; */ 0x02, /* u8 if_bInterfaceProtocol; [usb1.1 or single tt] */ 0x05, /* u8 if_iInterface; */ - - /* one endpoint (status change endpoint) */ - 0x07, /* u8 ep_bLength; */ - 0x05, /* u8 ep_bDescriptorType; Endpoint */ - 0x81, /* u8 ep_bEndpointAddress; IN Endpoint 1 */ - 0x03, /* u8 ep_bmAttributes; Interrupt */ - 0x03, 0x00, /* u16 ep_wMaxPacketSize; */ - 0x0a, /* u8 ep_bInterval; (255ms -- usb 2.0 spec) */ /* HID descriptor */ 0x09, /* u8 bLength; */ @@ -109,8 +102,17 @@ 0x01, /* u8 num_descriptors */ 0x22, /* u8 type; Report */ 50, 0, /* u16 len */ + + /* one endpoint (status change endpoint) */ + 0x07, /* u8 ep_bLength; */ + 0x05, /* u8 ep_bDescriptorType; Endpoint */ + 0x81, /* u8 ep_bEndpointAddress; IN Endpoint 1 */ + 0x03, /* u8 ep_bmAttributes; Interrupt */ + 0x03, 0x00, /* u16 ep_wMaxPacketSize; */ + 0x0a, /* u8 ep_bInterval; (255ms -- usb 2.0 spec) */ }; +#if 0 static const uint8_t qemu_mouse_hid_report_descriptor[] = { 0x05, 0x01, 0x09, 0x02, 0xA1, 0x01, 0x09, 0x01, 0xA1, 0x00, 0x05, 0x09, 0x19, 0x01, 0x29, 0x03, @@ -120,6 +122,41 @@ 0x25, 0x7F, 0x75, 0x08, 0x95, 0x02, 0x81, 0x06, 0xC0, 0xC0, }; +#else +static const uint8_t qemu_mouse_hid_report_descriptor[] = { + 0x05, 0x01, /* Usage Page Generic Desktop */ + 0x09, 0x01, /* Usage Mouse */ + 0xA1, 0x01, /* Collection Application */ + 0x09, 0x01, /* Usage Pointer */ + 0xA1, 0x00, /* Collection Physical */ + 0x05, 0x09, /* Usage Page Button */ + 0x19, 0x01, /* Usage Minimum Button 1 */ + 0x29, 0x03, /* Usage Maximum Button 3 */ + 0x15, 0x00, /* Logical Minimum 0 */ + 0x25, 0x01, /* Logical Maximum 1 */ + 0x95, 0x03, /* Report Count 3 */ + 0x75, 0x01, /* Report Size 1 */ + 0x81, 0x02, /* Input (Data, Var, Abs) */ + 0x95, 0x01, /* Report Count 1 */ + 0x75, 0x05, /* Report Size 5 */ + 0x81, 0x01, /* Input (Cnst, Var, Abs) */ + 0x05, 0x01, /* Usage Page Generic Desktop */ + 0x09, 0x30, /* Usage X */ + 0x09, 0x31, /* Usage Y */ + 0x15, 0x00, /* Logical Minimum 0 */ + 0x27, 0xFF, 0xFF, 0x00, 0x00, /* Logical Maximum 0xffff */ + 0x75, 0x10, /* Report Size 32 */ + 0x95, 0x02, /* Report Count 2 */ + 0x81, 0x02, /* Input (Data, Var, Abs) */ +// 0x09, 0x32, /* Usage Z */ +// 0x15, 0x81, /* Logical Minimum -127 */ +// 0x25, 0x7F, /* Logical Maximum 127 */ +// 0x75, 0x08, /* Report Size 8 */ +// 0x95, 0x01, /* Report Count 1 */ + 0xC0, /* End Collection */ + 0xC0, /* End Collection */ +}; +#endif static void usb_mouse_event(void *opaque, int dx1, int dy1, int dz1, int buttons_state) @@ -129,6 +166,8 @@ s->dx += dx1; s->dy += dy1; s->dz += dz1; + s->X = dx1; + s->Y = dy1; s->buttons_state = buttons_state; } @@ -142,6 +181,7 @@ return val; } +#if 0 static int usb_mouse_poll(USBMouseState *s, uint8_t *buf, int len) { int dx, dy, dz, b, l; @@ -172,6 +212,37 @@ } return l; } +#else + +static int usb_mouse_poll(USBMouseState *s, uint8_t *buf, int len) +{ + int dx, dy, dz, b, l; + + dx = int_clamp(s->dx, -128, 127); + dy = int_clamp(s->dy, -128, 127); + dz = int_clamp(s->dz, -128, 127); + + s->dx -= dx; + s->dy -= dy; + s->dz -= dz; + b = 0; + if (s->buttons_state & MOUSE_EVENT_LBUTTON) + b |= 0x01; + if (s->buttons_state & MOUSE_EVENT_RBUTTON) + b |= 0x02; + if (s->buttons_state & MOUSE_EVENT_MBUTTON) + b |= 0x04; + + buf[0] = b; + buf[1] = s->X & 0xff; + buf[2] = s->X >> 8; + buf[3] = s->Y & 0xff; + buf[4] = s->Y >> 8; + l = 5; + + return l; +} +#endif static void usb_mouse_handle_reset(USBDevice *dev) { @@ -180,6 +251,8 @@ s->dx = 0; s->dy = 0; s->dz = 0; + s->X = 0; + s->Y = 0; s->buttons_state = 0; } @@ -341,7 +414,8 @@ s->dev.handle_control = usb_mouse_handle_control; s->dev.handle_data = usb_mouse_handle_data; - qemu_add_mouse_event_handler(usb_mouse_event, s); + qemu_add_mouse_event_handler(NULL, NULL); + qemu_add_mouse_abs_event_handler(usb_mouse_event, s); return (USBDevice *)s; } diff -r 8937c657c23f sdl.c --- a/sdl.c Sun Mar 26 01:31:22 2006 +0000 +++ b/sdl.c Sun Apr 9 15:57:13 2006 -0500 @@ -301,6 +301,9 @@ if (state & SDL_BUTTON(SDL_BUTTON_MIDDLE)) buttons |= MOUSE_EVENT_MBUTTON; kbd_mouse_event(dx, dy, dz, buttons); + + SDL_GetMouseState(&dx, &dy); + kbd_mouse_abs_event(dx, dy, dz, buttons); } static void toggle_full_screen(DisplayState *ds) diff -r 8937c657c23f vl.c --- a/vl.c Sun Mar 26 01:31:22 2006 +0000 +++ b/vl.c Sun Apr 9 15:57:13 2006 -0500 @@ -475,6 +475,8 @@ static void *qemu_put_kbd_event_opaque; static QEMUPutMouseEvent *qemu_put_mouse_event; static void *qemu_put_mouse_event_opaque; +static QEMUPutMouseAbsEvent *qemu_put_mouse_abs_event; +static void *qemu_put_mouse_abs_event_opaque; void qemu_add_kbd_event_handler(QEMUPutKBDEvent *func, void *opaque) { @@ -486,6 +488,12 @@ { qemu_put_mouse_event_opaque = opaque; qemu_put_mouse_event = func; +} + +void qemu_add_mouse_abs_event_handler(QEMUPutMouseAbsEvent *func, void *opaque) +{ + qemu_put_mouse_abs_event_opaque = opaque; + qemu_put_mouse_abs_event = func; } void kbd_put_keycode(int keycode) @@ -500,6 +508,14 @@ if (qemu_put_mouse_event) { qemu_put_mouse_event(qemu_put_mouse_event_opaque, dx, dy, dz, buttons_state); + } +} + +void kbd_mouse_abs_event(int x, int y, int dz, int buttons_state) +{ + if (qemu_put_mouse_abs_event) { + qemu_put_mouse_abs_event(qemu_put_mouse_abs_event_opaque, + x, y, dz, buttons_state); } } @@ -1308,7 +1324,7 @@ /* for STDIO, we handle the case where several clients use it (nographic mode) */ -#define TERM_ESCAPE 0x01 /* ctrl-a is used for escape */ +#define TERM_ESCAPE 0x1d /* ctrl-a is used for escape */ #define TERM_FIFO_MAX_SIZE 1 diff -r 8937c657c23f vl.h --- a/vl.h Sun Mar 26 01:31:22 2006 +0000 +++ b/vl.h Sun Apr 9 15:57:13 2006 -0500 @@ -156,12 +156,15 @@ typedef void QEMUPutKBDEvent(void *opaque, int keycode); typedef void QEMUPutMouseEvent(void *opaque, int dx, int dy, int dz, int buttons_state); +typedef void QEMUPutMouseAbsEvent(void *opaque, int x, int y, int dz, int buttons_state); void qemu_add_kbd_event_handler(QEMUPutKBDEvent *func, void *opaque); void qemu_add_mouse_event_handler(QEMUPutMouseEvent *func, void *opaque); +void qemu_add_mouse_abs_event_handler(QEMUPutMouseAbsEvent *func, void *opaque); void kbd_put_keycode(int keycode); void kbd_mouse_event(int dx, int dy, int dz, int buttons_state); +void kbd_mouse_abs_event(int x, int y, int dz, int buttons_state); /* keysym is a unicode code except for special keys (see QEMU_KEY_xxx constants) */ ^ permalink raw reply [flat|nested] 68+ messages in thread
* Re: [Qemu-devel] Gentlemen we have absolute movement! was:Absolute USB-HID device musings (was Re: VNC Terminal Server) 2006-04-09 20:57 ` Anthony Liguori @ 2006-04-09 21:02 ` Brad Campbell 2006-04-09 21:10 ` Brad Campbell 1 sibling, 0 replies; 68+ messages in thread From: Brad Campbell @ 2006-04-09 21:02 UTC (permalink / raw) To: qemu-devel Anthony Liguori wrote: > Hi Brad, > > I have your patch applied and the previous one and it doesn't seem to > work under win2k. Can you post a patch of what you have? > > I've got what I have attached. I did a little bit of SDL plumbing based > on my touchscreen patch. Really sorry about that.. it was not a patch as just an indicator of what I was doing.. here is what I have against latest cvs.. I've applied malc's grabless patch also and hacked around just to get it to work.. try to pretend it's not 1am here and I've not just left crap all over the place :) http://fnarfbargle.dyndns.org:81/qemu/hid-grabless-001.patch -- "Human beings, who are almost unique in having the ability to learn from the experience of others, are also remarkable for their apparent disinclination to do so." -- Douglas Adams ^ permalink raw reply [flat|nested] 68+ messages in thread
* Re: [Qemu-devel] Gentlemen we have absolute movement! was:Absolute USB-HID device musings (was Re: VNC Terminal Server) 2006-04-09 20:57 ` Anthony Liguori 2006-04-09 21:02 ` Brad Campbell @ 2006-04-09 21:10 ` Brad Campbell 2006-04-09 21:20 ` Johannes Schindelin 2006-04-09 21:39 ` Anthony Liguori 1 sibling, 2 replies; 68+ messages in thread From: Brad Campbell @ 2006-04-09 21:10 UTC (permalink / raw) To: qemu-devel Anthony Liguori wrote: > Hi Brad, > > I have your patch applied and the previous one and it doesn't seem to > work under win2k. Can you post a patch of what you have? > > I've got what I have attached. I did a little bit of SDL plumbing based > on my touchscreen patch. > Ok.. now I've embarrassed myself by publicly releasing my spaghetti, I've had a look at what you are up to.. The VNC patch extends the existing mouse handler by passing it abs coordinates as well, (this is the basis of what I used) so there are no additional routines.. I figure if you pass both relative (faked if need be) and abs to the routine then the mouse can use whatever it likes. It looks like you are adding a completely separate handler there ? I had to stop the ps2 mouse handler registering itself to let the usb one have a go. But now its working. I've left both cursors live so you can see how well it mates up. There is a minor elastic discrepancy toward the bottom right of the screen, but I'm *sure* its just due to my off the top of my head hacky position calculations and it can be refined further.. I figure a command line switch for usbmouse/usbabs/ps2 might be in order so you can change depending on your os. Hopefully the evdev patch in X gets up and running and we can just default to abs mode. I'll get hold of a wheel mouse tomorrow (my trackpad does not have a Z) and see if I can get the Z axis going.. Tested under win2k-SP4. How cool is it to be grabless and change resolutions on the fly.. I'll clean it up tomorrow and graft it into the vnc patch also.. virtual servers here we come! Brad -- "Human beings, who are almost unique in having the ability to learn from the experience of others, are also remarkable for their apparent disinclination to do so." -- Douglas Adams ^ permalink raw reply [flat|nested] 68+ messages in thread
* Re: [Qemu-devel] Gentlemen we have absolute movement! was:Absolute USB-HID device musings (was Re: VNC Terminal Server) 2006-04-09 21:10 ` Brad Campbell @ 2006-04-09 21:20 ` Johannes Schindelin 2006-04-09 21:35 ` Brad Campbell 2006-04-09 21:39 ` Anthony Liguori 1 sibling, 1 reply; 68+ messages in thread From: Johannes Schindelin @ 2006-04-09 21:20 UTC (permalink / raw) To: qemu-devel Hi, On Mon, 10 Apr 2006, Brad Campbell wrote: > The VNC patch extends the existing mouse handler by passing it abs > coordinates as well, (this is the basis of what I used) so there are no > additional routines.. I figure if you pass both relative (faked if need > be) and abs to the routine then the mouse can use whatever it likes. That was a kludge. I always meant to do some cleanup there as soon as I got Summagraphics to work with win98 (which has not yet happened :-( ). I'd rather have two calls, one for absolute and one for relative, where relative checks if the current active mouse is relative or absolute, and in the latter case just calls absolute and vice versa. Ciao, Dscho ^ permalink raw reply [flat|nested] 68+ messages in thread
* Re: [Qemu-devel] Gentlemen we have absolute movement! was:Absolute USB-HID device musings (was Re: VNC Terminal Server) 2006-04-09 21:20 ` Johannes Schindelin @ 2006-04-09 21:35 ` Brad Campbell 0 siblings, 0 replies; 68+ messages in thread From: Brad Campbell @ 2006-04-09 21:35 UTC (permalink / raw) To: qemu-devel Johannes Schindelin wrote: > Hi, > > On Mon, 10 Apr 2006, Brad Campbell wrote: > >> The VNC patch extends the existing mouse handler by passing it abs >> coordinates as well, (this is the basis of what I used) so there are no >> additional routines.. I figure if you pass both relative (faked if need >> be) and abs to the routine then the mouse can use whatever it likes. > > That was a kludge. I always meant to do some cleanup there as soon as I > got Summagraphics to work with win98 (which has not yet happened :-( ). Ok, well I'll look at the work that Anthony has put in already and see what we come up with. Speaking of Win98. I just tried this under win98, and after it installed its usb kit and the HID driver it kinda works.. looks like win98 expects 0x0-0xffff while 2k expects 0x0-0x7fff for the position information.. buttons are ok and tracking is good, just the target pointer only moves half the distance. A problem perhaps, but one that could be worked around in a pinch.. -- "Human beings, who are almost unique in having the ability to learn from the experience of others, are also remarkable for their apparent disinclination to do so." -- Douglas Adams ^ permalink raw reply [flat|nested] 68+ messages in thread
* Re: [Qemu-devel] Gentlemen we have absolute movement! was:Absolute USB-HID device musings (was Re: VNC Terminal Server) 2006-04-09 21:10 ` Brad Campbell 2006-04-09 21:20 ` Johannes Schindelin @ 2006-04-09 21:39 ` Anthony Liguori 2006-04-09 22:01 ` Brad Campbell 1 sibling, 1 reply; 68+ messages in thread From: Anthony Liguori @ 2006-04-09 21:39 UTC (permalink / raw) To: qemu-devel [-- Attachment #1: Type: text/plain, Size: 2742 bytes --] Brad Campbell wrote: > Anthony Liguori wrote: >> Hi Brad, >> >> I have your patch applied and the previous one and it doesn't seem to >> work under win2k. Can you post a patch of what you have? >> >> I've got what I have attached. I did a little bit of SDL plumbing >> based on my touchscreen patch. >> > > Ok.. now I've embarrassed myself by publicly releasing my spaghetti, > I've had a look at what you are up to.. > The VNC patch extends the existing mouse handler by passing it abs > coordinates as well, (this is the basis of what I used) so there are > no additional routines.. I figure if you pass both relative (faked if > need be) and abs to the routine then the mouse can use whatever it likes. I don't really like that myself. > > It looks like you are adding a completely separate handler there ? Yeah, I figure if a device is interested only in relative movements (like the PS/2 mouse), that's all it should get. > I had to stop the ps2 mouse handler registering itself to let the usb > one have a go. But now its working. I've left both cursors live so you > can see how well it mates up. There is a minor elastic discrepancy > toward the bottom right of the screen, but I'm *sure* its just due to > my off the top of my head hacky position calculations and it can be > refined further.. Everything seems to work fine for me. Both mice get their own coordinates and the guest choices which one it wants. In Windows, once you log in the first time, it detects the mouse and switches over to the USB mouse. I've added the necessary stuff to SDL so that the switch over occurs gracefully. Once the USB mouse starts being used, SDL no longer triggers grab on left click (but still on ctrl-alt) and always reports mouse movements. I also got rid of the ShowCursor() calls as that warps the host mouse. > I figure a command line switch for usbmouse/usbabs/ps2 might be in > order so you can change depending on your os. Hopefully the evdev > patch in X gets up and running and we can just default to abs mode. I'm not sure a command line switch is needed. I think we can have it automatically do the right thing. Attached is my latest patch. I did some awful things to SDL that I'd like to clean up. The only real "feature" I'd like to add is automatic breaking of grap when the USB mouse is detected. > > I'll get hold of a wheel mouse tomorrow (my trackpad does not have a > Z) and see if I can get the Z axis going.. > > Tested under win2k-SP4. How cool is it to be grabless and change > resolutions on the fly.. > I'll clean it up tomorrow and graft it into the vnc patch also.. > virtual servers here we come! Seriously, awesome job here :-) Regards, Anthony Liguori > > Brad [-- Attachment #2: qemu-abs-hid.diff --] [-- Type: text/plain, Size: 10219 bytes --] diff -r 8937c657c23f hw/usb-hid.c --- a/hw/usb-hid.c Sun Mar 26 01:31:22 2006 +0000 +++ b/hw/usb-hid.c Sun Apr 9 16:29:35 2006 -0500 @@ -33,6 +33,7 @@ typedef struct USBMouseState { USBDevice dev; int dx, dy, dz, buttons_state; + int X, Y; } USBMouseState; /* mostly the same values as the Bochs USB Mouse device */ @@ -92,14 +93,6 @@ 0x01, /* u8 if_bInterfaceSubClass; */ 0x02, /* u8 if_bInterfaceProtocol; [usb1.1 or single tt] */ 0x05, /* u8 if_iInterface; */ - - /* one endpoint (status change endpoint) */ - 0x07, /* u8 ep_bLength; */ - 0x05, /* u8 ep_bDescriptorType; Endpoint */ - 0x81, /* u8 ep_bEndpointAddress; IN Endpoint 1 */ - 0x03, /* u8 ep_bmAttributes; Interrupt */ - 0x03, 0x00, /* u16 ep_wMaxPacketSize; */ - 0x0a, /* u8 ep_bInterval; (255ms -- usb 2.0 spec) */ /* HID descriptor */ 0x09, /* u8 bLength; */ @@ -108,9 +101,18 @@ 0x00, /* u8 country_code */ 0x01, /* u8 num_descriptors */ 0x22, /* u8 type; Report */ - 50, 0, /* u16 len */ + 53, 0, /* u16 len */ + + /* one endpoint (status change endpoint) */ + 0x07, /* u8 ep_bLength; */ + 0x05, /* u8 ep_bDescriptorType; Endpoint */ + 0x81, /* u8 ep_bEndpointAddress; IN Endpoint 1 */ + 0x03, /* u8 ep_bmAttributes; Interrupt */ + 0x08, 0x00, /* u16 ep_wMaxPacketSize; */ + 0x03, /* u8 ep_bInterval; (255ms -- usb 2.0 spec) */ }; +#if 0 static const uint8_t qemu_mouse_hid_report_descriptor[] = { 0x05, 0x01, 0x09, 0x02, 0xA1, 0x01, 0x09, 0x01, 0xA1, 0x00, 0x05, 0x09, 0x19, 0x01, 0x29, 0x03, @@ -120,6 +122,41 @@ 0x25, 0x7F, 0x75, 0x08, 0x95, 0x02, 0x81, 0x06, 0xC0, 0xC0, }; +#else +static const uint8_t qemu_mouse_hid_report_descriptor[] = { + 0x05, 0x01, /* Usage Page Generic Desktop */ + 0x09, 0x01, /* Usage Mouse */ + 0xA1, 0x01, /* Collection Application */ + 0x09, 0x01, /* Usage Pointer */ + 0xA1, 0x00, /* Collection Physical */ + 0x05, 0x09, /* Usage Page Button */ + 0x19, 0x01, /* Usage Minimum Button 1 */ + 0x29, 0x03, /* Usage Maximum Button 3 */ + 0x15, 0x00, /* Logical Minimum 0 */ + 0x25, 0x01, /* Logical Maximum 1 */ + 0x95, 0x03, /* Report Count 3 */ + 0x75, 0x01, /* Report Size 1 */ + 0x81, 0x02, /* Input (Data, Var, Abs) */ + 0x95, 0x01, /* Report Count 1 */ + 0x75, 0x05, /* Report Size 5 */ + 0x81, 0x01, /* Input (Cnst, Var, Abs) */ + 0x05, 0x01, /* Usage Page Generic Desktop */ + 0x09, 0x30, /* Usage X */ + 0x09, 0x31, /* Usage Y */ + 0x15, 0x00, /* Logical Minimum 0 */ + 0x27, 0xFF, 0xFF, 0x00, 0x00, /* Logical Maximum 0xffff */ + 0x75, 0x10, /* Report Size 32 */ + 0x95, 0x02, /* Report Count 2 */ + 0x81, 0x02, /* Input (Data, Var, Abs) */ +// 0x09, 0x32, /* Usage Z */ +// 0x15, 0x81, /* Logical Minimum -127 */ +// 0x25, 0x7F, /* Logical Maximum 127 */ +// 0x75, 0x08, /* Report Size 8 */ +// 0x95, 0x01, /* Report Count 1 */ + 0xC0, /* End Collection */ + 0xC0, /* End Collection */ +}; +#endif static void usb_mouse_event(void *opaque, int dx1, int dy1, int dz1, int buttons_state) @@ -129,6 +166,8 @@ s->dx += dx1; s->dy += dy1; s->dz += dz1; + s->X = dx1; + s->Y = dy1; s->buttons_state = buttons_state; } @@ -142,6 +181,7 @@ return val; } +#if 0 static int usb_mouse_poll(USBMouseState *s, uint8_t *buf, int len) { int dx, dy, dz, b, l; @@ -172,6 +212,40 @@ } return l; } +#else + +static int usb_mouse_poll(USBMouseState *s, uint8_t *buf, int len) +{ + int dx, dy, dz, b, l; + + /* FIXME this is ugly */ + absolute_mouse = 1; + + dx = int_clamp(s->dx, -128, 127); + dy = int_clamp(s->dy, -128, 127); + dz = int_clamp(s->dz, -128, 127); + + s->dx -= dx; + s->dy -= dy; + s->dz -= dz; + b = 0; + if (s->buttons_state & MOUSE_EVENT_LBUTTON) + b |= 0x01; + if (s->buttons_state & MOUSE_EVENT_RBUTTON) + b |= 0x02; + if (s->buttons_state & MOUSE_EVENT_MBUTTON) + b |= 0x04; + + buf[0] = b; + buf[1] = s->X & 0xff; + buf[2] = s->X >> 8; + buf[3] = s->Y & 0xff; + buf[4] = s->Y >> 8; + l = 5; + + return l; +} +#endif static void usb_mouse_handle_reset(USBDevice *dev) { @@ -180,6 +254,8 @@ s->dx = 0; s->dy = 0; s->dz = 0; + s->X = 0; + s->Y = 0; s->buttons_state = 0; } @@ -341,7 +417,8 @@ s->dev.handle_control = usb_mouse_handle_control; s->dev.handle_data = usb_mouse_handle_data; - qemu_add_mouse_event_handler(usb_mouse_event, s); + qemu_add_mouse_event_handler(NULL, NULL); + qemu_add_mouse_abs_event_handler(usb_mouse_event, s); return (USBDevice *)s; } diff -r 8937c657c23f sdl.c --- a/sdl.c Sun Mar 26 01:31:22 2006 +0000 +++ b/sdl.c Sun Apr 9 16:29:35 2006 -0500 @@ -39,6 +39,10 @@ static int gui_fullscreen_initial_grab; static int gui_grab_code = KMOD_LALT | KMOD_LCTRL; static uint8_t modifiers_state[256]; +static int width, height; +static SDL_Cursor *sdl_cursor_normal; +static SDL_Cursor *sdl_cursor_hidden; +static int cursor_hidden = 0; static void sdl_update(DisplayState *ds, int x, int y, int w, int h) { @@ -55,6 +59,9 @@ flags = SDL_HWSURFACE|SDL_ASYNCBLIT|SDL_HWACCEL; if (gui_fullscreen) flags |= SDL_FULLSCREEN; + + width = w; + height = h; again: screen = SDL_SetVideoMode(w, h, 0, flags); @@ -273,7 +280,9 @@ static void sdl_grab_start(void) { - SDL_ShowCursor(0); + sdl_cursor_normal = SDL_GetCursor(); + SDL_SetCursor(sdl_cursor_hidden); + cursor_hidden = 1; SDL_WM_GrabInput(SDL_GRAB_ON); /* dummy read to avoid moving the mouse */ SDL_GetRelativeMouseState(NULL, NULL); @@ -284,7 +293,10 @@ static void sdl_grab_end(void) { SDL_WM_GrabInput(SDL_GRAB_OFF); - SDL_ShowCursor(1); + if (!absolute_mouse) { + SDL_SetCursor(sdl_cursor_normal); + cursor_hidden = 1; + } gui_grab = 0; sdl_update_caption(); } @@ -301,6 +313,17 @@ if (state & SDL_BUTTON(SDL_BUTTON_MIDDLE)) buttons |= MOUSE_EVENT_MBUTTON; kbd_mouse_event(dx, dy, dz, buttons); + + SDL_GetMouseState(&dx, &dy); + kbd_mouse_abs_event(dx * 0x7FFF / width, + dy * 0x7FFF / height, + dz, buttons); + if (absolute_mouse && !cursor_hidden) { + sdl_cursor_normal = SDL_GetCursor(); + SDL_SetCursor(sdl_cursor_hidden); + cursor_hidden = 1; + } + } static void toggle_full_screen(DisplayState *ds) @@ -427,7 +450,7 @@ qemu_system_shutdown_request(); break; case SDL_MOUSEMOTION: - if (gui_grab) { + if (gui_grab || absolute_mouse) { sdl_send_mouse_event(0); } break; @@ -435,7 +458,7 @@ case SDL_MOUSEBUTTONUP: { SDL_MouseButtonEvent *bev = &ev->button; - if (!gui_grab) { + if (!gui_grab && !absolute_mouse) { if (ev->type == SDL_MOUSEBUTTONDOWN && (bev->state & SDL_BUTTON_LMASK)) { /* start grabbing all events */ @@ -475,6 +498,7 @@ void sdl_display_init(DisplayState *ds, int full_screen) { int flags; + uint8_t data = 0; #if defined(__APPLE__) /* always use generic keymaps */ @@ -508,6 +532,8 @@ SDL_EnableUNICODE(1); gui_grab = 0; + sdl_cursor_hidden = SDL_CreateCursor(&data, &data, 8, 1, 0, 0); + atexit(sdl_cleanup); if (full_screen) { gui_fullscreen = 1; diff -r 8937c657c23f vl.c --- a/vl.c Sun Mar 26 01:31:22 2006 +0000 +++ b/vl.c Sun Apr 9 16:29:35 2006 -0500 @@ -148,6 +148,7 @@ USBDevice *vm_usb_hub; static VLANState *first_vlan; int smp_cpus = 1; +int absolute_mouse = 0; #if defined(TARGET_SPARC) #define MAX_CPUS 16 #elif defined(TARGET_I386) @@ -475,6 +476,8 @@ static void *qemu_put_kbd_event_opaque; static QEMUPutMouseEvent *qemu_put_mouse_event; static void *qemu_put_mouse_event_opaque; +static QEMUPutMouseAbsEvent *qemu_put_mouse_abs_event; +static void *qemu_put_mouse_abs_event_opaque; void qemu_add_kbd_event_handler(QEMUPutKBDEvent *func, void *opaque) { @@ -486,6 +489,12 @@ { qemu_put_mouse_event_opaque = opaque; qemu_put_mouse_event = func; +} + +void qemu_add_mouse_abs_event_handler(QEMUPutMouseAbsEvent *func, void *opaque) +{ + qemu_put_mouse_abs_event_opaque = opaque; + qemu_put_mouse_abs_event = func; } void kbd_put_keycode(int keycode) @@ -500,6 +509,14 @@ if (qemu_put_mouse_event) { qemu_put_mouse_event(qemu_put_mouse_event_opaque, dx, dy, dz, buttons_state); + } +} + +void kbd_mouse_abs_event(int x, int y, int dz, int buttons_state) +{ + if (qemu_put_mouse_abs_event) { + qemu_put_mouse_abs_event(qemu_put_mouse_abs_event_opaque, + x, y, dz, buttons_state); } } diff -r 8937c657c23f vl.h --- a/vl.h Sun Mar 26 01:31:22 2006 +0000 +++ b/vl.h Sun Apr 9 16:29:35 2006 -0500 @@ -138,6 +138,7 @@ extern int win2k_install_hack; extern int usb_enabled; extern int smp_cpus; +extern int absolute_mouse; /* XXX: make it dynamic */ #if defined (TARGET_PPC) @@ -156,12 +157,15 @@ typedef void QEMUPutKBDEvent(void *opaque, int keycode); typedef void QEMUPutMouseEvent(void *opaque, int dx, int dy, int dz, int buttons_state); +typedef void QEMUPutMouseAbsEvent(void *opaque, int x, int y, int dz, int buttons_state); void qemu_add_kbd_event_handler(QEMUPutKBDEvent *func, void *opaque); void qemu_add_mouse_event_handler(QEMUPutMouseEvent *func, void *opaque); +void qemu_add_mouse_abs_event_handler(QEMUPutMouseAbsEvent *func, void *opaque); void kbd_put_keycode(int keycode); void kbd_mouse_event(int dx, int dy, int dz, int buttons_state); +void kbd_mouse_abs_event(int x, int y, int dz, int buttons_state); /* keysym is a unicode code except for special keys (see QEMU_KEY_xxx constants) */ ^ permalink raw reply [flat|nested] 68+ messages in thread
* Re: [Qemu-devel] Gentlemen we have absolute movement! was:Absolute USB-HID device musings (was Re: VNC Terminal Server) 2006-04-09 21:39 ` Anthony Liguori @ 2006-04-09 22:01 ` Brad Campbell 2006-04-09 22:08 ` Anthony Liguori 0 siblings, 1 reply; 68+ messages in thread From: Brad Campbell @ 2006-04-09 22:01 UTC (permalink / raw) To: qemu-devel Anthony Liguori wrote: > + kbd_mouse_abs_event(dx * 0x7FFF / width, > + dy * 0x7FFF / height, I had just made that same mod to my tree.. solved the tracking problem perfectly. Now if only it would work under win98 without modification.. Look what I just stumbled across.. irrelevant now I guess.. http://msdn.microsoft.com/library/default.asp?url=/library/en-us/Hid_d/hh/HID_d/km-ovr_8d838937-f6b9-4245-8bb0-758bf162af7e.xml.asp I wonder.. does windows switch over from ps2 to hid or just react to both and given hid is more positive about where it wants the mouse to go it wins ? I'm sure I've used a ps2 mouse and a usb mouse on windows before.. I'm thought they both worked at the same time. Like what you have with the rest of the patch.. I'll clean up my tree and go with that I think.. That should work quite well for sdl, gtk and vnc displays.. I guess cocoa also.. Now all we need is X support. I guess as a temporary measure the wacom patch works with linux.. Do you find having usb enabled makes the windows session feel a bit less responsive or jerkier ? I know the mouse tracking is not as smooth with usb.. perhaps having ps2 and usb on together will smooth that out a little. -- "Human beings, who are almost unique in having the ability to learn from the experience of others, are also remarkable for their apparent disinclination to do so." -- Douglas Adams ^ permalink raw reply [flat|nested] 68+ messages in thread
* Re: [Qemu-devel] Gentlemen we have absolute movement! was:Absolute USB-HID device musings (was Re: VNC Terminal Server) 2006-04-09 22:01 ` Brad Campbell @ 2006-04-09 22:08 ` Anthony Liguori 2006-04-09 22:12 ` Brad Campbell ` (2 more replies) 0 siblings, 3 replies; 68+ messages in thread From: Anthony Liguori @ 2006-04-09 22:08 UTC (permalink / raw) To: qemu-devel [-- Attachment #1: Type: text/plain, Size: 2251 bytes --] Brad Campbell wrote: > Anthony Liguori wrote: > >> + kbd_mouse_abs_event(dx * 0x7FFF / width, >> + dy * 0x7FFF / height, > > I had just made that same mod to my tree.. solved the tracking problem > perfectly. > > Now if only it would work under win98 without modification.. > > Look what I just stumbled across.. irrelevant now I guess.. > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/Hid_d/hh/HID_d/km-ovr_8d838937-f6b9-4245-8bb0-758bf162af7e.xml.asp > > > I wonder.. does windows switch over from ps2 to hid or just react to > both and given hid is more positive about where it wants the mouse to > go it wins ? > I'm sure I've used a ps2 mouse and a usb mouse on windows before.. I'm > thought they both worked at the same time. I think they do. I think the absolute movements just override the relative ones. However, this may just be a twist of fate so I think it's safer to disable relative reporting. > Like what you have with the rest of the patch.. I'll clean up my tree > and go with that I think.. Final one of the night. This patch disables relative mouse reporting and disables grab automatically the first time SDL detects that the absolute mouse was enabled. Needs a lot of cleanup but I'm very happy with the user experience on this one. > That should work quite well for sdl, gtk and vnc displays.. I guess > cocoa also.. > Now all we need is X support. I guess as a temporary measure the wacom > patch works with linux.. Creating a VM right now to try out the latest Xorg driver. Wacom for older Linux guests is probably not a bad idea. > Do you find having usb enabled makes the windows session feel a bit > less responsive or jerkier ? > I know the mouse tracking is not as smooth with usb.. perhaps having > ps2 and usb on together will smooth that out a little. I don't really see a difference. It actually seems a bit nicer with the USB mouse enabled (as the mouse moves with the same acceleration as under the host). One thing I noticed with the Wacom driver is that the PS/2 mouse tends to accelerate faster than the host mouse and that tends to give a feeling of a "snappier" interface. That may be what you're experiencing. Regards, Anthony Liguori [-- Attachment #2: qemu-abs-hid-1.diff --] [-- Type: text/plain, Size: 10800 bytes --] # HG changeset patch # User Anthony Liguori <anthony@codemonkey.ws> # Node ID c2a6c24121b8a56622cafddf39812a37ab887600 # Parent 8937c657c23f99c8d352cc2b68a2e8a814243ec7 USB Mouse support for with absolute coordinates. The HID modifications are all from Brad Campbell <brad@wasp.net.au> diff -r 8937c657c23f -r c2a6c24121b8 hw/usb-hid.c --- a/hw/usb-hid.c Sun Mar 26 01:31:22 2006 +0000 +++ b/hw/usb-hid.c Sun Apr 9 16:59:35 2006 -0500 @@ -33,6 +33,7 @@ typedef struct USBMouseState { USBDevice dev; int dx, dy, dz, buttons_state; + int X, Y; } USBMouseState; /* mostly the same values as the Bochs USB Mouse device */ @@ -92,14 +93,6 @@ 0x01, /* u8 if_bInterfaceSubClass; */ 0x02, /* u8 if_bInterfaceProtocol; [usb1.1 or single tt] */ 0x05, /* u8 if_iInterface; */ - - /* one endpoint (status change endpoint) */ - 0x07, /* u8 ep_bLength; */ - 0x05, /* u8 ep_bDescriptorType; Endpoint */ - 0x81, /* u8 ep_bEndpointAddress; IN Endpoint 1 */ - 0x03, /* u8 ep_bmAttributes; Interrupt */ - 0x03, 0x00, /* u16 ep_wMaxPacketSize; */ - 0x0a, /* u8 ep_bInterval; (255ms -- usb 2.0 spec) */ /* HID descriptor */ 0x09, /* u8 bLength; */ @@ -108,9 +101,18 @@ 0x00, /* u8 country_code */ 0x01, /* u8 num_descriptors */ 0x22, /* u8 type; Report */ - 50, 0, /* u16 len */ + 53, 0, /* u16 len */ + + /* one endpoint (status change endpoint) */ + 0x07, /* u8 ep_bLength; */ + 0x05, /* u8 ep_bDescriptorType; Endpoint */ + 0x81, /* u8 ep_bEndpointAddress; IN Endpoint 1 */ + 0x03, /* u8 ep_bmAttributes; Interrupt */ + 0x08, 0x00, /* u16 ep_wMaxPacketSize; */ + 0x03, /* u8 ep_bInterval; (255ms -- usb 2.0 spec) */ }; +#if 0 static const uint8_t qemu_mouse_hid_report_descriptor[] = { 0x05, 0x01, 0x09, 0x02, 0xA1, 0x01, 0x09, 0x01, 0xA1, 0x00, 0x05, 0x09, 0x19, 0x01, 0x29, 0x03, @@ -120,6 +122,41 @@ 0x25, 0x7F, 0x75, 0x08, 0x95, 0x02, 0x81, 0x06, 0xC0, 0xC0, }; +#else +static const uint8_t qemu_mouse_hid_report_descriptor[] = { + 0x05, 0x01, /* Usage Page Generic Desktop */ + 0x09, 0x01, /* Usage Mouse */ + 0xA1, 0x01, /* Collection Application */ + 0x09, 0x01, /* Usage Pointer */ + 0xA1, 0x00, /* Collection Physical */ + 0x05, 0x09, /* Usage Page Button */ + 0x19, 0x01, /* Usage Minimum Button 1 */ + 0x29, 0x03, /* Usage Maximum Button 3 */ + 0x15, 0x00, /* Logical Minimum 0 */ + 0x25, 0x01, /* Logical Maximum 1 */ + 0x95, 0x03, /* Report Count 3 */ + 0x75, 0x01, /* Report Size 1 */ + 0x81, 0x02, /* Input (Data, Var, Abs) */ + 0x95, 0x01, /* Report Count 1 */ + 0x75, 0x05, /* Report Size 5 */ + 0x81, 0x01, /* Input (Cnst, Var, Abs) */ + 0x05, 0x01, /* Usage Page Generic Desktop */ + 0x09, 0x30, /* Usage X */ + 0x09, 0x31, /* Usage Y */ + 0x15, 0x00, /* Logical Minimum 0 */ + 0x27, 0xFF, 0xFF, 0x00, 0x00, /* Logical Maximum 0xffff */ + 0x75, 0x10, /* Report Size 32 */ + 0x95, 0x02, /* Report Count 2 */ + 0x81, 0x02, /* Input (Data, Var, Abs) */ +// 0x09, 0x32, /* Usage Z */ +// 0x15, 0x81, /* Logical Minimum -127 */ +// 0x25, 0x7F, /* Logical Maximum 127 */ +// 0x75, 0x08, /* Report Size 8 */ +// 0x95, 0x01, /* Report Count 1 */ + 0xC0, /* End Collection */ + 0xC0, /* End Collection */ +}; +#endif static void usb_mouse_event(void *opaque, int dx1, int dy1, int dz1, int buttons_state) @@ -129,6 +166,8 @@ s->dx += dx1; s->dy += dy1; s->dz += dz1; + s->X = dx1; + s->Y = dy1; s->buttons_state = buttons_state; } @@ -142,6 +181,7 @@ return val; } +#if 0 static int usb_mouse_poll(USBMouseState *s, uint8_t *buf, int len) { int dx, dy, dz, b, l; @@ -172,6 +212,44 @@ } return l; } +#else + +static int usb_mouse_poll(USBMouseState *s, uint8_t *buf, int len) +{ + int dx, dy, dz, b, l; + + /* FIXME this is ugly */ + if (absolute_mouse == 0) { + /* disable the PS/2 mouse */ + qemu_add_mouse_event_handler(NULL, NULL); + absolute_mouse = 1; + } + + dx = int_clamp(s->dx, -128, 127); + dy = int_clamp(s->dy, -128, 127); + dz = int_clamp(s->dz, -128, 127); + + s->dx -= dx; + s->dy -= dy; + s->dz -= dz; + b = 0; + if (s->buttons_state & MOUSE_EVENT_LBUTTON) + b |= 0x01; + if (s->buttons_state & MOUSE_EVENT_RBUTTON) + b |= 0x02; + if (s->buttons_state & MOUSE_EVENT_MBUTTON) + b |= 0x04; + + buf[0] = b; + buf[1] = s->X & 0xff; + buf[2] = s->X >> 8; + buf[3] = s->Y & 0xff; + buf[4] = s->Y >> 8; + l = 5; + + return l; +} +#endif static void usb_mouse_handle_reset(USBDevice *dev) { @@ -180,6 +258,8 @@ s->dx = 0; s->dy = 0; s->dz = 0; + s->X = 0; + s->Y = 0; s->buttons_state = 0; } @@ -341,7 +421,7 @@ s->dev.handle_control = usb_mouse_handle_control; s->dev.handle_data = usb_mouse_handle_data; - qemu_add_mouse_event_handler(usb_mouse_event, s); + qemu_add_mouse_abs_event_handler(usb_mouse_event, s); return (USBDevice *)s; } diff -r 8937c657c23f -r c2a6c24121b8 sdl.c --- a/sdl.c Sun Mar 26 01:31:22 2006 +0000 +++ b/sdl.c Sun Apr 9 16:59:35 2006 -0500 @@ -39,6 +39,11 @@ static int gui_fullscreen_initial_grab; static int gui_grab_code = KMOD_LALT | KMOD_LCTRL; static uint8_t modifiers_state[256]; +static int width, height; +static SDL_Cursor *sdl_cursor_normal; +static SDL_Cursor *sdl_cursor_hidden; +static int cursor_hidden = 0; +static int absolute_enabled = 0; static void sdl_update(DisplayState *ds, int x, int y, int w, int h) { @@ -55,6 +60,9 @@ flags = SDL_HWSURFACE|SDL_ASYNCBLIT|SDL_HWACCEL; if (gui_fullscreen) flags |= SDL_FULLSCREEN; + + width = w; + height = h; again: screen = SDL_SetVideoMode(w, h, 0, flags); @@ -273,7 +281,9 @@ static void sdl_grab_start(void) { - SDL_ShowCursor(0); + sdl_cursor_normal = SDL_GetCursor(); + SDL_SetCursor(sdl_cursor_hidden); + cursor_hidden = 1; SDL_WM_GrabInput(SDL_GRAB_ON); /* dummy read to avoid moving the mouse */ SDL_GetRelativeMouseState(NULL, NULL); @@ -284,7 +294,10 @@ static void sdl_grab_end(void) { SDL_WM_GrabInput(SDL_GRAB_OFF); - SDL_ShowCursor(1); + if (!absolute_mouse) { + SDL_SetCursor(sdl_cursor_normal); + cursor_hidden = 1; + } gui_grab = 0; sdl_update_caption(); } @@ -301,6 +314,25 @@ if (state & SDL_BUTTON(SDL_BUTTON_MIDDLE)) buttons |= MOUSE_EVENT_MBUTTON; kbd_mouse_event(dx, dy, dz, buttons); + + if (absolute_mouse) { + if (!absolute_enabled) { + if (!cursor_hidden) { + sdl_cursor_normal = SDL_GetCursor(); + SDL_SetCursor(sdl_cursor_hidden); + cursor_hidden = 1; + } + if (gui_grab) { + sdl_grab_end(); + } + absolute_enabled = 1; + } + + SDL_GetMouseState(&dx, &dy); + kbd_mouse_abs_event(dx * 0x7FFF / width, + dy * 0x7FFF / height, + dz, buttons); + } } static void toggle_full_screen(DisplayState *ds) @@ -427,7 +459,7 @@ qemu_system_shutdown_request(); break; case SDL_MOUSEMOTION: - if (gui_grab) { + if (gui_grab || absolute_mouse) { sdl_send_mouse_event(0); } break; @@ -435,7 +467,7 @@ case SDL_MOUSEBUTTONUP: { SDL_MouseButtonEvent *bev = &ev->button; - if (!gui_grab) { + if (!gui_grab && !absolute_mouse) { if (ev->type == SDL_MOUSEBUTTONDOWN && (bev->state & SDL_BUTTON_LMASK)) { /* start grabbing all events */ @@ -475,6 +507,7 @@ void sdl_display_init(DisplayState *ds, int full_screen) { int flags; + uint8_t data = 0; #if defined(__APPLE__) /* always use generic keymaps */ @@ -508,6 +541,8 @@ SDL_EnableUNICODE(1); gui_grab = 0; + sdl_cursor_hidden = SDL_CreateCursor(&data, &data, 8, 1, 0, 0); + atexit(sdl_cleanup); if (full_screen) { gui_fullscreen = 1; diff -r 8937c657c23f -r c2a6c24121b8 vl.c --- a/vl.c Sun Mar 26 01:31:22 2006 +0000 +++ b/vl.c Sun Apr 9 16:59:35 2006 -0500 @@ -148,6 +148,7 @@ USBDevice *vm_usb_hub; static VLANState *first_vlan; int smp_cpus = 1; +int absolute_mouse = 0; #if defined(TARGET_SPARC) #define MAX_CPUS 16 #elif defined(TARGET_I386) @@ -475,6 +476,8 @@ static void *qemu_put_kbd_event_opaque; static QEMUPutMouseEvent *qemu_put_mouse_event; static void *qemu_put_mouse_event_opaque; +static QEMUPutMouseAbsEvent *qemu_put_mouse_abs_event; +static void *qemu_put_mouse_abs_event_opaque; void qemu_add_kbd_event_handler(QEMUPutKBDEvent *func, void *opaque) { @@ -486,6 +489,12 @@ { qemu_put_mouse_event_opaque = opaque; qemu_put_mouse_event = func; +} + +void qemu_add_mouse_abs_event_handler(QEMUPutMouseAbsEvent *func, void *opaque) +{ + qemu_put_mouse_abs_event_opaque = opaque; + qemu_put_mouse_abs_event = func; } void kbd_put_keycode(int keycode) @@ -500,6 +509,14 @@ if (qemu_put_mouse_event) { qemu_put_mouse_event(qemu_put_mouse_event_opaque, dx, dy, dz, buttons_state); + } +} + +void kbd_mouse_abs_event(int x, int y, int dz, int buttons_state) +{ + if (qemu_put_mouse_abs_event) { + qemu_put_mouse_abs_event(qemu_put_mouse_abs_event_opaque, + x, y, dz, buttons_state); } } diff -r 8937c657c23f -r c2a6c24121b8 vl.h --- a/vl.h Sun Mar 26 01:31:22 2006 +0000 +++ b/vl.h Sun Apr 9 16:59:35 2006 -0500 @@ -138,6 +138,7 @@ extern int win2k_install_hack; extern int usb_enabled; extern int smp_cpus; +extern int absolute_mouse; /* XXX: make it dynamic */ #if defined (TARGET_PPC) @@ -156,12 +157,15 @@ typedef void QEMUPutKBDEvent(void *opaque, int keycode); typedef void QEMUPutMouseEvent(void *opaque, int dx, int dy, int dz, int buttons_state); +typedef void QEMUPutMouseAbsEvent(void *opaque, int x, int y, int dz, int buttons_state); void qemu_add_kbd_event_handler(QEMUPutKBDEvent *func, void *opaque); void qemu_add_mouse_event_handler(QEMUPutMouseEvent *func, void *opaque); +void qemu_add_mouse_abs_event_handler(QEMUPutMouseAbsEvent *func, void *opaque); void kbd_put_keycode(int keycode); void kbd_mouse_event(int dx, int dy, int dz, int buttons_state); +void kbd_mouse_abs_event(int x, int y, int dz, int buttons_state); /* keysym is a unicode code except for special keys (see QEMU_KEY_xxx constants) */ ^ permalink raw reply [flat|nested] 68+ messages in thread
* Re: [Qemu-devel] Gentlemen we have absolute movement! was:Absolute USB-HID device musings (was Re: VNC Terminal Server) 2006-04-09 22:08 ` Anthony Liguori @ 2006-04-09 22:12 ` Brad Campbell 2006-04-09 22:18 ` Brad Campbell 2006-04-09 23:14 ` Brad Campbell 2 siblings, 0 replies; 68+ messages in thread From: Brad Campbell @ 2006-04-09 22:12 UTC (permalink / raw) To: qemu-devel Anthony Liguori wrote: >> I wonder.. does windows switch over from ps2 to hid or just react to >> both and given hid is more positive about where it wants the mouse to >> go it wins ? >> I'm sure I've used a ps2 mouse and a usb mouse on windows before.. I'm >> thought they both worked at the same time. > > I think they do. I think the absolute movements just override the > relative ones. However, this may just be a twist of fate so I think > it's safer to disable relative reporting. > I think so.. I'm getting double clicks on every left button press here with your older patch. I'll try this revised one then I'm off to bed.. Good work! Brad -- "Human beings, who are almost unique in having the ability to learn from the experience of others, are also remarkable for their apparent disinclination to do so." -- Douglas Adams ^ permalink raw reply [flat|nested] 68+ messages in thread
* Re: [Qemu-devel] Gentlemen we have absolute movement! was:Absolute USB-HID device musings (was Re: VNC Terminal Server) 2006-04-09 22:08 ` Anthony Liguori 2006-04-09 22:12 ` Brad Campbell @ 2006-04-09 22:18 ` Brad Campbell 2006-04-09 23:14 ` Brad Campbell 2 siblings, 0 replies; 68+ messages in thread From: Brad Campbell @ 2006-04-09 22:18 UTC (permalink / raw) To: qemu-devel Anthony Liguori wrote: > Final one of the night. This patch disables relative mouse reporting > and disables grab automatically the first time SDL detects that the > absolute mouse was enabled. Needs a lot of cleanup but I'm very happy > with the user experience on this one. > Perfect with a capital *P*. Disabling the sdl cursor make it look that much smoother.. My biggest problem now is my motor memory is toast. I run a trackball here and I've just been used to giving it a whirl to let the pointer slam up against the edge of the window.. now it runs off the other side of the host screen :) -- "Human beings, who are almost unique in having the ability to learn from the experience of others, are also remarkable for their apparent disinclination to do so." -- Douglas Adams ^ permalink raw reply [flat|nested] 68+ messages in thread
* Re: [Qemu-devel] Gentlemen we have absolute movement! was:Absolute USB-HID device musings (was Re: VNC Terminal Server) 2006-04-09 22:08 ` Anthony Liguori 2006-04-09 22:12 ` Brad Campbell 2006-04-09 22:18 ` Brad Campbell @ 2006-04-09 23:14 ` Brad Campbell 2006-04-10 3:40 ` [Qemu-devel] USB Tablet Emulation (was: Gentlemen we have absolute movement! was:Absolute USB-HID device musings (was Re: VNC Terminal Server)) Anthony Liguori 2 siblings, 1 reply; 68+ messages in thread From: Brad Campbell @ 2006-04-09 23:14 UTC (permalink / raw) To: qemu-devel [-- Attachment #1: Type: text/plain, Size: 575 bytes --] Anthony Liguori wrote: > > Final one of the night. This patch disables relative mouse reporting > and disables grab automatically the first time SDL detects that the > absolute mouse was enabled. Needs a lot of cleanup but I'm very happy > with the user experience on this one. > Wish I'd just gone to bed now.. Heres a patch against your last one to implement wheel support. Brad -- "Human beings, who are almost unique in having the ability to learn from the experience of others, are also remarkable for their apparent disinclination to do so." -- Douglas Adams [-- Attachment #2: hid-wheel.patch --] [-- Type: text/plain, Size: 2034 bytes --] diff -ur qemu-clean/hw/usb-hid.c qemu/hw/usb-hid.c --- qemu-clean/hw/usb-hid.c 2006-04-10 02:57:46.000000000 +0400 +++ qemu/hw/usb-hid.c 2006-04-10 03:11:58.000000000 +0400 @@ -101,7 +101,7 @@ 0x00, /* u8 country_code */ 0x01, /* u8 num_descriptors */ 0x22, /* u8 type; Report */ - 53, 0, /* u16 len */ + 65, 0, /* u16 len */ /* one endpoint (status change endpoint) */ 0x07, /* u8 ep_bLength; */ @@ -145,14 +145,15 @@ 0x09, 0x31, /* Usage Y */ 0x15, 0x00, /* Logical Minimum 0 */ 0x27, 0xFF, 0xFF, 0x00, 0x00, /* Logical Maximum 0xffff */ - 0x75, 0x10, /* Report Size 32 */ + 0x75, 0x10, /* Report Size 16 */ 0x95, 0x02, /* Report Count 2 */ 0x81, 0x02, /* Input (Data, Var, Abs) */ -// 0x09, 0x32, /* Usage Z */ -// 0x15, 0x81, /* Logical Minimum -127 */ -// 0x25, 0x7F, /* Logical Maximum 127 */ -// 0x75, 0x08, /* Report Size 8 */ -// 0x95, 0x01, /* Report Count 1 */ + 0x09, 0x38, /* Usage Wheel */ + 0x15, 0x81, /* Logical Minimum -127 */ + 0x25, 0x7F, /* Logical Maximum 127 */ + 0x75, 0x08, /* Report Size 8 */ + 0x95, 0x01, /* Report Count 1 */ + 0x81, 0x02, /* Input (Data, Var, Rel) */ 0xC0, /* End Collection */ 0xC0, /* End Collection */ }; @@ -224,14 +225,18 @@ qemu_add_mouse_event_handler(NULL, NULL); absolute_mouse = 1; } - +/* dx = int_clamp(s->dx, -128, 127); dy = int_clamp(s->dy, -128, 127); - dz = int_clamp(s->dz, -128, 127); s->dx -= dx; s->dy -= dy; +*/ + + dz = int_clamp(s->dz, -128, 127); s->dz -= dz; +/* Appears we have to invert the wheel direction */ + dz = 0 - dz; b = 0; if (s->buttons_state & MOUSE_EVENT_LBUTTON) b |= 0x01; @@ -245,7 +250,8 @@ buf[2] = s->X >> 8; buf[3] = s->Y & 0xff; buf[4] = s->Y >> 8; - l = 5; + buf[5] = dz; + l = 6; return l; } ^ permalink raw reply [flat|nested] 68+ messages in thread
* Re: [Qemu-devel] USB Tablet Emulation (was: Gentlemen we have absolute movement! was:Absolute USB-HID device musings (was Re: VNC Terminal Server)) 2006-04-09 23:14 ` Brad Campbell @ 2006-04-10 3:40 ` Anthony Liguori 2006-04-10 8:23 ` [Qemu-devel] USB Tablet Emulation Brad Campbell 2006-04-10 14:58 ` [Qemu-devel] USB Tablet Emulation Leonardo E. Reiter 0 siblings, 2 replies; 68+ messages in thread From: Anthony Liguori @ 2006-04-10 3:40 UTC (permalink / raw) To: qemu-devel [-- Attachment #1: Type: text/plain, Size: 3502 bytes --] I spent some time cleaning this all up. The following integrates Brad's patches and the patch from http://gnome.dnsalias.net/patches/qemu-hidmousexp.patch It adds a new emulated USB device that reports absolute coordinates. It also modifies SDL to operate in grabless mode when an absolute input device is enabled. I think it's pretty close to apply-able. To use, just specify: -usbdevice tablet With Xorg from CVS, the evdev driver segfaults. This is apparently expected behavior. Hopefully it will be fixed soon. It works quite nicely under Win2k. Regards, Anthony Liguori Brad Campbell wrote: > Anthony Liguori wrote: >> >> Final one of the night. This patch disables relative mouse reporting >> and disables grab automatically the first time SDL detects that the >> absolute mouse was enabled. Needs a lot of cleanup but I'm very >> happy with the user experience on this one. >> > > Wish I'd just gone to bed now.. > Heres a patch against your last one to implement wheel support. > > Brad > ------------------------------------------------------------------------ > > diff -ur qemu-clean/hw/usb-hid.c qemu/hw/usb-hid.c > --- qemu-clean/hw/usb-hid.c 2006-04-10 02:57:46.000000000 +0400 > +++ qemu/hw/usb-hid.c 2006-04-10 03:11:58.000000000 +0400 > @@ -101,7 +101,7 @@ > 0x00, /* u8 country_code */ > 0x01, /* u8 num_descriptors */ > 0x22, /* u8 type; Report */ > - 53, 0, /* u16 len */ > + 65, 0, /* u16 len */ > > /* one endpoint (status change endpoint) */ > 0x07, /* u8 ep_bLength; */ > @@ -145,14 +145,15 @@ > 0x09, 0x31, /* Usage Y */ > 0x15, 0x00, /* Logical Minimum 0 */ > 0x27, 0xFF, 0xFF, 0x00, 0x00, /* Logical Maximum 0xffff */ > - 0x75, 0x10, /* Report Size 32 */ > + 0x75, 0x10, /* Report Size 16 */ > 0x95, 0x02, /* Report Count 2 */ > 0x81, 0x02, /* Input (Data, Var, Abs) */ > -// 0x09, 0x32, /* Usage Z */ > -// 0x15, 0x81, /* Logical Minimum -127 */ > -// 0x25, 0x7F, /* Logical Maximum 127 */ > -// 0x75, 0x08, /* Report Size 8 */ > -// 0x95, 0x01, /* Report Count 1 */ > + 0x09, 0x38, /* Usage Wheel */ > + 0x15, 0x81, /* Logical Minimum -127 */ > + 0x25, 0x7F, /* Logical Maximum 127 */ > + 0x75, 0x08, /* Report Size 8 */ > + 0x95, 0x01, /* Report Count 1 */ > + 0x81, 0x02, /* Input (Data, Var, Rel) */ > 0xC0, /* End Collection */ > 0xC0, /* End Collection */ > }; > @@ -224,14 +225,18 @@ > qemu_add_mouse_event_handler(NULL, NULL); > absolute_mouse = 1; > } > - > +/* > dx = int_clamp(s->dx, -128, 127); > dy = int_clamp(s->dy, -128, 127); > - dz = int_clamp(s->dz, -128, 127); > > s->dx -= dx; > s->dy -= dy; > +*/ > + > + dz = int_clamp(s->dz, -128, 127); > s->dz -= dz; > +/* Appears we have to invert the wheel direction */ > + dz = 0 - dz; > b = 0; > if (s->buttons_state & MOUSE_EVENT_LBUTTON) > b |= 0x01; > @@ -245,7 +250,8 @@ > buf[2] = s->X >> 8; > buf[3] = s->Y & 0xff; > buf[4] = s->Y >> 8; > - l = 5; > + buf[5] = dz; > + l = 6; > > return l; > } > > ------------------------------------------------------------------------ > > _______________________________________________ > Qemu-devel mailing list > Qemu-devel@nongnu.org > http://lists.nongnu.org/mailman/listinfo/qemu-devel > [-- Attachment #2: qemu-usb-tablet.diff --] [-- Type: text/plain, Size: 16563 bytes --] diff -r 6a786a97b822 hw/ps2.c --- a/hw/ps2.c Mon Apr 10 01:47:35 2006 +0000 +++ b/hw/ps2.c Sun Apr 9 22:34:20 2006 -0500 @@ -560,7 +560,7 @@ s->common.update_arg = update_arg; ps2_reset(&s->common); register_savevm("ps2mouse", 0, 2, ps2_mouse_save, ps2_mouse_load, s); - qemu_add_mouse_event_handler(ps2_mouse_event, s); + qemu_add_mouse_event_handler(ps2_mouse_event, s, 0); qemu_register_reset(ps2_reset, &s->common); return s; } diff -r 6a786a97b822 hw/usb-hid.c --- a/hw/usb-hid.c Mon Apr 10 01:47:35 2006 +0000 +++ b/hw/usb-hid.c Sun Apr 9 22:34:20 2006 -0500 @@ -30,9 +30,15 @@ #define SET_IDLE 0x210a #define SET_PROTOCOL 0x210b +#define USB_MOUSE 1 +#define USB_TABLET 2 + typedef struct USBMouseState { USBDevice dev; int dx, dy, dz, buttons_state; + int x, y; + int kind; + int mouse_grabbed; } USBMouseState; /* mostly the same values as the Bochs USB Mouse device */ @@ -93,14 +99,6 @@ 0x02, /* u8 if_bInterfaceProtocol; [usb1.1 or single tt] */ 0x05, /* u8 if_iInterface; */ - /* one endpoint (status change endpoint) */ - 0x07, /* u8 ep_bLength; */ - 0x05, /* u8 ep_bDescriptorType; Endpoint */ - 0x81, /* u8 ep_bEndpointAddress; IN Endpoint 1 */ - 0x03, /* u8 ep_bmAttributes; Interrupt */ - 0x03, 0x00, /* u16 ep_wMaxPacketSize; */ - 0x0a, /* u8 ep_bInterval; (255ms -- usb 2.0 spec) */ - /* HID descriptor */ 0x09, /* u8 bLength; */ 0x21, /* u8 bDescriptorType; */ @@ -109,6 +107,69 @@ 0x01, /* u8 num_descriptors */ 0x22, /* u8 type; Report */ 50, 0, /* u16 len */ + + /* one endpoint (status change endpoint) */ + 0x07, /* u8 ep_bLength; */ + 0x05, /* u8 ep_bDescriptorType; Endpoint */ + 0x81, /* u8 ep_bEndpointAddress; IN Endpoint 1 */ + 0x03, /* u8 ep_bmAttributes; Interrupt */ + 0x03, 0x00, /* u16 ep_wMaxPacketSize; */ + 0x0a, /* u8 ep_bInterval; (255ms -- usb 2.0 spec) */ +}; + +static const uint8_t qemu_tablet_config_descriptor[] = { + /* one configuration */ + 0x09, /* u8 bLength; */ + 0x02, /* u8 bDescriptorType; Configuration */ + 0x22, 0x00, /* u16 wTotalLength; */ + 0x01, /* u8 bNumInterfaces; (1) */ + 0x01, /* u8 bConfigurationValue; */ + 0x04, /* u8 iConfiguration; */ + 0xa0, /* u8 bmAttributes; + Bit 7: must be set, + 6: Self-powered, + 5: Remote wakeup, + 4..0: resvd */ + 50, /* u8 MaxPower; */ + + /* USB 1.1: + * USB 2.0, single TT organization (mandatory): + * one interface, protocol 0 + * + * USB 2.0, multiple TT organization (optional): + * two interfaces, protocols 1 (like single TT) + * and 2 (multiple TT mode) ... config is + * sometimes settable + * NOT IMPLEMENTED + */ + + /* one interface */ + 0x09, /* u8 if_bLength; */ + 0x04, /* u8 if_bDescriptorType; Interface */ + 0x00, /* u8 if_bInterfaceNumber; */ + 0x00, /* u8 if_bAlternateSetting; */ + 0x01, /* u8 if_bNumEndpoints; */ + 0x03, /* u8 if_bInterfaceClass; */ + 0x01, /* u8 if_bInterfaceSubClass; */ + 0x02, /* u8 if_bInterfaceProtocol; [usb1.1 or single tt] */ + 0x05, /* u8 if_iInterface; */ + + /* HID descriptor */ + 0x09, /* u8 bLength; */ + 0x21, /* u8 bDescriptorType; */ + 0x01, 0x00, /* u16 HID_class */ + 0x00, /* u8 country_code */ + 0x01, /* u8 num_descriptors */ + 0x22, /* u8 type; Report */ + 65, 0, /* u16 len */ + + /* one endpoint (status change endpoint) */ + 0x07, /* u8 ep_bLength; */ + 0x05, /* u8 ep_bDescriptorType; Endpoint */ + 0x81, /* u8 ep_bEndpointAddress; IN Endpoint 1 */ + 0x03, /* u8 ep_bmAttributes; Interrupt */ + 0x08, 0x00, /* u16 ep_wMaxPacketSize; */ + 0x03, /* u8 ep_bInterval; (255ms -- usb 2.0 spec) */ }; static const uint8_t qemu_mouse_hid_report_descriptor[] = { @@ -121,6 +182,41 @@ 0xC0, 0xC0, }; +static const uint8_t qemu_tablet_hid_report_descriptor[] = { + 0x05, 0x01, /* Usage Page Generic Desktop */ + 0x09, 0x01, /* Usage Mouse */ + 0xA1, 0x01, /* Collection Application */ + 0x09, 0x01, /* Usage Pointer */ + 0xA1, 0x00, /* Collection Physical */ + 0x05, 0x09, /* Usage Page Button */ + 0x19, 0x01, /* Usage Minimum Button 1 */ + 0x29, 0x03, /* Usage Maximum Button 3 */ + 0x15, 0x00, /* Logical Minimum 0 */ + 0x25, 0x01, /* Logical Maximum 1 */ + 0x95, 0x03, /* Report Count 3 */ + 0x75, 0x01, /* Report Size 1 */ + 0x81, 0x02, /* Input (Data, Var, Abs) */ + 0x95, 0x01, /* Report Count 1 */ + 0x75, 0x05, /* Report Size 5 */ + 0x81, 0x01, /* Input (Cnst, Var, Abs) */ + 0x05, 0x01, /* Usage Page Generic Desktop */ + 0x09, 0x30, /* Usage X */ + 0x09, 0x31, /* Usage Y */ + 0x15, 0x00, /* Logical Minimum 0 */ + 0x27, 0xFF, 0xFF, 0x00, 0x00, /* Logical Maximum 0xffff */ + 0x75, 0x10, /* Report Size 16 */ + 0x95, 0x02, /* Report Count 2 */ + 0x81, 0x02, /* Input (Data, Var, Abs) */ + 0x09, 0x38, /* Usage Wheel */ + 0x15, 0x81, /* Logical Minimum -127 */ + 0x25, 0x7F, /* Logical Maximum 127 */ + 0x75, 0x08, /* Report Size 8 */ + 0x95, 0x01, /* Report Count 1 */ + 0x81, 0x02, /* Input (Data, Var, Rel) */ + 0xC0, /* End Collection */ + 0xC0, /* End Collection */ +}; + static void usb_mouse_event(void *opaque, int dx1, int dy1, int dz1, int buttons_state) { @@ -129,6 +225,17 @@ s->dx += dx1; s->dy += dy1; s->dz += dz1; + s->buttons_state = buttons_state; +} + +static void usb_tablet_event(void *opaque, + int x, int y, int dz, int buttons_state) +{ + USBMouseState *s = opaque; + + s->x = x; + s->y = y; + s->dz += dz; s->buttons_state = buttons_state; } @@ -146,6 +253,11 @@ { int dx, dy, dz, b, l; + if (!s->mouse_grabbed) { + qemu_add_mouse_event_handler(usb_mouse_event, s, 0); + s->mouse_grabbed = 1; + } + dx = int_clamp(s->dx, -128, 127); dy = int_clamp(s->dy, -128, 127); dz = int_clamp(s->dz, -128, 127); @@ -173,6 +285,39 @@ return l; } +static int usb_tablet_poll(USBMouseState *s, uint8_t *buf, int len) +{ + int dz, b, l; + + if (!s->mouse_grabbed) { + qemu_add_mouse_event_handler(usb_tablet_event, s, 1); + s->mouse_grabbed = 1; + } + + dz = int_clamp(s->dz, -128, 127); + s->dz -= dz; + + /* Appears we have to invert the wheel direction */ + dz = 0 - dz; + b = 0; + if (s->buttons_state & MOUSE_EVENT_LBUTTON) + b |= 0x01; + if (s->buttons_state & MOUSE_EVENT_RBUTTON) + b |= 0x02; + if (s->buttons_state & MOUSE_EVENT_MBUTTON) + b |= 0x04; + + buf[0] = b; + buf[1] = s->x & 0xff; + buf[2] = s->x >> 8; + buf[3] = s->y & 0xff; + buf[4] = s->y >> 8; + buf[5] = dz; + l = 6; + + return l; +} + static void usb_mouse_handle_reset(USBDevice *dev) { USBMouseState *s = (USBMouseState *)dev; @@ -180,6 +325,8 @@ s->dx = 0; s->dy = 0; s->dz = 0; + s->x = 0; + s->y = 0; s->buttons_state = 0; } @@ -187,7 +334,7 @@ int index, int length, uint8_t *data) { USBMouseState *s = (USBMouseState *)dev; - int ret; + int ret = 0; switch(request) { case DeviceRequest | USB_REQ_GET_STATUS: @@ -224,9 +371,15 @@ ret = sizeof(qemu_mouse_dev_descriptor); break; case USB_DT_CONFIG: - memcpy(data, qemu_mouse_config_descriptor, - sizeof(qemu_mouse_config_descriptor)); - ret = sizeof(qemu_mouse_config_descriptor); + if (s->kind == USB_MOUSE) { + memcpy(data, qemu_mouse_config_descriptor, + sizeof(qemu_mouse_config_descriptor)); + ret = sizeof(qemu_mouse_config_descriptor); + } else if (s->kind == USB_TABLET) { + memcpy(data, qemu_tablet_config_descriptor, + sizeof(qemu_tablet_config_descriptor)); + ret = sizeof(qemu_tablet_config_descriptor); + } break; case USB_DT_STRING: switch(value & 0xff) { @@ -244,7 +397,10 @@ break; case 2: /* product description */ - ret = set_usb_string(data, "QEMU USB Mouse"); + if (s->kind == USB_MOUSE) + ret = set_usb_string(data, "QEMU USB Mouse"); + else if (s->kind == USB_TABLET) + ret = set_usb_string(data, "QEMU USB Tablet"); break; case 3: /* vendor description */ @@ -282,16 +438,25 @@ case InterfaceRequest | USB_REQ_GET_DESCRIPTOR: switch(value >> 8) { case 0x22: - memcpy(data, qemu_mouse_hid_report_descriptor, - sizeof(qemu_mouse_hid_report_descriptor)); - ret = sizeof(qemu_mouse_hid_report_descriptor); - break; + if (s->kind == USB_MOUSE) { + memcpy(data, qemu_mouse_hid_report_descriptor, + sizeof(qemu_mouse_hid_report_descriptor)); + ret = sizeof(qemu_mouse_hid_report_descriptor); + } else if (s->kind == USB_TABLET) { + memcpy(data, qemu_tablet_hid_report_descriptor, + sizeof(qemu_tablet_hid_report_descriptor)); + ret = sizeof(qemu_tablet_hid_report_descriptor); + } + break; default: goto fail; } break; case GET_REPORT: - ret = usb_mouse_poll(s, data, length); + if (s->kind == USB_MOUSE) + ret = usb_mouse_poll(s, data, length); + else if (s->kind == USB_TABLET) + ret = usb_tablet_poll(s, data, length); break; case SET_IDLE: ret = 0; @@ -308,12 +473,15 @@ uint8_t devep, uint8_t *data, int len) { USBMouseState *s = (USBMouseState *)dev; - int ret; + int ret = 0; switch(pid) { case USB_TOKEN_IN: if (devep == 1) { - ret = usb_mouse_poll(s, data, len); + if (s->kind == USB_MOUSE) + ret = usb_mouse_poll(s, data, len); + else if (s->kind == USB_TABLET) + ret = usb_tablet_poll(s, data, len); } else { goto fail; } @@ -327,7 +495,7 @@ return ret; } -USBDevice *usb_mouse_init(void) +USBDevice *usb_tablet_init(void) { USBMouseState *s; @@ -340,8 +508,25 @@ s->dev.handle_reset = usb_mouse_handle_reset; s->dev.handle_control = usb_mouse_handle_control; s->dev.handle_data = usb_mouse_handle_data; - - qemu_add_mouse_event_handler(usb_mouse_event, s); - + s->kind = USB_TABLET; + return (USBDevice *)s; } + +USBDevice *usb_mouse_init(void) +{ + USBMouseState *s; + + s = qemu_mallocz(sizeof(USBMouseState)); + if (!s) + return NULL; + s->dev.speed = USB_SPEED_FULL; + s->dev.handle_packet = usb_generic_handle_packet; + + s->dev.handle_reset = usb_mouse_handle_reset; + s->dev.handle_control = usb_mouse_handle_control; + s->dev.handle_data = usb_mouse_handle_data; + s->kind = USB_MOUSE; + + return (USBDevice *)s; +} diff -r 6a786a97b822 hw/usb.h --- a/hw/usb.h Mon Apr 10 01:47:35 2006 +0000 +++ b/hw/usb.h Sun Apr 9 22:34:20 2006 -0500 @@ -163,3 +163,4 @@ /* usb-hid.c */ USBDevice *usb_mouse_init(void); +USBDevice *usb_tablet_init(void); diff -r 6a786a97b822 sdl.c --- a/sdl.c Mon Apr 10 01:47:35 2006 +0000 +++ b/sdl.c Sun Apr 9 22:34:20 2006 -0500 @@ -39,6 +39,10 @@ static int gui_fullscreen_initial_grab; static int gui_grab_code = KMOD_LALT | KMOD_LCTRL; static uint8_t modifiers_state[256]; +static int width, height; +static SDL_Cursor *sdl_cursor_normal; +static SDL_Cursor *sdl_cursor_hidden; +static int absolute_enabled = 0; static void sdl_update(DisplayState *ds, int x, int y, int w, int h) { @@ -55,6 +59,9 @@ flags = SDL_HWSURFACE|SDL_ASYNCBLIT|SDL_HWACCEL; if (gui_fullscreen) flags |= SDL_FULLSCREEN; + + width = w; + height = h; again: screen = SDL_SetVideoMode(w, h, 0, flags); @@ -271,9 +278,21 @@ SDL_WM_SetCaption(buf, "QEMU"); } +static void sdl_hide_cursor(void) +{ + SDL_SetCursor(sdl_cursor_hidden); +} + +static void sdl_show_cursor(void) +{ + if (!kbd_mouse_is_absolute()) { + SDL_SetCursor(sdl_cursor_normal); + } +} + static void sdl_grab_start(void) { - SDL_ShowCursor(0); + sdl_hide_cursor(); SDL_WM_GrabInput(SDL_GRAB_ON); /* dummy read to avoid moving the mouse */ SDL_GetRelativeMouseState(NULL, NULL); @@ -284,7 +303,7 @@ static void sdl_grab_end(void) { SDL_WM_GrabInput(SDL_GRAB_OFF); - SDL_ShowCursor(1); + sdl_show_cursor(); gui_grab = 0; sdl_update_caption(); } @@ -300,6 +319,21 @@ buttons |= MOUSE_EVENT_RBUTTON; if (state & SDL_BUTTON(SDL_BUTTON_MIDDLE)) buttons |= MOUSE_EVENT_MBUTTON; + + if (kbd_mouse_is_absolute()) { + if (!absolute_enabled) { + sdl_hide_cursor(); + if (gui_grab) { + sdl_grab_end(); + } + absolute_enabled = 1; + } + + SDL_GetMouseState(&dx, &dy); + dx = dx * 0x7FFF / width; + dy = dy * 0x7FFF / height; + } + kbd_mouse_event(dx, dy, dz, buttons); } @@ -423,7 +457,7 @@ qemu_system_shutdown_request(); break; case SDL_MOUSEMOTION: - if (gui_grab) { + if (gui_grab || kbd_mouse_is_absolute()) { sdl_send_mouse_event(0); } break; @@ -431,7 +465,7 @@ case SDL_MOUSEBUTTONUP: { SDL_MouseButtonEvent *bev = &ev->button; - if (!gui_grab) { + if (!gui_grab && !kbd_mouse_is_absolute()) { if (ev->type == SDL_MOUSEBUTTONDOWN && (bev->state & SDL_BUTTON_LMASK)) { /* start grabbing all events */ @@ -471,6 +505,7 @@ void sdl_display_init(DisplayState *ds, int full_screen) { int flags; + uint8_t data = 0; #if defined(__APPLE__) /* always use generic keymaps */ @@ -504,6 +539,9 @@ SDL_EnableUNICODE(1); gui_grab = 0; + sdl_cursor_hidden = SDL_CreateCursor(&data, &data, 8, 1, 0, 0); + sdl_cursor_normal = SDL_GetCursor(); + atexit(sdl_cleanup); if (full_screen) { gui_fullscreen = 1; diff -r 6a786a97b822 vl.c --- a/vl.c Mon Apr 10 01:47:35 2006 +0000 +++ b/vl.c Sun Apr 9 22:34:20 2006 -0500 @@ -474,6 +474,7 @@ static void *qemu_put_kbd_event_opaque; static QEMUPutMouseEvent *qemu_put_mouse_event; static void *qemu_put_mouse_event_opaque; +static int qemu_put_mouse_event_absolute; void qemu_add_kbd_event_handler(QEMUPutKBDEvent *func, void *opaque) { @@ -481,10 +482,11 @@ qemu_put_kbd_event = func; } -void qemu_add_mouse_event_handler(QEMUPutMouseEvent *func, void *opaque) +void qemu_add_mouse_event_handler(QEMUPutMouseEvent *func, void *opaque, int absolute) { qemu_put_mouse_event_opaque = opaque; qemu_put_mouse_event = func; + qemu_put_mouse_event_absolute = absolute; } void kbd_put_keycode(int keycode) @@ -500,6 +502,11 @@ qemu_put_mouse_event(qemu_put_mouse_event_opaque, dx, dy, dz, buttons_state); } +} + +int kbd_mouse_is_absolute(void) +{ + return qemu_put_mouse_event_absolute; } /***********************************************************/ @@ -2855,6 +2862,10 @@ dev = usb_mouse_init(); if (!dev) return -1; + } else if (!strcmp(devname, "tablet")) { + dev = usb_tablet_init(); + if (!dev) + return -1; } else { return -1; } diff -r 6a786a97b822 vl.h --- a/vl.h Mon Apr 10 01:47:35 2006 +0000 +++ b/vl.h Sun Apr 9 22:34:20 2006 -0500 @@ -158,10 +158,11 @@ typedef void QEMUPutMouseEvent(void *opaque, int dx, int dy, int dz, int buttons_state); void qemu_add_kbd_event_handler(QEMUPutKBDEvent *func, void *opaque); -void qemu_add_mouse_event_handler(QEMUPutMouseEvent *func, void *opaque); +void qemu_add_mouse_event_handler(QEMUPutMouseEvent *func, void *opaque, int absolute); void kbd_put_keycode(int keycode); void kbd_mouse_event(int dx, int dy, int dz, int buttons_state); +int kbd_mouse_is_absolute(void); /* keysym is a unicode code except for special keys (see QEMU_KEY_xxx constants) */ ^ permalink raw reply [flat|nested] 68+ messages in thread
* Re: [Qemu-devel] USB Tablet Emulation 2006-04-10 3:40 ` [Qemu-devel] USB Tablet Emulation (was: Gentlemen we have absolute movement! was:Absolute USB-HID device musings (was Re: VNC Terminal Server)) Anthony Liguori @ 2006-04-10 8:23 ` Brad Campbell 2006-04-10 8:32 ` Johannes Schindelin 2006-04-19 17:18 ` [Qemu-devel] USB Tablet Emulation + VNC patch Troy Benjegerdes 2006-04-10 14:58 ` [Qemu-devel] USB Tablet Emulation Leonardo E. Reiter 1 sibling, 2 replies; 68+ messages in thread From: Brad Campbell @ 2006-04-10 8:23 UTC (permalink / raw) To: qemu-devel [-- Attachment #1: Type: text/plain, Size: 864 bytes --] Anthony Liguori wrote: > I spent some time cleaning this all up. The following integrates Brad's > patches and the patch from > http://gnome.dnsalias.net/patches/qemu-hidmousexp.patch > > It adds a new emulated USB device that reports absolute coordinates. It > also modifies SDL to operate in grabless mode when an absolute input > device is enabled. I think it's pretty close to apply-able. To use, > just specify: -usbdevice tablet > > With Xorg from CVS, the evdev driver segfaults. This is apparently > expected behavior. Hopefully it will be fixed soon. It works quite > nicely under Win2k. Here is the vnc patch to go on top of that and the latest cvs. -- "Human beings, who are almost unique in having the ability to learn from the experience of others, are also remarkable for their apparent disinclination to do so." -- Douglas Adams [-- Attachment #2: qemu-rfb-bkc-001.patch --] [-- Type: text/plain, Size: 37140 bytes --] diff -urN -x CVS qemu-clean/configure qemu/configure --- qemu-clean/configure 2006-04-09 23:06:58.000000000 +0400 +++ qemu/configure 2006-04-10 11:08:05.000000000 +0400 @@ -181,6 +181,8 @@ ;; --disable-sdl) sdl="no" ;; + --disable-vnc) vnc="no" + ;; --enable-coreaudio) coreaudio="yes" ;; --enable-alsa) alsa="yes" @@ -240,6 +242,8 @@ echo " --interp-prefix=PREFIX where to find shared libraries, etc." echo " use %M for cpu name [$interp_prefix]" echo " --target-list=LIST set target list [$target_list]" +echo " --disable-vnc disable vnc support (else configure checks" +echo " for libvncserver-config in your PATH)" echo "" echo "kqemu kernel acceleration support:" echo " --disable-kqemu disable kqemu support" @@ -363,6 +367,19 @@ fi ########################################## +# VNC probe + +if test -z "$vnc"; then + +if libvncserver-config --version > /dev/null; then + vnc=yes +else + vnc=no +fi + +fi + +########################################## # SDL probe sdl_too_old=no @@ -448,6 +465,7 @@ echo "gprof enabled $gprof" echo "profiler $profiler" echo "static build $static" +echo "VNC support $vnc" if test "$darwin" = "yes" ; then echo "Cocoa support $cocoa" fi @@ -561,6 +579,8 @@ if test "$darwin" = "yes" ; then echo "CONFIG_DARWIN=yes" >> $config_mak echo "#define CONFIG_DARWIN 1" >> $config_h + echo "#define socklen_t int" >> $config_h + echo "#define sqrtf sqrt" >> $config_h fi if test "$gdbstub" = "yes" ; then echo "CONFIG_GDBSTUB=yes" >> $config_mak @@ -624,6 +644,16 @@ echo "#define _BSD 1" >> $config_h fi +if test "$vnc" = "yes"; then + echo "CONFIG_VNC=yes" >> $config_mak + echo "VNC_CFLAGS=`libvncserver-config --cflags`" >> $config_mak +fi + +if test "$sdl" = "yes"; then + echo "CONFIG_SDL=yes" >> $config_mak + echo "SDL_CFLAGS=`$sdl_config --cflags`" >> $config_mak +fi + for target in $target_list; do target_dir="$target" @@ -735,13 +765,22 @@ echo "#define CONFIG_USER_ONLY 1" >> $config_h fi +if test "$target_user_only" = "no"; then + if test "$vnc" = "yes"; then + echo "#define CONFIG_VNC 1" >> $config_h + echo "CONFIG_VNC=yes" >> $config_mak + echo "VNC_CFLAGS=`libvncserver-config --cflags`" >> $config_mak + echo "VNC_LIBS=`libvncserver-config --libs`" >> $config_mak + fi +fi + if test "$target_cpu" = "arm" -o "$target_cpu" = "armeb" ; then echo "CONFIG_SOFTFLOAT=yes" >> $config_mak echo "#define CONFIG_SOFTFLOAT 1" >> $config_h fi # sdl defines -if test "$target_user_only" = "no"; then +if test "$sdl" = "yes" -a "$target_user_only" = "no"; then if test "$target_softmmu" = "no" -o "$static" = "yes"; then sdl1=$sdl_static else diff -urN -x CVS qemu-clean/hw/pckbd.c qemu/hw/pckbd.c --- qemu-clean/hw/pckbd.c 2006-04-09 23:07:05.000000000 +0400 +++ qemu/hw/pckbd.c 2006-04-10 11:07:37.000000000 +0400 @@ -333,7 +333,11 @@ static void kbd_save(QEMUFile* f, void* opaque) { KBDState *s = (KBDState*)opaque; - + + /* release alt, ctrl */ + kbd_put_keycode(0x38|0x80); /* alt */ + kbd_put_keycode(0x1d|0x80); /* ctrl */ + qemu_put_8s(f, &s->write_cmd); qemu_put_8s(f, &s->status); qemu_put_8s(f, &s->mode); diff -urN -x CVS qemu-clean/keymaps.c qemu/keymaps.c --- qemu-clean/keymaps.c 2006-04-09 23:06:58.000000000 +0400 +++ qemu/keymaps.c 2006-04-10 11:07:37.000000000 +0400 @@ -93,6 +93,12 @@ if (keysym < MAX_NORMAL_KEYCODE) { //fprintf(stderr,"Setting keysym %s (%d) to %d\n",line,keysym,keycode); k->keysym2keycode[keysym] = keycode; +#ifdef KEYBOARD_HANDLE_UPPER_CASE + line[0]=toupper(line[0]); + keysym=get_keysym(line); + if(keysym) + k->keysym2keycode[keysym]=keycode; +#endif } else { if (k->extra_count >= MAX_EXTRA_COUNT) { fprintf(stderr, diff -urN -x CVS qemu-clean/Makefile.target qemu/Makefile.target --- qemu-clean/Makefile.target 2006-04-10 02:03:49.000000000 +0400 +++ qemu/Makefile.target 2006-04-10 11:07:37.000000000 +0400 @@ -345,6 +345,9 @@ ifdef CONFIG_GDBSTUB VL_OBJS+=gdbstub.o endif +ifdef CONFIG_VNC +VL_OBJS+=vnc.o +endif ifdef CONFIG_SDL VL_OBJS+=sdl.o endif @@ -390,7 +393,10 @@ endif $(QEMU_SYSTEM): $(VL_OBJS) libqemu.a - $(CC) $(VL_LDFLAGS) -o $@ $^ $(LIBS) $(SDL_LIBS) $(COCOA_LIBS) $(VL_LIBS) + $(CC) $(VL_LDFLAGS) -o $@ $^ $(LIBS) $(SDL_LIBS) $(COCOA_LIBS) $(VNC_LIBS) $(VL_LIBS) + +vnc.o: vnc.c keymaps.c vnc_keysym.h + $(CC) $(CFLAGS) $(DEFINES) $(VNC_CFLAGS) $(SDL_CFLAGS) -c -o $@ $< cocoa.o: cocoa.m $(CC) $(CFLAGS) $(DEFINES) -c -o $@ $< @@ -401,6 +407,9 @@ sdlaudio.o: sdlaudio.c $(CC) $(CFLAGS) $(DEFINES) $(SDL_CFLAGS) -c -o $@ $< +vl.o: vl.c + $(CC) $(CFLAGS) $(DEFINES) $(SDL_CFLAGS) -c -o $@ $< + depend: $(SRCS) $(CC) -MM $(CFLAGS) $(DEFINES) $^ 1>.depend diff -urN -x CVS qemu-clean/monitor.c qemu/monitor.c --- qemu-clean/monitor.c 2006-04-09 23:06:59.000000000 +0400 +++ qemu/monitor.c 2006-04-10 11:07:37.000000000 +0400 @@ -69,7 +69,10 @@ void term_flush(void) { if (term_outbuf_index > 0) { + if(monitor_hd) qemu_chr_write(monitor_hd, term_outbuf, term_outbuf_index); + else + fwrite(term_outbuf, term_outbuf_index, 1, stderr); term_outbuf_index = 0; } } diff -urN -x CVS qemu-clean/sdl.c qemu/sdl.c --- qemu-clean/sdl.c 2006-04-10 12:10:47.000000000 +0400 +++ qemu/sdl.c 2006-04-10 11:07:37.000000000 +0400 @@ -44,6 +44,10 @@ static SDL_Cursor *sdl_cursor_hidden; static int absolute_enabled = 0; +SDL_PixelFormat* sdl_get_format() { + return screen->format; +} + static void sdl_update(DisplayState *ds, int x, int y, int w, int h) { // printf("updating x=%d y=%d w=%d h=%d\n", x, y, w, h); diff -urN -x CVS qemu-clean/slirp/main.h qemu/slirp/main.h --- qemu-clean/slirp/main.h 2006-04-09 23:07:05.000000000 +0400 +++ qemu/slirp/main.h 2006-04-10 11:07:37.000000000 +0400 @@ -9,6 +9,8 @@ #include <sys/select.h> #endif +#include <inttypes.h> + #define TOWRITEMAX 512 extern struct timeval tt; diff -urN -x CVS qemu-clean/vl.c qemu/vl.c --- qemu-clean/vl.c 2006-04-10 12:10:47.000000000 +0400 +++ qemu/vl.c 2006-04-10 11:07:37.000000000 +0400 @@ -72,7 +72,7 @@ #ifdef CONFIG_SDL #ifdef __APPLE__ -#include <SDL/SDL.h> +#include "SDL.h" #endif #endif /* CONFIG_SDL */ @@ -117,6 +117,8 @@ int bios_size; static DisplayState display_state; int nographic; +int usevnc; /* 1=vnc only, 2=vnc and sdl */ +int vnc_port = 0; const char* keyboard_layout = NULL; int64_t ticks_per_sec; int boot_device = 'c'; @@ -4142,6 +4144,13 @@ "-m megs set virtual RAM size to megs MB [default=%d]\n" "-smp n set the number of CPUs to 'n' [default=1]\n" "-nographic disable graphical output and redirect serial I/Os to console\n" +#ifdef CONFIG_VNC + "-vnc use vnc instead of sdl\n" + "-vncport <port> use this vnc port. Default is auto-choosing\n" +#ifdef CONFIG_SDL + "-vnc-and-sdl use vnc and sdl simultaneously\n" +#endif +#endif #ifndef _WIN32 "-k language use keyboard layout (for example \"fr\" for French)\n" #endif @@ -4267,7 +4276,14 @@ QEMU_OPTION_boot, QEMU_OPTION_snapshot, QEMU_OPTION_m, + QEMU_OPTION_vncport, QEMU_OPTION_nographic, +#ifdef CONFIG_VNC + QEMU_OPTION_vnc, +#ifdef CONFIG_SDL + QEMU_OPTION_vnc_and_sdl, +#endif +#endif #ifdef HAS_AUDIO QEMU_OPTION_audio_help, QEMU_OPTION_soundhw, @@ -4328,7 +4344,14 @@ { "boot", HAS_ARG, QEMU_OPTION_boot }, { "snapshot", 0, QEMU_OPTION_snapshot }, { "m", HAS_ARG, QEMU_OPTION_m }, + { "vncport", HAS_ARG, QEMU_OPTION_vncport }, { "nographic", 0, QEMU_OPTION_nographic }, +#ifdef CONFIG_VNC + { "vnc", 0, QEMU_OPTION_vnc }, +#ifdef CONFIG_SDL + { "vnc-and-sdl", 0, QEMU_OPTION_vnc_and_sdl }, +#endif +#endif { "k", HAS_ARG, QEMU_OPTION_k }, #ifdef HAS_AUDIO { "audio-help", 0, QEMU_OPTION_audio_help }, @@ -4608,6 +4631,7 @@ #endif snapshot = 0; nographic = 0; + usevnc = 0; kernel_filename = NULL; kernel_cmdline = ""; #ifdef TARGET_PPC @@ -4742,6 +4766,16 @@ pstrcpy(serial_devices[0], sizeof(serial_devices[0]), "stdio"); nographic = 1; break; +#ifdef CONFIG_VNC + case QEMU_OPTION_vnc: + usevnc = 1; + break; +#ifdef CONFIG_SDL + case QEMU_OPTION_vnc_and_sdl: + usevnc = 2; + break; +#endif +#endif case QEMU_OPTION_kernel: kernel_filename = optarg; break; @@ -4819,6 +4853,9 @@ exit(1); } break; + case QEMU_OPTION_vncport: + vnc_port = atoi(optarg); + break; case QEMU_OPTION_d: { int mask; @@ -5125,6 +5162,13 @@ if (nographic) { dumb_display_init(ds); } else { + if (usevnc) { +#ifdef CONFIG_VNC + vnc_display_init(ds, (usevnc==2)); +#else + perror("qemu not configured with vnc support"); +#endif + } else { #if defined(CONFIG_SDL) sdl_display_init(ds, full_screen); #elif defined(CONFIG_COCOA) @@ -5133,6 +5177,7 @@ dumb_display_init(ds); #endif } + } monitor_hd = qemu_chr_open(monitor_device); if (!monitor_hd) { diff -urN -x CVS qemu-clean/vl.h qemu/vl.h --- qemu-clean/vl.h 2006-04-10 12:10:47.000000000 +0400 +++ qemu/vl.h 2006-04-10 11:07:37.000000000 +0400 @@ -684,6 +684,9 @@ unsigned long vga_ram_offset, int vga_ram_size, unsigned long vga_bios_offset, int vga_bios_size); +/* vnc.c */ +void vnc_display_init(DisplayState *ds, int useAlsoSDL); + /* cirrus_vga.c */ void pci_cirrus_vga_init(PCIBus *bus, DisplayState *ds, uint8_t *vga_ram_base, unsigned long vga_ram_offset, int vga_ram_size); @@ -757,6 +760,7 @@ /* pckbd.c */ void kbd_init(void); +extern const char* keyboard_layout; /* mc146818rtc.c */ diff -urN -x CVS qemu-clean/vnc.c qemu/vnc.c --- qemu-clean/vnc.c 1970-01-01 04:00:00.000000000 +0400 +++ qemu/vnc.c 2006-04-10 12:08:19.000000000 +0400 @@ -0,0 +1,600 @@ +/* + * QEMU VNC display driver (uses LibVNCServer, based on QEMU SDL driver) + * + * Copyright (c) 2003,2004,2005 Fabrice Bellard, Matthew Mastracci, + * Johannes E. Schindelin, Donald D. Dugger + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +#include "vl.h" + +#include <rfb/rfb.h> + +/* keyboard stuff */ +#include <rfb/keysym.h> +#include "vnc_keysym.h" +#define KEYBOARD_HANDLE_UPPER_CASE +#include "keymaps.c" + + +#ifndef _WIN32 +#include <signal.h> +#endif + +static rfbScreenInfoPtr screen; +static DisplayState* ds_sdl; +static void* kbd_layout; // TODO: move into rfbClient +static int ctl_keys; // Ctrl+Alt starts calibration + +/* mouse stuff */ + +typedef struct mouse_magic_t { + /* When calibrating, mouse_calibration contains a copy of the + * current frame buffer. After a simulated mouse movement, the + * update function only gets (0,y1,width,y2) as bounding box + * of the changed region, so we refine that with the help of + * this copy, and then update the copy. */ + char* calibration; + /* Mouse handling using VNC used to be wrong, because if moving the + * mouse very fast, the pointer got even faster. The reason for this: + * when the mouse sends a delta of at least 4 (Windows: 3) pixels, + * it is treated as if it were double the amount. I call this the + * sonic wall. */ + int sonic_wall_x; + int sonic_wall_y; + /* Unfortunately, Windows and X behave differently, when the sonic + * wall was reached in one axis, but not the other: Windows treats + * them independently. I call this orthogonal. */ + char sonic_wall_is_orthogonal; + /* last_dy contains the last delta sent on the y axis. We don't + * use the x axis (see mouse_calibration). */ + //static int last_dy=0; +} mouse_magic_t; + +mouse_magic_t* init_mouse_magic() { + mouse_magic_t* ret=(mouse_magic_t*)malloc(sizeof(mouse_magic_t)); + + ret->calibration=0; +#ifdef EXPECT_WINDOWS_GUEST + ret->sonic_wall_x=3; + ret->sonic_wall_y=3; + ret->sonic_wall_is_orthogonal=1; +#else + ret->sonic_wall_x=4; + ret->sonic_wall_y=4; + ret->sonic_wall_is_orthogonal=0; +#endif + return ret; +} + +static void vnc_save(QEMUFile* f,void* opaque) +{ + mouse_magic_t* s=(mouse_magic_t*)opaque; + + qemu_put_be32s(f, &s->sonic_wall_x); + qemu_put_be32s(f, &s->sonic_wall_y); + qemu_put_8s(f, &s->sonic_wall_is_orthogonal); +} + +static int vnc_load(QEMUFile* f,void* opaque,int version_id) +{ + mouse_magic_t* s=(mouse_magic_t*)opaque; + + if (version_id != 1) + return -EINVAL; + + qemu_get_be32s(f, &s->sonic_wall_x); + qemu_get_be32s(f, &s->sonic_wall_y); + qemu_get_8s(f, &s->sonic_wall_is_orthogonal); + + return 0; +} + +static mouse_magic_t* mouse_magic; + +typedef struct { + int x,y,w,h; +} rectangle_t; +/* In order to calibrate the mouse, we have to know about the bounding boxes + * of the last changes. */ +static rectangle_t last_update, before_update; +static int updates_since_mouse=0; + +int mouse_maxx; +int mouse_maxy; +static int mouse_x,mouse_y; +static int new_mouse_x,new_mouse_y,new_mouse_z,new_mouse_buttons; + +static void init_mouse(int max_x,int max_y) { + mouse_maxx=max_x - 1; + mouse_maxy=max_y - 1; + mouse_x=new_mouse_x=max_x/2; + mouse_y=new_mouse_y=max_y/2; + new_mouse_z=new_mouse_buttons=0; + mouse_magic->calibration = 0; +} + +static void mouse_refresh() { + int dx=0,dy=0,dz=new_mouse_z; + static int counter=1; + + /* + * Simulate lifting the mouse by pressing left <ctl><alt> together + * e.g. don't send mouse events. + */ +#if 0 + if(1) { + if(dx!=0) { + if(1 || abs(dx)<10) { dx=(dx>0?2:-2); mouse_x-=dx/2; } + } + if(dy!=0) { + if(1 || abs(dy)<10) { dy=(dy>0?2:-2); mouse_y-=dy/2; } + } + } else + if(mouse_magic->sonic_wall_is_orthogonal) { + if(abs(dx)>=mouse_magic->sonic_wall_x) { dx/=2; mouse_x+=dx; } + if(abs(dy)>=mouse_magic->sonic_wall_y) { dy/=2; mouse_y+=dy; } + } else { + if(abs(dx)>=mouse_magic->sonic_wall_x || abs(dy)>=mouse_magic->sonic_wall_y) { + dx/=2; mouse_x+=dx; + dy/=2; mouse_y+=dy; + } + } +#endif + //fprintf(stderr,"sending mouse event %d,%d\n",dx,dy); + if (kbd_mouse_is_absolute()) { + dx = new_mouse_x * 0x7FFF / screen->width; + dy = new_mouse_y * 0x7FFF / screen->height; + } else { + if (ctl_keys == 3) { + mouse_x = new_mouse_x; + mouse_y = new_mouse_y; + return; + } + counter++; +// if(!mouse_magic->calibration && counter>=2) { counter=0; return; } + + dx=new_mouse_x-mouse_x; + dy=new_mouse_y-mouse_y; + } + +// printf("%i \n",new_mouse_buttons); + kbd_mouse_event(dx,dy,dz,new_mouse_buttons); + mouse_x+=dx; + mouse_y+=dy; + new_mouse_z=0; + + updates_since_mouse=0; +} + +static int calibration_step=0; +//static int calibration_count=0; + +static void mouse_find_bounding_box_of_difference(int* x,int* y,int* w,int* h) { + int i,j,X=*x,Y=*y,W=*w,H=*h; + int bpp=screen->depth/8; + + *x=screen->width; *w=-*x; + *y=screen->height; *h=-*y; + for(i=X;i<X+W;i++) + for(j=Y;j<Y+H;j++) { + int offset=i*bpp+j*screen->paddedWidthInBytes; + if(memcmp(mouse_magic->calibration+offset,screen->frameBuffer+offset,bpp)) { + if(i<((*x))) { (*w)+=(*x)-i; (*x)=i; } + if(i>(*x)+(*w)) (*w)=i-(*x); + if(j<(*y)) { (*h)+=(*y)-j; (*y)=j; } + if(j>(*y)+(*h)) (*h)=j-(*y); + } + } + if(h>0) + memcpy(mouse_magic->calibration+Y*screen->paddedWidthInBytes, + screen->frameBuffer+Y*screen->paddedWidthInBytes, + H*screen->paddedWidthInBytes); +} + +static void start_mouse_calibration() { + int size = screen->height*screen->paddedWidthInBytes; + if(mouse_magic->calibration) + free(mouse_magic->calibration); + mouse_magic->calibration = malloc(size); + memcpy(mouse_magic->calibration, screen->frameBuffer, size); + calibration_step=0; + // calibration_count=-1; + //calibration_count=1000; updates_since_mouse=1; + term_printf("Starting mouse calibration:\n"); +} + +static void stop_mouse_calibration() { + if(mouse_magic->calibration) + free(mouse_magic->calibration); + mouse_magic->calibration = 0; +} + +#if 0 +static void adjust_last_update(int x,int y,int w,int h,char enlarge) +{ + if(enlarge && !(last_update.w<=0 || last_update.h<=0)) { + if(w<=0||h<=0) + return; + if(x<last_update.x) { last_update.w+=last_update.x-x; last_update.x=x; } + if(x+w>last_update.x+last_update.w) { last_update.w=x+w-last_update.w; } + if(y<last_update.y) { last_update.h+=last_update.y-y; last_update.y=y; } + if(y+h>last_update.y+last_update.h) { last_update.h=y+h-last_update.h; } + } else { + last_update.x=x; + last_update.y=y; + last_update.w=w; + last_update.h=h; + } +} +#endif + +static void mouse_calibration_update(int x,int y,int w,int h) { + mouse_find_bounding_box_of_difference(&x,&y,&w,&h); + if(w<=0 || h<=0) + return; + last_update.x=x; + last_update.y=y; + last_update.w=w; + last_update.h=h; + updates_since_mouse++; +#if 0 + adjust_last_update(x,y,w,h,(updates_since_mouse>1)); + if(last_dy<0) { + fprintf(stderr,"\t\t\tcount: %d, dy: %d, real_dy: %d\n", + updates_since_mouse,last_dy,y-before_update.y); + } else if (last_dy>0) { + fprintf(stderr,"\t\t\tcount: %d, dy: %d, real_dy: %d\n", + updates_since_mouse,last_dy,y+h-before_update.y-before_update.h); + } //else + fprintf(stderr,"got update with last_dy=%d: %d,%d - %d,%d\n", + last_dy,x,y,w,h); +#endif +} + +static void mouse_calibration_refresh() { + static rectangle_t cursor; + static int x,y; + static int idle_counter; + //fprintf(stderr,"refresh: %d\n",updates_since_mouse); + + if(calibration_step==0) + idle_counter=0; + else { + idle_counter++; + if(idle_counter<10) + return; + idle_counter=0; + if(updates_since_mouse!=1) { + term_printf("Calibration failed: updates=%d\n",updates_since_mouse); + stop_mouse_calibration(); + return; + } + } + /* fprintf(stderr,"step: %d\n",calibration_step); + fprintf(stderr,"-%d,%d,%d,%d\n", + before_update.x,before_update.y,before_update.w,before_update.h); + fprintf(stderr,"+%d,%d,%d,%d\n", + last_update.x,last_update.y,last_update.w,last_update.h); + */ + if(calibration_step==0) { + x=0; y=1; + kbd_mouse_event(0,-1,0,0); + calibration_step++; + } else if(calibration_step==1) { + // find out the initial position of the cursor + cursor=last_update; + cursor.h--; + calibration_step++; + mouse_magic->sonic_wall_y=-1; + last_update=cursor; + x=0; y=2; + goto move_calibrate; + } else if(calibration_step==2) { + // find out the sonic_wall + if(last_update.y==before_update.y-2*y) { + mouse_magic->sonic_wall_y=y; + // test orthogonality + calibration_step++; + x=mouse_magic->sonic_wall_y+1; y=1; + goto move_calibrate; + } else if(last_update.y<=2) { + if(y<6) + term_printf("Calibration failed: not enough head room!\n"); + else + term_printf("Calibration finished.\n"); + mouse_magic->sonic_wall_x=mouse_magic->sonic_wall_y=32768; + goto stop_calibration; + } else if(last_update.y!=before_update.y-y) { + if(last_update.y==before_update.y-y/2) { + term_printf("XP detected!\n"); + } else { + term_printf("Calibration failed: delta=%d (expected: %d)\n",last_update.y-before_update.y,-y); + goto stop_calibration; + } + } else { + y++; +move_calibrate: + kbd_mouse_event(-x,-y,0,0); + before_update=last_update; + } + } else if(calibration_step==3) { + if(last_update.y==before_update.y-2) + mouse_magic->sonic_wall_is_orthogonal=0; + else if(last_update.y==before_update.y-1) + mouse_magic->sonic_wall_is_orthogonal=-1; + else + term_printf("Calibration failed: no clue of orthogonal.\n"); + mouse_magic->sonic_wall_x=mouse_magic->sonic_wall_y; + if(last_update.x==before_update.x-mouse_magic->sonic_wall_x) + mouse_magic->sonic_wall_x++; + else if(last_update.x!=before_update.x-x*2) + term_printf("Calibration failed: could not determine horizontal sonic wall x\n"); + term_printf("Calibration finished\n"); +stop_calibration: + /* + mouse_x+=last_update.x-cursor.x; + mouse_y+=last_update.y-cursor.y-1; + */ + mouse_x=last_update.x; + mouse_y=last_update.y; + stop_mouse_calibration(); + } + updates_since_mouse=0; +} + +/* end of mouse stuff */ + +static void vnc_update(DisplayState *ds, int x, int y, int w, int h) +{ + if(ds_sdl) + ds_sdl->dpy_update(ds_sdl,x,y,w,h); + if(0) term_printf("updating x=%d y=%d w=%d h=%d\n", x, y, w, h); + rfbMarkRectAsModified(screen,x,y,x+w,y+h); + if(mouse_magic->calibration) { + mouse_calibration_update(x,y,w,h); + } +} + +#ifdef CONFIG_SDL +#include <SDL_video.h> +extern SDL_PixelFormat* sdl_get_format(); +#endif +extern int vnc_port; + +static void vnc_resize(DisplayState *ds, int w, int h) +{ + int depth = screen->bitsPerPixel; + rfbClientIteratorPtr iter; + rfbClientPtr cl; + + if(w==screen->width && h==screen->height) + return; + + if(ds_sdl) { +#ifdef CONFIG_SDL + SDL_PixelFormat* sdl_format; + ds_sdl->dpy_resize(ds_sdl,w,h); + ds->data = ds_sdl->data; + ds->linesize = screen->paddedWidthInBytes = ds_sdl->linesize; + screen->serverFormat.bitsPerPixel = screen->serverFormat.depth + = screen->bitsPerPixel = depth = ds->depth = ds_sdl->depth; + w = ds->width = ds_sdl->width; + h = ds->height = ds_sdl->height; + sdl_format=sdl_get_format(); + if(sdl_format->palette==0) { + screen->serverFormat.trueColour=TRUE; + screen->serverFormat.redShift=sdl_format->Rshift; + screen->serverFormat.greenShift=sdl_format->Gshift; + screen->serverFormat.blueShift=sdl_format->Bshift; + screen->serverFormat.redMax=sdl_format->Rmask>>screen->serverFormat.redShift; + screen->serverFormat.greenMax=sdl_format->Gmask>>screen->serverFormat.greenShift; + screen->serverFormat.blueMax=sdl_format->Bmask>>screen->serverFormat.blueShift; + } else { + rfbColourMap* cmap=&(screen->colourMap); + int i; + screen->serverFormat.trueColour=FALSE; + cmap->is16=FALSE; + cmap->count=sdl_format->palette->ncolors; + if(cmap->data.bytes==0) + cmap->data.bytes=malloc(256*3); + for(i=0;i<cmap->count;i++) { + cmap->data.bytes[3*i+0]=sdl_format->palette->colors[i].r; + cmap->data.bytes[3*i+1]=sdl_format->palette->colors[i].g; + cmap->data.bytes[3*i+2]=sdl_format->palette->colors[i].b; + } + } +#else + term_printf("Warning: SDL not configured\n"); +#endif + } else { + ds->data = (unsigned char*)realloc(ds->data, w*h*depth/8); + ds->linesize = screen->paddedWidthInBytes = w*2; + ds->width = w; + ds->height = h; + ds->depth = depth; + screen->paddedWidthInBytes = w*depth/8; + } + screen->frameBuffer = ds->data; + + screen->width = w; + screen->height = h; + + iter=rfbGetClientIterator(screen); + while((cl=rfbClientIteratorNext(iter))) + if(cl->useNewFBSize) + cl->newFBSizePending = TRUE; + else + rfbLog("Warning: Client %s does not support NewFBSize!\n",cl->host); + rfbReleaseClientIterator(iter); + + if(mouse_magic->calibration) { + term_printf("Warning: mouse calibration interrupted by video mode change\n"); + stop_mouse_calibration(); + } + init_mouse(w,h); +} + +static void vnc_process_key(rfbBool down, rfbKeySym keySym, rfbClientPtr cl) +{ + /* handle Ctrl+Alt (AKA magic keys) first */ + if(down) { + if(keySym==XK_Control_L) + ctl_keys|=1; + else if(keySym==XK_Alt_L) + ctl_keys|=2; + else if((ctl_keys&3)==3) + return; + } else { + if (keySym == XK_Control_L) + ctl_keys &= ~1; + else if (keySym == XK_Alt_L) + ctl_keys &= ~2; + else if((ctl_keys&3)==3) { + switch(keySym) { + case XK_m: + start_mouse_calibration(); + break; + case XK_1 ... XK_9: + //fprintf(stderr,"switch to %d\n",keySym-XK_1); + console_select(keySym - XK_1); + if (!is_graphic_console()) { + /* tell the vga console to redisplay itself */ + vga_hw_invalidate(); + vnc_update(0,0,0,screen->width,screen->height); + } + break; + } + return; + } + } + + if(is_graphic_console()) { + int keycode=keysym2scancode(kbd_layout, keySym); + if(keycode>=0x80) + keycode=(keycode<<8)^0x80e0; + //fprintf(stdout,"vnc key out %s: 0x%x,\n",down?"down":"up",keycode); + while(keycode!=0) { + kbd_put_keycode((keycode&0xff)|(down?0:0x80)); + keycode>>=8; + } + } else if(down) { + if(!(keySym>=XK_Shift_L && keySym<=XK_Hyper_R) + && !(keySym>=XK_ISO_Lock && keySym<=XK_Pointer_DfltBtnPrev)) + kbd_put_keysym(keySym); + //fprintf(stderr,"vnc key %s: 0x%x (magic=%d)\n",down?"down":"up",keySym,ctl_keys); + } +} + +static void vnc_process_mouse(int buttonMask, int x, int y, rfbClientPtr cl) +{ + new_mouse_x=x; new_mouse_y=y; new_mouse_buttons=0; + if(buttonMask&1) new_mouse_buttons|=MOUSE_EVENT_LBUTTON; + if(buttonMask&2) new_mouse_buttons|=MOUSE_EVENT_MBUTTON; + if(buttonMask&4) new_mouse_buttons|=MOUSE_EVENT_RBUTTON; + if(buttonMask&8) new_mouse_z--; + if(buttonMask&16) new_mouse_z++; + if(mouse_magic->calibration && (kbd_mouse_is_absolute() == 0)) { + printf("mouse_calibration_refresg\n"); + mouse_calibration_refresh(); + } else { + // printf("mouse_refresh\n"); + mouse_refresh(); + } + +} + +static void vnc_refresh(DisplayState *ds) { + if(ds_sdl) + ds_sdl->dpy_refresh(ds_sdl); + else if(!is_graphic_console()) + vga_hw_update(); + rfbProcessEvents(screen,0); +} + +static void vnc_cleanup(void) +{ + rfbScreenCleanup(screen); +} + +void vnc_display_init(DisplayState *ds, int useAlsoSDL) +{ + if(!keyboard_layout) { + fprintf(stderr, "No keyboard language specified\n"); + exit(1); + } + + kbd_layout=init_keyboard_layout(keyboard_layout); + if(!kbd_layout) { + fprintf(stderr, "Could not initialize keyboard\n"); + exit(1); + } + + mouse_magic=init_mouse_magic(); + register_savevm("vnc", 0, 1, vnc_save, vnc_load, mouse_magic); + + rfbLog=rfbErr=term_printf; + screen=rfbGetScreen(0,0,0,0,5,3,2); + if(screen==0) { + fprintf(stderr, "Could not initialize VNC - exiting\n"); + exit(1); + } + + screen->serverFormat.redShift = 11; + screen->serverFormat.greenShift = 5; + screen->serverFormat.blueShift = 0; + screen->serverFormat.redMax = 31; + screen->serverFormat.greenMax = 63; + screen->serverFormat.blueMax = 31; + + if(useAlsoSDL) { +#ifdef CONFIG_SDL + ds_sdl=(DisplayState*)malloc(sizeof(DisplayState)); + sdl_display_init(ds_sdl,0); + screen->frameBuffer = ds_sdl->data; +#else + term_printf("SDL not configured!\n"); +#endif + } else + screen->frameBuffer = malloc(640*400*2); + + screen->desktopName = "QEMU/VNC"; + screen->cursor = 0; + + /* Did we get a VNC port in the command line? */ + if (vnc_port) { + screen->autoPort = FALSE; + screen->port = vnc_port; + } + else + screen->autoPort = TRUE; + + screen->kbdAddEvent = vnc_process_key; + screen->ptrAddEvent = vnc_process_mouse; + rfbInitServer(screen); + + vnc_resize(ds,640,400); + + ds->dpy_update = vnc_update; + ds->dpy_resize = vnc_resize; + ds->dpy_refresh = vnc_refresh; + + atexit(vnc_cleanup); +} + diff -urN -x CVS qemu-clean/vnc_keysym.h qemu/vnc_keysym.h --- qemu-clean/vnc_keysym.h 1970-01-01 04:00:00.000000000 +0400 +++ qemu/vnc_keysym.h 2006-04-10 11:07:37.000000000 +0400 @@ -0,0 +1,278 @@ +typedef struct { + const char* name; + int keysym; +} name2keysym_t; +static name2keysym_t name2keysym[]={ +/* ascii */ + { "space", 0x020}, + { "exclam", 0x021}, + { "quotedbl", 0x022}, + { "numbersign", 0x023}, + { "dollar", 0x024}, + { "percent", 0x025}, + { "ampersand", 0x026}, + { "apostrophe", 0x027}, + { "parenleft", 0x028}, + { "parenright", 0x029}, + { "asterisk", 0x02a}, + { "plus", 0x02b}, + { "comma", 0x02c}, + { "minus", 0x02d}, + { "period", 0x02e}, + { "slash", 0x02f}, + { "0", 0x030}, + { "1", 0x031}, + { "2", 0x032}, + { "3", 0x033}, + { "4", 0x034}, + { "5", 0x035}, + { "6", 0x036}, + { "7", 0x037}, + { "8", 0x038}, + { "9", 0x039}, + { "colon", 0x03a}, + { "semicolon", 0x03b}, + { "less", 0x03c}, + { "equal", 0x03d}, + { "greater", 0x03e}, + { "question", 0x03f}, + { "at", 0x040}, + { "A", 0x041}, + { "B", 0x042}, + { "C", 0x043}, + { "D", 0x044}, + { "E", 0x045}, + { "F", 0x046}, + { "G", 0x047}, + { "H", 0x048}, + { "I", 0x049}, + { "J", 0x04a}, + { "K", 0x04b}, + { "L", 0x04c}, + { "M", 0x04d}, + { "N", 0x04e}, + { "O", 0x04f}, + { "P", 0x050}, + { "Q", 0x051}, + { "R", 0x052}, + { "S", 0x053}, + { "T", 0x054}, + { "U", 0x055}, + { "V", 0x056}, + { "W", 0x057}, + { "X", 0x058}, + { "Y", 0x059}, + { "Z", 0x05a}, + { "bracketleft", 0x05b}, + { "backslash", 0x05c}, + { "bracketright", 0x05d}, + { "asciicircum", 0x05e}, + { "underscore", 0x05f}, + { "grave", 0x060}, + { "a", 0x061}, + { "b", 0x062}, + { "c", 0x063}, + { "d", 0x064}, + { "e", 0x065}, + { "f", 0x066}, + { "g", 0x067}, + { "h", 0x068}, + { "i", 0x069}, + { "j", 0x06a}, + { "k", 0x06b}, + { "l", 0x06c}, + { "m", 0x06d}, + { "n", 0x06e}, + { "o", 0x06f}, + { "p", 0x070}, + { "q", 0x071}, + { "r", 0x072}, + { "s", 0x073}, + { "t", 0x074}, + { "u", 0x075}, + { "v", 0x076}, + { "w", 0x077}, + { "x", 0x078}, + { "y", 0x079}, + { "z", 0x07a}, + { "braceleft", 0x07b}, + { "bar", 0x07c}, + { "braceright", 0x07d}, + { "asciitilde", 0x07e}, + +/* latin 1 extensions */ +{ "nobreakspace", 0x0a0}, +{ "exclamdown", 0x0a1}, +{ "cent", 0x0a2}, +{ "sterling", 0x0a3}, +{ "currency", 0x0a4}, +{ "yen", 0x0a5}, +{ "brokenbar", 0x0a6}, +{ "section", 0x0a7}, +{ "diaeresis", 0x0a8}, +{ "copyright", 0x0a9}, +{ "ordfeminine", 0x0aa}, +{ "guillemotleft", 0x0ab}, +{ "notsign", 0x0ac}, +{ "hyphen", 0x0ad}, +{ "registered", 0x0ae}, +{ "macron", 0x0af}, +{ "degree", 0x0b0}, +{ "plusminus", 0x0b1}, +{ "twosuperior", 0x0b2}, +{ "threesuperior", 0x0b3}, +{ "acute", 0x0b4}, +{ "mu", 0x0b5}, +{ "paragraph", 0x0b6}, +{ "periodcentered", 0x0b7}, +{ "cedilla", 0x0b8}, +{ "onesuperior", 0x0b9}, +{ "masculine", 0x0ba}, +{ "guillemotright", 0x0bb}, +{ "onequarter", 0x0bc}, +{ "onehalf", 0x0bd}, +{ "threequarters", 0x0be}, +{ "questiondown", 0x0bf}, +{ "Agrave", 0x0c0}, +{ "Aacute", 0x0c1}, +{ "Acircumflex", 0x0c2}, +{ "Atilde", 0x0c3}, +{ "Adiaeresis", 0x0c4}, +{ "Aring", 0x0c5}, +{ "AE", 0x0c6}, +{ "Ccedilla", 0x0c7}, +{ "Egrave", 0x0c8}, +{ "Eacute", 0x0c9}, +{ "Ecircumflex", 0x0ca}, +{ "Ediaeresis", 0x0cb}, +{ "Igrave", 0x0cc}, +{ "Iacute", 0x0cd}, +{ "Icircumflex", 0x0ce}, +{ "Idiaeresis", 0x0cf}, +{ "ETH", 0x0d0}, +{ "Eth", 0x0d0}, +{ "Ntilde", 0x0d1}, +{ "Ograve", 0x0d2}, +{ "Oacute", 0x0d3}, +{ "Ocircumflex", 0x0d4}, +{ "Otilde", 0x0d5}, +{ "Odiaeresis", 0x0d6}, +{ "multiply", 0x0d7}, +{ "Ooblique", 0x0d8}, +{ "Oslash", 0x0d8}, +{ "Ugrave", 0x0d9}, +{ "Uacute", 0x0da}, +{ "Ucircumflex", 0x0db}, +{ "Udiaeresis", 0x0dc}, +{ "Yacute", 0x0dd}, +{ "THORN", 0x0de}, +{ "Thorn", 0x0de}, +{ "ssharp", 0x0df}, +{ "agrave", 0x0e0}, +{ "aacute", 0x0e1}, +{ "acircumflex", 0x0e2}, +{ "atilde", 0x0e3}, +{ "adiaeresis", 0x0e4}, +{ "aring", 0x0e5}, +{ "ae", 0x0e6}, +{ "ccedilla", 0x0e7}, +{ "egrave", 0x0e8}, +{ "eacute", 0x0e9}, +{ "ecircumflex", 0x0ea}, +{ "ediaeresis", 0x0eb}, +{ "igrave", 0x0ec}, +{ "iacute", 0x0ed}, +{ "icircumflex", 0x0ee}, +{ "idiaeresis", 0x0ef}, +{ "eth", 0x0f0}, +{ "ntilde", 0x0f1}, +{ "ograve", 0x0f2}, +{ "oacute", 0x0f3}, +{ "ocircumflex", 0x0f4}, +{ "otilde", 0x0f5}, +{ "odiaeresis", 0x0f6}, +{ "division", 0x0f7}, +{ "oslash", 0x0f8}, +{ "ooblique", 0x0f8}, +{ "ugrave", 0x0f9}, +{ "uacute", 0x0fa}, +{ "ucircumflex", 0x0fb}, +{ "udiaeresis", 0x0fc}, +{ "yacute", 0x0fd}, +{ "thorn", 0x0fe}, +{ "ydiaeresis", 0x0ff}, +{"EuroSign", XK_EuroSign}, + + /* modifiers */ +{"Control_L", XK_Control_L}, +{"Control_R", XK_Control_R}, +{"Alt_L", XK_Alt_L}, +{"Alt_R", XK_Alt_R}, +{"Caps_Lock", XK_Caps_Lock}, +{"Meta_L", XK_Meta_L}, +{"Meta_R", XK_Meta_R}, +{"Shift_L", XK_Shift_L}, +{"Shift_R", XK_Shift_R}, +{"Super_L", XK_Super_L}, +{"Super_R", XK_Super_R}, + + /* special keys */ +{"BackSpace", XK_BackSpace}, +{"Tab", XK_Tab}, +{"Return", XK_Return}, +{"Right", XK_Right}, +{"Left", XK_Left}, +{"Up", XK_Up}, +{"Down", XK_Down}, +{"Page_Down", XK_Page_Down}, +{"Page_Up", XK_Page_Up}, +{"Insert", XK_Insert}, +{"Delete", XK_Delete}, +{"Home", XK_Home}, +{"End", XK_End}, +{"Scroll_Lock", XK_Scroll_Lock}, +{"F1", XK_F1}, +{"F2", XK_F2}, +{"F3", XK_F3}, +{"F4", XK_F4}, +{"F5", XK_F5}, +{"F6", XK_F6}, +{"F7", XK_F7}, +{"F8", XK_F8}, +{"F9", XK_F9}, +{"F10", XK_F10}, +{"F11", XK_F11}, +{"F12", XK_F12}, +{"F13", XK_F13}, +{"F14", XK_F14}, +{"F15", XK_F15}, +{"Sys_Req", XK_Sys_Req}, +{"KP_0", XK_KP_0}, +{"KP_1", XK_KP_1}, +{"KP_2", XK_KP_2}, +{"KP_3", XK_KP_3}, +{"KP_4", XK_KP_4}, +{"KP_5", XK_KP_5}, +{"KP_6", XK_KP_6}, +{"KP_7", XK_KP_7}, +{"KP_8", XK_KP_8}, +{"KP_9", XK_KP_9}, +{"KP_Add", XK_KP_Add}, +{"KP_Decimal", XK_KP_Decimal}, +{"KP_Divide", XK_KP_Divide}, +{"KP_Enter", XK_KP_Enter}, +{"KP_Equal", XK_KP_Equal}, +{"KP_Multiply", XK_KP_Multiply}, +{"KP_Subtract", XK_KP_Subtract}, +{"help", XK_Help}, +{"Menu", XK_Menu}, +/*{"Power", XK_Power},*/ +{"Print", XK_Print}, +{"Mode_switch", XK_Mode_switch}, +/*{"Multi_Key", XK_Multi_Key},*/ +{"Num_Lock", XK_Num_Lock}, +{"Pause", XK_Pause}, +{"Escape", XK_Escape}, + +{0,0}, +}; ^ permalink raw reply [flat|nested] 68+ messages in thread
* Re: [Qemu-devel] USB Tablet Emulation 2006-04-10 8:23 ` [Qemu-devel] USB Tablet Emulation Brad Campbell @ 2006-04-10 8:32 ` Johannes Schindelin 2006-04-10 10:27 ` Brad Campbell 2006-04-19 17:18 ` [Qemu-devel] USB Tablet Emulation + VNC patch Troy Benjegerdes 1 sibling, 1 reply; 68+ messages in thread From: Johannes Schindelin @ 2006-04-10 8:32 UTC (permalink / raw) To: qemu-devel Hi, On Mon, 10 Apr 2006, Brad Campbell wrote: > Anthony Liguori wrote: > > I spent some time cleaning this all up. The following integrates Brad's > > patches and the patch from > > http://gnome.dnsalias.net/patches/qemu-hidmousexp.patch > > > > It adds a new emulated USB device that reports absolute coordinates. It > > also modifies SDL to operate in grabless mode when an absolute input device > > is enabled. I think it's pretty close to apply-able. To use, just specify: > > -usbdevice tablet > > > > With Xorg from CVS, the evdev driver segfaults. This is apparently expected > > behavior. Hopefully it will be fixed soon. It works quite nicely under > > Win2k. > > Here is the vnc patch to go on top of that and the latest cvs. Before anybody complains: vnc.c needs a major cleanup (what with all that magic mouse stuff), and there are more things in the patch, like releasing Ctrl+Alt just before savevm'ing. I will do the cleanup this week if nobody else is faster... Also note that I got a patch to implement "-vnclisten <localhost | any>" to possibly restrict access from anywhere but localhost. Ciao, Dscho ^ permalink raw reply [flat|nested] 68+ messages in thread
* Re: [Qemu-devel] USB Tablet Emulation 2006-04-10 8:32 ` Johannes Schindelin @ 2006-04-10 10:27 ` Brad Campbell 2006-04-10 11:27 ` Johannes Schindelin 0 siblings, 1 reply; 68+ messages in thread From: Brad Campbell @ 2006-04-10 10:27 UTC (permalink / raw) To: qemu-devel Johannes Schindelin wrote: >>> With Xorg from CVS, the evdev driver segfaults. This is apparently expected >>> behavior. Hopefully it will be fixed soon. It works quite nicely under >>> Win2k. >> Here is the vnc patch to go on top of that and the latest cvs. > > Before anybody complains: vnc.c needs a major cleanup (what with all that > magic mouse stuff), and there are more things in the patch, like releasing > Ctrl+Alt just before savevm'ing. Not complaining at all. I was looking at removing the magic mouse stuff but that would then remove functionality for clients that currently can't use the hid-abs support. So I left it there and patched it up to work. My feeling is with the current functionality for mice, vnc is probably reaching the point where it could be merged. -- "Human beings, who are almost unique in having the ability to learn from the experience of others, are also remarkable for their apparent disinclination to do so." -- Douglas Adams ^ permalink raw reply [flat|nested] 68+ messages in thread
* Re: [Qemu-devel] USB Tablet Emulation 2006-04-10 10:27 ` Brad Campbell @ 2006-04-10 11:27 ` Johannes Schindelin 0 siblings, 0 replies; 68+ messages in thread From: Johannes Schindelin @ 2006-04-10 11:27 UTC (permalink / raw) To: qemu-devel Hi, On Mon, 10 Apr 2006, Brad Campbell wrote: > Not complaining at all. I was looking at removing the magic mouse stuff but > that would then remove functionality for clients that currently can't use the > hid-abs support. So I left it there and patched it up to work. Good! I'll give it a try tonight. > My feeling is with the current functionality for mice, vnc is probably > reaching the point where it could be merged. I'd like Wacom to work with Win98 first... Something like Beos is much more likely to work if that stage is already reached. Ciao, Dscho ^ permalink raw reply [flat|nested] 68+ messages in thread
* [Qemu-devel] USB Tablet Emulation + VNC patch.. 2006-04-10 8:23 ` [Qemu-devel] USB Tablet Emulation Brad Campbell 2006-04-10 8:32 ` Johannes Schindelin @ 2006-04-19 17:18 ` Troy Benjegerdes 2006-04-21 21:13 ` Brad Campbell 1 sibling, 1 reply; 68+ messages in thread From: Troy Benjegerdes @ 2006-04-19 17:18 UTC (permalink / raw) To: qemu-devel On Mon, Apr 10, 2006 at 12:23:05PM +0400, Brad Campbell wrote: > Anthony Liguori wrote: > >I spent some time cleaning this all up. The following integrates Brad's > >patches and the patch from > >http://gnome.dnsalias.net/patches/qemu-hidmousexp.patch > > > >It adds a new emulated USB device that reports absolute coordinates. It > >also modifies SDL to operate in grabless mode when an absolute input > >device is enabled. I think it's pretty close to apply-able. To use, > >just specify: -usbdevice tablet > > > >With Xorg from CVS, the evdev driver segfaults. This is apparently > >expected behavior. Hopefully it will be fixed soon. It works quite > >nicely under Win2k. > > Here is the vnc patch to go on top of that and the latest cvs. This works beautifully so far.. I applied the VNC patch to the latest qemu CVS (which has the usb tablet emulation already). Now, does anyone have instructions on how to get Win2k installed and updated to the latest set of security patches? I can get service pack 4 installed, but running windowsupdate seems to never work right. ^ permalink raw reply [flat|nested] 68+ messages in thread
* Re: [Qemu-devel] USB Tablet Emulation + VNC patch.. 2006-04-19 17:18 ` [Qemu-devel] USB Tablet Emulation + VNC patch Troy Benjegerdes @ 2006-04-21 21:13 ` Brad Campbell 2006-04-26 0:55 ` Troy Benjegerdes 0 siblings, 1 reply; 68+ messages in thread From: Brad Campbell @ 2006-04-21 21:13 UTC (permalink / raw) To: qemu-devel Troy Benjegerdes wrote: > On Mon, Apr 10, 2006 at 12:23:05PM +0400, Brad Campbell wrote: >> Anthony Liguori wrote: >>> I spent some time cleaning this all up. The following integrates Brad's >>> patches and the patch from >>> http://gnome.dnsalias.net/patches/qemu-hidmousexp.patch >>> >>> It adds a new emulated USB device that reports absolute coordinates. It >>> also modifies SDL to operate in grabless mode when an absolute input >>> device is enabled. I think it's pretty close to apply-able. To use, >>> just specify: -usbdevice tablet >>> >>> With Xorg from CVS, the evdev driver segfaults. This is apparently >>> expected behavior. Hopefully it will be fixed soon. It works quite >>> nicely under Win2k. >> Here is the vnc patch to go on top of that and the latest cvs. > > This works beautifully so far.. I applied the VNC patch to the latest > qemu CVS (which has the usb tablet emulation already). > > Now, does anyone have instructions on how to get Win2k installed and > updated to the latest set of security patches? I can get service pack 4 > installed, but running windowsupdate seems to never work right. If I run it up with -win2k-hack then windowsupdate works fine.. Here is what I did though (although variants have worked) Install win2k-sp4 run windowsupdate and ignore the warning about ie6, let it install the updated windows-update component. Reboot, install ie6, reboot, then run windows-update and install all the patches. All of this with win2k-hack enabled or it won't work.. and the updated win2k-hack from Leo so it works with dma.. -- "Human beings, who are almost unique in having the ability to learn from the experience of others, are also remarkable for their apparent disinclination to do so." -- Douglas Adams ^ permalink raw reply [flat|nested] 68+ messages in thread
* Re: [Qemu-devel] USB Tablet Emulation + VNC patch.. 2006-04-21 21:13 ` Brad Campbell @ 2006-04-26 0:55 ` Troy Benjegerdes 2006-04-26 7:37 ` Brad Campbell 0 siblings, 1 reply; 68+ messages in thread From: Troy Benjegerdes @ 2006-04-26 0:55 UTC (permalink / raw) To: qemu-devel > >Now, does anyone have instructions on how to get Win2k installed and > >updated to the latest set of security patches? I can get service pack 4 > >installed, but running windowsupdate seems to never work right. > > If I run it up with -win2k-hack then windowsupdate works fine.. > Here is what I did though (although variants have worked) > > Install win2k-sp4 > run windowsupdate and ignore the warning about ie6, let it install the > updated windows-update component. Reboot, install ie6, reboot, then run > windows-update and install all the patches. > > All of this with win2k-hack enabled or it won't work.. and the updated > win2k-hack from Leo so it works with dma.. I'm still stuck with windowsupdate not working.. I am finding now that after I go through installing win2k, and running ie5, I can see it has 56 bit encryption. But after installing service pack 3 and service pack 4, IE says '0-bit encryption'. I think this means there is a DLL or something corrupted somewhere, but I have no idea how to find out where. I am wondering if delaying the interrupt every time instead of every 16th time really is needed.. Is there any good way to detect the behavior that needs to have the delay in qemu and print out a warning on the console? I have also found that haveing '-usbdevice tablet' enabled during the install sometimes results in the mouse stopping working halfway through the install, although it's never consistent when it stops. ^ permalink raw reply [flat|nested] 68+ messages in thread
* Re: [Qemu-devel] USB Tablet Emulation + VNC patch.. 2006-04-26 0:55 ` Troy Benjegerdes @ 2006-04-26 7:37 ` Brad Campbell 0 siblings, 0 replies; 68+ messages in thread From: Brad Campbell @ 2006-04-26 7:37 UTC (permalink / raw) To: qemu-devel Troy Benjegerdes wrote: >>> Now, does anyone have instructions on how to get Win2k installed and >>> updated to the latest set of security patches? I can get service pack 4 >>> installed, but running windowsupdate seems to never work right. >> If I run it up with -win2k-hack then windowsupdate works fine.. >> Here is what I did though (although variants have worked) >> >> Install win2k-sp4 >> run windowsupdate and ignore the warning about ie6, let it install the >> updated windows-update component. Reboot, install ie6, reboot, then run >> windows-update and install all the patches. >> >> All of this with win2k-hack enabled or it won't work.. and the updated >> win2k-hack from Leo so it works with dma.. > > I'm still stuck with windowsupdate not working.. > > I am finding now that after I go through installing win2k, and running > ie5, I can see it has 56 bit encryption. But after installing service > pack 3 and service pack 4, IE says '0-bit encryption'. Better to download SP4 complete.. don't use windows update to install the service packs, just install and load SP4 without interracting with the net at all.. sp3 does strange things.. -- "Human beings, who are almost unique in having the ability to learn from the experience of others, are also remarkable for their apparent disinclination to do so." -- Douglas Adams ^ permalink raw reply [flat|nested] 68+ messages in thread
* Re: [Qemu-devel] USB Tablet Emulation 2006-04-10 3:40 ` [Qemu-devel] USB Tablet Emulation (was: Gentlemen we have absolute movement! was:Absolute USB-HID device musings (was Re: VNC Terminal Server)) Anthony Liguori 2006-04-10 8:23 ` [Qemu-devel] USB Tablet Emulation Brad Campbell @ 2006-04-10 14:58 ` Leonardo E. Reiter 2006-04-10 15:27 ` Anthony Liguori 1 sibling, 1 reply; 68+ messages in thread From: Leonardo E. Reiter @ 2006-04-10 14:58 UTC (permalink / raw) To: qemu-devel Anthony, your patch works perfectly, even with Windows XP as well. The transition from the boot-time PS/2 mouse is perfect, and the way the cursor grab logic is handled is seamless. I haven't been able to test the scroll wheel because I have some hardware restrictions today (laptop only for a while)... does that still work as well? I also tested it as a normal X11 application on top of an Xvnc server, and that works great, even with -full-screen set. Thank you, Leo Reiter Anthony Liguori wrote: > I spent some time cleaning this all up. The following integrates Brad's > patches and the patch from > http://gnome.dnsalias.net/patches/qemu-hidmousexp.patch > > It adds a new emulated USB device that reports absolute coordinates. It > also modifies SDL to operate in grabless mode when an absolute input > device is enabled. I think it's pretty close to apply-able. To use, > just specify: -usbdevice tablet > > With Xorg from CVS, the evdev driver segfaults. This is apparently > expected behavior. Hopefully it will be fixed soon. It works quite > nicely under Win2k. > > Regards, > > Anthony Liguori > > Brad Campbell wrote: > >> Anthony Liguori wrote: >> >>> >>> Final one of the night. This patch disables relative mouse reporting >>> and disables grab automatically the first time SDL detects that the >>> absolute mouse was enabled. Needs a lot of cleanup but I'm very >>> happy with the user experience on this one. >>> >> >> Wish I'd just gone to bed now.. >> Heres a patch against your last one to implement wheel support. >> >> Brad >> ------------------------------------------------------------------------ >> >> diff -ur qemu-clean/hw/usb-hid.c qemu/hw/usb-hid.c >> --- qemu-clean/hw/usb-hid.c 2006-04-10 02:57:46.000000000 +0400 >> +++ qemu/hw/usb-hid.c 2006-04-10 03:11:58.000000000 +0400 >> @@ -101,7 +101,7 @@ >> 0x00, /* u8 country_code */ >> 0x01, /* u8 num_descriptors */ >> 0x22, /* u8 type; Report */ >> - 53, 0, /* u16 len */ >> + 65, 0, /* u16 len */ >> >> /* one endpoint (status change endpoint) */ >> 0x07, /* u8 ep_bLength; */ >> @@ -145,14 +145,15 @@ >> 0x09, 0x31, /* Usage Y */ >> 0x15, 0x00, /* Logical Minimum 0 */ >> 0x27, 0xFF, 0xFF, 0x00, 0x00, /* Logical Maximum 0xffff */ >> - 0x75, 0x10, /* Report Size 32 */ >> + 0x75, 0x10, /* Report Size 16 */ >> 0x95, 0x02, /* Report Count 2 */ >> 0x81, 0x02, /* Input (Data, Var, Abs) */ >> -// 0x09, 0x32, /* Usage Z */ >> -// 0x15, 0x81, /* Logical Minimum -127 */ >> -// 0x25, 0x7F, /* Logical Maximum 127 */ >> -// 0x75, 0x08, /* Report Size 8 */ >> -// 0x95, 0x01, /* Report Count 1 */ >> + 0x09, 0x38, /* Usage Wheel */ >> + 0x15, 0x81, /* Logical Minimum -127 */ >> + 0x25, 0x7F, /* Logical Maximum 127 */ >> + 0x75, 0x08, /* Report Size 8 */ >> + 0x95, 0x01, /* Report Count 1 */ >> + 0x81, 0x02, /* Input (Data, Var, Rel) */ >> 0xC0, /* End Collection */ >> 0xC0, /* End Collection */ >> }; >> @@ -224,14 +225,18 @@ >> qemu_add_mouse_event_handler(NULL, NULL); >> absolute_mouse = 1; >> } >> - >> +/* >> dx = int_clamp(s->dx, -128, 127); >> dy = int_clamp(s->dy, -128, 127); >> - dz = int_clamp(s->dz, -128, 127); >> >> s->dx -= dx; >> s->dy -= dy; >> +*/ >> + >> + dz = int_clamp(s->dz, -128, 127); >> s->dz -= dz; >> +/* Appears we have to invert the wheel direction */ >> + dz = 0 - dz; >> b = 0; >> if (s->buttons_state & MOUSE_EVENT_LBUTTON) >> b |= 0x01; >> @@ -245,7 +250,8 @@ >> buf[2] = s->X >> 8; >> buf[3] = s->Y & 0xff; >> buf[4] = s->Y >> 8; >> - l = 5; >> + buf[5] = dz; >> + l = 6; >> >> return l; >> } >> >> ------------------------------------------------------------------------ >> >> _______________________________________________ >> Qemu-devel mailing list >> Qemu-devel@nongnu.org >> http://lists.nongnu.org/mailman/listinfo/qemu-devel >> > > > > ------------------------------------------------------------------------ > > diff -r 6a786a97b822 hw/ps2.c > --- a/hw/ps2.c Mon Apr 10 01:47:35 2006 +0000 > +++ b/hw/ps2.c Sun Apr 9 22:34:20 2006 -0500 > @@ -560,7 +560,7 @@ > s->common.update_arg = update_arg; > ps2_reset(&s->common); > register_savevm("ps2mouse", 0, 2, ps2_mouse_save, ps2_mouse_load, s); > - qemu_add_mouse_event_handler(ps2_mouse_event, s); > + qemu_add_mouse_event_handler(ps2_mouse_event, s, 0); > qemu_register_reset(ps2_reset, &s->common); > return s; > } > diff -r 6a786a97b822 hw/usb-hid.c > --- a/hw/usb-hid.c Mon Apr 10 01:47:35 2006 +0000 > +++ b/hw/usb-hid.c Sun Apr 9 22:34:20 2006 -0500 > @@ -30,9 +30,15 @@ > #define SET_IDLE 0x210a > #define SET_PROTOCOL 0x210b > > +#define USB_MOUSE 1 > +#define USB_TABLET 2 > + > typedef struct USBMouseState { > USBDevice dev; > int dx, dy, dz, buttons_state; > + int x, y; > + int kind; > + int mouse_grabbed; > } USBMouseState; > > /* mostly the same values as the Bochs USB Mouse device */ > @@ -93,14 +99,6 @@ > 0x02, /* u8 if_bInterfaceProtocol; [usb1.1 or single tt] */ > 0x05, /* u8 if_iInterface; */ > > - /* one endpoint (status change endpoint) */ > - 0x07, /* u8 ep_bLength; */ > - 0x05, /* u8 ep_bDescriptorType; Endpoint */ > - 0x81, /* u8 ep_bEndpointAddress; IN Endpoint 1 */ > - 0x03, /* u8 ep_bmAttributes; Interrupt */ > - 0x03, 0x00, /* u16 ep_wMaxPacketSize; */ > - 0x0a, /* u8 ep_bInterval; (255ms -- usb 2.0 spec) */ > - > /* HID descriptor */ > 0x09, /* u8 bLength; */ > 0x21, /* u8 bDescriptorType; */ > @@ -109,6 +107,69 @@ > 0x01, /* u8 num_descriptors */ > 0x22, /* u8 type; Report */ > 50, 0, /* u16 len */ > + > + /* one endpoint (status change endpoint) */ > + 0x07, /* u8 ep_bLength; */ > + 0x05, /* u8 ep_bDescriptorType; Endpoint */ > + 0x81, /* u8 ep_bEndpointAddress; IN Endpoint 1 */ > + 0x03, /* u8 ep_bmAttributes; Interrupt */ > + 0x03, 0x00, /* u16 ep_wMaxPacketSize; */ > + 0x0a, /* u8 ep_bInterval; (255ms -- usb 2.0 spec) */ > +}; > + > +static const uint8_t qemu_tablet_config_descriptor[] = { > + /* one configuration */ > + 0x09, /* u8 bLength; */ > + 0x02, /* u8 bDescriptorType; Configuration */ > + 0x22, 0x00, /* u16 wTotalLength; */ > + 0x01, /* u8 bNumInterfaces; (1) */ > + 0x01, /* u8 bConfigurationValue; */ > + 0x04, /* u8 iConfiguration; */ > + 0xa0, /* u8 bmAttributes; > + Bit 7: must be set, > + 6: Self-powered, > + 5: Remote wakeup, > + 4..0: resvd */ > + 50, /* u8 MaxPower; */ > + > + /* USB 1.1: > + * USB 2.0, single TT organization (mandatory): > + * one interface, protocol 0 > + * > + * USB 2.0, multiple TT organization (optional): > + * two interfaces, protocols 1 (like single TT) > + * and 2 (multiple TT mode) ... config is > + * sometimes settable > + * NOT IMPLEMENTED > + */ > + > + /* one interface */ > + 0x09, /* u8 if_bLength; */ > + 0x04, /* u8 if_bDescriptorType; Interface */ > + 0x00, /* u8 if_bInterfaceNumber; */ > + 0x00, /* u8 if_bAlternateSetting; */ > + 0x01, /* u8 if_bNumEndpoints; */ > + 0x03, /* u8 if_bInterfaceClass; */ > + 0x01, /* u8 if_bInterfaceSubClass; */ > + 0x02, /* u8 if_bInterfaceProtocol; [usb1.1 or single tt] */ > + 0x05, /* u8 if_iInterface; */ > + > + /* HID descriptor */ > + 0x09, /* u8 bLength; */ > + 0x21, /* u8 bDescriptorType; */ > + 0x01, 0x00, /* u16 HID_class */ > + 0x00, /* u8 country_code */ > + 0x01, /* u8 num_descriptors */ > + 0x22, /* u8 type; Report */ > + 65, 0, /* u16 len */ > + > + /* one endpoint (status change endpoint) */ > + 0x07, /* u8 ep_bLength; */ > + 0x05, /* u8 ep_bDescriptorType; Endpoint */ > + 0x81, /* u8 ep_bEndpointAddress; IN Endpoint 1 */ > + 0x03, /* u8 ep_bmAttributes; Interrupt */ > + 0x08, 0x00, /* u16 ep_wMaxPacketSize; */ > + 0x03, /* u8 ep_bInterval; (255ms -- usb 2.0 spec) */ > }; > > static const uint8_t qemu_mouse_hid_report_descriptor[] = { > @@ -121,6 +182,41 @@ > 0xC0, 0xC0, > }; > > +static const uint8_t qemu_tablet_hid_report_descriptor[] = { > + 0x05, 0x01, /* Usage Page Generic Desktop */ > + 0x09, 0x01, /* Usage Mouse */ > + 0xA1, 0x01, /* Collection Application */ > + 0x09, 0x01, /* Usage Pointer */ > + 0xA1, 0x00, /* Collection Physical */ > + 0x05, 0x09, /* Usage Page Button */ > + 0x19, 0x01, /* Usage Minimum Button 1 */ > + 0x29, 0x03, /* Usage Maximum Button 3 */ > + 0x15, 0x00, /* Logical Minimum 0 */ > + 0x25, 0x01, /* Logical Maximum 1 */ > + 0x95, 0x03, /* Report Count 3 */ > + 0x75, 0x01, /* Report Size 1 */ > + 0x81, 0x02, /* Input (Data, Var, Abs) */ > + 0x95, 0x01, /* Report Count 1 */ > + 0x75, 0x05, /* Report Size 5 */ > + 0x81, 0x01, /* Input (Cnst, Var, Abs) */ > + 0x05, 0x01, /* Usage Page Generic Desktop */ > + 0x09, 0x30, /* Usage X */ > + 0x09, 0x31, /* Usage Y */ > + 0x15, 0x00, /* Logical Minimum 0 */ > + 0x27, 0xFF, 0xFF, 0x00, 0x00, /* Logical Maximum 0xffff */ > + 0x75, 0x10, /* Report Size 16 */ > + 0x95, 0x02, /* Report Count 2 */ > + 0x81, 0x02, /* Input (Data, Var, Abs) */ > + 0x09, 0x38, /* Usage Wheel */ > + 0x15, 0x81, /* Logical Minimum -127 */ > + 0x25, 0x7F, /* Logical Maximum 127 */ > + 0x75, 0x08, /* Report Size 8 */ > + 0x95, 0x01, /* Report Count 1 */ > + 0x81, 0x02, /* Input (Data, Var, Rel) */ > + 0xC0, /* End Collection */ > + 0xC0, /* End Collection */ > +}; > + > static void usb_mouse_event(void *opaque, > int dx1, int dy1, int dz1, int buttons_state) > { > @@ -129,6 +225,17 @@ > s->dx += dx1; > s->dy += dy1; > s->dz += dz1; > + s->buttons_state = buttons_state; > +} > + > +static void usb_tablet_event(void *opaque, > + int x, int y, int dz, int buttons_state) > +{ > + USBMouseState *s = opaque; > + > + s->x = x; > + s->y = y; > + s->dz += dz; > s->buttons_state = buttons_state; > } > > @@ -146,6 +253,11 @@ > { > int dx, dy, dz, b, l; > > + if (!s->mouse_grabbed) { > + qemu_add_mouse_event_handler(usb_mouse_event, s, 0); > + s->mouse_grabbed = 1; > + } > + > dx = int_clamp(s->dx, -128, 127); > dy = int_clamp(s->dy, -128, 127); > dz = int_clamp(s->dz, -128, 127); > @@ -173,6 +285,39 @@ > return l; > } > > +static int usb_tablet_poll(USBMouseState *s, uint8_t *buf, int len) > +{ > + int dz, b, l; > + > + if (!s->mouse_grabbed) { > + qemu_add_mouse_event_handler(usb_tablet_event, s, 1); > + s->mouse_grabbed = 1; > + } > + > + dz = int_clamp(s->dz, -128, 127); > + s->dz -= dz; > + > + /* Appears we have to invert the wheel direction */ > + dz = 0 - dz; > + b = 0; > + if (s->buttons_state & MOUSE_EVENT_LBUTTON) > + b |= 0x01; > + if (s->buttons_state & MOUSE_EVENT_RBUTTON) > + b |= 0x02; > + if (s->buttons_state & MOUSE_EVENT_MBUTTON) > + b |= 0x04; > + > + buf[0] = b; > + buf[1] = s->x & 0xff; > + buf[2] = s->x >> 8; > + buf[3] = s->y & 0xff; > + buf[4] = s->y >> 8; > + buf[5] = dz; > + l = 6; > + > + return l; > +} > + > static void usb_mouse_handle_reset(USBDevice *dev) > { > USBMouseState *s = (USBMouseState *)dev; > @@ -180,6 +325,8 @@ > s->dx = 0; > s->dy = 0; > s->dz = 0; > + s->x = 0; > + s->y = 0; > s->buttons_state = 0; > } > > @@ -187,7 +334,7 @@ > int index, int length, uint8_t *data) > { > USBMouseState *s = (USBMouseState *)dev; > - int ret; > + int ret = 0; > > switch(request) { > case DeviceRequest | USB_REQ_GET_STATUS: > @@ -224,9 +371,15 @@ > ret = sizeof(qemu_mouse_dev_descriptor); > break; > case USB_DT_CONFIG: > - memcpy(data, qemu_mouse_config_descriptor, > - sizeof(qemu_mouse_config_descriptor)); > - ret = sizeof(qemu_mouse_config_descriptor); > + if (s->kind == USB_MOUSE) { > + memcpy(data, qemu_mouse_config_descriptor, > + sizeof(qemu_mouse_config_descriptor)); > + ret = sizeof(qemu_mouse_config_descriptor); > + } else if (s->kind == USB_TABLET) { > + memcpy(data, qemu_tablet_config_descriptor, > + sizeof(qemu_tablet_config_descriptor)); > + ret = sizeof(qemu_tablet_config_descriptor); > + } > break; > case USB_DT_STRING: > switch(value & 0xff) { > @@ -244,7 +397,10 @@ > break; > case 2: > /* product description */ > - ret = set_usb_string(data, "QEMU USB Mouse"); > + if (s->kind == USB_MOUSE) > + ret = set_usb_string(data, "QEMU USB Mouse"); > + else if (s->kind == USB_TABLET) > + ret = set_usb_string(data, "QEMU USB Tablet"); > break; > case 3: > /* vendor description */ > @@ -282,16 +438,25 @@ > case InterfaceRequest | USB_REQ_GET_DESCRIPTOR: > switch(value >> 8) { > case 0x22: > - memcpy(data, qemu_mouse_hid_report_descriptor, > - sizeof(qemu_mouse_hid_report_descriptor)); > - ret = sizeof(qemu_mouse_hid_report_descriptor); > - break; > + if (s->kind == USB_MOUSE) { > + memcpy(data, qemu_mouse_hid_report_descriptor, > + sizeof(qemu_mouse_hid_report_descriptor)); > + ret = sizeof(qemu_mouse_hid_report_descriptor); > + } else if (s->kind == USB_TABLET) { > + memcpy(data, qemu_tablet_hid_report_descriptor, > + sizeof(qemu_tablet_hid_report_descriptor)); > + ret = sizeof(qemu_tablet_hid_report_descriptor); > + } > + break; > default: > goto fail; > } > break; > case GET_REPORT: > - ret = usb_mouse_poll(s, data, length); > + if (s->kind == USB_MOUSE) > + ret = usb_mouse_poll(s, data, length); > + else if (s->kind == USB_TABLET) > + ret = usb_tablet_poll(s, data, length); > break; > case SET_IDLE: > ret = 0; > @@ -308,12 +473,15 @@ > uint8_t devep, uint8_t *data, int len) > { > USBMouseState *s = (USBMouseState *)dev; > - int ret; > + int ret = 0; > > switch(pid) { > case USB_TOKEN_IN: > if (devep == 1) { > - ret = usb_mouse_poll(s, data, len); > + if (s->kind == USB_MOUSE) > + ret = usb_mouse_poll(s, data, len); > + else if (s->kind == USB_TABLET) > + ret = usb_tablet_poll(s, data, len); > } else { > goto fail; > } > @@ -327,7 +495,7 @@ > return ret; > } > > -USBDevice *usb_mouse_init(void) > +USBDevice *usb_tablet_init(void) > { > USBMouseState *s; > > @@ -340,8 +508,25 @@ > s->dev.handle_reset = usb_mouse_handle_reset; > s->dev.handle_control = usb_mouse_handle_control; > s->dev.handle_data = usb_mouse_handle_data; > - > - qemu_add_mouse_event_handler(usb_mouse_event, s); > - > + s->kind = USB_TABLET; > + > return (USBDevice *)s; > } > + > +USBDevice *usb_mouse_init(void) > +{ > + USBMouseState *s; > + > + s = qemu_mallocz(sizeof(USBMouseState)); > + if (!s) > + return NULL; > + s->dev.speed = USB_SPEED_FULL; > + s->dev.handle_packet = usb_generic_handle_packet; > + > + s->dev.handle_reset = usb_mouse_handle_reset; > + s->dev.handle_control = usb_mouse_handle_control; > + s->dev.handle_data = usb_mouse_handle_data; > + s->kind = USB_MOUSE; > + > + return (USBDevice *)s; > +} > diff -r 6a786a97b822 hw/usb.h > --- a/hw/usb.h Mon Apr 10 01:47:35 2006 +0000 > +++ b/hw/usb.h Sun Apr 9 22:34:20 2006 -0500 > @@ -163,3 +163,4 @@ > > /* usb-hid.c */ > USBDevice *usb_mouse_init(void); > +USBDevice *usb_tablet_init(void); > diff -r 6a786a97b822 sdl.c > --- a/sdl.c Mon Apr 10 01:47:35 2006 +0000 > +++ b/sdl.c Sun Apr 9 22:34:20 2006 -0500 > @@ -39,6 +39,10 @@ > static int gui_fullscreen_initial_grab; > static int gui_grab_code = KMOD_LALT | KMOD_LCTRL; > static uint8_t modifiers_state[256]; > +static int width, height; > +static SDL_Cursor *sdl_cursor_normal; > +static SDL_Cursor *sdl_cursor_hidden; > +static int absolute_enabled = 0; > > static void sdl_update(DisplayState *ds, int x, int y, int w, int h) > { > @@ -55,6 +59,9 @@ > flags = SDL_HWSURFACE|SDL_ASYNCBLIT|SDL_HWACCEL; > if (gui_fullscreen) > flags |= SDL_FULLSCREEN; > + > + width = w; > + height = h; > > again: > screen = SDL_SetVideoMode(w, h, 0, flags); > @@ -271,9 +278,21 @@ > SDL_WM_SetCaption(buf, "QEMU"); > } > > +static void sdl_hide_cursor(void) > +{ > + SDL_SetCursor(sdl_cursor_hidden); > +} > + > +static void sdl_show_cursor(void) > +{ > + if (!kbd_mouse_is_absolute()) { > + SDL_SetCursor(sdl_cursor_normal); > + } > +} > + > static void sdl_grab_start(void) > { > - SDL_ShowCursor(0); > + sdl_hide_cursor(); > SDL_WM_GrabInput(SDL_GRAB_ON); > /* dummy read to avoid moving the mouse */ > SDL_GetRelativeMouseState(NULL, NULL); > @@ -284,7 +303,7 @@ > static void sdl_grab_end(void) > { > SDL_WM_GrabInput(SDL_GRAB_OFF); > - SDL_ShowCursor(1); > + sdl_show_cursor(); > gui_grab = 0; > sdl_update_caption(); > } > @@ -300,6 +319,21 @@ > buttons |= MOUSE_EVENT_RBUTTON; > if (state & SDL_BUTTON(SDL_BUTTON_MIDDLE)) > buttons |= MOUSE_EVENT_MBUTTON; > + > + if (kbd_mouse_is_absolute()) { > + if (!absolute_enabled) { > + sdl_hide_cursor(); > + if (gui_grab) { > + sdl_grab_end(); > + } > + absolute_enabled = 1; > + } > + > + SDL_GetMouseState(&dx, &dy); > + dx = dx * 0x7FFF / width; > + dy = dy * 0x7FFF / height; > + } > + > kbd_mouse_event(dx, dy, dz, buttons); > } > > @@ -423,7 +457,7 @@ > qemu_system_shutdown_request(); > break; > case SDL_MOUSEMOTION: > - if (gui_grab) { > + if (gui_grab || kbd_mouse_is_absolute()) { > sdl_send_mouse_event(0); > } > break; > @@ -431,7 +465,7 @@ > case SDL_MOUSEBUTTONUP: > { > SDL_MouseButtonEvent *bev = &ev->button; > - if (!gui_grab) { > + if (!gui_grab && !kbd_mouse_is_absolute()) { > if (ev->type == SDL_MOUSEBUTTONDOWN && > (bev->state & SDL_BUTTON_LMASK)) { > /* start grabbing all events */ > @@ -471,6 +505,7 @@ > void sdl_display_init(DisplayState *ds, int full_screen) > { > int flags; > + uint8_t data = 0; > > #if defined(__APPLE__) > /* always use generic keymaps */ > @@ -504,6 +539,9 @@ > SDL_EnableUNICODE(1); > gui_grab = 0; > > + sdl_cursor_hidden = SDL_CreateCursor(&data, &data, 8, 1, 0, 0); > + sdl_cursor_normal = SDL_GetCursor(); > + > atexit(sdl_cleanup); > if (full_screen) { > gui_fullscreen = 1; > diff -r 6a786a97b822 vl.c > --- a/vl.c Mon Apr 10 01:47:35 2006 +0000 > +++ b/vl.c Sun Apr 9 22:34:20 2006 -0500 > @@ -474,6 +474,7 @@ > static void *qemu_put_kbd_event_opaque; > static QEMUPutMouseEvent *qemu_put_mouse_event; > static void *qemu_put_mouse_event_opaque; > +static int qemu_put_mouse_event_absolute; > > void qemu_add_kbd_event_handler(QEMUPutKBDEvent *func, void *opaque) > { > @@ -481,10 +482,11 @@ > qemu_put_kbd_event = func; > } > > -void qemu_add_mouse_event_handler(QEMUPutMouseEvent *func, void *opaque) > +void qemu_add_mouse_event_handler(QEMUPutMouseEvent *func, void *opaque, int absolute) > { > qemu_put_mouse_event_opaque = opaque; > qemu_put_mouse_event = func; > + qemu_put_mouse_event_absolute = absolute; > } > > void kbd_put_keycode(int keycode) > @@ -500,6 +502,11 @@ > qemu_put_mouse_event(qemu_put_mouse_event_opaque, > dx, dy, dz, buttons_state); > } > +} > + > +int kbd_mouse_is_absolute(void) > +{ > + return qemu_put_mouse_event_absolute; > } > > /***********************************************************/ > @@ -2855,6 +2862,10 @@ > dev = usb_mouse_init(); > if (!dev) > return -1; > + } else if (!strcmp(devname, "tablet")) { > + dev = usb_tablet_init(); > + if (!dev) > + return -1; > } else { > return -1; > } > diff -r 6a786a97b822 vl.h > --- a/vl.h Mon Apr 10 01:47:35 2006 +0000 > +++ b/vl.h Sun Apr 9 22:34:20 2006 -0500 > @@ -158,10 +158,11 @@ > typedef void QEMUPutMouseEvent(void *opaque, int dx, int dy, int dz, int buttons_state); > > void qemu_add_kbd_event_handler(QEMUPutKBDEvent *func, void *opaque); > -void qemu_add_mouse_event_handler(QEMUPutMouseEvent *func, void *opaque); > +void qemu_add_mouse_event_handler(QEMUPutMouseEvent *func, void *opaque, int absolute); > > void kbd_put_keycode(int keycode); > void kbd_mouse_event(int dx, int dy, int dz, int buttons_state); > +int kbd_mouse_is_absolute(void); > > /* keysym is a unicode code except for special keys (see QEMU_KEY_xxx > constants) */ > > > ------------------------------------------------------------------------ > > _______________________________________________ > Qemu-devel mailing list > Qemu-devel@nongnu.org > http://lists.nongnu.org/mailman/listinfo/qemu-devel -- Leonardo E. Reiter Vice President of Product Development, CTO Win4Lin, Inc. Virtual Computing from Desktop to Data Center Main: +1 512 339 7979 Fax: +1 512 532 6501 http://www.win4lin.com ^ permalink raw reply [flat|nested] 68+ messages in thread
* Re: [Qemu-devel] USB Tablet Emulation 2006-04-10 14:58 ` [Qemu-devel] USB Tablet Emulation Leonardo E. Reiter @ 2006-04-10 15:27 ` Anthony Liguori 2006-04-10 15:39 ` Leonardo E. Reiter 0 siblings, 1 reply; 68+ messages in thread From: Anthony Liguori @ 2006-04-10 15:27 UTC (permalink / raw) To: qemu-devel Leonardo E. Reiter wrote: > Anthony, > > your patch works perfectly, even with Windows XP as well. Make sure to give credit where credit's due. Brad Campbell figured out the hard stuff :-) > The transition from the boot-time PS/2 mouse is perfect, and the way > the cursor grab logic is handled is seamless. I haven't been able to > test the scroll wheel because I have some hardware restrictions today > (laptop only for a while)... does that still work as well? I haven't tried it but Brad has. Perhaps he can comment here. Regards, Anthony Liguori > I also tested it as a normal X11 application on top of an Xvnc server, > and that works great, even with -full-screen set. > > Thank you, > > Leo Reiter > > Anthony Liguori wrote: >> I spent some time cleaning this all up. The following integrates >> Brad's patches and the patch from >> http://gnome.dnsalias.net/patches/qemu-hidmousexp.patch >> >> It adds a new emulated USB device that reports absolute coordinates. >> It also modifies SDL to operate in grabless mode when an absolute >> input device is enabled. I think it's pretty close to apply-able. >> To use, just specify: -usbdevice tablet >> >> With Xorg from CVS, the evdev driver segfaults. This is apparently >> expected behavior. Hopefully it will be fixed soon. It works quite >> nicely under Win2k. >> >> Regards, >> >> Anthony Liguori >> >> Brad Campbell wrote: >> >>> Anthony Liguori wrote: >>> >>>> >>>> Final one of the night. This patch disables relative mouse >>>> reporting and disables grab automatically the first time SDL >>>> detects that the absolute mouse was enabled. Needs a lot of >>>> cleanup but I'm very happy with the user experience on this one. >>>> >>> >>> Wish I'd just gone to bed now.. >>> Heres a patch against your last one to implement wheel support. >>> >>> Brad >>> ------------------------------------------------------------------------ >>> >>> >>> diff -ur qemu-clean/hw/usb-hid.c qemu/hw/usb-hid.c >>> --- qemu-clean/hw/usb-hid.c 2006-04-10 02:57:46.000000000 +0400 >>> +++ qemu/hw/usb-hid.c 2006-04-10 03:11:58.000000000 +0400 >>> @@ -101,7 +101,7 @@ >>> 0x00, /* u8 country_code */ >>> 0x01, /* u8 num_descriptors */ >>> 0x22, /* u8 type; Report */ >>> - 53, 0, /* u16 len */ >>> + 65, 0, /* u16 len */ >>> >>> /* one endpoint (status change endpoint) */ >>> 0x07, /* u8 ep_bLength; */ >>> @@ -145,14 +145,15 @@ >>> 0x09, 0x31, /* Usage Y */ >>> 0x15, 0x00, /* Logical Minimum 0 */ >>> 0x27, 0xFF, 0xFF, 0x00, 0x00, /* Logical Maximum 0xffff */ >>> - 0x75, 0x10, /* Report Size 32 */ >>> + 0x75, 0x10, /* Report Size 16 */ >>> 0x95, 0x02, /* Report Count 2 */ >>> 0x81, 0x02, /* Input (Data, Var, Abs) */ >>> -// 0x09, 0x32, /* Usage Z */ >>> -// 0x15, 0x81, /* Logical Minimum -127 */ >>> -// 0x25, 0x7F, /* Logical Maximum 127 */ >>> -// 0x75, 0x08, /* Report Size 8 */ >>> -// 0x95, 0x01, /* Report Count 1 */ >>> + 0x09, 0x38, /* Usage Wheel */ >>> + 0x15, 0x81, /* Logical Minimum -127 */ >>> + 0x25, 0x7F, /* Logical Maximum 127 */ >>> + 0x75, 0x08, /* Report Size 8 */ >>> + 0x95, 0x01, /* Report Count 1 */ >>> + 0x81, 0x02, /* Input (Data, Var, Rel) */ >>> 0xC0, /* End Collection */ >>> 0xC0, /* End Collection */ >>> }; >>> @@ -224,14 +225,18 @@ >>> qemu_add_mouse_event_handler(NULL, NULL); >>> absolute_mouse = 1; >>> } >>> - >>> +/* >>> dx = int_clamp(s->dx, -128, 127); >>> dy = int_clamp(s->dy, -128, 127); >>> - dz = int_clamp(s->dz, -128, 127); >>> >>> s->dx -= dx; >>> s->dy -= dy; >>> +*/ >>> + >>> + dz = int_clamp(s->dz, -128, 127); >>> s->dz -= dz; >>> +/* Appears we have to invert the wheel direction */ >>> + dz = 0 - dz; >>> b = 0; >>> if (s->buttons_state & MOUSE_EVENT_LBUTTON) >>> b |= 0x01; >>> @@ -245,7 +250,8 @@ >>> buf[2] = s->X >> 8; >>> buf[3] = s->Y & 0xff; >>> buf[4] = s->Y >> 8; >>> - l = 5; >>> + buf[5] = dz; >>> + l = 6; >>> >>> return l; >>> } >>> >>> ------------------------------------------------------------------------ >>> >>> >>> _______________________________________________ >>> Qemu-devel mailing list >>> Qemu-devel@nongnu.org >>> http://lists.nongnu.org/mailman/listinfo/qemu-devel >>> >> >> >> >> ------------------------------------------------------------------------ >> >> diff -r 6a786a97b822 hw/ps2.c >> --- a/hw/ps2.c Mon Apr 10 01:47:35 2006 +0000 >> +++ b/hw/ps2.c Sun Apr 9 22:34:20 2006 -0500 >> @@ -560,7 +560,7 @@ >> s->common.update_arg = update_arg; >> ps2_reset(&s->common); >> register_savevm("ps2mouse", 0, 2, ps2_mouse_save, >> ps2_mouse_load, s); >> - qemu_add_mouse_event_handler(ps2_mouse_event, s); >> + qemu_add_mouse_event_handler(ps2_mouse_event, s, 0); >> qemu_register_reset(ps2_reset, &s->common); >> return s; >> } >> diff -r 6a786a97b822 hw/usb-hid.c >> --- a/hw/usb-hid.c Mon Apr 10 01:47:35 2006 +0000 >> +++ b/hw/usb-hid.c Sun Apr 9 22:34:20 2006 -0500 >> @@ -30,9 +30,15 @@ >> #define SET_IDLE 0x210a >> #define SET_PROTOCOL 0x210b >> >> +#define USB_MOUSE 1 >> +#define USB_TABLET 2 >> + >> typedef struct USBMouseState { >> USBDevice dev; >> int dx, dy, dz, buttons_state; >> + int x, y; >> + int kind; >> + int mouse_grabbed; >> } USBMouseState; >> >> /* mostly the same values as the Bochs USB Mouse device */ >> @@ -93,14 +99,6 @@ >> 0x02, /* u8 if_bInterfaceProtocol; [usb1.1 or single tt] */ >> 0x05, /* u8 if_iInterface; */ >> - /* one endpoint (status change endpoint) */ >> - 0x07, /* u8 ep_bLength; */ >> - 0x05, /* u8 ep_bDescriptorType; Endpoint */ >> - 0x81, /* u8 ep_bEndpointAddress; IN Endpoint 1 */ >> - 0x03, /* u8 ep_bmAttributes; Interrupt */ >> - 0x03, 0x00, /* u16 ep_wMaxPacketSize; */ >> - 0x0a, /* u8 ep_bInterval; (255ms -- usb 2.0 spec) */ >> - >> /* HID descriptor */ >> 0x09, /* u8 bLength; */ >> 0x21, /* u8 bDescriptorType; */ >> @@ -109,6 +107,69 @@ >> 0x01, /* u8 num_descriptors */ >> 0x22, /* u8 type; Report */ >> 50, 0, /* u16 len */ >> + >> + /* one endpoint (status change endpoint) */ >> + 0x07, /* u8 ep_bLength; */ >> + 0x05, /* u8 ep_bDescriptorType; Endpoint */ >> + 0x81, /* u8 ep_bEndpointAddress; IN Endpoint 1 */ >> + 0x03, /* u8 ep_bmAttributes; Interrupt */ >> + 0x03, 0x00, /* u16 ep_wMaxPacketSize; */ >> + 0x0a, /* u8 ep_bInterval; (255ms -- usb 2.0 spec) */ >> +}; >> + >> +static const uint8_t qemu_tablet_config_descriptor[] = { >> + /* one configuration */ >> + 0x09, /* u8 bLength; */ >> + 0x02, /* u8 bDescriptorType; Configuration */ >> + 0x22, 0x00, /* u16 wTotalLength; */ >> + 0x01, /* u8 bNumInterfaces; (1) */ >> + 0x01, /* u8 bConfigurationValue; */ >> + 0x04, /* u8 iConfiguration; */ >> + 0xa0, /* u8 bmAttributes; + Bit 7: must >> be set, >> + 6: Self-powered, >> + 5: Remote wakeup, >> + 4..0: resvd */ >> + 50, /* u8 MaxPower; */ >> + + /* USB 1.1: >> + * USB 2.0, single TT organization (mandatory): >> + * one interface, protocol 0 >> + * >> + * USB 2.0, multiple TT organization (optional): >> + * two interfaces, protocols 1 (like single TT) >> + * and 2 (multiple TT mode) ... config is >> + * sometimes settable >> + * NOT IMPLEMENTED >> + */ >> + >> + /* one interface */ >> + 0x09, /* u8 if_bLength; */ >> + 0x04, /* u8 if_bDescriptorType; Interface */ >> + 0x00, /* u8 if_bInterfaceNumber; */ >> + 0x00, /* u8 if_bAlternateSetting; */ >> + 0x01, /* u8 if_bNumEndpoints; */ >> + 0x03, /* u8 if_bInterfaceClass; */ >> + 0x01, /* u8 if_bInterfaceSubClass; */ >> + 0x02, /* u8 if_bInterfaceProtocol; [usb1.1 or single tt] */ >> + 0x05, /* u8 if_iInterface; */ >> + >> + /* HID descriptor */ >> + 0x09, /* u8 bLength; */ >> + 0x21, /* u8 bDescriptorType; */ >> + 0x01, 0x00, /* u16 HID_class */ >> + 0x00, /* u8 country_code */ >> + 0x01, /* u8 num_descriptors */ >> + 0x22, /* u8 type; Report */ >> + 65, 0, /* u16 len */ >> + >> + /* one endpoint (status change endpoint) */ >> + 0x07, /* u8 ep_bLength; */ >> + 0x05, /* u8 ep_bDescriptorType; Endpoint */ >> + 0x81, /* u8 ep_bEndpointAddress; IN Endpoint 1 */ >> + 0x03, /* u8 ep_bmAttributes; Interrupt */ >> + 0x08, 0x00, /* u16 ep_wMaxPacketSize; */ >> + 0x03, /* u8 ep_bInterval; (255ms -- usb 2.0 spec) */ >> }; >> >> static const uint8_t qemu_mouse_hid_report_descriptor[] = { >> @@ -121,6 +182,41 @@ >> 0xC0, 0xC0, >> }; >> >> +static const uint8_t qemu_tablet_hid_report_descriptor[] = { >> + 0x05, 0x01, /* Usage Page Generic Desktop */ >> + 0x09, 0x01, /* Usage Mouse */ >> + 0xA1, 0x01, /* Collection Application */ >> + 0x09, 0x01, /* Usage Pointer */ >> + 0xA1, 0x00, /* Collection Physical */ >> + 0x05, 0x09, /* Usage Page Button */ >> + 0x19, 0x01, /* Usage Minimum Button 1 */ >> + 0x29, 0x03, /* Usage Maximum Button 3 */ >> + 0x15, 0x00, /* Logical Minimum 0 */ >> + 0x25, 0x01, /* Logical Maximum 1 */ >> + 0x95, 0x03, /* Report Count 3 */ >> + 0x75, 0x01, /* Report Size 1 */ >> + 0x81, 0x02, /* Input (Data, Var, Abs) */ >> + 0x95, 0x01, /* Report Count 1 */ >> + 0x75, 0x05, /* Report Size 5 */ >> + 0x81, 0x01, /* Input (Cnst, Var, Abs) */ >> + 0x05, 0x01, /* Usage Page Generic Desktop */ >> + 0x09, 0x30, /* Usage X */ >> + 0x09, 0x31, /* Usage Y */ >> + 0x15, 0x00, /* Logical Minimum 0 */ >> + 0x27, 0xFF, 0xFF, 0x00, 0x00, /* Logical Maximum 0xffff */ >> + 0x75, 0x10, /* Report Size 16 */ >> + 0x95, 0x02, /* Report Count 2 */ >> + 0x81, 0x02, /* Input (Data, Var, Abs) */ >> + 0x09, 0x38, /* Usage Wheel */ >> + 0x15, 0x81, /* Logical Minimum -127 */ >> + 0x25, 0x7F, /* Logical Maximum 127 */ >> + 0x75, 0x08, /* Report Size 8 */ >> + 0x95, 0x01, /* Report Count 1 */ >> + 0x81, 0x02, /* Input (Data, Var, Rel) */ >> + 0xC0, /* End Collection */ >> + 0xC0, /* End Collection */ >> +}; >> + >> static void usb_mouse_event(void *opaque, >> int dx1, int dy1, int dz1, int >> buttons_state) >> { >> @@ -129,6 +225,17 @@ >> s->dx += dx1; >> s->dy += dy1; >> s->dz += dz1; >> + s->buttons_state = buttons_state; >> +} >> + >> +static void usb_tablet_event(void *opaque, >> + int x, int y, int dz, int buttons_state) >> +{ >> + USBMouseState *s = opaque; >> + >> + s->x = x; >> + s->y = y; >> + s->dz += dz; >> s->buttons_state = buttons_state; >> } >> >> @@ -146,6 +253,11 @@ >> { >> int dx, dy, dz, b, l; >> >> + if (!s->mouse_grabbed) { >> + qemu_add_mouse_event_handler(usb_mouse_event, s, 0); >> + s->mouse_grabbed = 1; >> + } >> + dx = int_clamp(s->dx, -128, 127); >> dy = int_clamp(s->dy, -128, 127); >> dz = int_clamp(s->dz, -128, 127); >> @@ -173,6 +285,39 @@ >> return l; >> } >> >> +static int usb_tablet_poll(USBMouseState *s, uint8_t *buf, int len) >> +{ >> + int dz, b, l; >> + >> + if (!s->mouse_grabbed) { >> + qemu_add_mouse_event_handler(usb_tablet_event, s, 1); >> + s->mouse_grabbed = 1; >> + } >> + + dz = int_clamp(s->dz, -128, 127); >> + s->dz -= dz; >> + >> + /* Appears we have to invert the wheel direction */ >> + dz = 0 - dz; >> + b = 0; >> + if (s->buttons_state & MOUSE_EVENT_LBUTTON) >> + b |= 0x01; >> + if (s->buttons_state & MOUSE_EVENT_RBUTTON) >> + b |= 0x02; >> + if (s->buttons_state & MOUSE_EVENT_MBUTTON) >> + b |= 0x04; >> + >> + buf[0] = b; >> + buf[1] = s->x & 0xff; >> + buf[2] = s->x >> 8; >> + buf[3] = s->y & 0xff; >> + buf[4] = s->y >> 8; >> + buf[5] = dz; >> + l = 6; >> + >> + return l; >> +} >> + >> static void usb_mouse_handle_reset(USBDevice *dev) >> { >> USBMouseState *s = (USBMouseState *)dev; >> @@ -180,6 +325,8 @@ >> s->dx = 0; >> s->dy = 0; >> s->dz = 0; >> + s->x = 0; >> + s->y = 0; >> s->buttons_state = 0; >> } >> >> @@ -187,7 +334,7 @@ >> int index, int length, uint8_t *data) >> { >> USBMouseState *s = (USBMouseState *)dev; >> - int ret; >> + int ret = 0; >> >> switch(request) { >> case DeviceRequest | USB_REQ_GET_STATUS: >> @@ -224,9 +371,15 @@ >> ret = sizeof(qemu_mouse_dev_descriptor); >> break; >> case USB_DT_CONFIG: >> - memcpy(data, qemu_mouse_config_descriptor, >> - sizeof(qemu_mouse_config_descriptor)); >> - ret = sizeof(qemu_mouse_config_descriptor); >> + if (s->kind == USB_MOUSE) { >> + memcpy(data, qemu_mouse_config_descriptor, + >> sizeof(qemu_mouse_config_descriptor)); >> + ret = sizeof(qemu_mouse_config_descriptor); >> + } else if (s->kind == USB_TABLET) { >> + memcpy(data, qemu_tablet_config_descriptor, + >> sizeof(qemu_tablet_config_descriptor)); >> + ret = sizeof(qemu_tablet_config_descriptor); >> + } >> break; >> case USB_DT_STRING: >> switch(value & 0xff) { >> @@ -244,7 +397,10 @@ >> break; >> case 2: >> /* product description */ >> - ret = set_usb_string(data, "QEMU USB Mouse"); >> + if (s->kind == USB_MOUSE) >> + ret = set_usb_string(data, "QEMU USB Mouse"); >> + else if (s->kind == USB_TABLET) >> + ret = set_usb_string(data, "QEMU USB Tablet"); >> break; >> case 3: >> /* vendor description */ >> @@ -282,16 +438,25 @@ >> case InterfaceRequest | USB_REQ_GET_DESCRIPTOR: >> switch(value >> 8) { >> case 0x22: >> - memcpy(data, qemu_mouse_hid_report_descriptor, >> - sizeof(qemu_mouse_hid_report_descriptor)); >> - ret = sizeof(qemu_mouse_hid_report_descriptor); >> - break; >> + if (s->kind == USB_MOUSE) { >> + memcpy(data, qemu_mouse_hid_report_descriptor, >> + sizeof(qemu_mouse_hid_report_descriptor)); >> + ret = sizeof(qemu_mouse_hid_report_descriptor); >> + } else if (s->kind == USB_TABLET) { >> + memcpy(data, qemu_tablet_hid_report_descriptor, >> + sizeof(qemu_tablet_hid_report_descriptor)); >> + ret = sizeof(qemu_tablet_hid_report_descriptor); >> + } >> + break; >> default: >> goto fail; >> } >> break; >> case GET_REPORT: >> - ret = usb_mouse_poll(s, data, length); >> + if (s->kind == USB_MOUSE) >> + ret = usb_mouse_poll(s, data, length); >> + else if (s->kind == USB_TABLET) >> + ret = usb_tablet_poll(s, data, length); >> break; >> case SET_IDLE: >> ret = 0; >> @@ -308,12 +473,15 @@ >> uint8_t devep, uint8_t *data, int len) >> { >> USBMouseState *s = (USBMouseState *)dev; >> - int ret; >> + int ret = 0; >> >> switch(pid) { >> case USB_TOKEN_IN: >> if (devep == 1) { >> - ret = usb_mouse_poll(s, data, len); >> + if (s->kind == USB_MOUSE) >> + ret = usb_mouse_poll(s, data, len); >> + else if (s->kind == USB_TABLET) >> + ret = usb_tablet_poll(s, data, len); >> } else { >> goto fail; >> } >> @@ -327,7 +495,7 @@ >> return ret; >> } >> >> -USBDevice *usb_mouse_init(void) >> +USBDevice *usb_tablet_init(void) >> { >> USBMouseState *s; >> >> @@ -340,8 +508,25 @@ >> s->dev.handle_reset = usb_mouse_handle_reset; >> s->dev.handle_control = usb_mouse_handle_control; >> s->dev.handle_data = usb_mouse_handle_data; >> - >> - qemu_add_mouse_event_handler(usb_mouse_event, s); >> - + s->kind = USB_TABLET; >> + >> return (USBDevice *)s; >> } >> + >> +USBDevice *usb_mouse_init(void) >> +{ >> + USBMouseState *s; >> + >> + s = qemu_mallocz(sizeof(USBMouseState)); >> + if (!s) >> + return NULL; >> + s->dev.speed = USB_SPEED_FULL; >> + s->dev.handle_packet = usb_generic_handle_packet; >> + >> + s->dev.handle_reset = usb_mouse_handle_reset; >> + s->dev.handle_control = usb_mouse_handle_control; >> + s->dev.handle_data = usb_mouse_handle_data; >> + s->kind = USB_MOUSE; >> + >> + return (USBDevice *)s; >> +} >> diff -r 6a786a97b822 hw/usb.h >> --- a/hw/usb.h Mon Apr 10 01:47:35 2006 +0000 >> +++ b/hw/usb.h Sun Apr 9 22:34:20 2006 -0500 >> @@ -163,3 +163,4 @@ >> >> /* usb-hid.c */ >> USBDevice *usb_mouse_init(void); >> +USBDevice *usb_tablet_init(void); >> diff -r 6a786a97b822 sdl.c >> --- a/sdl.c Mon Apr 10 01:47:35 2006 +0000 >> +++ b/sdl.c Sun Apr 9 22:34:20 2006 -0500 >> @@ -39,6 +39,10 @@ >> static int gui_fullscreen_initial_grab; >> static int gui_grab_code = KMOD_LALT | KMOD_LCTRL; >> static uint8_t modifiers_state[256]; >> +static int width, height; >> +static SDL_Cursor *sdl_cursor_normal; >> +static SDL_Cursor *sdl_cursor_hidden; >> +static int absolute_enabled = 0; >> >> static void sdl_update(DisplayState *ds, int x, int y, int w, int h) >> { >> @@ -55,6 +59,9 @@ >> flags = SDL_HWSURFACE|SDL_ASYNCBLIT|SDL_HWACCEL; >> if (gui_fullscreen) >> flags |= SDL_FULLSCREEN; >> + >> + width = w; >> + height = h; >> >> again: >> screen = SDL_SetVideoMode(w, h, 0, flags); >> @@ -271,9 +278,21 @@ >> SDL_WM_SetCaption(buf, "QEMU"); >> } >> >> +static void sdl_hide_cursor(void) >> +{ >> + SDL_SetCursor(sdl_cursor_hidden); >> +} >> + >> +static void sdl_show_cursor(void) >> +{ >> + if (!kbd_mouse_is_absolute()) { >> + SDL_SetCursor(sdl_cursor_normal); >> + } >> +} >> + >> static void sdl_grab_start(void) >> { >> - SDL_ShowCursor(0); >> + sdl_hide_cursor(); >> SDL_WM_GrabInput(SDL_GRAB_ON); >> /* dummy read to avoid moving the mouse */ >> SDL_GetRelativeMouseState(NULL, NULL); >> @@ -284,7 +303,7 @@ >> static void sdl_grab_end(void) >> { >> SDL_WM_GrabInput(SDL_GRAB_OFF); >> - SDL_ShowCursor(1); >> + sdl_show_cursor(); >> gui_grab = 0; >> sdl_update_caption(); >> } >> @@ -300,6 +319,21 @@ >> buttons |= MOUSE_EVENT_RBUTTON; >> if (state & SDL_BUTTON(SDL_BUTTON_MIDDLE)) >> buttons |= MOUSE_EVENT_MBUTTON; >> + >> + if (kbd_mouse_is_absolute()) { >> + if (!absolute_enabled) { >> + sdl_hide_cursor(); >> + if (gui_grab) { >> + sdl_grab_end(); >> + } >> + absolute_enabled = 1; >> + } >> + >> + SDL_GetMouseState(&dx, &dy); >> + dx = dx * 0x7FFF / width; >> + dy = dy * 0x7FFF / height; >> + } >> + >> kbd_mouse_event(dx, dy, dz, buttons); >> } >> >> @@ -423,7 +457,7 @@ >> qemu_system_shutdown_request(); >> break; >> case SDL_MOUSEMOTION: >> - if (gui_grab) { >> + if (gui_grab || kbd_mouse_is_absolute()) { >> sdl_send_mouse_event(0); >> } >> break; >> @@ -431,7 +465,7 @@ >> case SDL_MOUSEBUTTONUP: >> { >> SDL_MouseButtonEvent *bev = &ev->button; >> - if (!gui_grab) { >> + if (!gui_grab && !kbd_mouse_is_absolute()) { >> if (ev->type == SDL_MOUSEBUTTONDOWN && >> (bev->state & SDL_BUTTON_LMASK)) { >> /* start grabbing all events */ >> @@ -471,6 +505,7 @@ >> void sdl_display_init(DisplayState *ds, int full_screen) >> { >> int flags; >> + uint8_t data = 0; >> >> #if defined(__APPLE__) >> /* always use generic keymaps */ >> @@ -504,6 +539,9 @@ >> SDL_EnableUNICODE(1); >> gui_grab = 0; >> >> + sdl_cursor_hidden = SDL_CreateCursor(&data, &data, 8, 1, 0, 0); >> + sdl_cursor_normal = SDL_GetCursor(); >> + >> atexit(sdl_cleanup); >> if (full_screen) { >> gui_fullscreen = 1; >> diff -r 6a786a97b822 vl.c >> --- a/vl.c Mon Apr 10 01:47:35 2006 +0000 >> +++ b/vl.c Sun Apr 9 22:34:20 2006 -0500 >> @@ -474,6 +474,7 @@ >> static void *qemu_put_kbd_event_opaque; >> static QEMUPutMouseEvent *qemu_put_mouse_event; >> static void *qemu_put_mouse_event_opaque; >> +static int qemu_put_mouse_event_absolute; >> >> void qemu_add_kbd_event_handler(QEMUPutKBDEvent *func, void *opaque) >> { >> @@ -481,10 +482,11 @@ >> qemu_put_kbd_event = func; >> } >> >> -void qemu_add_mouse_event_handler(QEMUPutMouseEvent *func, void >> *opaque) >> +void qemu_add_mouse_event_handler(QEMUPutMouseEvent *func, void >> *opaque, int absolute) >> { >> qemu_put_mouse_event_opaque = opaque; >> qemu_put_mouse_event = func; >> + qemu_put_mouse_event_absolute = absolute; >> } >> >> void kbd_put_keycode(int keycode) >> @@ -500,6 +502,11 @@ >> qemu_put_mouse_event(qemu_put_mouse_event_opaque, >> dx, dy, dz, buttons_state); >> } >> +} >> + >> +int kbd_mouse_is_absolute(void) >> +{ >> + return qemu_put_mouse_event_absolute; >> } >> >> /***********************************************************/ >> @@ -2855,6 +2862,10 @@ >> dev = usb_mouse_init(); >> if (!dev) >> return -1; >> + } else if (!strcmp(devname, "tablet")) { >> + dev = usb_tablet_init(); >> + if (!dev) >> + return -1; >> } else { >> return -1; >> } >> diff -r 6a786a97b822 vl.h >> --- a/vl.h Mon Apr 10 01:47:35 2006 +0000 >> +++ b/vl.h Sun Apr 9 22:34:20 2006 -0500 >> @@ -158,10 +158,11 @@ >> typedef void QEMUPutMouseEvent(void *opaque, int dx, int dy, int dz, >> int buttons_state); >> >> void qemu_add_kbd_event_handler(QEMUPutKBDEvent *func, void *opaque); >> -void qemu_add_mouse_event_handler(QEMUPutMouseEvent *func, void >> *opaque); >> +void qemu_add_mouse_event_handler(QEMUPutMouseEvent *func, void >> *opaque, int absolute); >> >> void kbd_put_keycode(int keycode); >> void kbd_mouse_event(int dx, int dy, int dz, int buttons_state); >> +int kbd_mouse_is_absolute(void); >> >> /* keysym is a unicode code except for special keys (see QEMU_KEY_xxx >> constants) */ >> >> >> ------------------------------------------------------------------------ >> >> _______________________________________________ >> Qemu-devel mailing list >> Qemu-devel@nongnu.org >> http://lists.nongnu.org/mailman/listinfo/qemu-devel > ^ permalink raw reply [flat|nested] 68+ messages in thread
* Re: [Qemu-devel] USB Tablet Emulation 2006-04-10 15:27 ` Anthony Liguori @ 2006-04-10 15:39 ` Leonardo E. Reiter 2006-04-10 16:08 ` Brad Campbell 0 siblings, 1 reply; 68+ messages in thread From: Leonardo E. Reiter @ 2006-04-10 15:39 UTC (permalink / raw) To: qemu-devel Sorry about that... Brad, very well done! On another note, I'm looking over the USB HID spec to better understand the boot-time device constraints. I doubt you can use an absolute coordinate tablet as a boot-time mouse that actually reports positions in absolute terms, but maybe it's possible. It's not a big deal, just cosmetic really - to be able to use the tablet at OS install/early boot time, before more complex drivers are loaded. I'm not sure how possible this is, but the USB HID spec seems to imply it. - Leo Reiter Anthony Liguori wrote: > Make sure to give credit where credit's due. Brad Campbell figured out > the hard stuff :-) > -- Leonardo E. Reiter Vice President of Product Development, CTO Win4Lin, Inc. Virtual Computing from Desktop to Data Center Main: +1 512 339 7979 Fax: +1 512 532 6501 http://www.win4lin.com ^ permalink raw reply [flat|nested] 68+ messages in thread
* Re: [Qemu-devel] USB Tablet Emulation 2006-04-10 15:39 ` Leonardo E. Reiter @ 2006-04-10 16:08 ` Brad Campbell 2006-04-10 19:28 ` Brad Campbell 0 siblings, 1 reply; 68+ messages in thread From: Brad Campbell @ 2006-04-10 16:08 UTC (permalink / raw) To: qemu-devel Leonardo E. Reiter wrote: > Sorry about that... Brad, very well done! Ta :) Anthony did a great job doing the stuff I'm knaff at (making clean and mergable code) and the sdl hookups. I just hacked the hid stuff (about 150 win2k reboots in there). It works with Win98 also, but Win98 seems to want a slightly different hid config or wants 0-ffff rather than 0-7fff. I'm playing with that.. The wheel works in SDL although there is currently a bug where it steps by 2 instead of 1.. so it's ok for scrolling, but scrolling through a selection box causes it to skip every second selection. I've not tested the wheel with the vnc patch yet. I'll get to those tonight.. > On another note, I'm looking over the USB HID spec to better understand > the boot-time device constraints. I doubt you can use an absolute > coordinate tablet as a boot-time mouse that actually reports positions > in absolute terms, but maybe it's possible. It's not a big deal, just > cosmetic really - to be able to use the tablet at OS install/early boot > time, before more complex drivers are loaded. I'm not sure how possible > this is, but the USB HID spec seems to imply it. Yes, there are tight boot time constraints.. and no from what I can find the hid required to meet them won't work with abs coordinates. if you absolutely *had* to do that, perhaps there might be a way of switching mice on the fly.. virtual unplug mouse and replug tablet, or enable ps2 for boot and then some way of causing a tablet plug in at the appropriate time.. I'm not sure the bochs bios handles legacy usb though, so I feel its somewhat of a moot point, as you *need* the OS usb drivers loaded to even pick up a legacy usb mouse device. Brad -- "Human beings, who are almost unique in having the ability to learn from the experience of others, are also remarkable for their apparent disinclination to do so." -- Douglas Adams ^ permalink raw reply [flat|nested] 68+ messages in thread
* Re: [Qemu-devel] USB Tablet Emulation 2006-04-10 16:08 ` Brad Campbell @ 2006-04-10 19:28 ` Brad Campbell 2006-04-10 19:44 ` Brad Campbell 0 siblings, 1 reply; 68+ messages in thread From: Brad Campbell @ 2006-04-10 19:28 UTC (permalink / raw) To: qemu-devel Brad Campbell wrote: > The wheel works in SDL although there is currently a bug where it steps > by 2 instead of 1.. so it's ok for scrolling, but scrolling through a > selection box causes it to skip every second selection. > I've not tested the wheel with the vnc patch yet. I'll get to those > tonight.. Wheel works in VNC unmodified :) (yay) I've been playing some more on the Win98 calibration issue and I'll keep looking at that, but for now it' still a no-go. And the 2 step wheel thing still needs fixing. Brad -- "Human beings, who are almost unique in having the ability to learn from the experience of others, are also remarkable for their apparent disinclination to do so." -- Douglas Adams ^ permalink raw reply [flat|nested] 68+ messages in thread
* Re: [Qemu-devel] USB Tablet Emulation 2006-04-10 19:28 ` Brad Campbell @ 2006-04-10 19:44 ` Brad Campbell 2006-04-10 21:27 ` Brad Campbell 0 siblings, 1 reply; 68+ messages in thread From: Brad Campbell @ 2006-04-10 19:44 UTC (permalink / raw) To: qemu-devel [-- Attachment #1: Type: text/plain, Size: 818 bytes --] Brad Campbell wrote: > Brad Campbell wrote: > >> The wheel works in SDL although there is currently a bug where it >> steps by 2 instead of 1.. so it's ok for scrolling, but scrolling >> through a selection box causes it to skip every second selection. >> I've not tested the wheel with the vnc patch yet. I'll get to those >> tonight.. > > Wheel works in VNC unmodified :) (yay) > > I've been playing some more on the Win98 calibration issue and I'll keep > looking at that, but for now it' still a no-go. And the 2 step wheel > thing still needs fixing. Fixed the descriptor.. Now works perfectly in Win98, 2k and XP :) -- "Human beings, who are almost unique in having the ability to learn from the experience of others, are also remarkable for their apparent disinclination to do so." -- Douglas Adams [-- Attachment #2: qemu-usb-hid-001.patch --] [-- Type: text/plain, Size: 1176 bytes --] diff -ur qemu-clean/hw/usb-hid.c qemu/hw/usb-hid.c --- qemu-clean/hw/usb-hid.c 2006-04-10 23:39:14.000000000 +0400 +++ qemu/hw/usb-hid.c 2006-04-10 23:41:39.000000000 +0400 @@ -161,7 +161,7 @@ 0x00, /* u8 country_code */ 0x01, /* u8 num_descriptors */ 0x22, /* u8 type; Report */ - 65, 0, /* u16 len */ + 70, 0, /* u16 len */ /* one endpoint (status change endpoint) */ 0x07, /* u8 ep_bLength; */ @@ -203,10 +203,13 @@ 0x09, 0x30, /* Usage X */ 0x09, 0x31, /* Usage Y */ 0x15, 0x00, /* Logical Minimum 0 */ - 0x27, 0xFF, 0xFF, 0x00, 0x00, /* Logical Maximum 0xffff */ + 0x26, 0xFF, 0x7F, /* Logical Maximum 0x7fff */ + 0x35, 0x00, /* Physical Minimum 0 */ + 0x46, 0xFF, 0x7F, /* Physical Maximum 0x7fff */ 0x75, 0x10, /* Report Size 16 */ 0x95, 0x02, /* Report Count 2 */ 0x81, 0x02, /* Input (Data, Var, Abs) */ + 0x05, 0x01, /* Usage Page Generic Desktop */ 0x09, 0x38, /* Usage Wheel */ 0x15, 0x81, /* Logical Minimum -127 */ 0x25, 0x7F, /* Logical Maximum 127 */ ^ permalink raw reply [flat|nested] 68+ messages in thread
* Re: [Qemu-devel] USB Tablet Emulation 2006-04-10 19:44 ` Brad Campbell @ 2006-04-10 21:27 ` Brad Campbell 2006-04-10 21:39 ` Brad Campbell 0 siblings, 1 reply; 68+ messages in thread From: Brad Campbell @ 2006-04-10 21:27 UTC (permalink / raw) To: qemu-devel [-- Attachment #1: Type: text/plain, Size: 1828 bytes --] Brad Campbell wrote: > Brad Campbell wrote: >> Brad Campbell wrote: >> >>> The wheel works in SDL although there is currently a bug where it >>> steps by 2 instead of 1.. so it's ok for scrolling, but scrolling >>> through a selection box causes it to skip every second selection. >>> I've not tested the wheel with the vnc patch yet. I'll get to those >>> tonight.. >> >> Wheel works in VNC unmodified :) (yay) >> >> I've been playing some more on the Win98 calibration issue and I'll >> keep looking at that, but for now it' still a no-go. And the 2 step >> wheel thing still needs fixing. > > Fixed the descriptor.. Now works perfectly in Win98, 2k and XP :) > Spoke too soon.. revised patch that actually has been completely tested in all 3. For those thinking of going into a career of hid descriptor writing.. DON'T! Win98 does not parse the descriptor properly.. and win2k/xp appear to adhere strictly to the specs. We should now be in a pretty compliant position with all bases covered. Also attached a small patch to sdl.c which solves the double wheel messages. The wheel is just 2 buttons.. up and down effectively, and we were sending a delta on both press and release of each button, where it should only be a press. This makes the double events go away and I can scroll line by line through any listbox or list. For those that just want to play. This is a rollup of Anthony's patch, Leo's win2k-hack patch and all my latest fixes plus the vnc patch. It applies directly over the latest cvs checkout and is enabled with -usb -usbdevice tablet. http://fnarfbargle.dyndns.org:81/qemu/qemu-hid-rfb-ide.patch.gz Brad -- "Human beings, who are almost unique in having the ability to learn from the experience of others, are also remarkable for their apparent disinclination to do so." -- Douglas Adams [-- Attachment #2: qemu-usb-hid-002.patch --] [-- Type: text/plain, Size: 2443 bytes --] --- qemu-clean/hw/usb-hid.c 2006-04-10 23:39:14.000000000 +0400 +++ qemu/hw/usb-hid.c 2006-04-11 01:15:49.000000000 +0400 @@ -161,7 +161,7 @@ 0x00, /* u8 country_code */ 0x01, /* u8 num_descriptors */ 0x22, /* u8 type; Report */ - 65, 0, /* u16 len */ + 74, 0, /* u16 len */ /* one endpoint (status change endpoint) */ 0x07, /* u8 ep_bLength; */ @@ -188,29 +188,40 @@ 0xA1, 0x01, /* Collection Application */ 0x09, 0x01, /* Usage Pointer */ 0xA1, 0x00, /* Collection Physical */ - 0x05, 0x09, /* Usage Page Button */ + + 0x05, 0x09, /* Usage Page Button */ 0x19, 0x01, /* Usage Minimum Button 1 */ 0x29, 0x03, /* Usage Maximum Button 3 */ 0x15, 0x00, /* Logical Minimum 0 */ 0x25, 0x01, /* Logical Maximum 1 */ - 0x95, 0x03, /* Report Count 3 */ + + 0x95, 0x03, /* Report Count 3 */ 0x75, 0x01, /* Report Size 1 */ 0x81, 0x02, /* Input (Data, Var, Abs) */ 0x95, 0x01, /* Report Count 1 */ 0x75, 0x05, /* Report Size 5 */ - 0x81, 0x01, /* Input (Cnst, Var, Abs) */ + + 0x81, 0x01, /* Input (Cnst, Var, Abs) */ 0x05, 0x01, /* Usage Page Generic Desktop */ - 0x09, 0x30, /* Usage X */ + 0x09, 0x30, /* Usage X */ 0x09, 0x31, /* Usage Y */ 0x15, 0x00, /* Logical Minimum 0 */ - 0x27, 0xFF, 0xFF, 0x00, 0x00, /* Logical Maximum 0xffff */ - 0x75, 0x10, /* Report Size 16 */ - 0x95, 0x02, /* Report Count 2 */ - 0x81, 0x02, /* Input (Data, Var, Abs) */ + + 0x26, 0xFF, 0x7F, /* Logical Maximum 0x7fff */ + 0x35, 0x00, /* Physical Minimum 0 */ + 0x46, 0xFE, 0x7F, /* Physical Maximum 0x7fff */ + 0x75, 0x10, /* Report Size 16 */ + + 0x95, 0x02, /* Report Count 2 */ + 0x81, 0x02, /* Input (Data, Var, Abs) */ + 0x05, 0x01, /* Usage Page Generic Desktop */ 0x09, 0x38, /* Usage Wheel */ 0x15, 0x81, /* Logical Minimum -127 */ - 0x25, 0x7F, /* Logical Maximum 127 */ - 0x75, 0x08, /* Report Size 8 */ + + 0x25, 0x7F, /* Logical Maximum 127 */ + 0x35, 0x00, /* Physical Minimum 0 (same as logical) */ + 0x45, 0x00, /* Physical Maximum 0 (same as logical) */ + 0x75, 0x08, /* Report Size 8 */ 0x95, 0x01, /* Report Count 1 */ 0x81, 0x02, /* Input (Data, Var, Rel) */ 0xC0, /* End Collection */ [-- Attachment #3: qemu-sdl-wheel.patch --] [-- Type: text/plain, Size: 662 bytes --] --- qemu-clean/sdl.c 2006-04-10 23:43:08.000000000 +0400 +++ qemu/sdl.c 2006-04-11 00:56:01.000000000 +0400 @@ -479,9 +479,9 @@ int dz; dz = 0; #ifdef SDL_BUTTON_WHEELUP - if (bev->button == SDL_BUTTON_WHEELUP) { + if (bev->button == SDL_BUTTON_WHEELUP && ev->type == SDL_MOUSEBUTTONDOWN) { dz = -1; - } else if (bev->button == SDL_BUTTON_WHEELDOWN) { + } else if (bev->button == SDL_BUTTON_WHEELDOWN && ev->type == SDL_MOUSEBUTTONDOWN) { dz = 1; } #endif ^ permalink raw reply [flat|nested] 68+ messages in thread
* Re: [Qemu-devel] USB Tablet Emulation 2006-04-10 21:27 ` Brad Campbell @ 2006-04-10 21:39 ` Brad Campbell 0 siblings, 0 replies; 68+ messages in thread From: Brad Campbell @ 2006-04-10 21:39 UTC (permalink / raw) To: qemu-devel [-- Attachment #1: Type: text/plain, Size: 310 bytes --] Ok.. and for my next trick.. one that is not whitespace damaged.. Functionally same as 002.. Brad (need caffeine or sleep) -- "Human beings, who are almost unique in having the ability to learn from the experience of others, are also remarkable for their apparent disinclination to do so." -- Douglas Adams [-- Attachment #2: qemu-usb-hid-003.patch --] [-- Type: text/plain, Size: 1386 bytes --] --- qemu-clean/hw/usb-hid.c 2006-04-10 23:39:14.000000000 +0400 +++ qemu/hw/usb-hid.c 2006-04-11 01:21:05.000000000 +0400 @@ -161,7 +161,7 @@ 0x00, /* u8 country_code */ 0x01, /* u8 num_descriptors */ 0x22, /* u8 type; Report */ - 65, 0, /* u16 len */ + 74, 0, /* u16 len */ /* one endpoint (status change endpoint) */ 0x07, /* u8 ep_bLength; */ @@ -203,13 +203,18 @@ 0x09, 0x30, /* Usage X */ 0x09, 0x31, /* Usage Y */ 0x15, 0x00, /* Logical Minimum 0 */ - 0x27, 0xFF, 0xFF, 0x00, 0x00, /* Logical Maximum 0xffff */ + 0x26, 0xFF, 0x7F, /* Logical Maximum 0x7fff */ + 0x35, 0x00, /* Physical Minimum 0 */ + 0x46, 0xFE, 0x7F, /* Physical Maximum 0x7fff */ 0x75, 0x10, /* Report Size 16 */ 0x95, 0x02, /* Report Count 2 */ 0x81, 0x02, /* Input (Data, Var, Abs) */ + 0x05, 0x01, /* Usage Page Generic Desktop */ 0x09, 0x38, /* Usage Wheel */ 0x15, 0x81, /* Logical Minimum -127 */ 0x25, 0x7F, /* Logical Maximum 127 */ + 0x35, 0x00, /* Physical Minimum 0 (same as logical) */ + 0x45, 0x00, /* Physical Maximum 0 (same as logical) */ 0x75, 0x08, /* Report Size 8 */ 0x95, 0x01, /* Report Count 1 */ 0x81, 0x02, /* Input (Data, Var, Rel) */ ^ permalink raw reply [flat|nested] 68+ messages in thread
* Re: [Qemu-devel] VNC terminal server? 2006-04-08 18:24 ` Johannes Schindelin 2006-04-08 18:37 ` Leonardo E. Reiter @ 2006-04-08 18:38 ` Mark Williamson 2006-04-08 18:53 ` Johannes Schindelin 2006-04-08 19:01 ` Jim C. Brown ` (2 subsequent siblings) 4 siblings, 1 reply; 68+ messages in thread From: Mark Williamson @ 2006-04-08 18:38 UTC (permalink / raw) To: qemu-devel > On Sat, 8 Apr 2006, Samuel Hunt wrote: > > It occurs to me that this program would make an excellent basis for a VNC > > terminal server. > > Yeah, something like that has been done already: > http://libvncserver.sourceforge.net/qemu/qemu-rfb13.patch.gz > > There is a notable update since rfb12 (which is a bit out of date > _cough_): Nis Jorgensen has sent a patch to support scroll mice. > > IMHO the biggest obstacle to inclusion in mainline QEmu is that the mouse > support is rather flakey: You have to disable mouse acceleration of the > guest OS. > > I had that cunning plan to write a virtual Wacom tablet, but I just don't > find the time. The Xen copy of pckbd.c includes a patch to emulate a Summagraphics tablet, in order to fix this problem. This is probably reusable for QEmu itself. Cheers, Mark -- Dave: Just a question. What use is a unicyle with no seat? And no pedals! Mark: To answer a question with a question: What use is a skateboard? Dave: Skateboards have wheels. Mark: My wheel has a wheel! ^ permalink raw reply [flat|nested] 68+ messages in thread
* Re: [Qemu-devel] VNC terminal server? 2006-04-08 18:38 ` [Qemu-devel] VNC terminal server? Mark Williamson @ 2006-04-08 18:53 ` Johannes Schindelin 0 siblings, 0 replies; 68+ messages in thread From: Johannes Schindelin @ 2006-04-08 18:53 UTC (permalink / raw) To: Mark Williamson; +Cc: qemu-devel Hi, On Sat, 8 Apr 2006, Mark Williamson wrote: > The Xen copy of pckbd.c includes a patch to emulate a Summagraphics > tablet, in order to fix this problem. This is probably reusable for > QEmu itself. I even know who wrote it... Donald Dugger. He forwarded it to me also, and I even think it is part of the RFB patch (too lazy to check right now). There are two problems: - configuration is a bitch. For example, X and gpm do not play nice together. And there is no automatic detection for Summagraphics in kudzu (which is the automatic hardware detection of Knoppix). - the patch modifies the PS/2 mouse of QEmu. However, there is no such thing as a PS/2 Summagraphics. Consequently, all win98 drivers I found did not detect a Summagraphics device. Ciao, Dscho ^ permalink raw reply [flat|nested] 68+ messages in thread
* Re: [Qemu-devel] VNC terminal server? 2006-04-08 18:24 ` Johannes Schindelin 2006-04-08 18:37 ` Leonardo E. Reiter 2006-04-08 18:38 ` [Qemu-devel] VNC terminal server? Mark Williamson @ 2006-04-08 19:01 ` Jim C. Brown 2006-04-08 19:12 ` Johannes Schindelin 2006-04-09 2:53 ` Anthony Liguori 2006-04-08 19:21 ` andrzej zaborowski 2006-04-09 2:52 ` Anthony Liguori 4 siblings, 2 replies; 68+ messages in thread From: Jim C. Brown @ 2006-04-08 19:01 UTC (permalink / raw) To: qemu-devel On Sat, Apr 08, 2006 at 08:24:03PM +0200, Johannes Schindelin wrote: > IMHO the biggest obstacle to inclusion in mainline QEmu is that the mouse > support is rather flakey: You have to disable mouse acceleration of the > guest OS. > > I had that cunning plan to write a virtual Wacom tablet, but I just don't > find the time. > > Ciao, > Dscho > Anthony Ligouri has written a patch for wacom support. However, when I combine this with the -no-sdl-grab patch I still see syncing issues. -- Infinite complexity begets infinite beauty. Infinite precision begets infinite perfection. ^ permalink raw reply [flat|nested] 68+ messages in thread
* Re: [Qemu-devel] VNC terminal server? 2006-04-08 19:01 ` Jim C. Brown @ 2006-04-08 19:12 ` Johannes Schindelin 2006-04-08 19:30 ` Jim C. Brown 2006-04-09 2:55 ` Anthony Liguori 2006-04-09 2:53 ` Anthony Liguori 1 sibling, 2 replies; 68+ messages in thread From: Johannes Schindelin @ 2006-04-08 19:12 UTC (permalink / raw) To: qemu-devel Hi, On Sat, 8 Apr 2006, Jim C. Brown wrote: > On Sat, Apr 08, 2006 at 08:24:03PM +0200, Johannes Schindelin wrote: > > IMHO the biggest obstacle to inclusion in mainline QEmu is that the mouse > > support is rather flakey: You have to disable mouse acceleration of the > > guest OS. > > > > I had that cunning plan to write a virtual Wacom tablet, but I just don't > > find the time. > > > > Ciao, > > Dscho > > > > Anthony Ligouri has written a patch for wacom support. > > However, when I combine this with the -no-sdl-grab patch I still see syncing > issues. Where can I get it? Ciao, Dscho ^ permalink raw reply [flat|nested] 68+ messages in thread
* Re: [Qemu-devel] VNC terminal server? 2006-04-08 19:12 ` Johannes Schindelin @ 2006-04-08 19:30 ` Jim C. Brown 2006-04-08 19:40 ` Johannes Schindelin 2006-04-09 2:55 ` Anthony Liguori 1 sibling, 1 reply; 68+ messages in thread From: Jim C. Brown @ 2006-04-08 19:30 UTC (permalink / raw) To: qemu-devel On Sat, Apr 08, 2006 at 09:12:18PM +0200, Johannes Schindelin wrote: > > Anthony Ligouri has written a patch for wacom support. > > > > However, when I combine this with the -no-sdl-grab patch I still see syncing > > issues. > > Where can I get it? http://www.cs.utexas.edu/users/aliguori/qemu-wacom-2.tgz > > Ciao, > Dscho > > > > _______________________________________________ > Qemu-devel mailing list > Qemu-devel@nongnu.org > http://lists.nongnu.org/mailman/listinfo/qemu-devel > -- Infinite complexity begets infinite beauty. Infinite precision begets infinite perfection. ^ permalink raw reply [flat|nested] 68+ messages in thread
* Re: [Qemu-devel] VNC terminal server? 2006-04-08 19:30 ` Jim C. Brown @ 2006-04-08 19:40 ` Johannes Schindelin 0 siblings, 0 replies; 68+ messages in thread From: Johannes Schindelin @ 2006-04-08 19:40 UTC (permalink / raw) To: qemu-devel Hi, On Sat, 8 Apr 2006, Jim C. Brown wrote: > On Sat, Apr 08, 2006 at 09:12:18PM +0200, Johannes Schindelin wrote: > > > Anthony Ligouri has written a patch for wacom support. > > > > > > However, when I combine this with the -no-sdl-grab patch I still see syncing > > > issues. > > > > Where can I get it? > > http://www.cs.utexas.edu/users/aliguori/qemu-wacom-2.tgz Thanks! I will play around a little. Ciao, Dscho ^ permalink raw reply [flat|nested] 68+ messages in thread
* Re: [Qemu-devel] VNC terminal server? 2006-04-08 19:12 ` Johannes Schindelin 2006-04-08 19:30 ` Jim C. Brown @ 2006-04-09 2:55 ` Anthony Liguori 1 sibling, 0 replies; 68+ messages in thread From: Anthony Liguori @ 2006-04-09 2:55 UTC (permalink / raw) To: qemu-devel Johannes Schindelin wrote: > Hi, > > On Sat, 8 Apr 2006, Jim C. Brown wrote: > > >> On Sat, Apr 08, 2006 at 08:24:03PM +0200, Johannes Schindelin wrote: >> >>> IMHO the biggest obstacle to inclusion in mainline QEmu is that the mouse >>> support is rather flakey: You have to disable mouse acceleration of the >>> guest OS. >>> >>> I had that cunning plan to write a virtual Wacom tablet, but I just don't >>> find the time. >>> >>> Ciao, >>> Dscho >>> >>> >> Anthony Ligouri has written a patch for wacom support. >> >> However, when I combine this with the -no-sdl-grab patch I still see syncing >> issues. >> > > Where can I get it? > http://www.cs.utexas.edu/users/aliguori/qemu-wacom-2.tgz but as I mentioned earlier, YMMV. Regards, Anthony Liguori > Ciao, > Dscho > > > > _______________________________________________ > Qemu-devel mailing list > Qemu-devel@nongnu.org > http://lists.nongnu.org/mailman/listinfo/qemu-devel > ^ permalink raw reply [flat|nested] 68+ messages in thread
* Re: [Qemu-devel] VNC terminal server? 2006-04-08 19:01 ` Jim C. Brown 2006-04-08 19:12 ` Johannes Schindelin @ 2006-04-09 2:53 ` Anthony Liguori 1 sibling, 0 replies; 68+ messages in thread From: Anthony Liguori @ 2006-04-09 2:53 UTC (permalink / raw) To: qemu-devel Jim C. Brown wrote: > On Sat, Apr 08, 2006 at 08:24:03PM +0200, Johannes Schindelin wrote: > >> IMHO the biggest obstacle to inclusion in mainline QEmu is that the mouse >> support is rather flakey: You have to disable mouse acceleration of the >> guest OS. >> >> I had that cunning plan to write a virtual Wacom tablet, but I just don't >> find the time. >> >> Ciao, >> Dscho >> >> > > Anthony Ligouri has written a patch for wacom support. > Docs are available for older Wacom tablets. I've not gotten the time to update my patches to actually implement the full protocol according to the docs. The version I wrote is based on a newer X driver so YMMV. Regards, ANthony Liguori > However, when I combine this with the -no-sdl-grab patch I still see syncing > issues. > > ^ permalink raw reply [flat|nested] 68+ messages in thread
* Re: [Qemu-devel] VNC terminal server? 2006-04-08 18:24 ` Johannes Schindelin ` (2 preceding siblings ...) 2006-04-08 19:01 ` Jim C. Brown @ 2006-04-08 19:21 ` andrzej zaborowski 2006-04-08 19:33 ` Leonardo E. Reiter 2006-04-09 2:57 ` Anthony Liguori 2006-04-09 2:52 ` Anthony Liguori 4 siblings, 2 replies; 68+ messages in thread From: andrzej zaborowski @ 2006-04-08 19:21 UTC (permalink / raw) To: qemu-devel Hi, > IMHO the biggest obstacle to inclusion in mainline QEmu is that the mouse > support is rather flakey: You have to disable mouse acceleration of the > guest OS. > > I had that cunning plan to write a virtual Wacom tablet, but I just don't > find the time. > I thought Anthony Liguori had already written a Wacom tablet emulator for QEMU and that worked fine except it supports only one button. I don't remember if this support was complete and I don't have a link to the patch. With this you don't need to disable mouse acceleration in the guest OS because it makes no sense to accelerate a tablet. On the other hand writing a guest-side driver for QEMU would leave room for further improvements like hiding/showing or grabbing/releasing the mouse at specific moments. Or, possibly reusing tools from Win4Lin or VMtools from VMware. > Ciao, > Dscho > > > > _______________________________________________ > Qemu-devel mailing list > Qemu-devel@nongnu.org > http://lists.nongnu.org/mailman/listinfo/qemu-devel > -- balrog 2oo6 Dear Outlook users: Please remove me from your address books http://www.newsforge.com/article.pl?sid=03/08/21/143258 ^ permalink raw reply [flat|nested] 68+ messages in thread
* Re: [Qemu-devel] VNC terminal server? 2006-04-08 19:21 ` andrzej zaborowski @ 2006-04-08 19:33 ` Leonardo E. Reiter 2006-04-09 2:59 ` Anthony Liguori 2006-04-09 2:57 ` Anthony Liguori 1 sibling, 1 reply; 68+ messages in thread From: Leonardo E. Reiter @ 2006-04-08 19:33 UTC (permalink / raw) To: balrogg, qemu-devel The Win4Lin Pro version is not a driver, but rather a high-priority Windows userspace thread. We try to avoid drivers as much as possible because they are a serious obstacle to supporting new Windows versions and service packs as they come out. I can't comment on VMware's approach to be honest. I will say that using a device that has readily and/or publicly available drivers is probably ideal, such as a Wacom tablet. We are trying to move to more of a device model on Win4Lin Pro for performance reasons, which is why I am interested in this approach. But letting Microsoft maintain the guest driver, if it's built into Windows, is the best solution. It also guarantees the broadest possible guest support in general - whether it be Linux, Mac OS X, etc. If anyone has a link to Anthony Liguori's driver, I'd be glad to look into fixing whatever may be wrong with it and posting the patches. Thanks, Leo Reiter andrzej zaborowski wrote: > I thought Anthony Liguori had already written a Wacom tablet emulator > for QEMU and that worked fine except it supports only one button. I > don't remember if this support was complete and I don't have a link to > the patch. > > With this you don't need to disable mouse acceleration in the guest OS > because it makes no sense to accelerate a tablet. > > On the other hand writing a guest-side driver for QEMU would leave > room for further improvements like hiding/showing or > grabbing/releasing the mouse at specific moments. Or, possibly reusing > tools from Win4Lin or VMtools from VMware. -- Leonardo E. Reiter Vice President of Product Development, CTO Win4Lin, Inc. Virtual Computing from Desktop to Data Center Main: +1 512 339 7979 Fax: +1 512 532 6501 http://www.win4lin.com ^ permalink raw reply [flat|nested] 68+ messages in thread
* Re: [Qemu-devel] VNC terminal server? 2006-04-08 19:33 ` Leonardo E. Reiter @ 2006-04-09 2:59 ` Anthony Liguori 2006-04-09 16:06 ` Leonardo E. Reiter 0 siblings, 1 reply; 68+ messages in thread From: Anthony Liguori @ 2006-04-09 2:59 UTC (permalink / raw) To: qemu-devel Leonardo E. Reiter wrote: > The Win4Lin Pro version is not a driver, but rather a high-priority > Windows userspace thread. We try to avoid drivers as much as possible > because they are a serious obstacle to supporting new Windows versions > and service packs as they come out. I can't comment on VMware's > approach to be honest. > > I will say that using a device that has readily and/or publicly > available drivers is probably ideal, such as a Wacom tablet. We are > trying to move to more of a device model on Win4Lin Pro for > performance reasons, which is why I am interested in this approach. > But letting Microsoft maintain the guest driver, if it's built into > Windows, is the best solution. It also guarantees the broadest > possible guest support in general - whether it be Linux, Mac OS X, etc. The driver isn't built into Windows. It's pretty easy to install though and the way my patch works, the PS/2 mouse is used until it detects the tablet has been enabled. The Windows driver uses quite a bit more of the features of the tablet than the X driver so there's a bit more work to do but nothing extraordinary. Regards, Anthony Liguori > > If anyone has a link to Anthony Liguori's driver, I'd be glad to look > into fixing whatever may be wrong with it and posting the patches. > > Thanks, > > Leo Reiter > > andrzej zaborowski wrote: >> I thought Anthony Liguori had already written a Wacom tablet emulator >> for QEMU and that worked fine except it supports only one button. I >> don't remember if this support was complete and I don't have a link to >> the patch. >> >> With this you don't need to disable mouse acceleration in the guest OS >> because it makes no sense to accelerate a tablet. >> >> On the other hand writing a guest-side driver for QEMU would leave >> room for further improvements like hiding/showing or >> grabbing/releasing the mouse at specific moments. Or, possibly reusing >> tools from Win4Lin or VMtools from VMware. > ^ permalink raw reply [flat|nested] 68+ messages in thread
* Re: [Qemu-devel] VNC terminal server? 2006-04-09 2:59 ` Anthony Liguori @ 2006-04-09 16:06 ` Leonardo E. Reiter 2006-04-09 16:40 ` Anthony Liguori 0 siblings, 1 reply; 68+ messages in thread From: Leonardo E. Reiter @ 2006-04-09 16:06 UTC (permalink / raw) To: qemu-devel Hi Anthony, I noticed that the Windows driver does not work... it does send a bunch of commands to the tablet, mostly resets, but then claims that it can't discover it. I downloaded the latest driver from wacom.com. I did not try this with a Linux guest yet.... maybe that should be my next thing, and see what it will take to make it work without the SDL grab altogether (and sync up). If that can work reliably, then adding the bits to the protocol that Windows expects would be worth the work. I'm thinking that this device would be a good complementary option to an absolute USB HID device. Having both in the long run won't hurt, especially if certain OS's prefer serial over USB absolute pointers, and vice versa. - Leo Reiter Anthony Liguori wrote: > The driver isn't built into Windows. It's pretty easy to install though > and the way my patch works, the PS/2 mouse is used until it detects the > tablet has been enabled. > > The Windows driver uses quite a bit more of the features of the tablet > than the X driver so there's a bit more work to do but nothing > extraordinary. > > Regards, > > Anthony Liguori -- Leonardo E. Reiter Vice President of Product Development, CTO Win4Lin, Inc. Virtual Computing from Desktop to Data Center Main: +1 512 339 7979 Fax: +1 512 532 6501 http://www.win4lin.com ^ permalink raw reply [flat|nested] 68+ messages in thread
* Re: [Qemu-devel] VNC terminal server? 2006-04-09 16:06 ` Leonardo E. Reiter @ 2006-04-09 16:40 ` Anthony Liguori 0 siblings, 0 replies; 68+ messages in thread From: Anthony Liguori @ 2006-04-09 16:40 UTC (permalink / raw) To: qemu-devel Leonardo E. Reiter wrote: > Hi Anthony, > > I noticed that the Windows driver does not work... it does send a > bunch of commands to the tablet, mostly resets, but then claims that > it can't discover it. I downloaded the latest driver from wacom.com. Yes, this is what I said. The Windows driver uses a bunch more commands than the Linux driver that I have not implemented (which is why I haven't submitted to this list yet). > I did not try this with a Linux guest yet.... maybe that should be my > next thing, and see what it will take to make it work without the SDL > grab altogether (and sync up). If that can work reliably, then adding > the bits to the protocol that Windows expects would be worth the work. > > I'm thinking that this device would be a good complementary option to > an absolute USB HID device. Having both in the long run won't hurt, > especially if certain OS's prefer serial over USB absolute pointers, > and vice versa. Xorg CVS has initial support for absolute USB devices so I think this is the best route for the future. Regards, Anthony Liguori > - Leo Reiter > > Anthony Liguori wrote: >> The driver isn't built into Windows. It's pretty easy to install >> though and the way my patch works, the PS/2 mouse is used until it >> detects the tablet has been enabled. >> >> The Windows driver uses quite a bit more of the features of the >> tablet than the X driver so there's a bit more work to do but nothing >> extraordinary. >> >> Regards, >> >> Anthony Liguori > ^ permalink raw reply [flat|nested] 68+ messages in thread
* Re: [Qemu-devel] VNC terminal server? 2006-04-08 19:21 ` andrzej zaborowski 2006-04-08 19:33 ` Leonardo E. Reiter @ 2006-04-09 2:57 ` Anthony Liguori 1 sibling, 0 replies; 68+ messages in thread From: Anthony Liguori @ 2006-04-09 2:57 UTC (permalink / raw) To: balrogg, qemu-devel andrzej zaborowski wrote: > Hi, > > > >> IMHO the biggest obstacle to inclusion in mainline QEmu is that the mouse >> support is rather flakey: You have to disable mouse acceleration of the >> guest OS. >> >> I had that cunning plan to write a virtual Wacom tablet, but I just don't >> find the time. >> >> > I thought Anthony Liguori had already written a Wacom tablet emulator > for QEMU and that worked fine except it supports only one button. I > don't remember if this support was complete and I don't have a link to > the patch. > No, it supports all three. Works quite well for new X drivers. If you search the wacom-devel archives you'll find a link to the docs for the Wacom driver. It does kind of suck though that you have to manually configure your X server. I looked at a number of tablets and they all seem to be serial or undocumented. Regards, Anthony Liguori > With this you don't need to disable mouse acceleration in the guest OS > because it makes no sense to accelerate a tablet. > > On the other hand writing a guest-side driver for QEMU would leave > room for further improvements like hiding/showing or > grabbing/releasing the mouse at specific moments. Or, possibly reusing > tools from Win4Lin or VMtools from VMware. > >> Ciao, >> Dscho >> >> >> >> _______________________________________________ >> Qemu-devel mailing list >> Qemu-devel@nongnu.org >> http://lists.nongnu.org/mailman/listinfo/qemu-devel >> >> > > > -- > balrog 2oo6 > > Dear Outlook users: Please remove me from your address books > http://www.newsforge.com/article.pl?sid=03/08/21/143258 > > ------------------------------------------------------------------------ > > _______________________________________________ > Qemu-devel mailing list > Qemu-devel@nongnu.org > http://lists.nongnu.org/mailman/listinfo/qemu-devel > ^ permalink raw reply [flat|nested] 68+ messages in thread
* Re: [Qemu-devel] VNC terminal server? 2006-04-08 18:24 ` Johannes Schindelin ` (3 preceding siblings ...) 2006-04-08 19:21 ` andrzej zaborowski @ 2006-04-09 2:52 ` Anthony Liguori 4 siblings, 0 replies; 68+ messages in thread From: Anthony Liguori @ 2006-04-09 2:52 UTC (permalink / raw) To: qemu-devel Johannes Schindelin wrote: > Hi, > > On Sat, 8 Apr 2006, Samuel Hunt wrote: > > >> It occurs to me that this program would make an excellent basis for a VNC >> terminal server. >> > > Yeah, something like that has been done already: > http://libvncserver.sourceforge.net/qemu/qemu-rfb13.patch.gz > > There is a notable update since rfb12 (which is a bit out of date > _cough_): Nis Jorgensen has sent a patch to support scroll mice. > > IMHO the biggest obstacle to inclusion in mainline QEmu is that the mouse > support is rather flakey: You have to disable mouse acceleration of the > guest OS. > > I had that cunning plan to write a virtual Wacom tablet, but I just don't > find the time. > Someone posted a virtual Synaptic tablet on xen-devel recently (Xen uses qemu for VT support). If someone wants to pick it up and submit it to qemu, that would solve this problem. Regards, Anthony Liguori > Ciao, > Dscho > > > > _______________________________________________ > Qemu-devel mailing list > Qemu-devel@nongnu.org > http://lists.nongnu.org/mailman/listinfo/qemu-devel > ^ permalink raw reply [flat|nested] 68+ messages in thread
end of thread, other threads:[~2006-04-26 7:36 UTC | newest] Thread overview: 68+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2006-04-08 16:20 [Qemu-devel] VNC terminal server? Samuel Hunt 2006-04-08 18:12 ` Brad Campbell 2006-04-21 15:31 ` Troy Benjegerdes 2006-04-21 15:58 ` WaxDragon 2006-04-08 18:24 ` Johannes Schindelin 2006-04-08 18:37 ` Leonardo E. Reiter 2006-04-08 19:04 ` Johannes Schindelin 2006-04-08 19:15 ` Leonardo E. Reiter 2006-04-09 2:54 ` Anthony Liguori 2006-04-08 20:19 ` Brad Campbell 2006-04-08 20:29 ` Leonardo E. Reiter 2006-04-08 21:06 ` [Qemu-devel] Absolute USB-HID device musings (was Re: VNC Terminal Server) Leonardo E. Reiter 2006-04-08 21:18 ` Leonardo E. Reiter 2006-04-08 21:22 ` Brad Campbell 2006-04-08 21:36 ` Leonardo E. Reiter 2006-04-09 4:36 ` Anthony Liguori 2006-04-09 15:14 ` Jim C. Brown 2006-04-09 16:03 ` Leonardo E. Reiter 2006-04-09 16:49 ` Brad Campbell 2006-04-09 18:07 ` andrzej zaborowski 2006-04-09 18:35 ` Brad Campbell 2006-04-09 18:41 ` Lonnie Mendez 2006-04-09 19:22 ` Brad Campbell 2006-04-09 20:27 ` [Qemu-devel] Gentlemen we have absolute movement! was:Absolute " Brad Campbell 2006-04-09 20:31 ` Anthony Liguori 2006-04-09 20:57 ` Anthony Liguori 2006-04-09 21:02 ` Brad Campbell 2006-04-09 21:10 ` Brad Campbell 2006-04-09 21:20 ` Johannes Schindelin 2006-04-09 21:35 ` Brad Campbell 2006-04-09 21:39 ` Anthony Liguori 2006-04-09 22:01 ` Brad Campbell 2006-04-09 22:08 ` Anthony Liguori 2006-04-09 22:12 ` Brad Campbell 2006-04-09 22:18 ` Brad Campbell 2006-04-09 23:14 ` Brad Campbell 2006-04-10 3:40 ` [Qemu-devel] USB Tablet Emulation (was: Gentlemen we have absolute movement! was:Absolute USB-HID device musings (was Re: VNC Terminal Server)) Anthony Liguori 2006-04-10 8:23 ` [Qemu-devel] USB Tablet Emulation Brad Campbell 2006-04-10 8:32 ` Johannes Schindelin 2006-04-10 10:27 ` Brad Campbell 2006-04-10 11:27 ` Johannes Schindelin 2006-04-19 17:18 ` [Qemu-devel] USB Tablet Emulation + VNC patch Troy Benjegerdes 2006-04-21 21:13 ` Brad Campbell 2006-04-26 0:55 ` Troy Benjegerdes 2006-04-26 7:37 ` Brad Campbell 2006-04-10 14:58 ` [Qemu-devel] USB Tablet Emulation Leonardo E. Reiter 2006-04-10 15:27 ` Anthony Liguori 2006-04-10 15:39 ` Leonardo E. Reiter 2006-04-10 16:08 ` Brad Campbell 2006-04-10 19:28 ` Brad Campbell 2006-04-10 19:44 ` Brad Campbell 2006-04-10 21:27 ` Brad Campbell 2006-04-10 21:39 ` Brad Campbell 2006-04-08 18:38 ` [Qemu-devel] VNC terminal server? Mark Williamson 2006-04-08 18:53 ` Johannes Schindelin 2006-04-08 19:01 ` Jim C. Brown 2006-04-08 19:12 ` Johannes Schindelin 2006-04-08 19:30 ` Jim C. Brown 2006-04-08 19:40 ` Johannes Schindelin 2006-04-09 2:55 ` Anthony Liguori 2006-04-09 2:53 ` Anthony Liguori 2006-04-08 19:21 ` andrzej zaborowski 2006-04-08 19:33 ` Leonardo E. Reiter 2006-04-09 2:59 ` Anthony Liguori 2006-04-09 16:06 ` Leonardo E. Reiter 2006-04-09 16:40 ` Anthony Liguori 2006-04-09 2:57 ` Anthony Liguori 2006-04-09 2:52 ` Anthony Liguori
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).