Fixed potential dropped events under DirectInput
--HG-- extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%40537
This commit is contained in:
parent
c78b556d00
commit
6083c21174
1 changed files with 22 additions and 1 deletions
|
@ -49,7 +49,7 @@ static char rcsid =
|
||||||
|
|
||||||
/* The keyboard and mouse device input */
|
/* The keyboard and mouse device input */
|
||||||
#define MAX_INPUTS 16 /* Maximum of 16-1 input devices */
|
#define MAX_INPUTS 16 /* Maximum of 16-1 input devices */
|
||||||
#define INPUT_QSIZE 32 /* Buffer up to 32 input messages */
|
#define INPUT_QSIZE 512 /* Buffer up to 512 input messages */
|
||||||
|
|
||||||
static LPDIRECTINPUT dinput = NULL;
|
static LPDIRECTINPUT dinput = NULL;
|
||||||
static LPDIRECTINPUTDEVICE2 SDL_DIdev[MAX_INPUTS];
|
static LPDIRECTINPUTDEVICE2 SDL_DIdev[MAX_INPUTS];
|
||||||
|
@ -275,6 +275,7 @@ static void handle_mouse(const int numevents, DIDEVICEOBJECTDATA *ptrbuf)
|
||||||
Sint16 xrel, yrel;
|
Sint16 xrel, yrel;
|
||||||
Uint8 state;
|
Uint8 state;
|
||||||
Uint8 button;
|
Uint8 button;
|
||||||
|
DWORD timestamp = 0;
|
||||||
|
|
||||||
/* If we are in windowed mode, Windows is taking care of the mouse */
|
/* If we are in windowed mode, Windows is taking care of the mouse */
|
||||||
if ( (SDL_PublicSurface->flags & SDL_OPENGL) ||
|
if ( (SDL_PublicSurface->flags & SDL_OPENGL) ||
|
||||||
|
@ -363,9 +364,27 @@ static void handle_mouse(const int numevents, DIDEVICEOBJECTDATA *ptrbuf)
|
||||||
for ( i=0; i<(int)numevents; ++i ) {
|
for ( i=0; i<(int)numevents; ++i ) {
|
||||||
switch (ptrbuf[i].dwOfs) {
|
switch (ptrbuf[i].dwOfs) {
|
||||||
case DIMOFS_X:
|
case DIMOFS_X:
|
||||||
|
if ( timestamp != ptrbuf[i].dwTimeStamp ) {
|
||||||
|
if ( xrel || yrel ) {
|
||||||
|
posted = SDL_PrivateMouseMotion(
|
||||||
|
0, 1, xrel, yrel);
|
||||||
|
xrel = 0;
|
||||||
|
yrel = 0;
|
||||||
|
}
|
||||||
|
timestamp = ptrbuf[i].dwTimeStamp;
|
||||||
|
}
|
||||||
xrel += (Sint16)ptrbuf[i].dwData;
|
xrel += (Sint16)ptrbuf[i].dwData;
|
||||||
break;
|
break;
|
||||||
case DIMOFS_Y:
|
case DIMOFS_Y:
|
||||||
|
if ( timestamp != ptrbuf[i].dwTimeStamp ) {
|
||||||
|
if ( xrel || yrel ) {
|
||||||
|
posted = SDL_PrivateMouseMotion(
|
||||||
|
0, 1, xrel, yrel);
|
||||||
|
xrel = 0;
|
||||||
|
yrel = 0;
|
||||||
|
}
|
||||||
|
timestamp = ptrbuf[i].dwTimeStamp;
|
||||||
|
}
|
||||||
yrel += (Sint16)ptrbuf[i].dwData;
|
yrel += (Sint16)ptrbuf[i].dwData;
|
||||||
break;
|
break;
|
||||||
case DIMOFS_Z:
|
case DIMOFS_Z:
|
||||||
|
@ -375,6 +394,7 @@ static void handle_mouse(const int numevents, DIDEVICEOBJECTDATA *ptrbuf)
|
||||||
xrel = 0;
|
xrel = 0;
|
||||||
yrel = 0;
|
yrel = 0;
|
||||||
}
|
}
|
||||||
|
timestamp = 0;
|
||||||
if((int)ptrbuf[i].dwData > 0)
|
if((int)ptrbuf[i].dwData > 0)
|
||||||
button = SDL_BUTTON_WHEELUP;
|
button = SDL_BUTTON_WHEELUP;
|
||||||
else
|
else
|
||||||
|
@ -394,6 +414,7 @@ static void handle_mouse(const int numevents, DIDEVICEOBJECTDATA *ptrbuf)
|
||||||
xrel = 0;
|
xrel = 0;
|
||||||
yrel = 0;
|
yrel = 0;
|
||||||
}
|
}
|
||||||
|
timestamp = 0;
|
||||||
button = (Uint8)(ptrbuf[i].dwOfs-DIMOFS_BUTTON0)+1;
|
button = (Uint8)(ptrbuf[i].dwOfs-DIMOFS_BUTTON0)+1;
|
||||||
/* Button #2 on two button mice is button 3
|
/* Button #2 on two button mice is button 3
|
||||||
(the middle button is button 2)
|
(the middle button is button 2)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue