#include "SDL_tizenmouse.h"
#include "SDL_log.h"
+#include "SDL_tizentouch.h"
#include <sys/mman.h>
#include <fcntl.h>
SDL_LogDebug(SDL_LOG_CATEGORY_APPLICATION, "mouse down (%d x %d)",e->x,e->y);
SDL_SendMouseMotion(_this->current_glwin, 0, 0, e->x, e->y);
SDL_SendMouseButton(_this->current_glwin, 0, SDL_PRESSED, SDL_BUTTON_LEFT);
+
+ Tizen_OnTouch(_this,1,e->multi.device,ACTION_POINTER_DOWN,e->x,e->y,1.0f);
+
return ECORE_CALLBACK_PASS_ON;
}
SDL_LogDebug(SDL_LOG_CATEGORY_APPLICATION, "mouse up (%d x %d)",e->x,e->y);
SDL_SendMouseMotion(_this->current_glwin, 0, 0, e->x, e->y);
SDL_SendMouseButton(_this->current_glwin, 0, SDL_RELEASED, SDL_BUTTON_LEFT);
+
+ Tizen_OnTouch(_this,1,e->multi.device,ACTION_POINTER_UP,e->x,e->y,1.0f);
+
return ECORE_CALLBACK_PASS_ON;
}
//SDL_LogDebug(SDL_LOG_CATEGORY_APPLICATION, "mouse move (%d x %d)",e->x,e->y);
SDL_SendMouseMotion(_this->current_glwin, 0, 0, e->x, e->y);
+ Tizen_OnTouch(_this,1,e->multi.device,ACTION_POINTER_MOVE,e->x,e->y,1.0f);
+
return ECORE_CALLBACK_PASS_ON;
}
#include "../../SDL_internal.h"
+#if SDL_VIDEO_DRIVER_TIZEN
+
+#include "../SDL_sysvideo.h"
+#include "SDL_video.h"
+#include "SDL_mouse.h"
+#include "SDL_stdinc.h"
+#include "SDL_hints.h"
+#include "../../events/SDL_events_c.h"
+#include "../../core/tizen/SDL_tizen.h"
+
+#include "SDL_tizenvideo.h"
+#include "SDL_tizenevents_c.h"
+#include "SDL_tizenmouse.h"
+#include "SDL_tizentouch.h"
+
+static void Tizen_GetNormalizedCoordinates(_THIS,float x, float y,
+ float *normalized_x, float *normalized_y)
+{
+ int window_w, window_h;
+
+ SDL_GetWindowSize(_this->windows, &window_w, &window_h);
+ *normalized_x = (float)(x / window_w);
+ *normalized_y = (float)(y / window_h);
+}
+
+static volatile SDL_bool separate_mouse_and_touch = SDL_FALSE;
+
+static void
+SeparateEventsHintWatcher(void *userdata, const char *name,
+ const char *oldValue, const char *newValue)
+{
+ SDL_Unsupported();
+}
+
+void Tizen_InitTouch(void)
+{
+ /*By default,tizen only have one touch device*/
+ SDL_TouchID deviceId = 1;
+
+ SDL_AddHintCallback(SDL_HINT_ANDROID_SEPARATE_MOUSE_AND_TOUCH,
+ SeparateEventsHintWatcher, NULL);
+ if(SDL_AddTouch(deviceId, "Tizen_Touch")<0)
+ {
+ SDL_Log("error: can't add tizen touch %s, %d", __FILE__, __LINE__);
+ }
+}
+
+void Tizen_QuitTouch(void)
+{
+ SDL_DelHintCallback(SDL_HINT_ANDROID_SEPARATE_MOUSE_AND_TOUCH,
+ SeparateEventsHintWatcher, NULL);
+ separate_mouse_and_touch = SDL_FALSE;
+}
+
+void Tizen_OnTouch(_THIS, int touch_device_id_in, int pointer_finger_id_in, int action, float x, float y, float p)
+{
+ SDL_TouchID touchDeviceId = 0;
+ SDL_FingerID fingerId = 0;
+ float normalized_x, normalized_y;
+
+ if (!_this->windows) {
+ return;
+ }
+ Tizen_GetNormalizedCoordinates(_this,x,y,&normalized_x,&normalized_y);
+
+ touchDeviceId = (SDL_TouchID)touch_device_id_in;
+ if (SDL_AddTouch(touchDeviceId, "Tizen_Touch") < 0) {
+ SDL_Log("error: can't add touch %s, %d", __FILE__, __LINE__);
+ }
+
+ fingerId = (SDL_FingerID)pointer_finger_id_in;
+ switch (action) {
+ case ACTION_POINTER_DOWN:
+ /* Touch pointer down */
+ SDL_SendTouch(touchDeviceId, fingerId, SDL_TRUE, normalized_x, normalized_y, p);
+ break;
+
+ case ACTION_POINTER_MOVE:
+ SDL_SendTouchMotion(touchDeviceId, fingerId, normalized_x, normalized_y, p);
+ break;
+
+ case ACTION_POINTER_UP:
+ /* Touch pointer up */
+ SDL_SendTouch(touchDeviceId, fingerId, SDL_FALSE, normalized_x, normalized_y, p);
+ break;
+
+ default:
+ break;
+ }
+}
+
+#endif /* SDL_VIDEO_DRIVER_TIZEN */
+
+/* vi: set ts=4 sw=4 expandtab: */
#include "../../SDL_internal.h"
+#include "SDL_tizenvideo.h"
+
+#define ACTION_POINTER_DOWN 1
+#define ACTION_POINTER_UP 2
+#define ACTION_POINTER_MOVE 3
+#define ACTION_CANCEL 4
+#define ACTION_OUTSIDE 5
+
+#define TOUCH_THRESHOLD 100.0f
+
+extern void Tizen_InitTouch(void);
+extern void Tizen_QuitTouch(void);
+extern void Tizen_OnTouch(_THIS, int touch_device_id_in, int pointer_finger_id_in, int action, float x, float y, float p);
+
+/* vi: set ts=4 sw=4 expandtab: */