Author: lslezak
Date: Mon Oct 3 17:51:13 2011
New Revision: 66209
URL: http://svn.opensuse.org/viewcvs/yast?rev=66209&view=rev
Log:
joystick - store the sound card to which it is connected,
reload drivers and refresh the table after changes,
connect detected and configured joysticks
Modified:
branches/tmp/lslezak/sound/sound/src/Joystick.ycp
branches/tmp/lslezak/sound/sound/src/joy_dialog.ycp
branches/tmp/lslezak/sound/sound/src/joystick.ycp
branches/tmp/lslezak/sound/sound/src/volume.ycp
Modified: branches/tmp/lslezak/sound/sound/src/Joystick.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/lslezak/sound/sound/src/Joystick.ycp?rev=66209&r1=66208&r2=66209&view=diff
==============================================================================
--- branches/tmp/lslezak/sound/sound/src/Joystick.ycp (original)
+++ branches/tmp/lslezak/sound/sound/src/Joystick.ycp Mon Oct 3 17:51:13 2011
@@ -46,6 +46,11 @@
return detected_joysticks;
}
+ global void Detect()
+ {
+ detected_joysticks = (list<map>)SCR::Read(.probe.joystick);
+ }
+
/**
* Get list of all required joystick kernel modules
* @return list list of modules
@@ -77,6 +82,26 @@
return ret;
}
+ string format_model_line(string model, string attached_to)
+ {
+ return sformat("# Model: %1, Attached to: %2\n", model, attached_to);
+ }
+
+ list<string> parse_model_line(string line)
+ {
+ string regexp = "^#[ \t]*Model: (.*),[ \t]*Attached to:[ \t]*(.*)$";
+
+ string model = regexpsub(line, regexp, "\\1");
+ string attached_to = regexpsub(line, regexp, "\\2");
+
+ if (model == nil) model = "";
+ if (attached_to == nil) attached_to = "";
+
+ y2milestone("Parsed model line: %1 -> model: %2, attached_to: %3", line, model, attached_to);
+
+ return [model, attached_to];
+ }
+
/**
* Read all joystick settings from the SCR
* @param abort A block that can be called by Read to find
@@ -114,6 +139,7 @@
// read model comment
string model = (string) SCR::Read(topath(
sformat(".sysconfig.joystick.JOYSTICK_MODULE_%1.comment",pos)));
+ string attached_to = "";
y2debug("Read model comment: %1", model);
@@ -151,28 +177,14 @@
}
else
{
- // remove comment char
- if (substring(model, 0, 1) == "#")
- {
- if (size(model) > 1)
- {
- model = substring(model, 1);
- }
- else
- {
- model = "";
- }
- }
+ list<string> info = parse_model_line(model);
- // remove new line char
- if (size(model) > 1 &&
- substring(model, size(model) - 1, 1) == "\n")
- {
- model = substring(model, 0, size(model) - 1);
- }
+ model = info[0]:"";
+ attached_to = info[1]:"";
}
- j = add(j, "model", model);
+ j["model"] = model;
+ j["attached_to"] = attached_to;
joystick = add(joystick, j);
@@ -181,7 +193,7 @@
joystick_backup = joystick;
- detected_joysticks = (list<map>)SCR::Read(.probe.joystick);
+ Detect();
return true;
}
@@ -224,13 +236,14 @@
// write model comment
string model = j["model"]:"";
+ string attached_to = j["attached_to"]:"";
// add comment before first model
if (pos == 0)
{
if (size(model) > 0)
{
- model = module_comment + "\n#" + model + "\n";
+ model = module_comment + "\n" + format_model_line(model, attached_to);
}
else
{
@@ -241,7 +254,7 @@
{
if (size(model) > 0)
{
- model = "#" + model + "\n";
+ model = format_model_line(model, attached_to);
}
}
Modified: branches/tmp/lslezak/sound/sound/src/joy_dialog.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/lslezak/sound/sound/src/joy_dialog.ycp?rev=66209&r1=66208&r2=66209&view=diff
==============================================================================
--- branches/tmp/lslezak/sound/sound/src/joy_dialog.ycp (original)
+++ branches/tmp/lslezak/sound/sound/src/joy_dialog.ycp Mon Oct 3 17:51:13 2011
@@ -25,6 +25,7 @@
include "sound/joysticks.ycp";
include "sound/ui.ycp";
include "sound/volume_routines.ycp";
+ include "sound/routines.ycp";
list joylist = [];
@@ -385,35 +386,46 @@
return true;
}
+ integer find_sound_card_id(map sound_card)
+ {
+ integer i = 0;
+ integer ret = nil;
+
+ foreach(map card, Sound::modules_conf, {
+ if (card["unique_key"]:"" == sound_card["unique_key"]:"")
+ {
+ ret = i;
+ }
+
+ i = i + 1;
+ });
+
+ return ret;
+ }
+
/**
* Joystick configuration dialog.
* Configuration of joystick attached to specified sound card.
- * @param card_id Sound card card_id
+ * @param joy_id Joystick index (in the sysconfig file)
* @param button Label for `next button: `finish, `ok or `next
* @return symbol Id of pressed button in the dialog
*/
- define symbol joy_dialog (integer card_id, symbol button) ``{
+ define symbol joy_dialog (integer joy_id, symbol button, map sound_card) ``{
// item in joystick types
string nonejoy = _("No joystick");
- if (card_id == nil)
+ if (joy_id == nil)
{
return `back;
}
- list jcards = Sound::GetSoundCardListWithJoy();
-
// find card name
- string cardname = "";
- foreach (map card, (list