当前位置: 首页>>代码示例>>C++>>正文


C++ Transfer::data方法代码示例

本文整理汇总了C++中Transfer::data方法的典型用法代码示例。如果您正苦于以下问题:C++ Transfer::data方法的具体用法?C++ Transfer::data怎么用?C++ Transfer::data使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Transfer的用法示例。


在下文中一共展示了Transfer::data方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: shiftPressed

void TraktorF1MK2::processButtons(const Transfer& input_)
{
  bool shiftPressed(isButtonPressed(input_, Button::Shift));
  Device::Button changedButton(Device::Button::Unknown);
  bool buttonPressed(false);

  for (int i = 0; i < kF1MK2_buttonsDataSize - 1; i++) // Skip the last byte (encoder value)
  {
    for (int k = 0; k < 8; k++)
    {
      uint8_t btn = (i * 8) + k;
      Button currentButton(static_cast<Button>(btn));
      if (currentButton == Button::Shift)
      {
        continue;
      }
      buttonPressed = isButtonPressed(input_, currentButton);
      if (buttonPressed != m_buttonStates[btn])
      {
        m_buttonStates[btn] = buttonPressed;
        changedButton = deviceButton(currentButton);
        if (changedButton != Device::Button::Unknown)
        {
          if (currentButton >= Button::Pad8 && currentButton <= Button::Pad9)
          {
            keyChanged(btn, buttonPressed ? 1.0 : 0.0, shiftPressed);
          }
          else
          {
            buttonChanged(changedButton, buttonPressed, shiftPressed);
          }
        }
      }
    }
  }

  // encoder
  uint8_t currentValue = input_.data()[kF1MK2_buttonsDataSize];
  if (currentValue != m_encoderValue)
  {
    bool valueIncreased = ((static_cast<uint8_t>(m_encoderValue) < currentValue)
                            || ((m_encoderValue == 0xff) && (currentValue == 0x00)))
                          && (!((m_encoderValue == 0x0) && (currentValue == 0xff)));
    m_encoderValue = currentValue;
    encoderChanged(0, valueIncreased, shiftPressed);
  }

  // pots/faders
  for (uint8_t potIndex = 0, i = kF1MK2_buttonsDataSize + 1; potIndex < 8; i += 2, potIndex++)
  {
    unsigned value = (input_.data()[i]) | (input_.data()[i + 1] << 8);
    if (m_potentiometersValues[potIndex] != value)
    {
      m_potentiometersValues[potIndex] = value;
      controlChanged(potIndex, value / 1024.0, shiftPressed);
    }
  }
}
开发者ID:shaduzlabs,项目名称:cabl,代码行数:58,代码来源:TraktorF1MK2.cpp

示例2: write

bool DeviceHandleLibUSB::write(const Transfer& transfer_, uint8_t endpoint_)
{
  int nBytesWritten = 0;
  if (static_cast<bool>(transfer_) == true)
  {
    int result = libusb_bulk_transfer(m_pCurrentDevice, // Device handle
      endpoint_,                                        // Endpoint
      const_cast<uint8_t*>(transfer_.data().data()),    // Data pointer
      transfer_.size(),                                 // Size of data
      &nBytesWritten,                                   // N. of bytes actually written
      kLibUSBWriteTimeout                               // Timeout
      );
    if ((LIBUSB_SUCCESS != result) || (nBytesWritten != transfer_.size()))
    {
      M_LOG(
        "[DeviceHandleLibUSB] write: error=" << result << " - transfer size: " << transfer_.size()
                                             << " written: "
                                             << nBytesWritten);
      return false;
    }
    return true;
  }

  return false;
}
开发者ID:shaduzlabs,项目名称:cabl,代码行数:25,代码来源:DeviceHandleLibUSB.cpp

示例3: write

bool DeviceHandleHIDAPI::write(const Transfer& transfer_, uint8_t)
{
  if (transfer_)
  {
    int nBytesWritten = hid_write(m_pCurrentDevice, transfer_.data().data(), transfer_.size());
    return (nBytesWritten >= static_cast<int>(transfer_.size()));
  }

  return false;
}
开发者ID:shaduzlabs,项目名称:cabl,代码行数:10,代码来源:DeviceHandleHIDAPI.cpp

示例4: cancel

 bool Stream::cancel ( Transfer& transfer )
 {
     const ::BOOL result = ::CancelIoEx(handle(), &transfer.data());
     if (result == FALSE)
     {
         const ::DWORD error = ::GetLastError();
         if (error == ERROR_NOT_FOUND) {
             return (false);
         }
         UNCHECKED_WIN32C_ERROR(CancelIoEx, error);
     }
     return (true);
 }
开发者ID:AndreLouisCaron,项目名称:w32,代码行数:13,代码来源:Stream.cpp

示例5: finish

 dword Stream::finish ( Transfer& transfer )
 {
     dword xferred = 0;
     const ::BOOL result = ::GetOverlappedResult
         (handle(), &transfer.data(), &xferred, TRUE);
     if (result == FALSE)
     {
         const ::DWORD error = ::GetLastError();
         if (result == ERROR_NOT_FOUND) {
             return (0);
         }
         if (result == ERROR_HANDLE_EOF) {
             return (0);
         }
         UNCHECKED_WIN32C_ERROR(GetOverlappedResult, error);
     }
     return (xferred);
 }
开发者ID:AndreLouisCaron,项目名称:w32,代码行数:18,代码来源:Stream.cpp


注:本文中的Transfer::data方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。