Construct d_event_mousebutton
This commit is contained in:
parent
a8431a1933
commit
babfa9d8e7
|
@ -19,7 +19,6 @@
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include "window.h"
|
#include "window.h"
|
||||||
|
|
||||||
struct d_event;
|
|
||||||
struct SDL_MouseButtonEvent;
|
struct SDL_MouseButtonEvent;
|
||||||
struct SDL_MouseMotionEvent;
|
struct SDL_MouseMotionEvent;
|
||||||
|
|
||||||
|
@ -61,7 +60,8 @@ void mouse_cursor_autohide();
|
||||||
class d_event_mousebutton : public d_event
|
class d_event_mousebutton : public d_event
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
int button;
|
d_event_mousebutton(event_type type, unsigned b);
|
||||||
|
const unsigned button;
|
||||||
};
|
};
|
||||||
|
|
||||||
class d_event_mouse_moved : public d_event
|
class d_event_mouse_moved : public d_event
|
||||||
|
|
|
@ -42,6 +42,11 @@ struct mouseinfo : flushable_mouseinfo
|
||||||
|
|
||||||
static mouseinfo Mouse;
|
static mouseinfo Mouse;
|
||||||
|
|
||||||
|
d_event_mousebutton::d_event_mousebutton(const event_type type, const unsigned b) :
|
||||||
|
d_event{type}, button(b)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
void mouse_init(void)
|
void mouse_init(void)
|
||||||
{
|
{
|
||||||
Mouse = {};
|
Mouse = {};
|
||||||
|
@ -76,9 +81,7 @@ static void maybe_send_z_move(const unsigned button)
|
||||||
|
|
||||||
static void send_singleclick(const bool pressed, const unsigned button)
|
static void send_singleclick(const bool pressed, const unsigned button)
|
||||||
{
|
{
|
||||||
d_event_mousebutton event;
|
const d_event_mousebutton event{pressed ? EVENT_MOUSE_BUTTON_DOWN : EVENT_MOUSE_BUTTON_UP, button};
|
||||||
event.type = pressed ? EVENT_MOUSE_BUTTON_DOWN : EVENT_MOUSE_BUTTON_UP;
|
|
||||||
event.button = button;
|
|
||||||
con_printf(CON_DEBUG, "Sending event %s, button %d, coords %d,%d,%d",
|
con_printf(CON_DEBUG, "Sending event %s, button %d, coords %d,%d,%d",
|
||||||
pressed ? "EVENT_MOUSE_BUTTON_DOWN" : "EVENT_MOUSE_BUTTON_UP", event.button, Mouse.x, Mouse.y, Mouse.z);
|
pressed ? "EVENT_MOUSE_BUTTON_DOWN" : "EVENT_MOUSE_BUTTON_UP", event.button, Mouse.x, Mouse.y, Mouse.z);
|
||||||
event_send(event);
|
event_send(event);
|
||||||
|
@ -91,9 +94,7 @@ static void maybe_send_doubleclick(const fix64 now, const unsigned button)
|
||||||
when = now;
|
when = now;
|
||||||
if (now > then + F1_0/5)
|
if (now > then + F1_0/5)
|
||||||
return;
|
return;
|
||||||
d_event_mousebutton event;
|
const d_event_mousebutton event{EVENT_MOUSE_DOUBLE_CLICKED, button};
|
||||||
event.type = EVENT_MOUSE_DOUBLE_CLICKED;
|
|
||||||
event.button = button;
|
|
||||||
con_printf(CON_DEBUG, "Sending event EVENT_MOUSE_DOUBLE_CLICKED, button %d, coords %d,%d", button, Mouse.x, Mouse.y);
|
con_printf(CON_DEBUG, "Sending event EVENT_MOUSE_DOUBLE_CLICKED, button %d, coords %d,%d", button, Mouse.x, Mouse.y);
|
||||||
event_send(event);
|
event_send(event);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue