This is an automatic generated email to let you know that the following patch 
were queued at the 
http://git.linuxtv.org/v4l-utils.git tree:

Subject: ir-keytable: Add support to adjust repeat period/delay
Author:  Mauro Carvalho Chehab <[email protected]>
Date:    Wed Jan 26 16:40:15 2011 -0200

Signed-off-by: Mauro Carvalho Chehab <[email protected]>

 utils/keytable/ir-keytable.1 |   10 ++++++++
 utils/keytable/keytable.c    |   53 +++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 62 insertions(+), 1 deletions(-)

---

http://git.linuxtv.org/v4l-utils.git?a=commitdiff;h=78d531f655951ec2fe23746b62e51f665d139f7e

diff --git a/utils/keytable/ir-keytable.1 b/utils/keytable/ir-keytable.1
index 3598b9f..22ee5bc 100644
--- a/utils/keytable/ir-keytable.1
+++ b/utils/keytable/ir-keytable.1
@@ -27,6 +27,9 @@ clears the old table
 .TP 
 \fB\-d\fR, \fB\-\-device\fR=\fIDEV\fR
 ir device to control
+.TP
+\fB\-D\fR, \fB\-\-delay\fR=\fIDELAY\fR
+Sets the delay before repeating a keystroke
 .TP 
 \fB\-k\fR, \fB\-\-set\-key\fR=\fISCANKEY\fR
 Change scan/key pairs
@@ -34,6 +37,9 @@ Change scan/key pairs
 \fB\-p\fR, \fB\-\-protocol\fR=\fIPROTOCOL\fR
 Protocol to enable (the other ones will be disabled). To enable more than one, 
 use the option more than one time
+.TP
+\fB\-P\fR, \fB\-\-period\fR\=\fiPERIOD\fR
+Sets the period to repeat a keystroke
 .TP 
 \fB\-r\fR, \fB\-\-read\fR
 reads the current scancode/keycode table
@@ -73,6 +79,10 @@ a file wit a set of scancode=keycode value pairs
 a set of scancode1=keycode1,scancode2=keycode2.. value pairs
 .IP \fIPROTOCOL\fR
 protocol name (nec, rc\-5, rc\-6, other) to be enabled
+.IP \fIDELAY\fR
+Delay before repeating a keystroke
+.IP \fIPERIOD\fR
+Period to repeat a keystroke
 .IP \fICFGFILE\fR
 configuration file that associates a driver/table name with a keymap file
 .SH EXIT STATUS
diff --git a/utils/keytable/keytable.c b/utils/keytable/keytable.c
index e36a72b..87b6442 100644
--- a/utils/keytable/keytable.c
+++ b/utils/keytable/keytable.c
@@ -111,6 +111,8 @@ static const char doc[] = "\nAllows get/set IR 
keycode/scancode tables\n"
        "  TABLE    - a file wit a set of scancode=keycode value pairs\n"
        "  SCANKEY  - a set of scancode1=keycode1,scancode2=keycode2.. value 
pairs\n"
        "  PROTOCOL - protocol name (nec, rc-5, rc-6, other) to be enabled\n"
+       "  DELAY    - Delay before repeating a keystroke\n"
+       "  PERIOD   - Period to repeat a keystroke\n"
        "  CFGFILE  - configuration file that associates a driver/table name 
with a keymap file\n"
        "\nOptions can be combined together.";
 
@@ -124,6 +126,8 @@ static const struct argp_option options[] = {
        {"write",       'w',    "TABLE",        0,      "write (adds) the 
scancodes to the device scancode/keycode table from an specified file", 0},
        {"set-key",     'k',    "SCANKEY",      0,      "Change scan/key 
pairs", 0},
        {"protocol",    'p',    "PROTOCOL",     0,      "Protocol to enable 
(the other ones will be disabled). To enable more than one, use the option more 
than one time", 0},
+       {"delay",       'D',    "DELAY",        0,      "Sets the delay before 
repeating a keystroke", 0},
+       {"period",      'P',    "PERIOD",       0,      "Sets the period to 
repeat a keystroke", 0},
        {"auto-load",   'a',    "CFGFILE",      0,      "Auto-load a table, 
based on a configuration file. Only works with sysdev.", 0},
        { 0, 0, 0, 0, 0, 0 }
 };
@@ -140,6 +144,8 @@ static int readtable = 0;
 static int clear = 0;
 static int debug = 0;
 static int test = 0;
+static int delay = 0;
+static int period = 0;
 static enum ir_protocols ch_proto = 0;
 
 struct keytable keys = {
@@ -368,6 +374,12 @@ static error_t parse_opt(int k, char *arg, struct 
argp_state *state)
        case 'c':
                clear++;
                break;
+       case 'D':
+               delay = atoi(arg);
+               break;
+       case 'P':
+               period = atoi(arg);
+               break;
        case 'd':
                devname = arg;
                break;
@@ -1303,6 +1315,32 @@ static void display_table(struct rc_device *rc_dev, int 
fd)
                display_table_v2(rc_dev, fd);
 }
 
+static int set_rate(int fd, unsigned int delay, unsigned int period)
+{
+       unsigned int rep[2] = { delay, period };
+
+       if (ioctl(fd, EVIOCSREP, rep) < 0) {
+               perror("evdev ioctl");
+               return -1;
+       }
+
+       printf("Changed Repeat delay to %d ms and repeat period to %d ms\n", 
delay, period);
+       return 0;
+}
+
+static int get_rate(int fd, unsigned int *delay, unsigned int *period)
+{
+       unsigned int rep[2];
+
+       if (ioctl(fd, EVIOCGREP, rep) < 0) {
+               perror("evdev ioctl");
+               return -1;
+       }
+       *delay = rep[0];
+       *period = rep[1];
+       printf("Repeat delay = %d ms, repeat period = %d ms\n", *delay, 
*period);
+       return 0;
+}
 
 int main(int argc, char *argv[])
 {
@@ -1314,7 +1352,7 @@ int main(int argc, char *argv[])
        argp_parse(&argp, argc, argv, 0, 0, 0);
 
        /* Just list all devices */
-       if (!clear && !readtable && !keys.next && !ch_proto && !cfg.next && 
!test) {
+       if (!clear && !readtable && !keys.next && !ch_proto && !cfg.next && 
!test && !delay && !period) {
                static struct sysfs_names *names, *cur;
 
                names = find_device(NULL);
@@ -1445,6 +1483,19 @@ int main(int argc, char *argv[])
        if (readtable)
                display_table(&rc_dev, fd);
 
+       /*
+        * Fiveth step: change repeat rate/delay
+        */
+       if (delay || period) {
+               unsigned int new_delay, new_period;
+               get_rate(fd, &new_delay, &new_period);
+               if (delay)
+                       new_delay = delay;
+               if (period)
+                       new_period = period;
+               set_rate(fd, new_delay, new_period);
+       }
+
        if (test)
                test_event(fd);
 

_______________________________________________
linuxtv-commits mailing list
[email protected]
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linuxtv-commits

Reply via email to