* uinput: How to use force feedback?
@ 2016-01-17 13:27 Manuel Reimer
2016-01-17 15:46 ` Elias Vanderstuyft
0 siblings, 1 reply; 8+ messages in thread
From: Manuel Reimer @ 2016-01-17 13:27 UTC (permalink / raw)
To: linux-input
Hello,
I have an existing uinput driver, which itself sits on an open device
with a blocking read(), waiting for events to come in. Every event is
translated to a key code and then sent to uinput.
My next step would be to pass through force feedback information, but I
don't really understand how I should do this.
As far as I can see, the "uninput device" itself sends events in this
case. But my main loop is already blocked by the "read", I use to get
device events.
I see two possible solutions:
- "Somehow", I should be able to get "blocking read" from two open
devices. As far as I found out, so far, "select" should be the right
command to do this?
- I could start two threads. One blocked by the "device events" and one
by the "uinput events".
Which one would you recommend? Is uinput/ioctl thread safe? Is the
second thread a good idea or is the communication, coming from uinput,
such "low traffic", that it doesn't delay key handling in a relevant way?
Thank you very much in advance
Manuel
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: uinput: How to use force feedback?
2016-01-17 13:27 uinput: How to use force feedback? Manuel Reimer
@ 2016-01-17 15:46 ` Elias Vanderstuyft
2016-01-17 15:47 ` Elias Vanderstuyft
` (2 more replies)
0 siblings, 3 replies; 8+ messages in thread
From: Elias Vanderstuyft @ 2016-01-17 15:46 UTC (permalink / raw)
To: Manuel Reimer; +Cc: open list:HID CORE LAYER
On Sun, Jan 17, 2016 at 2:27 PM, Manuel Reimer
<Manuel.Spam@nurfuerspam.de> wrote:
> Hello,
>
> I have an existing uinput driver, which itself sits on an open device with a
> blocking read(), waiting for events to come in. Every event is translated to
> a key code and then sent to uinput.
>
> My next step would be to pass through force feedback information, but I
> don't really understand how I should do this.
Concerning this,
the following may give you an example how to read incoming FF events on uinput:
https://github.com/xboxdrv/xboxdrv/blob/8e9fb6b40df568d4e4af63e80518366ee4aa5fd3/src/linux_uinput.cpp#L341
A good while ago I started working on FF support for
the uinput user-space library libsuinput, (and also for python-uinput,)
but I have to clean up some things before I can merge it to:
https://github.com/xboxdrv/xboxdrv/blob/8e9fb6b40df568d4e4af63e80518366ee4aa5fd3/src/linux_uinput.cpp#L341
Thanks,
Elias
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: uinput: How to use force feedback?
2016-01-17 15:46 ` Elias Vanderstuyft
@ 2016-01-17 15:47 ` Elias Vanderstuyft
2016-01-18 17:39 ` Tuomas Räsänen
2016-02-05 15:54 ` Manuel Reimer
2 siblings, 0 replies; 8+ messages in thread
From: Elias Vanderstuyft @ 2016-01-17 15:47 UTC (permalink / raw)
To: Manuel Reimer; +Cc: open list:HID CORE LAYER
On Sun, Jan 17, 2016 at 4:46 PM, Elias Vanderstuyft <elias.vds@gmail.com> wrote:
> On Sun, Jan 17, 2016 at 2:27 PM, Manuel Reimer
> <Manuel.Spam@nurfuerspam.de> wrote:
>> Hello,
>>
>> I have an existing uinput driver, which itself sits on an open device with a
>> blocking read(), waiting for events to come in. Every event is translated to
>> a key code and then sent to uinput.
>>
>> My next step would be to pass through force feedback information, but I
>> don't really understand how I should do this.
>
> Concerning this,
> the following may give you an example how to read incoming FF events on uinput:
> https://github.com/xboxdrv/xboxdrv/blob/8e9fb6b40df568d4e4af63e80518366ee4aa5fd3/src/linux_uinput.cpp#L341
>
> A good while ago I started working on FF support for
> the uinput user-space library libsuinput, (and also for python-uinput,)
> but I have to clean up some things before I can merge it to:
> https://github.com/xboxdrv/xboxdrv/blob/8e9fb6b40df568d4e4af63e80518366ee4aa5fd3/src/linux_uinput.cpp#L341
Sorry for the typo, here is the correct link:
https://github.com/tuomasjjrasanen/python-uinput/tree/master/libsuinput
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: uinput: How to use force feedback?
2016-01-17 15:46 ` Elias Vanderstuyft
2016-01-17 15:47 ` Elias Vanderstuyft
@ 2016-01-18 17:39 ` Tuomas Räsänen
2016-02-05 15:54 ` Manuel Reimer
2 siblings, 0 replies; 8+ messages in thread
From: Tuomas Räsänen @ 2016-01-18 17:39 UTC (permalink / raw)
To: Elias Vanderstuyft; +Cc: Manuel Reimer, open list:HID CORE LAYER
On Sun, Jan 17, 2016 at 5:46 PM, Elias Vanderstuyft <elias.vds@gmail.com> wrote:
>
> A good while ago I started working on FF support for
> the uinput user-space library libsuinput, (and also for python-uinput,)
> but I have to clean up some things before I can merge it to:
> https://github.com/xboxdrv/xboxdrv/blob/8e9fb6b40df568d4e4af63e80518366ee4aa5fd3/src/linux_uinput.cpp#L341
>
Patches are more than welcome! (I'm the author of libsuinput, happy to
see someone actually uses it without python-uinput, but I welcome
patches to python-uinput as well).
--
Tuomas
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: uinput: How to use force feedback?
2016-01-17 15:46 ` Elias Vanderstuyft
2016-01-17 15:47 ` Elias Vanderstuyft
2016-01-18 17:39 ` Tuomas Räsänen
@ 2016-02-05 15:54 ` Manuel Reimer
2016-02-05 20:58 ` Manuel Reimer
2 siblings, 1 reply; 8+ messages in thread
From: Manuel Reimer @ 2016-02-05 15:54 UTC (permalink / raw)
To: linux-input
On 01/17/2016 04:46 PM, Elias Vanderstuyft wrote:
> Concerning this,
> the following may give you an example how to read incoming FF events on uinput:
> https://github.com/xboxdrv/xboxdrv/blob/8e9fb6b40df568d4e4af63e80518366ee4aa5fd3/src/linux_uinput.cpp#L341
Tried that and I'm pretty close to giving up...
I've added the following to my uinput init function:
// Set up force feedback parameters
ret = ioctl(fd, UI_SET_EVBIT, EV_FF);
ret = ioctl(fd, UI_SET_FFBIT, FF_PERIODIC);
ret = ioctl(fd, UI_SET_FFBIT, FF_RUMBLE);
ret = ioctl(fd, UI_SET_FFBIT, FF_GAIN);
ret = ioctl(fd, UI_SET_FFBIT, FF_SQUARE);
ret = ioctl(fd, UI_SET_FFBIT, FF_TRIANGLE);
ret = ioctl(fd, UI_SET_FFBIT, FF_SINE);
From my device handling thread, I'm starting a separate thread to
handle the opposite direction of communication. Plan is to do blocking
read from the open uinput device. I open the device with O_RDWR to be
able to read and write. The "rumble thread" starts with:
pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
struct input_event event;
while (1) {
ssize_t n = read(args->fduinput, &event, sizeof(event));
printf("n: %d\n", n);
Everything beyond this never executes. The read blocks forever.
And even worse: If the read blocks, my "driver", and all programs
connected to my input device, are deadlocked. No chance to kill them.
And to be honest: After three hours of debugging I'm kind of sick of
rebooting my machine over and over again.
Any chance to get some hint?
Thanks in advance
Manuel
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: uinput: How to use force feedback?
2016-02-05 15:54 ` Manuel Reimer
@ 2016-02-05 20:58 ` Manuel Reimer
2016-02-10 21:41 ` Elias Vanderstuyft
0 siblings, 1 reply; 8+ messages in thread
From: Manuel Reimer @ 2016-02-05 20:58 UTC (permalink / raw)
To: linux-input
Hello,
I just want to add here, that I found the reason for this problem.
It is required that the ff_effects_max field of the uinput_user_dev
struct is set. Without doing this everything just hangs...
Best regards,
Manuel
On 02/05/2016 04:54 PM, Manuel Reimer wrote:
> On 01/17/2016 04:46 PM, Elias Vanderstuyft wrote:
>> Concerning this,
>> the following may give you an example how to read incoming FF events
>> on uinput:
>> https://github.com/xboxdrv/xboxdrv/blob/8e9fb6b40df568d4e4af63e80518366ee4aa5fd3/src/linux_uinput.cpp#L341
>>
>
> Tried that and I'm pretty close to giving up...
>
> I've added the following to my uinput init function:
>
> // Set up force feedback parameters
> ret = ioctl(fd, UI_SET_EVBIT, EV_FF);
>
> ret = ioctl(fd, UI_SET_FFBIT, FF_PERIODIC);
> ret = ioctl(fd, UI_SET_FFBIT, FF_RUMBLE);
> ret = ioctl(fd, UI_SET_FFBIT, FF_GAIN);
> ret = ioctl(fd, UI_SET_FFBIT, FF_SQUARE);
> ret = ioctl(fd, UI_SET_FFBIT, FF_TRIANGLE);
> ret = ioctl(fd, UI_SET_FFBIT, FF_SINE);
>
> From my device handling thread, I'm starting a separate thread to
> handle the opposite direction of communication. Plan is to do blocking
> read from the open uinput device. I open the device with O_RDWR to be
> able to read and write. The "rumble thread" starts with:
>
> pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
> pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
>
> struct input_event event;
>
> while (1) {
> ssize_t n = read(args->fduinput, &event, sizeof(event));
> printf("n: %d\n", n);
>
> Everything beyond this never executes. The read blocks forever.
>
> And even worse: If the read blocks, my "driver", and all programs
> connected to my input device, are deadlocked. No chance to kill them.
>
> And to be honest: After three hours of debugging I'm kind of sick of
> rebooting my machine over and over again.
>
> Any chance to get some hint?
>
> Thanks in advance
>
> Manuel
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-input" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: uinput: How to use force feedback?
2016-02-05 20:58 ` Manuel Reimer
@ 2016-02-10 21:41 ` Elias Vanderstuyft
2016-02-15 20:05 ` Manuel Reimer
0 siblings, 1 reply; 8+ messages in thread
From: Elias Vanderstuyft @ 2016-02-10 21:41 UTC (permalink / raw)
To: Manuel Reimer; +Cc: open list:HID CORE LAYER
On Fri, Feb 5, 2016 at 9:58 PM, Manuel Reimer
<Manuel.Spam@nurfuerspam.de> wrote:
> Hello,
>
> I just want to add here, that I found the reason for this problem.
>
> It is required that the ff_effects_max field of the uinput_user_dev struct
> is set. Without doing this everything just hangs...
Indeed, the uinput_user_dev struct should be properly initialized.
I ran into the same problem, and I created some patches which may fix the hangs:
https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/commit/drivers/input/ff-core.c?id=33b96d934902f96e901b72ac18bbc47afad1ac20
https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/commit/drivers/input/misc/uinput.c?id=daf6cd0c1829c48cba197bd87d57fc8bf3f65faa
Which kernel version are you using?
The first patch is already in version 4.4.
Glad you got it working now,
Elias
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: uinput: How to use force feedback?
2016-02-10 21:41 ` Elias Vanderstuyft
@ 2016-02-15 20:05 ` Manuel Reimer
0 siblings, 0 replies; 8+ messages in thread
From: Manuel Reimer @ 2016-02-15 20:05 UTC (permalink / raw)
To: linux-input
On 02/10/2016 10:41 PM, Elias Vanderstuyft wrote:
> Which kernel version are you using?
> The first patch is already in version 4.4.
Currently 4.3.3. Self-built to have a small patch which makes PS4
controller bluetooth binding possible (will be in kernel in version 4.5).
Rumble seems to be a problem with uinput in general. For example it is
pretty easy to create "non-killable" processes if fftest is still
running when the uinput daemon is killed. Not much fun to debug
something like this, so I finally disabled my rumble support.
> Glad you got it working now,
Partially but not really solving my problem. Still working on it.
Manuel
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2016-02-15 20:11 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-17 13:27 uinput: How to use force feedback? Manuel Reimer
2016-01-17 15:46 ` Elias Vanderstuyft
2016-01-17 15:47 ` Elias Vanderstuyft
2016-01-18 17:39 ` Tuomas Räsänen
2016-02-05 15:54 ` Manuel Reimer
2016-02-05 20:58 ` Manuel Reimer
2016-02-10 21:41 ` Elias Vanderstuyft
2016-02-15 20:05 ` Manuel Reimer
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.