XboxHacker BBS
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
May 22, 2013, 01:49:18 PM


Login with username, password and session length


Pages: 1
  Print  
Author Topic: PC GENERIC USB GAMEPAD / JOYSTICK CHINESE adapter for XBOX360  (Read 1432 times)
Super_TOB
Newbie
*
Posts: 6


View Profile
« on: August 29, 2012, 09:39:15 AM »

This topic is specifically for creating ADAPTER MODULE to use generic USB gamepad PC (Personal Computer) in the Xbox360 console.

CHINESE USB GAMEPAD USB PC -> Xbox360 (CONSOLE).

scenario:

You have Retro SEGA Saturn USB Classic Controller, this is a wonderful gamepad to play Street Fighter, Marvel Vs Capcom, and all fighting games that use six buttons CAPCOM or more.But the Xbox360 does not recognize the generic USB gamepad or joystick computer.

Plus you want to play on your Xbox 360 using your favorite gamepad usb computer.



Logged
Super_TOB
Newbie
*
Posts: 6


View Profile
« Reply #1 on: August 29, 2012, 09:46:07 AM »

I'm studying a solution using PIC microcontrollers on to adapt the generic HID gamepad PC for standard Microsoft wired xbox360 gamepad , or create an emulator.

its is one example:

http://www.xboxhacker.org/index.php?PHPSESSID=31ac5e3ae02d68a14bc0024ebc9d562d&topic=17779.0



Logged
Super_TOB
Newbie
*
Posts: 6


View Profile
« Reply #2 on: August 29, 2012, 09:53:08 AM »

I found some information about the controller:

Site fonte: http://euc.jp/periphs/xbox-controller.ja.html


Vendor/Product IDs

The vendor ID is 0x045e (Microsoft). Product IDs are as follows:
ID   product
0x001c   integrated hub
0x0202   gamepad (American)
0x0280   memory unit
0x0284   DVD remote receiver
0x0285   gamepad (Japanese)

It is not recommended to distinguish Xbox gamepads by vendor/product IDs because third-party controllers may have their own vendor/product IDs.
Device Class

The gamepad has interface class 0x58 ('X'), subclass 0x42 ('B'), protocol 0x00. I believe this should be also common to third-party controllers, but I have no evidence. In fact the gamepad conforms to the HID class and behaves like a USB HID gamepad except that it lacks the HID descriptor and the HID report descriptor.

The memory unit has interface class 0x08 (mass storage), subclass 0x42 ('B'=???), protocol 0x50 (bulk-only). It seems to conform to the mass storage device class with bulk-only transport, though the "true" subclass must be revealed to access the unit.
HID Report Format
Input Report

The input report is 20-byte.
offset    data
+0    0x00
+1    0x14 (size of the whole report)
+2    digital buttons
bit0    D-pad up
bit1    D-pad down
bit2    D-pad left
bit3    D-pad right
bit4    start button
bit5    back button
bit6    left stick press
bit7    right stick press
+3    0x00 (reserved for more digital buttons?)
+4    A button (*)
+5    B button (*)
+6    X button (*)
+7    Y button (*)
+8    black button (*)
+9    white button (*)
+10    L trigger (*)
+11    R trigger (*)
+12    left stick x (**)
+14    left stick y (**)
+16    right stick x (**)
+18    right stick y (**)

    (*) unsigned 8-bit
    (**) signed 16-bit, little-endian, north/east positive

Output Report

The output report (rumble control) is 6-byte.
offset    data
+0    0x00
+1    0x06 (size of the whole report)
+2    0x00
+3    left actuator (*)
+4    0x00
+5    right actuator (*)

(*) unsigned 8-bit
Logged
Super_TOB
Newbie
*
Posts: 6


View Profile
« Reply #3 on: August 29, 2012, 10:12:15 AM »

New more information:

Site:  http://www.free60.org/GamePad


 The gamepad HID device

The gamepad is a regular USB HID device, but it has been crippled in a slight way:

The device uses the 0xff DeviceClass ('Vendor Specific') while normal HID devices use 0x03. Therefore normal HID drivers won't attach to it automatically. The device has no USB Report Descriptor, making the operating system unable to determine its device layout. Both problems are not hard to overcome; some operating systems (the BSDs for example) already override the USB Report Descriptors for some devices because they were shipped with broken ones.

A replacement report descriptor is available from the Free60 CVS repository. The layout of this descriptor is the same as the Windows driver, except that the big X button has been mapped to button 11. On Windows, it's unmapped.
Input report

Once in a while, a USB HID device sends back a so-called input report which contains all information about its current state. The length of the input report is the same as the original Xbox gamepad; 20 bytes.

Its button/trigger/pad/stick alignment is as listed below:

Offset    Length (bits)    Description    Windows driver
0x00.0    8    Message type
0x01.0    8    Packet size (20 bytes = 0x14)
0x02.0    1    D-Pad up    D-Pad up
0x02.1    1    D-Pad down    D-Pad down
0x02.2    1    D-Pad left    D-Pad left
0x02.3    1    D-pad right    D-Pad right
0x02.4    1    Start button    Button 8
0x02.5    1    Back button    Button 7
0x02.6    1    Left stick press    Button 9
0x02.7    1    Right stick press    Button 10
0x03.0    1    Button LB    Button 5
0x03.1    1    Button RB    Button 6
0x03.2    1    Xbox logo button
0x03.3    1    Unused
0x03.4    1    Button A    Button 1
0x03.5    1    Button B    Button 2
0x03.6    1    Button X    Button 3
0x03.7    1    Button Y    Button 4
0x04.0    8    Left trigger    Z-axis down
0x05.0    8    Right trigger    Z-axis up
0x06.0    16    Left stick X-axis    X-axis
0x08.0    16    Left stick Y-axis    Y-axis
0x0a.0    16    Right stick X-axis    X-turn
0x0c.0    16    Right stick Y-axis    Y-turn
0x0e.0    48    Unused

All eight-bit values are unsigned. The 16-bit values are signed little-endian. The first byte (Message type) will be 0x01 for a LED status message and 0x00 for a normal input report message.
Output report
LED Control

Some control over the LEDs surrounding the XBox button is provided, corresponding to the markings 1, 2, 3 and 4. This is controlled using message type 0x01.

To select a new pattern for the LEDs, send a 3-byte packet of the following form:

0103XX

0x01 is the message type, 0x03 is the message length, and 0xXX is the desired pattern:

Pattern    Description
0x00    All off
0x01    All blinking
0x02    1 flashes, then on
0x03    2 flashes, then on
0x04    3 flashes, then on
0x05    4 flashes, then on
0x06    1 on
0x07    2 on
0x08    3 on
0x09    4 on
0x0A    Rotating (e.g. 1-2-4-3)
0x0B    Blinking*
0x0C    Slow blinking*
0x0D    Alternating (e.g. 1+4-2+3), then back to previous*

The previous setting will be used for any itmes with * (all blinking, or 1, 2, 3 or 4 on).
Rumbler Control

Rumbling is also similar to on the original controller. Rumble commands take the following 8-byte form:

000800bbll000000

Where b is the speed to set the motor with the big weight, and l is the speed to set the small weight (0x00 to 0xFF in both cases).
The headset-port

Headset Port File:Headset port pinout.jpg Pinout for the headset port on the wired and wireless Xbox 360 controller Baud Rate: Unknown, Data 1: RX or TX, Data 2: RX or TX

A chatpad (mini-keyboard) for text entry can be plugged into this port.
The headset data protocol

FreeBSD ships with a driver called ugen(4) which is just a fallback driver for USB devices that do not have a matching driver. It allows you to read and write to the descriptors of the device. Descriptor 3 is used for the microphone. Descriptor 4 is the earpiece.

At this moment there isn't a lot of information available about the transfer protocol. The protocol for the microphone and the earpiece are the same, but the latter one uses half the sample rate of the first one. The following test shows this:

$ cat /dev/ugen0.3 > myvoice
# tell a funny joke to the microphone and press ^C
$ cat myvoice > /dev/ugen0.4
Playback will take twice as long.

The microphone emits 8000 bytes per second of 4 bits signed PCM, thus it's 16 KHz. The earpiece only consumes 4000 bytes, so it can only emit 8 KHz PCM (4 KHz sound at best).
lsusb output

Linux's lsusb utility tells us the following about the gamepad.

Bus 002 Device 003: ID 045e:028e Microsoft Corp.
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass          255 Vendor Specific Class
  bDeviceSubClass       255 Vendor Specific Subclass
  bDeviceProtocol       255 Vendor Specific Protocol
  bMaxPacketSize0         8
  idVendor           0x045e Microsoft Corp.
  idProduct          0x028e
  bcdDevice            1.10
  iManufacturer           1
  iProduct                2
  iSerial                 3
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength          153
    bNumInterfaces          4
    bConfigurationValue     1
    iConfiguration          0
    bmAttributes         0xa0
      (Bus Powered)
      Remote Wakeup
    MaxPower              500mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           2
      bInterfaceClass       255 Vendor Specific Class
      bInterfaceSubClass     93
      bInterfaceProtocol      1
      iInterface              0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0020  1x 32 bytes
        bInterval               4
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x02  EP 2 OUT
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0020  1x 32 bytes
        bInterval               8
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        1
      bAlternateSetting       0
      bNumEndpoints           4
      bInterfaceClass       255 Vendor Specific Class
      bInterfaceSubClass     93
      bInterfaceProtocol      3
      iInterface              0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x83  EP 3 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0020  1x 32 bytes
        bInterval               2
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x04  EP 4 OUT
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0020  1x 32 bytes
        bInterval               4
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x85  EP 5 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0020  1x 32 bytes
        bInterval              64
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x05  EP 5 OUT
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0020  1x 32 bytes
        bInterval              16
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        2
      bAlternateSetting       0
      bNumEndpoints           1
      bInterfaceClass       255 Vendor Specific Class
      bInterfaceSubClass     93
      bInterfaceProtocol      2
      iInterface              0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x86  EP 6 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0020  1x 32 bytes
        bInterval              16
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        3
      bAlternateSetting       0
      bNumEndpoints           0
      bInterfaceClass       255 Vendor Specific Class
      bInterfaceSubClass    253
      bInterfaceProtocol     19
      iInterface              4
      UNRECOGNIZED:  06 41 00 01 01 03

Logged
Super_TOB
Newbie
*
Posts: 6


View Profile
« Reply #4 on: September 07, 2012, 08:52:44 AM »

 new very interesting VIDEO, use calculator to control Xbox360 .

http://brandonw.net/360bridge/

youtube video ( http://www.youtube.com/watch?v=0iIrdrFfx8I )


EXAMPLE CODE



using System;
using System.Collections.Generic;
using System.Text;
using LibUsbDotNet;
using LibUsbDotNet.Main;

namespace Salamax
{
  public class Xbox360Controller : USBDevice
  {
    private UsbDevice _device = null;

    public override bool IsConnected
    {
      get
      {
        return (_device != null && _device.IsOpen);
      }
    }

    public override void Find()
    {
      bool wasValid = (_device != null && _device.IsOpen);

      //Find the Xbox 360 controller
      bool found = _FindController();

      if (found)
      {
        if (!wasValid)
        {
          Logger.WriteLine("Xbox 360 controller found, initializing...", Logger.Type.Warning);
          /*
          var device = _device as IUsbDevice;
          device.ResetDevice();
          System.Threading.Thread.Sleep(3000);
          _FindController();
           * */
          var writer = _device.OpenEndpointWriter(WriteEndpointID.Ep02, EndpointType.Interrupt);
          int transferred;
          writer.Write(new byte[] { 0x01, 0x03, 0x00 }, 10000, out transferred);

          Logger.WriteLine("Xbox 360 controller initialized.", Logger.Type.Information);
        }
      }
      else
      {
        if (_device != null)
        {
          _device = null;
          Logger.WriteLine("Xbox 360 controller disconnected.", Logger.Type.Warning);
        }
      }
    }

    public override void Disconnect()
    {
      if (_device != null && _device.IsOpen)
      {
        _device.Close();
      }
    }

    public byte[] RequestStaticData()
    {
      var ret = new byte[0x1D];

      int transferred;
      Logger.WriteLine("Setting Xbox 360 controller configuration 1.", Logger.Type.Information);
      var setup = new UsbSetupPacket(0x00, 0x09, 0x0001, 0x00000, 0x0000);
      var success = _device.ControlTransfer(ref setup, IntPtr.Zero, 0x0000, out transferred);
      Logger.WriteLine("Requesting Xbox 360 controller security string descriptor...", Logger.Type.Information);
      setup = new UsbSetupPacket(0x80, 0x06, 0x0304, 0x0409, 0x00B2);
      var buffer = new byte[0x00B2];
      success = _device.ControlTransfer(ref setup, buffer, 0x00B2, out transferred);

      setup = new UsbSetupPacket(0xC1, 0x81, 0x5B17, 0x0103, 0x001D);
      Logger.WriteLine("Requesting static data from controller...", Logger.Type.Information);
      if (_device.ControlTransfer(ref setup, ret, 0x001D, out transferred))
        Logger.WriteLine("Static controller data received successfully.", Logger.Type.Information);

      return ret;
    }

    public byte[] DoChallenge1(byte[] data)
    {
      int transferred;
      var ret = new byte[0x2E];

      Logger.WriteLine("Sending first challenge to Xbox 360 controller...", Logger.Type.Information);
      var setup = new UsbSetupPacket(0x41, 0x82, 0x0003, 0x0103, 0x0022);
      if (_device.ControlTransfer(ref setup, data, 0x0022, out transferred))
      {
        //Wait till the controller is done with our response
        bool complete = false;
        do
        {
          setup = new UsbSetupPacket(0xC1, 0x86, 0x0000, 0x0103, 0x0002);
          var response = new byte[0x0002];
          if (_device.ControlTransfer(ref setup, response, 0x0002, out transferred) && transferred == 2)
          {
            Logger.WriteLine("Checking status of first response from Xbox 360 controller: " + response[0].ToString("X2"),
              Logger.Type.Information);
            if (response[0] > 1)
              complete = true;
          }

          System.Threading.Thread.Sleep(100);
        } while (!complete);

        Logger.WriteLine("First response is ready from Xbox 360 controller.", Logger.Type.Information);

        //Get the response
        setup = new UsbSetupPacket(0xC1, 0x83, 0x5C28, 0x0103, 0x002E);
        Logger.WriteLine("Requesting first response from Xbox 360 controller...", Logger.Type.Information);
        if (_device.ControlTransfer(ref setup, ret, 0x002E, out transferred))
        {
          Logger.WriteLine("Sending next step to Xbox 360 controller...", Logger.Type.Information);
          setup = new UsbSetupPacket(0x41, 0x84, 0x0003, 0x0103, 0x0000);
          _device.ControlTransfer(ref setup, IntPtr.Zero, 0, out transferred);
        }
        else
          Logger.WriteLine("First response request from Xbox 360 controller failed.", Logger.Type.Error);
      }
      else
        Logger.WriteLine("Sending first challenge to Xbox 360 controller failed.", Logger.Type.Error);

      return ret;
    }

    public byte[] DoChallenge2(byte[] data)
    {
      int transferred;
      var ret = new byte[0x16];

      Logger.WriteLine("Sending second challenge to Xbox 360 controller...", Logger.Type.Information);
      var setup = new UsbSetupPacket(0x41, 0x87, 0x0003, 0x0103, 0x0016);
      var buffer = new byte[0x100];
      for (int i = 0; i < data.Length; i++)
        buffer = data;
      if (_device.ControlTransfer(ref setup, buffer, 0x0016, out transferred))
      {
        //Wait till the controller is done with our response
        bool complete = false;
        do
        {
          setup = new UsbSetupPacket(0xC1, 0x86, 0x0000, 0x0103, 0x0002);
          var response = new byte[0x0002];
          if (_device.ControlTransfer(ref setup, response, 0x0002, out transferred) && transferred == 2)
          {
            Logger.WriteLine("Checking status of second response from Xbox 360 controller: " + response[0].ToString("X2"),
              Logger.Type.Information);
            if (response[0] > 1)
              complete = true;
          }

          System.Threading.Thread.Sleep(100);
        } while (!complete);

        Logger.WriteLine("Second response is ready from Xbox 360 controller.", Logger.Type.Information);

        //Get the response
        setup = new UsbSetupPacket(0xC1, 0x83, 0x5C10, 0x0103, 0x0016);
        Logger.WriteLine("Requesting second response from Xbox 360 controller...", Logger.Type.Information);
        if (_device.ControlTransfer(ref setup, ret, 0x0016, out transferred))
        {
          Logger.WriteLine("Sending next step to Xbox 360 controller...", Logger.Type.Information);
          setup = new UsbSetupPacket(0x41, 0x84, 0x0003, 0x0103, 0x0000);
          _device.ControlTransfer(ref setup, IntPtr.Zero, 0, out transferred);
        }
        else
          Logger.WriteLine("Second response request from Xbox 360 controller failed.", Logger.Type.Error);
      }
      else
        Logger.WriteLine("Sending second challenge to Xbox 360 controller failed.", Logger.Type.Error);

      return ret;
    }

    private bool _FindController()
    {
      bool ret = false;

      foreach (object reg in LibUsbDotNet.LibUsb.LibUsbRegistry.DeviceList)
      {
        if (reg.GetType() == typeof(LibUsbDotNet.LibUsb.LibUsbRegistry))
        {
          var usb = reg as LibUsbDotNet.LibUsb.LibUsbRegistry;

          if (usb.Vid == 0x1BAD && usb.Pid == 0xF900)
          {
            _device = usb.Device;
            ret = true;
            break;
          }
        }
      }

      return ret;
    }
  }
}
Logged
Pages: 1
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC

Valid XHTML 1.0! Valid CSS! Dilber MC Theme by HarzeM