aboutsummaryrefslogtreecommitdiffstats
path: root/yage/core/inputmanager.cpp
blob: 1f324b9e0e00def738a55b080abd32cbb39d1c1b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/** ---------------------------------------------------------------------------
 * @file: inputmanager.cpp
 *
 * Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com>
 * MIT License, see LICENSE file for more details.
 * ----------------------------------------------------------------------------
 */

#include <yage/core/inputmanager.h>

namespace yage
{

void InputManager::keyPressed(unsigned key)
{
    key_map_[key] = true;
}

void InputManager::keyReleased(unsigned key)
{
    key_map_[key] = false;
}

bool InputManager::isKeyPressed(unsigned key) const
{
    auto key_index = key_map_.find(key);
    if (key_index != key_map_.end()) {
        return key_index->second;
    }
    return false;
}

} // namespace yage