Source

pyGAP / game / src / game / game_x11.cpp

Full commit
#include "game/game_x11.h"
#include "platform/x11/platform_x11.h"

#include "game/game_loop_sample.h"
#include "game/input/command_sample.h"

#include "input/input.h"
#include "input/command.h"
#include "input/command_manager.h"

#include "input/x11/mouse.h"
#include "input/x11/keyboard.h"


namespace game {


GameX11::GameX11(platform::GameLoop* game_loop):
    platform::x11::ApplicationX11(game_loop)
{}


int GameX11::init_commands()
{
    GameLoopSample* game_loop = static_cast< GameLoopSample* >(get_game_loop());
    input::CommandManager* commands = game_loop->get_commands();

    //TODO: read config from file
    //input::CommandManager* commands = new input::CommandManager;
    input::x11::Keyboard* keyboard = static_cast< input::x11::Keyboard* >(input_devices_[0]);
    input::Input* i;

    i = new input::Input(keyboard, keyboard->get_key_code(input::Keyboard::KEY_ESC));
    (*commands)[CommandSample::QUIT] = input::Command(i);

    i = new input::Input(keyboard, keyboard->get_key_code(input::Keyboard::KEY_S));
    (*commands)[CommandSample::SWITCH] = input::Command(i);

    i = new input::Input(keyboard, keyboard->get_key_code(input::Keyboard::KEY_P));
    (*commands)[CommandSample::PAUSE] = input::Command(i);

    return 0;
}


GameX11::~GameX11()
{}


} /* namespace x11 */