MCPcopy Create free account
hub / github.com/360Controller/360Controller / Escape

Method Escape

Feedback360/Feedback360.cpp:544–593  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

542}
543
544HRESULT Feedback360::Escape(FFEffectDownloadID downloadID, FFEFFESCAPE *escape)
545{
546 if (downloadID!=0) return FFERR_UNSUPPORTED;
547 if (escape->dwSize < sizeof(FFEFFESCAPE)) return FFERR_INVALIDPARAM;
548 escape->cbOutBuffer=0;
549 switch (escape->dwCommand) {
550 case 0x00: // Control motors
551 if(escape->cbInBuffer!=1) return FFERR_INVALIDPARAM;
552 dispatch_sync(Queue, ^{
553 Manual=((unsigned char*)escape->lpvInBuffer)[0]!=0x00;
554 });
555 break;
556
557 case 0x01: // Set motors
558 if (escape->cbInBuffer!=2) return FFERR_INVALIDPARAM;
559 dispatch_sync(Queue, ^{
560 if(Manual) {
561 unsigned char *data=(unsigned char *)escape->lpvInBuffer;
562 unsigned char buf[]={0x00,0x04,data[0],data[1]};
563 Device_Send(&this->device,buf,sizeof(buf));
564 }
565 });
566 break;
567
568 case 0x02: // Set LED
569 if (escape->cbInBuffer!=1) return FFERR_INVALIDPARAM;
570 {
571 dispatch_sync(Queue, ^{
572 unsigned char *data=(unsigned char *)escape->lpvInBuffer;
573 unsigned char buf[]={0x01,0x03,data[0]};
574 Device_Send(&this->device,buf,sizeof(buf));
575 });
576 }
577 break;
578
579 case 0x03: // Power off
580 {
581 dispatch_sync(Queue, ^{
582 unsigned char buf[] = {0x02, 0x02};
583 Device_Send(&this->device, buf, sizeof(buf));
584 });
585 }
586 break;
587
588 default:
589 fprintf(stderr, "Xbox360Controller FF plugin: Unknown escape (%i)\n", (int)escape->dwCommand);
590 return FFERR_UNSUPPORTED;
591 }
592 return FF_OK;
593}
594
595void Feedback360::SetForce(LONG LeftLevel, LONG RightLevel)
596{

Callers 1

sEscapeMethod · 0.45

Calls 1

Device_SendFunction · 0.85

Tested by

no test coverage detected