Share this post

Submit to DeliciousSubmit to DiggSubmit to FacebookSubmit to Google BookmarksSubmit to StumbleuponSubmit to TechnoratiSubmit to TwitterSubmit to LinkedIn

Before I talked about a way to send and receive data to a Serial port and I told you that most of the microcontrollers and other electronic stuff have a serial port and in the Electronics section of the site I posted a project to create a Virtual Serial port out of a USB.

Now what if you want to send and receive data directly to a USB port? 


Suppose that you have an XBOX360 USB controller and you want to use it to control your mouse. Or you want to write a simple game and use it as the controller for your game. Seems like an exciting project no? But the problem is that you can't create a virtual serial port, can you?

You may think: Ok we just find a library like we did for the Serial and we use it with our VC++ project, but unfortunately this time things aren't so easy.

Before you have any understanding of USB you should know that it's a "BUS" not only a "Port" like the "Serial Port".

Any device that gets connected to this bus should have a driver to define it's functionality because there can be infinite kinds of data packets between two devices on a USB bus.

I don't want to make it more complicated so I just tell you how it's done: You have to use something like a filter which is mounted on the driver program of the device and inspects the data that is sent or received between the driver and the operating system.

Some people have done a wonderful job and put it on Sourceforge. The project is called libusb-win32. The download link is here. You can also find a brief explanation about the project there.

Here are the steps I took in VC++ to use libusb-win32 to send and receive data directly to and from a device like a usb keyboard, an XBOX360 controller and so on...

 These are done in windows Vista but for other versions of windows are identical:


1.Download Libusb-Win32-bin

2.Run "Libusb-Win32-bin/bin/x86/install-filter-win" and choose the device you want to communicate with

3.Create a windows forms application and in stdafx.h include the header file from the "Libusb-Win32-bin/include" folder: lusb0_usb.h

4.Copy Libusb-Win32 library from the folder "Libusb-Win32-bin/lib/msvc" to Visual Studio Library folder

5.In Project tab select $(Project name)Properties and in "Linker/Input/Additional Dependencies" write libusb.lib

6.In Project tab select $(Project name)Properties again. Go to "Configuration Properties/General/Common Language Runtime Support" and select Common Language Runtime Support(/clr)


In my future posts I'll explain the ways to use libusb-win32 to hack an XBOX360 usb controller.


Strict Standards: Only variables should be assigned by reference in /home/geekbrot/public_html/modules/mod_ilike_social_media_optimization/tmpl/default.php on line 13

Strict Standards: Only variables should be assigned by reference in /home/geekbrot/public_html/modules/mod_ilike_social_media_optimization/tmpl/horizontal1.php on line 13
© geek brothers