pingus-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Pingus-CVS] CVS: Games/Pingus/src/input/buttons Makefile.am,NONE,1.1 bu


From: torangan
Subject: [Pingus-CVS] CVS: Games/Pingus/src/input/buttons Makefile.am,NONE,1.1 button.hxx,NONE,1.1 double_button.cxx,NONE,1.1 double_button.hxx,NONE,1.1 dummy_button.hxx,NONE,1.1 joystick_button.cxx,NONE,1.1 joystick_button.hxx,NONE,1.1 key_button.cxx,NONE,1.1 key_button.hxx,NONE,1.1 mouse_button.cxx,NONE,1.1 mouse_button.hxx,NONE,1.1 multiple_button.cxx,NONE,1.1 multiple_button.hxx,NONE,1.1 triple_button.cxx,NONE,1.1 triple_button.hxx,NONE,1.1
Date: 24 Aug 2002 11:37:33 -0000

Update of /usr/local/cvsroot/Games/Pingus/src/input/buttons
In directory dark:/tmp/cvs-serv15327/src/input/buttons

Added Files:
        Makefile.am button.hxx double_button.cxx double_button.hxx 
        dummy_button.hxx joystick_button.cxx joystick_button.hxx 
        key_button.cxx key_button.hxx mouse_button.cxx 
        mouse_button.hxx multiple_button.cxx multiple_button.hxx 
        triple_button.cxx triple_button.hxx 
Log Message:
moved input devices in own subdirs / namespaces


--- NEW FILE: Makefile.am ---
# Pingus - A free Lemmings clone
# Copyright (C) 1999 Ingo Ruhnke <address@hidden>
#
# 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 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.

noinst_LIBRARIES = libpingus_input_buttons.a

libpingus_input_buttons_a_SOURCES =       \
        button.hxx  \
        double_button.hxx double_button.cxx \
        dummy_button.hxx \
        joystick_button.hxx joystick_button.cxx \
        key_button.hxx key_button.cxx \
        key_helper.hxx key_helper.cxx \
        mouse_button.hxx mouse_button.cxx \
        multiple_button.hxx multiple_button.cxx \
        triple_button.hxx triple_button.cxx

# EOF #

--- NEW FILE: button.hxx ---
//  $Id: button.hxx,v 1.1 2002/08/24 11:37:31 torangan Exp $
// 
//  Pingus - A free Lemmings clone
//  Copyright (C) 2000 Ingo Ruhnke <address@hidden>
//
//  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 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.

#ifndef HEADER_PINGUS_INPUT_BUTTON_HXX
#define HEADER_PINGUS_INPUT_BUTTON_HXX

#include "../../pingus.hxx"

namespace Input {

  namespace Buttons {
  
    /// abstract base class which defines the button interface
    class Button
    {
    public:
      Button () { }
      virtual ~Button () { }

      /// returns true if the button is pressed, false otherwise
      virtual bool is_pressed ()      const =0;
      virtual void update     (float)       =0;
    
    private:
      Button (const Button&);
      Button operator= (const Button&);
    };
    
  }
}

#endif

/* EOF */

--- NEW FILE: double_button.cxx ---
//  $Id: double_button.cxx,v 1.1 2002/08/24 11:37:31 torangan Exp $
// 
//  Pingus - A free Lemmings clone
//  Copyright (C) 2000 Ingo Ruhnke <address@hidden>
//
//  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 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 "double_button.hxx"

namespace Input {

  namespace Buttons {
  
    DoubleButton::DoubleButton (Button* button1_, Button* button2_) : 
button1(button1_), button2(button2_),
                                                                      
first_pressed(false), ignore_second(false)
    {
    }

    DoubleButton::~DoubleButton ()
    {
      delete button1;
      delete button2;
    }

    void
    DoubleButton::update (float delta)
    {
      button1->update(delta);
      button2->update(delta);
    
      if (button1->is_pressed())
        {
          if (!first_pressed)
            {
              first_pressed = true;
              ignore_second = button2->is_pressed();
            }
        }
      else
        {
          first_pressed = false;
          ignore_second = true;
        }
    }
  
    bool
    DoubleButton::is_pressed () const
    {
      return ( ! ignore_second && first_pressed && button2->is_pressed());
    }

  }
}

/* EOF */

--- NEW FILE: double_button.hxx ---
//  $Id: double_button.hxx,v 1.1 2002/08/24 11:37:31 torangan Exp $
// 
//  Pingus - A free Lemmings clone
//  Copyright (C) 2000 Ingo Ruhnke <address@hidden>
//
//  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 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.

#ifndef HEADER_PINGUS_INPUT_DOUBLE_BUTTON_HXX
#define HEADER_PINGUS_INPUT_DOUBLE_BUTTON_HXX

#include "button.hxx"

namespace Input {

  namespace Buttons {
  
    /**
      @brief allows two buttons to be used in combination
    
      XML definition: <double-button><button1><button2></double-button>
    
      This class allows combinations like CTRL-X whereby it's important that 
the first
      key is pressed before the second else the DoubleButton itself won't 
change it's
      own state to pressed.
      */
    class DoubleButton : public Button {
  
      private:
        Button* const button1;
        Button* const button2;
        bool          first_pressed;
        bool          ignore_second;
      
      public:
    
        DoubleButton (Button* button1_, Button* button2_);
       ~DoubleButton ();

        virtual bool is_pressed () const;
        virtual void update (float delta);
      
      private:
        DoubleButton (const DoubleButton&);
        DoubleButton operator= (const DoubleButton&);
    };

  }
}

#endif

/* EOF */

--- NEW FILE: dummy_button.hxx ---
//  $Id: dummy_button.hxx,v 1.1 2002/08/24 11:37:31 torangan Exp $
// 
//  Pingus - A free Lemmings clone
//  Copyright (C) 2000 Ingo Ruhnke <address@hidden>
//
//  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 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.

#ifndef HEADER_PINGUS_INPUT_DUMMY_BUTTON_HXX
#define HEADER_PINGUS_INPUT_DUMMY_BUTTON_HXX

#include "button.hxx"

namespace Input {

  namespace Buttons {
  
    /**
      @brief dummy class to be used if a button is required but not defined
    
      XML definition: none
      */
    class DummyButton : public Button  {
      public:
        DummyButton () { }
      
        virtual bool is_pressed ()  const { return false; }
        virtual void update (float) { }
      
      private:
        DummyButton (const DummyButton&);
        DummyButton operator= (const DummyButton&);
    };
    
  }
}

#endif

/* EOF */

--- NEW FILE: joystick_button.cxx ---
//  $Id: joystick_button.cxx,v 1.1 2002/08/24 11:37:31 torangan Exp $
// 
//  Pingus - A free Lemmings clone
//  Copyright (C) 2000 Ingo Ruhnke <address@hidden>
//
//  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 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 <ClanLib/Display/Input/input.h>
#include <ClanLib/Display/Input/inputdevice.h>
#include <ClanLib/Display/Input/inputbutton.h>
#include "joystick_button.hxx"
#include "../../pingus_error.hxx"

namespace Input {

  namespace Buttons {
  
    JoystickButton::JoystickButton(int id_, int button_) : id(id_), 
button(button_)
    {
      if (static_cast<unsigned int>(id) >= CL_Input::joysticks.size())
        PingusError::raise("JoystickButton: Invalid joystick id");
      
      if (button > CL_Input::joysticks[id]->get_num_buttons())
        PingusError::raise("JoystickButton: Invalid joystick button id");
    }

    void
    JoystickButton::update(float)
    {
    }
  
    bool
    JoystickButton::is_pressed() const
    {
      return CL_Input::joysticks[id]->get_button(button)->is_pressed();
    }
  
  }
}

/* EOF */

--- NEW FILE: joystick_button.hxx ---
//  $Id: joystick_button.hxx,v 1.1 2002/08/24 11:37:31 torangan Exp $
// 
//  Pingus - A free Lemmings clone
//  Copyright (C) 2000 Ingo Ruhnke <address@hidden>
//
//  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 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.

#ifndef HEADER_PINGUS_INPUT_JOYSTICK_BUTTON_HXX
#define HEADER_PINGUS_INPUT_JOYSTICK_BUTTON_HXX

#include "button.hxx"

namespace Input {

  namespace Buttons {
  
    /**
      @brief represents a button of a joystick
    
      XML definition: <joystick-button id="joystick id" button="button num"/>
      */
    class JoystickButton : public Button {
  
      private:
        int id;
        int button;
      
      public:
    
        JoystickButton (int id_, int button_);
    
        virtual bool is_pressed () const;
        virtual void update (float);
      
      private:
        JoystickButton (const JoystickButton&);
        JoystickButton operator= (const JoystickButton&);
    };

  }
}

#endif

/* EOF */

--- NEW FILE: key_button.cxx ---
//  $Id: key_button.cxx,v 1.1 2002/08/24 11:37:31 torangan Exp $
// 
//  Pingus - A free Lemmings clone
//  Copyright (C) 2000 Ingo Ruhnke <address@hidden>
//
//  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 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 <ClanLib/Display/Input/keyboard.h>
#include "key_button.hxx"

namespace Input {

  namespace Buttons {
  
    KeyButton::KeyButton (int button_) : button(button_) { }

    void
    KeyButton::update (float)
    {
    }
  
    bool
    KeyButton::is_pressed () const
    {
      return CL_Keyboard::get_keycode(button); 
    }
  
  }
}

/* EOF */

--- NEW FILE: key_button.hxx ---
//  $Id: key_button.hxx,v 1.1 2002/08/24 11:37:31 torangan Exp $
// 
//  Pingus - A free Lemmings clone
//  Copyright (C) 2000 Ingo Ruhnke <address@hidden>
//
//  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 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.

#ifndef HEADER_PINGUS_INPUT_KEY_BUTTON_HXX
#define HEADER_PINGUS_INPUT_KEY_BUTTON_HXX

#include "button.hxx"

namespace Input {

  namespace Buttons {

    /**
      @brief maps a keyboard key to a button
    
      XML definition: <key-button button="key name"/>
      */
    class KeyButton : public Button {
  
      private:
        int button;
      
      public:
    
        KeyButton (int button_);
    
        virtual bool is_pressed () const;
        virtual void update (float);
      
      private:
        KeyButton (const KeyButton&);
        KeyButton operator= (const KeyButton&);
    };

  }
}

#endif

/* EOF */

--- NEW FILE: mouse_button.cxx ---
//  $Id: mouse_button.cxx,v 1.1 2002/08/24 11:37:31 torangan Exp $
// 
//  Pingus - A free Lemmings clone
//  Copyright (C) 2000 Ingo Ruhnke <address@hidden>
//
//  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 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 <ClanLib/Display/Input/input.h>
#include <ClanLib/Display/Input/inputdevice.h>
#include <ClanLib/Display/Input/inputbutton.h>
#include "mouse_button.hxx"
#include "../../pingus_error.hxx"

namespace Input {

  namespace Buttons {

    MouseButton::MouseButton (int button_) : button(button_)
    {
      if (button > CL_Input::pointers[0]->get_num_buttons())
        PingusError::raise("MouseButton: Invalid button id");
    }

    void
    MouseButton::update (float)
    {
    }
  
    bool
    MouseButton::is_pressed () const
    {
      return CL_Input::pointers[0]->get_button(button)->is_pressed();
    }
  
  }
}

/* EOF */

--- NEW FILE: mouse_button.hxx ---
//  $Id: mouse_button.hxx,v 1.1 2002/08/24 11:37:31 torangan Exp $
// 
//  Pingus - A free Lemmings clone
//  Copyright (C) 2000 Ingo Ruhnke <address@hidden>
//
//  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 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.

#ifndef HEADER_PINGUS_INPUT_MOUSE_BUTTON_HXX
#define HEADER_PINGUS_INPUT_MOUSE_BUTTON_HXX

#include "button.hxx"

namespace Input {

  namespace Buttons {

    /**
      @brief represents a mouse button
    
      XML definition: <mouse-button button="button num"/>
      */
    class MouseButton : public Button {
  
      private:
        int button;
      
      public:
        MouseButton (int button_);
    
        virtual bool is_pressed () const;
        virtual void update (float);
      
      private:
        MouseButton (const MouseButton&);
        MouseButton operator= (const MouseButton&);
    };
    
  }
}

#endif

/* EOF */


--- NEW FILE: multiple_button.cxx ---
//  $Id: multiple_button.cxx,v 1.1 2002/08/24 11:37:31 torangan Exp $
// 
//  Pingus - A free Lemmings clone
//  Copyright (C) 2000 Ingo Ruhnke <address@hidden>
//
//  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 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 "multiple_button.hxx"

namespace Input {

  namespace Buttons {
  
    MultipleButton::MultipleButton (const std::vector<Button*>& buttons_) : 
buttons(buttons_)
    {
    }

    MultipleButton::~MultipleButton ()
    {
      for (std::vector<Button*>::iterator it = buttons.begin(); it != 
buttons.end(); it++)
        delete *it;
    }

    void
    MultipleButton::update (float delta)
    {
      for (std::vector<Button*>::iterator it = buttons.begin(); it != 
buttons.end(); it++)
        (*it)->update(delta);
    }
  
    bool
    MultipleButton::is_pressed () const
    {
      for (std::vector<Button*>::const_iterator it = buttons.begin(); it != 
buttons.end(); it++)
        if ((*it)->is_pressed())
          return true;

      return false;
    }
  
  }
}

/* EOF */

--- NEW FILE: multiple_button.hxx ---
//  $Id: multiple_button.hxx,v 1.1 2002/08/24 11:37:31 torangan Exp $
// 
//  Pingus - A free Lemmings clone
//  Copyright (C) 2000 Ingo Ruhnke <address@hidden>
//
//  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 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.

#ifndef HEADER_PINGUS_INPUT_MULTIPLE_BUTTON_HXX
#define HEADER_PINGUS_INPUT_MULTIPLE_BUTTON_HXX

#include <vector>
#include "button.hxx"

namespace Input {

  namespace Buttons {
  
    /**
      @brief wrapper class mapping multiple buttons into one
    
      XML definition: <multiple-button> <button 1>...<button n> 
</multiple-button>
    
      A multiple button is pressed whenever at least one of the buttons 
contained is pressed.
      */
    class MultipleButton : public Button {
  
      private:
        std::vector<Button*> buttons;
      
      public:
    
        MultipleButton (const std::vector<Button*>& buttons_);
       ~MultipleButton ();

        virtual bool is_pressed () const;
        virtual void update (float delta);
      
      private:
        MultipleButton (const MultipleButton&);
        MultipleButton operator= (const MultipleButton&);
    };
    
  }
}

#endif

/* EOF */

--- NEW FILE: triple_button.cxx ---
//  $Id: triple_button.cxx,v 1.1 2002/08/24 11:37:31 torangan Exp $
// 
//  Pingus - A free Lemmings clone
//  Copyright (C) 2000 Ingo Ruhnke <address@hidden>
//
//  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 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 "triple_button.hxx"

namespace Input {

  namespace Buttons {

    TripleButton::TripleButton (Button* button1_, Button* button2_, Button* 
button3_) 
                              : button1(button1_), 
                                button2(button2_),
                                button3(button3_),
                                first_second_pressed(false), 
                                ignore_third(false)
    {
    }

    TripleButton::~TripleButton ()
    {
      delete button1;
      delete button2;
      delete button3;
    }

    void
    TripleButton::update (float delta)
    {
      button1->update(delta);
      button2->update(delta);
      button3->update(delta);
  
      if (button1->is_pressed() && button2->is_pressed())
        {
          if (!first_second_pressed)
            {
              first_second_pressed = true;
              ignore_third = button3->is_pressed();
            }
        }
      else
        {
          first_second_pressed = false;
          ignore_third         = true;
        }
    }
  
    bool
    TripleButton::is_pressed() const
    {
      return ( ! ignore_third && first_second_pressed && button3->is_pressed());
    }
  
  }
}

/* EOF */

--- NEW FILE: triple_button.hxx ---
//  $Id: triple_button.hxx,v 1.1 2002/08/24 11:37:31 torangan Exp $
// 
//  Pingus - A free Lemmings clone
//  Copyright (C) 2000 Ingo Ruhnke <address@hidden>
//
//  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 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.

#ifndef HEADER_PINGUS_INPUT_TRIPLE_BUTTON_HXX
#define HEADER_PINGUS_INPUT_TRIPLE_BUTTON_HXX

#include "button.hxx"

namespace Input {

  namespace Buttons {
  
    /**
      @brief allows three buttons to be used in combination
    
      XML definition: <triple-button> <button1><button2><button3> 
</triple-button>
    
      This class allows combinations like CTRL-ALT-R whereby it's important 
that the first
      two keys are pressed before the third else the TripleButton itself won't 
change it's
      own state to pressed. The order in which the first two keys are pressed 
is of no
      importance, such behaviour may be created by using nested DoubleButtons.
      */
    class TripleButton : public Button {
  
      private:
        Button* const button1;
        Button* const button2;
        Button* const button3;
        bool          first_second_pressed;
        bool          ignore_third;
      
      public:
        TripleButton (Button* button1_, Button* button2_, Button* button3_);
       ~TripleButton ();

        virtual bool is_pressed () const;
        virtual void update (float delta);
      
      private:
        TripleButton (const TripleButton&);
        TripleButton operator= (const TripleButton&);
    };
    
  }
}

#endif

/* EOF */





reply via email to

[Prev in Thread] Current Thread [Next in Thread]