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


C++ HIDDevice类代码示例

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


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

示例1: usb_hid_free

static status_t
usb_hid_free(void *cookie)
{
	TRACE("free(%p)\n", cookie);
	mutex_lock(&sDriverLock);

	HIDDevice *device = ((ProtocolHandler *)cookie)->Device();
	if (device->IsOpen()) {
		// another handler of this device is still open so we can't free it
	} else if (device->IsRemoved()) {
		// the parent device is removed already and none of its handlers are
		// open anymore so we can free it here
		for (uint32 i = 0;; i++) {
			ProtocolHandler *handler = device->ProtocolHandlerAt(i);
			if (handler == NULL)
				break;

			gDeviceList->RemoveDevice(NULL, handler);
		}

		delete device;
	}

	mutex_unlock(&sDriverLock);
	return B_OK;
}
开发者ID:mmanley,项目名称:Antares,代码行数:26,代码来源:Driver.cpp

示例2: QueueCallback

void InputHandler_MacOSX_HID::QueueCallback( void *target, int result, void *refcon, void *sender )
{
	// The result seems useless as you can't actually return anything...
	// refcon is the Device number

	RageTimer now;
	InputHandler_MacOSX_HID *This = (InputHandler_MacOSX_HID *)target;
	IOHIDQueueInterface **queue = (IOHIDQueueInterface **)sender;
	IOHIDEventStruct event;
	AbsoluteTime zeroTime = { 0, 0 };
	HIDDevice *dev = This->m_vDevices[size_t( refcon )];
	vector<DeviceInput> vPresses;

	while( (result = CALL(queue, getNextEvent, &event, zeroTime, 0)) == kIOReturnSuccess )
	{
		if( event.longValueSize != 0 && event.longValue != NULL )
		{
			free( event.longValue );
			continue;
		}
		//LOG->Trace( "Got event with cookie %p, value %d", event.elementCookie, int(event.value) );
		dev->GetButtonPresses( vPresses, event.elementCookie, event.value, now );
	}
	FOREACH_CONST( DeviceInput, vPresses, i )
		INPUTFILTER->ButtonPressed( *i );
}
开发者ID:AratnitY,项目名称:stepmania,代码行数:26,代码来源:InputHandler_MacOSX_HID.cpp

示例3: device

/*********************************************************************
 * Outputs
 *********************************************************************/
void HIDPlugin::openOutput(quint32 output)
{
    HIDDevice* dev = device(output);
    if (dev != NULL)
        dev->openOutput();
    else
        qDebug() << name() << "has no output number:" << output;
}
开发者ID:Boudewijn26,项目名称:qlcplus,代码行数:11,代码来源:hidplugin.cpp

示例4: device

void HID::closeOutput(quint32 output)
{
    HIDDevice* dev = device(output);
    if (dev != NULL)
        dev->closeOutput();
    else
        qDebug() << name() << "has no output number:" << output;
}
开发者ID:flaviobarollo,项目名称:qlcplus,代码行数:8,代码来源:hid.cpp

示例5: GetFirmwareProps

int GetFirmwareProps(const char * deviceFile, std::string &props, bool configid)
{
	HIDDevice rmidevice;
	int rc = UPDATE_SUCCESS;
	std::stringstream ss;

	rc = rmidevice.Open(deviceFile);
	if (rc)
		return rc;

	rmidevice.ScanPDT(0x1);
	rmidevice.QueryBasicProperties();

	if (configid) {
		ss << std::hex << rmidevice.GetConfigID();
	} else {
		ss << rmidevice.GetFirmwareVersionMajor() << "."
			<< rmidevice.GetFirmwareVersionMinor() << "."
			<< std::hex << rmidevice.GetFirmwareID();

		if (rmidevice.InBootloader())
			ss << " bootloader";
	}

	props = ss.str();

	return rc;
}
开发者ID:aduggan,项目名称:rmi4utils,代码行数:28,代码来源:main.cpp

示例6: Q_UNUSED

void HID::writeUniverse(quint32 universe, quint32 output, const QByteArray &data)
{
    Q_UNUSED(universe);

    if (output != QLCIOPlugin::invalidLine())
    {
        HIDDevice* dev = device(output);
        if (dev != NULL)
            dev->outputDMX(data);
    }
}
开发者ID:flaviobarollo,项目名称:qlcplus,代码行数:11,代码来源:hid.cpp

示例7: deviceOutput

void HIDPlugin::closeOutput(quint32 output, quint32 universe)
{
    HIDDevice* dev = deviceOutput(output);
    if (dev != NULL)
    {
        removeFromMap(output, universe, Output);
        dev->closeOutput();
    }
    else
        qDebug() << name() << "has no output number:" << output;
}
开发者ID:PML369,项目名称:qlcplus,代码行数:11,代码来源:hidplugin.cpp

示例8: staticHIDReportCallback

void HIDDevice::staticHIDReportCallback(void* pContext,
                                        IOReturn result,
                                        void* pSender,
                                        IOHIDReportType reportType,
                                        uint32_t reportId,
                                        uint8_t* pReport,
                                        CFIndex reportLength)
{
    HIDDevice* pDevice = (HIDDevice*) pContext;
    return pDevice->hidReportCallback(pReport, (UInt32)reportLength);
}
开发者ID:123woodman,项目名称:minko,代码行数:11,代码来源:OVR_OSX_HIDDevice.cpp

示例9: GetMatchingDictionary

void InputHandler_MacOSX_HID::AddDevices( int usagePage, int usage, InputDevice &id )
{
	io_iterator_t iter;
	CFDictionaryRef dict = GetMatchingDictionary( usagePage, usage );
	kern_return_t ret = IOServiceAddMatchingNotification( m_NotifyPort, kIOFirstMatchNotification, dict,
						InputHandler_MacOSX_HID::DeviceAdded, this, &iter );
	io_object_t device;

	if( ret != KERN_SUCCESS )
		return;

	m_vIters.push_back( iter );

	// Iterate over the devices and add them
	while( (device = IOIteratorNext(iter)) )
	{
		LOG->Trace( "\tFound device %d", id );
		HIDDevice *dev = MakeDevice( id );
		int num;

		if( !dev )
		{
			LOG->Trace( "\t\tInvalid id, deleting device" );
			IOObjectRelease( device );
			continue;
		}

		if( !dev->Open(device) || (num = dev->AssignIDs(id)) == -1 )
		{
			LOG->Trace( "\tFailed top open or assign id, deleting device" );
			delete dev;
			IOObjectRelease( device );
			continue;
		}
		io_iterator_t i;

		enum_add( id, num );
		m_vDevices.push_back( dev );

		ret = IOServiceAddInterestNotification(
			m_NotifyPort, device, kIOGeneralInterest,
			InputHandler_MacOSX_HID::DeviceChanged,
			this, &i
		);

		if( ret == KERN_SUCCESS )
			m_vIters.push_back( i );
		else
			LOG->Trace( "\t\tFailed to add device changed notification, deleting device" );
		IOObjectRelease( device );
	}
}
开发者ID:AratnitY,项目名称:stepmania,代码行数:52,代码来源:InputHandler_MacOSX_HID.cpp

示例10: it

HIDDevice* HID::device(const QString& path)
{
    QListIterator <HIDDevice*> it(m_devices);

    while (it.hasNext() == true)
    {
        HIDDevice* dev = it.next();
        if (dev->path() == path)
            return dev;
    }

    return NULL;
}
开发者ID:flaviobarollo,项目名称:qlcplus,代码行数:13,代码来源:hid.cpp

示例11: device

void HIDPlugin::closeInput(quint32 input, quint32 universe)
{
    HIDDevice* dev = device(input);
    if (dev != NULL)
    {
        removeFromMap(input, universe, Input);
        dev->closeInput();
        disconnect(dev, SIGNAL(valueChanged(quint32,quint32,quint32,uchar)),
                   this, SIGNAL(valueChanged(quint32,quint32,quint32,uchar)));
    }
    else
        qDebug() << name() << "has no input number:" << input;
}
开发者ID:PML369,项目名称:qlcplus,代码行数:13,代码来源:hidplugin.cpp

示例12: new

void
JoystickProtocolHandler::AddHandlers(HIDDevice &device,
	HIDCollection &collection, ProtocolHandler *&handlerList)
{
	if (collection.UsagePage() != B_HID_USAGE_PAGE_GENERIC_DESKTOP
		|| (collection.UsageID() != B_HID_UID_GD_JOYSTICK
			&& collection.UsageID() != B_HID_UID_GD_GAMEPAD
			&& collection.UsageID() != B_HID_UID_GD_MULTIAXIS)) {
		TRACE("collection not a joystick or gamepad\n");
		return;
	}

	HIDParser &parser = device.Parser();
	uint32 maxReportCount = parser.CountReports(HID_REPORT_TYPE_INPUT);
	if (maxReportCount == 0)
		return;

	uint32 inputReportCount = 0;
	HIDReport *inputReports[maxReportCount];
	collection.BuildReportList(HID_REPORT_TYPE_INPUT, inputReports,
		inputReportCount);

	for (uint32 i = 0; i < inputReportCount; i++) {
		HIDReport *inputReport = inputReports[i];

		// try to find at least one axis
		bool foundAxis = false;
		for (uint32 j = 0; j < inputReport->CountItems(); j++) {
			HIDReportItem *item = inputReport->ItemAt(j);
			if (item == NULL || !item->HasData())
				continue;

			if (item->UsagePage() != B_HID_USAGE_PAGE_GENERIC_DESKTOP)
				continue;

			if (item->UsageID() >= B_HID_UID_GD_X
				&& item->UsageID() <= B_HID_UID_GD_RZ) {
				foundAxis = true;
				break;
			}
		}

		if (!foundAxis)
			continue;

		ProtocolHandler *newHandler
			= new(std::nothrow) JoystickProtocolHandler(*inputReport);
		if (newHandler == NULL) {
			TRACE("failed to allocated joystick protocol handler\n");
			continue;
		}

		newHandler->SetNextHandler(handlerList);
		handlerList = newHandler;
	}
}
开发者ID:AmirAbrams,项目名称:haiku,代码行数:56,代码来源:JoystickProtocolHandler.cpp

示例13: RunF54Test

int RunF54Test(const char * deviceFile, f54_report_types reportType, bool continuousMode, bool noReset)
{
	int rc;
	HIDDevice rmidevice;
	Display * display;

	if (continuousMode)
	{
		display = new AnsiConsole();
	}
	else
	{
		display = new Display();
	}

	display->Clear();

	rc = rmidevice.Open(deviceFile);
	if (rc)
		return rc;

	F54Test f54Test(rmidevice, *display);

	rc = f54Test.Prepare(reportType);
	if (rc)
		return rc;

	stopRequested = false;

	do {
		rc = f54Test.Run();
	}
	while (continuousMode && !stopRequested);

	if (!noReset)
		rmidevice.Reset();

	rmidevice.Close();

	delete display;

	return rc;
}
开发者ID:adlr,项目名称:rmi4utils,代码行数:43,代码来源:main.cpp

示例14: refreshList

void ConfigureHID::refreshList()
{
    QString s;

    m_list->clear();

    for (int i = 0; i < m_plugin->m_devices.count(); i++)
    {
        HIDDevice* dev;
        QTreeWidgetItem* item;

        dev = m_plugin->device(i);
        Q_ASSERT(dev != NULL);

        item = new QTreeWidgetItem(m_list);
        item->setText(KColumnNumber, s.setNum(i + 1));
        item->setText(KColumnName, dev->name());
        item->setFlags(item->flags() | Qt::ItemIsUserCheckable);
    }
    m_list->header()->resizeSections(QHeaderView::ResizeToContents);
}
开发者ID:PML369,项目名称:qlcplus,代码行数:21,代码来源:configurehid.cpp

示例15: usb_hid_free

static status_t
usb_hid_free(void *_cookie)
{
	device_cookie *cookie = (device_cookie *)_cookie;
	TRACE("free(%p)\n", cookie);

	mutex_lock(&sDriverLock);

	HIDDevice *device = cookie->handler->Device();
	if (device->IsOpen()) {
		// another handler of this device is still open so we can't free it
	} else if (device->IsRemoved()) {
		// the parent device is removed already and none of its handlers are
		// open anymore so we can free it here
		delete device;
	}

	mutex_unlock(&sDriverLock);

	delete cookie;
	return B_OK;
}
开发者ID:AmirAbrams,项目名称:haiku,代码行数:22,代码来源:Driver.cpp


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