Move EVENT_MOUSE_DOUBLE_CLICKED support from ui/mouse.c to arch/sdl/mouse.c for tidiness and to possibly use it outside the editor

This commit is contained in:
Chris Taylor 2011-09-12 11:02:30 +08:00
parent 2b5ef3ecfb
commit 3f5506ee72
3 changed files with 20 additions and 4 deletions

View file

@ -1,5 +1,9 @@
D1X-Rebirth Changelog
20110912
--------
arch/sdl/mouse.c, ui/mouse.c: Move EVENT_MOUSE_DOUBLE_CLICKED support from ui/mouse.c to arch/sdl/mouse.c for tidiness and to possibly use it outside the editor
20110826
--------
main/ai.c: Due to conversion from fix64 to fix Boss_dying_start_time was not 0 when saving even if boss was not dead - fixed; Fixed warning about set but unused variable

View file

@ -15,6 +15,7 @@
static struct mouseinfo {
ubyte button_state[MOUSE_MAX_BUTTONS];
fix64 time_lastpressed[MOUSE_MAX_BUTTONS];
int delta_x, delta_y, delta_z, old_delta_x, old_delta_y;
int x,y,z;
int cursor_enabled;
@ -106,6 +107,21 @@ void mouse_button_handler(SDL_MouseButtonEvent *mbe)
con_printf(CON_DEBUG, "Sending event %s, button %d, coords %d,%d,%d\n",
(mbe->state == SDL_PRESSED) ? "EVENT_MOUSE_BUTTON_DOWN" : "EVENT_MOUSE_BUTTON_UP", event.button, Mouse.x, Mouse.y, Mouse.z);
event_send((d_event *)&event);
//Double-click support
if (Mouse.button_state[button])
{
if (timer_query() <= Mouse.time_lastpressed[button] + F1_0/5)
{
event.type = EVENT_MOUSE_DOUBLE_CLICKED;
//event.button = button; // already set the button
con_printf(CON_DEBUG, "Sending event EVENT_MOUSE_DOUBLE_CLICKED, button %d, coords %d,%d\n",
event.button, Mouse.x, Mouse.y);
event_send((d_event *)&event);
}
Mouse.time_lastpressed[button] = Mouse.cursor_time;
}
}
void mouse_motion_handler(SDL_MouseMotionEvent *mme)

View file

@ -241,11 +241,7 @@ int ui_mouse_button_process(d_event *event)
{
if ((timer_query() <= Mouse.time_lastpressed + F1_0/5)) //&& (Mouse.moved==0)
{
d_event_mousebutton event = { EVENT_MOUSE_DOUBLE_CLICKED, MBTN_LEFT };
Mouse.b1_status |= BUTTON_DOUBLE_CLICKED;
con_printf(CON_DEBUG, "Sending event EVENT_MOUSE_DOUBLE_CLICKED, button %d, coords %d,%d\n",
event.button, Mouse.x, Mouse.y);
event_send((d_event *)&event);
}
Mouse.moved = 0;