From: GetAway Date: Tue, 13 Mar 2018 10:38:15 +0000 (+0100) Subject: blockads: add RC Support for more Hardware X-Git-Url: https://git.webhop.me/?a=commitdiff_plain;h=HEAD;p=blockads.git blockads: add RC Support for more Hardware - fix CONFIGDIR - fix FONTDIR - fix some compiler warnings please build with -DHAVE_ARM_HARDWARE -DHAVE_COOL_HARDWARE --- diff --git a/blockads.c b/blockads.c index 6083590..2e286c1 100644 --- a/blockads.c +++ b/blockads.c @@ -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 "); + exit(1); + } + InitRC(); read_neutrino_osd_conf ( &ex,&sx,&ey, &sy); - if ( ( ex == -1 ) || ( sx == -1 ) || ( ey == -1 ) || ( sy == -1 ) ) - { - sx = 100; - ex = 1180; - sy = 100; - ey = 620; + 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); diff --git a/blockads.h b/blockads.h index ae59a0b..1f3f39d 100644 --- a/blockads.h +++ b/blockads.h @@ -107,9 +107,10 @@ //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 diff --git a/globals.c b/globals.c index 438fec4..eb65715 100644 --- 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) +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); diff --git a/globals.h b/globals.h index e3bc8bf..8d1de6e 100644 --- a/globals.h +++ b/globals.h @@ -25,14 +25,27 @@ #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 8ee6132..a50d338 100644 --- a/http.c +++ b/http.c @@ -36,7 +36,7 @@ //#include #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 fbe2861..d9f80ed 100644 --- 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 "); @@ -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 61b93f8..29b1537 100644 --- 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 index 0000000..bad11e3 --- /dev/null +++ b/rc_device.h @@ -0,0 +1,21 @@ +#ifdef HAVE_CONFIG_H +#include +#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 60bae83..b45f1f5 100644 --- a/text.c +++ b/text.c @@ -27,11 +27,12 @@ * 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("\n", (char*)face_id); else printf("\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 a9332b7..dff3857 100644 --- 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