From: Manuel Reimer <mail+linux-input@m-reimer.de>
To: "Clément VUCHENER" <clement.vuchener@gmail.com>
Cc: linux-input <linux-input@vger.kernel.org>
Subject: Re: uinput: ioctls for UI_BEGIN_FF_UPLOAD fails (returns -1). How to debug?
Date: Mon, 28 Mar 2016 10:53:27 +0200 [thread overview]
Message-ID: <56F8F107.3050906@m-reimer.de> (raw)
In-Reply-To: <CAM4jgCp_t_mvayUbBnz_1aznbvZJz8jFLxbD49r=qLZCdOhH7Q@mail.gmail.com>
On 03/27/2016 09:11 PM, Clément VUCHENER wrote:
> Check the value of errno just after the failed call (and use strerror
> to get a nice error message).
See the following output of my test program
UI_FF_UPLOAD start
UI_FF_UPLOAD middle
first ioctl failed -1 Inappropriate ioctl for device
second ioctl failed -1 Inappropriate ioctl for device
UI_FF_UPLOAD end
> You also need to check the event code, it must be UI_FF_UPLOAD.
else if (event.type == EV_UINPUT) {
printf("EV_UINPUT %d\n", event.code);
if (event.code == UI_FF_UPLOAD) {
printf("UI_FF_UPLOAD start\n");
struct uinput_ff_upload upload;
memset(&upload, 0, sizeof(upload));
upload.request_id = event.value;
printf("UI_FF_UPLOAD middle\n");
int ret;
ret = ioctl(args->fduinput, UI_BEGIN_FF_UPLOAD, &upload);
if (ret < 0) {
printf("first ioctl failed %d %s\n", ret, strerror(errno));
}
// Remember ID and motor values for playback
if (upload.effect.type == FF_RUMBLE) {
effect_id = upload.effect.id;
strong = upload.effect.u.rumble.strong_magnitude;
weak = upload.effect.u.rumble.weak_magnitude;
printf("Effect uploaded\n");
}
ret = ioctl(args->fduinput, UI_END_FF_UPLOAD, &upload);
if (ret < 0) {
printf("second ioctl failed %d %s\n", ret, strerror(errno));
}
printf("UI_FF_UPLOAD end\n");
}
else if (event.code == UI_FF_ERASE) {
struct uinput_ff_erase erase;
memset(&erase, 0, sizeof(erase));
erase.request_id = event.value;
// Doesn't make sense to actually erase something...
ioctl(args->fduinput, UI_BEGIN_FF_ERASE, &erase);
ioctl(args->fduinput, UI_END_FF_ERASE, &erase);
printf("Event erased\n");
}
}
I report that my device only supports one effect at once. My idea was
that I maybe try to get ff-memless connected to uinput at a later time
to make it emulate the common "memless configuration" used by the kernel
and operate my one-effect-rumble-only device.
The above code works well as long as nothing was sent out to the open
uinput file descriptor.
As soon as I press a button on my USB input device, it "wakes up" and
sends out information even if no button is pressed. This information is
also forwarded to uinput, so from this point on there is a regular
information stream from my code to the uinput module.
Maybe I have to add that I run dual-threaded. The above code is from my
"reception thread". The sending runs on a separate "sending thread".
Did I currently find out that uinput is not multithread-safe?
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
next prev parent reply other threads:[~2016-03-28 9:01 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-27 18:53 uinput: ioctls for UI_BEGIN_FF_UPLOAD fails (returns -1). How to debug? Manuel Reimer
2016-03-27 19:11 ` Clément VUCHENER
2016-03-28 8:53 ` Manuel Reimer [this message]
2016-03-29 10:21 ` Clément VUCHENER
2016-03-29 16:48 ` Manuel Reimer
2016-03-31 17:46 ` Manuel Reimer
2016-04-03 10:02 ` Manuel Reimer
2016-04-03 10:21 ` Clément VUCHENER
2016-04-05 19:10 ` Manuel Reimer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=56F8F107.3050906@m-reimer.de \
--to=mail+linux-input@m-reimer.de \
--cc=clement.vuchener@gmail.com \
--cc=linux-input@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).