Main Page | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

InputHandler.cpp

Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2004 Ivo Danihelka (ivo@danihelka.net)
00003  *
00004  * This program is free software; you can redistribute it and/or modify
00005  * it under the terms of the GNU General Public License as published by
00006  * the Free Software Foundation; either version 2 of the License, or
00007  * (at your option) any later version.
00008  */
00009 #include "InputHandler.h"
00010 
00011 #include "ExInfo.h"
00012 
00013 //-----------------------------------------------------------------
00014 InputHandler::InputHandler()
00015 : m_mouseLoc(-1, -1)
00016 {
00017     m_pressed = NULL;
00018     m_buttons = 0;
00019 }
00020 //-----------------------------------------------------------------
00021 void
00022 InputHandler::mouseState(const V2 &loc, Uint8 buttons)
00023 {
00024     m_mouseLoc = loc;
00025     m_buttons = buttons;
00026 }
00027 //-----------------------------------------------------------------
00028 bool
00029 InputHandler::isPressed(SDLKey key) const
00030 {
00031     return m_pressed && m_pressed[key];
00032 }
00033 //-----------------------------------------------------------------
00034 bool
00035 InputHandler::isLeftPressed() const
00036 {
00037     return m_buttons & SDL_BUTTON(1);
00038 }
00039 //-----------------------------------------------------------------
00040 bool
00041 InputHandler::isMiddlePressed() const
00042 {
00043     return m_buttons & SDL_BUTTON(2);
00044 }
00045 //-----------------------------------------------------------------
00046 bool
00047 InputHandler::isRightPressed() const
00048 {
00049     return m_buttons & SDL_BUTTON(3);
00050 }
00051 //-----------------------------------------------------------------
00052 std::string
00053 InputHandler::toString() const
00054 {
00055     return ExInfo("input")
00056         .addInfo("mouse", m_mouseLoc.toString())
00057         .addInfo("buttons", m_buttons).info();
00058 }
00059 

Generated on Wed Jun 1 09:54:31 2005 for Fish Fillets - Next Generation by  doxygen 1.4.2