本文整理汇总了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;
}
示例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 );
}
示例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;
}
示例4: device
void HID::closeOutput(quint32 output)
{
HIDDevice* dev = device(output);
if (dev != NULL)
dev->closeOutput();
else
qDebug() << name() << "has no output number:" << output;
}
示例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;
}
示例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);
}
}
示例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;
}
示例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);
}
示例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 );
}
}
示例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;
}
示例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;
}
示例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;
}
}
示例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;
}
示例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);
}
示例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;
}