[Patch] Make RGYB buttons customizeable

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hey all,

Ever had the trouble that your remote's color navigation key weren't the
same as VDR's? Well I wrote this patch the past 4 hours which lets you
configure them.

By doing so, the order of the buttons in the menu changes depending on
whatever you tell it to. So finally that remote can match whatever is
displayed on screen.

This only works for the classic and st-tng  skins, as those are supplied
with VDR. The Skin needs to support this feature. If there is no skin
support, the setting simply gets ignored by that skin. Since only the
order of the buttons in the skin are being changed any plugin
configuration will be independent from this change. What I mean is that,
when a plugin has configured blue to take you straight to the photo
gallery, the blue button will still do this, no matter where it is on
the remote. If the plugin however used the blue key to fast forward,
because it is the right most key, and thus made sense logically there,
it will no longer when you move the keys around. Practically, this will
boil down to a handful of plugins depending on location which imo is a
little weird anyway :)

Also, I patched it on a Gentoo box using the latest 1.6 ebuild they have
so line numbers may be a little off in the patch due to various patches
Gentoo may apply. It's the only dev. box for VDR I have so forgive me on
that.

I'm looking forward to the review :)

Oliver

diff -ru config.c.orig config.c
--- config.c.orig	2010-09-16 03:34:59.000000000 +0200
+++ config.c	2010-09-16 03:35:36.000000000 +0200
@@ -218,6 +218,10 @@
   strcpy(OSDLanguage, ""); // default is taken from environment
   strcpy(OSDSkin, "sttng");
   strcpy(OSDTheme, "default");
+  Button0 = 0;
+  Button1 = 1;
+  Button2 = 2;
+  Button3 = 3;
   PrimaryDVB = 1;
   ShowInfoOnChSwitch = 1;
   TimeoutRequChInfo = 1;
@@ -417,6 +421,10 @@
   if      (!strcasecmp(Name, "OSDLanguage"))       { strn0cpy(OSDLanguage, Value, sizeof(OSDLanguage)); I18nSetLocale(OSDLanguage); }
   else if (!strcasecmp(Name, "OSDSkin"))             Utf8Strn0Cpy(OSDSkin, Value, MaxSkinName);
   else if (!strcasecmp(Name, "OSDTheme"))            Utf8Strn0Cpy(OSDTheme, Value, MaxThemeName);
+  else if (!strcasecmp(Name, "Button0"))             Button0            = atoi(Value);
+  else if (!strcasecmp(Name, "Button1"))             Button1            = atoi(Value);
+  else if (!strcasecmp(Name, "Button2"))             Button2            = atoi(Value);
+  else if (!strcasecmp(Name, "Button3"))             Button3            = atoi(Value);
   else if (!strcasecmp(Name, "PrimaryDVB"))          PrimaryDVB         = atoi(Value);
   else if (!strcasecmp(Name, "ShowInfoOnChSwitch"))  ShowInfoOnChSwitch = atoi(Value);
   else if (!strcasecmp(Name, "TimeoutRequChInfo"))   TimeoutRequChInfo  = atoi(Value);
@@ -524,6 +532,10 @@
   Store("OSDLanguage",        OSDLanguage);
   Store("OSDSkin",            OSDSkin);
   Store("OSDTheme",           OSDTheme);
+  Store("Button0",            Button0);
+  Store("Button1",            Button1);
+  Store("Button2",            Button2);
+  Store("Button3",            Button3);
   Store("PrimaryDVB",         PrimaryDVB);
   Store("ShowInfoOnChSwitch", ShowInfoOnChSwitch);
   Store("TimeoutRequChInfo",  TimeoutRequChInfo);
diff -ru config.h.orig config.h > ~/Desktop/config.h.diff
--- config.h.orig	2010-09-16 03:34:39.000000000 +0200
+++ config.h	2010-09-16 03:35:38.000000000 +0200
@@ -219,6 +219,10 @@
   char OSDLanguage[I18N_MAX_LOCALE_LEN];
   char OSDSkin[MaxSkinName];
   char OSDTheme[MaxThemeName];
+  int Button0;
+  int Button1;
+  int Button2;
+  int Button3;
   int PrimaryDVB;
   int ShowInfoOnChSwitch;
   int TimeoutRequChInfo;
diff -ru menu.c.orig menu.c
--- menu.c.orig	2010-09-16 03:34:44.000000000 +0200
+++ menu.c	2010-09-16 03:35:36.000000000 +0200
@@ -2422,6 +2422,7 @@
   const char *useSmallFontTexts[3];
   const char *mainMenuTitle[MAXMAINMENUTITLE];
   int osdLanguageIndex;
+  const char *buttonColorTexts[4];
   int numSkins;
   int originalSkinIndex;
   int skinIndex;
@@ -2475,12 +2476,20 @@
   mainMenuTitle[1]=tr("VDR - text");
   mainMenuTitle[2]=tr("text");
   mainMenuTitle[3]=tr("VDR - version");
+  buttonColorTexts[0]=tr("Key$Red");
+  buttonColorTexts[1]=tr("Key$Green");
+  buttonColorTexts[2]=tr("Key$Yellow");
+  buttonColorTexts[3]=tr("Key$Blue");
   Clear();
   SetSection(tr("OSD"));
   Add(new cMenuEditStraItem(tr("Setup.OSD$Language"),               &osdLanguageIndex, I18nNumLanguagesWithLocale(), &I18nLanguages()->At(0)));
   Add(new cMenuEditStraItem(tr("Setup.OSD$Skin"),                   &skinIndex, numSkins, skinDescriptions));
   if (themes.NumThemes())
   Add(new cMenuEditStraItem(tr("Setup.OSD$Theme"),                  &themeIndex, themes.NumThemes(), themes.Descriptions()));
+  Add(new cMenuEditStraItem(tr("Setup.OSD$Button0"),                &data.Button0, 4, buttonColorTexts));
+  Add(new cMenuEditStraItem(tr("Setup.OSD$Button1"),                &data.Button1, 4, buttonColorTexts));
+  Add(new cMenuEditStraItem(tr("Setup.OSD$Button2"),                &data.Button2, 4, buttonColorTexts));
+  Add(new cMenuEditStraItem(tr("Setup.OSD$Button3"),                &data.Button3, 4, buttonColorTexts));
   Add(new cMenuEditIntItem( tr("Setup.OSD$Left"),                   &data.OSDLeft, 0, MAXOSDWIDTH));
   Add(new cMenuEditIntItem( tr("Setup.OSD$Top"),                    &data.OSDTop, 0, MAXOSDHEIGHT));
   Add(new cMenuEditIntItem( tr("Setup.OSD$Width"),                  &data.OSDWidth, MINOSDWIDTH, MAXOSDWIDTH));
diff -ru skinclassic.c.orig skinclassic.c
--- skinclassic.c.orig	2010-09-16 03:35:21.000000000 +0200
+++ skinclassic.c	2010-09-16 03:35:36.000000000 +0200
@@ -277,16 +277,19 @@
 void cSkinClassicDisplayMenu::SetButtons(const char *Red, const char *Green, const char *Yellow, const char *Blue)
 {
   const cFont *font = cFont::GetFont(fontOsd);
+  const char *lutKeys[] = {Red, Green, Yellow, Blue};
+  tColor lutFg[4] = {clrButtonRedFg, clrButtonGreenFg, clrButtonYellowFg, clrButtonBlueFg};
+  tColor lutBg[4] = {clrButtonRedBg, clrButtonGreenBg, clrButtonYellowBg, clrButtonBlueBg};
   int w = x3 - x0;
   int t0 = x0;
   int t1 = x0 + w / 4;
   int t2 = x0 + w / 2;
   int t3 = x3 - w / 4;
   int t4 = x3;
-  osd->DrawText(t0, y4, Red,    Theme.Color(clrButtonRedFg),    Red    ? Theme.Color(clrButtonRedBg)    : Theme.Color(clrBackground), font, t1 - t0, 0, taCenter);
-  osd->DrawText(t1, y4, Green,  Theme.Color(clrButtonGreenFg),  Green  ? Theme.Color(clrButtonGreenBg)  : Theme.Color(clrBackground), font, t2 - t1, 0, taCenter);
-  osd->DrawText(t2, y4, Yellow, Theme.Color(clrButtonYellowFg), Yellow ? Theme.Color(clrButtonYellowBg) : Theme.Color(clrBackground), font, t3 - t2, 0, taCenter);
-  osd->DrawText(t3, y4, Blue,   Theme.Color(clrButtonBlueFg),   Blue   ? Theme.Color(clrButtonBlueBg)   : Theme.Color(clrBackground), font, t4 - t3, 0, taCenter);
+  osd->DrawText(t0, y4, lutKeys[Setup.Button0], Theme.Color(lutFg[Setup.Button0]), lutKeys[Setup.Button0] ? Theme.Color(lutBg[Setup.Button0]) : Theme.Color(lutBg[Setup.Button0]), font, t1 - t0, 0, taCenter);
+  osd->DrawText(t1, y4, lutKeys[Setup.Button1], Theme.Color(lutFg[Setup.Button1]), lutKeys[Setup.Button1] ? Theme.Color(lutBg[Setup.Button1]) : Theme.Color(lutBg[Setup.Button1]), font, t2 - t1, 0, taCenter);
+  osd->DrawText(t2, y4, lutKeys[Setup.Button2], Theme.Color(lutFg[Setup.Button2]), lutKeys[Setup.Button2] ? Theme.Color(lutBg[Setup.Button2]) : Theme.Color(lutBg[Setup.Button2]), font, t3 - t2, 0, taCenter);
+  osd->DrawText(t3, y4, lutKeys[Setup.Button3], Theme.Color(lutFg[Setup.Button3]), lutKeys[Setup.Button3] ? Theme.Color(lutBg[Setup.Button3]) : Theme.Color(lutBg[Setup.Button3]), font, t4 - t3, 0, taCenter);
 }
 
 void cSkinClassicDisplayMenu::SetMessage(eMessageType Type, const char *Text)
diff -ru skinsttng.c.orig skinsttng.c
--- skinsttng.c.orig	2010-09-16 03:35:23.000000000 +0200
+++ skinsttng.c	2010-09-16 03:35:36.000000000 +0200
@@ -499,6 +499,9 @@
 
 void cSkinSTTNGDisplayMenu::SetButtons(const char *Red, const char *Green, const char *Yellow, const char *Blue)
 {
+  const char *lutKeys[] = {Red, Green, Yellow, Blue};
+  tColor lutFg[4] = {clrButtonRedFg, clrButtonGreenFg, clrButtonYellowFg, clrButtonBlueFg};
+  tColor lutBg[4] = {clrButtonRedBg, clrButtonGreenBg, clrButtonYellowBg, clrButtonBlueBg};
   cString date = DayDateTime();
   const cFont *font = cFont::GetFont(fontSml);
   int d = 10;
@@ -513,10 +516,10 @@
   osd->DrawRectangle(t1 + d2, y6, t2 - d2, y7 - 1, clrBlack);
   osd->DrawRectangle(t2 + d2, y6, t3 - d2, y7 - 1, clrBlack);
   osd->DrawRectangle(t3 + d2, y6, t4 - d2, y7 - 1, clrBlack);
-  osd->DrawText(t0 + d, y6, Red,    Theme.Color(clrButtonRedFg),    Theme.Color(clrButtonRedBg),    font, t1 - t0 - 2 * d, 0, taCenter);
-  osd->DrawText(t1 + d, y6, Green,  Theme.Color(clrButtonGreenFg),  Theme.Color(clrButtonGreenBg),  font, t2 - t1 - 2 * d, 0, taCenter);
-  osd->DrawText(t2 + d, y6, Yellow, Theme.Color(clrButtonYellowFg), Theme.Color(clrButtonYellowBg), font, t3 - t2 - 2 * d, 0, taCenter);
-  osd->DrawText(t3 + d, y6, Blue,   Theme.Color(clrButtonBlueFg),   Theme.Color(clrButtonBlueBg),   font, t4 - t3 - 2 * d, 0, taCenter);
+  osd->DrawText(t0 + d, y6, lutKeys[Setup.Button0], Theme.Color(lutFg[Setup.Button0]), Theme.Color(lutBg[Setup.Button0]), font, t1 - t0 - 2 * d, 0, taCenter);
+  osd->DrawText(t1 + d, y6, lutKeys[Setup.Button1], Theme.Color(lutFg[Setup.Button1]), Theme.Color(lutBg[Setup.Button1]), font, t2 - t1 - 2 * d, 0, taCenter);
+  osd->DrawText(t2 + d, y6, lutKeys[Setup.Button2], Theme.Color(lutFg[Setup.Button2]), Theme.Color(lutBg[Setup.Button2]), font, t3 - t2 - 2 * d, 0, taCenter);
+  osd->DrawText(t3 + d, y6, lutKeys[Setup.Button3], Theme.Color(lutFg[Setup.Button3]), Theme.Color(lutBg[Setup.Button3]), font, t4 - t3 - 2 * d, 0, taCenter);
 }
 
 void cSkinSTTNGDisplayMenu::SetMessage(eMessageType Type, const char *Text)

_______________________________________________
vdr mailing list
vdr@xxxxxxxxxxx
http://www.linuxtv.org/cgi-bin/mailman/listinfo/vdr

[Index of Archives]     [Linux Media]     [Asterisk]     [DCCP]     [Netdev]     [Xorg]     [Util Linux NG]     [Xfree86]     [Big List of Linux Books]     [Fedora Users]     [Fedora Women]     [ALSA Devel]     [Linux USB]

  Powered by Linux