Reputation: 979
How can I use ioctl to change the value of auto-repeat for a given device in C?
I know about
#define REP_DELAY 0x00
#define REP_PERIOD 0x01
source: http://lxr.free-electrons.com/source/include/uapi/linux/input.h#L931
I didn't find any tutorial or documentation about these things. This question is not vague, it is actually just about using ioctl with REP_DELAY and REP_PERIOD. How can I use them with ioctl?
Upvotes: 2
Views: 1320
Reputation:
I think the ioctls you need are EVIOCGREP
and EVIOCSREP
. I can't find any documentation for them, but they are declared here as working on unsigned int[2]
so I guess that REP_DELAY
and REP_PERIOD
are indexes in that array.
Something like this should work:
unsigned int rep[2];
ioctl(fd, EVIOCGREP, rep); /* get current values */
/* do something with rep[REP_DELAY] and/or rep[REP_PERIOD] */
ioctl(fd, EVIOCSREP, rep) /* write new values */
The KD
ioctls predate evdev so the REP_
macros aren't be used with them. If you're operating directly on a virtual console (/dev/tty1
etc.) then KD
and struct kbd_repeat
are the way to go. On the newer input devices, EVIOC
and REP_
.
Upvotes: 1
Reputation: 388
You need to get the file descriptor for that particular device. The request is
#define KDKBDREP 0x4B52
The parameters to pass are
struct kbd_repeat {
int delay;
int period;
}
Source http://lxr.free-electrons.com/source/include/uapi/linux/kd.h?v=3.10#L153 .
Upvotes: 2