diff --git a/src/config/user_config.hpp b/src/config/user_config.hpp index a0f072c39..758b8dd03 100644 --- a/src/config/user_config.hpp +++ b/src/config/user_config.hpp @@ -45,7 +45,8 @@ const int CURRENT_CONFIG_VERSION = 8; #include #include -#include "input/input.hpp" +#include "irrlicht.h" + #include "utils/constants.hpp" #include "utils/no_copy.hpp" #include "utils/ptr_vector.hpp" diff --git a/src/input/input.cpp b/src/input/input.cpp index 688191651..1040a657b 100644 --- a/src/input/input.cpp +++ b/src/input/input.cpp @@ -43,7 +43,16 @@ irr::core::stringw Input::getInputAsString(const Input::InputType type, const in s = "?"; switch(id) - { + { +#ifdef WIN32 + case 186: s=";"; break; + case 191: s="/"; break; + case 192: s="`"; break; + case 219: s="["; break; + case 220: s="\\"; break; + case 221: s="]"; break; + case 222: s="'"; break; +#endif case KEY_LBUTTON : s = "left mouse button"; break; diff --git a/src/input/input.hpp b/src/input/input.hpp index fd4e7753a..74405ede6 100644 --- a/src/input/input.hpp +++ b/src/input/input.hpp @@ -56,13 +56,15 @@ struct Input }; static const int IT_LAST = IT_MOUSEBUTTON; - InputType type; - int deviceID; - int btnID; // or axis ID for gamepads axes - int axisDirection; + InputType m_type; + int m_device_id; + int m_button_id; // or axis ID for gamepads axes + int m_axis_direction; + wchar_t m_character; Input() - : type(IT_NONE), deviceID(0), btnID(0), axisDirection(0) + : m_type(IT_NONE), m_device_id(0), m_button_id(0), + m_axis_direction(0), m_character(0) { // Nothing to do. } @@ -91,7 +93,8 @@ struct Input * to the system. */ Input(InputType ntype, int deviceID , int btnID = 0, int axisDirection= 0) - : type(ntype), deviceID(deviceID), btnID(btnID), axisDirection(axisDirection) + : m_type(ntype), m_device_id(deviceID), m_button_id(btnID), + m_axis_direction(axisDirection) { // Nothing to do. } diff --git a/src/input/input_manager.cpp b/src/input/input_manager.cpp index 95fb0c2e1..5c0940711 100644 --- a/src/input/input_manager.cpp +++ b/src/input/input_manager.cpp @@ -228,10 +228,10 @@ void InputManager::inputSensing(Input::InputType type, int deviceID, int btnID, if (store_new) { - m_sensed_input->type = type; - m_sensed_input->deviceID = deviceID; - m_sensed_input->btnID = btnID; - m_sensed_input->axisDirection = axisDirection; + m_sensed_input->m_type = type; + m_sensed_input->m_device_id = deviceID; + m_sensed_input->m_button_id= btnID; + m_sensed_input->m_axis_direction = axisDirection; if (type == Input::IT_KEYBOARD && value > Input::MAX_VALUE/2) { @@ -240,7 +240,8 @@ void InputManager::inputSensing(Input::InputType type, int deviceID, int btnID, else if (type == Input::IT_KEYBOARD && value == 0) { // only notify on key release - if (m_sensed_input_high_kbd.find(m_sensed_input->btnID) != m_sensed_input_high_kbd.end()) + if (m_sensed_input_high_kbd.find(m_sensed_input->m_button_id) + != m_sensed_input_high_kbd.end()) { OptionsScreenInput2::getInstance()->gotSensedInput(m_sensed_input); return; @@ -282,7 +283,7 @@ void InputManager::inputSensing(Input::InputType type, int deviceID, int btnID, } else if ( abs(value) < Input::MAX_VALUE/8.0f && inverse_id_has_high_value ) { - m_sensed_input->axisDirection = (axisDirection?0:-1); + m_sensed_input->m_axis_direction= (axisDirection?0:-1); OptionsScreenInput2::getInstance()->gotSensedInput(m_sensed_input); } } diff --git a/src/karts/controller/controller.hpp b/src/karts/controller/controller.hpp index 0bb316d71..5251592f1 100644 --- a/src/karts/controller/controller.hpp +++ b/src/karts/controller/controller.hpp @@ -28,6 +28,7 @@ using namespace irr; class Kart; class Item; +enum PlayerAction; /** This is the base class for kart controller - that can be a player * or a a robot. @@ -63,7 +64,7 @@ public: virtual bool isPlayerController () const {return false;} virtual bool isNetworkController() const {return false;} /** Default: ignore actions. Only PlayerController get them. */ - virtual void action (PlayerAction action, int value) {} + virtual void action (const PlayerAction &action, int value) {} virtual const irr::core::stringw& getNamePostfix() const; }; // Controller diff --git a/src/karts/controller/end_controller.cpp b/src/karts/controller/end_controller.cpp index 15454e701..7527d4c15 100644 --- a/src/karts/controller/end_controller.cpp +++ b/src/karts/controller/end_controller.cpp @@ -138,7 +138,7 @@ void EndController::reset() //----------------------------------------------------------------------------- /** The end controller must forward 'fire' presses to the race gui. */ -void EndController::action(PlayerAction action, int value) +void EndController::action(const PlayerAction &action, int value) { if(action!=PA_FIRE) return; RaceResultGUI *race_result_gui = dynamic_cast(World::getWorld()->getRaceGUI()); diff --git a/src/karts/controller/end_controller.hpp b/src/karts/controller/end_controller.hpp index fc7c071b1..bec8d9128 100644 --- a/src/karts/controller/end_controller.hpp +++ b/src/karts/controller/end_controller.hpp @@ -83,7 +83,7 @@ public: * controller. This way e.g. highscores can still be assigned * to the right player. */ virtual bool isPlayerController () const {return m_player!=NULL;} - virtual void action (PlayerAction action, int value); + virtual void action (const PlayerAction &action, int value); }; // EndKart diff --git a/src/karts/controller/player_controller.cpp b/src/karts/controller/player_controller.cpp index 4325db587..7dda7a2f9 100644 --- a/src/karts/controller/player_controller.cpp +++ b/src/karts/controller/player_controller.cpp @@ -113,7 +113,7 @@ void PlayerController::resetInputState() * and if it's 0 it indicates that the corresponding button * was released. */ -void PlayerController::action(PlayerAction action, int value) +void PlayerController::action(const PlayerAction &action, int value) { switch (action) { diff --git a/src/karts/controller/player_controller.hpp b/src/karts/controller/player_controller.hpp index 326f0b026..c22697c81 100644 --- a/src/karts/controller/player_controller.hpp +++ b/src/karts/controller/player_controller.hpp @@ -51,7 +51,7 @@ public: unsigned int player_index); ~PlayerController (); void update (float); - void action (PlayerAction action, int value); + void action (const PlayerAction &action, int value); void handleZipper (); void collectedItem (const Item &item, int add_info=-1, float previous_energy=0); diff --git a/src/states_screens/options_screen_input2.cpp b/src/states_screens/options_screen_input2.cpp index 09fa99ed8..deba75dcb 100644 --- a/src/states_screens/options_screen_input2.cpp +++ b/src/states_screens/options_screen_input2.cpp @@ -266,9 +266,9 @@ static std::string binding_to_set_button; void OptionsScreenInput2::gotSensedInput(Input* sensedInput) { const bool keyboard = (m_config->getType() == DEVICE_CONFIG_TYPE_KEYBOARD && - sensedInput->type == Input::IT_KEYBOARD); - const bool gamepad = (sensedInput->type == Input::IT_STICKMOTION || - sensedInput->type == Input::IT_STICKBUTTON) && + sensedInput->m_type == Input::IT_KEYBOARD); + const bool gamepad = (sensedInput->m_type == Input::IT_STICKMOTION || + sensedInput->m_type == Input::IT_STICKBUTTON) && m_config->getType() == DEVICE_CONFIG_TYPE_GAMEPAD; if (keyboard) @@ -276,11 +276,13 @@ void OptionsScreenInput2::gotSensedInput(Input* sensedInput) if (UserConfigParams::m_verbosity>=5) { std::cout << "% Binding " << KartActionStrings[binding_to_set] - << " : setting to keyboard key " << sensedInput->btnID << " \n\n"; + << " : setting to keyboard key " << sensedInput->m_button_id + << " \n\n"; } KeyboardConfig* keyboard = (KeyboardConfig*)m_config; - keyboard->setBinding(binding_to_set, Input::IT_KEYBOARD, sensedInput->btnID, Input::AD_NEUTRAL); + keyboard->setBinding(binding_to_set, Input::IT_KEYBOARD, + sensedInput->m_button_id, Input::AD_NEUTRAL); // refresh display updateInputButtons(); @@ -290,16 +292,19 @@ void OptionsScreenInput2::gotSensedInput(Input* sensedInput) if (UserConfigParams::m_verbosity>=5) { std::cout << "% Binding " << KartActionStrings[binding_to_set] - << " : setting to gamepad #" << sensedInput->deviceID << " : "; + << " : setting to gamepad #" + << sensedInput->m_device_id<< " : "; - if (sensedInput->type == Input::IT_STICKMOTION) + if (sensedInput->m_type == Input::IT_STICKMOTION) { - std::cout << "axis " << sensedInput->btnID << " direction " - << (sensedInput->axisDirection == Input::AD_NEGATIVE ? "-" : "+") << "\n\n"; + std::cout << "axis " << sensedInput->m_button_id<< " direction " + << (sensedInput->m_axis_direction== Input::AD_NEGATIVE + ? "-" : "+") + << "\n\n"; } - else if (sensedInput->type == Input::IT_STICKBUTTON) + else if (sensedInput->m_type == Input::IT_STICKBUTTON) { - std::cout << "button " << sensedInput->btnID << "\n\n"; + std::cout << "button " << sensedInput->m_button_id<< "\n\n"; } else { @@ -308,8 +313,9 @@ void OptionsScreenInput2::gotSensedInput(Input* sensedInput) } GamepadConfig* config = (GamepadConfig*)m_config; - config->setBinding(binding_to_set, sensedInput->type, sensedInput->btnID, - (Input::AxisDirection)sensedInput->axisDirection); + config->setBinding(binding_to_set, sensedInput->m_type, + sensedInput->m_button_id, + (Input::AxisDirection)sensedInput->m_axis_direction); // refresh display updateInputButtons(); diff --git a/src/utils/constants.hpp b/src/utils/constants.hpp index ab13681cc..0b8eff842 100644 --- a/src/utils/constants.hpp +++ b/src/utils/constants.hpp @@ -43,12 +43,9 @@ # define M_PI 3.14159265358979323846f /* As in Linux's math.h */ #endif -/* And we want float for everyone, not double */ -const float M_PIf = 4.0f*atanf(1.0f); - -#define NINETY_DEGREE_RAD (M_PIf/2.0f) -#define DEGREE_TO_RAD (M_PIf/180.0f) -#define RAD_TO_DEGREE (180.0f/M_PIf) +#define NINETY_DEGREE_RAD (M_PI/2.0f) +#define DEGREE_TO_RAD (M_PI/180.0f) +#define RAD_TO_DEGREE (180.0f/M_PI) const int MAX_PLAYER_COUNT = 4;