Commit 71cf3b6d authored by Benjamin 'Albsi' Albsmeier's avatar Benjamin 'Albsi' Albsmeier
Browse files

replaced all map[] in input to .find() - key down dont works - i fix that later

parent 29198a36
......@@ -34,6 +34,7 @@ namespace gdw{
//if you add here, add also a mapping in makeMapping() in input.cpp
enum class inputMapping {
input_test,
state_switch,
player_move_left,
player_move_right,
......@@ -102,27 +103,27 @@ namespace gdw{
/**Returns true every frame, as long as the key is down.*/
private:
int isKeyDown(SDL_Keycode key) noexcept {return keyState_[SDL_GetScancodeFromKey(key)];};
int isKeyDown(inputMapping key) noexcept {return isKeyDown(getKeyCodeByMapping(key, 1)) || isKeyDown(getKeyCodeByMapping(key, 2));};
int isKeyDown(SDL_Keycode key);
int isKeyDown(inputMapping key);
/**Returns true once the key is pressed*/
bool isKeyPressed(SDL_Keycode key) noexcept {return keyMap_[key]==1;};
bool isKeyPressed(inputMapping key) noexcept {return isKeyPressed(getKeyCodeByMapping(key, 1)) || isKeyPressed(getKeyCodeByMapping(key, 2));};
bool isKeyPressed(SDL_Keycode key);
bool isKeyPressed(inputMapping key);
/**Returns true once the key is released*/
bool isKeyReleased(SDL_Keycode key) noexcept {return keyReleasedMap_[key] && !keyState_[SDL_GetScancodeFromKey(key)];};
bool isKeyReleased(inputMapping key) noexcept {return isKeyReleased(getKeyCodeByMapping(key, 1)) || isKeyReleased(getKeyCodeByMapping(key, 2));};
bool isKeyReleased(SDL_Keycode key);
bool isKeyReleased(inputMapping key);
/**Returns true every frame, as long as the mouse button is down.*/
bool isMouseButtonDown(int button) noexcept {return SDL_GetMouseState(NULL, NULL) & SDL_BUTTON(button);};
bool isMouseButtonDown(int button);
bool isMouseButtonDown(inputMapping button);
/**Returns true once the mouse button is pressed*/
bool isMouseButtonPressed(int button) noexcept {return mouseMap_[button]==1;};
bool isMouseButtonPressed(int button);
bool isMouseButtonPressed(inputMapping button);
/**Returns true once the mouse button is released*/
bool isMouseButtonReleased(int button) noexcept {return mouseReleasedMap_[button];};
bool isMouseButtonReleased(int button);
bool isMouseButtonReleased(inputMapping button);
public:
......@@ -173,7 +174,7 @@ namespace gdw{
int controllerCount() noexcept {return controllers_.size();};
/**Returns true if a controller exists with that id*/
bool isController(int id) noexcept {return SDL_IsGameController(id) && controllers_[id].active;};
bool isController(int id);
private:
std::shared_ptr<const asset> controllerDB_;
std::unordered_map<int, controller> controllers_;
......@@ -213,14 +214,10 @@ namespace gdw{
const Uint8 *keyState_;
std::unordered_map<int, int> mouseMap_;
std::unordered_map<int, int> mousePressedMap_;
std::unordered_map<int, int> mouseReleasedMap_;
std::unordered_map<int, int> keyMap_;
std::unordered_map<int, int> keyReleasedMap_;
std::unordered_map<int, int>::iterator mouseIt_;
std::unordered_map<int, int>::iterator keyIt_;
std::unordered_map<int, bool>::iterator controllerIt_;
std::unordered_map<int, axisStruct>::iterator caxisIt_;
//KEYBOARD
void keyDown(const SDL_KeyboardEvent &e);
......@@ -235,28 +232,46 @@ namespace gdw{
void controllerDown(const SDL_ControllerButtonEvent &e);
void controllerAdded(const SDL_ControllerDeviceEvent &e);
void controllerRemoved(const SDL_ControllerDeviceEvent &e);
void controllerRemapped(const SDL_ControllerDeviceEvent &e) noexcept {log << "[input] controllerRemapped was triggerd but is not handelt" << std::endl;};
void controllerAxis(const SDL_ControllerAxisEvent &e) noexcept {/*handelt on another way, see: float controllerAxis(SDL_GameControllerAxis axis, int nr)*/};
void controllerRemapped(const SDL_ControllerDeviceEvent &e)
noexcept {log << "input: controllerRemapped was triggerd but is not handelt" << std::endl;};
void controllerAxis(const SDL_ControllerAxisEvent &e)
noexcept {/*handelt on another way, see: float controllerAxis(SDL_GameControllerAxis axis, int nr)*/};
//TEXTINPUT
void textEdit(const SDL_TextEditingEvent &e) noexcept {log << "[input] textInput was triggerd but is not handelt" << std::endl;};
void textInput(const SDL_TextInputEvent &e) noexcept {/*spams the log on every key input - not handelt*/};
void textEdit(const SDL_TextEditingEvent &e)
noexcept {log << "input: textInput was triggerd but is not handelt" << std::endl;};
void textInput(const SDL_TextInputEvent &e)
noexcept {/*spams the log on every key input - not handelt*/};
//TOUCH
void touchMotion(const SDL_TouchFingerEvent &e) noexcept {log << "[input] touchMotion was triggerd but is not handelt" << std::endl;};
void touchDown(const SDL_TouchFingerEvent &e) noexcept {log << "[input] touchDown was triggerd but is not handelt" << std::endl;};
void touchUp(const SDL_TouchFingerEvent &e) noexcept {log << "[input] touchUp was triggerd but is not handelt" << std::endl;};
void touchGesture(const SDL_MultiGestureEvent &e) noexcept {log << "[input] touchGesture was triggerd but is not handelt" << std::endl;};
void touchComplexGesture(const SDL_DollarGestureEvent &e) noexcept {log << "[input] touchComplexGesture was triggerd but is not handelt" << std::endl;};
void touchGestureRecord(const SDL_DollarGestureEvent &e) noexcept {log << "[input] touchGestureRecord was triggerd but is not handelt" << std::endl;};
void touchMotion(const SDL_TouchFingerEvent &e)
noexcept {log << "input: touchMotion was triggerd but is not handelt" << std::endl;};
void touchDown(const SDL_TouchFingerEvent &e)
noexcept {log << "input: touchDown was triggerd but is not handelt" << std::endl;};
void touchUp(const SDL_TouchFingerEvent &e)
noexcept {log << "input: touchUp was triggerd but is not handelt" << std::endl;};
void touchGesture(const SDL_MultiGestureEvent &e)
noexcept {log << "input: touchGesture was triggerd but is not handelt" << std::endl;};
void touchComplexGesture(const SDL_DollarGestureEvent &e)
noexcept {log << "input: touchComplexGesture was triggerd but is not handelt" << std::endl;};
void touchGestureRecord(const SDL_DollarGestureEvent &e)
noexcept {log << "input: touchGestureRecord was triggerd but is not handelt" << std::endl;};
//JOYSTICK
void joyAdded(const SDL_JoyDeviceEvent &e) noexcept {/*controllerAdded*/};
void joyRemoved(const SDL_JoyDeviceEvent &e) noexcept {/*controllerRemoved*/};
void joyHat(const SDL_JoyHatEvent &e) noexcept {/*controllerDown / controllerUp*/};
void joyDown(const SDL_JoyButtonEvent &e) noexcept {/*controllerDown*/};
void joyUp(const SDL_JoyButtonEvent &e) noexcept {/*controllerUp*/};
void joyBall(const SDL_JoyBallEvent &e) noexcept {log << "[input] joyBall was triggerd but is not handelt" << std::endl;};
void joyAxis(const SDL_JoyAxisEvent &e) noexcept {/*controllerAxis*/};
void joyAdded(const SDL_JoyDeviceEvent &e)
noexcept {/*controllerAdded*/};
void joyRemoved(const SDL_JoyDeviceEvent &e)
noexcept {/*controllerRemoved*/};
void joyHat(const SDL_JoyHatEvent &e)
noexcept {/*controllerDown / controllerUp*/};
void joyDown(const SDL_JoyButtonEvent &e)
noexcept {/*controllerDown*/};
void joyUp(const SDL_JoyButtonEvent &e)
noexcept {/*controllerUp*/};
void joyBall(const SDL_JoyBallEvent &e)
noexcept {log << "input: joyBall was triggerd but is not handelt" << std::endl;};
void joyAxis(const SDL_JoyAxisEvent &e)
noexcept {/*controllerAxis*/};
//DROP
void drop(const SDL_DropEvent &e) noexcept {log << "[input] drop was triggerd but is not handelt" << std::endl;};
void drop(const SDL_DropEvent &e)
noexcept {log << "input: drop was triggerd but is not handelt" << std::endl;};
};
}
......
......@@ -78,6 +78,18 @@ namespace gdw {
constexpr float rotation_speed = 7.f;
constexpr float turn_rate_modifier = 4.5f;
/*if (input.isPressed(inputMapping::input_test)){
log << "input_test pressed" << std::endl;
}
if (input.isDown(inputMapping::input_test)){
log << "input_test down" << std::endl;
}
if (input.isReleased(inputMapping::input_test)){
log << "input_test released" << std::endl;
}*/
if (input.isDown(inputMapping::player_move_left) && player->position().x > -maximum_movement_distance) {
auto orientation = player->rotation()*glm::vec3(0,0,1);
auto diff = std::abs(orientation.x - (-1.f)) + std::abs(orientation.z - (0.f));
......
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment