本文整理汇总了C++中HIDDevice::Open方法的典型用法代码示例。如果您正苦于以下问题:C++ HIDDevice::Open方法的具体用法?C++ HIDDevice::Open怎么用?C++ HIDDevice::Open使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HIDDevice
的用法示例。
在下文中一共展示了HIDDevice::Open方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: AddDevices
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 );
}
}
示例3: 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;
}
示例4: main
int main(int argc, char **argv)
{
int rc;
FirmwareImage image;
int opt;
int index;
char *deviceName = NULL;
const char *firmwareName = NULL;
bool force = false;
static struct option long_options[] = {
{"help", 0, NULL, 'h'},
{"force", 0, NULL, 'f'},
{"device", 1, NULL, 'd'},
{"fw-props", 0, NULL, 'p'},
{"config-id", 0, NULL, 'c'},
{"lockdown", 0, NULL, 'l'},
{"version", 0, NULL, 'v'},
{"device-type", 1, NULL, 't'},
{0, 0, 0, 0},
};
bool printFirmwareProps = false;
bool printConfigid = false;
bool performLockdown = false;
HIDDevice device;
enum RMIDeviceType deviceType = RMI_DEVICE_TYPE_ANY;
while ((opt = getopt_long(argc, argv, RMI4UPDATE_GETOPTS, long_options, &index)) != -1) {
switch (opt) {
case 'h':
printHelp(argv[0]);
return 0;
case 'f':
force = true;
break;
case 'd':
deviceName = optarg;
break;
case 'p':
printFirmwareProps = true;
break;
case 'c':
printFirmwareProps = true;
printConfigid = true;
break;
case 'l':
performLockdown = true;
break;
case 't':
if (!strcasecmp((const char *)optarg, "touchpad"))
deviceType = RMI_DEVICE_TYPE_TOUCHPAD;
else if (!strcasecmp((const char *)optarg, "touchscreen"))
deviceType = RMI_DEVICE_TYPE_TOUCHSCREEN;
break;
case 'v':
printVersion();
return 0;
default:
break;
}
}
if (printFirmwareProps) {
std::string props;
if (!deviceName) {
fprintf(stderr, "Specifiy which device to query\n");
return 1;
}
rc = GetFirmwareProps(deviceName, props, printConfigid);
if (rc) {
fprintf(stderr, "Failed to read properties from device: %s\n", update_err_to_string(rc));
return 1;
}
fprintf(stdout, "%s\n", props.c_str());
return 0;
}
if (optind < argc) {
firmwareName = argv[optind];
} else {
printHelp(argv[0]);
return -1;
}
rc = image.Initialize(firmwareName);
if (rc != UPDATE_SUCCESS) {
fprintf(stderr, "Failed to initialize the firmware image: %s\n", update_err_to_string(rc));
return 1;
}
if (deviceName) {
rc = device.Open(deviceName);
if (rc) {
fprintf(stderr, "%s: failed to initialize rmi device (%d): %s\n", argv[0], errno,
strerror(errno));
return 1;
}
} else {
if (!device.FindDevice(deviceType))
//.........这里部分代码省略.........