Commit 3ceea4db authored by Benjamin 'Albsi' Albsmeier's avatar Benjamin 'Albsi' Albsmeier
Browse files

fixed a typo

parent 80afd2cf
......@@ -25,8 +25,8 @@ namespace gdw{
bool active = false;
};
//if you add here, add also a maping in makeMaping() in input.cpp
enum class inputMaping {
//if you add here, add also a mapping in makeMapping() in input.cpp
enum class inputMapping {
state_switch,
player_move_left,
player_move_right,
......@@ -35,7 +35,7 @@ namespace gdw{
place_item
};
struct inputMapingStruct {
struct inputMappingStruct {
unsigned int type = 0;
bool negativAxis = false;
SDL_Keycode keyCode1 = 0;
......@@ -52,14 +52,14 @@ namespace gdw{
static float constexpr controllerAxisMax_ = 32767.f;
static float constexpr controllerAxisDeadZone_ = .3f;
/**inputMapingStruct.type for key*/
/**inputMappingStruct.type for key*/
static unsigned int constexpr key1 = 0x01;
static unsigned int constexpr key2 = 0x02;
/**inputMapingStruct.type for mouse button*/
/**inputMappingStruct.type for mouse button*/
static unsigned int constexpr mbutton = 0x04;
/**inputMapingStruct.type for controller button*/
/**inputMappingStruct.type for controller button*/
static unsigned int constexpr cbutton = 0x08;
/**inputMapingStruct.type for controller axis*/
/**inputMappingStruct.type for controller axis*/
static unsigned int constexpr caxis = 0x10;
public:
input(engine& engine);
......@@ -73,34 +73,39 @@ namespace gdw{
* should called once per game loop, at the end*/
void reset();
bool isPressed(inputMaping id);
bool isDown(inputMaping id);
bool isReleased(inputMaping id);
/**Returns true every frame, as long as it is down - NOT FOR MULTI CONTROLLER*/
bool isPressed(inputMapping id);
/**Returns true once it is pressed - NOT FOR MULTI CONTROLLER*/
bool isDown(inputMapping id);
/**Returns true once it is released - NOT FOR MULTI CONTROLLER*/
bool isReleased(inputMapping id);
/**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(inputMaping key) noexcept {return isKeyDown(getKeyCodeByMaping(key, 1)) || isKeyDown(getKeyCodeByMaping(key, 2));};
int isKeyDown(inputMapping key) noexcept {return isKeyDown(getKeyCodeByMapping(key, 1)) || isKeyDown(getKeyCodeByMapping(key, 2));};
/**Returns true once the key is pressed*/
bool isKeyPressed(SDL_Keycode key) noexcept {return keyMap_[key]==1;};
bool isKeyPressed(inputMaping key) noexcept {return isKeyPressed(getKeyCodeByMaping(key, 1)) || isKeyPressed(getKeyCodeByMaping(key, 2));};
bool isKeyPressed(inputMapping key) noexcept {return isKeyPressed(getKeyCodeByMapping(key, 1)) || isKeyPressed(getKeyCodeByMapping(key, 2));};
/**Returns true once the key is released*/
bool isKeyReleased(SDL_Keycode key) noexcept {return keyReleasedMap_[key] && !keyState_[SDL_GetScancodeFromKey(key)];};
bool isKeyReleased(inputMaping key) noexcept {return isKeyReleased(getKeyCodeByMaping(key, 1)) || isKeyReleased(getKeyCodeByMaping(key, 2));};
bool isKeyReleased(inputMapping key) noexcept {return isKeyReleased(getKeyCodeByMapping(key, 1)) || isKeyReleased(getKeyCodeByMapping(key, 2));};
/**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(inputMaping button);
bool isMouseButtonDown(inputMapping button);
/**Returns true once the mouse button is pressed*/
bool isMouseButtonPressed(int button) noexcept {return mouseMap_[button]==1;};
bool isMouseButtonPressed(inputMaping button);
bool isMouseButtonPressed(inputMapping button);
/**Returns true once the mouse button is released*/
bool isMouseButtonReleased(int button) noexcept {return mouseReleasedMap_[button];};
bool isMouseButtonReleased(inputMaping button);
bool isMouseButtonReleased(inputMapping button);
public:
/**Returns a glm::vec2 with the x and y motion of the mouse wheel
......@@ -126,25 +131,25 @@ namespace gdw{
private:
bool isControllerButtonDown(SDL_GameControllerButton button, int nr = 0);
public:
bool isControllerButtonDown(inputMaping button, int nr = 0) noexcept {return isControllerButtonDown(getCButtonCodeByMaping(button), nr);};
bool isControllerButtonDown(inputMapping button, int nr = 0) noexcept {return isControllerButtonDown(getCButtonCodeByMapping(button), nr);};
/**Returns true once the controller button is pressed*/
private:
bool isControllerButtonPressed(SDL_GameControllerButton button, int nr = 0);
public:
bool isControllerButtonPressed(inputMaping button, int nr = 0) noexcept {return isControllerButtonPressed(getCButtonCodeByMaping(button), nr);};
bool isControllerButtonPressed(inputMapping button, int nr = 0) noexcept {return isControllerButtonPressed(getCButtonCodeByMapping(button), nr);};
/**Returns true once the controller button is released*/
private:
bool isControllerButtonReleased(SDL_GameControllerButton button, int nr = 0);
public:
bool isControllerButtonReleased(inputMaping button, int nr = 0) noexcept {return isControllerButtonReleased(getCButtonCodeByMaping(button), nr);};
bool isControllerButtonReleased(inputMapping button, int nr = 0) noexcept {return isControllerButtonReleased(getCButtonCodeByMapping(button), nr);};
/**Returns the value of that axis as a float between -1 and 1*/
private:
float controllerAxis(SDL_GameControllerAxis axis, int nr = 0);
public:
float controllerAxis(inputMaping axis, int nr = 0) noexcept {return controllerAxis(getCAxisCodeByMaping(axis), nr);};
float controllerAxis(inputMapping axis, int nr = 0) noexcept {return controllerAxis(getCAxisCodeByMapping(axis), nr);};
/**Returns number of aktiv controllers*/
int controllerCount() noexcept {return controllers_.size();};
......@@ -155,14 +160,14 @@ namespace gdw{
std::shared_ptr<const asset> controllerDB_;
std::unordered_map<int, controller> controllers_;
std::map<gdw::inputMaping, gdw::inputMapingStruct> mapings_;
void makeMapings();
bool isMapingOk(inputMapingStruct maping, std::string name);
std::map<gdw::inputMapping, gdw::inputMappingStruct> mappings_;
void makeMappings();
bool isMappingOk(inputMappingStruct mapping, std::string name);
SDL_Keycode getKeyCodeByMaping(inputMaping id, int nr);
int getMButtonCodeByMaping(inputMaping id);
SDL_GameControllerButton getCButtonCodeByMaping(inputMaping id);
SDL_GameControllerAxis getCAxisCodeByMaping(inputMaping id);
SDL_Keycode getKeyCodeByMapping(inputMapping id, int nr);
int getMButtonCodeByMapping(inputMapping id);
SDL_GameControllerButton getCButtonCodeByMapping(inputMapping id);
SDL_GameControllerAxis getCAxisCodeByMapping(inputMapping id);
int getMButtonFromName(std::string name);
SDL_Keycode getKeyFromName(std::string name);
......
......@@ -43,12 +43,12 @@ namespace gdw {
}
void AudioEventHandler::playStateUpdate(float deltaTime) {
if ((this->engine.input().isPressed(inputMaping::player_move_left) || this->engine.input().isPressed(inputMaping::player_move_right)) && !this->playerMoving) {
if ((this->engine.input().isPressed(inputMapping::player_move_left) || this->engine.input().isPressed(inputMapping::player_move_right)) && !this->playerMoving) {
this->channels["ship"] = this->engine.audio().queue_sound("engine", -1);
this->engine.audio().sound_volume(40, this->channels["ship"]);
this->playerMoving = true;
}
if (!this->engine.input().isDown(inputMaping::player_move_left) && !this->engine.input().isDown(inputMaping::player_move_right) && this->playerMoving) {
if (!this->engine.input().isDown(inputMapping::player_move_left) && !this->engine.input().isDown(inputMapping::player_move_right) && this->playerMoving) {
this->engine.audio().stop_sound(this->channels["ship"], 600);
this->playerMoving = false;
}
......
......@@ -21,7 +21,7 @@ void menu_state::on_enter() {
}
void menu_state::update(float dt) {
if (this->engine_.input().isPressed(inputMaping::state_switch))
if (this->engine_.input().isPressed(inputMapping::state_switch))
this->engine_.game_state_machine().change_state<play_state>();
}
......
......@@ -58,7 +58,7 @@ void play_state::update(float dt) {
engine_.game_play_system().update(dt);
this->engine_.audioEventHandler().playStateUpdate(dt);
if (this->engine_.input().isPressed(inputMaping::state_switch))
if (this->engine_.input().isPressed(inputMapping::state_switch))
this->engine_.game_state_machine().change_state<menu_state>();
}
......
......@@ -76,7 +76,7 @@ namespace gdw {
constexpr float rotation_speed = 7.f;
constexpr float turn_rate_modifier = 4.5f;
if (input.isDown(inputMaping::player_move_left) && player->position().x > -maximum_movement_distance) {
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));
auto clamped = glm::clamp(diff/turn_rate_modifier, 0.f, 1.f);
......@@ -89,7 +89,7 @@ namespace gdw {
move->add_angular_force(glm::vec3(0.f, -rotation_speed*(std::pow(diff, 1.4f)) , 0.f));
}
if (engine_.input().isDown(inputMaping::player_move_right) && player->position().x < maximum_movement_distance) {
if (engine_.input().isDown(inputMapping::player_move_right) && 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));
auto clamped = glm::clamp(diff/turn_rate_modifier, 0.f, 1.f);
......@@ -103,7 +103,7 @@ namespace gdw {
}
// SET ITEM WITH SPACE KEY
if (input.isDown(inputMaping::place_item)) {
if (input.isDown(inputMapping::place_item)) {
engine_.game_play_system().player_item_manager().place_item(get_world_mouse_pos());
}
}
......@@ -124,24 +124,24 @@ namespace gdw {
level_manager.set_weapon(weapon_type::portal_gun);
}
if(input.isPressed(inputMaping::beam_normal)) {
if(input.isPressed(inputMapping::beam_normal)) {
engine_.audioEventHandler().trigger(AudioEventHandler::TRAKTORBEAM_REVERSE_ACTIVATED);
}
if(input.isReleased(inputMaping::beam_normal)) {
if(input.isReleased(inputMapping::beam_normal)) {
engine_.audioEventHandler().trigger(AudioEventHandler::TRAKTORBEAM_REVERSE_DEACTIVATED);
}
if(input.isPressed(inputMaping::beam_inverse)) {
if(input.isPressed(inputMapping::beam_inverse)) {
engine_.audioEventHandler().trigger(AudioEventHandler::TRAKTORBEAM_ACTIVATED);
}
if(input.isReleased(inputMaping::beam_inverse)) {
if(input.isReleased(inputMapping::beam_inverse)) {
engine_.audioEventHandler().trigger(AudioEventHandler::TRAKTORBEAM_DEACTIVATED);
}
//LEFT && RIGHT CLICK
switch(level_manager.weapon()) {
case weapon_type::tractor_beam: {
if(input.isDown(inputMaping::beam_normal) || input.isDown(inputMaping::beam_inverse)) {
if(input.isDown(inputMapping::beam_normal) || input.isDown(inputMapping::beam_inverse)) {
auto intersection_point = get_world_mouse_pos();
auto cannon = level_manager.cannon();
......@@ -165,7 +165,7 @@ namespace gdw {
rot *= glm::quat(qw,qx,qy,qz);
auto ray_unnormalized = glm::vec3(1.f);
if (input.isDown(inputMaping::beam_normal)) {
if (input.isDown(inputMapping::beam_normal)) {
ray_unnormalized = r.source - r.destination;
} else {
ray_unnormalized = r.destination - r.source;
......@@ -181,7 +181,7 @@ namespace gdw {
process_beam_collision(r, ray_unnormalized, beam_velocity, ray_length_, asteroid_hit, portal_type, remaining_length);
if (input.isDown(inputMaping::beam_normal)) {
if (input.isDown(inputMapping::beam_normal)) {
auto ray_length = (std::abs(ray_length_ - 0.f) < 0.001f)? glm::length(ray_unnormalized): ray_length_;
render_ray(&r, ray_length, std::max((beam_velocity/10.f)/2.f, 1.f), glm::vec3(0,0,1));
} else {
......@@ -197,7 +197,7 @@ namespace gdw {
portal_type = -1;
ray_length_ = remaining_length;
process_beam_collision(r2, ray_unnormalized, beam_velocity, ray_length_, asteroid_hit, portal_type, remaining_length);
if (input.isDown(inputMaping::beam_normal)) {
if (input.isDown(inputMapping::beam_normal)) {
render_ray(&r2, remaining_length, std::max((beam_velocity/10.f)/2.f, 1.f), glm::vec3(0,0,1));
} else {
render_ray(&r2, remaining_length, std::max((beam_velocity/10.f)/2.f, 1.f), glm::vec3(1,0,0));
......@@ -212,7 +212,7 @@ namespace gdw {
portal_type = -1;
ray_length_ = remaining_length;
process_beam_collision(r2, ray_unnormalized, beam_velocity, ray_length_, asteroid_hit, portal_type, remaining_length);
if (input.isDown(inputMaping::beam_normal)) {
if (input.isDown(inputMapping::beam_normal)) {
render_ray(&r2, remaining_length, std::max((beam_velocity/10.f)/2.f, 1.f), glm::vec3(0,0,1));
} else {
render_ray(&r2, remaining_length, std::max((beam_velocity/10.f)/2.f, 1.f), glm::vec3(1,0,0));
......@@ -227,13 +227,13 @@ namespace gdw {
break;
}
case weapon_type::portal_gun: {
if(input.isDown(inputMaping::beam_normal) || input.isDown(inputMaping::beam_inverse)) {
if(input.isDown(inputMapping::beam_normal) || input.isDown(inputMapping::beam_inverse)) {
auto intersection_point = get_world_mouse_pos();
if(input.isDown(inputMaping::beam_normal))
if(input.isDown(inputMapping::beam_normal))
level_manager.create_blue_portal(intersection_point);
if(input.isDown(inputMaping::beam_inverse))
if(input.isDown(inputMapping::beam_inverse))
level_manager.create_yellow_portal(intersection_point);
}
break;
......
......@@ -6,13 +6,13 @@
#include <util/config.hpp>
namespace gdw{
input::input(engine& engine):engine_(engine),mousePos_(0,0),mouseWheel_(0,0),controllers_(),mapings_(){
input::input(engine& engine):engine_(engine),mousePos_(0,0),mouseWheel_(0,0),controllers_(),mappings_(){
keyState_ = SDL_GetKeyboardState(NULL);
controllerDB_ = engine.asset_manager().load(engine.asset_manager().native_name(controllerDBPath_));
makeMapings();
makeMappings();
}
/** if you add here, add also in enum inputMaping in input.hpp
/** if you add here, add also in enum inputMapping in input.hpp
*
* key names: http://wiki.libsdl.org/SDL_Keycode?highlight=%28%5CbCategoryEnum%5Cb%29%7C%28CategoryKeyboard%29
* getKeyFromName(std::string)
......@@ -33,56 +33,56 @@ namespace gdw{
* DON'T MISS TO ADD THE RIGHT TYPES [ key1 | mbutton | cbutton | caxis]!
* CAXIS DON'T TRIGGER 'PRESSED' OR 'RELEASED' IT ONLY TRIGGERS 'DOWN'!
*/
void input::makeMapings(){
inputMapingStruct state_switch_;
void input::makeMappings(){
inputMappingStruct state_switch_;
state_switch_.type = key1 + cbutton;
state_switch_.keyCode1 = getKeyFromName(engine_.getConfig().get<std::string>("state_switch_key","Escape"));
state_switch_.cbuttonCode = getCButtonFromName(engine_.getConfig().get<std::string>("state_switch_cbutton","START"));
isMapingOk(state_switch_, "state_switch");
mapings_.emplace(inputMaping::state_switch, state_switch_);
isMappingOk(state_switch_, "state_switch");
mappings_.emplace(inputMapping::state_switch, state_switch_);
inputMapingStruct player_move_left_;
inputMappingStruct player_move_left_;
player_move_left_.type = key1 + key2 + cbutton + caxis;
player_move_left_.keyCode1 = getKeyFromName(engine_.getConfig().get<std::string>("player_move_left_key","A"));
player_move_left_.keyCode2 = getKeyFromName(engine_.getConfig().get<std::string>("player_move_left_key2","A"));
player_move_left_.cbuttonCode = getCButtonFromName(engine_.getConfig().get<std::string>("player_move_left_cbutton","LEFT"));
player_move_left_.caxisCode = getCAxisFromName(engine_.getConfig().get<std::string>("player_move_left_caxis","RIGHTX"));
player_move_left_.negativAxis = true;
isMapingOk(player_move_left_, "player_move_left");
mapings_.emplace(inputMaping::player_move_left, player_move_left_);
isMappingOk(player_move_left_, "player_move_left");
mappings_.emplace(inputMapping::player_move_left, player_move_left_);
inputMapingStruct player_move_right_;
inputMappingStruct player_move_right_;
player_move_right_.type = key1 + key2 + cbutton + caxis;
player_move_right_.keyCode1 = getKeyFromName(engine_.getConfig().get<std::string>("player_move_right_key","D"));
player_move_right_.keyCode2 = getKeyFromName(engine_.getConfig().get<std::string>("player_move_right_key2","A"));
player_move_right_.cbuttonCode = getCButtonFromName(engine_.getConfig().get<std::string>("player_move_right_cbutton","RIGHT"));
player_move_right_.caxisCode = getCAxisFromName(engine_.getConfig().get<std::string>("player_move_right_caxis","RIGHTX"));
isMapingOk(player_move_right_, "player_move_right");
mapings_.emplace(inputMaping::player_move_right, player_move_right_);
isMappingOk(player_move_right_, "player_move_right");
mappings_.emplace(inputMapping::player_move_right, player_move_right_);
inputMapingStruct place_item_;
inputMappingStruct place_item_;
place_item_.type = key1 + mbutton + cbutton;
place_item_.keyCode1 = getKeyFromName(engine_.getConfig().get<std::string>("place_item_key","Space"));
place_item_.mbuttonCode = getMButtonFromName(engine_.getConfig().get<std::string>("place_item_mbutton","Middle"));
place_item_.cbuttonCode = getCButtonFromName(engine_.getConfig().get<std::string>("place_item_cbutton","A"));
isMapingOk(place_item_, "place_item");
mapings_.emplace(inputMaping::place_item, place_item_);
isMappingOk(place_item_, "place_item");
mappings_.emplace(inputMapping::place_item, place_item_);
inputMapingStruct beam_normal_;
inputMappingStruct beam_normal_;
beam_normal_.type = key1 + mbutton + caxis;
beam_normal_.mbuttonCode = getMButtonFromName(engine_.getConfig().get<std::string>("beam_normal_mouse","Left"));
beam_normal_.keyCode1 = getKeyFromName(engine_.getConfig().get<std::string>("beam_normal_key","Q"));
beam_normal_.caxisCode = getCAxisFromName(engine_.getConfig().get<std::string>("beam_normal_caxis","LEFTTRIGGER"));
isMapingOk(beam_normal_, "beam_normal");
mapings_.emplace(inputMaping::beam_normal, beam_normal_);
isMappingOk(beam_normal_, "beam_normal");
mappings_.emplace(inputMapping::beam_normal, beam_normal_);
inputMapingStruct beam_inverse_;
inputMappingStruct beam_inverse_;
beam_inverse_.type = key1 + mbutton + caxis;
beam_inverse_.mbuttonCode = getMButtonFromName(engine_.getConfig().get<std::string>("beam_inverse_mouse","Right"));
beam_inverse_.keyCode1 = getKeyFromName(engine_.getConfig().get<std::string>("beam_inverse_key","E"));
beam_inverse_.caxisCode = getCAxisFromName(engine_.getConfig().get<std::string>("beam_inverse_caxis","RIGHTTRIGGER"));
isMapingOk(beam_inverse_, "beam_inverse");
mapings_.emplace(inputMaping::beam_inverse, beam_inverse_);
isMappingOk(beam_inverse_, "beam_inverse");
mappings_.emplace(inputMapping::beam_inverse, beam_inverse_);
}
input::~input(){}
......@@ -217,26 +217,26 @@ namespace gdw{
}
}
//MAPING
int input::getKeyCodeByMaping(inputMaping id, int nr){
//MAPPING
int input::getKeyCodeByMapping(inputMapping id, int nr){
if(nr == 1){
return (mapings_[id].type & key1) !=0? mapings_[id].keyCode1 : 0;
return (mappings_[id].type & key1) !=0? mappings_[id].keyCode1 : 0;
}else if(nr == 2){
return (mapings_[id].type & key2) !=0? mapings_[id].keyCode2 : 0;
return (mappings_[id].type & key2) !=0? mappings_[id].keyCode2 : 0;
}
return 0;
}
int input::getMButtonCodeByMaping(inputMaping id){
return (mapings_[id].type & mbutton) !=0? mapings_[id].mbuttonCode : -1;
int input::getMButtonCodeByMapping(inputMapping id){
return (mappings_[id].type & mbutton) !=0? mappings_[id].mbuttonCode : -1;
}
SDL_GameControllerButton input::getCButtonCodeByMaping(inputMaping id){
return (mapings_[id].type & cbutton) !=0? mapings_[id].cbuttonCode : SDL_CONTROLLER_BUTTON_INVALID;
SDL_GameControllerButton input::getCButtonCodeByMapping(inputMapping id){
return (mappings_[id].type & cbutton) !=0? mappings_[id].cbuttonCode : SDL_CONTROLLER_BUTTON_INVALID;
}
SDL_GameControllerAxis input::getCAxisCodeByMaping(inputMaping id){
return (mapings_[id].type & caxis) !=0? mapings_[id].caxisCode : SDL_CONTROLLER_AXIS_INVALID;
SDL_GameControllerAxis input::getCAxisCodeByMapping(inputMapping id){
return (mappings_[id].type & caxis) !=0? mappings_[id].caxisCode : SDL_CONTROLLER_AXIS_INVALID;
}
int input::getMButtonFromName(std::string name){
......@@ -277,63 +277,63 @@ namespace gdw{
}
//RETURN
bool input::isPressed(inputMaping id){
if((mapings_[id].type & key1) != 0){
if(isKeyPressed(mapings_[id].keyCode1)){
bool input::isPressed(inputMapping id){
if((mappings_[id].type & key1) != 0){
if(isKeyPressed(mappings_[id].keyCode1)){
return true;
}
}
if((mapings_[id].type & key2) != 0){
if(isKeyPressed(mapings_[id].keyCode2)){
if((mappings_[id].type & key2) != 0){
if(isKeyPressed(mappings_[id].keyCode2)){
return true;
}
}
if((mapings_[id].type & mbutton) != 0){
if(isMouseButtonPressed(mapings_[id].mbuttonCode)){
if((mappings_[id].type & mbutton) != 0){
if(isMouseButtonPressed(mappings_[id].mbuttonCode)){
return true;
}
}
if((mapings_[id].type & cbutton) != 0){
if(isControllerButtonPressed(mapings_[id].cbuttonCode)){
if((mappings_[id].type & cbutton) != 0){
if(isControllerButtonPressed(mappings_[id].cbuttonCode)){
return true;
}
}
/*if((mapings_[id].type & caxis) != 0){
if(controllerAxis(mapings_[id].caxisCode)){
/*if((mappings_[id].type & caxis) != 0){
if(controllerAxis(mappings_[id].caxisCode)){
return true;
}
}*/
return false;
}
bool input::isDown(inputMaping id){
if((mapings_[id].type & key1) != 0){
if(isKeyDown(mapings_[id].keyCode1)){
bool input::isDown(inputMapping id){
if((mappings_[id].type & key1) != 0){
if(isKeyDown(mappings_[id].keyCode1)){
return true;
}
}
if((mapings_[id].type & key2) != 0){
if(isKeyDown(mapings_[id].keyCode2)){
if((mappings_[id].type & key2) != 0){
if(isKeyDown(mappings_[id].keyCode2)){
return true;
}
}
if((mapings_[id].type & mbutton) != 0){
if(isMouseButtonDown(mapings_[id].mbuttonCode)){
if((mappings_[id].type & mbutton) != 0){
if(isMouseButtonDown(mappings_[id].mbuttonCode)){
return true;
}
}
if((mapings_[id].type & cbutton) != 0){
if(isControllerButtonDown(mapings_[id].cbuttonCode)){
if((mappings_[id].type & cbutton) != 0){
if(isControllerButtonDown(mappings_[id].cbuttonCode)){
return true;
}
}
if((mapings_[id].type & caxis) != 0){
if(!mapings_[id].negativAxis){
if(controllerAxis(mapings_[id].caxisCode) > controllerAxisDeadZone_){
if((mappings_[id].type & caxis) != 0){
if(!mappings_[id].negativAxis){
if(controllerAxis(mappings_[id].caxisCode) > controllerAxisDeadZone_){
return true;
}
}else{
if(controllerAxis(mapings_[id].caxisCode) < -controllerAxisDeadZone_){
if(controllerAxis(mappings_[id].caxisCode) < -controllerAxisDeadZone_){
return true;
}
}
......@@ -341,47 +341,47 @@ namespace gdw{
return false;
}
bool input::isReleased(inputMaping id){
if((mapings_[id].type & key1) != 0){
if(isKeyReleased(mapings_[id].keyCode1)){
bool input::isReleased(inputMapping id){
if((mappings_[id].type & key1) != 0){
if(isKeyReleased(mappings_[id].keyCode1)){
return true;
}
}
if((mapings_[id].type & key2) != 0){
if(isKeyReleased(mapings_[id].keyCode2)){
if((mappings_[id].type & key2) != 0){
if(isKeyReleased(mappings_[id].keyCode2)){
return true;
}
}
if((mapings_[id].type & mbutton) != 0){
if(isMouseButtonReleased(mapings_[id].mbuttonCode)){
if((mappings_[id].type & mbutton) != 0){
if(isMouseButtonReleased(mappings_[id].mbuttonCode)){
return true;
}
}
if((mapings_[id].type & cbutton) != 0){
if(isControllerButtonReleased(mapings_[id].cbuttonCode)){
if((mappings_[id].type & cbutton) != 0){
if(isControllerButtonReleased(mappings_[id].cbuttonCode)){
return true;
}
}
/*if((mapings_[id].type & caxis) != 0){
if(controllerAxis(mapings_[id].caxisCode)){
/*if((mappings_[id].type & caxis) != 0){
if(controllerAxis(mappings_[id].caxisCode)){
return true;
}
}*/
return false;
}
bool input::isMouseButtonDown(inputMaping button){
int c = getMButtonCodeByMaping(button);
bool input::isMouseButtonDown(inputMapping button){
int c = getMButtonCodeByMapping(button);
return c != -1?isMouseButtonDown(c):false;
}
bool input::isMouseButtonPressed(inputMaping button){
int c = getMButtonCodeByMaping(button);
bool input::isMouseButtonPressed(inputMapping button){
int c = getMButtonCodeByMapping(button);
return c != -1?isMouseButtonPressed(c):false;
}
bool input::isMouseButtonReleased(inputMaping button){
int c = getMButtonCodeByMaping(button);
bool input::isMouseButtonReleased(inputMapping button){
int c = getMButtonCodeByMapping(button);
return c != -1?isMouseButtonReleased(c):false;
}
......@@ -422,7 +422,7 @@ namespace gdw{
return 0.f;
}
bool input::isMapingOk(inputMapingStruct m, std::string n){
bool input::isMappingOk(inputMappingStruct m, std::string n){
bool ok = true;
if((m.type & key1) != 0 && m.keyCode1 == 0){
ok = 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