diff options
| author | SND\weimingzhi_cp <SND\weimingzhi_cp@e17a0e51-4ae3-4d35-97c3-1a29b211df97> | 2010-08-01 11:11:29 +0000 |
|---|---|---|
| committer | SND\weimingzhi_cp <SND\weimingzhi_cp@e17a0e51-4ae3-4d35-97c3-1a29b211df97> | 2010-08-01 11:11:29 +0000 |
| commit | 3f7356f6f3b1825d53e41abe52aa4f16434ca75d (patch) | |
| tree | 6748ea78874d8359e472a9894a2321efd5ca06eb /macosx/plugins/DFInput | |
| parent | 8bca7a2d9797c2b0546895f5e62fc05b38183468 (diff) | |
| download | pcsxr-3f7356f6f3b1825d53e41abe52aa4f16434ca75d.tar.gz | |
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
Diffstat (limited to 'macosx/plugins/DFInput')
| -rw-r--r-- | macosx/plugins/DFInput/DFInput.xcodeproj/project.pbxproj | 1 | ||||
| -rw-r--r-- | macosx/plugins/DFInput/macsrc/MappingCell.m | 2 | ||||
| -rw-r--r-- | macosx/plugins/DFInput/macsrc/cfg.c | 32 | ||||
| -rw-r--r-- | macosx/plugins/DFInput/macsrc/cfg.h | 1 |
4 files changed, 32 insertions, 4 deletions
diff --git a/macosx/plugins/DFInput/DFInput.xcodeproj/project.pbxproj b/macosx/plugins/DFInput/DFInput.xcodeproj/project.pbxproj index 416142b2..35a8d87e 100644 --- a/macosx/plugins/DFInput/DFInput.xcodeproj/project.pbxproj +++ b/macosx/plugins/DFInput/DFInput.xcodeproj/project.pbxproj @@ -516,6 +516,7 @@ ../../../libpcsxcore, ../.., ../../../plugins/dfinput, + ../../../plugins/dfinput, ../../../../plugins/dfinput, ./SDL, ./SDL/include, diff --git a/macosx/plugins/DFInput/macsrc/MappingCell.m b/macosx/plugins/DFInput/macsrc/MappingCell.m index 812adf42..0fb43bd1 100644 --- a/macosx/plugins/DFInput/macsrc/MappingCell.m +++ b/macosx/plugins/DFInput/macsrc/MappingCell.m @@ -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]; diff --git a/macosx/plugins/DFInput/macsrc/cfg.c b/macosx/plugins/DFInput/macsrc/cfg.c index f9b897b8..9465426c 100644 --- a/macosx/plugins/DFInput/macsrc/cfg.c +++ b/macosx/plugins/DFInput/macsrc/cfg.c @@ -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++) { diff --git a/macosx/plugins/DFInput/macsrc/cfg.h b/macosx/plugins/DFInput/macsrc/cfg.h index 232ed9c6..99bc103d 100644 --- a/macosx/plugins/DFInput/macsrc/cfg.h +++ b/macosx/plugins/DFInput/macsrc/cfg.h @@ -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); |
