Fix compiler warnings
This commit is contained in:
parent
b561cc8fac
commit
9b20c08db3
3 changed files with 55 additions and 55 deletions
|
@ -66,7 +66,7 @@ private:
|
|||
};
|
||||
|
||||
std::vector<ServerInfo> m_servers;
|
||||
int m_currentIndex = 0;
|
||||
unsigned int m_currentIndex = 0;
|
||||
};
|
||||
|
||||
#endif // MPSERVERSMODEL_H
|
||||
|
|
|
@ -160,7 +160,7 @@ namespace HID
|
|||
case AD_AlphanumericDisplay: return "alphanumeric";
|
||||
case AD_CharacterReport: return "character-report";
|
||||
case AD_DisplayData: return "display-data";
|
||||
case AD_DisplayBrightness: return "display-brightness";
|
||||
case AD_DisplayBrightness: return "display-brightness";
|
||||
case AD_7SegmentDirectMap: return "seven-segment-direct";
|
||||
case AD_14SegmentDirectMap: return "fourteen-segment-direct";
|
||||
|
||||
|
@ -244,7 +244,7 @@ public:
|
|||
bool Open() override;
|
||||
void Close() override;
|
||||
void Configure(SGPropertyNode_ptr node) override;
|
||||
|
||||
|
||||
void update(double dt) override;
|
||||
const char *TranslateEventName(FGEventData &eventData) override;
|
||||
void Send( const char * eventName, double value ) override;
|
||||
|
@ -307,21 +307,21 @@ private:
|
|||
int maybeSignExtend(Item* item, int inValue);
|
||||
|
||||
void defineReport(SGPropertyNode_ptr reportNode);
|
||||
|
||||
|
||||
std::vector<Report*> _reports;
|
||||
std::string _hidPath;
|
||||
hid_device* _device = nullptr;
|
||||
bool _haveNumberedReports = false;
|
||||
bool _debugRaw = false;
|
||||
|
||||
|
||||
/// set if we parsed the device description our XML
|
||||
/// instead of from the USB data. Useful on Windows where the data
|
||||
/// is inaccessible, or devices with broken descriptors
|
||||
bool _haveLocalDescriptor = false;
|
||||
|
||||
|
||||
/// allow specifying the descriptor as hex bytes in XML
|
||||
std::vector<uint8_t>_rawXMLDescriptor;
|
||||
|
||||
|
||||
// all sets which will be send on the next update() call.
|
||||
std::set<Report*> _dirtyReports;
|
||||
};
|
||||
|
@ -347,7 +347,7 @@ FGHIDDevice::FGHIDDevice(hid_device_info *devInfo, FGHIDEventInput *)
|
|||
std::wstring manufacturerName, productName;
|
||||
productName = devInfo->product_string ? std::wstring(devInfo->product_string)
|
||||
: L"unknown HID device";
|
||||
|
||||
|
||||
if (devInfo->manufacturer_string) {
|
||||
manufacturerName = std::wstring(devInfo->manufacturer_string);
|
||||
SetName(simgear::strutils::convertWStringToUtf8(manufacturerName) + " " +
|
||||
|
@ -377,25 +377,25 @@ void FGHIDDevice::Configure(SGPropertyNode_ptr node)
|
|||
{
|
||||
// base class first
|
||||
FGInputDevice::Configure(node);
|
||||
|
||||
|
||||
if (node->hasChild("hid-descriptor")) {
|
||||
_haveLocalDescriptor = true;
|
||||
if (debugEvents) {
|
||||
SG_LOG(SG_INPUT, SG_INFO, GetUniqueName() << " will configure using local HID descriptor");
|
||||
}
|
||||
|
||||
|
||||
for (auto report : node->getChild("hid-descriptor")->getChildren("report")) {
|
||||
defineReport(report);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (node->hasChild("hid-raw-descriptor")) {
|
||||
_rawXMLDescriptor = simgear::strutils::decodeHex(node->getStringValue("hid-raw-descriptor"));
|
||||
if (debugEvents) {
|
||||
SG_LOG(SG_INPUT, SG_INFO, GetUniqueName() << " will configure using XML-defined raw HID descriptor");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (node->getBoolValue("hid-debug-raw")) {
|
||||
_debugRaw = true;
|
||||
}
|
||||
|
@ -418,17 +418,17 @@ bool FGHIDDevice::Open()
|
|||
SG_LOG(SG_INPUT, SG_WARN, "HID: " << GetUniqueName() << " failed to read HID descriptor");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
_rawXMLDescriptor.resize(descriptorSize);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
if (!_haveLocalDescriptor) {
|
||||
bool ok = parseUSBHIDDescriptor();
|
||||
if (!ok)
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
for (auto& v : handledEvents) {
|
||||
auto reportItem = itemWithName(v.first);
|
||||
if (!reportItem.second) {
|
||||
|
@ -440,13 +440,13 @@ bool FGHIDDevice::Open()
|
|||
if (debugEvents) {
|
||||
SG_LOG(SG_INPUT, SG_INFO, "\tfound item for event:" << v.first);
|
||||
}
|
||||
|
||||
|
||||
reportItem.second->event = event;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool FGHIDDevice::parseUSBHIDDescriptor()
|
||||
{
|
||||
#if defined(SG_WINDOWS)
|
||||
|
@ -457,12 +457,12 @@ bool FGHIDDevice::parseUSBHIDDescriptor()
|
|||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
if (_debugRaw) {
|
||||
SG_LOG(SG_INPUT, SG_INFO, "\nHID: descriptor for:" << GetUniqueName());
|
||||
{
|
||||
std::ostringstream byteString;
|
||||
|
||||
|
||||
for (auto i=0; i<_rawXMLDescriptor.size(); ++i) {
|
||||
byteString << hexTable[_rawXMLDescriptor[i] >> 4];
|
||||
byteString << hexTable[_rawXMLDescriptor[i] & 0x0f];
|
||||
|
@ -471,15 +471,15 @@ bool FGHIDDevice::parseUSBHIDDescriptor()
|
|||
SG_LOG(SG_INPUT, SG_INFO, "\tbytes: " << byteString.str());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
hid_item* rootItem = nullptr;
|
||||
hid_parse_reportdesc(_rawXMLDescriptor.data(), _rawXMLDescriptor.size(), &rootItem);
|
||||
if (debugEvents) {
|
||||
SG_LOG(SG_INPUT, SG_INFO, "\nHID: scan for:" << GetUniqueName());
|
||||
}
|
||||
|
||||
|
||||
parseCollection(rootItem);
|
||||
|
||||
|
||||
hid_free_reportdesc(rootItem);
|
||||
return true;
|
||||
}
|
||||
|
@ -669,7 +669,7 @@ void FGHIDDevice::sendReport(Report* report) const
|
|||
}
|
||||
|
||||
reportLength /= 8;
|
||||
|
||||
|
||||
if (_debugRaw) {
|
||||
std::ostringstream byteString;
|
||||
for (size_t i=0; i<reportLength; ++i) {
|
||||
|
@ -679,7 +679,7 @@ void FGHIDDevice::sendReport(Report* report) const
|
|||
}
|
||||
SG_LOG(SG_INPUT, SG_INFO, "sending bytes: " << byteString.str());
|
||||
}
|
||||
|
||||
|
||||
|
||||
// send the data, based on the report type
|
||||
if (report->type == HID::ReportType::Feature) {
|
||||
|
@ -748,13 +748,13 @@ void FGHIDDevice::SendFeatureReport(unsigned int reportId, const std::string& da
|
|||
if (!_device) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (_debugRaw) {
|
||||
SG_LOG(SG_INPUT, SG_INFO, GetName() << ": FGHIDDevice: Sending feature report:" << (int) reportId << ", len=" << data.size());
|
||||
{
|
||||
std::ostringstream byteString;
|
||||
|
||||
for (int i=0; i<data.size(); ++i) {
|
||||
|
||||
for (unsigned int i=0; i<data.size(); ++i) {
|
||||
byteString << hexTable[data[i] >> 4];
|
||||
byteString << hexTable[data[i] & 0x0f];
|
||||
byteString << " ";
|
||||
|
@ -797,7 +797,7 @@ void FGHIDDevice::Send(const char *eventName, double value)
|
|||
item.second->lastValue = intValue;
|
||||
_dirtyReports.insert(item.first);
|
||||
}
|
||||
|
||||
|
||||
void FGHIDDevice::defineReport(SGPropertyNode_ptr reportNode)
|
||||
{
|
||||
const int nChildren = reportNode->nChildren();
|
||||
|
@ -824,21 +824,21 @@ void FGHIDDevice::defineReport(SGPropertyNode_ptr reportNode)
|
|||
bitCount += size;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
if (!strcmp(nd->getName(), "type") || !strcmp(nd->getName(), "id")) {
|
||||
continue; // already handled above
|
||||
}
|
||||
|
||||
|
||||
// allow repeating items
|
||||
uint8_t count = nd->getIntValue("count", 1);
|
||||
std::string name = nd->getNameString();
|
||||
const auto lastHypen = name.rfind("-");
|
||||
std::string baseName = name.substr(0, lastHypen + 1);
|
||||
int baseIndex = std::stoi(name.substr(lastHypen + 1));
|
||||
|
||||
|
||||
const bool isRelative = (name.find("rel-") == 0);
|
||||
const bool isSigned = nd->getBoolValue("is-signed", false);
|
||||
|
||||
|
||||
for (uint8_t i=0; i < count; ++i) {
|
||||
std::ostringstream oss;
|
||||
oss << baseName << (baseIndex + i);
|
||||
|
@ -962,7 +962,7 @@ SGSubsystemMgr::Registrant<FGHIDEventInput> registrantFGHIDEventInput;
|
|||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void FGHIDEventInput::FGHIDEventInputPrivate::evaluateDevice(hid_device_info* deviceInfo)
|
||||
{
|
||||
{
|
||||
// allocate an input device, and add to the base class to see if we have
|
||||
// a config
|
||||
p->AddDevice(new FGHIDDevice(deviceInfo, p));
|
||||
|
|
|
@ -1251,12 +1251,12 @@ NavDataCache::NavDataCache()
|
|||
}
|
||||
}
|
||||
} // of retry loop
|
||||
|
||||
|
||||
double RADIUS_EARTH_M = 7000 * 1000.0; // 7000km is plenty
|
||||
SGVec3d earthExtent(RADIUS_EARTH_M, RADIUS_EARTH_M, RADIUS_EARTH_M);
|
||||
Octree::global_spatialOctree =
|
||||
new Octree::Branch(SGBox<double>(-earthExtent, earthExtent), 1);
|
||||
|
||||
|
||||
// Update d->aptDatFilesInfo, d->metarDatPath, d->navDatPath, etc.
|
||||
updateListsOfDatFiles();
|
||||
}
|
||||
|
@ -2038,7 +2038,7 @@ char** NavDataCache::searchAirportNamesAndIdents(const std::string& searchInput)
|
|||
string heliport("HELIPORT");
|
||||
bool heli_p = searchInput.substr(0, heliport.length()) == heliport;
|
||||
auto pos = searchInput.find(":");
|
||||
string aFilter((pos != string::npos) ? searchInput.substr(pos+1) : searchInput);
|
||||
string aFilter((pos != string::npos) ? searchInput.substr(pos+1) : searchInput);
|
||||
string searchTerm("%" + aFilter + "%");
|
||||
|
||||
if (aFilter.empty() && !heli_p) {
|
||||
|
@ -2315,24 +2315,24 @@ AirwayEdgeVec NavDataCache::airwayEdgesFrom(int network, PositionedID pos)
|
|||
}
|
||||
|
||||
d->reset(d->airwayEdgesFrom);
|
||||
|
||||
|
||||
// find bidirectional / backwsards edges
|
||||
// at present all edges are bidirectional
|
||||
sqlite3_bind_int(d->airwayEdgesTo, 1, network);
|
||||
sqlite3_bind_int64(d->airwayEdgesTo, 2, pos);
|
||||
|
||||
|
||||
while (d->stepSelect(d->airwayEdgesTo)) {
|
||||
result.push_back(AirwayEdge(
|
||||
sqlite3_column_int(d->airwayEdgesTo, 0),
|
||||
sqlite3_column_int64(d->airwayEdgesTo, 1)
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
d->reset(d->airwayEdgesTo);
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
AirwayRef NavDataCache::loadAirway(int airwayID)
|
||||
{
|
||||
sqlite3_bind_int(d->loadAirway, 1, airwayID);
|
||||
|
@ -2371,7 +2371,7 @@ PositionedIDVec NavDataCache::airwayWaypts(int id)
|
|||
|
||||
// linearize
|
||||
PositionedIDVec result;
|
||||
|
||||
|
||||
while (!rawEdges.empty()) {
|
||||
bool didAddEdge = false;
|
||||
std::set<PositionedID> seen;
|
||||
|
@ -2379,31 +2379,31 @@ PositionedIDVec NavDataCache::airwayWaypts(int id)
|
|||
PositionedIDDeque linearAirway;
|
||||
PositionedID firstId = rawEdges.front().first,
|
||||
lastId = rawEdges.front().second;
|
||||
|
||||
|
||||
// first edge is trivial
|
||||
linearAirway.push_back(firstId);
|
||||
linearAirway.push_back(lastId);
|
||||
seen.insert(firstId);
|
||||
seen.insert(lastId);
|
||||
rawEdges.pop_front();
|
||||
|
||||
|
||||
while (!rawEdges.empty()) {
|
||||
Edge e = rawEdges.front();
|
||||
rawEdges.pop_front();
|
||||
|
||||
|
||||
bool seenFirst = (seen.find(e.first) != seen.end());
|
||||
bool seenSecond = (seen.find(e.second) != seen.end());
|
||||
|
||||
|
||||
// duplicated segment, should be impossible
|
||||
assert(!(seenFirst && seenSecond));
|
||||
|
||||
|
||||
if (!seenFirst && !seenSecond) {
|
||||
// push back to try later on
|
||||
nextDeque.push_back(e);
|
||||
if (rawEdges.empty()) {
|
||||
rawEdges = nextDeque;
|
||||
nextDeque.clear();
|
||||
|
||||
|
||||
if (!didAddEdge) {
|
||||
// we have a disjoint, need to start a new section
|
||||
// break out of the inner while loop so the outer
|
||||
|
@ -2412,10 +2412,10 @@ PositionedIDVec NavDataCache::airwayWaypts(int id)
|
|||
}
|
||||
didAddEdge = false;
|
||||
}
|
||||
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
// we have an exterior edge, grow our current linear piece
|
||||
if (seenFirst && (e.first == firstId)) {
|
||||
linearAirway.push_front(e.second);
|
||||
|
@ -2435,20 +2435,20 @@ PositionedIDVec NavDataCache::airwayWaypts(int id)
|
|||
seen.insert(e.first);
|
||||
}
|
||||
didAddEdge = true;
|
||||
|
||||
|
||||
if (rawEdges.empty()) {
|
||||
rawEdges = nextDeque;
|
||||
nextDeque.clear();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!result.empty())
|
||||
result.push_back(0);
|
||||
result.insert(result.end(), linearAirway.begin(), linearAirway.end());
|
||||
} // outer loop
|
||||
|
||||
|
||||
SG_LOG(SG_AUTOPILOT, SG_WARN, "Airway:" << id);
|
||||
for (int i=0; i<result.size(); ++i) {
|
||||
for (unsigned int i=0; i<result.size(); ++i) {
|
||||
if (result.at(i) == 0) {
|
||||
SG_LOG(SG_AUTOPILOT, SG_WARN, i << " <break>");
|
||||
} else {
|
||||
|
@ -2456,7 +2456,7 @@ PositionedIDVec NavDataCache::airwayWaypts(int id)
|
|||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue