Skip to contentSkip to conversation

uinput really needs a custom sleep time?

DISCUSSION Marcos Paulo de Souza 3 participants 7 messages Jan 31, 2017 – Feb 3, 2017 HID

lore
Share & tools
lore
#0 lore raw

Hi input guys,

after playing with uinput, it seems an sleep call is necessary before emitting new events. If this really required?

While reading code of cwiid project, another user of uinput interface, it seems this sleep time isn't necessary[1].

In the other hang, when trying to send a simple event in my desktop, an sleep is necessary, take a look in my example[2].

Another interesting fact: kernel documentation lacks of an uinput example. Do you think this would be interesting to have one?

Thanks for your time,
Marcos

[1] https://github.com/abstrakraft/cwiid/blob/master/wminput/uinput.c#L193
[2] https://github.com/marcosps/kernel_experiments/blob/master/userspace/uinput.c#L65

#1 lore raw
Quoted 7 lines · Marcos Paulo de Souza

Hi input guys,

after playing with uinput, it seems an sleep call is necessary before emitting new events. If this really required?

While reading code of cwiid project, another user of uinput interface, it seems this sleep time isn't necessary[1].

In the other hang, when trying to send a simple event in my desktop, an sleep is necessary, take a look in my example[2].

The sleep is not necessary for sending events, but you need to give time for the rest of the system to notice that there is new input device, decide what to do with it, and open it, so that you can actually observe the events you sent, as opposed for them to be dropped because there are no users of that input device.

Thanks.

Signature · 1 line
Dmitry
#2 lore raw
Quoted 8 lines · Dmitry Torokhov
Quoted 6 lines · Marcos Paulo de Souza

Hi input guys,

after playing with uinput, it seems an sleep call is necessary before emitting new events. If this really required?

While reading code of cwiid project, another user of uinput interface, it seems this sleep time isn't necessary[1].

Quoted 7 lines
Quoted 1 line

In the other hang, when trying to send a simple event in my desktop, an sleep is necessary, take a look in my example[2].

The sleep is not necessary for sending events, but you need to give time for the rest of the system to notice that there is new input device, decide what to do with it, and open it, so that you can actually observe the events you sent, as opposed for them to be dropped because there are no users of that input device.

Makes sense to wait to the Window Manager to "discover" the new input device and to receive the events. Thanks for the clarification!

Quoted 5 lines

Thanks.

Signature · 1 line
Dmitry
#3 lore raw
In reply to Marcos Paulo de Souza
Quoted 5 lines · Marcos Paulo de Souza

Hi input guys,

after playing with uinput, it seems an sleep call is necessary before emitting new events. If this really required?

Quoted 8 lines

While reading code of cwiid project, another user of uinput interface, it seems this sleep time isn't necessary[1].

In the other hang, when trying to send a simple event in my desktop, an sleep is necessary, take a look in my example[2].

Another interesting fact: kernel documentation lacks of an uinput example. Do you think this would be interesting to have one?

I'm obviously biased but imo you should really use libevdev for uinput devices, it makes things a lot easier. Example is here:
https://www.freedesktop.org/software/libevdev/doc/latest/group__uinput.html

it also makes any sleep calls obsolete because it won't return until the device node is available.

Cheers,
Peter

Quoted 11 lines

Thanks for your time,
Marcos

[1] https://github.com/abstrakraft/cwiid/blob/master/wminput/uinput.c#L193
[2] https://github.com/marcosps/kernel_experiments/blob/master/userspace/uinput.c#L65
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#4 lore raw

Hi Peter,

Quoted 15 lines · Peter Hutterer
Quoted 5 lines · Marcos Paulo de Souza

Hi input guys,

after playing with uinput, it seems an sleep call is necessary before emitting new events. If this really required?

Quoted 8 lines

While reading code of cwiid project, another user of uinput interface, it seems this sleep time isn't necessary[1].

In the other hang, when trying to send a simple event in my desktop, an sleep is necessary, take a look in my example[2].

Another interesting fact: kernel documentation lacks of an uinput example. Do you think this would be interesting to have one?

Quoted 6 lines

I'm obviously biased but imo you should really use libevdev for uinput devices, it makes things a lot easier. Example is here:
https://www.freedesktop.org/software/libevdev/doc/latest/group__uinput.html

it also makes any sleep calls obsolete because it won't return until the device node is available.

So, I had some problems to understand the relation to EV_KEY, EV_TYPE, and other stuff to configure uinput, and reading about evdev[1], I think I really should take a look on it.

Thanks a lot for pointing evdev as a "competitor" of uinput!

[1]
http://who-t.blogspot.com.br/2016/05/the-difference-between-uinput-and-evdev.html

Quoted 15 lines

Cheers,
Peter

Quoted 11 lines

Thanks for your time,
Marcos

[1] https://github.com/abstrakraft/cwiid/blob/master/wminput/uinput.c#L193
[2] https://github.com/marcosps/kernel_experiments/blob/master/userspace/uinput.c#L65
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#5 lore raw
In reply to Peter Hutterer
Quoted 15 lines · Peter Hutterer
Quoted 5 lines · Marcos Paulo de Souza

Hi input guys,

after playing with uinput, it seems an sleep call is necessary before emitting new events. If this really required?

Quoted 8 lines

While reading code of cwiid project, another user of uinput interface, it seems this sleep time isn't necessary[1].

In the other hang, when trying to send a simple event in my desktop, an sleep is necessary, take a look in my example[2].

Another interesting fact: kernel documentation lacks of an uinput example. Do you think this would be interesting to have one?

Quoted 6 lines

I'm obviously biased but imo you should really use libevdev for uinput devices, it makes things a lot easier. Example is here:
https://www.freedesktop.org/software/libevdev/doc/latest/group__uinput.html

it also makes any sleep calls obsolete because it won't return until the device node is available.

I created another example[1], basically converting my uinput code now using libevdev, but it doesn't work as it should...

Am I missing something, or forgetting to set some bit?

Thanks.

[1]
https://github.com/marcosps/kernel_experiments/blob/master/userspace/evdev.c

Quoted 15 lines

Cheers,
Peter

Quoted 11 lines

Thanks for your time,
Marcos

[1] https://github.com/abstrakraft/cwiid/blob/master/wminput/uinput.c#L193
[2] https://github.com/marcosps/kernel_experiments/blob/master/userspace/uinput.c#L65
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#6 lore raw
Quoted 20 lines · Marcos Paulo de Souza
Quoted 19 lines · Peter Hutterer
Quoted 5 lines · Marcos Paulo de Souza

Hi input guys,

after playing with uinput, it seems an sleep call is necessary before emitting new events. If this really required?

Quoted 8 lines

While reading code of cwiid project, another user of uinput interface, it seems this sleep time isn't necessary[1].

In the other hang, when trying to send a simple event in my desktop, an sleep is necessary, take a look in my example[2].

Another interesting fact: kernel documentation lacks of an uinput example. Do you think this would be interesting to have one?

I'm obviously biased but imo you should really use libevdev for uinput devices, it makes things a lot easier. Example is here:
https://www.freedesktop.org/software/libevdev/doc/latest/group__uinput.html

Quoted 7 lines
Quoted 2 lines

it also makes any sleep calls obsolete because it won't return until the device node is available.

I created another example[1], basically converting my uinput code now using libevdev, but it doesn't work as it should...

Am I missing something, or forgetting to set some bit?

you're missing a SYN_REPORT after the key down.

Cheers,
Peter

Quoted 21 lines

Thanks.

[1]
https://github.com/marcosps/kernel_experiments/blob/master/userspace/evdev.c

Quoted 15 lines

Cheers,
Peter

Quoted 11 lines

Thanks for your time,
Marcos

[1] https://github.com/abstrakraft/cwiid/blob/master/wminput/uinput.c#L193
[2] https://github.com/marcosps/kernel_experiments/blob/master/userspace/uinput.c#L65
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html