HID-Input disambiguation tweaks
This commit is contained in:
parent
361225f919
commit
921f29fbfe
4 changed files with 20 additions and 10 deletions
|
@ -266,6 +266,7 @@ if(EVENT_INPUT)
|
|||
endif()
|
||||
|
||||
if (ENABLE_HID_INPUT)
|
||||
message(STATUS "Enabling HID-API input")
|
||||
list(APPEND EVENT_INPUT_LIBRARIES hidapi)
|
||||
endif()
|
||||
|
||||
|
|
|
@ -369,17 +369,20 @@ unsigned FGEventInput::AddDevice( FGInputDevice * inputDevice )
|
|||
const string deviceName = inputDevice->GetName();
|
||||
SGPropertyNode_ptr configNode;
|
||||
|
||||
// if we have a serial number set, tru using that to select a specfic configuration
|
||||
if (!inputDevice->GetSerialNumber().empty()) {
|
||||
const string nameWithSerial = deviceName + "::" + inputDevice->GetSerialNumber();
|
||||
if (configMap.hasConfiguration(nameWithSerial)) {
|
||||
configNode = configMap.configurationForDeviceName(nameWithSerial);
|
||||
SG_LOG(SG_INPUT, SG_INFO, "using instance-specific configuration for device "
|
||||
<< nameWithSerial << " : " << configNode->getStringValue("source"));
|
||||
}
|
||||
}
|
||||
|
||||
// otherwise try the unmodifed name for the device
|
||||
if (configNode == nullptr) {
|
||||
if (!configMap.hasConfiguration(deviceName)) {
|
||||
SG_LOG(SG_INPUT, SG_DEBUG, "No configuration found for device " << deviceName <<
|
||||
" (with serial: " << inputDevice->GetSerialNumber() << ")");
|
||||
SG_LOG(SG_INPUT, SG_DEBUG, "No configuration found for device " << deviceName);
|
||||
delete inputDevice;
|
||||
return INVALID_DEVICE_INDEX;
|
||||
}
|
||||
|
|
|
@ -313,12 +313,22 @@ FGHIDDevice::FGHIDDevice(hid_device_info *devInfo, FGHIDEventInput *)
|
|||
productName = std::wstring(devInfo->product_string);
|
||||
const auto serial = devInfo->serial_number;
|
||||
|
||||
auto path = devInfo->path;
|
||||
|
||||
SetName(simgear::strutils::convertWStringToUtf8(manufactuerName) + " " +
|
||||
simgear::strutils::convertWStringToUtf8(productName));
|
||||
|
||||
// every device so far encountered returns a blank serial number, so we
|
||||
// fall back to the device path to disambiguate.
|
||||
std::string path(devInfo->path);
|
||||
if ((serial == nullptr) || std::wcslen(serial) == 0) {
|
||||
// use device path to disambiguate
|
||||
if (!path.empty()) {
|
||||
SG_LOG(SG_INPUT, SG_INFO, "Missing serial on device, using path: " << path);
|
||||
SetSerialNumber(path);
|
||||
}
|
||||
} else {
|
||||
SetSerialNumber(simgear::strutils::convertWStringToUtf8(serial));
|
||||
}
|
||||
}
|
||||
|
||||
FGHIDDevice::~FGHIDDevice()
|
||||
{
|
||||
|
|
|
@ -252,7 +252,7 @@ void FGMacOSXEventInputPrivate::matchedDevice(IOHIDDeviceRef device)
|
|||
std::string manufacturer = getDeviceStringProperty(device, CFSTR(kIOHIDManufacturerKey));
|
||||
std::string serial = getDeviceStringProperty(device, CFSTR(kIOHIDSerialNumberKey));
|
||||
|
||||
SG_LOG(SG_INPUT, SG_INFO, "matched device:" << productName << " from " << manufacturer);
|
||||
SG_LOG(SG_INPUT, SG_DEBUG, "MacOSX-EventInput: matched device:" << productName << "( from " << manufacturer << ")");
|
||||
|
||||
// allocate a Mac input device, and add to the base class to see if we have
|
||||
// a config
|
||||
|
@ -268,10 +268,6 @@ void FGMacOSXEventInputPrivate::removedDevice(IOHIDDeviceRef device)
|
|||
{
|
||||
std::string productName = getDeviceStringProperty(device, CFSTR(kIOHIDProductKey));
|
||||
std::string manufacturer = getDeviceStringProperty(device, CFSTR(kIOHIDManufacturerKey));
|
||||
|
||||
SG_LOG(SG_INPUT, SG_INFO, "removed device:" << productName << " from " << manufacturer);
|
||||
|
||||
|
||||
// see if we have an entry for the device
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue