map-mouse-buttons.patch
1.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
diff -Naur a/src/gui/sdl_mapper.cpp b/src/gui/sdl_mapper.cpp
--- a/src/gui/sdl_mapper.cpp 2015-01-10 14:16:22.000000000 +0100
+++ b/src/gui/sdl_mapper.cpp 2016-10-31 21:36:44.509231014 +0100
@@ -32,6 +32,7 @@
#include "dosbox.h"
#include "video.h"
#include "keyboard.h"
+#include "mouse.h"
#include "joystick.h"
#include "support.h"
#include "mapper.h"
@@ -1497,6 +1498,20 @@
KBD_KEYS key;
};
+class CMouseButtonEvent : public CTriggeredEvent {
+public:
+ CMouseButtonEvent(char const * const _entry,Bit8u _button) : CTriggeredEvent(_entry) {
+ button=_button;
+ }
+ void Active(bool yesno) {
+ if (yesno)
+ Mouse_ButtonPressed(button);
+ else
+ Mouse_ButtonReleased(button);
+ }
+ Bit8u button;
+};
+
class CJAxisEvent : public CContinuousEvent {
public:
CJAxisEvent(char const * const _entry,Bitu _stick,Bitu _axis,bool _positive,CJAxisEvent * _opposite_axis) : CContinuousEvent(_entry) {
@@ -1708,6 +1723,15 @@
return event;
}
+static CMouseButtonEvent * AddMouseButtonEvent(Bitu x,Bitu y,Bitu dx,Bitu dy,char const * const title,char const * const entry,Bit8u button) {
+ char buf[64];
+ strcpy(buf,"mouse_");
+ strcat(buf,entry);
+ CMouseButtonEvent * event=new CMouseButtonEvent(buf,button);
+ new CEventButton(x,y,dx,dy,title,event);
+ return event;
+}
+
static CJAxisEvent * AddJAxisButton(Bitu x,Bitu y,Bitu dx,Bitu dy,char const * const title,Bitu stick,Bitu axis,bool positive,CJAxisEvent * opposite_axis) {
char buf[64];
sprintf(buf,"jaxis_%d_%d%s",stick,axis,positive ? "+" : "-");
@@ -1866,6 +1890,15 @@
AddKeyButtonEvent(PX(XO+2),PY(YO+4),BW,BH,".","kp_period",KBD_kpperiod);
#undef XO
#undef YO
+#define XO 5
+#define YO 8
+ /* Mouse Buttons */
+ new CTextButton(PX(XO+0),PY(YO-1),3*BW,20,"Mouse");
+ AddMouseButtonEvent(PX(XO+0),PY(YO),BW,BH,"L","left",0);
+ AddMouseButtonEvent(PX(XO+1),PY(YO),BW,BH,"M","middle",2);
+ AddMouseButtonEvent(PX(XO+2),PY(YO),BW,BH,"R","right",1);
+#undef XO
+#undef YO
#define XO 10
#define YO 8
/* Joystick Buttons/Texts */