re introduced snprintf

This commit is contained in:
alphanu1 2018-09-10 18:12:44 +01:00 committed by GitHub
parent d4e43b15c1
commit 6c2d11b414
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -238,73 +238,64 @@ static bool x11_set_resolution(void *data,
sprintf(xrandr,"xrandr --newmode \"%dx%d_%0.2f\" %lf %d %d %d %d %d %d %d %d -hsync -vsync", width, height, hz, pixel_clock, width, hfp, hsp, hbp, height, vfp, vsp, vbp);
system(xrandr);
}
/* create interlaced newmode from modline variables */
if (height < 300)
{
snprintf(xrandr, sizeof(xrandr), "xrandr --newmode \"%dx%d_%0.2f\" %lf %d %d %d %d %d %d %d %d -hsync -vsync", width, height, hz, pixel_clock, width, hfp, hsp, hbp, height, vfp, vsp, vbp);
system(xrandr);
}
/* create interlaced newmode from modline variables */
if (height > 300)
{
sprintf(xrandr,"xrandr --newmode \"%dx%d_%0.2f\" %lf %d %d %d %d %d %d %d %d interlace -hsync -vsync", width, height, hz, pixel_clock, width, hfp, hsp, hbp, height, vfp, vsp, vbp);
snprintf(xrandr, sizeof(xrandr), "xrandr --newmode \"%dx%d_%0.2f\" %lf %d %d %d %d %d %d %d %d interlace -hsync -vsync", width, height, hz, pixel_clock, width, hfp, hsp, hbp, height, vfp, vsp, vbp);
system(xrandr);
}
/* variable for new mode */
sprintf(new_mode,"%dx%d_%0.2f", width, height, hz);
snprintf(new_mode, sizeof(new_mode), "%dx%d_%0.2f", width, height, hz);
/* need to run loops for DVI0 - DVI-2 and VGA0 - VGA-2 outputs to add and delete modes */
for (i =0; i < 3; i++)
{
sprintf(output,"xrandr --addmode %s%d %s", "HDMI",i ,new_mode);
snprintf(output, sizeof(output), "xrandr --addmode %s%d %s", "DVI",i ,new_mode);
system(output);
sprintf(output,"xrandr --output %s%d --mode %s", "HDMI", i, new_mode);
system(output);
sprintf(output,"xrandr --delmode %s%d %s", "HDMI",i ,old_mode);
snprintf(output, sizeof(output), "xrandr --delmode %s%d %s", "DVI",i ,old_mode);
system(output);
sprintf(output,"xrandr --addmode %s-%d %s", "HDMI",i ,new_mode);
system(output);
sprintf(output,"xrandr --output %s-%d --mode %s", "HDMI", i, new_mode);
system(output);
sprintf(output,"xrandr --delmode %s-%d %s", "HDMI",i ,old_mode);
system(output);
sprintf(output,"xrandr --addmode %s%d %s", "DVI",i ,new_mode);
}
for (i =0; i < 3; i++)
{
snprintf(output, sizeof(output), "xrandr --addmode %s-%d %s", "DVI",i ,new_mode);
system(output);
sprintf(output,"xrandr --output %s%d --mode %s", "DVI", i, new_mode);
snprintf(output, sizeof(output), "xrandr --delmode %s-%d %s", "DVI",i ,old_mode);
system(output);
sprintf(output,"xrandr --delmode %s%d %s", "DVI",i ,old_mode);
}
for (i =0; i < 3; i++)
{
snprintf(output, sizeof(output), "xrandr --addmode %s%d %s", "VGA",i ,new_mode);
system(output);
snprintf(output, sizeof(output), "xrandr --delmode %s%d %s", "VGA",i ,old_mode);
system(output);
sprintf(output,"xrandr --addmode %s-%d %s", "DVI",i ,new_mode);
}
for (i =0; i < 3; i++)
{
snprintf(output, sizeof(output), "xrandr --addmode %s-%d %s", "VGA",i ,new_mode);
system(output);
sprintf(output,"xrandr --output %s-%d --mode %s", "DVI", i, new_mode);
system(output);
sprintf(output,"xrandr --delmode %s-%d %s", "DVI",i ,old_mode);
system(output);
sprintf(output,"xrandr --addmode %s%d %s", "VGA",i ,new_mode);
snprintf(output, sizeof(output), "xrandr --delmode %s-%d %s", "VGA",i ,old_mode);
system(output);
sprintf(output,"xrandr --output %s%d --mode %s", "VGA", i, new_mode);
system(output);
sprintf(output,"xrandr --delmode %s%d %s", "VGA",i ,old_mode);
system(output);
sprintf(output,"xrandr --addmode %s-%d %s", "VGA",i ,new_mode);
system(output);
sprintf(output,"xrandr --output %s-%d --mode %s", "VGA", i, new_mode);
system(output);
sprintf(output,"xrandr --delmode %s-%d %s", "VGA",i ,old_mode);
system(output);
}
snprintf(output, sizeof(output), "xrandr -s %s", new_mode);
system(output);
/* remove old mode */
sprintf(output,"xrandr --rmmode %s", old_mode);
snprintf(output, sizeof(output), "xrandr --rmmode %s", old_mode);
system(output);
system("xdotool windowactivate $(xdotool search --class RetroArch)"); /* needs xdotool installed. needed to recaputure window. */
/* variable for old mode */
sprintf(old_mode,"%s", new_mode);
snprintf(old_mode, sizeof(old_mode), "%s", new_mode);
system("xdotool windowactivate $(xdotool search --class RetroArch)"); /* needs xdotool installed. needed to recaputure window. */
/* Second run needed as some times it runs to fast to capture first time */
/* Second run needed as some times it runs to fast to capture first time */
return true;
}