//! Player controls connector /*! * Class for assigning keys to respond to player events. * */ /* * Copyright (C) 2009-2010 Alejandro Valenzuela Roca, * * http://mexinetica.com/~lanjoe9 * * This file is part of MotorJ, a free framework for videogame development. * * * MotorJ is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * MotorJ is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with MotorJ. If not, see . */ #include "playerctl-class.h" void mjPlayerCtl::AssignKey(SDLKey SDLkeyPressed, bool * variableToggled) { // Create a new helper structure mjKeyAssign * assgn = new mjKeyAssign; assgn->key = SDLkeyPressed; assgn->toggleVar = variableToggled; assignments.push_back(assgn); } bool mjPlayerCtl::ProcessKeybdEvent(SDL_KeyboardEvent& keyboardEvent) { for (int i = 0; i < assignments.size(); i++) { if (assignments[i]->key == keyboardEvent.keysym.sym) { *assignments[i]->toggleVar = (keyboardEvent.type == SDL_KEYDOWN); } } return true; }