[yast-commit] r66332 - /branches/tmp/lslezak/sound/sound/src/joy_dialog.ycp
Author: lslezak Date: Fri Oct 7 14:43:59 2011 New Revision: 66332 URL: http://svn.opensuse.org/viewcvs/yast?rev=66332&view=rev Log: added comments 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=66332&r1=66331&r2=66332&view=diff ============================================================================== --- branches/tmp/lslezak/sound/sound/src/joy_dialog.ycp (original) +++ branches/tmp/lslezak/sound/sound/src/joy_dialog.ycp Fri Oct 7 14:43:59 2011 @@ -29,6 +29,7 @@ list joylist = []; + // notice about USB devices, used at several places string usb_notice = _("USB joysticks do not need any configuration, just connect them."); /** @@ -66,6 +67,11 @@ } + /* + * Find index of the sound card in Sound::modules_conf + * @param sound card map (as returned from .probe.sound) + * @return integer index in Sound::modules_conf + */ integer find_sound_card_id(map sound_card) { integer i = 0; @@ -121,6 +127,7 @@ mod = Joystick::generic_joystick_translated; } + // list of joystick drivers and models joylist = maplist(string modname, list<string> models, JoystickDB, ``( maplist(string model, models, ``([modname, model])) )); @@ -246,16 +253,31 @@ return s; } + /* + * Create unique widget id for a broken joystick config + * @param index index of non-working joystick configuration + * @return string the ID + */ define string broken_id(integer index) { return sformat("broken_%1", index); } + /* + * Belogs the ID to a broken joystick? + * @param id + * @return boolean true if the ID belongs to a broken configuration + */ define boolean is_broken(string id) { return regexpmatch(id, "broken_[0-9]+"); } + /* + * Get the joystick index from broken ID string + * @param id + * @return integer the ID or nil if the ID do not belong to a broken configuration + */ define integer broken_index(string id) { string num = regexpsub(id, "broken_([0-9]+)", "\\1"); @@ -268,6 +290,10 @@ return tointeger(num); } + /* + * Create content for the joystick overview table + * @return list<map<string,any>> content for WizardHW::SetContents() function + */ define list<map<string,any> > joystick_table() { list<map<string,any> > content = []; @@ -293,6 +319,7 @@ string bus = js["bus"]:""; + // add the sound card name for gameport joysticks if (bus == "Gameport" && size(js["parent_unique_key"]:"") > 0) { string unique_key = js["parent_unique_key"]:""; @@ -388,11 +415,20 @@ return content; } + /* + * Find detected joystick with requested device name + * @param device joystick device name (e.g. "/dev/input/js0") + * @return map joystick map returned from .probe.joystick agent + */ map find_joystick(string device) { return find(map j, Joystick::Detected(), {return j["dev_name2"]:"" == device;}); } + /* + * Display and run the joystick test dialog + * @param device device name of the joystick to test (e.g. "/dev/input/js0") + */ void test_joystick(string device) { map js = find_joystick(device); @@ -518,6 +554,11 @@ UI::CloseDialog(); } + /* + * Return list of sound cards with gameport that do not have any joystick configured + * @param gameport_cards list of all cards with gameport + * @return list list of cards from gameport_cards that don't have any joystick configured + */ list unconfigured_sound_cards(list gameport_cards) { list ret = filter(map card, (list<map>) gameport_cards, { @@ -528,6 +569,11 @@ return ret; } + /* + * Display dialog for selecting sound card to configure + * @param gameport_cards available sound cards with gameport + * @returen map the selected card (one from gameport_cards) or nil if [Cancel] was pressed + */ map select_sound_card(list gameport_cards) { integer i = -1; @@ -578,6 +624,11 @@ return gameport_cards[joy_card]:$[]; } + /* + * Is the selected joystick connected via USB? + * @param device joystick device name (e.g. "/dev/input/js0") + * @reurn boolean true if the device is an USB joystick + */ boolean is_usb(string device) { map js = find_joystick(device); @@ -586,6 +637,11 @@ return js["bus"]:"" == "USB"; } + /* + * Find joystick index which is attached to a sound card + * @param parent_id the unique key of the sound card + * @return the index or nil if the sound card was not found + */ integer find_joystick_number(string parent_id) { integer i = 0; @@ -611,6 +667,10 @@ return ret; } + /* + * Find the index of the first unused joystick configuration + * @return integer the index or nil when all configs are already used + */ integer find_free_number() { integer i = 0; @@ -636,6 +696,10 @@ return ret; } + /* + * Save one joystick configuration and restart the joystick service to reload drivers + * @param num index of the joystick configuration to change + */ define void restart_joystick(integer num) { // restart joystick service to reload the driver @@ -648,12 +712,19 @@ Joystick::Detect(); } + /* + * Refresh the joystick table in the main configuration dialog + */ define void refresh_table() { list<map<string,any> > items = joystick_table(); WizardHW::SetContents(items); } + /* + * Return the list of detected sound cards that support gameport + * @return list<map> list of devices (as returned by .probe.sound agent) + */ list<map> sound_cards_with_joystick() { list<map> sound_cards = (list<map>)SCR::Read(.probe.sound); @@ -672,11 +743,19 @@ return sound_cards; } + /* + * Return modification time of /dev/input directory + * @return integer mtime in seconds + */ integer input_mtime() { return ((map)SCR::Read(.target.stat, "/dev/input"))["mtime"]:0; } + /* + * Display and run the main joystick dialog + * @return symbol the final user input + */ define symbol joystick_overview() { list<list> extra_buttons = [ @@ -711,6 +790,7 @@ { ret = (symbol)UI::TimeoutUserInput(2000); + // no user input, check for hotplug changes if (ret == `timeout) { integer current_mtime = input_mtime(); -- 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