X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FInput%2FFGLinuxEventInput.cxx;h=39702cfc75998bfd91c60f100152bd9099252e5f;hb=5151f7f5e0ba7c7e6688bdfbc4cea365196e1ed3;hp=deff1b88fde701fb2241ee807d39f2447e7fff7a;hpb=3eff9a14c992a3ae29ce021040bf6a5e560a3ff1;p=flightgear.git diff --git a/src/Input/FGLinuxEventInput.cxx b/src/Input/FGLinuxEventInput.cxx index deff1b88f..39702cfc7 100644 --- a/src/Input/FGLinuxEventInput.cxx +++ b/src/Input/FGLinuxEventInput.cxx @@ -23,11 +23,15 @@ #endif #include +#include #include #include #include "FGLinuxEventInput.hxx" -#include +extern "C" { + #include +} + #include #include #include @@ -42,7 +46,7 @@ struct TypeCode { return (unsigned long)type << 16 | (unsigned long)code; } - bool operator < ( const TypeCode other) const { + bool operator < ( const TypeCode & other) const { return hashCode() < other.hashCode(); } }; @@ -410,9 +414,18 @@ void FGLinuxInputDevice::Send( const char * eventName, double value ) evt.value = (long)value; evt.time.tv_sec = 0; evt.time.tv_usec = 0; - write( fd, &evt, sizeof(evt) ); - SG_LOG( SG_INPUT, SG_DEBUG, "Written event " << eventName - << " as type=" << evt.type << ", code=" << evt.code << " value=" << evt.value ); + size_t bytes_written = write(fd, &evt, sizeof(evt)); + + if( bytes_written == sizeof(evt) ) + SG_LOG( SG_INPUT, + SG_DEBUG, + "Written event " << eventName << " as type=" << evt.type + << ", code=" << evt.code + << " value=" << evt.value ); + else + SG_LOG( SG_INPUT, + SG_WARN, + "Failed to write event: written = " << bytes_written ); } static char ugly_buffer[128]; @@ -436,7 +449,7 @@ const char * FGLinuxInputDevice::TranslateEventName( FGEventData & eventData ) return EVENT_NAME_BY_TYPE[typeCode]; } -void FGLinuxInputDevice::SetDevname( std::string name ) +void FGLinuxInputDevice::SetDevname( const std::string & name ) { this->devname = name; }