mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2024-12-23 01:59:43 +01:00
Remove duplicate game.controllerSensitivity proxy
It wasn't a direct duplicate of key.sensitivity, but it was still basically the same thing. Although to be fair, at least the case-switch conversion didn't get duplicated everywhere unlike game.slowdown. So now key.sensitivity functions the same as game.controllerSensitivity, and it only gets converted to its actual value whenever a joystick input happens in key.Poll(), unlike previously where it got converted every single frame on the title screen (there was even a comment that said "TODO bit wasteful doing this every poll").
This commit is contained in:
parent
bc9dff8c2a
commit
fb19787489
6 changed files with 32 additions and 37 deletions
|
@ -12,6 +12,7 @@
|
||||||
#include "Enums.h"
|
#include "Enums.h"
|
||||||
#include "FileSystemUtils.h"
|
#include "FileSystemUtils.h"
|
||||||
#include "Graphics.h"
|
#include "Graphics.h"
|
||||||
|
#include "KeyPoll.h"
|
||||||
#include "MakeAndPlay.h"
|
#include "MakeAndPlay.h"
|
||||||
#include "Map.h"
|
#include "Map.h"
|
||||||
#include "Music.h"
|
#include "Music.h"
|
||||||
|
@ -172,9 +173,6 @@ void Game::init(void)
|
||||||
noflashingmode = false;
|
noflashingmode = false;
|
||||||
slowdown = 30;
|
slowdown = 30;
|
||||||
|
|
||||||
// 0..5
|
|
||||||
controllerSensitivity = 2;
|
|
||||||
|
|
||||||
nodeathmode = false;
|
nodeathmode = false;
|
||||||
nocutscenes = false;
|
nocutscenes = false;
|
||||||
|
|
||||||
|
@ -4704,7 +4702,7 @@ void Game::deserializesettings(tinyxml2::XMLElement* dataNode, ScreenSettings* s
|
||||||
|
|
||||||
if (pKey == "controllerSensitivity")
|
if (pKey == "controllerSensitivity")
|
||||||
{
|
{
|
||||||
controllerSensitivity = help.Int(pText);
|
key.sensitivity = help.Int(pText);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -4942,7 +4940,7 @@ void Game::serializesettings(tinyxml2::XMLElement* dataNode)
|
||||||
dataNode->LinkEndChild(msg);
|
dataNode->LinkEndChild(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
xml::update_tag(dataNode, "controllerSensitivity", controllerSensitivity);
|
xml::update_tag(dataNode, "controllerSensitivity", key.sensitivity);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Game::loadsettings(ScreenSettings* screen_settings)
|
void Game::loadsettings(ScreenSettings* screen_settings)
|
||||||
|
|
|
@ -366,8 +366,6 @@ public:
|
||||||
bool savemystats;
|
bool savemystats;
|
||||||
|
|
||||||
|
|
||||||
int controllerSensitivity;
|
|
||||||
|
|
||||||
bool quickrestartkludge;
|
bool quickrestartkludge;
|
||||||
|
|
||||||
//Custom stuff
|
//Custom stuff
|
||||||
|
|
|
@ -1238,11 +1238,11 @@ void menuactionpress()
|
||||||
switch (game.currentmenuoption)
|
switch (game.currentmenuoption)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
game.controllerSensitivity++;
|
key.sensitivity++;
|
||||||
music.playef(11);
|
music.playef(11);
|
||||||
if(game.controllerSensitivity > 4)
|
if(key.sensitivity > 4)
|
||||||
{
|
{
|
||||||
game.controllerSensitivity = 0;
|
key.sensitivity = 0;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -1595,9 +1595,6 @@ void titleinput()
|
||||||
//game.mx = (mouseX / 4);
|
//game.mx = (mouseX / 4);
|
||||||
//game.my = (mouseY / 4);
|
//game.my = (mouseY / 4);
|
||||||
|
|
||||||
//TODO bit wasteful doing this every poll
|
|
||||||
key.setSensitivity(game.controllerSensitivity);
|
|
||||||
|
|
||||||
game.press_left = false;
|
game.press_left = false;
|
||||||
game.press_right = false;
|
game.press_right = false;
|
||||||
game.press_action = false;
|
game.press_action = false;
|
||||||
|
|
|
@ -9,34 +9,32 @@
|
||||||
#include "Graphics.h"
|
#include "Graphics.h"
|
||||||
#include "Music.h"
|
#include "Music.h"
|
||||||
|
|
||||||
void KeyPoll::setSensitivity(int _value)
|
int inline KeyPoll::getThreshold()
|
||||||
{
|
{
|
||||||
switch (_value)
|
switch (sensitivity)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
sensitivity = 28000;
|
return 28000;
|
||||||
break;
|
case 1:
|
||||||
case 1:
|
return 16000;
|
||||||
sensitivity = 16000;
|
case 2:
|
||||||
break;
|
return 8000;
|
||||||
case 2:
|
case 3:
|
||||||
sensitivity = 8000;
|
return 4000;
|
||||||
break;
|
case 4:
|
||||||
case 3:
|
return 2000;
|
||||||
sensitivity = 4000;
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
sensitivity = 2000;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return 8000;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
KeyPoll::KeyPoll()
|
KeyPoll::KeyPoll()
|
||||||
{
|
{
|
||||||
xVel = 0;
|
xVel = 0;
|
||||||
yVel = 0;
|
yVel = 0;
|
||||||
setSensitivity(2);
|
// 0..5
|
||||||
|
sensitivity = 2;
|
||||||
|
|
||||||
quitProgram = 0;
|
quitProgram = 0;
|
||||||
keybuffer="";
|
keybuffer="";
|
||||||
|
@ -199,11 +197,13 @@ void KeyPoll::Poll()
|
||||||
buttonmap[(SDL_GameControllerButton) evt.cbutton.button] = false;
|
buttonmap[(SDL_GameControllerButton) evt.cbutton.button] = false;
|
||||||
break;
|
break;
|
||||||
case SDL_CONTROLLERAXISMOTION:
|
case SDL_CONTROLLERAXISMOTION:
|
||||||
|
{
|
||||||
|
const int threshold = getThreshold();
|
||||||
switch (evt.caxis.axis)
|
switch (evt.caxis.axis)
|
||||||
{
|
{
|
||||||
case SDL_CONTROLLER_AXIS_LEFTX:
|
case SDL_CONTROLLER_AXIS_LEFTX:
|
||||||
if ( evt.caxis.value > -sensitivity &&
|
if ( evt.caxis.value > -threshold &&
|
||||||
evt.caxis.value < sensitivity )
|
evt.caxis.value < threshold )
|
||||||
{
|
{
|
||||||
xVel = 0;
|
xVel = 0;
|
||||||
}
|
}
|
||||||
|
@ -213,8 +213,8 @@ void KeyPoll::Poll()
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SDL_CONTROLLER_AXIS_LEFTY:
|
case SDL_CONTROLLER_AXIS_LEFTY:
|
||||||
if ( evt.caxis.value > -sensitivity &&
|
if ( evt.caxis.value > -threshold &&
|
||||||
evt.caxis.value < sensitivity )
|
evt.caxis.value < threshold )
|
||||||
{
|
{
|
||||||
yVel = 0;
|
yVel = 0;
|
||||||
}
|
}
|
||||||
|
@ -225,6 +225,7 @@ void KeyPoll::Poll()
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case SDL_CONTROLLERDEVICEADDED:
|
case SDL_CONTROLLERDEVICEADDED:
|
||||||
{
|
{
|
||||||
SDL_GameController *toOpen = SDL_GameControllerOpen(evt.cdevice.which);
|
SDL_GameController *toOpen = SDL_GameControllerOpen(evt.cdevice.which);
|
||||||
|
|
|
@ -42,7 +42,7 @@ public:
|
||||||
|
|
||||||
int sensitivity;
|
int sensitivity;
|
||||||
|
|
||||||
void setSensitivity(int _value);
|
int inline getThreshold();
|
||||||
|
|
||||||
KeyPoll();
|
KeyPoll();
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
#include "Entity.h"
|
#include "Entity.h"
|
||||||
#include "FileSystemUtils.h"
|
#include "FileSystemUtils.h"
|
||||||
#include "Graphics.h"
|
#include "Graphics.h"
|
||||||
|
#include "KeyPoll.h"
|
||||||
#include "MakeAndPlay.h"
|
#include "MakeAndPlay.h"
|
||||||
#include "Map.h"
|
#include "Map.h"
|
||||||
#include "Maths.h"
|
#include "Maths.h"
|
||||||
|
@ -410,7 +411,7 @@ void menurender()
|
||||||
switch (game.currentmenuoption)
|
switch (game.currentmenuoption)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
switch(game.controllerSensitivity)
|
switch(key.sensitivity)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
graphics.Print( -1, 85, " Low Medium High", tr, tg, tb, true);
|
graphics.Print( -1, 85, " Low Medium High", tr, tg, tb, true);
|
||||||
|
|
Loading…
Reference in a new issue