Source

pyGAP / game / src / game / game_x11.cpp

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


#include "game/input/command_sample.h"

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

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

namespace game {


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


int GameX11::init_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;

    commands->set_num_commands(CommandSample::MAX);

    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);

    commands_ = commands;

    return 0;
}


GameX11::~GameX11()
{}


} /* namespace x11 */