increase dvbapp PR
[vuplus_openvuplus] / meta-openvuplus / recipes-vuplus / tuxtxt / tuxbox-tuxtxt-32bpp / add_advanced_rc.diff
1 diff -u tuxtxt_orig/tuxtxt.c tuxtxt/tuxtxt.c
2 --- tuxtxt_orig/tuxtxt.c        2009-01-29 21:38:42.000000000 +0100
3 +++ tuxtxt/tuxtxt.c     2009-01-29 21:44:29.000000000 +0100
4 @@ -173,6 +173,7 @@
5         char cvs_revision[] = "$Revision: 1.108 $";
6  
7         int cnt=0;
8 +       int rc_num = 0;
9  #if !TUXTXT_CFG_STANDALONE
10         int initialized = tuxtxt_init();
11         if ( initialized )
12 @@ -186,7 +187,7 @@
13  
14         tuxtxt_SetRenderingDefaults(&renderinfo);
15         /* get params */
16 -       tuxtxt_cache.vtxtpid = renderinfo.fb = lcd = rc = renderinfo.sx = renderinfo.ex = renderinfo.sy = renderinfo.ey = -1;
17 +       tuxtxt_cache.vtxtpid = renderinfo.fb = lcd = renderinfo.sx = renderinfo.ex = renderinfo.sy = renderinfo.ey = -1;
18         if (argc==1)
19         {
20                 printf("\nUSAGE: tuxtxt vtpid\n");
21 @@ -204,8 +205,8 @@
22                 perror("TuxTxt <open /dev/fb/0>");
23                 return 0;
24         }
25 -       rc=-1;
26 -       while(1)
27 +       rc[0] = rc[1] =-1;
28 +       while(rc_num < 2)
29         {
30                 struct stat s;
31                 char tmp[128];
32 @@ -213,23 +214,26 @@
33                 if (stat(tmp, &s))
34                         break;
35                 /* open Remote Control */
36 -               if ((rc=open(tmp, O_RDONLY)) == -1)
37 +               if ((rc[rc_num]=open(tmp, O_RDONLY)) == -1)
38                 {
39                         perror("TuxTxt <open remote control>");
40                         return 0;
41                 }
42 -               if (ioctl(rc, EVIOCGNAME(128), tmp) < 0)
43 +               if (ioctl(rc[rc_num], EVIOCGNAME(128), tmp) < 0)
44                         perror("EVIOCGNAME failed");
45 -               if (strstr(tmp, "remote control"))
46 -                       break;
47 -               close(rc);
48 -               rc=-1;
49 +               if (!strstr(tmp, "remote control"))
50 +               {
51 +                       close(rc[rc_num]);
52 +                       rc[rc_num] = -1;
53 +               }
54 +               else
55 +                       ++rc_num;
56                 ++cnt;
57         }
58  
59 -       if (rc == -1)
60 +       if (rc[0] == -1)
61         {
62 -               printf("couldnt find correct input device!!!\n");
63 +               printf("couldnt find usable input device!!!\n");
64                 return -1;
65         }
66  
67 @@ -247,7 +251,7 @@
68         renderinfo.sy = 30;
69         renderinfo.ey = 555;
70  
71 -       if (tuxtxt_cache.vtxtpid == -1 || renderinfo.fb == -1 || rc == -1 || renderinfo.sx == -1 || renderinfo.ex == -1 || renderinfo.sy == -1 || renderinfo.ey == -1)
72 +       if (tuxtxt_cache.vtxtpid == -1 || renderinfo.fb == -1 || renderinfo.sx == -1 || renderinfo.ex == -1 || renderinfo.sy == -1 || renderinfo.ey == -1)
73         {
74                 printf("TuxTxt <Invalid Param(s)>\n");
75                 return;
76 @@ -623,7 +627,8 @@
77         writeproc("/proc/stb/avs/0/sb", fncmodes[renderinfo.screen_mode1]);
78  
79         /* setup rc */
80 -       ioctl(rc, RC_IOCTL_BCODES, 1);
81 +       if (rc[0] >= 0) ioctl(rc[0], RC_IOCTL_BCODES, 1);
82 +       if (rc[1] >= 0) ioctl(rc[1], RC_IOCTL_BCODES, 1);
83  
84  
85  
86 @@ -682,9 +687,12 @@
87         close(lcd);
88         
89         /* close rc */
90 -       close(rc);
91 +       if (rc[0] >= 0)
92 +               close(rc[0]);
93 +       if (rc[1] >= 0)
94 +               close(rc[1]);
95  
96 -       lcd = rc = -1;
97 +       lcd = rc[0] = rc[1] = -1;
98   
99         if (hotlistchanged)
100                 savehotlist();
101 @@ -2819,20 +2827,28 @@
102         timeout.tv_sec = 0;
103         timeout.tv_usec = 100000;
104         /* get code */
105 -       if (rc >= 0)
106 +       if (rc[0] >= 0)
107 +       {
108 +               FD_SET(rc[0], &rset);
109 +               if (rc[0] > maxfd)
110 +               {
111 +                       maxfd = rc[0];
112 +               }
113 +       }
114 +       if (rc[1] >= 0)
115         {
116 -               FD_SET(rc, &rset);
117 -               if (rc > maxfd)
118 +               FD_SET(rc[1], &rset);
119 +               if (rc[1] > maxfd)
120                 {
121 -                       maxfd = rc;
122 +                       maxfd = rc[1];
123                 }
124         }
125         if (select(maxfd + 1, &rset, NULL, NULL, &timeout) > 0)
126         {
127 -               if (rc >= 0 && FD_ISSET(rc, &rset))
128 +               if (rc[0] >= 0 && FD_ISSET(rc[0], &rset))
129                 {
130  #if HAVE_DVB_API_VERSION < 3
131 -                       read(rc, &RCCode, 2);
132 +                       read(rc[0], &RCCode, 2);
133                 }
134                 if (RCCode != LastKey)
135                 {
136 @@ -2842,7 +2858,11 @@
137                         {
138                                 switch (RCCode)
139  #else
140 -                       read(rc, &ev, sizeof(ev));
141 +                       read(rc[0], &ev, sizeof(ev));
142 +               }
143 +               else if (rc[1] >= 0 && FD_ISSET(rc[1], &rset))
144 +               {
145 +                       read(rc[1], &ev, sizeof(ev));
146                 }
147                 if (ev.value)
148                 {
149 Only in tuxtxt_orig/: tuxtxt.c.orig
150 diff -u tuxtxt_orig/tuxtxt.h tuxtxt/tuxtxt.h
151 --- tuxtxt_orig/tuxtxt.h        2009-01-29 21:38:18.000000000 +0100
152 +++ tuxtxt/tuxtxt.h     2009-01-29 21:44:29.000000000 +0100
153 @@ -209,7 +209,7 @@
154  int hotlist[10];
155  int maxhotlist;
156  
157 -int rc, lcd;
158 +int rc[2], lcd;
159  int lastpage;
160  int savedscreenmode;
161  char dumpl25;