|
From: Tupone A. <at...@us...> - 2007-02-28 22:20:52
|
Update of /cvsroot/bzflag/bzflag/src/bzflag In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv7383 Modified Files: Tag: v2_0_cs_branch MainWindow.cxx Log Message: Fixed segv when joystick is unplugged Index: MainWindow.cxx =================================================================== RCS file: /cvsroot/bzflag/bzflag/src/bzflag/MainWindow.cxx,v retrieving revision 2.6.2.1.2.3 retrieving revision 2.6.2.1.2.4 diff -w -u -r2.6.2.1.2.3 -r2.6.2.1.2.4 --- MainWindow.cxx 27 Feb 2007 21:13:05 -0000 2.6.2.1.2.3 +++ MainWindow.cxx 28 Feb 2007 22:20:49 -0000 2.6.2.1.2.4 @@ -260,13 +260,18 @@ bool MainWindow::haveJoystick() const { - return true; + return joy; } void MainWindow::getJoyPosition(int& mx, int& my) const { + if (joy) { mx = joy->GetLast(joystickNumber, joystickXAxis); my = joy->GetLast(joystickNumber, joystickYAxis); + } else { + mx = 0; + my = 0; + } mx = ((width >> 1) * mx) / (900); my = ((height >> 1) * my) / (900); } @@ -278,6 +283,9 @@ if (joystickNumber == 255) return 0; + if (!joy) + return 0; + for (int i = 0; i < CS_MAX_JOYSTICK_BUTTONS; i++) buttons |= joy->GetLastButton(joystickNumber, i) << i; |