USB接続でタッチイベントを提供するデバイスに接続されているLinux/X11を搭載した組み込みデバイスがあります。このデバイスは、標準的なポインタ/マウス入力の形式として認識されません。私がしようとしているのは、外部デバイスがイベントを報告したときにマウスイベントをX11に「注入」する方法です。合成マウスイベントをX11入力キューに挿入する方法
これを行うと、Gtk +でマウスを押すことを偽装するために、私のアプリケーション(Gtk +を使ってCで書かれている)が不要になります。
私のGtk +アプリケーションは、タッチイベントを生成するデバイスを知っていたり気にする必要はありません。標準のマウスイベントとしてアプリケーションに表示されます。
誰もが合成マウスイベントをX11に挿入する方法を知っていますか?
今私は以下のことをしていますが、最適ではありません。
GtkWidget *btnSpin; /* sample button */
gboolean buttonPress_cb(void *btn);
gboolean buttonDePress_cb(void *btn);
/* make this call after the device library calls the TouchEvent_cb() callback
and the application has determined which, if any, button was touched
In this example we are assuming btnSpin was touched.
This function will, in 5ms, begin the process of causing the button to do it's
normal animation (button in, button out effects) and then send the actual
button_clicked event to the button.
*/
g_timeout_add(5, (GSourceFunc) buttonPress_cb, (void *)btnSpin);
/* this callback is fired 5ms after the g_timeout_add() function above.
It first sets the button state to ACTIVE to begin the animation cycle (pressed look)
And then 250ms later calls buttonDePress_cb which will make the button look un-pressed
and then send the button_clicked event.
*/
gboolean buttonPress_cb(void *btn)
{
gtk_widget_set_state((GtkWidget *)btn, GTK_STATE_ACTIVE);
g_timeout_add(250, (GSourceFunc) buttonDePress_cb, btn);
return(FALSE);
}
/* Sets button state back to NORMAL (not pressed look)
and sends the button_clicked event so that the registered signal handler for the
button can be activated
*/
gboolean buttonDePress_cb(void *btn)
{
gtk_widget_set_state(btn, GTK_STATE_NORMAL);
gtk_button_clicked(GTK_BUTTON(btn));
return(FALSE);
}
優秀な..これはちょうど答えかもしれません。私の組み込みLinuxデバイスが 'uinput'システムをサポートしているかどうかを確認する必要があります。 ありがとうございます。 – Chimera