Add patch 1210768 which reintroduces the lockfree mouse from Moe
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@2468
This commit is contained in:
parent
73530a5ed1
commit
2ac98a74ab
3 changed files with 37 additions and 14 deletions
|
@ -16,7 +16,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
/* $Id: mouse.h,v 1.10 2005-09-21 11:37:35 c2woody Exp $ */
|
||||
/* $Id: mouse.h,v 1.11 2006-01-31 09:26:43 qbix79 Exp $ */
|
||||
|
||||
#ifndef DOSBOX_MOUSE_H
|
||||
#define DOSBOX_MOUSE_H
|
||||
|
@ -27,7 +27,7 @@ void Mouse_HideCursor(void);
|
|||
bool Mouse_SetPS2State(bool use);
|
||||
void Mouse_ChangePS2Callback(Bit16u pseg, Bit16u pofs);
|
||||
|
||||
void Mouse_CursorMoved(float x,float y);
|
||||
void Mouse_CursorMoved(float xrel,float yrel,float x,float y,bool emulate);
|
||||
void Mouse_CursorSet(float x,float y);
|
||||
void Mouse_ButtonPressed(Bit8u button);
|
||||
void Mouse_ButtonReleased(Bit8u button);
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
/* $Id: sdlmain.cpp,v 1.97 2006-01-30 15:02:33 harekiet Exp $ */
|
||||
/* $Id: sdlmain.cpp,v 1.98 2006-01-31 09:26:44 qbix79 Exp $ */
|
||||
|
||||
#ifndef _GNU_SOURCE
|
||||
#define _GNU_SOURCE
|
||||
|
@ -588,6 +588,7 @@ dosurface:
|
|||
}//CASE
|
||||
if (retFlags)
|
||||
GFX_Start();
|
||||
if (!sdl.mouse.autoenable) SDL_ShowCursor(sdl.mouse.autolock?SDL_DISABLE:SDL_ENABLE);
|
||||
return retFlags;
|
||||
}
|
||||
|
||||
|
@ -599,7 +600,7 @@ static void CaptureMouse(void) {
|
|||
SDL_ShowCursor(SDL_DISABLE);
|
||||
} else {
|
||||
SDL_WM_GrabInput(SDL_GRAB_OFF);
|
||||
SDL_ShowCursor(SDL_ENABLE);
|
||||
if (sdl.mouse.autoenable || !sdl.mouse.autolock) SDL_ShowCursor(SDL_ENABLE);
|
||||
}
|
||||
mouselocked=sdl.mouse.locked;
|
||||
}
|
||||
|
@ -966,6 +967,7 @@ static void GUI_StartUp(Section * sec) {
|
|||
#endif
|
||||
}
|
||||
sdl.mouse.autoenable=section->Get_bool("autolock");
|
||||
if (!sdl.mouse.autoenable) SDL_ShowCursor(SDL_DISABLE);
|
||||
sdl.mouse.autolock=false;
|
||||
sdl.mouse.sensitivity=section->Get_int("sensitivity");
|
||||
const char * output=section->Get_string("output");
|
||||
|
@ -1048,13 +1050,16 @@ static void GUI_StartUp(Section * sec) {
|
|||
|
||||
void Mouse_AutoLock(bool enable) {
|
||||
sdl.mouse.autolock=enable;
|
||||
if (enable && sdl.mouse.autoenable) sdl.mouse.requestlock=true;
|
||||
else sdl.mouse.requestlock=false;
|
||||
if (sdl.mouse.autoenable) sdl.mouse.requestlock=enable;
|
||||
else {
|
||||
SDL_ShowCursor(enable?SDL_DISABLE:SDL_ENABLE);
|
||||
sdl.mouse.requestlock=false;
|
||||
}
|
||||
}
|
||||
|
||||
static void HandleMouseMotion(SDL_MouseMotionEvent * motion) {
|
||||
if (sdl.mouse.locked)
|
||||
Mouse_CursorMoved((float)motion->xrel*sdl.mouse.sensitivity/100,(float)motion->yrel*sdl.mouse.sensitivity/100);
|
||||
if (sdl.mouse.locked || !sdl.mouse.autoenable)
|
||||
Mouse_CursorMoved((float)motion->xrel*sdl.mouse.sensitivity/100,(float)motion->yrel*sdl.mouse.sensitivity/100,(float)(motion->x-sdl.clip.x)/(sdl.clip.w-1)*sdl.mouse.sensitivity/100,(float)(motion->y-sdl.clip.y)/(sdl.clip.h-1)*sdl.mouse.sensitivity/100.0,sdl.mouse.locked);
|
||||
}
|
||||
|
||||
static void HandleMouseButton(SDL_MouseButtonEvent * button) {
|
||||
|
@ -1065,6 +1070,10 @@ static void HandleMouseButton(SDL_MouseButtonEvent * button) {
|
|||
// Dont pass klick to mouse handler
|
||||
break;
|
||||
}
|
||||
if (!sdl.mouse.autoenable && sdl.mouse.autolock && button->button == SDL_BUTTON_MIDDLE) {
|
||||
CaptureMouse();
|
||||
break;
|
||||
}
|
||||
switch (button->button) {
|
||||
case SDL_BUTTON_LEFT:
|
||||
Mouse_ButtonPressed(0);
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
/* $Id: mouse.cpp,v 1.58 2006-01-30 10:06:36 harekiet Exp $ */
|
||||
/* $Id: mouse.cpp,v 1.59 2006-01-31 09:26:45 qbix79 Exp $ */
|
||||
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
|
@ -410,9 +410,9 @@ void DrawCursor() {
|
|||
RestoreVgaRegisters();
|
||||
}
|
||||
|
||||
void Mouse_CursorMoved(float x,float y) {
|
||||
float dx = x * mouse.pixelPerMickey_x;
|
||||
float dy = y * mouse.pixelPerMickey_y;
|
||||
void Mouse_CursorMoved(float xrel,float yrel,float x,float y,bool emulate) {
|
||||
float dx = xrel * mouse.pixelPerMickey_x;
|
||||
float dy = yrel * mouse.pixelPerMickey_y;
|
||||
|
||||
if((fabs(x) > 1.0) || (mouse.senv_x < 1.0)) dx *= mouse.senv_x;
|
||||
if((fabs(y) > 1.0) || (mouse.senv_y < 1.0)) dy *= mouse.senv_y;
|
||||
|
@ -420,8 +420,22 @@ void Mouse_CursorMoved(float x,float y) {
|
|||
|
||||
mouse.mickey_x += dx;
|
||||
mouse.mickey_y += dy;
|
||||
mouse.x += dx;
|
||||
mouse.y += dy;
|
||||
if (emulate) {
|
||||
mouse.x += dx;
|
||||
mouse.y += dy;
|
||||
} else {
|
||||
if (CurMode->type == M_TEXT) {
|
||||
mouse.x = x*CurMode->swidth;
|
||||
mouse.y = y*CurMode->sheight * 8 / CurMode->cheight;
|
||||
} else if (mouse.max_x < 2048 || mouse.max_y < 2048 || mouse.max_x != mouse.max_y) {
|
||||
mouse.x = x*mouse.max_x;
|
||||
mouse.y = y*mouse.max_y;
|
||||
} else { // Games faking relative movement through absolute coordinates. Quite surprising that this actually works..
|
||||
mouse.x += xrel;
|
||||
mouse.y += yrel;
|
||||
}
|
||||
}
|
||||
|
||||
/* ignore constraints if using PS2 mouse callback in the bios */
|
||||
|
||||
if (!useps2callback) {
|
||||
|
|
Loading…
Add table
Reference in a new issue