From: <the...@us...> - 2007-06-27 21:05:05
|
Revision: 76 http://qonk.svn.sourceforge.net/qonk/?rev=76&view=rev Author: thebohemian Date: 2007-06-27 14:04:59 -0700 (Wed, 27 Jun 2007) Log Message: ----------- - fixed mouse/keyboard control co-existence - fixed planet/player initialization - fixed player/planet correctio routines Modified Paths: -------------- branches/input-abstraction-2007-06-12/src/gameoptions.cpp branches/input-abstraction-2007-06-12/src/sdl_driver.cpp branches/input-abstraction-2007-06-12/src/sdl_driver.h branches/input-abstraction-2007-06-12/src/settings.cpp Modified: branches/input-abstraction-2007-06-12/src/gameoptions.cpp =================================================================== --- branches/input-abstraction-2007-06-12/src/gameoptions.cpp 2007-06-27 18:48:36 UTC (rev 75) +++ branches/input-abstraction-2007-06-12/src/gameoptions.cpp 2007-06-27 21:04:59 UTC (rev 76) @@ -16,7 +16,7 @@ GameOptions::GameOptions() : enemyVisibilityAction(0), playersAction(0), planetsAction(0), - startSinglePlayerGameAction(0) + startSinglePlayerGameAction(0), planets(2), players(1) { setPlanets(Settings::getNumberOfPlanets()); setPlayers(Settings::getNumberOfComputerPlayers()); @@ -90,8 +90,8 @@ if (planets < 2) planets = 2; - if (p < players) - planets = players; + if (planets < players + 1) + planets = players + 1; if (planetsAction) planetsAction->update(); @@ -159,11 +159,11 @@ { players = p; - if (players < 0) + if (players <= 0) players = 1; - if (players > planets) - players = planets; + if (players > planets - 1) + players = planets - 1; if (playersAction) playersAction->update(); Modified: branches/input-abstraction-2007-06-12/src/sdl_driver.cpp =================================================================== --- branches/input-abstraction-2007-06-12/src/sdl_driver.cpp 2007-06-27 18:48:36 UTC (rev 75) +++ branches/input-abstraction-2007-06-12/src/sdl_driver.cpp 2007-06-27 21:04:59 UTC (rev 76) @@ -126,11 +126,11 @@ void SDLDriver::loop() { + static MouseState mouseXPos = INITIAL, mouseXNeg = INITIAL; + static MouseState mouseYPos = INITIAL, mouseYNeg = INITIAL; + SDL_Event ev; - bool mouseXPos = false, mouseXNeg = false; - bool mouseYPos = false, mouseYNeg = false; - while(SDL_PollEvent(&ev)) { switch(ev.type) @@ -159,23 +159,23 @@ if (ev.motion.xrel <= -DEADZONE_MOUSE) { input(IT_MOUSEMOTION, 0, AD_NEGATIVE, 0, -ev.motion.xrel); - mouseXNeg = true; + mouseXNeg = MOVED; } else if(ev.motion.xrel >= DEADZONE_MOUSE) { input(IT_MOUSEMOTION, 0, AD_POSITIVE, 0, ev.motion.xrel); - mouseXPos = true; + mouseXPos = MOVED; } if (ev.motion.yrel <= -DEADZONE_MOUSE) { input(IT_MOUSEMOTION, 1, AD_NEGATIVE, 0, -ev.motion.yrel); - mouseYNeg = true; + mouseYNeg = MOVED; } else if(ev.motion.yrel >= DEADZONE_MOUSE) { input(IT_MOUSEMOTION, 1, AD_POSITIVE, 0, ev.motion.yrel); - mouseYPos = true; + mouseYPos = MOVED; } break; @@ -202,21 +202,37 @@ // If mouse has not moved in this input cycle an extra - axis stand still - // input event is transmitted. This makes the relative mouse axis appear more // like a key or joystick axis where releases and non-movement can be detected. - - // TODO: This implementation has a bug: The 'standing still' reporting should - // be done only once after a move. This can probably only be done with two - // bools per axis and direction. :| - if (!mouseXNeg) + if (mouseXNeg == RESET_NEEDED) + { input(IT_MOUSEMOTION, 0, AD_NEGATIVE, 0, 0); + mouseXNeg = INITIAL; + } + else if (mouseXNeg == MOVED) + mouseXNeg = RESET_NEEDED; - if (!mouseXPos) + if (mouseXPos == RESET_NEEDED) + { input(IT_MOUSEMOTION, 0, AD_POSITIVE, 0, 0); + mouseXPos = INITIAL; + } + else if (mouseXPos == MOVED) + mouseXPos = RESET_NEEDED; - if (!mouseYNeg) + if (mouseYNeg == RESET_NEEDED) + { input(IT_MOUSEMOTION, 1, AD_NEGATIVE, 0, 0); + mouseYNeg = INITIAL; + } + else if (mouseYNeg == MOVED) + mouseYNeg = RESET_NEEDED; - if (!mouseYPos) + if (mouseYPos == RESET_NEEDED) + { input(IT_MOUSEMOTION, 1, AD_POSITIVE, 0, 0); + mouseYPos = INITIAL; + } + else if (mouseYPos == MOVED) + mouseYPos = RESET_NEEDED; } Modified: branches/input-abstraction-2007-06-12/src/sdl_driver.h =================================================================== --- branches/input-abstraction-2007-06-12/src/sdl_driver.h 2007-06-27 18:48:36 UTC (rev 75) +++ branches/input-abstraction-2007-06-12/src/sdl_driver.h 2007-06-27 21:04:59 UTC (rev 76) @@ -16,6 +16,8 @@ class SDLDriver { + enum MouseState { INITIAL, MOVED, RESET_NEEDED }; + public: SDLDriver(InputHandler &); Modified: branches/input-abstraction-2007-06-12/src/settings.cpp =================================================================== --- branches/input-abstraction-2007-06-12/src/settings.cpp 2007-06-27 18:48:36 UTC (rev 75) +++ branches/input-abstraction-2007-06-12/src/settings.cpp 2007-06-27 21:04:59 UTC (rev 76) @@ -124,6 +124,7 @@ qonkReader->get("fullscreen", fullscreen); qonkReader->get("planets", numberOfPlanets); + cerr << "read planets: " << numberOfPlanets << endl; qonkReader->get("enemies", numberOfComputerPlayers); qonkReader->get("enemiesVisible", enemyVisibility); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |