[gnome-games/wip/abhinavsingh/gamepad-config2] temp patch
- From: Abhinav Singh <abhinavsingh src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games/wip/abhinavsingh/gamepad-config2] temp patch
- Date: Mon, 17 Jul 2017 17:32:32 +0000 (UTC)
commit 1a8d40081951657e5549cd77614ddf2812ba1715
Author: theawless <theawless gmail com>
Date: Mon Jul 17 23:02:07 2017 +0530
temp patch
data/ui/gamepad-mapper.ui | 73 ++++++++---------
src/Makefile.am | 2 +-
src/gamepad/gamepad-mapping-builder.vala | 78 ++++++++++++------
src/gamepad/standard-gamepad-inputs.c | 17 ++++
src/gamepad/standard-gamepad-inputs.vala | 28 ------
src/ui/gamepad-mapper.vala | 136 +++++++++++++++++------------
src/ui/gamepad-view-configuration.vala | 12 +++
src/ui/gamepad-view.vala | 53 ++++++------
src/ui/preferences-page-input.vala | 4 +
src/ui/preferences-page.vala | 1 +
src/ui/preferences-window.vala | 1 +
11 files changed, 228 insertions(+), 177 deletions(-)
---
diff --git a/data/ui/gamepad-mapper.ui b/data/ui/gamepad-mapper.ui
index 673f8c6..0efc6a9 100644
--- a/data/ui/gamepad-mapper.ui
+++ b/data/ui/gamepad-mapper.ui
@@ -5,26 +5,8 @@
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="spacing">6</property>
- <property name="margin-top">12</property>
- <property name="margin-bottom">12</property>
- <property name="margin-start">48</property>
- <property name="margin-end">48</property>
<child>
- <object class="GtkLabel" id="info_message">
- <property name="visible">True</property>
- </object>
- </child>
- <child>
- <object class="GtkLabel" id="error_message">
- <property name="visible">True</property>
- <attributes>
- <attribute name="foreground" value="red"/>
- </attributes>
- </object>
- </child>
- <child>
- <object class="GamesGamepadView" id="gamepad_view">
- <property name="halign">center</property>
+ <object class="GtkBox" id="gamepad_view_holder">
<property name="visible">True</property>
<property name="halign">fill</property>
<property name="valign">fill</property>
@@ -32,6 +14,39 @@
<property name="vexpand">True</property>
</object>
</child>
+ <child>
+ <object class="GtkActionBar" id="action_bar">
+ <property name="visible">True</property>
+ <child>
+ <object class="GtkButton" id="reset_button">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Reset</property>
+ <signal name="clicked" handler="on_reset_clicked"/>
+ <style>
+ <class name="destructive-action"/>
+ </style>
+ </object>
+ <packing>
+ <property name="pack-type">end</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="skip_button">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Skip</property>
+ <signal name="clicked" handler="on_skip_clicked"/>
+ </object>
+ <packing>
+ <property name="pack-type">start</property>
+ </packing>
+ </child>
+ <child type="center">
+ <object class="GtkLabel" id="subtitle">
+ <property name="visible">True</property>
+ </object>
+ </child>
+ </object>
+ </child>
</template>
<object class="GtkBox" id="header_content">
<property name="orientation">horizontal</property>
@@ -62,16 +77,6 @@
<property name="pack-type">start</property>
</packing>
</child>
- <child>
- <object class="GtkButton" id="reset_button">
- <property name="visible">True</property>
- <property name="label" translatable="yes">Reset</property>
- <signal name="clicked" handler="on_reset_clicked"/>
- </object>
- <packing>
- <property name="pack-type">start</property>
- </packing>
- </child>
<child type="center">
<object class="GtkLabel" id="title">
<property name="visible">True</property>
@@ -91,15 +96,5 @@
<property name="pack-type">end</property>
</packing>
</child>
- <child>
- <object class="GtkButton" id="skip_button">
- <property name="visible">True</property>
- <property name="label" translatable="yes">Skip</property>
- <signal name="clicked" handler="on_skip_clicked"/>
- </object>
- <packing>
- <property name="pack-type">end</property>
- </packing>
- </child>
</object>
</interface>
diff --git a/src/Makefile.am b/src/Makefile.am
index 98f6923..a8ceb49 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -90,7 +90,6 @@ gnome_games_SOURCES = \
gamepad/gamepad-monitor.c \
gamepad/raw-gamepad.c \
gamepad/raw-gamepad-monitor.c \
- gamepad/standard-gamepad-inputs.vala \
\
generic/generic-game.vala \
generic/generic-game-uri-adapter.vala \
@@ -131,6 +130,7 @@ gnome_games_SOURCES = \
ui/error-info-bar.vala \
ui/gamepad-mapper.vala \
ui/gamepad-view.vala \
+ ui/gamepad-view-configuration.vala \
ui/game-icon-view.vala \
ui/game-thumbnail.vala \
ui/media-selector.vala \
diff --git a/src/gamepad/gamepad-mapping-builder.vala b/src/gamepad/gamepad-mapping-builder.vala
index d3f53e9..ee8678f 100644
--- a/src/gamepad/gamepad-mapping-builder.vala
+++ b/src/gamepad/gamepad-mapping-builder.vala
@@ -1,26 +1,53 @@
// This file is part of GNOME Games. License: GPL-3.0+.
private class Games.GamepadMappingBuilder : Object {
- private string[] sources = { "a", "b", "x", "y",
- "leftstick", "rightstick",
- "leftshoulder", "rightshoulder", "lefttrigger", "righttrigger",
- "dpup", "dpleft", "dpdown", "dpright",
- "back", "guide", "start",
- "leftx", "rightx", "lefty", "righty" };
- private string[] destinations;
+ private struct GamepadInputSource {
+ GamepadInput input;
+ string source;
+ }
+
+ private const GamepadInputSource[] input_sources = {
+ { { EventCode.EV_ABS, EventCode.ABS_X }, "leftx" },
+ { { EventCode.EV_ABS, EventCode.ABS_Y }, "lefty" },
+ { { EventCode.EV_ABS, EventCode.ABS_RX }, "rightx" },
+ { { EventCode.EV_ABS, EventCode.ABS_RY }, "righty" },
+ { { EventCode.EV_KEY, EventCode.BTN_A }, "a" },
+ { { EventCode.EV_KEY, EventCode.BTN_B }, "b" },
+ { { EventCode.EV_KEY, EventCode.BTN_DPAD_DOWN }, "dpdown" },
+ { { EventCode.EV_KEY, EventCode.BTN_DPAD_LEFT }, "dpleft" },
+ { { EventCode.EV_KEY, EventCode.BTN_DPAD_RIGHT }, "dpright" },
+ { { EventCode.EV_KEY, EventCode.BTN_DPAD_UP }, "dpup" },
+ { { EventCode.EV_KEY, EventCode.BTN_MODE }, "guide" },
+ { { EventCode.EV_KEY, EventCode.BTN_SELECT }, "back" },
+ { { EventCode.EV_KEY, EventCode.BTN_TL }, "leftshoulder" },
+ { { EventCode.EV_KEY, EventCode.BTN_TR }, "rightshoulder" },
+ { { EventCode.EV_KEY, EventCode.BTN_START }, "start" },
+ { { EventCode.EV_KEY, EventCode.BTN_THUMBL }, "leftstick" },
+ { { EventCode.EV_KEY, EventCode.BTN_THUMBR }, "rightstick" },
+ { { EventCode.EV_KEY, EventCode.BTN_TL2 }, "lefttrigger" },
+ { { EventCode.EV_KEY, EventCode.BTN_TR2 }, "righttrigger" },
+ { { EventCode.EV_KEY, EventCode.BTN_Y }, "x" },
+ { { EventCode.EV_KEY, EventCode.BTN_X }, "y" },
+ };
+
+ private struct GamepadInputMapping {
+ string source_string;
+ string destination_string;
+ }
+
+ private GamepadInputMapping[] mappings;
private GamepadDPad[] dpads;
construct {
- destinations = new string[sources.length];
+ mappings = new GamepadInputMapping[]{};
dpads = new GamepadDPad[]{};
}
public string build_sdl_string () {
var sdl_string = "platform:Linux" + ",";
- for (var i = 0; i < destinations.length; ++i)
- if (destinations[i] != null)
- sdl_string += sources[i] + ":" + destinations[i] + ",";
+ foreach (var mapping in mappings)
+ sdl_string += mapping.source_string + ":" + mapping.destination_string + ",";
return sdl_string;
}
@@ -56,33 +83,34 @@ private class Games.GamepadMappingBuilder : Object {
}
private bool add_destination (string destination_string, GamepadInput source) {
- if (index_in_destinations (destination_string) != -1)
+ if (is_mapping_present (destination_string))
return false;
- var i = index_in_inputs (source);
- if (i == -1) {
+ var source_string = get_mapping_source (source);
+ if (source_string == null) {
warning ("Invalid input");
return false;
}
- destinations[i] = destination_string;
+ GamepadInputMapping mapping = {source_string, destination_string};
+ mappings += mapping;
return true;
}
- private int index_in_destinations (string destination_string) {
- for (var i = 0; i < destinations.length ; ++i)
- if (destination_string == destinations[i])
- return i;
+ private bool is_mapping_present (string destination_string) {
+ foreach (var mapping in mappings)
+ if (destination_string == mapping.destination_string)
+ return true;
- return -1;
+ return false;
}
- private int index_in_inputs (GamepadInput input) {
- for (var i = 0; i < STANDARD_GAMEPAD_INPUTS.length ; ++i)
- if (input == STANDARD_GAMEPAD_INPUTS[i])
- return i;
+ private string? get_mapping_source (GamepadInput input) {
+ foreach (var input_source in input_sources)
+ if (input == input_source.input)
+ return input_source.source;
- return -1;
+ return null;
}
}
diff --git a/src/gamepad/standard-gamepad-inputs.c b/src/gamepad/standard-gamepad-inputs.c
new file mode 100644
index 0000000..df46f48
--- /dev/null
+++ b/src/gamepad/standard-gamepad-inputs.c
@@ -0,0 +1,17 @@
+/* standard-gamepad-inputs.c generated by valac 0.37.1.4-3591e, the Vala compiler
+ * generated from standard-gamepad-inputs.vala, do not modify */
+
+/* This file is part of GNOME Games. License: GPL-3.0+.*/
+
+#include <glib.h>
+#include <glib-object.h>
+#include <gamepad-input.h>
+#include <linux/input-event-codes.h>
+
+
+
+
+
+const GamesGamepadInput GAMES_STANDARD_GAMEPAD_INPUTS[21] = {{EV_KEY, BTN_A}, {EV_KEY, BTN_B}, {EV_KEY,
BTN_X}, {EV_KEY, BTN_Y}, {EV_KEY, BTN_THUMBL}, {EV_KEY, BTN_THUMBR}, {EV_KEY, BTN_TL}, {EV_KEY, BTN_TR},
{EV_KEY, BTN_TL2}, {EV_KEY, BTN_TR2}, {EV_KEY, BTN_DPAD_UP}, {EV_KEY, BTN_DPAD_LEFT}, {EV_KEY,
BTN_DPAD_DOWN}, {EV_KEY, BTN_DPAD_RIGHT}, {EV_KEY, BTN_SELECT}, {EV_KEY, BTN_MODE}, {EV_KEY, BTN_START},
{EV_ABS, ABS_X}, {EV_ABS, ABS_RX}, {EV_ABS, ABS_Y}, {EV_ABS, ABS_RY}};
+
+
diff --git a/src/ui/gamepad-mapper.vala b/src/ui/gamepad-mapper.vala
index ef58916..fb60db4 100644
--- a/src/ui/gamepad-mapper.vala
+++ b/src/ui/gamepad-mapper.vala
@@ -13,9 +13,7 @@ private class Games.GamepadMapper : Gtk.Box {
private State? _state;
private State? state {
set {
- error_message.label = "";
- if (value == _state)
- return;
+ gamepad_view.reset ();
switch (value) {
case State.BEGIN:
@@ -25,6 +23,8 @@ private class Games.GamepadMapper : Gtk.Box {
break;
case State.CONFIGURE:
+ gamepad_view.highlight (input, true);
+
break;
case State.FINISH:
skip_button.set_sensitive (false);
@@ -45,21 +45,21 @@ private class Games.GamepadMapper : Gtk.Box {
set {
_input = value;
if (_input == null) {
- info_message.label = "";
+ subtitle.label = "";
return;
}
switch (input.type) {
case EventCode.EV_KEY:
- info_message.label = _("Press suitable button on your gamepad");
+ subtitle.label = _("Press suitable button on your gamepad");
break;
case EventCode.EV_ABS:
if (input.code == EventCode.ABS_X || input.code == EventCode.ABS_RX)
- info_message.label = _("Move suitable axis left/right on your
gamepad");
+ subtitle.label = _("Move suitable axis left/right on your gamepad");
else if (input.code == EventCode.ABS_Y || input.code == EventCode.ABS_RY)
- info_message.label = _("Move suitable axis up/down on your gamepad");
+ subtitle.label = _("Move suitable axis up/down on your gamepad");
break;
default:
@@ -67,15 +67,10 @@ private class Games.GamepadMapper : Gtk.Box {
}
}
get { return _input; }
-
}
[GtkChild]
- private Gtk.Label info_message;
- [GtkChild]
- private Gtk.Label error_message;
- [GtkChild]
- private GamepadView gamepad_view;
+ private Gtk.Box gamepad_view_holder;
[GtkChild]
public Gtk.Box header_content;
[GtkChild]
@@ -84,36 +79,76 @@ private class Games.GamepadMapper : Gtk.Box {
private Gtk.Button skip_button;
[GtkChild]
private Gtk.Label title;
+ [GtkChild]
+ private Gtk.Label subtitle;
+
+ private const GamepadInput[] STANDARD_GAMEPAD_INPUTS = {
+ { EventCode.EV_KEY, EventCode.BTN_A },
+ { EventCode.EV_KEY, EventCode.BTN_B },
+ { EventCode.EV_KEY, EventCode.BTN_X },
+ { EventCode.EV_KEY, EventCode.BTN_Y },
+ { EventCode.EV_KEY, EventCode.BTN_THUMBL },
+ { EventCode.EV_KEY, EventCode.BTN_THUMBR },
+ { EventCode.EV_KEY, EventCode.BTN_TL },
+ { EventCode.EV_KEY, EventCode.BTN_TR },
+ { EventCode.EV_KEY, EventCode.BTN_TL2 },
+ { EventCode.EV_KEY, EventCode.BTN_TR2 },
+ { EventCode.EV_KEY, EventCode.BTN_DPAD_UP },
+ { EventCode.EV_KEY, EventCode.BTN_DPAD_LEFT },
+ { EventCode.EV_KEY, EventCode.BTN_DPAD_DOWN },
+ { EventCode.EV_KEY, EventCode.BTN_DPAD_RIGHT },
+ { EventCode.EV_KEY, EventCode.BTN_SELECT },
+ { EventCode.EV_KEY, EventCode.BTN_MODE },
+ { EventCode.EV_KEY, EventCode.BTN_START },
+ { EventCode.EV_ABS, EventCode.ABS_X },
+ { EventCode.EV_ABS, EventCode.ABS_RX },
+ { EventCode.EV_ABS, EventCode.ABS_Y },
+ { EventCode.EV_ABS, EventCode.ABS_RY },
+ };
+
+ private const GamepadInputPath[] STANDARD_GAMEPAD_INPUT_PATHS = {
+ { { EventCode.EV_ABS, EventCode.ABS_X }, "leftx" },
+ { { EventCode.EV_ABS, EventCode.ABS_Y }, "lefty" },
+ { { EventCode.EV_ABS, EventCode.ABS_RX }, "rightx" },
+ { { EventCode.EV_ABS, EventCode.ABS_RY }, "righty" },
+ { { EventCode.EV_KEY, EventCode.BTN_A }, "a" },
+ { { EventCode.EV_KEY, EventCode.BTN_B }, "b" },
+ { { EventCode.EV_KEY, EventCode.BTN_DPAD_DOWN }, "dpdown" },
+ { { EventCode.EV_KEY, EventCode.BTN_DPAD_LEFT }, "dpleft" },
+ { { EventCode.EV_KEY, EventCode.BTN_DPAD_RIGHT }, "dpright" },
+ { { EventCode.EV_KEY, EventCode.BTN_DPAD_UP }, "dpup" },
+ { { EventCode.EV_KEY, EventCode.BTN_MODE }, "guide" },
+ { { EventCode.EV_KEY, EventCode.BTN_SELECT }, "back" },
+ { { EventCode.EV_KEY, EventCode.BTN_TL }, "leftshoulder" },
+ { { EventCode.EV_KEY, EventCode.BTN_TR }, "rightshoulder" },
+ { { EventCode.EV_KEY, EventCode.BTN_START }, "start" },
+ { { EventCode.EV_KEY, EventCode.BTN_THUMBL }, "leftstick" },
+ { { EventCode.EV_KEY, EventCode.BTN_THUMBR }, "rightstick" },
+ { { EventCode.EV_KEY, EventCode.BTN_TL2 }, "lefttrigger" },
+ { { EventCode.EV_KEY, EventCode.BTN_TR2 }, "righttrigger" },
+ { { EventCode.EV_KEY, EventCode.BTN_Y }, "x" },
+ { { EventCode.EV_KEY, EventCode.BTN_X }, "y" },
+ };
+
+ private const GamepadViewConfiguration STANDARD_GAMEPAD_VIEW_CONFIGURATION = {
+ "resource:///org/gnome/Games/gamepads/standard-gamepad.svg", STANDARD_GAMEPAD_INPUT_PATHS
+ };
private Gamepad gamepad;
+ private GamepadView gamepad_view;
private GamepadMappingBuilder mapping_builder;
private ulong gamepad_event_handler_id;
- private uint error_message_hider_id;
-
- construct {
- error_message.notify["label"].connect (() => {
- if (error_message.label != "")
- error_message_hide ();
- });
- }
+ private uint current_input_index;
public GamepadMapper (Gamepad gamepad) {
this.gamepad = gamepad;
+ gamepad_view = new GamepadView (STANDARD_GAMEPAD_VIEW_CONFIGURATION);
+ gamepad_view_holder.pack_start (gamepad_view);
+ gamepad_view.show ();
+
mapping_builder = new GamepadMappingBuilder ();
state = State.BEGIN;
- }
-
- private void error_message_hide () {
- if (error_message_hider_id > 0) {
- GLib.Source.remove (error_message_hider_id);
- }
- error_message_hider_id = GLib.Timeout.add (2000, () => {
- error_message_hider_id = 0;
- if (error_message != null)
- error_message.label = "";
-
- return false;
- });
+ current_input_index = 0;
}
public void start () {
@@ -168,39 +203,28 @@ private class Games.GamepadMapper : Gtk.Box {
}
private void on_button_event (EventGamepadButton event) {
- if (input.type == EventCode.EV_ABS) {
- error_message.label = _("This combination is not valid");
-
+ if (input.type == EventCode.EV_ABS)
return;
- }
var success = mapping_builder.set_button_mapping (event.gamepad_button.hardware_index,
input);
- if (!success) {
- error_message.label = _("This button is already in use");
-
+ if (!success)
return;
- }
next_input ();
}
private void on_axis_event (EventGamepadAxis event) {
- if (input.type == EventCode.EV_KEY) {
- error_message.label = _("This combination is not valid");
-
+ if (input.type == EventCode.EV_KEY)
return;
- }
+
if (-0.8 < event.gamepad_axis.value && event.gamepad_axis.value < 0.8)
return;
var success = mapping_builder.set_axis_mapping (event.gamepad_axis.hardware_index,
input);
- if (!success) {
- error_message.label = _("This axis is already in use");
-
+ if (!success)
return;
- }
next_input ();
}
@@ -213,23 +237,23 @@ private class Games.GamepadMapper : Gtk.Box {
event.gamepad_hat.value,
event.gamepad_hat.axis,
input);
- if (!success) {
- error_message.label = _("This hat is already in use");
-
+ if (!success)
return;
- }
next_input ();
}
private void next_input () {
- input = gamepad_view.highlight_next ();
- if (input == null) {
+ if (state == State.FINISH)
+ return;
+ if (current_input_index >= STANDARD_GAMEPAD_INPUTS.length) {
+ input = null;
state = State.FINISH;
return;
}
+ input = STANDARD_GAMEPAD_INPUTS[current_input_index++];
state = State.CONFIGURE;
}
diff --git a/src/ui/gamepad-view-configuration.vala b/src/ui/gamepad-view-configuration.vala
new file mode 100644
index 0000000..84bff1c
--- /dev/null
+++ b/src/ui/gamepad-view-configuration.vala
@@ -0,0 +1,12 @@
+// This file is part of GNOME Games. License: GPL-3.0+.
+
+private struct Games.GamepadInputPath {
+ GamepadInput input;
+ string path;
+}
+
+private struct Games.GamepadViewConfiguration {
+ string svg_path;
+ GamepadInputPath[] input_paths;
+}
+
diff --git a/src/ui/gamepad-view.vala b/src/ui/gamepad-view.vala
index a06f6cb..1399186 100644
--- a/src/ui/gamepad-view.vala
+++ b/src/ui/gamepad-view.vala
@@ -1,41 +1,38 @@
// This file is part of GNOME Games. License: GPL-3.0+.
private class Games.GamepadView : Gtk.DrawingArea {
- private const string STANDARD_GAMEPAD_SVG_PATH =
"resource:///org/gnome/Games/gamepads/standard-gamepad.svg";
private const Gtk.StateFlags DEFAULT_STATE = Gtk.StateFlags.NORMAL;
private const Gtk.StateFlags HIGHLIGHT_STATE = Gtk.StateFlags.LINK;
private Rsvg.Handle handle;
- private string[] highlight_paths = { "a", "b", "x", "y",
- "leftstick", "rightstick",
- "leftshoulder", "rightshoulder", "lefttrigger", "righttrigger",
- "dpup", "dpleft", "dpdown", "dpright",
- "back", "guide", "start",
- "leftx", "rightx", "lefty", "righty" };
- private GamepadInput[] inputs;
- private int current_input_index;
-
- construct {
+ private GamepadViewConfiguration configuration;
+ private bool[] input_highlights;
+
+ public GamepadView (GamepadViewConfiguration configuration) {
+ this.configuration = configuration;
+ input_highlights = new bool[configuration.input_paths.length];
try {
- handle = new Rsvg.Handle.from_file (STANDARD_GAMEPAD_SVG_PATH);
+ handle = new Rsvg.Handle.from_file (configuration.svg_path);
set_size_request (handle.width, handle.height);
}
catch (Error e) {
warning (e.message);
}
-
- inputs = STANDARD_GAMEPAD_INPUTS;
- current_input_index = -1;
}
- public GamepadInput? highlight_next () {
- current_input_index += 1;
+ public void reset () {
+ for (var i = 0; i < input_highlights.length; ++i)
+ input_highlights[i] = false;
+
queue_draw ();
+ }
- if (current_input_index >= inputs.length)
- return null;
+ public void highlight (GamepadInput input, bool highlight) {
+ for (var i = 0; i < configuration.input_paths.length; ++i)
+ if (configuration.input_paths[i].input == input)
+ input_highlights[i] = highlight;
- return inputs[current_input_index];
+ queue_draw ();
}
public override bool draw (Cairo.Context context) {
@@ -43,11 +40,7 @@ private class Games.GamepadView : Gtk.DrawingArea {
calculate_image_dimensions (out x, out y, out scale);
color_gamepad (context, x, y, scale);
- if (!(0 <= current_input_index && current_input_index < inputs.length))
- return false;
-
- var highlight_path = "#" + highlight_paths[current_input_index];
- highlight_gamepad (context, highlight_path, x, y, scale);
+ highlight_gamepad (context, x, y, scale);
return false;
}
@@ -57,6 +50,7 @@ private class Games.GamepadView : Gtk.DrawingArea {
var color_suface = color_context.get_target ();
color_context.translate (x, y);
color_context.scale (scale, scale);
+
handle.render_cairo (color_context);
var color = get_style_context ().get_color (DEFAULT_STATE);
@@ -64,12 +58,15 @@ private class Games.GamepadView : Gtk.DrawingArea {
gamepad_context.mask_surface (color_suface, 0, 0);
}
- private void highlight_gamepad (Cairo.Context gamepad_context, string highlight_path, double x,
double y, double scale) {
+ private void highlight_gamepad (Cairo.Context gamepad_context, double x, double y, double scale) {
var highlight_context = create_similar_context (gamepad_context);
var highlight_suface = highlight_context.get_target ();
highlight_context.translate (x, y);
highlight_context.scale (scale, scale);
- handle.render_cairo_sub (highlight_context, highlight_path);
+
+ for (var i = 0; i < configuration.input_paths.length; ++i)
+ if (input_highlights[i])
+ handle.render_cairo_sub (highlight_context, "#" +
configuration.input_paths[i].path);
var color = get_style_context ().get_color (HIGHLIGHT_STATE);
gamepad_context.set_source_rgba (color.red, color.green, color.blue, color.alpha);
@@ -88,7 +85,7 @@ private class Games.GamepadView : Gtk.DrawingArea {
double w = get_allocated_width ();
double h = get_allocated_height ();
double allocation_ratio = w / h;
- double image_ratio = handle.width / handle.height;
+ double image_ratio = (double) handle.width / handle.height;
if (allocation_ratio > image_ratio) {
scale = h / handle.height;
diff --git a/src/ui/preferences-page-input.vala b/src/ui/preferences-page-input.vala
index 8182d28..a1d6ac2 100644
--- a/src/ui/preferences-page-input.vala
+++ b/src/ui/preferences-page-input.vala
@@ -27,6 +27,10 @@ private class Games.PreferencesPageInput: Gtk.Stack, PreferencesPage {
build_gamepad_list ();
}
+ public void visible_page_changed () {
+ on_mapper_back ();
+ }
+
private void rebuild_gamepad_list () {
clear_gamepad_list ();
build_gamepad_list ();
diff --git a/src/ui/preferences-page.vala b/src/ui/preferences-page.vala
index c010998..ed273d3 100644
--- a/src/ui/preferences-page.vala
+++ b/src/ui/preferences-page.vala
@@ -2,4 +2,5 @@
private interface Games.PreferencesPage: Gtk.Widget {
public abstract Gtk.Widget header_content { get; protected set; }
+ public virtual void visible_page_changed () {}
}
diff --git a/src/ui/preferences-window.vala b/src/ui/preferences-window.vala
index f925ea8..8de360d 100644
--- a/src/ui/preferences-window.vala
+++ b/src/ui/preferences-window.vala
@@ -11,6 +11,7 @@ private class Games.PreferencesWindow : Gtk.Window {
stack.foreach ((child) => {
var page = (PreferencesPage) child;
page.notify["header-content"].connect (update_right_header);
+ stack.notify["visible-child-name"].connect (page.visible_page_changed);
});
stack.notify["visible-child-name"].connect (update_right_header);
update_right_header ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]