void Device::ReadBulk(const EndpointPtr & ep, const IObjectOutputStreamPtr &outputStream, int timeout) { UrbPtr urb = std::make_shared<Urb>(_fd.Get(), USBDEVFS_URB_TYPE_BULK, ep); size_t transferSize = urb->GetTransferSize(); size_t r; bool continuation = false; do { urb->SetContinuationFlag(continuation); continuation = true; Submit(urb, timeout); ProcessControl(); r = urb->Recv(outputStream); } while(r == transferSize); }
void Device::WriteBulk(const EndpointPtr & ep, const IObjectInputStreamPtr &inputStream, int timeout) { UrbPtr urb = std::make_shared<Urb>(_fd.Get(), USBDEVFS_URB_TYPE_BULK, ep); size_t transferSize = urb->GetTransferSize(); size_t r; bool continuation = false; do { r = urb->Send(inputStream); urb->SetZeroPacketFlag(r != transferSize); urb->SetContinuationFlag(continuation); continuation = true; Submit(urb, timeout); ProcessControl(); } while(r == transferSize); }
void CClientPad::ProcessSetAnalogControlState ( CControllerState & cs, bool bOnFoot ) { // We forcefully apply the control state until we find that the user isnt pressing that button anymore. // When that happens, we wait for new input and then stop setting the control state and remove it. if ( bOnFoot ) { unsigned int uiIndex = 0; ProcessControl ( cs.LeftStickX, uiIndex, false ); uiIndex++; //Left ProcessControl ( cs.LeftStickX, uiIndex, true ); uiIndex++; //Right ProcessControl ( cs.LeftStickY, uiIndex, false ); uiIndex++;; //Up ProcessControl ( cs.LeftStickY, uiIndex, true ); uiIndex++; //Down } else { unsigned int uiIndex = 4; ProcessControl ( cs.LeftStickX, uiIndex, false ); uiIndex++; //Left ProcessControl ( cs.LeftStickX, uiIndex, true ); uiIndex++; //Right ProcessControl ( cs.LeftStickY, uiIndex, false ); uiIndex++;; //Up ProcessControl ( cs.LeftStickY, uiIndex, true ); uiIndex++; //Down ProcessControl ( cs.ButtonCross, uiIndex, true ); uiIndex++; //Accel ProcessControl ( cs.ButtonSquare, uiIndex, true ); uiIndex++; //Brake ProcessControl ( cs.RightStickX, uiIndex, false ); uiIndex++; //Special Left ProcessControl ( cs.RightStickX, uiIndex, true ); uiIndex++; //Special Right ProcessControl ( cs.RightStickY, uiIndex, false ); uiIndex++; //Special Up ProcessControl ( cs.RightStickY, uiIndex, true ); uiIndex++; //Special Down } }