本文整理汇总了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);
}
}
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}