Explorar el Código

Fix OsTouchEvent

Daniele Bartolini hace 12 años
padre
commit
7d22e5cc9a
Se han modificado 2 ficheros con 35 adiciones y 0 borrados
  1. 27 0
      engine/os/OsEventQueue.h
  2. 8 0
      engine/os/OsTypes.h

+ 27 - 0
engine/os/OsEventQueue.h

@@ -81,6 +81,33 @@ struct OsEventQueue
 		push_event(&ev);
 	}
 
+	//-----------------------------------------------------------------------------
+	void push_touch_event(uint16_t x, uint16_t y, uint8_t pointer_id)
+	{
+		OsEvent ev;
+		ev.type = OsEvent::TOUCH;
+		ev.touch.type = OsTouchEvent::MOVE;
+		ev.touch.x = x;
+		ev.touch.y = y;
+		ev.touch.pointer_id = pointer_id;
+
+		push_event(&ev);
+	}
+
+	//-----------------------------------------------------------------------------
+	void push_touch_event(uint16_t x, uint16_t y, uint8_t pointer_id, bool pressed)
+	{
+		OsEvent ev;
+		ev.type = OsEvent::TOUCH;
+		ev.touch.type = OsTouchEvent::POINTER;
+		ev.touch.x = x;
+		ev.touch.y = y;
+		ev.touch.pointer_id = pointer_id;
+		ev.touch.pressed = pressed;
+
+		push_event(&ev);
+	}
+
 	//-----------------------------------------------------------------------------
 	void push_exit_event(int32_t code)
 	{

+ 8 - 0
engine/os/OsTypes.h

@@ -73,9 +73,17 @@ struct OsKeyboardEvent
 /// Represents an event fired by touch screen.
 struct OsTouchEvent
 {
+	enum Enum
+	{
+		POINTER,
+		MOVE
+	};
+
+	OsTouchEvent::Enum type;
 	uint8_t pointer_id;
 	uint16_t x;
 	uint16_t y;
+	bool pressed;
 };
 
 /// Represents an event fired by accelerometer.