[yast-commit] r66210 - in /branches/tmp/lslezak/sound/sound/src: joy_dialog.ycp joystick.ycp
Author: lslezak Date: Mon Oct 3 18:03:28 2011 New Revision: 66210 URL: http://svn.opensuse.org/viewcvs/yast?rev=66210&view=rev Log: clean up - removed obsoleted code Modified: branches/tmp/lslezak/sound/sound/src/joy_dialog.ycp branches/tmp/lslezak/sound/sound/src/joystick.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=66210&r1=66209&r2=66210&view=diff ============================================================================== --- branches/tmp/lslezak/sound/sound/src/joy_dialog.ycp (original) +++ branches/tmp/lslezak/sound/sound/src/joy_dialog.ycp Mon Oct 3 18:03:28 2011 @@ -65,326 +65,6 @@ return false; } -/** - * Dialog for joystick testing. - * @param card_id Sound card card_id - * @param joymodidx model id - * @param joymod joystick module - * @return boolean false when Abort was pressed or some problems occurred - */ -define boolean joy_test_popup (integer card_id, integer joymodidx, - string joymod) ``{ - - any ret = nil; - UI::OpenDialog(`opt(`decorated), `HBox(`HSpacing(1.5), - `VBox( - `VSpacing(1), - // Wait text label - `Label(_("Initializing joystick -- please wait...")), - `VSpacing(1), - `PushButton(`id(`done), `opt(`default), Label::AbortButton()), - `VSpacing(1) - ), - `HSpacing(1.5) - )); - - // store old joystick configuration: - list current_conf = (list) eval (Joystick::joystick); - - // if new joystick type was selected: - boolean testing_new = false; - - string modname = Sound::modules_conf [card_id, "module"]:""; - map joy_entry = Sound::GetJoystickSettings(modname); - string model = joylist [joymodidx, 1]:""; - - // do not translate model in /etc/sysconfig/joystick - if (model == Joystick::generic_joystick_translated) - { - model = Joystick::generic_joystick; - } - joy_entry = add(joy_entry, "JOYSTICK_MODULE", joymod); - joy_entry = add(joy_entry, "model", model); - - if (model != current_conf [card_id, "model"]:"") - testing_new = true; - - Joystick::joystick[card_id] = joy_entry; - y2milestone("Tested joystick configuration: %1", joy_entry); - - // unload old and load new modules if necessary: - if (testing_new) - { - Joystick::Stop(); - Joystick::SaveOneJoystick(card_id); - Joystick::WriteConfig(); - Joystick::StartAndEnable(); - } - - // sound card configuration must be changed... - if (update_sound_card_joy_config (card_id, true)) - { - // popup text (yes/no) - if (Popup::YesNo (_("For proper joystick initialization, -a restart of the sound system is necessary. -Proceed?"))) - { - sound_stop (); - sound_start_tmp(true); - } - } - - integer js_id = card_id; // default number of device - list joysticks = []; - integer i = 0; - - sleep (100); - while (i < 4) - { - if (SCR::Execute(.target.bash, - sformat("echo 2>/dev/null < /dev/input/js%1",i)) == 0) - { - joysticks = add (joysticks, i); - y2milestone("existing device: /dev/input/js%1", i); - } - i = i + 1; - } - i = 0; - - if (size (joysticks) == 0) - { - // popup message - Popup::Message(_("No joystick is connected.")); - if (testing_new) - { - Joystick::joystick = current_conf; - Joystick::Stop(); - Joystick::SaveOneJoystick(card_id); - Joystick::WriteConfig(); - Joystick::StartAndEnable(); - } - UI::CloseDialog(); - return false; - } - - if (size (joysticks) > 1) - { - UI::CloseDialog (); - UI::OpenDialog (`opt(`decorated), `HBox(`HSpacing(1.5), `VBox( - `VSpacing(1), - // text label - `Label(_("More than one joystick is connected. -Select the one to test -and press some of its buttons several times. -")), - `VSpacing(1), - `PushButton(`id(`abort), `opt(`default), Label::AbortButton()), - `VSpacing(1)), - `HSpacing(1.5) - )); - - // more joysticks are connected: run jstest alternately for all ones, - // until user pushs some button of joystick he want to test - while (ret == nil) - { - ret = UI::PollInput(); - js_id = joysticks [i]:0; - - SCR::Execute (.background.run_output, - sformat("/usr/bin/jstest --event /dev/input/js%1", js_id)); - sleep (500); - - if ((boolean) SCR::Read(.background.output_open) && - (integer) SCR::Read(.background.newlines)>0) - { - list test_output = (list)SCR::Read(.background.newout); - string last_output = test_output [size (test_output)-1]:""; - last_output = deletechars (last_output, ","); - list listed_output = splitstring (last_output," "); - integer event_type = tointeger (listed_output[2]:"0"); - integer value = tointeger (listed_output [8]:"0"); - if (event_type == 1) - { - y2debug ("output from /dev/js%1: %2", js_id, listed_output); - ret = `found; - } - } - SCR::Execute(.background.kill); - if (ret != `found) - { - if (i == size (joysticks)) - i = 0; - else - i = i + 1; - } - } - } - if (ret == `abort) - { - y2debug ("Abort pressed"); - if (testing_new) - { - Joystick::joystick = current_conf; - Joystick::Stop(); - Joystick::SaveOneJoystick(card_id); - Joystick::WriteConfig(); - Joystick::StartAndEnable(); - } - UI::CloseDialog(); - return false; - } - - // number of device could be different from card number... - js_id = joysticks [i]:0; - SCR::Execute(.background.run_output, - sformat("/usr/bin/jstest --event /dev/input/js%1",js_id)); - - // read the output of joystick initialization - while ((boolean)SCR::Read(.background.output_open) && - (integer)SCR::Read(.background.newlines) == 0) - { - ret = UI::PollInput(); - if (ret != nil) - { - SCR::Execute(.background.kill); - if (testing_new) - { - Joystick::joystick = current_conf; - Joystick::Stop(); - Joystick::SaveOneJoystick(card_id); - Joystick::WriteConfig(); - Joystick::StartAndEnable(); - } - UI::CloseDialog(); - return false; - } - } - // get the number of axes and buttons from the initial jstest output line - list test_output = (list)SCR::Read(.background.newout); - string last_output = test_output[0]:""; - list<string> listed_output = splitstring (last_output," "); - integer axes = 2; - integer buttons = 2; - i = 0; - - while (i < size(listed_output)) - { - // all text parts ("has") depend on output of jstest! - if (listed_output[i]:"" == "has" && listed_output[i+2]:"" == "axes" ) - axes = tointeger (listed_output[i+1]:"2"); - - if (listed_output[i]:"" == "and" && listed_output[i+2]:"" == "buttons.") - buttons = tointeger (listed_output[i+1]:"2"); - i = i + 1; - } - - // generate appropriate dialog for the joystick - term joy_attrib = `VBox(); - string widget_name = ""; - string widget_id = ""; - integer min = -32767; // see js_event.value in linux/joystick.h - integer max = 32767; - i = 0; - - while (i < axes) - { - // progress bar label - widget_name = sformat(_("Axis %1"), i); - widget_id = sformat("Axis %1", i); - joy_attrib = add (joy_attrib, `ProgressBar(`id(widget_id), - `opt(`autoShortcut), widget_name, 2*max, max)); - joy_attrib = add (joy_attrib, `VSpacing(1)); - i = i + 1; - } - - i = 0; - term joy_buttons = `HBox(); - string not_pressed = " "; - string pressed = UI::Glyph(`CheckMark); - while (i < buttons) - { - // label - widget_name = sformat(_("Button %1"), i); - widget_id = sformat ("Button %1", i); - joy_buttons = add (joy_buttons, - `Label (`id(widget_id), widget_name + " " + not_pressed)); - joy_buttons = add (joy_buttons, `HSpacing(2)); - i = i + 1; - } - joy_attrib = add (joy_attrib, joy_buttons); - - UI::CloseDialog(); - UI::OpenDialog(`opt(`decorated), `HBox(`HSpacing(1.5), - `VSpacing(18), - `VBox( - `HSpacing(50), - `VSpacing(1), - // Popup label - `Label(_("Joystick Test")), - `VSpacing(1), - joy_attrib, - `VSpacing(1), - `PushButton(`id(`done), `opt(`default), Label::OKButton()), - `VSpacing(1) - ), - `HSpacing(1.5) - )); - - // read the jstest output until "OK" button is pushed - do - { - if ((boolean)SCR::Read(.background.output_open) && - (integer)SCR::Read(.background.newlines)>0) - { - // read the output line from jstest: - test_output = (list)SCR::Read(.background.newout); - // select the last item of the list: - last_output = test_output [ size(test_output) - 1 ]:""; - last_output = deletechars (last_output, ","); - - listed_output = splitstring (last_output," "); - listed_output = filter (string l, listed_output, ``(l != "")); - - // positions in list depend on jstest output! - integer type = tointeger (listed_output[2]:"0"); - integer number = tointeger (listed_output[6]:"0"); - integer val = tointeger (listed_output[8]:"0"); - - if (type == 1) - { - // button pressed - if (val == 1) - UI::ChangeWidget(`id(sformat("Button %1", number)), `Value, - // label text ("Button" is joystick's button no. %1) - sformat(_("Button %1"), number) + " " + pressed); - else - UI::ChangeWidget(`id(sformat("Button %1", number)), `Value, - sformat(_("Button %1"), number) + " " + not_pressed); - } - else if (type == 2) - { - // change in some axis - UI::ChangeWidget(`id(sformat ("Axis %1", number)), `Value, max + val) ; - } - } - ret = UI::PollInput(); - } - while (ret == nil); - - SCR::Execute(.background.kill); - - // back to the old values - Joystick::joystick = current_conf; - if (testing_new) - { - Joystick::Stop(); - Joystick::SaveOneJoystick(card_id); - Joystick::WriteConfig(); - Joystick::StartAndEnable(); - } - UI::CloseDialog(); - return true; -} integer find_sound_card_id(map sound_card) { @@ -595,7 +275,7 @@ list<map<string,any> > content = []; foreach(map js, Joystick::Detected(), { - y2milestone("Addind joystick: %1", js); + y2milestone("Adding joystick to table: %1", js); string device = js["dev_name2"]:""; string model = js["model"]:""; list<string> descr = []; @@ -812,7 +492,7 @@ ), tcont ), - `Label("To add an USB joystick close this dialog and just connect it."), + `Label(_("To add an USB joystick close this dialog and just connect it.")), `ButtonBox( // button label `PushButton(`id(`ok), _("&Configure joystick")), 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=66210&r1=66209&r2=66210&view=diff ============================================================================== --- branches/tmp/lslezak/sound/sound/src/joystick.ycp (original) +++ branches/tmp/lslezak/sound/sound/src/joystick.ycp Mon Oct 3 18:03:28 2011 @@ -33,12 +33,6 @@ include "sound/joy_dialog.ycp"; include "sound/write_routines.ycp"; - // selected soundcard id - integer selected_card = nil; - - // label for `next button in joystick configuration dialog - symbol label = `next; - // abort block for read/write dialogs block<boolean> abort_block = ``{ return false; }; @@ -53,135 +47,11 @@ } /** - * First cofiguration dialog - if more than one sound card which support - * joystick is found display them, if there is exactly one card skip to - * joystick selection, if no card was found ask user to start - * sound configuration module. + * Display joystick configuration - the main dialog * @return symbol Symbol of pressed button */ define symbol joystick_configuration() ``{ - return joystick_overview(); - - // helptext - string helptext = _("<P>Two or more sound cards in your system support joysticks.</P> -<P>To configure a joystick, select the sound card and press <B>Configure Joystick</B>.</P> -"); - - if (label == `ok) - { - // one joystick already configured - end - return `next; - } - - // get list of installed sound cards - list cards = Sound::GetSoundCardList(); - - // cards which support joysticks - list filtered = Sound::GetSoundCardListWithJoy(); - - y2milestone("Configured sound cards: %1", cards); - y2milestone("Cards with joystick support: %1", filtered); - - if (Mode::test() == true) - { - cards = [ - $["card_no":0, "name":"VIA 82C686A/B"], - $["card_no":1, "name":"Sound Blaster Live!"]]; - filtered = [ - $["card_no":0, "name":"VIA 82C686A/B"], - $["card_no":1, "name":"Sound Blaster Live!"]]; - } - if (size(filtered) == 1) // one sound card - { - selected_card = filtered[0, "card_no"]:0; - label = `ok; - - // skip to configuration dialog if exactly one card was found - return `config; - } - else if (size(filtered) == 0) // no sound card - { - // dialog label - Wizard::SetContents(_("Joystick Configuration"), `Empty(), "", - false, false); - - string message = (size(cards) > 0) ? - // popup message text - _("The configured cards do not support the joystick.") : - // popup message text - _("No configured sound card was found."); - - // yesno popup message text - message = message + "\n" + _("Start sound card configuration?"); - - if (Popup::YesNoHeadline( - // popup message headline - _("No joystick port to configure was found."), message)) - { - // start sound module - joystick can be configured there - // so after sound config abort this module - WFM::CallFunction("sound", []); - } - return `abort; - } - else // more sound cards - { - list tcont = maplist (map card, (list<map>) filtered, ``{ - map jconf = Joystick::joystick[ card["card_no"]:0 ]:$[]; - string jmodel = jconf["model"]:""; - - // translate generic joystick - if (jmodel == Joystick::generic_joystick) - jmodel = Joystick::generic_joystick_translated; - - return `item( - `id(card["card_no"]:0), - sformat("%1", card["card_no"]:0), - card["name"]:"Sound card", - jmodel - ); - }); - - term dialog = `VBox( - `Table(`id(`cards), `header( - // table header (number) - _("No."), - // table header (card name) - _("Sound card"), - // table header (joystick type) - _("Joystick")), tcont - ), - // button label - `PushButton(`id(`config), _("&Configure joystick")) - ); - - Wizard::SetContents( - // dialog caption - _("Configured Sound Cards with Joystick Support"), - dialog, helptext, true, true); - - Wizard::SetNextButton(`next, Label::NextButton() ); - - // preselect first card - UI::ChangeWidget (`id(`cards),`CurrentItem,filtered[0,"card_no"]:0); - } - symbol ret = nil; - - do - { - ret = (symbol) UI::UserInput(); - } - while (ret != `next && ret != `abort && ret != `back && - ret != `cancel && ret != `config); - - if (ret == `cancel) - { - ret = `abort; - } - selected_card = (integer) UI::QueryWidget(`id(`cards), `CurrentItem); - - return ret; } /** -- 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