@@ -1704,21 +1704,25 @@ class CKeyEvent final : public CTriggeredEvent {
1704
1704
1705
1705
KBD_KEYS key;
1706
1706
};
1707
- /*
1708
- class CMouseButtonEvent : public CTriggeredEvent {
1707
+
1708
+ class CMouseButtonEvent final : public CTriggeredEvent {
1709
1709
public:
1710
- CMouseButtonEvent(char const * const _entry,Bit8u _button) : CTriggeredEvent(_entry) {
1711
- button=_button;
1712
- }
1713
- void Active(bool yesno) {
1714
- if (yesno)
1715
- Mouse_ButtonPressed(button);
1716
- else
1717
- Mouse_ButtonReleased(button);
1710
+ CMouseButtonEvent () = delete ;
1711
+
1712
+ CMouseButtonEvent (const char * const entry, const MouseButtonId id)
1713
+ : CTriggeredEvent(entry),
1714
+ button_id (id)
1715
+ {}
1716
+
1717
+ void Active (const bool pressed) override
1718
+ {
1719
+ MOUSE_EventButton (button_id, pressed);
1718
1720
}
1719
- Bit8u button;
1721
+
1722
+ private:
1723
+ const MouseButtonId button_id = MouseButtonId::None;
1720
1724
};
1721
- */
1725
+
1722
1726
class CJAxisEvent final : public CContinuousEvent {
1723
1727
public:
1724
1728
CJAxisEvent (const char * const entry, Bitu s, Bitu a, bool p,
@@ -2033,16 +2037,18 @@ static CKeyEvent* AddKeyButtonEvent(int32_t x, int32_t y, int32_t dx,
2033
2037
new CEventButton (x,y,dx,dy,title,event);
2034
2038
return event;
2035
2039
}
2036
- /*
2037
- static CMouseButtonEvent * AddMouseButtonEvent(Bitu x,Bitu y,Bitu dx,Bitu dy,char const * const title,char const * const entry,Bit8u button) {
2038
- char buf[64];
2039
- strcpy(buf,"mouse_");
2040
- strcat(buf,entry);
2041
- CMouseButtonEvent * event=new CMouseButtonEvent(buf,button);
2042
- new CEventButton(x,y,dx,dy,title,event);
2040
+
2041
+ static CMouseButtonEvent* AddMouseButtonEvent (const int32_t x, const int32_t y,
2042
+ const int32_t dx, const int32_t dy,
2043
+ const char * const title,
2044
+ const char * const entry,
2045
+ const MouseButtonId button_id)
2046
+ {
2047
+ auto event = new CMouseButtonEvent (entry, button_id);
2048
+ new CEventButton (x, y, dx, dy, title, event);
2043
2049
return event;
2044
2050
}
2045
- */
2051
+
2046
2052
static CJAxisEvent* AddJAxisButton (int32_t x, int32_t y, int32_t dx, int32_t dy,
2047
2053
const char * const title, Bitu stick, Bitu axis,
2048
2054
bool positive, CJAxisEvent* opposite_axis)
@@ -2269,17 +2275,36 @@ static void CreateLayout() {
2269
2275
#undef XO
2270
2276
#undef YO
2271
2277
2272
- #if 0
2273
2278
#define XO 5
2274
2279
#define YO 8
2275
2280
/* Mouse Buttons */
2276
- new CTextButton(PX(XO+0),PY(YO-1),3*BW,20,"Mouse");
2277
- AddMouseButtonEvent(PX(XO+0),PY(YO),BW,BH,"L","left",0);
2278
- AddMouseButtonEvent(PX(XO+1),PY(YO),BW,BH,"M","middle",2);
2279
- AddMouseButtonEvent(PX(XO+2),PY(YO),BW,BH,"R","right",1);
2281
+ new CTextButton (pos_x (XO + 0 ), pos_y (YO - 1 ), 3 * button_width, 20 , " Mouse" );
2282
+
2283
+ AddMouseButtonEvent (pos_x (XO + 0 ),
2284
+ pos_y (YO),
2285
+ button_width,
2286
+ button_height,
2287
+ " L" ,
2288
+ " mouse_left" ,
2289
+ MouseButtonId::Left);
2290
+
2291
+ AddMouseButtonEvent (pos_x (XO + 1 ),
2292
+ pos_y (YO),
2293
+ button_width,
2294
+ button_height,
2295
+ " M" ,
2296
+ " mouse_middle" ,
2297
+ MouseButtonId::Middle);
2298
+
2299
+ AddMouseButtonEvent (pos_x (XO + 2 ),
2300
+ pos_y (YO),
2301
+ button_width,
2302
+ button_height,
2303
+ " R" ,
2304
+ " mouse_right" ,
2305
+ MouseButtonId::Right);
2280
2306
#undef XO
2281
2307
#undef YO
2282
- #endif
2283
2308
2284
2309
#define XO 10
2285
2310
#define YO 8
0 commit comments