diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 08517f926..6fd9d00ab 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,5 +1,9 @@ D2X-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 diff --git a/arch/sdl/mouse.c b/arch/sdl/mouse.c index b1c86a7ce..ae2d19f39 100644 --- a/arch/sdl/mouse.c +++ b/arch/sdl/mouse.c @@ -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) diff --git a/ui/mouse.c b/ui/mouse.c index c713a1d42..96226be6a 100644 --- a/ui/mouse.c +++ b/ui/mouse.c @@ -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;