Merge pull request #1484 from lakkatv/xmb

(XMB) Mouse support
This commit is contained in:
Twinaphex 2015-03-08 23:38:22 +01:00
commit 15a8f262a0
2 changed files with 68 additions and 3 deletions

View File

@ -158,7 +158,7 @@ static void glui_render_background(gl_t *gl, glui_handle_t *glui,
gl->coords.color = gl->white_color_ptr;
}
static void glui_draw_cursor(gl_t *gl, glui_handle_t *glui, float x, float y)
static void glui_draw_cursor(gl_t *gl, float x, float y)
{
struct gl_coords coords;
static const GLfloat vertex[] = {
@ -181,7 +181,7 @@ static void glui_draw_cursor(gl_t *gl, glui_handle_t *glui, float x, float y)
1.0f, 1.0f, 1.0f, 1.0f,
};
glViewport(x - 5, gl->win_height - y, 11, 11);
glViewport(x - 5, gl->win_height - y + 5, 11, 11);
coords.vertices = 4;
coords.vertex = vertex;
@ -457,7 +457,7 @@ static void glui_frame(void)
}
if (menu->mouse.enable)
glui_draw_cursor(gl, glui, menu->mouse.x, menu->mouse.y);
glui_draw_cursor(gl, menu->mouse.x, menu->mouse.y);
gl_set_viewport(gl, gl->win_width, gl->win_height, false, true);
}

View File

@ -1135,14 +1135,76 @@ static void xmb_draw_items(xmb_handle_t *xmb, gl_t *gl,
}
}
static void xmb_draw_cursor(gl_t *gl, float x, float y)
{
struct gl_coords coords;
static const GLfloat vertex[] = {
0, 0,
1, 0,
0, 1,
1, 1,
};
static const GLfloat tex_coord[] = {
0, 1,
1, 1,
0, 0,
1, 0,
};
GLfloat color[] = {
1.0f, 1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 1.0f, 1.0f,
};
glViewport(x - 5, gl->win_height - y + 5, 11, 11);
coords.vertices = 4;
coords.vertex = vertex;
coords.tex_coord = tex_coord;
coords.lut_tex_coord = tex_coord;
coords.color = color;
glBindTexture(GL_TEXTURE_2D, 0);
gl->shader->use(gl, GL_SHADER_STOCK_BLEND);
gl->shader->set_coords(&coords);
gl->shader->set_mvp(gl, &gl->mvp_no_rot);
glEnable(GL_BLEND);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
glDisable(GL_BLEND);
gl->coords.color = gl->white_color_ptr;
}
static void xmb_render(void)
{
unsigned i, current, end;
menu_handle_t *menu = menu_driver_resolve();
if (!menu)
return;
xmb_handle_t *xmb = (xmb_handle_t*)menu->userdata;
if (!xmb)
return;
menu_animation_update(menu->animation, menu->dt / IDEAL_DT);
current = menu->navigation.selection_ptr;
end = menu_list_get_size(menu->menu_list);
for (i = 0; i < end; i++)
{
float item_y = xmb->margins.screen.top + xmb_item_y(xmb, i, current);
if (menu->mouse.y > item_y && menu->mouse.y < item_y + xmb->icon.size)
menu->mouse.ptr = i;
}
g_runloop.frames.video.current.menu.animation.is_active = false;
g_runloop.frames.video.current.menu.label.is_updated = false;
g_runloop.frames.video.current.menu.framebuf.dirty = false;
@ -1274,6 +1336,9 @@ static void xmb_frame(void)
xmb_render_messagebox(msg);
}
if (menu->mouse.enable)
xmb_draw_cursor(gl, menu->mouse.x, menu->mouse.y);
gl_set_viewport(gl, gl->win_width, gl->win_height, false, true);
}