Browse Source

Fix OsTouchEvent

Daniele Bartolini 12 years ago
parent
commit
7d22e5cc9a
2 changed files with 35 additions and 0 deletions
  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);
 		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)
 	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.
 /// Represents an event fired by touch screen.
 struct OsTouchEvent
 struct OsTouchEvent
 {
 {
+	enum Enum
+	{
+		POINTER,
+		MOVE
+	};
+
+	OsTouchEvent::Enum type;
 	uint8_t pointer_id;
 	uint8_t pointer_id;
 	uint16_t x;
 	uint16_t x;
 	uint16_t y;
 	uint16_t y;
+	bool pressed;
 };
 };
 
 
 /// Represents an event fired by accelerometer.
 /// Represents an event fired by accelerometer.