Each mouse should track its own double-click status (nw)

This commit is contained in:
Brad Hughes 2016-09-07 09:17:27 -04:00
parent 0c0c086268
commit db54570694

View File

@ -192,11 +192,19 @@ public:
class sdl_mouse_device : public sdl_device
{
private:
const std::chrono::milliseconds double_click_speed = std::chrono::milliseconds(250);
std::chrono::system_clock::time_point last_click;
int last_x;
int last_y;
public:
mouse_state mouse;
sdl_mouse_device(running_machine &machine, const char* name, input_module &module)
: sdl_device(machine, name, DEVICE_CLASS_MOUSE, module),
last_x(0),
last_y(0),
mouse({0})
{
}
@ -235,22 +243,18 @@ public:
//printf("But down %d %d %d %d %s\n", event.button.which, event.button.button, event.button.x, event.button.y, devinfo->name.c_str());
if (sdlevent.button.button == 1)
{
// FIXME Move static declaration
static osd_ticks_t last_click = 0;
static int last_x = 0;
static int last_y = 0;
int cx, cy;
osd_ticks_t click = osd_ticks() * 1000 / osd_ticks_per_second();
auto click = std::chrono::system_clock::now();
auto window = GET_FOCUS_WINDOW(&sdlevent.button);
if (window != nullptr && window->xy_to_render_target(sdlevent.button.x, sdlevent.button.y, &cx, &cy))
{
machine().ui_input().push_mouse_down_event(window->target(), cx, cy);
// FIXME Parameter ?
if ((click - last_click < 250)
if (click - last_click < double_click_speed
&& (cx >= last_x - 4 && cx <= last_x + 4)
&& (cy >= last_y - 4 && cy <= last_y + 4))
{
last_click = 0;
last_click = std::chrono::time_point<std::chrono::system_clock>::min();
machine().ui_input().push_mouse_double_click_event(window->target(), cx, cy);
}
else