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


C++ IOBufferMemoryDescriptor::writeBytes方法代码示例

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


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

示例1: QueueWrite

// Queue an asynchronous write on a controller
bool WirelessGamingReceiver::QueueWrite(int index, const void *bytes, UInt32 length)
{
    IOBufferMemoryDescriptor *outBuffer;
    IOUSBCompletion complete;
    IOReturn err;
    
    outBuffer = IOBufferMemoryDescriptor::inTaskWithOptions(kernel_task, 0, length);
    if (outBuffer == NULL)
    {
//        IOLog("send - unable to allocate buffer\n");
        return false;
    }
    outBuffer->writeBytes(0, bytes, length);
    
    complete.target = this;
    complete.action = _WriteComplete;
    complete.parameter = outBuffer;
    
    err = connections[index].controllerOut->Write(outBuffer, 0, 0, length, &complete);
    if (err == kIOReturnSuccess)
        return true;
    else
    {
//        IOLog("send - failed to start (0x%.8x)\n",err);
        return false;
    }
}
开发者ID:derekvanvliet,项目名称:Xbox360ControllerManager,代码行数:28,代码来源:WirelessGamingReceiver.cpp

示例2:

// Returns the HID descriptor for this device
IOReturn Xbox360ControllerClass::newReportDescriptor(IOMemoryDescriptor **descriptor) const
{
    IOBufferMemoryDescriptor *buffer = IOBufferMemoryDescriptor::inTaskWithOptions(kernel_task,0,sizeof(HID_360::ReportDescriptor));

    if (buffer == NULL) return kIOReturnNoResources;
    buffer->writeBytes(0,HID_360::ReportDescriptor,sizeof(HID_360::ReportDescriptor));
    *descriptor=buffer;
    return kIOReturnSuccess;
}
开发者ID:BossKing10086,项目名称:360Controller,代码行数:10,代码来源:Controller.cpp

示例3: newReportDescriptor

IOReturn it_unbit_foohid_device::newReportDescriptor(IOMemoryDescriptor **descriptor) const {
    IOLog("it_unbit_foohid_device::newReportDescriptor()\n");
    IOBufferMemoryDescriptor *buffer = IOBufferMemoryDescriptor::inTaskWithOptions(kernel_task, 0, reportDescriptor_len);
    if (buffer == NULL) {
        IOLog("OOOOPS");
        return kIOReturnNoResources;
    }
    
    buffer->writeBytes(0, reportDescriptor, reportDescriptor_len);
    *descriptor = buffer;
    
    IOLog("all fine\n");
    
    return kIOReturnSuccess;
}
开发者ID:crazevil,项目名称:foohid,代码行数:15,代码来源:foohid_device.cpp

示例4: IOLog

void VoodooI2CHIDDevice::i2c_hid_get_input(OSObject* owner, IOTimerEventSource* sender) {
//    IOLog("getting input\n");
    if (hid_device->reading)
        return;

    UInt rsize;
    int ret;

    rsize = UInt16(ihid->hdesc.wMaxInputLength);
    
    unsigned char* rdesc = (unsigned char *)IOMalloc(rsize);
    
    ret = i2c_hid_command(ihid, &hid_input_cmd, rdesc, rsize);

//    IOLog("===Input (%d)===\n", rsize);
//    for (int i = 0; i < rsize; i++)
//        IOLog("0x%02x ", (UInt8) rdesc[i]);
//    IOLog("\n");

    int return_size = rdesc[0] | rdesc[1] << 8;
    if (return_size == 0) {
        /* host or device initiated RESET completed */
        // test/clear bit?
        hid_device->timerSource->setTimeoutMS(10);
        return;
    }

    if (return_size > rsize) {
        IOLog("%s: Incomplete report %d/%d\n", __func__, rsize, return_size);
    }

    IOBufferMemoryDescriptor *buffer = IOBufferMemoryDescriptor::inTaskWithOptions(kernel_task, 0, return_size);
    buffer->writeBytes(0, rdesc + 2, return_size - 2);

    IOReturn err = _wrapper->handleReport(buffer, kIOHIDReportTypeInput);
    if (err != kIOReturnSuccess)
        IOLog("Error handling report: 0x%.8x\n", err);

    buffer->release();

    IOFree(rdesc, rsize);
    
    hid_device->timerSource->setTimeoutMS(10);
}
开发者ID:nuudles,项目名称:VoodooI2C,代码行数:44,代码来源:VoodooI2CHIDDevice.cpp

示例5: IOLog

// Set up an asynchronous write
bool Xbox360Peripheral::QueueWrite(const void *bytes,UInt32 length)
{
    IOBufferMemoryDescriptor *outBuffer;
    IOUSBCompletion complete;
    IOReturn err;
    
    outBuffer=IOBufferMemoryDescriptor::inTaskWithOptions(kernel_task,0,length);
    if(outBuffer==NULL) {
        IOLog("send - unable to allocate buffer\n");
        return false;
    }
    outBuffer->writeBytes(0,bytes,length);
    complete.target=this;
    complete.action=WriteCompleteInternal;
    complete.parameter=outBuffer;
    err=outPipe->Write(outBuffer,0,0,length,&complete);
    if(err==kIOReturnSuccess) return true;
    else {
        IOLog("send - failed to start (0x%.8x)\n",err);
        return false;
    }
}
开发者ID:LeftTurnClyde,项目名称:360Controller,代码行数:23,代码来源:_60Controller.cpp

示例6: IOLog

void VoodooI2CHIDDevice::i2c_hid_get_input(OSObject* owner, IOTimerEventSource* sender) {
//    IOLog("getting input\n");
    UInt rsize;
    int ret;
    static unsigned char* rdesc_prev = NULL;
    static UInt rsize_prev = 0;
    bool new_report = true;
    
    rsize = UInt16(ihid->hdesc.wMaxInputLength);
    
    unsigned char* rdesc = (unsigned char *)IOMalloc(rsize);
    
    ret = i2c_hid_command(ihid, &hid_input_cmd, rdesc, rsize);

//    IOLog("===Input (%d)===\n", rsize);
//    for (int i = 0; i < rsize; i++)
//        IOLog("0x%02x ", (UInt8) rdesc[i]);
//    IOLog("\n");

    int return_size = rdesc[0] | rdesc[1] << 8;
    if (return_size == 0) {
        /* host or device initiated RESET completed */
        // test/clear bit?
        hid_device->timerSource->setTimeoutMS(10);
        return;
    }

    if (return_size > rsize) {
        IOLog("%s: Incomplete report %d/%d\n", __func__, rsize, return_size);
    }

    IOBufferMemoryDescriptor *buffer = IOBufferMemoryDescriptor::inTaskWithOptions(kernel_task, 0, return_size);
    buffer->writeBytes(0, rdesc + 2, return_size - 2);

#define FILTER_REPEATED_REPORTS /* Needed on my ASUS/Skylake ELAN1000 */

#ifdef FILTER_REPEATED_REPORTS
    /* Compare to previous report */
    if (rdesc_prev)
    {
        /* See if they're different! */
        if (rsize == rsize_prev)
        {
            if (memcmp(rdesc_prev, rdesc, rsize))
            {
                new_report = true;
            } else {
                new_report = false;
            }
        } else {
            new_report = true;
        }

        /* We don't need the previous report anymore */
        IOFree(rdesc_prev, rsize_prev);
    }
    else
    {
        new_report = true;
    }

    /* Keep for next comparison */
    rdesc_prev = rdesc;
    rsize_prev = rsize;

    if (new_report)
    {
        IOReturn err = _wrapper->handleReport(buffer, kIOHIDReportTypeInput);
        if (err != kIOReturnSuccess)
            IOLog("Error handling report: 0x%.8x\n", err);
    }

#else /* non filtered for repeating reports */
    IOReturn err = _wrapper->handleReport(buffer, kIOHIDReportTypeInput);
    if (err != kIOReturnSuccess)
        IOLog("Error handling report: 0x%.8x\n", err);
#endif

    buffer->release();

#ifndef FILTER_REPEATED_REPORTS
    IOFree(rdesc, rsize);
#endif

    hid_device->timerSource->setTimeoutMS(10);
}
开发者ID:maximevince,项目名称:VoodooI2CPCI,代码行数:86,代码来源:VoodooI2CHIDDevice.cpp


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