compatibility with new version of input
This commit is contained in:
parent
8d3b0b527c
commit
36cce4e79c
@ -1,6 +0,0 @@
|
|||||||
#include "defaultkeysmap.h"
|
|
||||||
|
|
||||||
//DefaultKeysMap::DefaultKeysMap()
|
|
||||||
//{
|
|
||||||
|
|
||||||
//}
|
|
@ -12,37 +12,60 @@ public:
|
|||||||
EXIT_GAME,LAST_DEFAULT_ACTION};
|
EXIT_GAME,LAST_DEFAULT_ACTION};
|
||||||
|
|
||||||
DefaultKeysMap(){
|
DefaultKeysMap(){
|
||||||
keys.push_back( {MAIN_ACTION, sf::Keyboard::KeyCount + sf::Mouse::Left, IKeysMap::PRESSED} );
|
keys.push_back( {{MAIN_ACTION,input::MOUSE}, sf::Mouse::Left, IKeysMap::PRESSED} );
|
||||||
keys.push_back( {SECONDARY_ACTION, sf::Keyboard::KeyCount + sf::Mouse::Right, IKeysMap::PRESSED} );
|
keys.push_back( {{SECONDARY_ACTION,input::MOUSE}, sf::Mouse::Right, IKeysMap::PRESSED} );
|
||||||
keys.push_back( {TERTIARY_ACTION, sf::Keyboard::KeyCount + sf::Mouse::Middle, IKeysMap::PRESSED} );
|
keys.push_back( {{TERTIARY_ACTION,input::MOUSE}, sf::Mouse::Middle, IKeysMap::PRESSED} );
|
||||||
keys.push_back( {MOVE_FORWARD, sf::Keyboard::Z, IKeysMap::HOLD} );
|
keys.push_back( {{MOVE_FORWARD,input::KEYBOARD}, sf::Keyboard::Z, IKeysMap::HOLD} );
|
||||||
keys.push_back( {MOVE_BACKWARD, sf::Keyboard::S, IKeysMap::HOLD} );
|
keys.push_back( {{MOVE_BACKWARD,input::KEYBOARD}, sf::Keyboard::S, IKeysMap::HOLD} );
|
||||||
keys.push_back( {STRAFE_LEFT, sf::Keyboard::Q, IKeysMap::HOLD} );
|
keys.push_back( {{STRAFE_LEFT,input::KEYBOARD}, sf::Keyboard::Q, IKeysMap::HOLD} );
|
||||||
keys.push_back( {STRAFE_RIGHT, sf::Keyboard::D, IKeysMap::HOLD} );
|
keys.push_back( {{STRAFE_RIGHT,input::KEYBOARD}, sf::Keyboard::D, IKeysMap::HOLD} );
|
||||||
keys.push_back( {JUMP, sf::Keyboard::Space, IKeysMap::PRESSED} );
|
keys.push_back( {{JUMP,input::KEYBOARD}, sf::Keyboard::Space, IKeysMap::PRESSED} );
|
||||||
keys.push_back( {TOGGLE_NOCLIP, sf::Keyboard::G, IKeysMap::PRESSED} );
|
keys.push_back( {{TOGGLE_NOCLIP,input::KEYBOARD}, sf::Keyboard::G, IKeysMap::PRESSED} );
|
||||||
keys.push_back( {TOGGLE_PHYSICS_DEBUG, sf::Keyboard::P, IKeysMap::PRESSED} );
|
keys.push_back( {{TOGGLE_PHYSICS_DEBUG,input::KEYBOARD},sf::Keyboard::P, IKeysMap::PRESSED} );
|
||||||
keys.push_back( {TOGGLE_CONSOLE, sf::Keyboard::F3, IKeysMap::PRESSED} );
|
keys.push_back( {{TOGGLE_CONSOLE,input::KEYBOARD}, sf::Keyboard::F3, IKeysMap::PRESSED} );
|
||||||
keys.push_back( {MOVE_CURSOR_LEFT, sf::Keyboard::Left, IKeysMap::PRESSED} );
|
keys.push_back( {{MOVE_CURSOR_LEFT,input::KEYBOARD}, sf::Keyboard::Left, IKeysMap::PRESSED} );
|
||||||
keys.push_back( {MOVE_CURSOR_RIGHT, sf::Keyboard::Right, IKeysMap::PRESSED} );
|
keys.push_back( {{MOVE_CURSOR_RIGHT,input::KEYBOARD}, sf::Keyboard::Right, IKeysMap::PRESSED} );
|
||||||
keys.push_back( {PLOP_TEST, sf::Keyboard::F7, IKeysMap::PRESSED} );
|
keys.push_back( {{PLOP_TEST,input::KEYBOARD}, sf::Keyboard::F7, IKeysMap::PRESSED} );
|
||||||
keys.push_back( {CLEAR_CONSOLE, sf::Keyboard::F2, IKeysMap::PRESSED} );
|
keys.push_back( {{CLEAR_CONSOLE,input::KEYBOARD}, sf::Keyboard::F2, IKeysMap::PRESSED} );
|
||||||
keys.push_back( {EXIT_GAME, sf::Keyboard::Escape, IKeysMap::PRESSED} );
|
keys.push_back( {{EXIT_GAME,input::KEYBOARD}, sf::Keyboard::Escape,IKeysMap::PRESSED} );
|
||||||
keys.push_back( {LEFT_CLICK, sf::Keyboard::KeyCount + sf::Mouse::Left, IKeysMap::PRESSED} );
|
keys.push_back( {{LEFT_CLICK,input::MOUSE}, sf::Mouse::Left, IKeysMap::PRESSED} );
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::vector<int> getDefaultContext()
|
static std::vector<Action> getDefaultContext()
|
||||||
{
|
{
|
||||||
return {MAIN_ACTION, SECONDARY_ACTION, TERTIARY_ACTION, MOVE_FORWARD, MOVE_BACKWARD, STRAFE_LEFT, STRAFE_RIGHT, JUMP, TOGGLE_NOCLIP, TOGGLE_PHYSICS_DEBUG, TOGGLE_CONSOLE, EXIT_GAME};
|
return {
|
||||||
|
{MAIN_ACTION,input::MOUSE},
|
||||||
|
{SECONDARY_ACTION,input::MOUSE},
|
||||||
|
{TERTIARY_ACTION,input::MOUSE},
|
||||||
|
{MOVE_FORWARD,input::KEYBOARD},
|
||||||
|
{MOVE_BACKWARD,input::KEYBOARD},
|
||||||
|
{STRAFE_LEFT,input::KEYBOARD},
|
||||||
|
{STRAFE_RIGHT,input::KEYBOARD},
|
||||||
|
{JUMP,input::KEYBOARD},
|
||||||
|
{TOGGLE_NOCLIP,input::KEYBOARD},
|
||||||
|
{TOGGLE_PHYSICS_DEBUG,input::KEYBOARD},
|
||||||
|
{TOGGLE_CONSOLE,input::KEYBOARD},
|
||||||
|
{EXIT_GAME,input::KEYBOARD}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::vector<int> getShellContext()
|
static std::vector<Action> getShellContext()
|
||||||
{
|
{
|
||||||
return {TOGGLE_CONSOLE,MOVE_CURSOR_LEFT,MOVE_CURSOR_RIGHT,PLOP_TEST,CLEAR_CONSOLE};
|
return {
|
||||||
|
{TOGGLE_CONSOLE,input::KEYBOARD},
|
||||||
|
{MOVE_CURSOR_LEFT,input::KEYBOARD},
|
||||||
|
{MOVE_CURSOR_RIGHT,input::KEYBOARD},
|
||||||
|
{PLOP_TEST,input::KEYBOARD},
|
||||||
|
{CLEAR_CONSOLE,input::KEYBOARD}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::vector<int> getMenuContext(){
|
static std::vector<Action> getMenuContext(){
|
||||||
return {LEFT_CLICK,EXIT_GAME,TOGGLE_CONSOLE};
|
return {
|
||||||
|
{LEFT_CLICK,input::MOUSE},
|
||||||
|
{EXIT_GAME,input::KEYBOARD},
|
||||||
|
{TOGGLE_CONSOLE,input::KEYBOARD}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -202,23 +202,23 @@ void Engine::setShowMouseAction(int action)
|
|||||||
|
|
||||||
void Engine::checkSpecialInputs()
|
void Engine::checkSpecialInputs()
|
||||||
{
|
{
|
||||||
for(int action : m_input->getActions())
|
for(Action action : m_input->getActions())
|
||||||
{
|
{
|
||||||
if(action == -1)
|
if(action.action == NO_ACTION)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if(action == m_togglePhysicsDebugAction)
|
if(action.action == m_togglePhysicsDebugAction)
|
||||||
{
|
{
|
||||||
if(m_physicsDebugNode == nullptr)
|
if(m_physicsDebugNode == nullptr)
|
||||||
enablePhysicsDebug();
|
enablePhysicsDebug();
|
||||||
else
|
else
|
||||||
disablePhysicsDebug();
|
disablePhysicsDebug();
|
||||||
}
|
}
|
||||||
else if(action == m_toggleShellAction)
|
else if(action.action == m_toggleShellAction)
|
||||||
m_sparrowshell->toggleShell();
|
m_sparrowshell->toggleShell();
|
||||||
else if(action == m_exitGameAction)
|
else if(action.action == m_exitGameAction)
|
||||||
m_running = false;
|
m_running = false;
|
||||||
else if(action == m_showMouseAction)
|
else if(action.action == m_showMouseAction)
|
||||||
toggleMouseVisibility();
|
toggleMouseVisibility();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,7 @@ void ButtonNode::update()
|
|||||||
|
|
||||||
for (auto action : input->getActions())
|
for (auto action : input->getActions())
|
||||||
{
|
{
|
||||||
if (action == m_action){
|
if (action.action == m_action){
|
||||||
if (m_shape->hover(this->getPosition(),input->getPosition()))
|
if (m_shape->hover(this->getPosition(),input->getPosition()))
|
||||||
m_callback->exec();
|
m_callback->exec();
|
||||||
}
|
}
|
||||||
|
@ -36,13 +36,13 @@ void TextInputNode::update()
|
|||||||
|
|
||||||
auto input = getEngine().getInput();
|
auto input = getEngine().getInput();
|
||||||
for(auto action : input->getActions()){
|
for(auto action : input->getActions()){
|
||||||
if (action == m_move_cursor_left){
|
if (action.action == m_move_cursor_left){
|
||||||
if (m_cursor_pos > 0){
|
if (m_cursor_pos > 0){
|
||||||
m_cursor_pos--;
|
m_cursor_pos--;
|
||||||
cursor_pos_updated=true;
|
cursor_pos_updated=true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(action == m_move_cursor_right){
|
else if(action.action == m_move_cursor_right){
|
||||||
if(m_cursor_pos < m_text.length()){
|
if(m_cursor_pos < m_text.length()){
|
||||||
m_cursor_pos++;
|
m_cursor_pos++;
|
||||||
cursor_pos_updated=true;
|
cursor_pos_updated=true;
|
||||||
|
@ -118,19 +118,19 @@ void PlayerCharacterNode::update()
|
|||||||
int walk = 0;
|
int walk = 0;
|
||||||
int strafe = 0;
|
int strafe = 0;
|
||||||
bool jump = false;
|
bool jump = false;
|
||||||
for(int action : input->getActions())
|
for(Action action : input->getActions())
|
||||||
{
|
{
|
||||||
if(action == m_inputActions[FORWARD])
|
if(action.action == m_inputActions[FORWARD])
|
||||||
++walk;
|
++walk;
|
||||||
else if(action == m_inputActions[BACKWARD])
|
else if(action.action == m_inputActions[BACKWARD])
|
||||||
--walk;
|
--walk;
|
||||||
else if(action == m_inputActions[STRAFE_LEFT])
|
else if(action.action == m_inputActions[STRAFE_LEFT])
|
||||||
--strafe;
|
--strafe;
|
||||||
else if(action == m_inputActions[STRAFE_RIGHT])
|
else if(action.action == m_inputActions[STRAFE_RIGHT])
|
||||||
++strafe;
|
++strafe;
|
||||||
else if(action == m_inputActions[JUMP])
|
else if(action.action == m_inputActions[JUMP])
|
||||||
jump = true;
|
jump = true;
|
||||||
else if(action == m_inputActions[TOGGLE_NOCLIP])
|
else if(action.action == m_inputActions[TOGGLE_NOCLIP])
|
||||||
toggleNoClip();
|
toggleNoClip();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,11 +9,11 @@ TrackBallCameraNode::TrackBallCameraNode(Input *input) :
|
|||||||
void TrackBallCameraNode::update()
|
void TrackBallCameraNode::update()
|
||||||
{
|
{
|
||||||
glm::vec2 diff = m_input->getDeltaPosition();
|
glm::vec2 diff = m_input->getDeltaPosition();
|
||||||
for(int action : m_input->getActions())
|
for(Action action : m_input->getActions())
|
||||||
{
|
{
|
||||||
if(action == m_action_move)
|
if(action.action == m_action_move)
|
||||||
moveCamera(diff.x, diff.y);
|
moveCamera(diff.x, diff.y);
|
||||||
else if(action == m_action_rotate)
|
else if(action.action == m_action_rotate)
|
||||||
rotateCamera(diff.x, diff.y);
|
rotateCamera(diff.x, diff.y);
|
||||||
}
|
}
|
||||||
zoom(m_input->getDeltaVerticalScroll()*120.f);
|
zoom(m_input->getDeltaVerticalScroll()*120.f);
|
||||||
|
@ -167,13 +167,13 @@ void Potator::update()
|
|||||||
{
|
{
|
||||||
GibGeneratorNode::update();
|
GibGeneratorNode::update();
|
||||||
Input *input = getEngine().getInput();
|
Input *input = getEngine().getInput();
|
||||||
for(int action : input->getActions())
|
for(Action action : input->getActions())
|
||||||
{
|
{
|
||||||
if(action == m_throwCubeAction)
|
if(action.action == m_throwCubeAction)
|
||||||
throwCube();
|
throwCube();
|
||||||
else if(action == m_throwSphereAction)
|
else if(action.action == m_throwSphereAction)
|
||||||
throwSphere();
|
throwSphere();
|
||||||
else if(action == m_throwObjectAction)
|
else if(action.action == m_throwObjectAction)
|
||||||
throwSword();
|
throwSword();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user