[yast-commit] r66282 - /branches/tmp/lslezak/sound/sound/src/joy_dialog.ycp
Author: lslezak Date: Thu Oct 6 12:25:47 2011 New Revision: 66282 URL: http://svn.opensuse.org/viewcvs/yast?rev=66282&view=rev Log: added support for configured but not detected joysticks (i.e. disconnected or with a wrong driver) Modified: branches/tmp/lslezak/sound/sound/src/joy_dialog.ycp 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=66282&r1=66281&r2=66282&view=diff ============================================================================== --- branches/tmp/lslezak/sound/sound/src/joy_dialog.ycp (original) +++ branches/tmp/lslezak/sound/sound/src/joy_dialog.ycp Thu Oct 6 12:25:47 2011 @@ -246,10 +246,33 @@ return s; } + define string broken_id(integer index) + { + return sformat("broken_%1", index); + } + + define boolean is_broken(string id) + { + return regexpmatch(id, "broken_[0-9]+"); + } + + define integer broken_index(string id) + { + string num = regexpsub(id, "broken_([0-9]+)", "\\1"); + + if (num == nil) + { + return nil; + } + + return tointeger(num); + } + define list<map<string,any> > joystick_table() { list<map<string,any> > content = []; list<map> soundcards = (list<map>)SCR::Read(.probe.sound); + list<integer> found_joysticks = []; foreach(map js, Joystick::Detected(), { @@ -282,9 +305,25 @@ bus = sformat("%1 (%2)", bus, card["model"]:""); } - map j_config = find(map j, (list<map>)Joystick::joystick, {return j["attached_to"]:"" == unique_key;}); - if (j_config != nil) + integer i = 0; + integer joy_index = nil; + + while(i < 4) { + map jconf = Joystick::joystick[i]:$[]; + + if (jconf["attached_to"]:"" == unique_key) + { + joy_index = i; + break; + } + + i = i + 1; + } + + if (joy_index != nil) + { + map j_config = find(map j, (list<map>)Joystick::joystick, {return j["attached_to"]:"" == unique_key;}); string config_model = j_config["model"]:""; if (config_model != nil && config_model != "") @@ -293,6 +332,8 @@ model = sformat("%1 (%2)", model, config_model); } + + found_joysticks = add(found_joysticks, joy_index); } } @@ -305,6 +346,45 @@ content = add(content, j); }); + y2milestone("Found joysticks at indices: %1", found_joysticks); + + integer i = 0; + // check non-working joystick configurations + foreach(map js, (list<map>)Joystick::joystick, { + if (!contains(found_joysticks, i) && js["JOYSTICK_MODULE"]:"" != "") + { + y2milestone("Found inactive joystick configuration at index %1: %2", i, js); + string model = js["model"]:_("Unknown joystick model"); + string unique_key = js["attached_to"]:""; + string bus = "Gameport"; + + map card = find(map c, soundcards, {return c["unique_key"]:"" == unique_key;}); + + if (card != nil) + { + // joystick details, %1 is the sound card name to which is the joystick connected + bus = sformat("%1 (%2)", bus, card["model"]:""); + } + + map<string,any> j = $[ + "id" : broken_id(i), + // the joystick device was not found (the joystick is probably disconnected) + "table_descr" : [ model, _("<not found>"), bus ], + // add red warning about invalid configuration to the model name (%1) + "rich_descr" : WizardHW::CreateRichTextDescription(sformat(_("%1 - <font color=\"red\">Invalid configuration<font>"), model), [ + // help text + _("The configuration is not active - either the joystick is not connected or a wrong driver is used"), + // help text + _("Press <b>Edit</b> to change the joystick driver or <b>Delete</b> to remove the configuration") + ]) + ]; + + content = add(content, j); + } + + i = i + 1; + }); + return content; } @@ -679,11 +759,22 @@ } else { - string uid = find_joystick(device)["parent_unique_key"]:""; - integer num = find_joystick_number(uid); - list<map> soundcards = (list<map>)SCR::Read(.probe.sound); - map card = find(map c, soundcards, {return c["unique_key"]:"" == uid;}); + integer num = nil; + string key = ""; + if (is_broken(device)) + { + key = Joystick::joystick[num, "attached_to"]:""; + num = broken_index(device); + } + else + { + key = find_joystick(device)["parent_unique_key"]:""; + num = find_joystick_number(key); + } + + list<map> soundcards = (list<map>)SCR::Read(.probe.sound); + map card = find(map c, soundcards, {return c["unique_key"]:"" == key;}); symbol ui = joy_dialog(num, `ok, card); if (ui == `next || ui == `finish) @@ -705,7 +796,9 @@ } else { - integer num = find_joystick_number(find_joystick(device)["parent_unique_key"]:""); + integer num = is_broken(device) ? broken_index(device) + : find_joystick_number(find_joystick(device)["parent_unique_key"]:""); + y2milestone("Deleting joystick %1 (index %2)", device, num); // modify joystick config @@ -721,7 +814,15 @@ } else if (ret == `test) { - test_joystick(device); + if (is_broken(device)) + { + // error popup + Popup::Error(_("The selected joystick configuration is not active.\n\nThe joystick cannot be tested.")); + } + else + { + test_joystick(device); + } } } -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org
participants (1)
-
lslezak@svn2.opensuse.org