Skip to content

Commit

Permalink
Use :: for global calls.
Browse files Browse the repository at this point in the history
  • Loading branch information
przemek83 committed Sep 13, 2024
1 parent 81bead2 commit 86f9385
Showing 1 changed file with 19 additions and 18 deletions.
37 changes: 19 additions & 18 deletions src/Input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,28 @@
#include "Config.h"
#include "InputAction.h"

Input::Input() : events_(al_create_event_queue())
Input::Input() : events_(::al_create_event_queue())
{
ALLEGRO_TIMER* timer{al_create_timer(1.0 / Config::getInstance().getFps())};
al_register_event_source(events_, al_get_keyboard_event_source());
al_register_event_source(events_, al_get_mouse_event_source());
al_register_event_source(
events_, al_get_display_event_source(al_get_current_display()));
al_register_event_source(events_, al_get_timer_event_source(timer));
al_start_timer(timer);
ALLEGRO_TIMER* timer{
::al_create_timer(1.0 / Config::getInstance().getFps())};
::al_register_event_source(events_, ::al_get_keyboard_event_source());
::al_register_event_source(events_, ::al_get_mouse_event_source());
::al_register_event_source(
events_, ::al_get_display_event_source(::al_get_current_display()));
::al_register_event_source(events_, ::al_get_timer_event_source(timer));
::al_start_timer(timer);
}

void Input::init()
{
al_install_keyboard();
al_install_mouse();
::al_install_keyboard();
::al_install_mouse();
}

InputAction Input::getMenuAction()
{
ALLEGRO_EVENT event{};
al_wait_for_event(events_, &event);
::al_wait_for_event(events_, &event);

if (const InputAction action{getCommonAction(event)};
action != InputAction::EMPTY)
Expand Down Expand Up @@ -55,7 +56,7 @@ InputAction Input::getMenuAction()
std::set<InputAction> Input::getGameActions()
{
ALLEGRO_KEYBOARD_STATE keyState;
al_get_keyboard_state(&keyState);
::al_get_keyboard_state(&keyState);

std::set<InputAction> ongoingActions{};
if (fired(keyState))
Expand Down Expand Up @@ -102,8 +103,8 @@ bool Input::itemPicked(const ALLEGRO_EVENT& event)

bool Input::fired(const ALLEGRO_KEYBOARD_STATE& keyState)
{
return al_key_down(&keyState, ALLEGRO_KEY_SPACE) ||
al_key_down(&keyState, ALLEGRO_KEY_ENTER);
return ::al_key_down(&keyState, ALLEGRO_KEY_SPACE) ||
::al_key_down(&keyState, ALLEGRO_KEY_ENTER);
}

bool Input::userWantToExit(const ALLEGRO_EVENT& event)
Expand Down Expand Up @@ -131,22 +132,22 @@ bool Input::keyDownUsed(const ALLEGRO_EVENT& event)

bool Input::keyUpPressed(const ALLEGRO_KEYBOARD_STATE& keyState)
{
return al_key_down(&keyState, ALLEGRO_KEY_UP);
return ::al_key_down(&keyState, ALLEGRO_KEY_UP);
}

bool Input::keyDownPressed(const ALLEGRO_KEYBOARD_STATE& keyState)
{
return al_key_down(&keyState, ALLEGRO_KEY_DOWN);
return ::al_key_down(&keyState, ALLEGRO_KEY_DOWN);
}

bool Input::keyLeftPressed(const ALLEGRO_KEYBOARD_STATE& keyState)
{
return al_key_down(&keyState, ALLEGRO_KEY_LEFT);
return ::al_key_down(&keyState, ALLEGRO_KEY_LEFT);
}

bool Input::keyRightPressed(const ALLEGRO_KEYBOARD_STATE& keyState)
{
return al_key_down(&keyState, ALLEGRO_KEY_RIGHT);
return ::al_key_down(&keyState, ALLEGRO_KEY_RIGHT);
}

bool Input::keyEnterUsed(const ALLEGRO_EVENT& event)
Expand Down

0 comments on commit 86f9385

Please sign in to comment.