[C / C++] C言語でUbuntuでのマウスイベントの取得 – Ubuntuの上でマウスイベントC
Ubuntuのではマウスイベントをキャプチャするために、我々は、ライブラリX11 / Xlib.hを使用. コマンドを使用してこのライブラリを設定します:
須藤はapt-getをインストールlibx11-devの
これは、プログラムのページから示す図であります http://stackoverflow.com/questions/14553435/how-to-listen-for-mouse-events-in-linux
#include <stdio.h>
#include <X11/Xlib.h>
char *key_name[] = {
"first",
"second (or middle)",
"third",
"fourth",
"fivth"
};
int main(int argc, char **argv)
{
Display *display;
XEvent xevent;
Window window;
if( (display = XOpenDisplay(NULL)) == NULL )
return -1;
window = DefaultRootWindow(display);
XAllowEvents(display, AsyncBoth, CurrentTime);
XGrabPointer(display,
window,
1,
PointerMotionMask | ButtonPressMask | ButtonReleaseMask ,
GrabModeAsync,
GrabModeAsync,
None,
None,
CurrentTime);
while(1) {
XNextEvent(display, &xevent);
switch (xevent.type) {
case MotionNotify:
printf("Mouse move : [%d, %d]n", xevent.xmotion.x_root, xevent.xmotion.y_root);
break;
case ButtonPress:
printf("Button pressed : %sn", key_name[xevent.xbutton.button - 1]);
break;
case ButtonRelease:
printf("Button released : %sn", key_name[xevent.xbutton.button - 1]);
break;
}
}
return 0;
}

しかし、私はまだグラフィックスでそれを使用する方法がわかりません. 私たちは、あなたがこの点で共有する願っています.
参照する: 開発-Cをクリック



Windows上で使用され、この1はブロを取得します ?!
可能な場合は、ライブラリを自分でインストールするか、何も先生をインストールする必要があります ?!
TKS !
あまりにも持っています. あなたはここを参照してください: https://cachhoc.net/2013/10/03/cc-click-chuot-trong-dev-c-mouse-event-in-dev-c/