http://blissbox.freeforums.org

the first ever all in one, trouble free, and ready to go usb adapter
Home Page Play games in the arcade Home Page Home Page Home Page
  Register
Login 
View unanswered posts View active topics

Delete all board cookies


All times are UTC - 5 hours [ DST ]



Welcome
Welcome to blissbox

You are currently viewing our boards as a guest, which gives you limited access to view most discussions and access our other features. By joining our free community, you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content, and access many other special features. In addition, registered members also see less advertisements. Registration is fast, simple, and absolutely free, so please, join our community today!


Home Page Home Page  [ 8 posts ] 
  Print view
Previous topic | Next topic 
Author Message
Offline 
 Post subject: the legend of Force Feed Back
PostPosted: Wed Jun 02, 2010 10:11 am 
User avatar
Site Admin

Joined: Wed Apr 21, 2010 8:39 am
Posts: 1388
Image

NOTE: Do not use this code without showing a proper link back to this this forum.
I dont have a running total of time it took to do this, but I will say the only help I got was minimal. Most people I contacted had 0 to say, or just not interested. The few that tackled this ended up missing ( m$ conspiracy?). So far I'm still alive ;)
I can only thank:
Arrow from http://www.microchip.com [missing]
Easty from http://forums.obdev.at/
and
m_gray from http://www.usb.org/

They provided some tid-bits that help me hurtle a few challenges.
So again, please, link back to my page if you find this useful. Include this forum, my main page and email. This is all that I ask.


PSX Hardware note:
Its not clear what voltage is needed, best I could tell is 7.6 volts. I'm told some use 4 volts and others device use 5. I used 5 because its the easiest to use as no step up is needed. Also I read that 500ma may be drawn when the motor first comes on and 300 during use. I needed to make 4 bliss-boxes work on one hub so I experimented. I set my device to 50ma and both my large and small motors work. They are most certainly not as powerful as a 9 volt but quite playable.




Well first off it would not hurt to start here http://en.wikipedia.org/wiki/Human_interface_device. To keep this short I'm going to make the assumption readers have some idea of what is involved here. If anything is not clear just ask.

If your using V-USB you must fix a bug ( unless they got to it by now ) http://forums.obdev.at/viewtopic.php?f=8&t=4042 then make sure to set up for long transfers (#define USB_CFG_LONG_TRANSFERS 1), along with setting FN_WRITE to a 1. details in this post http://forums.obdev.at/viewtopic.php?f=8&t=4313&sid=44764e51f45731fc5051912cb4d8aaaa. Your also going to need this for a reference http://www.usb.org/developers/devclass_docs/pid1_01.pdf

Once you get to the point where your device shows up as a Force feed back device you can move forward. To know if its a FFB you can look in the registry for the OEMForceFeedback key under your PID/VID. NOTE: after you make a change in the firmware you need to delete this key so it will re-created it right. I spent days not knowing this. So if you dont see OEMForceFeedback try to use usbDview and remove the device, then let it reinstall itself. You can also use Fedit to see if its a FFB device. Fedit is very helpful.

Ok moving forward:
NOTE: This will work for most effects but its based on constant force.

Adding the above is simply not enough, you now need to communicate with the HOST. It will send a lot of commands, but you only need to watch for a few:

An OUT byte is info, no need to reply.
a GET requires a reply
a SET no need to reply, its like an out but from a feature report.


Normally when the FFB becomes alive you get these OUT bytes
0c 04
0d ff
0c 03

The C (Usage DC Disable Actuators) is a status of sorts ( 3 being pause 4 being continue ) and the D(Usage PID Pool Report) is a memory check of sorts. They are not allays in the same order and are used when you leave screen focus or close the app. I did not bother with them really.

In Fedit I also get a GET request from report 3, and I give it 03 FF 01 01 01 but I dont think you will see this normally and its not needed( have not see this in emulators). Also I get a SET for report 1 that seems not to be important ( some emulators do this ).

Once an effect is ran I get:
SET report 1 : this is out index effect. Save this data it looks like 01 03 00 00 where 3 is our index.
GET report 2 : you need to send a : 02 03 01 ff ff where 3 is the index.

during play watch for these OUTS.
05 01 ff 00 : magnitude where ff is the most. ( how much rumble: constant force only ), and the 01 is the index
0a 01 01 00 : where 01 in this case is the index.
0a 01 01 00 : where 01 means to start. IF it where 03 its a stop the effect.
0a 01 00 01 : where 01 means the amount of loops. ( stop will have a 0 here )


note: Do not confuse stops. You really dont need a stop since the start tells you the rumble loop times. If you see a 0a 01 01 10 you would rumble 10 loops. Most all dream cast emulators dont use FFB. The new NullDc supports Xinput for the 360 pad, but its not sending FFB commands. makaron does use it, but they use sine not constant force and they send a lot of stops 0A 03 03 . I see a start followed by a report 04 ( setting the characteristics for the sine wave, then a stop. After that I see a few stops the next time rumble is needed. I think the stop means do what you just did last. Personally I think the author need to send a start before those stops. So I added support for that by doing a quick rumble at every stop.

other commands I see that I dont use, but could be helpful or later implemented.
Envelope Report ( GET report )
02 01 ff ff 00 00 00 00 [ id index Attack Level, Fade Level Attack time Fade time 00 00

ES Playing- I think this is how the client tells the host to start the effect paused and use the attack time to start but I was not able to use it.
02 01 01 01 00 00 80 80 [ id index Reset Paused Actuator Power, undefined 00 00


Please Do not use this code without showing a proper credit, see above.

V-USB:
example device desc
Code: Select all
uchar my_usbDescriptorConfiguration[] = {    /* USB configuration descriptor */
     9,          /* sizeof(usbDescriptorConfiguration): length of descriptor in bytes */
    USBDESCR_CONFIG,    /* descriptor type */
    18 + 7 * USB_CFG_HAVE_INTRIN_ENDPOINT + 7 * USB_CFG_HAVE_INTRIN_ENDPOINT3 + 9, 0,
                /* total length of data returned (including inlined descriptors) */
    1,          /* number of interfaces in this configuration */
    1,          /* index of this configuration */
    0,          /* configuration name string index */
    USB_CFG_IS_SELF_POWERED,  /* attributes */

    USB_CFG_MAX_BUS_POWER/2,            /* max USB current in 2mA units */
/* interface descriptor follows inline: */
    9,          /* sizeof(usbDescrInterface): length of descriptor in bytes */
    USBDESCR_INTERFACE, /* descriptor type */
    0,          /* index of this interface */
    0,          /* alternate setting for this interface */
    USB_CFG_HAVE_INTRIN_ENDPOINT + USB_CFG_HAVE_INTRIN_ENDPOINT3,   /* endpoints excl 0: number of endpoint descriptors to follow */
    USB_CFG_INTERFACE_CLASS,
    USB_CFG_INTERFACE_SUBCLASS,
    USB_CFG_INTERFACE_PROTOCOL,
    0,          /* string index for interface */


    9,          /* sizeof(usbDescrHID): length of descriptor in bytes */
    USBDESCR_HID,   /* descriptor type: HID */
    0x10, 0x01, /* BCD representation of HID version */
    0x00,       /* target country code */
    0x01,       /* number of HID Report (or other HID class) Descriptor infos to follow */
    0x22,       /* descriptor type: report */
    USB_CFG_HID_REPORT_DESCRIPTOR_LENGTH, 0,  /* total length of report descriptor *///
//#endif


#if USB_CFG_HAVE_INTRIN_ENDPOINT    /* endpoint descriptor for endpoint 1 */
    7,          /* sizeof(usbDescrEndpoint) */
    USBDESCR_ENDPOINT,  /* descriptor type = endpoint */
    0x81,       /* IN endpoint number 1 */
    0x03,       /* attrib: Interrupt endpoint */
    8, 0,       /* maximum packet size */
    USB_CFG_INTR_POLL_INTERVAL, /* in ms */

#endif

#if USB_CFG_HAVE_INTRIN_ENDPOINT3
    7,          /* sizeof(usbDescrEndpoint) */
    5,  /* descriptor type = endpoint */
    0x02,      /* out endpoint number 2 */
    0x03,       /* attrib: Interrupt endpoint */
    8, 0,       /* maximum packet size */
    0x20, /* in ms */
#endif
};


example usb function setup
Code: Select all
unsigned  usbFunctionSetup(uchar data[8])
{
   usbRequest_t    *rq = (void *)data;
   usbMsgPtr = reportBuffer;

   if((rq->bmRequestType & USBRQ_TYPE_MASK) == USBRQ_TYPE_CLASS)
   {    /* class request type */
      if(rq->bRequest == USBRQ_HID_GET_REPORT)
      {
         if (  rq->wValue.bytes[0] == 2 )
         {//PID Block Load Report
         
            reportBuffer[0]=2; //report id 2
            reportBuffer[1]=_FFB_effect_index;//effect index
            reportBuffer[2]=1;//1 =  success:2 = full: 3 = error
         }             
         return USB_NO_MSG;      
      }   
      else if (rq->bRequest == USBRQ_HID_SET_REPORT)
       {
           if (  rq->wValue.bytes[0] == 1 )  _setReport=1;//set effect  Report
         return USB_NO_MSG;
       }      
   }
    return 0;
}


example usb function write
Code: Select all
char usbFunctionWrite(uchar *data, uchar len)
{

   if (data[0]==1 && _setReport )
   {
      _setReport=0;//remove flag
      _FFB_effect_index = data[1];//index
   }

   else if (data[0]==0x0C) //Usage DC Disable Actuators
   {   
      
      //I guess one could use these to pause effects on focus change
      //c,4 on out focus, c4 and c,3 on in focus ...
       /*
      0x09,0x97,    //    Usage DC Stop All Effects
      0x09,0x98,    //    Usage DC Device Reset
      0x09,0x99,    //    Usage DC Device Pause
      0x09,0x9A,    //    Usage DC Device Continue
      0x09,0x9B,    //    Usage PID Device State
      0x09,0x9C,    //    Usage DS Actuators Enabled
      */
     }
   else if (data[0]==0x05) //Usage Set Constant Force Rep
   {
      _rumbleLevel = data[2];
   }
   else if (data[0]==0x0A) //Usage Effect Operation Report
   {
      if (data[2]==1) _rumble++;
      else if (data[2]==3) _rumble = 0;//force shut off.
   }

    return 1;
}

for an example of the descriptor see Post #: 35 at this link http://www.microchip.com/forums/tm.aspx ... 25&mpage=2

tools:
usblyzer - http://www.usblyzer.com/
usbDview -http://www.nirsoft.net/utils/usb_devices_view.html
fEdit -http://bliss-box.net/temp/fedit.zip


Image
Bliss-Box- a usb adapter for all controllers

Compatibility List


Top
 Profile  
 
Offline 
 Post subject: Re: the legend of Force Feed Back
PostPosted: Sat Jun 19, 2010 9:58 am 

Joined: Fri May 07, 2010 10:53 pm
Posts: 17
Tears of joy my programming friend, tears of joy.


Top
 Profile  
 
Offline 
 Post subject: Re: the legend of Force Feed Back
PostPosted: Mon Aug 30, 2010 12:57 pm 
User avatar
Site Admin

Joined: Wed Apr 21, 2010 8:39 am
Posts: 1388
Well looks like v-USB finally got around to identifying the bug ( see thread from above ) It should be included in the next release as an official fix.


Image
Bliss-Box- a usb adapter for all controllers

Compatibility List


Top
 Profile  
 
Offline 
 Post subject: Re: the legend of Force Feed Back
PostPosted: Mon Feb 27, 2012 7:19 am 

Joined: Mon Dec 19, 2011 8:10 pm
Posts: 1
The OEMForceFeedback key should show up when noting else than the descriptors are in place and correct, right?

I am working with a PIC32 / MPLABX / Windows 7 x64.


Top
 Profile  
 
Offline 
 Post subject: Re: the legend of Force Feed Back
PostPosted: Mon Feb 27, 2012 4:52 pm 
User avatar
Site Admin

Joined: Wed Apr 21, 2010 8:39 am
Posts: 1388
I think your are referring to the reg key? This is the key you can set if you donbt have the FFB implemented in the HID ( hack ). I believe you are correct, that if you make a proper FFB descriptor it will show up. However, note that you must remove the device completely before changing if you tried fooling with it. I remember I had the FFB working long before it showed up in the OS and it was because of that key. I guess I read some advice about setting this manually to make things work. Turns out it only gave me headaches. You can use usb Dview to removed the device properly.


Image
Bliss-Box- a usb adapter for all controllers

Compatibility List


Top
 Profile  
 
Offline 
 Post subject: Re: the legend of Force Feed Back
PostPosted: Mon Apr 29, 2013 12:35 pm 

Joined: Thu Mar 14, 2013 4:20 pm
Posts: 1
Thank you so much for all your help!


Top
 Profile  
 
Offline 
 Post subject: Re: the legend of Force Feed Back
PostPosted: Wed Jul 03, 2013 1:59 am 

Joined: Wed May 01, 2013 4:19 pm
Posts: 1
Hi All,

Where can I know that, what is the effectblockindex number of my constant or periodic or whatever force?
I had a guess, that can be find in the OEM forcefeedback registry, but I am not sure about that.
Two examples from it:

GUID_ConstantForce
26 00 0F 00 01 86 00...

GUID_RampForce
27 00 0F 00 02 86 00...

The bold number should be the effect block index num?


Top
 Profile  
 
Offline 
 Post subject: Re: the legend of Force Feed Back
PostPosted: Wed Jul 03, 2013 7:31 am 
User avatar
Site Admin

Joined: Wed Apr 21, 2010 8:39 am
Posts: 1388
You set that yourself if you dont have FFB implemented in the HID . If your using the descriptor I linked to in the topic above you dont need to do this. All that hack does is tell the software "this usb has FFB". If yo do the descriptor correctly you want need to do that.

I never had to use report 26 or 27, I dont think those are the reports your looking for.


Image
Bliss-Box- a usb adapter for all controllers

Compatibility List


Top
 Profile  
 
Search for:
Display posts from previous:  Sort by  
Home Page Home Page  [ 8 posts ] 

All times are UTC - 5 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum
Jump to:  
suspicion-preferred