Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "../include/configbutton.h"
- #include <stdio.h>
- #include <stdlib.h>
- typedef struct {
- int tvout_mode;
- char command[256];
- } INTERNAL;
- const char *label[32] = { "PAL, Main Layer", "PAL, HW Scaler", "NTSC, Main Layer", "NTSC, HW Scaler", "Disable TV-out", "Configure TV-out" };
- int activate(void *internal) {
- INTERNAL *ip = internal;
- system(ip->command);
- /*switch (ip->tvout_mode) {
- case 0: // PAL, Layer 0
- system("sudo -n /usr/pandora/scripts/op_tvout.sh -t pal -l 0");
- break;
- case 1: // PAL, Layer 1
- system("sudo -n /usr/pandora/scripts/op_tvout.sh -t pal -l 1");
- break;
- case 2: // NTSC, Layer 0
- system("sudo -n /usr/pandora/scripts/op_tvout.sh -t ntsc -l 0");
- break;
- case 3: // NTSC, Layer 1
- system("sudo -n /usr/pandora/scripts/op_tvout.sh -t ntsc -l 1");
- break;
- case 4: // Disable
- system("sudo -n /usr/pandora/scripts/op_tvout.sh -d");
- break;
- default: // Configure
- system("/usr/pandora/scripts/TVoutConfig.py &");
- break;
- }*/
- return 0;
- }
- int getinfo(PLUGIN_INFO *info) {
- int i;
- struct PLUGIN_SUBMENU *sub;
- INTERNAL *internal;
- if (info->submenu == NULL) {
- info->label = malloc(128);
- // Open TV-Out profile
- FILE * file;
- file = fopen("/etc/pandora/conf/tvout-profiles.conf", "r");
- char buff[256];
- if(file)
- {
- i = 0; int modeCount = 0;
- while( fgets(buff, sizeof (buff), file) != NULL )
- {
- // If an even line it's a labal
- if((i % 2) == 0)
- {
- sub = malloc(sizeof(struct PLUGIN_SUBMENU));
- sub->next = info->submenu;
- sub->icon_path = "/usr/share/icons/pandora/tvout.png";
- sub->visible = 1;
- sub->label = buff;
- }
- else // It's a command!
- {
- internal = malloc(sizeof(INTERNAL));
- internal->tvout_mode = modeCount++;
- // We now need to build the command
- char isEnabled[5];
- char region[4];
- char format[10];
- int layer;
- int x;
- int y;
- int width;
- int height;
- if(sscanf (buff,"%s %s %s %d %d %d %d %d",isEnabled,region,format,&layer,&x,&y,&width,&height) > 0)
- {
- char base[256];
- char* pBase = base;
- pBase = "sudo -n /usr/pandora/scripts/op_tvout.sh -";
- if(isEnabled == "True")
- {
- isEnabled[0] = 't';
- }
- else
- {
- isEnabled[0] = 'f';
- }
- isEnabled[1] = '\0';
- sprintf(internal->command, "%s%s %s -c %s -l %d",/* %d %d %d %d",*/base,isEnabled,region,format,layer);/*,x,y,width,height); */
- }
- sub->internal = internal;
- info->submenu = sub;
- }
- ++i;
- }
- fclose(file);
- }
- else // Backup plan
- {
- for (i = 5; i >= 0; i--) {
- sub = malloc(sizeof(struct PLUGIN_SUBMENU));
- sub->next = info->submenu;
- sub->label = label[i];
- sub->icon_path = "/usr/share/icons/pandora/tvout.png";
- sub->visible = 1;
- internal = malloc(sizeof(INTERNAL));
- internal->tvout_mode = i;
- sub->internal = internal;
- info->submenu = sub;
- }
- }
- }
- info->label = "TV-out";
- info->icon_path = "/usr/share/icons/pandora/tvout.png";
- info->sort_hint = 10;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement