HID icon indicating copy to clipboard operation
HID copied to clipboard

How to get game effect

Open hoantv opened this issue 5 years ago • 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?

hoantv avatar Sep 20 '19 17:09 hoantv

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?

NicoHood avatar Sep 23 '19 06:09 NicoHood

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)

hoantv avatar Sep 25 '19 05:09 hoantv

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

NicoHood avatar Sep 29 '19 14:09 NicoHood

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.

hoantv avatar Sep 29 '19 23:09 hoantv

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.

NicoHood avatar Sep 30 '19 16:09 NicoHood

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 avatar Sep 30 '19 17:09 hoantv

@NicoHood Here is my code: https://github.com/hoantv/VNWheel

hoantv avatar Oct 03 '19 16:10 hoantv

@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 avatar Oct 04 '19 08:10 EtienneGameSeed

@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.

hoantv avatar Oct 04 '19 10:10 hoantv

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...

EtienneGameSeed avatar Oct 06 '19 22:10 EtienneGameSeed

@EtienneGameSeed Here it is

https://drive.google.com/open?id=1CrJxms5pFNL6whzVFgNIWS55XVVezBFZ

hoantv avatar Oct 21 '19 02:10 hoantv

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

EtienneGameSeed avatar Oct 21 '19 07:10 EtienneGameSeed

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.

EtienneGameSeed avatar Oct 21 '19 14:10 EtienneGameSeed