ModelMatrix mMatrix;
+SDL_bool isTouchIndicator(SDL_Window *window, int rot, int x, int y)
+{
+
+ if(rot==0 && x > window->x && x < window->x + window->w && y > window->y && y < window->y + 52)
+ return SDL_TRUE;
+
+ if(rot==90 && x > window->x && x < window->x + 52 && y > window->y && y < window->y + window->h)
+ return SDL_TRUE;
+
+ if(rot==270 && x > window->x + window->w -52 && x < window->x + window->w && y > window->y && y < window->y + window->h)
+ return SDL_TRUE;
+
+ return SDL_FALSE;
+}
+
Eina_Bool
_tizen_cb_event_mousedown_change(void *data, int type, void *event)
{
wind = window->driverdata;
SDL_LogDebug(SDL_LOG_CATEGORY_APPLICATION, "mouse down (%d x %d)",e->x,e->y);
- if(wind->rotation == 0)
+ if(isTouchIndicator(window, wind->rotation, e->x, e->y))
{
- if(e->x > window->x && e->x < window->x + window->w &&
- e->y > window->y && e->y < window->y + 52)
- {
- ModelMatrixLoadIdentity(&mMatrix);
- wind->indicator_show = SDL_TRUE;
- wind->last_indicator_showtime = SDL_GetTicks();
- _tizen_indicator_event_filter();
- }
- }
- else if(wind->rotation == 90)
- {
- if(e->x > window->x && e->x < window->x + 52 &&
- e->y > window->y && e->y < window->y + window->h)
- {
- ModelMatrixLoadIdentity(&mMatrix);
- wind->indicator_show = SDL_TRUE;
- wind->last_indicator_showtime = SDL_GetTicks();
- _tizen_indicator_event_filter();
- }
- }/*
- else if(wind->rotation == 180)
- {
- if(e->x > window->x && e->x < window->x + window->w &&
- e->y > window->y + window->h -52 && e->y < window->y + window->h)
- {
- ModelMatrixLoadIdentity(&mMatrix);
- wind->indicator_show = SDL_TRUE;
- wind->last_indicator_showtime = SDL_GetTicks();
- _tizen_indicator_event_filter();
- }
- }*/
- else if(wind->rotation == 270)
- {
- if(e->x > window->x + window->w -52 && e->x < window->x + window->w &&
- e->y > window->y && e->y < window->y + window->h)
- {
- ModelMatrixLoadIdentity(&mMatrix);
- wind->indicator_show = SDL_TRUE;
- wind->last_indicator_showtime = SDL_GetTicks();
- _tizen_indicator_event_filter();
- }
+ ModelMatrixTranslateInit(&mMatrix);
+ wind->indicator_show = SDL_TRUE;
+ wind->last_indicator_showtime = SDL_GetTicks();
+ _tizen_indicator_event_filter();
}
SDL_SendMouseMotion(window, 0, 0, e->x, e->y);
matrix->m[3][3] += (matrix->m[0][3] * x + matrix->m[1][3] * y + matrix->m[2][3] * z);
}
+void ModelMatrixTranslateInit(ModelMatrix* matrix)
+{
+ matrix->m[3][0] = matrix->m[3][1] = matrix->m[3][2] =0;
+ matrix->m[3][3] = 1;
+}
+
+void multiply_matrix(ModelMatrix *lhs, ModelMatrix *rhs, ModelMatrix *r)
+{
+ int i, j, k;
+ float tmp[4][4];
+
+ for (i = 0; i < 4; i++) {
+ for (j = 0; j < 4; j++) {
+ tmp[j][i] = 0.0;
+
+ for (k = 0; k < 4; k++) {
+ tmp[j][i] += lhs->m[k][i] * rhs->m[j][k];
+ }
+ }
+ }
+ for (i = 0; i < 4; i++) {
+ for (j=0; j<4; j++) {
+ r->m[i][j] = tmp[i][j];
+ }
+ }
+}
+
+void rotate_indicator(ModelMatrix* matrix, const float anglex, const float angley, const float anglez)
+{
+ const float pi = 3.141592f;
+ ModelMatrix* temp = (ModelMatrix*)malloc(sizeof(ModelMatrix));
+ float rz = 2.0f * pi * anglez / 360.0f;
+ float rx = 2.0f * pi * anglex / 360.0f;
+ float ry = 2.0f * pi * angley / 360.0f;
+ float sy = SDL_sinf(ry);
+ float cy = SDL_cosf(ry);
+ float sx = SDL_sinf(rx);
+ float cx = SDL_cosf(rx);
+ float sz = SDL_sinf(rz);
+ float cz = SDL_cosf(rz);
+
+ ModelMatrixLoadIdentity(temp);
+
+ temp->m[0][0] = cy * cz - sx * sy * sz;
+ temp->m[0][1] = cz * sx * sy + cy * sz;
+ temp->m[0][2] = -cx * sy;
+ temp->m[1][0] = -cx * sz;
+ temp->m[1][1] = cx * cz;
+ temp->m[1][2] = sx;
+
+ temp->m[2][0] = cz * sy + cy * sx * sz;
+ temp->m[2][1] = -cy * cz * sx + sy * sz;
+ temp->m[2][2] = cx * cy;
+
+ multiply_matrix(matrix, temp, matrix);
+ free(temp);
+}
+
void Tizen_remote_indicator(int res_id)
{
if(!shared_info.tizen_rs) {
if(wdata->last_indicator_showtime + 3000< SDL_GetTicks())
{
- switch(wdata->rotation)
- {
- case 0:
- ModelMatrixTranslate(&mMatrix, 0.0f, 0.02f, 0.0f);
- break;
- case 90:
- ModelMatrixTranslate(&mMatrix, -0.02f, 0.0f, 0.0f);
- break;
- case 180:
- ModelMatrixTranslate(&mMatrix, 0.0f, -0.02f, 0.0f);
- break;
- case 270:
- ModelMatrixTranslate(&mMatrix, 0.02f, 0.0f, 0.0f);
- break;
- }
+ ModelMatrixTranslate(&mMatrix, 0.0f, 0.02f, 0.0f);
}
if(wdata->last_indicator_showtime + 3500 <SDL_GetTicks()) {
wind->last_indicator_showtime = SDL_GetTicks();
ecore_main_loop_iterate();
- if (!wind->support_pre_rotation)
- SDL_IndicatorProcessEvent(window, wind->rotation);
- else
- SDL_IndicatorProcessEvent(window, 0);
-
+ SDL_IndicatorProcessEvent(window, wind->rotation);
_tizen_indicator_event_filter();
return 1;
LoadContext(&Mainctx);
SDL_WindowData *wind = window->driverdata;
- if( rot == 0)
- {
- SDL_Log("===rotate 0 degree!\n");
- vVertices[0] = 1.0f;
- vVertices[1] = 1.0f;
- vVertices[3] = -1.0f;
- vVertices[4] = 0.92f;
- vVertices[6] = 1.0f;
- vVertices[7] = 0.92f;
- vVertices[9] = 1.0f;
- vVertices[10] = 1.0f;
- vVertices[12] = -1.0f;
- vVertices[13] = 1.0f;
- vVertices[15] = -1.0f;
- vVertices[16] = 0.92f;
-
- vCoord[0] = 1.0f;
- vCoord[1] = 0.0f;
- vCoord[2] = 0.0f;
- vCoord[3] = 1.0f;
- vCoord[4] = 1.0f;
- vCoord[5] = 1.0f;
- vCoord[6] = 1.0f;
- vCoord[7] = 0.0f;
- vCoord[8] = 0.0f;
- vCoord[9] = 0.0f;
- vCoord[10] = 0.0f;
- vCoord[11] = 1.0f;
- }
- else if(rot == 90)
- {
- SDL_Log("===rotate 90 degree!\n");
- vVertices[0] = -0.86f;
- vVertices[1] = 1.0f;
- vVertices[3] = -0.86f;
- vVertices[4] = -1.0f;
- vVertices[6] = -1.0f;
- vVertices[7] = 1.0f;
- vVertices[9] = -1.0f;
- vVertices[10] = -1.0f;
- vVertices[12] = -0.86f;
- vVertices[13] = -1.0f;
- vVertices[15] = -1.0f;
- vVertices[16] = 1.0f;
-
- vCoord[0] = 1.0f;
- vCoord[1] = 1.0f;
- vCoord[2] = 0.0f;
- vCoord[3] = 1.0f;
- vCoord[4] = 1.0f;
- vCoord[5] = 0.0f;
- vCoord[6] = 0.0f;
- vCoord[7] = 0.0f;
- vCoord[8] = 0.0f;
- vCoord[9] = 1.0f;
- vCoord[10] = 1.0f;
- vCoord[11] = 0.0f;
- }
- else if(rot == 180)
- {
- SDL_Log("===rotate 180 degree!\n");
- vVertices[0] = -1.0f;
- vVertices[1] = -1.0f;
- vVertices[3] = -1.0f;
- vVertices[4] = -0.92f;
- vVertices[6] = 1.0f;
- vVertices[7] = -1.0f;
- vVertices[9] = 1.0f;
- vVertices[10] = -0.92f;
- vVertices[12] = -1.0f;
- vVertices[13] = -0.92f;
- vVertices[15] = 1.0f;
- vVertices[16] = -1.0f;
-
- vCoord[0] = 1.0f;
- vCoord[1] = 0.0f;
- vCoord[2] = 1.0f;
- vCoord[3] = 1.0f;
- vCoord[4] = 0.0f;
- vCoord[5] = 0.0f;
- vCoord[6] = 0.0f;
- vCoord[7] = 1.0f;
- vCoord[8] = 1.0f;
- vCoord[9] = 1.0f;
- vCoord[10] = 0.0f;
- vCoord[11] = 0.0f;
- }
- else if(rot == 270)
- {
- SDL_Log("===rotate 270 degree!\n");
- vVertices[0] = 1.0f;
- vVertices[1] = 1.0f;
- vVertices[3] = 0.86f;
- vVertices[4] = 1.0f;
- vVertices[6] = 1.0f;
- vVertices[7] = -1.0f;
- vVertices[9] = 0.86f;
- vVertices[10] = -1.0f;
- vVertices[12] = 0.86f;
- vVertices[13] = 1.0f;
- vVertices[15] = 1.0f;
- vVertices[16] = -1.0f;
-
- vCoord[0] = 0.0f;
- vCoord[1] = 0.0f;
- vCoord[2] = 0.0f;
- vCoord[3] = 1.0f;
- vCoord[4] = 1.0f;
- vCoord[5] = 0.0f;
- vCoord[6] = 1.0f;
- vCoord[7] = 1.0f;
- vCoord[8] = 0.0f;
- vCoord[9] = 1.0f;
- vCoord[10] = 1.0f;
- vCoord[11] = 0.0f;
-
- //Invisible Indicator
- wind->indicator_show = SDL_FALSE;
- _tizen_indicator_event_filter();
- }
- Mainctx.glBindBuffer(GL_ARRAY_BUFFER, indicator_vbo[wind->rotation/90]);
+ double ratio = 0.92f;
+ if( rot == 90 || rot ==270)
+ ratio = 0.86f;
+
+ vVertices[4] = vVertices[7] = vVertices[16] = ratio;
+
+ Mainctx.glBindBuffer(GL_ARRAY_BUFFER, indicator_vbo);
Mainctx.glBufferData(GL_ARRAY_BUFFER, 18 * 4, vVertices, GL_STATIC_DRAW);
- Mainctx.glBindBuffer(GL_ARRAY_BUFFER, indicator_ibo[wind->rotation/90]);
+ Mainctx.glBindBuffer(GL_ARRAY_BUFFER, indicator_ibo);
Mainctx.glBufferData(GL_ARRAY_BUFFER, 12 * 4, vCoord, GL_STATIC_DRAW);
ModelMatrixLoadIdentity(&mMatrix);
+
+ if (!wind->support_pre_rotation)
+ rotate_indicator(&mMatrix, 0, 0, rot);
+
wind->indicator_show = SDL_TRUE;
wind->last_indicator_showtime = SDL_GetTicks();
+
_tizen_indicator_event_filter();
}