Skip to content
Snippets Groups Projects
Select Git revision
  • fd827a67fe1a6662b9d44d6630ad9ef043fd014b
  • main default protected
  • Vincent
  • home
4 results

CONTRIBUTING.md

Blame
  • After you've reviewed these contribution guidelines, you'll be all set to contribute to this project.
    mouse.hpp 2.31 KiB
    //------------------------------------------------------------------------------
    // Project Phoenix
    //
    // Copyright (c) 2017-2018 RWTH Aachen University, Germany,
    // Virtual Reality & Immersive Visualization Group.
    //------------------------------------------------------------------------------
    //                                 License
    //
    // Licensed under the 3-Clause BSD License (the "License");
    // you may not use this file except in compliance with the License.
    // See the file LICENSE for the full text.
    // You may obtain a copy of the License at
    //
    //     https://opensource.org/licenses/BSD-3-Clause
    //
    // Unless required by applicable law or agreed to in writing, software
    // distributed under the License is distributed on an "AS IS" BASIS,
    // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    // See the License for the specific language governing permissions and
    // limitations under the License.
    //------------------------------------------------------------------------------
    
    #ifndef LIBRARY_PHX_INPUT_MOUSE_HPP_
    #define LIBRARY_PHX_INPUT_MOUSE_HPP_
    
    #include <memory>
    
    #define BOOST_BIND_NO_PLACEHOLDERS
    // otherwise boosts _ placeholders conflict with trompeloeil ones
    #include "boost/signals2/connection.hpp"
    #include "boost/signals2/signal.hpp"
    
    #include "phx/input/sdl_device.hpp"
    
    #include "phx/export.hpp"
    
    namespace phx {
    
    class PHOENIX_EXPORT Mouse : public SDLDevice {
     public:
      enum ButtonEvent { BUTTON_PRESSED, BUTTON_RELEASED };
      enum ButtonId {
        LEFT_BUTTON = SDL_BUTTON_LEFT,
        MIDDLE_BUTTON = SDL_BUTTON_MIDDLE,
        RIGHT_BUTTON = SDL_BUTTON_RIGHT,
        X1_BUTTON = SDL_BUTTON_X1,
        X2_BUTTON = SDL_BUTTON_X2
      };
    
      virtual ~Mouse() = default;
    
      void Update() override;
      void OnSDLEvent(const SDL_Event& event) override;
    
      boost::signals2::connection RegisterButtonSignal(
          const std::function<void(ButtonId, ButtonEvent)>& callback);
      boost::signals2::connection RegisterMoveSignal(
          const std::function<void(int, int)>& callback);
      boost::signals2::connection RegisterWheelSignal(
          const std::function<void(int)>& callback);
    
     private:
      boost::signals2::signal<void(ButtonId, ButtonEvent)> button_signal_;
      boost::signals2::signal<void(int, int)> move_signal_;
      boost::signals2::signal<void(int)> wheel_signal_;
    };
    
    }  // namespace phx
    
    #endif  // LIBRARY_PHX_INPUT_MOUSE_HPP_