[haiku-development] Re: Joysticks in Haiku

  • From: "Carwyn" <cdj1000@xxxxxxx>
  • To: "Haiku-dev" <haiku-development@xxxxxxxxxxxxx>
  • Date: Wed, 09 Mar 2011 21:32:33 +0000

Stephan,  Sorry for top posting.

Maybe i'm not explaining my question properly,  my question is about 
how to access the Reports in usb_hid,  at the moment as you know you 
can get the xAxis for a usb device as follows,

HIDReportItem *xAxis = report-
>FindItem(B_HID_USAGE_PAGE_GENERIC_DESKTOP, B_HID_UID_GD_X);

Now we have the xAxis for a Gamepad,  but the problem is how to detect 
what type of device is connected,  I would like to use the existing 
usb_hid code as is,  because it gives us access to what we need already 
and there is no need to write a seperate driver.  Do you think it's 
possible to modify the Parser so we can access the device's USAGE 
paramater.  By getting the possibilty of knowing the device's usage 
paramater it would stop MouseDevice detecting Gamepads as a mouse.

 

Enrique,

I'm not a usb hid expert either,  i think what is needed is to have 
access to the following HIDReportItem *game = report-
>FindItem(B_HID_USAGE_PAGE_GENERIC_DESKTOP, B_HID_UID_GD_GAMEPAD);

After looking at the usb_hid code parser it looks like it only adds 
reports of type main, a GamePad device descriptor has first the 
USAGE_PAGE(Generic Desktop) of type global,  then a local type of 
USAGE(Gamepad),  to properly detect what device type is connected we 
need access to the USAGE.

At the moment i have added a usb_device USBDevice() const { return 
fDevice; } to HIDDevice.h,  I then access the usb_device in 
GamepadDevice::AddHandler(HIDDevice *device, HIDReport *report)

usb_device current_device = device->Device();
const usb_device_descriptor *deviceDescriptor = gUSBModule-
>get_device_descriptor(current_device);

if(deviceDescriptor->vendor_id != 0x0428) return NULL; // check vendor

I don't like the above way of doing it,  because it shouldn't matter 
about the vendor_id as the device is just a Gamepad and we only want to 
know if it's a Gamepad.  You can send me your code for a tablet device 
if you don't mind.

Carwyn

Other related posts: