* uinput: waiting for UI_FF_UPLOAD events will not inform user when allocation is required @ 2023-10-10 7:08 John Salamon 2023-10-11 6:40 ` John Salamon 2023-10-13 21:59 ` Dmitry Torokhov 0 siblings, 2 replies; 4+ messages in thread From: John Salamon @ 2023-10-10 7:08 UTC (permalink / raw) To: dmitry.torokhov, rydberg; +Cc: linux-input, linux-kernel Currently the "fake" input events generated by uinput in response to effect uploads will return an effect with an id that has already been handled by input_ff_upload in ff-core.c, which can modify the effect id. This causes a problem specifically when the effect originally uploaded via the EVIOCSFF ioctl contained an effect with -1, as the userspace code handling UI_FF_UPLOAD receives an effect with an id other than -1, and therefore will not know an allocation was requested. I notice that the "old" field on the ff_effect struct is set to NULL when the -1 id is changed (in input_ff_upload), which can serve as a flag that an allocation was requested. If it is the intention is that uinput users check if old == NULL to know when allocations are needed I think uinput documentation should describe this. I first noticed this using python-evdev, see my issue report here: https://github.com/gvalkov/python-evdev/issues/199 ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: uinput: waiting for UI_FF_UPLOAD events will not inform user when allocation is required 2023-10-10 7:08 uinput: waiting for UI_FF_UPLOAD events will not inform user when allocation is required John Salamon @ 2023-10-11 6:40 ` John Salamon 2023-10-13 21:59 ` Dmitry Torokhov 1 sibling, 0 replies; 4+ messages in thread From: John Salamon @ 2023-10-11 6:40 UTC (permalink / raw) To: dmitry.torokhov, rydberg; +Cc: linux-input, linux-kernel Correction, "old" is a pointer to struct ff_effect, which after being set to NULL looks like it gets pushed out by uinput on a struct uinput_request. On Tue, Oct 10, 2023 at 5:38 PM John Salamon <salamonj9@gmail.com> wrote: > > Currently the "fake" input events generated by uinput in response to > effect uploads will return an effect with an id that has already been > handled by input_ff_upload in ff-core.c, which can modify the effect > id. This causes a problem specifically when the effect originally > uploaded via the EVIOCSFF ioctl contained an effect with -1, as the > userspace code handling UI_FF_UPLOAD receives an effect with an id > other than -1, and therefore will not know an allocation was > requested. > > I notice that the "old" field on the ff_effect struct is set to NULL > when the -1 id is changed (in input_ff_upload), which can serve as a > flag that an allocation was requested. If it is the intention is that > uinput users check if old == NULL to know when allocations are needed > I think uinput documentation should describe this. > > I first noticed this using python-evdev, see my issue report here: > https://github.com/gvalkov/python-evdev/issues/199 ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: uinput: waiting for UI_FF_UPLOAD events will not inform user when allocation is required 2023-10-10 7:08 uinput: waiting for UI_FF_UPLOAD events will not inform user when allocation is required John Salamon 2023-10-11 6:40 ` John Salamon @ 2023-10-13 21:59 ` Dmitry Torokhov 2023-10-14 6:32 ` John Salamon 1 sibling, 1 reply; 4+ messages in thread From: Dmitry Torokhov @ 2023-10-13 21:59 UTC (permalink / raw) To: John Salamon; +Cc: rydberg, linux-input, linux-kernel Hi John, On Tue, Oct 10, 2023 at 05:38:27PM +1030, John Salamon wrote: > Currently the "fake" input events generated by uinput in response to > effect uploads will return an effect with an id that has already been > handled by input_ff_upload in ff-core.c, which can modify the effect > id. This causes a problem specifically when the effect originally > uploaded via the EVIOCSFF ioctl contained an effect with -1, as the > userspace code handling UI_FF_UPLOAD receives an effect with an id > other than -1, and therefore will not know an allocation was > requested. The kernel never changes ID of an existing effect, the only time ID is changed is when userspace indicates that a new effect should be created by setting effect ID to -1. The handler of force feedback effects should know what effects (with what IDs) have been uploaded to the device so far, so whenever it sees a request for an effect with previously unseen effect_id it should recognize this as a signal that a new effect/id has been allocated by the kernel. > > I notice that the "old" field on the ff_effect struct is set to NULL > when the -1 id is changed (in input_ff_upload), which can serve as a > flag that an allocation was requested. If it is the intention is that > uinput users check if old == NULL to know when allocations are needed > I think uinput documentation should describe this. No, not really, as explained above. > > I first noticed this using python-evdev, see my issue report here: > https://github.com/gvalkov/python-evdev/issues/199 Thanks. -- Dmitry ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: uinput: waiting for UI_FF_UPLOAD events will not inform user when allocation is required 2023-10-13 21:59 ` Dmitry Torokhov @ 2023-10-14 6:32 ` John Salamon 0 siblings, 0 replies; 4+ messages in thread From: John Salamon @ 2023-10-14 6:32 UTC (permalink / raw) To: Dmitry Torokhov; +Cc: rydberg, linux-input, linux-kernel Hi Dmitry, Thank you for the clarification. > The handler of force feedback effects should know what effects (with > what IDs) have been uploaded to the device so far, so whenever it sees a > request for an effect with previously unseen effect_id it should > recognize this as a signal that a new effect/id has been allocated by > the kernel. In that case, would you consider accepting a patch adding a sentence or two explaining that handlers will need to keep track of effect IDs in this manner? Either in uinput documentation or just in the comment describing how to implement upload_effect() in uinput.h. Something along the lines of "Effects received here will never have an ID of -1. Handlers of these effects must recognize previously unseen effect IDs to know when a new effect has been allocated.". Cheers, John On Sat, Oct 14, 2023 at 8:29 AM Dmitry Torokhov <dmitry.torokhov@gmail.com> wrote: > > Hi John, > > On Tue, Oct 10, 2023 at 05:38:27PM +1030, John Salamon wrote: > > Currently the "fake" input events generated by uinput in response to > > effect uploads will return an effect with an id that has already been > > handled by input_ff_upload in ff-core.c, which can modify the effect > > id. This causes a problem specifically when the effect originally > > uploaded via the EVIOCSFF ioctl contained an effect with -1, as the > > userspace code handling UI_FF_UPLOAD receives an effect with an id > > other than -1, and therefore will not know an allocation was > > requested. > > The kernel never changes ID of an existing effect, the only time ID is > changed is when userspace indicates that a new effect should be created > by setting effect ID to -1. > > The handler of force feedback effects should know what effects (with > what IDs) have been uploaded to the device so far, so whenever it sees a > request for an effect with previously unseen effect_id it should > recognize this as a signal that a new effect/id has been allocated by > the kernel. > > > > > I notice that the "old" field on the ff_effect struct is set to NULL > > when the -1 id is changed (in input_ff_upload), which can serve as a > > flag that an allocation was requested. If it is the intention is that > > uinput users check if old == NULL to know when allocations are needed > > I think uinput documentation should describe this. > > No, not really, as explained above. > > > > > I first noticed this using python-evdev, see my issue report here: > > https://github.com/gvalkov/python-evdev/issues/199 > > Thanks. > > -- > Dmitry ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-10-14 6:32 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2023-10-10 7:08 uinput: waiting for UI_FF_UPLOAD events will not inform user when allocation is required John Salamon 2023-10-11 6:40 ` John Salamon 2023-10-13 21:59 ` Dmitry Torokhov 2023-10-14 6:32 ` John Salamon
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).