X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fcontrol%2Fcontroller.cpp;h=11cfd6557ec0886c2030757be3ea4525987d2a90;hb=3b98af33dfb3ea9f683a89d35a02206d18cb0494;hp=b8eb8d5f4915b1bdf151385acd7e039f77ef78c6;hpb=7ad6b7ed9d8d7c76ec7b70e4c27f47bd424b176e;p=supertux.git diff --git a/src/control/controller.cpp b/src/control/controller.cpp index b8eb8d5f4..11cfd6557 100644 --- a/src/control/controller.cpp +++ b/src/control/controller.cpp @@ -1,7 +1,7 @@ // $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 @@ -12,17 +12,14 @@ // 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. +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include -#include "controller.h" - -extern Controller* main_controller; +#include "controller.hpp" const char* Controller::controlNames[] = { "left", @@ -33,15 +30,17 @@ const char* Controller::controlNames[] = { "action", "pause-menu", "menu-select", + "console", + "peek-left", + "peek-right", + "peek-up", + "peek-down", 0 }; Controller::Controller() { - for(int i = 0; i < CONTROLCOUNT; ++i) { - controls[i] = false; - oldControls[i] = false; - } + reset(); } Controller::~Controller() @@ -65,7 +64,13 @@ Controller::hold(Control control) bool Controller::pressed(Control control) { - return oldControls[control] == false && controls[control] == true; + return !oldControls[control] && controls[control]; +} + +bool +Controller::released(Control control) +{ + return oldControls[control] && !controls[control]; } void