Browse Source

x11: Fixed joystick read.

Branimir Karadžić 10 years ago
parent
commit
ad768598b1
1 changed files with 7 additions and 2 deletions
  1. 7 2
      examples/common/entry/entry_x11.cpp

+ 7 - 2
examples/common/entry/entry_x11.cpp

@@ -63,6 +63,11 @@ namespace entry
 
 
 	struct Joystick
 	struct Joystick
 	{
 	{
+		Joystick()
+			: m_fd(-1)
+		{
+		}
+
 		void init()
 		void init()
 		{
 		{
 			m_fd = open("/dev/input/js0", O_RDONLY | O_NONBLOCK);
 			m_fd = open("/dev/input/js0", O_RDONLY | O_NONBLOCK);
@@ -80,7 +85,7 @@ namespace entry
 
 
 		void shutdown()
 		void shutdown()
 		{
 		{
-			if (0 != m_fd)
+			if (-1 != m_fd)
 			{
 			{
 				close(m_fd);
 				close(m_fd);
 			}
 			}
@@ -99,7 +104,7 @@ namespace entry
 
 
 		bool update(EventQueue& _eventQueue)
 		bool update(EventQueue& _eventQueue)
 		{
 		{
-			if (0 == m_fd)
+			if (-1 == m_fd)
 			{
 			{
 				return false;
 				return false;
 			}
 			}