diff options
| author | SND\ckain_cp <SND\ckain_cp@e17a0e51-4ae3-4d35-97c3-1a29b211df97> | 2013-07-26 09:59:05 +0000 |
|---|---|---|
| committer | SND\ckain_cp <SND\ckain_cp@e17a0e51-4ae3-4d35-97c3-1a29b211df97> | 2013-07-26 09:59:05 +0000 |
| commit | 13e08db872f4775ca23df12fcc03f1916ed9691e (patch) | |
| tree | c66601f85caab2ad0f7b78f3d4973d1fa9b1ae81 /plugins/dfinput | |
| parent | 6131285e0c96333cf10b7257441e54caae661cdf (diff) | |
| download | pcsxr-13e08db872f4775ca23df12fcc03f1916ed9691e.tar.gz | |
GTK/dfinput: added "prevent screensaver" feature. Makes ugly call to xdg-screensaver script which seems to be only sopisticated way of handling multiple screensaver backends.
git-svn-id: https://pcsxr.svn.codeplex.com/svn/pcsxr@86254 e17a0e51-4ae3-4d35-97c3-1a29b211df97
Diffstat (limited to 'plugins/dfinput')
| -rwxr-xr-x | plugins/dfinput/cfg-gtk.c | 10 | ||||
| -rwxr-xr-x | plugins/dfinput/cfg.c | 8 | ||||
| -rw-r--r-- | plugins/dfinput/dfinput.ui | 15 | ||||
| -rwxr-xr-x | plugins/dfinput/pad.c | 1 | ||||
| -rwxr-xr-x | plugins/dfinput/pad.h | 7 | ||||
| -rwxr-xr-x | plugins/dfinput/xkb.c | 26 |
6 files changed, 61 insertions, 6 deletions
diff --git a/plugins/dfinput/cfg-gtk.c b/plugins/dfinput/cfg-gtk.c index a60a16a9..7b5df6c2 100755 --- a/plugins/dfinput/cfg-gtk.c +++ b/plugins/dfinput/cfg-gtk.c @@ -353,6 +353,11 @@ static void OnHideCursorToggled(GtkWidget *widget, gpointer user_data) { g.cfg.HideCursor = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); } +static void OnPreventScrSaverToggled(GtkWidget *widget, gpointer user_data) { + (void)user_data; // unused + g.cfg.PreventScrSaver = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); +} + static void ReadDKeyEvent(int padnum, int key) { SDL_Joystick *js; time_t t; @@ -708,6 +713,11 @@ long PADconfigure() { g_signal_connect_data(G_OBJECT(widget), "toggled", G_CALLBACK(OnHideCursorToggled), NULL, NULL, G_CONNECT_AFTER); + widget = GTK_WIDGET(gtk_builder_get_object(xml, "checkps")); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), g.cfg.PreventScrSaver); + g_signal_connect_data(G_OBJECT(widget), "toggled", + G_CALLBACK(OnPreventScrSaverToggled), NULL, NULL, G_CONNECT_AFTER); + widget = GTK_WIDGET(gtk_builder_get_object(xml, widgetname_combodev[1])); g_signal_connect_data(G_OBJECT(widget), "changed", G_CALLBACK(OnDeviceChanged), GINT_TO_POINTER(0), NULL, G_CONNECT_AFTER); diff --git a/plugins/dfinput/cfg.c b/plugins/dfinput/cfg.c index c8158300..6e45a122 100755 --- a/plugins/dfinput/cfg.c +++ b/plugins/dfinput/cfg.c @@ -26,7 +26,8 @@ static void SetDefaultConfig() { memset(&g.cfg, 0, sizeof(g.cfg)); g.cfg.Threaded = 1; - g.cfg.HideCursor = 0; + g.cfg.HideCursor = 0; + g.cfg.PreventScrSaver = 0u; g.cfg.PadDef[0].DevNum = 0; g.cfg.PadDef[1].DevNum = 1; @@ -145,6 +146,8 @@ void LoadPADConfig() { g.cfg.Threaded = atoi(&buf[9]); } else if (strncmp(buf, "HideCursor=", 11) == 0) { g.cfg.HideCursor = atoi(&buf[11]); + } else if (strncmp(buf, "PreventScrSaver=", 16) == 0) { + g.cfg.PreventScrSaver = atoi(&buf[16]); } else if (strncmp(buf, "[PAD", 4) == 0) { current = atoi(&buf[4]) - 1; if (current < 0) { @@ -332,7 +335,8 @@ void SavePADConfig() { fprintf(fp, "[CONFIG]\n"); fprintf(fp, "Threaded=%d\n", g.cfg.Threaded); - fprintf(fp, "HideCursor=%d\n", g.cfg.HideCursor); + fprintf(fp, "HideCursor=%d\n", g.cfg.HideCursor); + fprintf(fp, "PreventScrSaver=%d\n", g.cfg.PreventScrSaver); fprintf(fp, "\n"); for (i = 0; i < 2; i++) { diff --git a/plugins/dfinput/dfinput.ui b/plugins/dfinput/dfinput.ui index df3b4606..17dfbdb9 100644 --- a/plugins/dfinput/dfinput.ui +++ b/plugins/dfinput/dfinput.ui @@ -694,6 +694,21 @@ <property name="position">1</property> </packing> </child> + <child> + <object class="GtkCheckButton" id="checkps"> + <property name="label" translatable="yes">Prevent screensaver (xdg-screensaver)</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="xalign">0</property> + <property name="draw_indicator">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">2</property> + </packing> + </child> </object> <packing> <property name="position">3</property> diff --git a/plugins/dfinput/pad.c b/plugins/dfinput/pad.c index 0861312e..d56c14ae 100755 --- a/plugins/dfinput/pad.c +++ b/plugins/dfinput/pad.c @@ -141,7 +141,6 @@ long PADclose(void) { SDL_Quit(); } } - g.Opened = 0; return PSE_PAD_ERR_SUCCESS; diff --git a/plugins/dfinput/pad.h b/plugins/dfinput/pad.h index f7927214..f055d9a0 100755 --- a/plugins/dfinput/pad.h +++ b/plugins/dfinput/pad.h @@ -167,7 +167,8 @@ typedef struct tagEmuDef2{ typedef struct tagConfig { uint8_t Threaded; - uint8_t HideCursor; + uint8_t HideCursor; + uint8_t PreventScrSaver; PADDEF PadDef[2]; EMUDEF2 E; } CONFIG; @@ -182,11 +183,11 @@ typedef struct tagPadState { volatile uint16_t JoyKeyStatus; volatile uint8_t AnalogStatus[ANALOG_TOTAL][2]; // 0-255 where 127 is center position volatile uint8_t AnalogKeyStatus[ANALOG_TOTAL][4]; - volatile int8_t MouseAxis[2][2]; + volatile int8_t MouseAxis[2][2]; uint8_t Vib0, Vib1; volatile uint8_t VibF[2]; #if SDL_VERSION_ATLEAST(1,3,0) - SDL_Haptic *haptic; + SDL_Haptic *haptic; #else #ifdef __linux__ int VibrateDev; diff --git a/plugins/dfinput/xkb.c b/plugins/dfinput/xkb.c index ed13c7c4..53fb90d4 100755 --- a/plugins/dfinput/xkb.c +++ b/plugins/dfinput/xkb.c @@ -23,6 +23,7 @@ static Atom wmprotocols, wmdelwindow; static int g_currentMouse_X; static int g_currentMouse_Y; static Window window; +static uint8_t resumeScrSaver = 0; void InitKeyboard() { int revert_to; @@ -30,6 +31,7 @@ void InitKeyboard() { wmprotocols = XInternAtom(g.Disp, "WM_PROTOCOLS", 0); wmdelwindow = XInternAtom(g.Disp, "WM_DELETE_WINDOW", 0); + // Hide cursor and lock cursor to window if type is mouse XkbSetDetectableAutoRepeat(g.Disp, 1, NULL); XGetInputFocus(g.Disp, &window, &revert_to); if (g.cfg.PadDef[0].Type == PSE_PAD_TYPE_MOUSE || @@ -40,6 +42,20 @@ void InitKeyboard() { showCursor(g.Disp, window, 0); } + // Disable screensaver - this could be in different place + resumeScrSaver = 0; + if (g.cfg.PreventScrSaver) { + char buf[64]; + snprintf(buf, 64, "xdg-screensaver suspend 0x%x > /dev/null 2>&1", window); + if (pclose(popen(buf, "r")) == 0) { + resumeScrSaver = 1; + printf("Suspending Window ID 0x%x of activating screensaver.\n", window); + } else { + //resumeScrSaver = 0; + fprintf(stderr, "Failed to execute xdg-screensaver (maybe not installed?)\n"); + } + } + g_currentMouse_X = 0; g_currentMouse_Y = 0; @@ -50,6 +66,7 @@ void InitKeyboard() { void DestroyKeyboard() { XkbSetDetectableAutoRepeat(g.Disp, 0, NULL); + // Enable cursor and revert grab cursor if mouse if (g.cfg.PadDef[0].Type == PSE_PAD_TYPE_MOUSE || g.cfg.PadDef[1].Type == PSE_PAD_TYPE_MOUSE) { grabCursor(g.Disp, window, 0); @@ -57,6 +74,15 @@ void DestroyKeyboard() { } else if (g.cfg.HideCursor) { showCursor(g.Disp, window, 1); } + + // Enable screensaver if it was disabled - this could be in different place + if (resumeScrSaver) { + char buf[64]; + printf("Resuming Window ID 0x%x to activate screensaver.\n", window); + snprintf(buf, 64, "xdg-screensaver resume 0x%x", window); + FILE *phandle = popen(buf, "r"); + pclose(phandle); + } } static void bdown(int pad, int bit) |
