mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-25 03:00:46 +00:00
Patch adding Wii support by tueidj, part 3: SDL-level mouse changes
This part adds support for an absolute pointing device. git-svn-id: https://svn.eduke32.com/eduke32@2623 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
bd8559f6c3
commit
bc70806d32
3 changed files with 42 additions and 9 deletions
|
@ -87,7 +87,7 @@ extern int32_t defaultres[][2];
|
||||||
extern void SetKey(int32_t key, int32_t state);
|
extern void SetKey(int32_t key, int32_t state);
|
||||||
|
|
||||||
// mouse
|
// mouse
|
||||||
extern volatile int32_t mousex, mousey, mouseb;
|
extern volatile int32_t mousex, mousey, mouseb, mouseabsx, mouseabsy;
|
||||||
extern volatile uint8_t mousegrab, moustat;
|
extern volatile uint8_t mousegrab, moustat;
|
||||||
|
|
||||||
// joystick
|
// joystick
|
||||||
|
@ -131,6 +131,7 @@ int32_t initmouse(void);
|
||||||
void uninitmouse(void);
|
void uninitmouse(void);
|
||||||
void grabmouse(char a);
|
void grabmouse(char a);
|
||||||
void readmousexy(int32_t *x, int32_t *y);
|
void readmousexy(int32_t *x, int32_t *y);
|
||||||
|
void readmouseabsxy(int32_t *x, int32_t *y);
|
||||||
void readmousebstatus(int32_t *b);
|
void readmousebstatus(int32_t *b);
|
||||||
void setjoydeadzone(int32_t axis, uint16_t dead, uint16_t satur);
|
void setjoydeadzone(int32_t axis, uint16_t dead, uint16_t satur);
|
||||||
void getjoydeadzone(int32_t axis, uint16_t *dead, uint16_t *satur);
|
void getjoydeadzone(int32_t axis, uint16_t *dead, uint16_t *satur);
|
||||||
|
|
|
@ -16,7 +16,7 @@ char keyasciififo[KEYFIFOSIZ], keyasciififoplc, keyasciififoend;
|
||||||
char remap[256];
|
char remap[256];
|
||||||
int32_t remapinit=0;
|
int32_t remapinit=0;
|
||||||
char key_names[256][24];
|
char key_names[256][24];
|
||||||
volatile int32_t mousex=0,mousey=0,mouseb=0;
|
volatile int32_t mousex=0,mousey=0,mouseb=0,mouseabsx=0,mouseabsy=0;
|
||||||
volatile uint8_t moustat = 0, mousegrab = 0;
|
volatile uint8_t moustat = 0, mousegrab = 0;
|
||||||
int32_t *joyaxis = NULL, joyb=0, *joyhat = NULL;
|
int32_t *joyaxis = NULL, joyb=0, *joyhat = NULL;
|
||||||
char joyisgamepad=0, joynumaxes=0, joynumbuttons=0, joynumhats=0;
|
char joyisgamepad=0, joynumaxes=0, joynumbuttons=0, joynumhats=0;
|
||||||
|
@ -101,6 +101,21 @@ void readmousexy(int32_t *x, int32_t *y)
|
||||||
mousex = mousey = 0;
|
mousex = mousey = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void readmouseabsxy(int32_t *x, int32_t *y)
|
||||||
|
{
|
||||||
|
if (!moustat || !mousegrab || !appactive)
|
||||||
|
{
|
||||||
|
// no mouse, centre it
|
||||||
|
*x = xdim >> 1;
|
||||||
|
*y = ydim >> 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
*x = mouseabsx;
|
||||||
|
*y = mouseabsy;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void readmousebstatus(int32_t *b)
|
void readmousebstatus(int32_t *b)
|
||||||
{
|
{
|
||||||
if (!moustat || !mousegrab || !appactive) { *b = 0; return; }
|
if (!moustat || !mousegrab || !appactive) { *b = 0; return; }
|
||||||
|
|
|
@ -619,6 +619,7 @@ void grabmouse(char a)
|
||||||
mousegrab = a;
|
mousegrab = a;
|
||||||
}
|
}
|
||||||
mousex = mousey = 0;
|
mousex = mousey = 0;
|
||||||
|
mouseabsx = mouseabsy = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -1825,16 +1826,32 @@ int32_t handleevents(void)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SDL_MOUSEMOTION:
|
case SDL_MOUSEMOTION:
|
||||||
// SDL 1.3 doesn't handle relative mouse movement correctly yet as the cursor still clips to the screen edges
|
// SDL <VER> doesn't handle relative mouse movement correctly yet as the cursor still clips to the screen edges
|
||||||
// so, we call SDL_WarpMouse() to center the cursor and ignore the resulting motion event that occurs
|
// so, we call SDL_WarpMouse() to center the cursor and ignore the resulting motion event that occurs
|
||||||
if (appactive && mousegrab && (ev.motion.x != xdim>>1 || ev.motion.y != ydim>>1))
|
// <VER> is 1.3 for PK, 1.2 for tueidj
|
||||||
|
if (appactive && mousegrab)
|
||||||
{
|
{
|
||||||
mousex += ev.motion.xrel;
|
#ifdef GEKKO
|
||||||
mousey += ev.motion.yrel;
|
// check if it's a wiimote pointer pretending to be a mouse
|
||||||
|
if (ev.motion.state & SDL_BUTTON_X2MASK)
|
||||||
#ifndef DEBUGGINGAIDS
|
{
|
||||||
SDL_WarpMouse(xdim>>1, ydim>>1);
|
// the absolute values are used to draw the crosshair
|
||||||
|
mouseabsx = ev.motion.x;
|
||||||
|
mouseabsy = ev.motion.y;
|
||||||
|
// hack: reduce the scale of the "relative" motions
|
||||||
|
// to make it act more like a real mouse
|
||||||
|
ev.motion.xrel /= 16;
|
||||||
|
ev.motion.yrel /= 12;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
if (ev.motion.x != xdim>>1 || ev.motion.y != ydim>>1)
|
||||||
|
{
|
||||||
|
mousex += ev.motion.xrel;
|
||||||
|
mousey += ev.motion.yrel;
|
||||||
|
#ifndef DEBUGGINGAIDS
|
||||||
|
SDL_WarpMouse(xdim>>1, ydim>>1);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue