Source

pyGAP / game / src / input / x11 / mouse.cpp

Full commit
#include "input/x11/mouse.h"

#include <X11/Xlib.h>


namespace input {
namespace x11 {


Mouse::Mouse(::Display* display):
    display_(display),
    window_(0)
{}


Mouse::~Mouse()
{}


bool Mouse::is_pressed(int button)
{}


int Mouse::get_x() { return x_; }
int Mouse::get_y() { return y_; }

void Mouse::update() {
    ::Window root_window;
    ::Window child_window;
    int root_x, root_y;
    int win_x, win_y;
    unsigned int mask;

    ::XQueryPointer(display_, window_, &root_window, &child_window, &root_x, &root_y, &win_x, &win_y, &mask);
    x_ = win_x - 160;
    y_ = win_y - 120;

    ::XWarpPointer(display_, None, window_, 0, 0, 0, 0, 160, 120);
}


} // namespace x11
} // namespace input