]> git.mxchange.org Git - flightgear.git/blobdiff - src/Input/FGLinuxEventInput.cxx
TACAN improvements.
[flightgear.git] / src / Input / FGLinuxEventInput.cxx
index deff1b88fde701fb2241ee807d39f2447e7fff7a..39702cfc75998bfd91c60f100152bd9099252e5f 100644 (file)
 #endif
 
 #include <cstring>
+#include <cstdio>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include "FGLinuxEventInput.hxx"
 
-#include <libudev.h>
+extern "C" {
+    #include <libudev.h>
+}
+
 #include <poll.h>
 #include <linux/input.h>
 #include <fcntl.h>
@@ -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; 
 }