X-Git-Url: https://git.octo.it/?a=blobdiff_plain;ds=sidebyside;f=src%2Fcontrol%2Fcontroller.cpp;h=49996e24450e4c4d98f963463059dd45bf7a0d9d;hb=9f40a73e89c17a2862a1213343589c19eff42199;hp=73f93afed0809177acf69a80d2db5b10c0f8f032;hpb=5b7f9214cb929399f1a855ef5807018a9447d510;p=supertux.git diff --git a/src/control/controller.cpp b/src/control/controller.cpp index 73f93afed..49996e244 100644 --- a/src/control/controller.cpp +++ b/src/control/controller.cpp @@ -1,28 +1,20 @@ -// $Id$ -// // SuperTux -// Copyright (C) 2005 Matthias Braun +// Copyright (C) 2006 Matthias Braun // -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. // // This program 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 General Public License for more details. -// +// // You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA -// 02111-1307, USA. - -#include - -#include "controller.hpp" +// along with this program. If not, see . -extern Controller* main_controller; +#include "control/controller.hpp" const char* Controller::controlNames[] = { "left", @@ -31,8 +23,16 @@ const char* Controller::controlNames[] = { "down", "jump", "action", - "pause-menu", + "start", + "escape", "menu-select", + "menu-back", + "cheat-menu", + "console", + "peek-left", + "peek-right", + "peek-up", + "peek-down", 0 }; @@ -53,16 +53,28 @@ Controller::reset() } } +void +Controller::set_control(Control control, bool value) +{ + controls[control] = value; +} + bool -Controller::hold(Control control) +Controller::hold(Control control) const { return controls[control]; } bool -Controller::pressed(Control control) +Controller::pressed(Control control) const +{ + return !oldControls[control] && controls[control]; +} + +bool +Controller::released(Control control) const { - return oldControls[control] == false && controls[control] == true; + return oldControls[control] && !controls[control]; } void @@ -71,3 +83,5 @@ Controller::update() for(int i = 0; i < CONTROLCOUNT; ++i) oldControls[i] = controls[i]; } + +/* EOF */