6

I'm trying to play a game on my MacBook (The Settlers under DOSBox) that makes use of something the manual calls a "special click": holding down the right mouse button and clicking the left mouse button.

It seems to be impossible to do that using the trackpad. Apart from attaching an external mouse, is there any way to simulate such input?

2
  • Are there in-game control settings that you can use to eliminate the need to click both at once?
    – user24601
    May 13, 2015 at 18:02
  • No, the controls are hardcoded.
    – legoscia
    May 13, 2015 at 19:46

2 Answers 2

1

You can setup touchpad to perform right click by pressing its right (or left) bottom corner. If your normal click is done by touching trackpad (not clicking it) then you can perform this magic trick - press bottom corner for right click and touch touchpad to make normal click = two clicks simultaneously. enter image description here

4
  • This might work, but it doesn't work in the game I'm trying to play, because I have to hold down left-click and then right-click. Any more ideas? May 6, 2019 at 1:39
  • In the original question it was vice versa. But even in your case it should work. I have right click by two fingers touch. So, normal click on touchpad (this would be your left-click) and then right-click by two fingers touch. May 6, 2019 at 12:14
  • 1
    Thanks. That works for a split second, but for this game I need to be able to hold them down at the same time. Since my problem is different enough, perhaps I'll post a separate question. May 6, 2019 at 13:38
  • This does not seem to work in practice. Is there a way to test it?
    – jvriesem
    May 13, 2021 at 17:35
1

It turned out to be quite easy to patch DOSBox to allow using a keyboard key as a mouse button. I submitted a patch for adding that functionality to the key mapper.


If you want to try this out, save the following into a text file called map-mouse-buttons.diff:

Index: src/gui/sdl_mapper.cpp
===================================================================
--- src/gui/sdl_mapper.cpp  (revision 3914)
+++ src/gui/sdl_mapper.cpp  (working copy)
@@ -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 */

Then, in the terminal, check out the latest DOSBox code from Subversion:

svn co svn://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk dosbox-svn

Enter the directory, and apply the patch with the patch command:

cd dosbox-svn
patch -p0 < ../map-mouse-buttons.diff

(This assumes that the patch file is saved in the parent directory of dosbox-svn. If it's somewhere else, adjust the command as needed.)

Then, follow the instructions in the INSTALL file to build your new version of DOSBox. Basically, it's these three commands:

./autogen.sh
./configure
make

Though you may have to install various dependencies, which can be done through Macports and similar tools.

4
  • How do I use your patch? I'm running a macbook pro 2011, with OSX 10.6.8 I'm trying to play Ultima VIII in a Dosbox wrapper, where I need this special click to perform an action. Thanks!
    – user149048
    Sep 28, 2015 at 22:32
  • Checkout the DOSBox source code from SVN here, apply the patch with patch -p0 < map-mouse-buttons.diff, and follow the instructions in the INSTALL file.
    – legoscia
    Sep 28, 2015 at 22:46
  • Your patch seems to have issues with Mac OS 10.13.3 . I get patching file src/gui/sdl_mapper.cpp Hunk #1 FAILED at 32. patch: **** malformed patch at line 25: \ Would you be able to update to work? Thanks Mar 12, 2018 at 1:09
  • Hm, it works for me.... Might be worth trying to download the patch file directly from Sourceforge: sourceforge.net/p/dosbox/patches/264/attachment/…
    – legoscia
    Mar 12, 2018 at 18:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .