diff options
| author | iCatButler <i.am.catbutler@gmail.com> | 2018-03-13 17:25:13 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-03-13 17:25:13 +0000 |
| commit | 768332417644451d38ce1a737465656c7cc75de3 (patch) | |
| tree | e6ca381effb72ccc4161d40f224b817a6631bc03 /plugins/dfinput | |
| parent | 15fe3782c1375634b7a9bd9bbbadfd75e7b06fed (diff) | |
| parent | 2d0b10f982e0b835f4b27be26b138703907a4219 (diff) | |
| download | pcsxr-768332417644451d38ce1a737465656c7cc75de3.tar.gz | |
Merge pull request #6 from loathingKernel/fix-linux-build
Fix compilation on Linux and add the new setting to the UI
Diffstat (limited to 'plugins/dfinput')
| -rw-r--r-- | plugins/dfinput/Makefile.am | 28 | ||||
| -rwxr-xr-x | plugins/dfinput/cfg-gtk.c | 33 | ||||
| -rwxr-xr-x | plugins/dfinput/cfg.c | 5 | ||||
| -rw-r--r-- | plugins/dfinput/dfinput.ui | 233 | ||||
| -rwxr-xr-x | plugins/dfinput/pad.c | 18 | ||||
| -rwxr-xr-x | plugins/dfinput/pad.h | 1 | ||||
| -rwxr-xr-x | plugins/dfinput/sdljoy.c | 4 | ||||
| -rwxr-xr-x | plugins/dfinput/xkb.c | 4 |
8 files changed, 206 insertions, 120 deletions
diff --git a/plugins/dfinput/Makefile.am b/plugins/dfinput/Makefile.am index 70f86fd1..458259c5 100644 --- a/plugins/dfinput/Makefile.am +++ b/plugins/dfinput/Makefile.am @@ -13,9 +13,31 @@ AM_CPPFLAGS = -DLOCALE_DIR=\"${datadir}/locale/\" \ -I../../include -I$(top_srcdir)/libpcsxcore $(SDL2_CFLAGS) $(SDL_CFLAGS) bin_PROGRAMS = cfgDFInput -cfgDFInput_SOURCES = cfg-gtk.c pad.h +cfgDFInput_SOURCES = cfg-gtk.c pad.h GtkResources.c GtkResources.h cfgDFInput_LDADD = $(GTK3_LIBS) $(SDL2_LIBS) $(SDL_LIBS) -lX11 -glade_DATA = dfinput.ui -gladedir = $(datadir)/psemu/ +# gresource.xml is dynamically generated in CMake. Mirror that here in a static way. +define gresource_xml = +<?xml version="1.0" encoding="UTF-8"?> +<gresources> + <gresource prefix="/org/pcsxr/dfinput"> + <file>dfinput.ui</file> + </gresource> +</gresources> +endef + +dfinput.gresource.xml: + $(file >$@,$(gresource_xml)) +dfinput_gresource: dfinput.gresource.xml + $(shell $(GLIB_COMPILE_RESOURCES) --sourcedir=$(srcdir) --generate-dependencies $(srcdir)/$<) +GtkResources.c: dfinput.gresource.xml $(dfinput_gresource) + $(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) --target=$@ --sourcedir=$(srcdir) --generate-source --c-name dfinput $< +GtkResources.h: dfinput.gresource.xml $(dfinput_gresource) + $(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) --target=$@ --sourcedir=$(srcdir) --generate-header --c-name dfinput $< + + +#glade_DATA = dfinput.ui +#gladedir = $(datadir)/psemu/ EXTRA_DIST = $(glade_DATA) + +CLEANFILES = dfinput.gresource.xml GtkResources.c GtkResources.h diff --git a/plugins/dfinput/cfg-gtk.c b/plugins/dfinput/cfg-gtk.c index 5f26040f..bcc733d1 100755 --- a/plugins/dfinput/cfg-gtk.c +++ b/plugins/dfinput/cfg-gtk.c @@ -246,7 +246,6 @@ static void UpdateKeyList() { gtk_tree_view_set_model(GTK_TREE_VIEW(widget), GTK_TREE_MODEL(store)); g_object_unref(G_OBJECT(store)); - gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(widget), TRUE); gtk_widget_show(widget); } } @@ -327,6 +326,7 @@ static void OnDeviceChanged(GtkWidget *widget, gpointer user_data) { static void OnTypeChanged(GtkWidget *widget, gpointer user_data) { uint n = GPOINTER_TO_UINT(user_data), current = gtk_combo_box_get_active(GTK_COMBO_BOX(widget)); + char checkbtn[9]; int padTypeList[] = { PSE_PAD_TYPE_STANDARD, @@ -336,6 +336,10 @@ static void OnTypeChanged(GtkWidget *widget, gpointer user_data) { g.cfg.PadDef[n].Type = padTypeList[current]; + snprintf(checkbtn, sizeof(checkbtn), "checkpv%d", n+1); + gtk_widget_set_sensitive(GTK_WIDGET( + gtk_builder_get_object(xml, checkbtn)), (g.cfg.PadDef[n].Type == PSE_PAD_TYPE_ANALOGPAD)); + UpdateKeyList(); } @@ -351,6 +355,14 @@ static void OnVisualVibration2Toggled(GtkWidget *widget, gpointer user_data) { g.cfg.PadDef[1].VisualVibration = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); } +static void OnPhysicalVibration1Toggled(GtkWidget *widget, gpointer user_data) { + g.cfg.PadDef[0].PhysicalVibration = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); +} + +static void OnPhysicalVibration2Toggled(GtkWidget *widget, gpointer user_data) { + g.cfg.PadDef[1].PhysicalVibration = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); +} + static void OnHideCursorToggled(GtkWidget *widget, gpointer user_data) { (void)user_data; // unused g.cfg.HideCursor = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); @@ -612,9 +624,9 @@ static void PopulateDevList() { for (j = 0; j < n; j++) { #if SDL_VERSION_ATLEAST(2, 0, 0) SDL_Joystick *joystick = SDL_JoystickOpen(j); - sprintf(buf, "%d: %s", j + 1, SDL_JoystickName(joystick)); + snprintf(buf, sizeof(buf), "%d: %s", j + 1, SDL_JoystickName(joystick)); #else - sprintf(buf, "%d: %s", j + 1, SDL_JoystickName(j)); + snprintf(buf, sizeof(buf), "%d: %s", j + 1, SDL_JoystickName(j)); #endif gtk_list_store_append(store, &iter); gtk_list_store_set(store, &iter, 0, buf, -1); @@ -655,7 +667,7 @@ long PADconfigure() { xml = gtk_builder_new(); - if (!gtk_builder_add_from_file(xml, DATADIR "dfinput.ui", NULL)) { + if (!gtk_builder_add_from_resource(xml, "/org/pcsxr/dfinput/dfinput.ui", NULL)) { g_warning("We could not load the interface!"); return -1; } @@ -748,12 +760,14 @@ long PADconfigure() { widget = GTK_WIDGET(gtk_builder_get_object(xml, "combotype1")); gtk_combo_box_set_active(GTK_COMBO_BOX(widget), padTypeList[g.cfg.PadDef[0].Type]); + OnTypeChanged(widget, GUINT_TO_POINTER(0u)); g_signal_connect_data(G_OBJECT(widget), "changed", G_CALLBACK(OnTypeChanged), GUINT_TO_POINTER(0u), NULL, G_CONNECT_AFTER); widget = GTK_WIDGET(gtk_builder_get_object(xml, "combotype2")); gtk_combo_box_set_active(GTK_COMBO_BOX(widget), padTypeList[g.cfg.PadDef[1].Type]); + OnTypeChanged(widget, GUINT_TO_POINTER(1u)); g_signal_connect_data(G_OBJECT(widget), "changed", G_CALLBACK(OnTypeChanged), GUINT_TO_POINTER(1u), NULL, G_CONNECT_AFTER); @@ -767,6 +781,16 @@ long PADconfigure() { g_signal_connect_data(G_OBJECT(widget), "toggled", G_CALLBACK(OnVisualVibration2Toggled), NULL, NULL, G_CONNECT_AFTER); + widget = GTK_WIDGET(gtk_builder_get_object(xml, "checkpv1")); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), g.cfg.PadDef[0].PhysicalVibration); + g_signal_connect_data(G_OBJECT(widget), "toggled", + G_CALLBACK(OnPhysicalVibration1Toggled), NULL, NULL, G_CONNECT_AFTER); + + widget = GTK_WIDGET(gtk_builder_get_object(xml, "checkpv2")); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), g.cfg.PadDef[1].PhysicalVibration); + g_signal_connect_data(G_OBJECT(widget), "toggled", + G_CALLBACK(OnPhysicalVibration2Toggled), NULL, NULL, G_CONNECT_AFTER); + widget = GTK_WIDGET(gtk_builder_get_object(xml, widgetname_change[1])); gtk_widget_set_sensitive(widget, FALSE); g_signal_connect_data(G_OBJECT(widget), "clicked", @@ -837,6 +861,7 @@ void PADabout() { GtkWidget *widget; widget = gtk_about_dialog_new(); + gtk_about_dialog_set_logo_icon_name (GTK_ABOUT_DIALOG(widget), "help-about"); gtk_about_dialog_set_program_name(GTK_ABOUT_DIALOG(widget), "Gamepad/Keyboard Input"); gtk_about_dialog_set_version(GTK_ABOUT_DIALOG(widget), "1.2"); gtk_about_dialog_set_authors(GTK_ABOUT_DIALOG(widget), authors); diff --git a/plugins/dfinput/cfg.c b/plugins/dfinput/cfg.c index f1d16673..622c3c34 100755 --- a/plugins/dfinput/cfg.c +++ b/plugins/dfinput/cfg.c @@ -37,6 +37,8 @@ static void SetDefaultConfig() { g.cfg.PadDef[0].VisualVibration = 0; g.cfg.PadDef[1].VisualVibration = 0; + g.cfg.PadDef[0].PhysicalVibration = 1; + g.cfg.PadDef[1].PhysicalVibration = 1; // Pad1 keyboard g.cfg.PadDef[0].KeyDef[DKEY_SELECT].Key = XK_c; @@ -164,6 +166,8 @@ void LoadPADConfig() { g.cfg.PadDef[current].Type = atoi(&buf[5]); } else if (strncmp(buf, "VisualVibration=", 16) == 0) { g.cfg.PadDef[current].VisualVibration = atoi(&buf[16]); + } else if (strncmp(buf, "PhysicalVibration=", 18) == 0) { + g.cfg.PadDef[current].PhysicalVibration = atoi(&buf[18]); } else if (strncmp(buf, "EmuDev=", 7) == 0) { g.cfg.E.DevNum = atoi(&buf[5]); } else if (strncmp(buf, "EMU_FASTFORWARDS=", 17) == 0) { @@ -362,6 +366,7 @@ void SavePADConfig() { fprintf(fp, "DevNum=%d\n", g.cfg.PadDef[i].DevNum); fprintf(fp, "Type=%d\n", g.cfg.PadDef[i].Type); fprintf(fp, "VisualVibration=%d\n", g.cfg.PadDef[i].VisualVibration); + fprintf(fp, "PhysicalVibration=%d\n", g.cfg.PadDef[i].PhysicalVibration); fprintf(fp, "Select=%d,%d,%d\n", g.cfg.PadDef[i].KeyDef[DKEY_SELECT].Key, g.cfg.PadDef[i].KeyDef[DKEY_SELECT].JoyEvType, g.cfg.PadDef[i].KeyDef[DKEY_SELECT].J.d); diff --git a/plugins/dfinput/dfinput.ui b/plugins/dfinput/dfinput.ui index 17dfbdb9..2d291e22 100644 --- a/plugins/dfinput/dfinput.ui +++ b/plugins/dfinput/dfinput.ui @@ -1,23 +1,58 @@ <?xml version="1.0" encoding="UTF-8"?> +<!-- Generated with glade 3.20.0 --> <interface> - <!-- interface-requires gtk+ 3.0 --> + <requires lib="gtk+" version="3.14"/> + <object class="GtkListStore" id="liststore1"> + <columns> + <!-- column-name item --> + <column type="gchararray"/> + </columns> + <data> + <row> + <col id="0" translatable="yes">Digital Pad</col> + </row> + <row> + <col id="0" translatable="yes">Analog Pad</col> + </row> + <row> + <col id="0" translatable="yes">Mouse</col> + </row> + </data> + </object> + <object class="GtkListStore" id="liststore2"> + <columns> + <!-- column-name item --> + <column type="gchararray"/> + </columns> + <data> + <row> + <col id="0" translatable="yes">Digital Pad</col> + </row> + <row> + <col id="0" translatable="yes">Analog Pad</col> + </row> + <row> + <col id="0" translatable="yes">Mouse</col> + </row> + </data> + </object> <object class="GtkWindow" id="CfgWnd"> <property name="can_focus">False</property> <child> - <object class="GtkTable" id="table1"> + <object class="GtkGrid" id="table1"> <property name="visible">True</property> <property name="can_focus">False</property> <property name="border_width">5</property> - <property name="n_rows">2</property> <child> <object class="GtkNotebook" id="notebook1"> <property name="visible">True</property> <property name="can_focus">True</property> <child> - <object class="GtkVBox" id="vbox1"> + <object class="GtkBox" id="vbox1"> <property name="visible">True</property> <property name="can_focus">False</property> <property name="border_width">5</property> + <property name="orientation">vertical</property> <property name="spacing">2</property> <child> <object class="GtkGrid" id="grid1"> @@ -29,14 +64,11 @@ <object class="GtkLabel" id="label10"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="xalign">0</property> <property name="label" translatable="yes">Device:</property> </object> <packing> <property name="left_attach">0</property> <property name="top_attach">0</property> - <property name="width">1</property> - <property name="height">1</property> </packing> </child> <child> @@ -47,22 +79,17 @@ <packing> <property name="left_attach">1</property> <property name="top_attach">0</property> - <property name="width">1</property> - <property name="height">1</property> </packing> </child> <child> <object class="GtkLabel" id="label5"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="xalign">0</property> <property name="label" translatable="yes">Type:</property> </object> <packing> <property name="left_attach">0</property> <property name="top_attach">1</property> - <property name="width">1</property> - <property name="height">1</property> </packing> </child> <child> @@ -80,8 +107,6 @@ <packing> <property name="left_attach">1</property> <property name="top_attach">1</property> - <property name="width">1</property> - <property name="height">1</property> </packing> </child> </object> @@ -92,13 +117,37 @@ </packing> </child> <child> - <object class="GtkCheckButton" id="checkvv1"> - <property name="label" translatable="yes">Visual vibration</property> + <object class="GtkBox"> <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> + <property name="can_focus">False</property> + <child> + <object class="GtkCheckButton" id="checkvv1"> + <property name="label" translatable="yes">Visual vibration</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="draw_indicator">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkCheckButton" id="checkpv1"> + <property name="label" translatable="yes">Physical vibration</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="draw_indicator">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> </object> <packing> <property name="expand">False</property> @@ -113,7 +162,6 @@ <property name="visible">True</property> <property name="can_focus">True</property> <property name="border_width">5</property> - <property name="window_placement_set">True</property> <property name="shadow_type">etched-in</property> <child> <object class="GtkTreeView" id="treeview1"> @@ -132,7 +180,7 @@ </packing> </child> <child> - <object class="GtkHButtonBox" id="hbuttonbox2"> + <object class="GtkButtonBox" id="hbuttonbox2"> <property name="visible">True</property> <property name="can_focus">False</property> <property name="spacing">20</property> @@ -143,7 +191,7 @@ <property name="can_focus">True</property> <property name="receives_default">True</property> <child> - <object class="GtkHBox" id="hbox1"> + <object class="GtkBox" id="hbox1"> <property name="visible">True</property> <property name="can_focus">False</property> <child> @@ -151,7 +199,7 @@ <property name="visible">True</property> <property name="can_focus">False</property> <property name="stock">gtk-edit</property> - <property name="icon-size">1</property> + <property name="icon_size">1</property> </object> <packing> <property name="expand">True</property> @@ -186,7 +234,7 @@ <property name="can_focus">True</property> <property name="receives_default">True</property> <child> - <object class="GtkHBox" id="hbox2"> + <object class="GtkBox" id="hbox2"> <property name="visible">True</property> <property name="can_focus">False</property> <child> @@ -194,7 +242,7 @@ <property name="visible">True</property> <property name="can_focus">False</property> <property name="stock">gtk-undo</property> - <property name="icon-size">1</property> + <property name="icon_size">1</property> </object> <packing> <property name="expand">True</property> @@ -243,10 +291,11 @@ </packing> </child> <child> - <object class="GtkVBox" id="vbox2"> + <object class="GtkBox" id="vbox2"> <property name="visible">True</property> <property name="can_focus">False</property> <property name="border_width">5</property> + <property name="orientation">vertical</property> <property name="spacing">2</property> <child> <object class="GtkGrid" id="grid2"> @@ -258,14 +307,11 @@ <object class="GtkLabel" id="label11"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="xalign">0</property> <property name="label" translatable="yes">Device:</property> </object> <packing> <property name="left_attach">0</property> <property name="top_attach">0</property> - <property name="width">1</property> - <property name="height">1</property> </packing> </child> <child> @@ -276,22 +322,17 @@ <packing> <property name="left_attach">1</property> <property name="top_attach">0</property> - <property name="width">1</property> - <property name="height">1</property> </packing> </child> <child> <object class="GtkLabel" id="label7"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="xalign">0</property> <property name="label" translatable="yes">Type:</property> </object> <packing> <property name="left_attach">0</property> <property name="top_attach">1</property> - <property name="width">1</property> - <property name="height">1</property> </packing> </child> <child> @@ -309,8 +350,6 @@ <packing> <property name="left_attach">1</property> <property name="top_attach">1</property> - <property name="width">1</property> - <property name="height">1</property> </packing> </child> </object> @@ -321,13 +360,37 @@ </packing> </child> <child> - <object class="GtkCheckButton" id="checkvv2"> - <property name="label" translatable="yes">Visual vibration</property> + <object class="GtkBox"> <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> + <property name="can_focus">False</property> + <child> + <object class="GtkCheckButton" id="checkvv2"> + <property name="label" translatable="yes">Visual vibration</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="draw_indicator">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkCheckButton" id="checkpv2"> + <property name="label" translatable="yes">Physical vibration</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="draw_indicator">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> </object> <packing> <property name="expand">False</property> @@ -342,7 +405,6 @@ <property name="visible">True</property> <property name="can_focus">True</property> <property name="border_width">5</property> - <property name="window_placement_set">True</property> <property name="shadow_type">etched-in</property> <child> <object class="GtkTreeView" id="treeview2"> @@ -361,7 +423,7 @@ </packing> </child> <child> - <object class="GtkHButtonBox" id="hbuttonbox3"> + <object class="GtkButtonBox" id="hbuttonbox3"> <property name="visible">True</property> <property name="can_focus">False</property> <property name="spacing">20</property> @@ -372,7 +434,7 @@ <property name="can_focus">True</property> <property name="receives_default">True</property> <child> - <object class="GtkHBox" id="hbox3"> + <object class="GtkBox" id="hbox3"> <property name="visible">True</property> <property name="can_focus">False</property> <child> @@ -380,7 +442,7 @@ <property name="visible">True</property> <property name="can_focus">False</property> <property name="stock">gtk-edit</property> - <property name="icon-size">1</property> + <property name="icon_size">1</property> </object> <packing> <property name="expand">True</property> @@ -415,7 +477,7 @@ <property name="can_focus">True</property> <property name="receives_default">True</property> <child> - <object class="GtkHBox" id="hbox4"> + <object class="GtkBox" id="hbox4"> <property name="visible">True</property> <property name="can_focus">False</property> <child> @@ -423,7 +485,7 @@ <property name="visible">True</property> <property name="can_focus">False</property> <property name="stock">gtk-undo</property> - <property name="icon-size">1</property> + <property name="icon_size">1</property> </object> <packing> <property name="expand">True</property> @@ -471,14 +533,16 @@ <property name="label" translatable="yes">Controller 2</property> </object> <packing> + <property name="position">1</property> <property name="tab_fill">False</property> </packing> </child> <child> - <object class="GtkVBox" id="vbox_e"> + <object class="GtkBox" id="vbox_e"> <property name="visible">True</property> <property name="can_focus">False</property> <property name="border_width">5</property> + <property name="orientation">vertical</property> <property name="spacing">2</property> <child> <object class="GtkGrid" id="grid_e"> @@ -490,14 +554,11 @@ <object class="GtkLabel" id="label_e2"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="xalign">0</property> <property name="label" translatable="yes">Device:</property> </object> <packing> <property name="left_attach">0</property> <property name="top_attach">0</property> - <property name="width">1</property> - <property name="height">1</property> </packing> </child> <child> @@ -508,8 +569,6 @@ <packing> <property name="left_attach">1</property> <property name="top_attach">0</property> - <property name="width">1</property> - <property name="height">1</property> </packing> </child> </object> @@ -526,7 +585,6 @@ <property name="visible">True</property> <property name="can_focus">True</property> <property name="border_width">5</property> - <property name="window_placement_set">True</property> <property name="shadow_type">etched-in</property> <child> <object class="GtkTreeView" id="treeview_e"> @@ -545,7 +603,7 @@ </packing> </child> <child> - <object class="GtkHButtonBox" id="hbuttonbox_e"> + <object class="GtkButtonBox" id="hbuttonbox_e"> <property name="visible">True</property> <property name="can_focus">False</property> <property name="spacing">20</property> @@ -556,7 +614,7 @@ <property name="can_focus">True</property> <property name="receives_default">True</property> <child> - <object class="GtkHBox" id="hbox_e1"> + <object class="GtkBox" id="hbox_e1"> <property name="visible">True</property> <property name="can_focus">False</property> <child> @@ -564,7 +622,7 @@ <property name="visible">True</property> <property name="can_focus">False</property> <property name="stock">gtk-edit</property> - <property name="icon-size">1</property> + <property name="icon_size">1</property> </object> <packing> <property name="expand">True</property> @@ -599,7 +657,7 @@ <property name="can_focus">True</property> <property name="receives_default">True</property> <child> - <object class="GtkHBox" id="hbox_e2"> + <object class="GtkBox" id="hbox_e2"> <property name="visible">True</property> <property name="can_focus">False</property> <child> @@ -607,7 +665,7 @@ <property name="visible">True</property> <property name="can_focus">False</property> <property name="stock">gtk-undo</property> - <property name="icon-size">1</property> + <property name="icon_size">1</property> </object> <packing> <property name="expand">True</property> @@ -655,14 +713,16 @@ <property name="label" translatable="yes">Emulator keys</property> </object> <packing> + <property name="position">2</property> <property name="tab_fill">False</property> </packing> </child> <child> - <object class="GtkVBox" id="vbox3"> + <object class="GtkBox" id="vbox3"> <property name="visible">True</property> <property name="can_focus">False</property> <property name="border_width">5</property> + <property name="orientation">vertical</property> <property name="spacing">5</property> <child> <object class="GtkCheckButton" id="checkmt"> @@ -670,7 +730,6 @@ <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> @@ -685,7 +744,6 @@ <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> @@ -700,7 +758,6 @@ <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> @@ -726,9 +783,13 @@ </packing> </child> </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">0</property> + </packing> </child> <child> - <object class="GtkHButtonBox" id="dialog-action_area1"> + <object class="GtkButtonBox" id="dialog-action_area1"> <property name="visible">True</property> <property name="can_focus">False</property> <property name="layout_style">end</property> @@ -748,46 +809,14 @@ </child> </object> <packing> + <property name="left_attach">0</property> <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="y_options">GTK_FILL</property> </packing> </child> </object> </child> - </object> - <object class="GtkListStore" id="liststore1"> - <columns> - <!-- column-name item --> - <column type="gchararray"/> - </columns> - <data> - <row> - <col id="0" translatable="yes">Digital Pad</col> - </row> - <row> - <col id="0" translatable="yes">Analog Pad</col> - </row> - <row> - <col id="0" translatable="yes">Mouse</col> - </row> - </data> - </object> - <object class="GtkListStore" id="liststore2"> - <columns> - <!-- column-name item --> - <column type="gchararray"/> - </columns> - <data> - <row> - <col id="0" translatable="yes">Digital Pad</col> - </row> - <row> - <col id="0" translatable="yes">Analog Pad</col> - </row> - <row> - <col id="0" translatable="yes">Mouse</col> - </row> - </data> + <child type="titlebar"> + <placeholder/> + </child> </object> </interface> diff --git a/plugins/dfinput/pad.c b/plugins/dfinput/pad.c index bd3aef73..f413d0a4 100755 --- a/plugins/dfinput/pad.c +++ b/plugins/dfinput/pad.c @@ -17,11 +17,15 @@ */ #include "pad.h" -#if !SDL_VERSION_ATLEAST(2,0,0) && defined(__linux__) +#if defined(__linux__) +#include <sys/types.h> +#include <sys/wait.h> +#if !SDL_VERSION_ATLEAST(2,0,0) #include <linux/input.h> #include <sys/file.h> #include <time.h> #endif +#endif #if SDL_VERSION_ATLEAST(2,0,0) int has_haptic; @@ -122,10 +126,10 @@ long PADopen(unsigned long *Disp) { #if SDL_VERSION_ATLEAST(2,0,0) SDL_InitSubSystem(SDL_INIT_GAMECONTROLLER); - - has_haptic = 0; - if (SDL_InitSubSystem(SDL_INIT_HAPTIC) == 0) - has_haptic = 1; + + has_haptic = 0; + if (SDL_InitSubSystem(SDL_INIT_HAPTIC) == 0) + has_haptic = 1; #endif InitSDLJoy(); @@ -491,7 +495,7 @@ unsigned char PADpoll(unsigned char value) { if (buf == NULL) { return 0; } - + switch (CurCmd) { case CMD_READ_DATA_AND_VIBRATE: if (g.cfg.PadDef[CurPad].Type == PSE_PAD_TYPE_ANALOGPAD) { @@ -510,7 +514,7 @@ unsigned char PADpoll(unsigned char value) { if (!JoyHapticRumble(CurPad, g.PadState[CurPad].VibF[0], g.PadState[CurPad].VibF[1])) { //gpuVisualVibration(g.PadState[CurPad].VibF[0], g.PadState[CurPad].VibF[1]); } - + if(gpuVisualVibration != NULL && g.cfg.PadDef[CurPad].VisualVibration) { gpuVisualVibration(g.PadState[CurPad].VibF[0], g.PadState[CurPad].VibF[1]); diff --git a/plugins/dfinput/pad.h b/plugins/dfinput/pad.h index 7cd8eefe..3051e6ad 100755 --- a/plugins/dfinput/pad.h +++ b/plugins/dfinput/pad.h @@ -158,6 +158,7 @@ typedef struct tagPadDef { int8_t DevNum; uint16_t Type; uint8_t VisualVibration; + uint8_t PhysicalVibration; KEYDEF KeyDef[DKEY_TOTAL]; KEYDEF AnalogDef[ANALOG_TOTAL][4]; #if SDL_VERSION_ATLEAST(2,0,0) diff --git a/plugins/dfinput/sdljoy.c b/plugins/dfinput/sdljoy.c index ee139517..3e8cc993 100755 --- a/plugins/dfinput/sdljoy.c +++ b/plugins/dfinput/sdljoy.c @@ -64,7 +64,7 @@ int JoyHapticRumble(int pad, uint32_t low, uint32_t high) #if SDL_VERSION_ATLEAST(2,0,0) float mag; - if (g.PadState[pad].haptic) { + if (g.PadState[pad].haptic && g.cfg.PadDef[pad].PhysicalVibration) { /* Stop the effect if it was playing. */ SDL_HapticRumbleStop(g.PadState[pad].haptic); @@ -74,7 +74,7 @@ int JoyHapticRumble(int pad, uint32_t low, uint32_t high) if(SDL_HapticRumblePlay(g.PadState[pad].haptic, mag, 500) != 0) { - printf("\nFailed to play rumble: %s\n", SDL_GetError()); + printf("\nFailed to play rumble on pad %d with error: %s\n", pad, SDL_GetError()); return 1; } } diff --git a/plugins/dfinput/xkb.c b/plugins/dfinput/xkb.c index 53fb90d4..47eac669 100755 --- a/plugins/dfinput/xkb.c +++ b/plugins/dfinput/xkb.c @@ -46,7 +46,7 @@ void InitKeyboard() { resumeScrSaver = 0; if (g.cfg.PreventScrSaver) { char buf[64]; - snprintf(buf, 64, "xdg-screensaver suspend 0x%x > /dev/null 2>&1", window); + snprintf(buf, sizeof(buf), "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); @@ -79,7 +79,7 @@ void DestroyKeyboard() { 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); + snprintf(buf, sizeof(buf), "xdg-screensaver resume 0x%x", window); FILE *phandle = popen(buf, "r"); pclose(phandle); } |
