Commit 505a2ae7 authored by Georg Schaefer's avatar Georg Schaefer
Browse files

Revert "now caxis also has pressed and released events"

This reverts commit 0ca2d0ac.
parent 522e5148
......@@ -17,18 +17,11 @@
#define __INPUT_HPP__
namespace gdw{
struct axisStruct{
bool changed = false;
int down = 0;
bool released = false;
};
struct controller {
SDL_GameController *sdlController;
int controllerNr = -1;
std::unordered_map<int, bool> controllerMap;
std::unordered_map<int, bool> controllerReleasedMap;
std::unordered_map<int, axisStruct> axisMap;
bool active = false;
};
......@@ -183,6 +176,7 @@ namespace gdw{
SDL_GameControllerAxis getCAxisFromName(std::string name);
int firstController();
//controller findController(int sdlId);
std::unordered_map<int, bool> usedControllers_;
controller controller_;
......@@ -200,7 +194,6 @@ namespace gdw{
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);
......@@ -216,7 +209,7 @@ namespace gdw{
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 {/*used another way*/};
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*/};
......
......@@ -112,8 +112,6 @@ namespace gdw {
auto &input = engine_.input();
auto &level_manager = engine_.game_play_system().level_manager();
log << "mouse: x:" << input.mousePosX() << " y:" << input.mousePosY() << std::endl;
//MOUSEWHEEL
if(input.mouseWheelY() < 0.f) {
auto cam = engine_.game_play_system().level_manager().camera();
......
......@@ -10,8 +10,6 @@ namespace gdw{
keyState_ = SDL_GetKeyboardState(NULL);
controllerDB_ = engine.asset_manager().load(engine.asset_manager().native_name(controllerDBPath_));
makeMappings();
SDL_SetCursor(SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_CROSSHAIR));
}
/** if you add here, add also in enum inputMapping in input.hpp
......@@ -195,23 +193,6 @@ namespace gdw{
}
void input::calcPosition(float delta){
for(int i=0;i<controllers_.size();++i){
for(int j=SDL_CONTROLLER_AXIS_INVALID+1;j<SDL_CONTROLLER_AXIS_MAX;++j){
float f = SDL_GameControllerGetAxis(controllers_[i].sdlController, SDL_GameControllerAxis(j)) / controllerAxisMax_;
if(!(f < controllerAxisDeadZone_ && f > -controllerAxisDeadZone_)){
if(controllers_[i].axisMap.find(j) == controllers_[j].axisMap.end()){
axisStruct as;
as.down = 1;
as.changed = true;
controllers_[i].axisMap.emplace(j, as);
}else{
++controllers_[i].axisMap[j].down;
controllers_[i].axisMap[j].changed = true;
}
}
}
}
}
......@@ -236,15 +217,6 @@ namespace gdw{
for(int i=0;i<controllers_.size();++i){
controllers_[i].controllerReleasedMap.clear();
controllers_[i].controllerMap.clear();
for (caxisIt_ = controllers_[i].axisMap.begin(); caxisIt_ != controllers_[i].axisMap.end(); caxisIt_++){
if(!caxisIt_->second.changed && caxisIt_->second.down > 0){
caxisIt_->second.released = true;
caxisIt_->second.down = 0;
}else{
if(caxisIt_->second.released)caxisIt_->second.released = false;
}
caxisIt_->second.changed = false;
}
}
for (mouseIt_ = mouseMap_.begin(); mouseIt_ != mouseMap_.end(); mouseIt_++){
......@@ -341,11 +313,11 @@ namespace gdw{
return true;
}
}
if((mappings_[id].type & caxis) != 0){
if(controllers_[firstController()].axisMap[mappings_[id].caxisCode].down == 1){
/*if((mappings_[id].type & caxis) != 0){
if(controllerAxis(mappings_[id].caxisCode)){
return true;
}
}
}*/
return false;
}
......@@ -405,11 +377,11 @@ namespace gdw{
return true;
}
}
if((mappings_[id].type & caxis) != 0){
if(controllers_[firstController()].axisMap[mappings_[id].caxisCode].released){
/*if((mappings_[id].type & caxis) != 0){
if(controllerAxis(mappings_[id].caxisCode)){
return true;
}
}
}*/
return false;
}
......
Supports Markdown
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