[Spice-devel] The solution of usbredir display problems for windows, temporarily

Cody Chan int64ago at gmail.com
Thu Sep 4 02:11:57 PDT 2014


Ok, this's not a patch, for I don't think it's good enough to be applied to
upstream.
For windows client, it's really not friendly for usbredir:
1. We need usbclerk service to let it redirect automatically --> not stably
currently
2. The display of redir-list is ALL "USB DEVICE" -->  make users confused
maybe
3. Filtering by class doesn't work at all --> usually need to filter input
devices, etc.

The reason for all the above is that libusb supports windows poorly.
So here's the solution for problem 2 & 3,
this's a vs2010 project built with libwdi
<http://sourceforge.net/projects/libwdi/>, the output is usbutils.dll,
and I put the project in github <https://github.com/int64Ago/UsbUtils4Spice>

After building libwdi, add LIBWDI_DIR=path\to\libwdi in environment
settings,
then build usbutils project

In gtk/usbutil.c or gtk/usb-device-manager.c ...
do something like this(just an example):
#define MAX_LEN_ 256
typedef struct{
        char desc[MAX_LEN_];
        int pid;
        int vid;
        int clas;
}UsbInfo;

//...
    UsbInfo usbInfo[20];
    typedef int (*fpFun)(UsbInfo[]);
    HMODULE hDllLib = LoadLibraryA("usbutils.dll");
    fpFun getUsbList = (fpFun)GetProcAddress(hDllLib,"getUsbList");
    int num = getUsbList(usbInfo);
    for(int i = 0; i < num; ++i){
        if(usbInfo[i].pid == pid && usbInfo[i].vid == vid)
            return g_strdup_printf("%s [%02X:%04X:%04X]", usbInfo[i].desc,
                usbInfo[i].clas, usbInfo[i].vid, usbInfo[i].pid);
//...

​And at last, here's the effect:
http://int64ago.qiniudn.com/o_190vus62h3lh1pr81kf0be6v4b9.png​

-- 
QSBDT0RFUiBGUk9NIFJJRVNUIE9GIENUU0VV
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/spice-devel/attachments/20140904/4b8d3f72/attachment.html>


More information about the Spice-devel mailing list