Skip to content

Commit

Permalink
changed mouse and input_manager
Browse files Browse the repository at this point in the history
  • Loading branch information
fmmarques committed Sep 1, 2019
1 parent b165f66 commit 000b94b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 4 additions & 2 deletions src/input/input_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ input_manager::input_manager():
invariant();
event_manager::instance().subscribe(
this,
{ ::SDL_KEYDOWN ,::SDL_KEYUP
,::SDL_MOUSEBUTTONDOWN ,::SDL_MOUSEBUTTONUP });
{ ::SDL_KEYDOWN ,::SDL_KEYUP
,::SDL_MOUSEBUTTONDOWN ,::SDL_MOUSEBUTTONUP
,::SDL_MOUSEMOTION });
}

input_manager& input_manager::instance()
Expand Down Expand Up @@ -97,6 +98,7 @@ void input_manager::unsubscribe( input_listener *listener )
// event_listener implementation
void input_manager::on_event(const SDL_Event& ev)
{
std::string fn { std::string( __PRETTY_FUNCTION__ ) + ": "};
std::list< mouse_listener * > m_l;
std::list< keyboard_listener * > k_l;

Expand Down
2 changes: 0 additions & 2 deletions src/input/mouse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,13 @@ void mouse::on_mouse_button_down(const SDL_MouseButtonEvent& e)
s[CLICK] = s[DOUBLE_CLICK] = s[DRAGGING] = false;
int index = e.clicks % 2;
s[index] = true;
std::cout << fn << "received a " << ((index==1)? "click" : "double click") << std::endl;
}

void mouse::on_mouse_movement(const SDL_MouseMotionEvent& e)
{
std::unique_lock<decltype(m)> l(m);
std::string fn { std::string( __PRETTY_FUNCTION__ ) + ": "};
r.x = e.x ; r.y = e.y;
std::cout << fn << "enter with click: " << std::boolalpha << s[CLICK] << ", double click: " << s[DOUBLE_CLICK] << ", dragging: " << s[DRAGGING] << std::endl;
if (s[CLICK])
s[DRAGGING]=true;
else
Expand Down

0 comments on commit 000b94b

Please sign in to comment.