Tengo un dispositivo integrado que ejecuta Linux/X11 que está conectado a un dispositivo que proporciona eventos táctiles a través de una conexión USB. Este dispositivo no se reconoce como ninguna forma de entrada estándar de puntero/mouse. Lo que intento hacer es encontrar una forma de "inyectar" eventos del mouse en X11 cuando el dispositivo externo informa un evento.Cómo insertar eventos de mouse sintéticos en la cola de entrada X11
Al hacerlo eliminaría la necesidad de mi aplicación (escrita en C usando Gtk +) para falsificar las pulsaciones del mouse con llamadas Gtk +.
Si esto se puede hacer, mi aplicación Gtk + no necesitaría saber o preocuparse por el dispositivo que genera los eventos táctiles. Simplemente aparecería en la aplicación como eventos estándar del mouse.
¿Alguien sabe cómo hacer para insertar eventos de mouse sintéticos en X11?
En este momento estoy haciendo lo siguiente que funciona, pero no es óptimo.
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);
}
Excelente ... esta puede ser la respuesta. Tendré que ver si mi dispositivo Linux incorporado admite el sistema 'uinput'. Gracias. – Chimera