dfinput: only accept axis input when the current axis position is off enough from previous or initial position in config dialog box.
git-svn-id: https://pcsxr.svn.codeplex.com/svn/pcsxr@55344 e17a0e51-4ae3-4d35-97c3-1a29b211df97
This commit is contained in:
parent
8bca7a2d97
commit
3f7356f6f3
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
|||
August 1, 2010 Wei Mingzhi <whistler_wmz@users.sf.net>
|
||||
|
||||
* plugins/dfinput/cfg-gtk2.c: Only accept axis input if the current axis
|
||||
position is off enough from the previous position or initial position.
|
||||
* macosx/plugins/DFInput/macsrc/cfg.c: Likewise.
|
||||
* macosx/plugins/DFInput/macsrc/cfg.h: Likewise.
|
||||
* macosx/plugins/DFInput/macsrc/MappingCell.m: Likewise.
|
||||
* macosx/plugins/DFInput/DFInput.xcodeproj/project.pbxproj: Fixed compile
|
||||
error.
|
||||
|
||||
July 31, 2010 Wei Mingzhi <whistler_wmz@users.sf.net>
|
||||
|
||||
* plugins/dfsound/spu.c: Silenced warning on Mac OS X and FreeBSD.
|
||||
|
|
|
@ -516,6 +516,7 @@
|
|||
../../../libpcsxcore,
|
||||
../..,
|
||||
../../../plugins/dfinput,
|
||||
../../../plugins/dfinput,
|
||||
../../../../plugins/dfinput,
|
||||
./SDL,
|
||||
./SDL/include,
|
||||
|
|
|
@ -48,6 +48,8 @@
|
|||
/* delay for a little while to allow user to release the button pressed to activate the element */
|
||||
[NSThread sleepUntilDate:[NSDate dateWithTimeIntervalSinceNow:0.15]];
|
||||
|
||||
InitAxisPos(whichPad);
|
||||
|
||||
/* wait for 10 seconds for user to press a key */
|
||||
for (i = 0; i < 10; i++) {
|
||||
[NSApp runModalSession:session];
|
||||
|
|
|
@ -559,6 +559,28 @@ int CheckKeyDown() {
|
|||
return 0;
|
||||
}
|
||||
|
||||
static Sint16 InitialAxisPos[256], PrevAxisPos[256];
|
||||
|
||||
#define NUM_AXES(js) (SDL_JoystickNumAxes(js) > 256 ? 256 : SDL_JoystickNumAxes(js))
|
||||
|
||||
void InitAxisPos(int padnum) {
|
||||
int i;
|
||||
SDL_Joystick *js;
|
||||
|
||||
if (g.cfg.PadDef[padnum].DevNum >= 0) {
|
||||
js = SDL_JoystickOpen(g.cfg.PadDef[padnum].DevNum);
|
||||
SDL_JoystickEventState(SDL_IGNORE);
|
||||
} else return;
|
||||
|
||||
SDL_JoystickUpdate();
|
||||
|
||||
for (i = 0; i < NUM_AXES(js); i++) {
|
||||
InitialAxisPos[i] = PrevAxisPos[i] = SDL_JoystickGetAxis(js, i);
|
||||
}
|
||||
|
||||
SDL_JoystickClose(js);
|
||||
}
|
||||
|
||||
int ReadDKeyEvent(int padnum, int key) {
|
||||
SDL_Joystick *js;
|
||||
int i, changed = 0, t;
|
||||
|
@ -585,14 +607,15 @@ int ReadDKeyEvent(int padnum, int key) {
|
|||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < SDL_JoystickNumAxes(js); i++) {
|
||||
for (i = 0; i < NUM_AXES(js); i++) {
|
||||
axis = SDL_JoystickGetAxis(js, i);
|
||||
if (abs(axis) > 16383) {
|
||||
if (abs(axis) > 16383 && (abs(axis - PrevAxisPos[i]) > 4096 || abs(axis - InitialAxisPos[i]) > 4096)) {
|
||||
g.cfg.PadDef[padnum].KeyDef[key].JoyEvType = AXIS;
|
||||
g.cfg.PadDef[padnum].KeyDef[key].J.Axis = (i + 1) * (axis > 0 ? 1 : -1);
|
||||
changed = 1;
|
||||
goto end;
|
||||
}
|
||||
PrevAxisPos[i] = axis;
|
||||
}
|
||||
|
||||
for (i = 0; i < SDL_JoystickNumHats(js); i++) {
|
||||
|
@ -667,14 +690,15 @@ int ReadAnalogEvent(int padnum, int analognum, int analogdir) {
|
|||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < SDL_JoystickNumAxes(js); i++) {
|
||||
for (i = 0; i < NUM_AXES(js); i++) {
|
||||
axis = SDL_JoystickGetAxis(js, i);
|
||||
if (abs(axis) > 16383) {
|
||||
if (abs(axis) > 16383 && (abs(axis - PrevAxisPos[i]) > 4096 || abs(axis - InitialAxisPos[i]) > 4096)) {
|
||||
g.cfg.PadDef[padnum].AnalogDef[analognum][analogdir].JoyEvType = AXIS;
|
||||
g.cfg.PadDef[padnum].AnalogDef[analognum][analogdir].J.Axis = (i + 1) * (axis > 0 ? 1 : -1);
|
||||
changed = 1;
|
||||
goto end;
|
||||
}
|
||||
PrevAxisPos[i] = axis;
|
||||
}
|
||||
|
||||
for (i = 0; i < SDL_JoystickNumHats(js); i++) {
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
|
||||
void GetKeyDescription(char *buf, int joynum, int key);
|
||||
void GetAnalogDescription(char *buf, int joynum, int analognum, int dir);
|
||||
void InitAxisPos(int padnum);
|
||||
int ReadDKeyEvent(int padnum, int key);
|
||||
int ReadAnalogEvent(int padnum, int analognum, int analogdir);
|
||||
|
||||
|
|
|
@ -325,11 +325,20 @@ static void ReadDKeyEvent(int padnum, int key) {
|
|||
time_t t;
|
||||
GdkEvent *ge;
|
||||
int i;
|
||||
Sint16 axis;
|
||||
Sint16 axis, numAxes = 0, InitAxisPos[256], PrevAxisPos[256];
|
||||
|
||||
if (g.cfg.PadDef[padnum].DevNum >= 0) {
|
||||
js = SDL_JoystickOpen(g.cfg.PadDef[padnum].DevNum);
|
||||
SDL_JoystickEventState(SDL_IGNORE);
|
||||
|
||||
SDL_JoystickUpdate();
|
||||
|
||||
numAxes = SDL_JoystickNumAxes(js);
|
||||
if (numAxes > 256) numAxes = 256;
|
||||
|
||||
for (i = 0; i < numAxes; i++) {
|
||||
InitAxisPos[i] = PrevAxisPos[i] = SDL_JoystickGetAxis(js, i);
|
||||
}
|
||||
} else {
|
||||
js = NULL;
|
||||
}
|
||||
|
@ -349,13 +358,14 @@ static void ReadDKeyEvent(int padnum, int key) {
|
|||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < SDL_JoystickNumAxes(js); i++) {
|
||||
for (i = 0; i < numAxes; i++) {
|
||||
axis = SDL_JoystickGetAxis(js, i);
|
||||
if (abs(axis) > 16383) {
|
||||
if (abs(axis) > 16383 && (abs(axis - InitAxisPos[i]) > 4096 || abs(axis - PrevAxisPos[i]) > 4096)) {
|
||||
g.cfg.PadDef[padnum].KeyDef[key].JoyEvType = AXIS;
|
||||
g.cfg.PadDef[padnum].KeyDef[key].J.Axis = (i + 1) * (axis > 0 ? 1 : -1);
|
||||
goto end;
|
||||
}
|
||||
PrevAxisPos[i] = axis;
|
||||
}
|
||||
|
||||
for (i = 0; i < SDL_JoystickNumHats(js); i++) {
|
||||
|
@ -404,11 +414,20 @@ static void ReadAnalogEvent(int padnum, int analognum, int analogdir) {
|
|||
time_t t;
|
||||
GdkEvent *ge;
|
||||
int i;
|
||||
Sint16 axis;
|
||||
Sint16 axis, numAxes = 0, InitAxisPos[256], PrevAxisPos[256];
|
||||
|
||||
if (g.cfg.PadDef[padnum].DevNum >= 0) {
|
||||
js = SDL_JoystickOpen(g.cfg.PadDef[padnum].DevNum);
|
||||
SDL_JoystickEventState(SDL_IGNORE);
|
||||
|
||||
SDL_JoystickUpdate();
|
||||
|
||||
numAxes = SDL_JoystickNumAxes(js);
|
||||
if (numAxes > 256) numAxes = 256;
|
||||
|
||||
for (i = 0; i < SDL_JoystickNumAxes(js); i++) {
|
||||
InitAxisPos[i] = PrevAxisPos[i] = SDL_JoystickGetAxis(js, i);
|
||||
}
|
||||
} else {
|
||||
js = NULL;
|
||||
}
|
||||
|
@ -428,13 +447,14 @@ static void ReadAnalogEvent(int padnum, int analognum, int analogdir) {
|
|||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < SDL_JoystickNumAxes(js); i++) {
|
||||
for (i = 0; i < numAxes; i++) {
|
||||
axis = SDL_JoystickGetAxis(js, i);
|
||||
if (abs(axis) > 16383) {
|
||||
if (abs(axis) > 16383 && (abs(axis - InitAxisPos[i]) > 4096 || abs(axis - PrevAxisPos[i]) > 4096)) {
|
||||
g.cfg.PadDef[padnum].AnalogDef[analognum][analogdir].JoyEvType = AXIS;
|
||||
g.cfg.PadDef[padnum].AnalogDef[analognum][analogdir].J.Axis = (i + 1) * (axis > 0 ? 1 : -1);
|
||||
goto end;
|
||||
}
|
||||
PrevAxisPos[i] = axis;
|
||||
}
|
||||
|
||||
for (i = 0; i < SDL_JoystickNumHats(js); i++) {
|
||||
|
|
Loading…
Reference in New Issue