]> git.webhop.me Git - blockads.git/commitdiff
blockads: add RC Support for more Hardware master
authorGetAway <get-away@t-online.de>
Tue, 13 Mar 2018 10:38:15 +0000 (11:38 +0100)
committerGetAway <get-away@t-online.de>
Tue, 13 Mar 2018 10:38:15 +0000 (11:38 +0100)
- fix CONFIGDIR
- fix FONTDIR
- fix some compiler warnings

please build with -DHAVE_ARM_HARDWARE
                  -DHAVE_COOL_HARDWARE

blockads.c
blockads.h
globals.c
globals.h
http.c
io.c
io.h
rc_device.h [new file with mode: 0644]
text.c
text.h

index 6083590e4071267b39f530185259f781d70aa1cc..2e286c17d41cdec693b90c655cc19265c5188b01 100644 (file)
@@ -267,18 +267,25 @@ FILE *fh1,*fh2;
        if((fh1=fopen(FLG_FILE,"r"))==NULL)
        {
 //             system("ping -c 5 google.com &");
-               fb = open(FB_DEVICE, O_RDWR);
-//             rc = open(RC_DEVICE, O_RDONLY);
-//             fcntl(rc, F_SETFL, (fcntl(rc, F_GETFL) | O_EXCL) & ~O_NONBLOCK);
+
+               /* open Framebuffer */
+               fb=open(FB_DEVICE, O_RDWR);
+               if (fb < 0)
+                       fb=open(FB_DEVICE_FALLBACK, O_RDWR);
+               if (fb < 0) {
+                       perror("Blockads <open framebuffer>");
+                       exit(1);
+               }
+
                InitRC();
 
                read_neutrino_osd_conf ( &ex,&sx,&ey, &sy);
-               if ( ( ex == -1 ) || ( sx == -1 ) || ( ey == -1 ) || ( sy == -1 ) )\r
-               {\r
-                       sx = 100;\r
-                       ex = 1180;\r
-                       sy = 100;\r
-                       ey = 620;\r
+               if ( ( ex == -1 ) || ( sx == -1 ) || ( ey == -1 ) || ( sy == -1 ) )
+               {
+                       sx = 100;
+                       ex = 1180;
+                       sy = 100;
+                       ey = 620;
                }
 
                for(index=CMCST; index<=CMH; index++)
@@ -396,7 +403,7 @@ FILE *fh1,*fh2;
                        {
                                if((fh1=fopen(ZAP_FILE,"r"))!=NULL)
                                {
-                                       while((fgets(line_buffer, sizeof(line_buffer), fh1)>0) && (strlen(line_buffer)<4));
+                                       while((fgets(line_buffer, sizeof(line_buffer), fh1)) && (strlen(line_buffer)<4));
                                        if(strlen(line_buffer)>1)
                                        {
                                                Trim_String(line_buffer);
@@ -446,7 +453,7 @@ FILE *fh1,*fh2;
                        {
                                if((fh1=fopen(ZAP_FILE,"r"))!=NULL)
                                {
-                                       while((fgets(line_buffer, sizeof(line_buffer), fh1)>0) && !strlen(line_buffer));
+                                       while((fgets(line_buffer, sizeof(line_buffer), fh1)) && !strlen(line_buffer));
                                        if(strlen(line_buffer)>=1)
                                        {
                                                Trim_String(line_buffer);
@@ -459,7 +466,7 @@ FILE *fh1,*fh2;
                        {
                                if((fh1=fopen(ZAP_FILE,"r"))!=NULL)
                                {
-                                       while((fgets(line_buffer, sizeof(line_buffer), fh1)>0) && !strlen(line_buffer));
+                                       while((fgets(line_buffer, sizeof(line_buffer), fh1)) && !strlen(line_buffer));
                                        if(strlen(line_buffer)>=1)
                                        {
                                                Trim_String(line_buffer);
index ae59a0babb2fa1437c01d7c9b3d1c8bea7cb878c..1f3f39dd5062bc14c097d34c8d8264123f93f22c 100644 (file)
 
 //freetype stuff
 
-#define FONT2 "/share/fonts/pakenham.ttf"
+#define FONT FONTDIR "/neutrino.ttf"
 // if font is not in usual place, we look here:
-#define FONT "/share/fonts/neutrino.ttf"
+#define FONT2 FONTDIR "/pakenham.ttf"
+
 
 enum {FILL, GRID};
 enum {LEFT, CENTER, RIGHT};
@@ -149,14 +150,4 @@ extern struct fb_var_screeninfo var_screeninfo;
 extern int startx, starty, sx, ex, sy, ey;
 extern unsigned char *proxyadress, *proxyuserpwd;
 
-
-#define FB_DEVICE      "/dev/fb/0"
-/*
-#if HAVE_DVB_API_VERSION < 3
-#define RC_DEVICE      "/dev/dbox/rc0"
-#else
-#define RC_DEVICE      "/dev/input/event0"
-#endif
-*/
-
 #endif
index 438fec456f671f78fe3bc34386e6080f717642e5..eb657157415d927c065ca77110310540457099ab 100644 (file)
--- a/globals.c
+++ b/globals.c
@@ -159,7 +159,7 @@ char *cptr;
        }
 }
 
-void read_neutrino_osd_conf(int *ex, int *sx, int *ey, int *sy)\r
+void read_neutrino_osd_conf(int *ex, int *sx, int *ey, int *sy)
 {
        const char *filename="/var/tuxbox/config/neutrino.conf";
        const char spres[][4]={"","crt","lcd"};
@@ -382,7 +382,7 @@ int avol, amut;
        {
                if((fh1=fopen(ZAP_FILE,"r"))!=NULL)
                {
-                       while((fgets(zstr, sizeof(zstr), fh1)>0) && !strlen(zstr));
+                       while((fgets(zstr, sizeof(zstr), fh1)) && !strlen(zstr));
                        if(strlen(zstr)>=1)
                        {
                                Trim_String(zstr);
@@ -395,7 +395,7 @@ int avol, amut;
        {
                if((fh1=fopen(ZAP_FILE,"r"))!=NULL)
                {
-                       while((fgets(zstr, sizeof(zstr), fh1)>0) && !strlen(zstr));
+                       while((fgets(zstr, sizeof(zstr), fh1)) && !strlen(zstr));
                        if(strlen(zstr)>=1)
                        {
                                Trim_String(zstr);
index e3bc8bfdb027056daf0067f6a4c3fccfc1a83868..8d1de6e49f2315d6f10008a11e3c724f83891175 100644 (file)
--- a/globals.h
+++ b/globals.h
 
 #define P_VERSION "0.79"
 
+#ifndef FB_DEVICE
+#define FB_DEVICE      "/dev/fb/0"
+#endif
+#ifndef FB_DEVICE_FALLBACK
+#define FB_DEVICE_FALLBACK     "/dev/fb0"
+#endif
+#ifndef CONFIGDIR
+#define CONFIGDIR "/var/tuxbox/config"
+#endif
+#ifndef FONTDIR
+#define FONTDIR        "/share/fonts"
+#endif
+
 #define ADS_FILE       "/tmp/blockads.ads"
 #define ZAP_FILE       "/tmp/blockads.zap"
 #define LST_FILE       "/tmp/blockads.lst"
 #define FLG_FILE       "/tmp/blockads.flg"
 #define MSG_FILE       "/tmp/blockads.msg"
 #define STS_FILE       "/tmp/blockads.sts"
-#define CFG_FILE       "/var/tuxbox/config/blockads.conf"
-#define NCF_FILE       "/var/tuxbox/config/neutrino.conf"
+#define CFG_FILE       CONFIGDIR "/blockads.conf"
+#define NCF_FILE       CONFIGDIR "/neutrino.conf"
 #define NUM_CHANNELS 12
 
 
diff --git a/http.c b/http.c
index 8ee6132e94b7fd8ae3c759796f7eaea0d2f8dd30..a50d338ed09034065bb8b482c9c2d8b81a52c533 100644 (file)
--- a/http.c
+++ b/http.c
@@ -36,7 +36,7 @@
 //#include <linux/delay.h>
 #include "blockads.h"
 
-int HTTP_downloadFile(char *host, int port, char *page, char *downloadTarget, int tmo, int repeats)
+int HTTP_downloadFile(char *host, int port, char *page, char *downloadTarget, int tmo __attribute__((unused)), int repeats __attribute__((unused)))
 {
        char tstr[256];
        
diff --git a/io.c b/io.c
index fbe28616b880ea0bb5c6442f625c09bcf5f5a9a5..d9f80ed0262f3e35a7e29055fe6ac06c3dffdb2e 100644 (file)
--- a/io.c
+++ b/io.c
@@ -21,6 +21,7 @@
 
 #include "io.h"
 #include "blockads.h"
+#include "rc_device.h"
 
 struct input_event ev;
 static unsigned short rccode=-1;
@@ -28,7 +29,10 @@ static int rc;
 
 int InitRC(void)
 {
-       rc = open(RC_DEVICE, O_RDONLY);
+       /* open Remote Control */
+       rc = open(RC_DEVICE, O_RDONLY | O_CLOEXEC);
+       if(rc == -1)
+               rc = open(RC_DEVICE_FALLBACK, O_RDONLY | O_CLOEXEC);
        if(rc == -1)
        {
                perror("Blockads <open remote control>");
@@ -69,15 +73,15 @@ int GetRCCode()
 
        if(read(rc, &ev, sizeof(ev)) == sizeof(ev))
        {
-               if(ev.value > 0 && ev.code != rc_last_key)
+               if(ev.value)
                {
-                       if ( ev.value == 2 )    
+                       if (ev.code == rc_last_key)     
                        {
                                while ( count < REPEAT_TIMER )                  
                                {
                                        count++;
                                        rccode = -1;
-                                       usleep(15000L);
+                                       usleep(1000000/100);
                                        return rccode;
                                }
                        }
diff --git a/io.h b/io.h
index 61b93f8a15915a856a1acdd0b8ceb7143781be9a..29b153727ff9b5f3064cb5cecc06794172dc8632 100644 (file)
--- a/io.h
+++ b/io.h
@@ -23,8 +23,6 @@
 
 #define __IO_H__
 
-#define RC_DEVICE      "/dev/input/nevis_ir"
-
 int InitRC(void);
 int CloseRC(void);
 int RCKeyPressed(void);
diff --git a/rc_device.h b/rc_device.h
new file mode 100644 (file)
index 0000000..bad11e3
--- /dev/null
@@ -0,0 +1,21 @@
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#if HAVE_COOL_HARDWARE
+#define RC_DEVICE "/dev/input/nevis_ir"
+#define RC_DEVICE_FALLBACK "/dev/input/event0"
+
+#elif HAVE_SPARK_HARDWARE
+#define RC_DEVICE "/dev/input/nevis_ir"
+#define RC_DEVICE_FALLBACK "/dev/input/event1"
+
+#elif HAVE_DUCKBOX_HARDWARE
+#define RC_DEVICE "/dev/input/event0"
+#define RC_DEVICE_FALLBACK "/dev/input/event1"
+#else
+#define RC_DEVICE "/dev/input/event1"
+#define RC_DEVICE_FALLBACK "/dev/input/event0"
+
+#endif
+
diff --git a/text.c b/text.c
index 60bae830b48adc8a013a3b13e7689be6214a2f07..b45f1f595721341866ec5d0d001bf690570d302d 100644 (file)
--- a/text.c
+++ b/text.c
  * MyFaceRequester
  ******************************************************************************/
 
-FT_Error MyFaceRequester(FTC_FaceID face_id, FT_Library library, FT_Pointer request_data, FT_Face *aface)
+FT_Error MyFaceRequester(FTC_FaceID face_id, FT_Library _library, FT_Pointer request_data, FT_Face *aface)
 {
        FT_Error result;
+       (void)request_data;
 
-       result = FT_New_Face(library, face_id, 0, aface);
+       result = FT_New_Face(_library, face_id, 0, aface);
 
        if(!result) printf("<Font \"%s\" loaded>\n", (char*)face_id);
        else        printf("<Font \"%s\" failed>\n", (char*)face_id);
@@ -112,7 +113,7 @@ return sbit->xadvance + kerning.x;
  * GetStringLen
  ******************************************************************************/
 
-int GetStringLen(unsigned char *string)
+int GetStringLen(char *string)
 {
        int stringlen = 0;
 
diff --git a/text.h b/text.h
index a9332b7b59ef97013fb1ccd88525cf5d47bb4370..dff3857b46904feaf347fa1066cbc97db6f7a216 100644 (file)
--- a/text.h
+++ b/text.h
@@ -28,6 +28,6 @@
 FT_Error MyFaceRequester(FTC_FaceID face_id, FT_Library library, FT_Pointer request_data, FT_Face *aface);
 void RenderString(char *string, int sx, int sy, int maxwidth, int layout, int size, int color);
 void ShowMessage(char *message, int wait);
-int GetStringLen(unsigned char *string);
+int GetStringLen(char *string);
 
 #endif