NicoHood/HID

How to get game effect

Opened this issue · 13 comments

I add more PDI descriptor to hdi discriptor game pad and using new pdi descriptor.
The gamepad work well. But how to send request to get effect using the HDI library?

I dont know what you are using/adding. I guess you have to do the magic and write some additional code on your own. What is the PDI descriptor used for?

I used PID descriptor in pid1_01.pdf. PC recongized it as ffb device.
Now I try to add receiveReport(id,data,len).
In sendReport(id, data, len) id is Hidreportgamepad, so maybe id in receiveReport is effect report.

In HID.cpp add:

  1. hidInterface
    D_ENDPOINT(USB_ENDPOINT_OUT(pluggedEndpoint), USB_ENDPOINT_TYPE_INTERRUPT, USB_EP_SIZE, 0x01) // add USB_ENDPOINT_OUT
  2. add 2 function
    uint8_t HID_::ReportAvailable(uint8_t id)
    {
    return(USB_Available(id));
    }

int HID_::ReceiveReport(uint8_t id, void* data, int len);
{
return(USB_Recv(id,data,len));
}

Now in gamepad.cpp i call
HID().ReportAVailable(reportid)
HID().ReceiveReport(reportid,hiddescriptorreport, reportlen)

Nice! Would you mind opening a PR with the FB support? I guess a lot of people would profit by this.

Atm i havent’t yet received effect report, my adruino has a problem, only upload the samples code. When i uploaded my code, it is too hot and pc doest recognize :( although i still uploaded before, maybe need new one)
. I saw many funcion in HId::settup but I don’t know which HID:: setup mean (dont see where it is called).
I did like this:

  • Add Rx_enpont = plugableusb+1
  • add interface for rx
  • add interupt out for rx.
  • add function availabe check rx>0
  • add get data for rx
  • main program:
    • check avalable rx
    • read first byte check request
    • Depend on requests i receive, i send reponse to pc.

Sure, but it would be easier to see your changes if you open a PR or at least share the modified files via file upload with us.

Sorry, i dont know PR mean.
Here are my changes
In HID.h add
#define HID_REPORT_TYPE_FEATURE 3
#define HID_ENPOINT_COUNT 2 //add
#define HID_ENDPOINT_IN (pluggedEndpoint) //add
#define HID_ENDPOINT_OUT (pluggedEndpoint+1) //add

EndpointDescriptor in;
EndpointDescriptor out; //add

void AppendDescriptor(HIDSubDescriptor* node);
int RecvReport(void* data, int len);; //add
uint8_t AvailableReport();; //add

int SendControl(uint8_t flags, const void* d, int len);; //add
int RecvControl(void* d, int len);; //add
int RecvControlLong(void* d, int len);; //add

uint8_t epType[HID_ENPOINT_COUNT]; //modify from 1 to 2
In HID.ccp

D_ENDPOINT(USB_ENDPOINT_IN(HID_ENDPOINT_IN), USB_ENDPOINT_TYPE_INTERRUPT, USB_EP_SIZE, 0x01),
D_ENDPOINT(USB_ENDPOINT_OUT(HID_ENDPOINT_OUT), USB_ENDPOINT_TYPE_INTERRUPT, USB_EP_SIZE, 0x01) //add
// add
int HID_::RecvReport(void* data, int len) {
return USB_Recv(HID_ENDPOINT_OUT, &data, len);
}
// add
uint8_t HID_::AvailableReport() {
return USB_Available(HID_ENDPOINT_OUT);
}

int HID_::SendControl(uint8_t flags, const void* d, int len){
//not yet finish
}
int HID_::RecvControl(void* d, int len){
//not yet finish
}
int HID_::RecvControlLong(void* d, int len){
//not yet finish
}

HID_::HID_(void) : PluggableUSBModule(2, 1, epType), //modify 1 to 2

epType[0] = EP_TYPE_INTERRUPT_IN;
epType[1] = EP_TYPE_INTERRUPT_OUT;//add
Wheel.cpp: joystick + Pid descriptor report. some function to set value of report.
In ffbWheel:
if Wheel.available > 0 . read 1st byte. check wValueL, wValueH. depend on wValueL, wValueH, i will send data to pc (this not yes finish)

Yesterday, i made it receive data and 1st byte = 3 and many data follows , After I changed some thing (add ffb funtion) i can't receive anymore. Many change so i can not rollback code :(! Now when check Wheel.availableReport, it alway =0.

Due to mycomputer, after restart Leonardo can read data.
Here is log i capture using FFB check
image

Btw, does leonardo support 32 bit or 24 bit for X axis or steering?

@hoantv, maybe you don't know, but you are using and publishing code I've released a few years ago, without my permission and without even explaining where it comes from. There no licence files, etc...
This is not correct !
Where did you get it ?
You can use it for personal use, but not for commercial purpose, and I don't want my code to be published by someone else.

@EtienneGameSeed: i use your HID desriptor and ffb engine. It is not commercial purpose. I found it on google code and think it is open source. If you dont agree i will remove them.

Could you please give me the link on google code ?

I've seen you cleaned up the unused code. Thanks. I don't know what you call the ffb engine, as there's no processing of the effects (The most important part of the code comes from adapt-ffb-joy project). You can keep the HID descriptor code, it's not rocket science...

It's not a google code link...
It was uploaded 1 year ago by Fernando Ígor, is that you ?

The problem is that you're not respecting original creators and licences. Open source doesn't work like that, you can't just take code that includes licences in the headers, remove them and publish it on github, which is what you did.
You removed references in the headers, as well as the non commercial creative commons licence in the main folder I published.