martinpitt / umockdev

Mock hardware devices for creating unit tests and bug reporting
https://launchpad.net/umockdev
GNU Lesser General Public License v2.1
314 stars 58 forks source link

generating input events #247

Open mkemlogic opened 6 months ago

mkemlogic commented 6 months ago

Currently it is possible to play back recorded events with umockdev_testbed_load_evemu_events(). It would be very useful to be able to generate input events directly from the code, similar to umockdev_testbed_uevent(). Maybe there is a way I'm not aware of?

I have tried:

cmd = g_strdup_printf("evemu-event --sync /dev/input/event1 --type EV_SW --code 15 --value 1");
g_assert(g_spawn_command_line_async(cmd, NULL));

but the events are nowhere to be found. evtest does not pick them up when called like that:

cmd = g_strdup_printf("evtest /dev/input/event1");
g_assert(g_spawn_command_line_async(cmd, NULL));

Note that evtest run this way can see events submitted by umockdev_testbed_load_evemu_events().

mkemlogic commented 6 months ago

I've made this PR https://github.com/mkemlogic/umockdev/pull/1 as a workaround. This allows me to generate one event at a time, or multiple if needed.