mirror of
https://github.com/apache/nuttx.git
synced 2026-05-28 11:56:10 +08:00
drivers/input: enable touch/kbd/mouse for virtio input
Signed-off-by: liuhongchao <liuhongchao@xiaomi.com>
This commit is contained in:
@@ -35,8 +35,8 @@ config DRIVERS_VIRTIO_GPU
|
|||||||
|
|
||||||
config DRIVERS_VIRTIO_INPUT
|
config DRIVERS_VIRTIO_INPUT
|
||||||
bool "Virtio input support"
|
bool "Virtio input support"
|
||||||
|
depends on INPUT && INPUT_TOUCHSCREEN && INPUT_KEYBOARD && INPUT_MOUSE
|
||||||
default n
|
default n
|
||||||
depends on INPUT
|
|
||||||
|
|
||||||
config DRIVERS_VIRTIO_NET
|
config DRIVERS_VIRTIO_NET
|
||||||
bool "Virtio network support"
|
bool "Virtio network support"
|
||||||
|
|||||||
@@ -165,6 +165,10 @@ virtio_input_send_mouse_event(FAR struct virtio_input_priv *priv,
|
|||||||
{
|
{
|
||||||
priv->mousesample.buttons |= MOUSE_BUTTON_1;
|
priv->mousesample.buttons |= MOUSE_BUTTON_1;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
priv->mousesample.buttons &= ~MOUSE_BUTTON_1;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BTN_RIGHT:
|
case BTN_RIGHT:
|
||||||
@@ -172,6 +176,10 @@ virtio_input_send_mouse_event(FAR struct virtio_input_priv *priv,
|
|||||||
{
|
{
|
||||||
priv->mousesample.buttons |= MOUSE_BUTTON_2;
|
priv->mousesample.buttons |= MOUSE_BUTTON_2;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
priv->mousesample.buttons &= ~MOUSE_BUTTON_2;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BTN_MIDDLE:
|
case BTN_MIDDLE:
|
||||||
@@ -179,13 +187,18 @@ virtio_input_send_mouse_event(FAR struct virtio_input_priv *priv,
|
|||||||
{
|
{
|
||||||
priv->mousesample.buttons |= MOUSE_BUTTON_3;
|
priv->mousesample.buttons |= MOUSE_BUTTON_3;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
priv->mousesample.buttons &= ~MOUSE_BUTTON_3;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (event->type == EV_SYN && event->code == SYN_REPORT)
|
else if (event->type == EV_SYN && event->code == SYN_REPORT)
|
||||||
{
|
{
|
||||||
mouse_event(priv->mouselower.priv, &priv->mousesample);
|
mouse_event(priv->mouselower.priv, &priv->mousesample);
|
||||||
memset(&priv->mousesample, 0, sizeof(priv->mousesample));
|
priv->mousesample.x = 0;
|
||||||
|
priv->mousesample.y = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -242,7 +255,7 @@ static void virtio_input_worker(FAR void *arg)
|
|||||||
while ((evt = (FAR struct virtio_input_event *)
|
while ((evt = (FAR struct virtio_input_event *)
|
||||||
virtqueue_get_buffer(vq, &len, NULL)) != NULL)
|
virtqueue_get_buffer(vq, &len, NULL)) != NULL)
|
||||||
{
|
{
|
||||||
vrtinfo("virtio_input_worker (type,code,value) - (%d,%d,%d).\n",
|
vrtinfo("virtio_input_worker (type,code,value)-(%d,%d,%" PRIu32 ").\n",
|
||||||
evt->type, evt->code, evt->value);
|
evt->type, evt->code, evt->value);
|
||||||
|
|
||||||
priv->eventhandler(priv, evt);
|
priv->eventhandler(priv, evt);
|
||||||
@@ -319,7 +332,7 @@ static void virtio_input_register(FAR struct virtio_input_priv *priv)
|
|||||||
if (virtio_input_select_cfg(priv, VIRTIO_INPUT_CFG_EV_BITS, EV_ABS))
|
if (virtio_input_select_cfg(priv, VIRTIO_INPUT_CFG_EV_BITS, EV_ABS))
|
||||||
{
|
{
|
||||||
priv->touchlower.maxpoint = 1;
|
priv->touchlower.maxpoint = 1;
|
||||||
snprintf(priv->name, NAME_MAX, "/dev/virtinput%d",
|
snprintf(priv->name, NAME_MAX, "/dev/input%d",
|
||||||
g_virtio_touch_idx++);
|
g_virtio_touch_idx++);
|
||||||
touch_register(&(priv->touchlower),
|
touch_register(&(priv->touchlower),
|
||||||
priv->name,
|
priv->name,
|
||||||
@@ -328,7 +341,7 @@ static void virtio_input_register(FAR struct virtio_input_priv *priv)
|
|||||||
}
|
}
|
||||||
else if (virtio_input_select_cfg(priv, VIRTIO_INPUT_CFG_EV_BITS, EV_REL))
|
else if (virtio_input_select_cfg(priv, VIRTIO_INPUT_CFG_EV_BITS, EV_REL))
|
||||||
{
|
{
|
||||||
snprintf(priv->name, NAME_MAX, "/dev/virtmouse%d",
|
snprintf(priv->name, NAME_MAX, "/dev/mouse%d",
|
||||||
g_virtio_mouse_idx++);
|
g_virtio_mouse_idx++);
|
||||||
mouse_register(&(priv->mouselower),
|
mouse_register(&(priv->mouselower),
|
||||||
priv->name,
|
priv->name,
|
||||||
@@ -337,7 +350,7 @@ static void virtio_input_register(FAR struct virtio_input_priv *priv)
|
|||||||
}
|
}
|
||||||
else if (virtio_input_select_cfg(priv, VIRTIO_INPUT_CFG_EV_BITS, EV_KEY))
|
else if (virtio_input_select_cfg(priv, VIRTIO_INPUT_CFG_EV_BITS, EV_KEY))
|
||||||
{
|
{
|
||||||
snprintf(priv->name, NAME_MAX, "/dev/virtkbd%d",
|
snprintf(priv->name, NAME_MAX, "/dev/kbd%d",
|
||||||
g_virtio_keyboard_idx++);
|
g_virtio_keyboard_idx++);
|
||||||
keyboard_register(&(priv->keyboardlower),
|
keyboard_register(&(priv->keyboardlower),
|
||||||
priv->name,
|
priv->name,
|
||||||
|
|||||||
Reference in New Issue
Block a user