VOGONS

Common searches


First post, by emendelson

User metadata
Rank Oldbie
Rank
Oldbie

It occurred to me that it might be useful to be able to capture the mouse from the command-line, so that a batch or conf file could capture the mouse, start a game, and release the mouse afterward. I couldn't find any way to do this in the existing code, so I somehow managed to throw together a MOUSECAP command. I don't know anything about programming, so this is probably incompetent, and a real programmer could do it better, but it seems to work. Here's how to do it:

1. In shell.h, add to the list of commands:

void CMD_MOUSECAP(char * args);

2. In shell_cmds.cpp, add below the list of includes:

extern void GFX_CaptureMouse(void);
extern bool mouselocked;

3. Also in shell.cmds.cpp, in the cmd_list near the top, add:

{	"MOUSECAP",	0,			&DOS_Shell::CMD_MOUSECAP,	"SHELL_CMD_MOUSECAP_HELP"},

4. Also in shell.cmds.cpp, among the code for the actual commands, add:

void DOS_Shell::CMD_MOUSECAP(char * args) {
HELP("MOUSECAP");
GFX_CaptureMouse();
if (mouselocked)
WriteOut("Mouse captured.\n");
else
WriteOut("Mouse released.\n");
}

5. Finally, in shell.cpp, add among the help texts:

	MSG_Add("SHELL_CMD_MOUSECAP_HELP","Toggle mouse capture.\n");

I hope someone else finds this useful.

Last edited by emendelson on 2015-11-22, 02:36. Edited 3 times in total.

Reply 1 of 3, by Dominus

User metadata
Rank DOSBox Moderator
Rank
DOSBox Moderator

Nice one 😉

(Moved to Patches)

Windows 3.1x guide for DOSBox
60 seconds guide to DOSBox
DOSBox SVN snapshot for macOS (10.4-11.x ppc/intel 32/64bit) notarized for gatekeeper

Reply 3 of 3, by emendelson

User metadata
Rank Oldbie
Rank
Oldbie

And this patch should be used together with the one here, which tells how to add a "Mouse Captured - Ctrl-F10 to release" message to the title bar when the mouse is captured:

INPUT - Add "Ctrl-F10 releases mouse" to titlebar (SDL1)