Re: [TuxKart-devel] Re: [Tuxkart-cvs] tuxkart/src WidgetSet.cxx,1.8,1.9
Status: Alpha
Brought to you by:
sjbaker
From: r. m. <anj...@ya...> - 2004-08-22 22:43:29
|
--- James Gregory <jam...@bt...> wrote: > On Sun, 2004-08-22 at 06:51, > tux...@li... > wrote: > > Update of /cvsroot/tuxkart/tuxkart/src > > In directory > sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23256/src > > > > Modified Files: > > WidgetSet.cxx > > Log Message: > > %1 > > > > Index: WidgetSet.cxx > > > =================================================================== > /* Find a new active widget in the direction > of > joystick motion. */ > > - if (x && -JOY_MID <= x && x <= +JOY_MID) > + if (!x || -JOY_MID <= x && x <= +JOY_MID) > The reason that it originally checked to make sure x > was true is that a > value of 0 for an axis doesn't mean "stick is > central", rather it means > "the motion event was not in this axis". > > See sdldrv.cxx: > > int x = 0; > int y = 0; > > if (event.jaxis.axis == 0) > x = event.jaxis.value; > else if (event.jaxis.axis == 1) > y = event.jaxis.value; > if (gui) > gui -> stick ( x, y ); > > N.B. even a value of 0 did mean "stick is central" > then testing for !x > would still be pointless, as unless you have some > very > crazy constants > when x == 0 then -JOY_MID <= x && x <= +JOY_MID will > always be true. > > James checking for x/y == 0 is necessary for digital sticks/pads to work properly (because they jump from 0 to +/-maximum) otherwise you get a single movement out of them before they go dead. and yes, if x/y is 0 then it will be between -JOY_MID and +JOY_MID, but when x/y isn't 0 we still need the old test for better analog support (stick doesn't have to go all the way back to center). in my testing w/ the if(!y || -JOY_MID <= y && y <= +JOY_MID) i had no side-effects w/ analog support and the digital worked fine if you have a fix for digital pad support you like better, i'm certainly ok w/ it. -paul __________________________________ Do you Yahoo!? New and Improved Yahoo! Mail - Send 10MB messages! http://promotions.yahoo.com/new_mail |