///////////////////////////////////////////////////////////////////////// this will take out any repeats of element and slot in function id.
| 899 | ////////////////////////////////////////////////////////////////////////////// |
| 900 | // this will take out any repeats of element and slot in function id. |
| 901 | void ctl_cfg_set_and_verify_changes(int16_t fnid, ct_type elem_type, uint8_t ctrl, uint8_t elem, int8_t slot) { |
| 902 | ct_type ctype_fn[CTLBINDS_PER_FUNC]; |
| 903 | uint8_t cfgflags_fn[CTLBINDS_PER_FUNC]; |
| 904 | ct_config_data ccfgdata_fn; |
| 905 | t_cfg_element *fn_list; |
| 906 | tCfgDataParts cfgparts; |
| 907 | int i, n_fn; |
| 908 | if (fnid == -1) { |
| 909 | Int3(); // get samir |
| 910 | return; |
| 911 | } |
| 912 | ASSERT(slot < N_CFGELEM_SLOTS && slot >= 0); |
| 913 | if (ctrl == NULL_CONTROLLER) { |
| 914 | return; |
| 915 | } |
| 916 | // if element is repeated anywhere in function list other than 'fnid'[slot] of elem_type, then remove that |
| 917 | // binding. |
| 918 | if (elem_type == ctNone) { |
| 919 | Int3(); |
| 920 | return; |
| 921 | } else if (elem_type == ctKey) { |
| 922 | n_fn = N_KEY_CFG_FN; |
| 923 | fn_list = Cfg_key_elements; |
| 924 | } else { |
| 925 | n_fn = N_JOY_CFG_FN; |
| 926 | fn_list = Cfg_joy_elements; |
| 927 | } |
| 928 | for (i = 0; i < n_fn; i++) { |
| 929 | // get current function. if element in any slot matches elem_type, and elem, then remove it. |
| 930 | bool match_found = false; |
| 931 | Controller->get_controller_function(fn_list[i].fn_id, ctype_fn, &ccfgdata_fn, cfgflags_fn); |
| 932 | |
| 933 | parse_config_data(&cfgparts, ctype_fn[0], ctype_fn[1], ccfgdata_fn); |
| 934 | if (elem_type == ctype_fn[0] && elem == cfgparts.bind_0 && cfgparts.ctrl_0 == ctrl) { |
| 935 | // match found! clear this part out. |
| 936 | cfgparts.bind_0 = NULL_BINDING; |
| 937 | cfgparts.ctrl_0 = NULL_CONTROLLER; |
| 938 | match_found = true; |
| 939 | } |
| 940 | if (elem_type == ctype_fn[1] && elem == cfgparts.bind_1 && cfgparts.ctrl_1 == ctrl) { |
| 941 | // match found! clear this part out. |
| 942 | cfgparts.bind_1 = NULL_BINDING; |
| 943 | cfgparts.ctrl_1 = NULL_CONTROLLER; |
| 944 | match_found = true; |
| 945 | } |
| 946 | if (match_found) { |
| 947 | // this will effectively clear any matches found. |
| 948 | ccfgdata_fn = unify_config_data(&cfgparts); |
| 949 | Controller->set_controller_function(fn_list[i].fn_id, ctype_fn, ccfgdata_fn, cfgflags_fn); |
| 950 | } |
| 951 | } |
| 952 | Controller->get_controller_function(fnid, ctype_fn, &ccfgdata_fn, cfgflags_fn); |
| 953 | |
| 954 | parse_config_data(&cfgparts, ctype_fn[0], ctype_fn[1], ccfgdata_fn); |
| 955 | |
| 956 | ctype_fn[slot] = elem_type; |
| 957 | cfgflags_fn[slot] = 0; |
| 958 | if (slot == 1) { |
no test coverage detected