commit
bf64c1cf23
|
@ -34,6 +34,7 @@
|
|||
#include "../video_display_server.h"
|
||||
#include "../common/win32_common.h"
|
||||
#include "../../verbosity.h"
|
||||
#include "../video_driver.h" /* needed to set refresh rate in set resolution */
|
||||
|
||||
#ifdef __ITaskbarList3_INTERFACE_DEFINED__
|
||||
#define HAS_TASKBAR_EXT
|
||||
|
@ -199,7 +200,7 @@ static bool win32_set_window_decorations(void *data, bool on)
|
|||
}
|
||||
|
||||
static bool win32_display_server_set_resolution(void *data,
|
||||
unsigned width, unsigned height, int f_restore, int hz)
|
||||
unsigned width, unsigned height, int f_restore, float hz)
|
||||
{
|
||||
LONG res;
|
||||
DEVMODE curDevmode;
|
||||
|
@ -219,6 +220,17 @@ static bool win32_display_server_set_resolution(void *data,
|
|||
if (win32_orig_height == 0)
|
||||
win32_orig_height = GetSystemMetrics(SM_CYSCREEN);
|
||||
|
||||
/* set hz float to an int for windows switching */
|
||||
if (hz < 53)
|
||||
hz = 50;
|
||||
if (hz >= 53 && hz < 57)
|
||||
hz = 55;
|
||||
if (hz >= 57)
|
||||
hz = 60;
|
||||
|
||||
video_monitor_set_refresh_rate(hz);
|
||||
|
||||
|
||||
if (f_restore == 0)
|
||||
freq = hz;
|
||||
|
||||
|
|
|
@ -18,6 +18,13 @@
|
|||
#include "../video_display_server.h"
|
||||
#include "../common/x11_common.h"
|
||||
#include "../../configuration.h"
|
||||
#include "../video_driver.h" /* needed to set refresh rate in set resolution */
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
|
||||
static char old_mode[150];
|
||||
static char new_mode[150];
|
||||
|
||||
typedef struct
|
||||
{
|
||||
|
@ -37,6 +44,8 @@ static void* x11_display_server_init(void)
|
|||
|
||||
static void x11_display_server_destroy(void *data)
|
||||
{
|
||||
|
||||
system("xrandr -s 704x480");
|
||||
dispserv_x11_t *dispserv = (dispserv_x11_t*)data;
|
||||
|
||||
if (dispserv)
|
||||
|
@ -72,14 +81,211 @@ static bool x11_set_window_decorations(void *data, bool on)
|
|||
return true;
|
||||
}
|
||||
|
||||
static bool x11_set_resolution(void *data,
|
||||
unsigned width, unsigned height, int f_restore, float hz)
|
||||
{
|
||||
int i = 0;
|
||||
int hfp = 0;
|
||||
int hsp = 0;
|
||||
int hbp = 0;
|
||||
int vfp = 0;
|
||||
int vsp = 0;
|
||||
int vbp = 0;
|
||||
int hmax = 0;
|
||||
int vmax = 0;
|
||||
float pixel_clock = 0;
|
||||
char xrandr[250];
|
||||
char fbset[150];
|
||||
char output[150];
|
||||
|
||||
hsp = width*1.10;
|
||||
|
||||
/* set core refresh from hz */
|
||||
video_monitor_set_refresh_rate(hz);
|
||||
|
||||
/* following code is the mode line genorator */
|
||||
|
||||
if (width < 599)
|
||||
{
|
||||
hfp = width+8;
|
||||
hbp = width*1.10;
|
||||
}
|
||||
if (width > 599 && width < 1919)
|
||||
{
|
||||
hfp = width+16;
|
||||
hbp = width*1.10-8;
|
||||
}
|
||||
|
||||
if (width > 1919 && width < 2559)
|
||||
{
|
||||
hfp = width+32;
|
||||
hbp = width*1.10;
|
||||
}
|
||||
|
||||
if (width > 2559)
|
||||
{
|
||||
hfp = width+48;
|
||||
hbp = width*1.24;
|
||||
}
|
||||
|
||||
hmax = hbp;
|
||||
|
||||
if (height < 241)
|
||||
{
|
||||
vmax = 261;
|
||||
}
|
||||
if (height < 241 && hz > 56 && hz < 58)
|
||||
{
|
||||
vmax = 280;
|
||||
}
|
||||
if (height < 241 && hz < 55)
|
||||
{
|
||||
vmax = 313;
|
||||
}
|
||||
if (height > 250 && height < 260 && hz > 54)
|
||||
{
|
||||
vmax = 296;
|
||||
}
|
||||
if (height > 250 && height < 260 && hz > 52 && hz < 54)
|
||||
{
|
||||
vmax = 285;
|
||||
}
|
||||
if (height > 240 && height < 260 && hz < 52)
|
||||
{
|
||||
vmax = 265;
|
||||
}
|
||||
if (height > 250 && height < 260 && hz < 52)
|
||||
{
|
||||
vmax = 313;
|
||||
}
|
||||
if (height > 260 && height < 300)
|
||||
{
|
||||
vmax = 313;
|
||||
}
|
||||
|
||||
if (height > 400 && hz > 56)
|
||||
{
|
||||
vmax = 523;
|
||||
}
|
||||
if (height > 520 && hz < 57)
|
||||
{
|
||||
vmax = 580;
|
||||
}
|
||||
|
||||
if (height > 300 && hz < 56)
|
||||
{
|
||||
vmax = 627;
|
||||
}
|
||||
|
||||
if (hz < 53)
|
||||
{
|
||||
vfp = height+((vmax-height)*0.38);
|
||||
}
|
||||
if (hz > 56)
|
||||
{
|
||||
vfp = height+((vmax-height)*0.15);
|
||||
}
|
||||
if (hz > 53 && hz < 56)
|
||||
{
|
||||
vfp = height+((vmax-height)*0.35);
|
||||
}
|
||||
|
||||
|
||||
if ( vfp < 1 )
|
||||
{
|
||||
vfp = height+2;
|
||||
|
||||
}
|
||||
|
||||
if (height < 300)
|
||||
{
|
||||
vsp = vfp+3; /* needs to me 3 for progressive */
|
||||
} if (height > 300)
|
||||
{
|
||||
vsp = vfp+6; /* needs to me 6 for interlaced */
|
||||
}
|
||||
|
||||
vbp = vmax;
|
||||
|
||||
if (height < 300)
|
||||
{
|
||||
pixel_clock = (hmax*vmax*hz)/1000000;
|
||||
}
|
||||
|
||||
if (height > 300)
|
||||
{
|
||||
pixel_clock = ((hmax*vmax*hz)/1000000)/2;
|
||||
}
|
||||
/* above code is the modeline genorator */
|
||||
|
||||
/* create progressive newmode from modline variables */
|
||||
if (height < 300)
|
||||
{
|
||||
sprintf(xrandr,"xrandr --newmode \"%dx%d_%0.2f\" %0.2f %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\" %0.2f %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);
|
||||
|
||||
/* 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", "DVI",i ,new_mode);
|
||||
system(output);
|
||||
sprintf(output,"xrandr --delmode %s%d %s", "DVI",i ,old_mode);
|
||||
system(output);
|
||||
}
|
||||
for (i =0; i < 3; i++)
|
||||
{
|
||||
sprintf(output,"xrandr --addmode %s-%d %s", "DVI",i ,new_mode);
|
||||
system(output);
|
||||
sprintf(output,"xrandr --delmode %s-%d %s", "DVI",i ,old_mode);
|
||||
system(output);
|
||||
}
|
||||
for (i =0; i < 3; i++)
|
||||
{
|
||||
sprintf(output,"xrandr --addmode %s%d %s", "VGA",i ,new_mode);
|
||||
system(output);
|
||||
sprintf(output,"xrandr --delmode %s%d %s", "VGA",i ,old_mode);
|
||||
system(output);
|
||||
}
|
||||
for (i =0; i < 3; i++)
|
||||
{
|
||||
sprintf(output,"xrandr --addmode %s-%d %s", "VGA",i ,new_mode);
|
||||
system(output);
|
||||
sprintf(output,"xrandr --delmode %s-%d %s", "VGA",i ,old_mode);
|
||||
system(output);
|
||||
}
|
||||
|
||||
sprintf(output,"xrandr -s %s", new_mode);
|
||||
system(output);
|
||||
/* remove old mode */
|
||||
sprintf(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);
|
||||
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 */
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
const video_display_server_t dispserv_x11 = {
|
||||
x11_display_server_init,
|
||||
x11_display_server_destroy,
|
||||
x11_set_window_opacity,
|
||||
NULL,
|
||||
x11_set_window_decorations,
|
||||
NULL, /* get_current_resolution */
|
||||
NULL, /* set_resolution */
|
||||
x11_set_resolution, /* set_resolution */
|
||||
"x11"
|
||||
};
|
||||
|
||||
|
|
|
@ -48,22 +48,6 @@ static void crt_check_first_run(void)
|
|||
first_run = false;
|
||||
}
|
||||
|
||||
static void switch_crt_hz(void)
|
||||
{
|
||||
if (ra_core_hz == ra_tmp_core_hz)
|
||||
return;
|
||||
|
||||
/* set hz float an int for windows switching */
|
||||
if (ra_core_hz < 53)
|
||||
ra_set_core_hz = 50;
|
||||
if (ra_core_hz >= 53 && ra_core_hz < 57)
|
||||
ra_set_core_hz = 55;
|
||||
if (ra_core_hz >= 57)
|
||||
ra_set_core_hz = 60;
|
||||
video_monitor_set_refresh_rate(ra_set_core_hz);
|
||||
ra_tmp_core_hz = ra_core_hz;
|
||||
}
|
||||
|
||||
static void crt_aspect_ratio_switch(unsigned width, unsigned height)
|
||||
{
|
||||
/* send aspect float to videeo_driver */
|
||||
|
@ -76,7 +60,7 @@ static void switch_res_crt(unsigned width, unsigned height)
|
|||
if (height > 100)
|
||||
{
|
||||
video_display_server_switch_resolution(width, height,
|
||||
0, ra_set_core_hz);
|
||||
0, ra_core_hz);
|
||||
video_driver_apply_state_changes();
|
||||
}
|
||||
}
|
||||
|
@ -84,7 +68,6 @@ static void switch_res_crt(unsigned width, unsigned height)
|
|||
/* Create correct aspect to fit video if resolution does not exist */
|
||||
static void crt_screen_setup_aspect(unsigned width, unsigned height)
|
||||
{
|
||||
switch_crt_hz();
|
||||
|
||||
/* get original resolution of core */
|
||||
if (height == 4)
|
||||
|
|
|
@ -84,7 +84,7 @@ bool video_display_server_set_window_decorations(bool on)
|
|||
|
||||
|
||||
bool video_display_server_switch_resolution(unsigned width, unsigned height,
|
||||
int f_restore, int hz)
|
||||
int f_restore, float hz)
|
||||
{
|
||||
if (current_display_server && current_display_server->switch_resolution)
|
||||
return current_display_server->switch_resolution(current_display_server_data, width, height, f_restore, hz);
|
||||
|
|
|
@ -31,7 +31,7 @@ typedef struct video_display_server
|
|||
bool (*set_window_progress)(void *data, int progress, bool finished);
|
||||
bool (*set_window_decorations)(void *data, bool on);
|
||||
bool (*switch_resolution)(void *data, unsigned width,
|
||||
unsigned height, int f_restore, int hz);
|
||||
unsigned height, int f_restore, float hz);
|
||||
const char *ident;
|
||||
} video_display_server_t;
|
||||
|
||||
|
@ -47,7 +47,7 @@ bool video_display_server_set_window_decorations(bool on);
|
|||
|
||||
bool video_display_server_switch_resolution(
|
||||
unsigned width, unsigned height,
|
||||
int f_restore, int hz);
|
||||
int f_restore, float hz);
|
||||
|
||||
extern const video_display_server_t dispserv_win32;
|
||||
extern const video_display_server_t dispserv_x11;
|
||||
|
|
Loading…
Reference in New Issue