src/osd/winui/menu.c
| r11509 | r11510 | |
| 86 | 86 | //============================================================ |
| 87 | 87 | |
| 88 | 88 | static int input_item_from_serial_number(running_machine &machine, int serial_number, |
| 89 | | const input_port_config **port, const input_field_config **field, const input_setting_config **setting) |
| 89 | input_port_config **port, input_field_config **field, input_setting_config **setting) |
| 90 | 90 | { |
| 91 | 91 | int i; |
| 92 | | const input_port_config *this_port = NULL; |
| 93 | | const input_field_config *this_field = NULL; |
| 94 | | const input_setting_config *this_setting = NULL; |
| 92 | input_port_config *this_port = NULL; |
| 93 | input_field_config *this_field = NULL; |
| 94 | input_setting_config *this_setting = NULL; |
| 95 | 95 | |
| 96 | 96 | i = 0; |
| 97 | 97 | for (this_port = machine.m_portlist.first(); (i != serial_number) && (this_port != NULL); this_port = this_port->next()) |
| 98 | 98 | { |
| 99 | 99 | i++; |
| 100 | | for (this_field = this_port->fieldlist; (i != serial_number) && (this_field != NULL); this_field = this_field->next) |
| 100 | for (this_field = this_port->fieldlist().first(); (i != serial_number) && (this_field != NULL); this_field = this_field->next()) |
| 101 | 101 | { |
| 102 | 102 | i++; |
| 103 | | for (this_setting = this_field->settinglist; (i != serial_number) && (this_setting != NULL); this_setting = this_setting->next) |
| 103 | for (this_setting = this_field->settinglist().first(); (i != serial_number) && (this_setting != NULL); this_setting = this_setting->next()) |
| 104 | 104 | { |
| 105 | 105 | i++; |
| 106 | 106 | } |
| 107 | 107 | } |
| 108 | 108 | } |
| 109 | 109 | |
| 110 | | if (this_setting != NULL) |
| 111 | | this_field = this_setting->field; |
| 112 | 110 | if (this_field != NULL) |
| 113 | | this_port = this_field->port; |
| 111 | this_port = &this_field->port(); |
| 114 | 112 | |
| 115 | 113 | if (port != NULL) |
| 116 | 114 | *port = this_port; |
| r11509 | r11510 | |
| 127 | 125 | // serial_number_from_input_item |
| 128 | 126 | //============================================================ |
| 129 | 127 | |
| 130 | | static int serial_number_from_input_item(running_machine &machine, const input_port_config *port, |
| 131 | | const input_field_config *field, const input_setting_config *setting) |
| 128 | static int serial_number_from_input_item(running_machine &machine, input_port_config *port, |
| 129 | input_field_config *field, input_setting_config *setting) |
| 132 | 130 | { |
| 133 | 131 | int i; |
| 134 | | const input_port_config *this_port; |
| 135 | | const input_field_config *this_field; |
| 136 | | const input_setting_config *this_setting; |
| 132 | input_port_config *this_port; |
| 133 | input_field_config *this_field; |
| 134 | input_setting_config *this_setting; |
| 137 | 135 | |
| 138 | 136 | i = 0; |
| 139 | 137 | for (this_port = machine.m_portlist.first(); this_port != NULL; this_port = this_port->next()) |
| r11509 | r11510 | |
| 142 | 140 | return i; |
| 143 | 141 | |
| 144 | 142 | i++; |
| 145 | | for (this_field = this_port->fieldlist; this_field != NULL; this_field = this_field->next) |
| 143 | for (this_field = this_port->fieldlist().first(); this_field != NULL; this_field = this_field->next()) |
| 146 | 144 | { |
| 147 | 145 | if ((port == this_port) && (field == this_field) && (setting == NULL)) |
| 148 | 146 | return i; |
| 149 | 147 | |
| 150 | 148 | i++; |
| 151 | | for (this_setting = this_field->settinglist; this_setting != NULL; this_setting = this_setting->next) |
| 149 | for (this_setting = this_field->settinglist().first(); this_setting != NULL; this_setting = this_setting->next()) |
| 152 | 150 | { |
| 153 | 151 | if ((port == this_port) && (field == this_field) && (setting == this_setting)) |
| 154 | 152 | return i; |
| r11509 | r11510 | |
| 169 | 167 | static void customize_input(running_machine &machine, HWND wnd, const char *title, int player, int inputclass) |
| 170 | 168 | { |
| 171 | 169 | dialog_box *dlg; |
| 172 | | const input_port_config *port; |
| 173 | | const input_field_config *field; |
| 170 | input_port_config *port; |
| 171 | input_field_config *field; |
| 174 | 172 | int this_inputclass, this_player, portslot_count = 0, i; |
| 175 | 173 | |
| 176 | 174 | struct |
| r11509 | r11510 | |
| 185 | 183 | |
| 186 | 184 | for (port = machine.m_portlist.first(); port != NULL; port = port->next()) |
| 187 | 185 | { |
| 188 | | for (field = port->fieldlist; field != NULL; field = field->next) |
| 186 | for (field = port->fieldlist().first(); field != NULL; field = field->next()) |
| 189 | 187 | { |
| 190 | 188 | this_inputclass = input_classify_port(field); |
| 191 | 189 | if (input_field_name(field) && (this_inputclass == inputclass)) |
| r11509 | r11510 | |
| 307 | 305 | static void customize_switches(running_machine &machine, HWND wnd, const char* title_string, UINT32 ipt_name) |
| 308 | 306 | { |
| 309 | 307 | dialog_box *dlg; |
| 310 | | const input_port_config *port; |
| 311 | | const input_field_config *field; |
| 312 | | const input_setting_config *setting; |
| 308 | input_port_config *port; |
| 309 | input_field_config *field; |
| 310 | input_setting_config *setting; |
| 313 | 311 | const char *switch_name = NULL; |
| 314 | 312 | input_field_user_settings settings; |
| 315 | 313 | |
| r11509 | r11510 | |
| 321 | 319 | |
| 322 | 320 | for (port = machine.m_portlist.first(); port != NULL; port = port->next()) |
| 323 | 321 | { |
| 324 | | for (field = port->fieldlist; field != NULL; field = field->next) |
| 322 | for (field = port->fieldlist().first(); field != NULL; field = field->next()) |
| 325 | 323 | { |
| 326 | 324 | type = field->type; |
| 327 | 325 | |
| r11509 | r11510 | |
| 334 | 332 | if (win_dialog_add_combobox(dlg, switch_name, settings.value, storeval_inputport, (void *) field)) |
| 335 | 333 | goto done; |
| 336 | 334 | |
| 337 | | for (setting = field->settinglist; setting != NULL; setting = setting->next) |
| 335 | for (setting = field->settinglist().first(); setting != NULL; setting = setting->next()) |
| 338 | 336 | { |
| 339 | 337 | if (win_dialog_add_combobox_item(dlg, setting->name, setting->value)) |
| 340 | 338 | goto done; |
| r11509 | r11510 | |
| 448 | 446 | static void customize_analogcontrols(running_machine &machine, HWND wnd) |
| 449 | 447 | { |
| 450 | 448 | dialog_box *dlg; |
| 451 | | const input_port_config *port; |
| 452 | | const input_field_config *field; |
| 449 | input_port_config *port; |
| 450 | input_field_config *field; |
| 453 | 451 | input_field_user_settings settings; |
| 454 | 452 | const char *name; |
| 455 | 453 | char buf[255]; |
| r11509 | r11510 | |
| 461 | 459 | |
| 462 | 460 | for (port = machine.m_portlist.first(); port != NULL; port = port->next()) |
| 463 | 461 | { |
| 464 | | for (field = port->fieldlist; field != NULL; field = field->next) |
| 462 | for (field = port->fieldlist().first(); field != NULL; field = field->next()) |
| 465 | 463 | { |
| 466 | 464 | if (port_type_is_analog(field->type)) |
| 467 | 465 | { |
| r11509 | r11510 | |
| 1117 | 1115 | int i; |
| 1118 | 1116 | UINT command; |
| 1119 | 1117 | HMENU submenu = NULL; |
| 1120 | | const input_port_config *port; |
| 1121 | | const input_field_config *field; |
| 1122 | | const input_setting_config *setting; |
| 1118 | input_port_config *port; |
| 1119 | input_field_config *field; |
| 1120 | input_setting_config *setting; |
| 1123 | 1121 | char buf[256]; |
| 1124 | 1122 | int child_count = 0; |
| 1125 | 1123 | |
| 1126 | 1124 | use_input_categories = 0; |
| 1127 | 1125 | for (port = machine.m_portlist.first(); port != NULL; port = port->next()) |
| 1128 | 1126 | { |
| 1129 | | for (field = port->fieldlist; field != NULL; field = field->next) |
| 1127 | for (field = port->fieldlist().first(); field != NULL; field = field->next()) |
| 1130 | 1128 | { |
| 1131 | 1129 | if (field->type == IPT_CATEGORY) |
| 1132 | 1130 | { |
| r11509 | r11510 | |
| 1145 | 1143 | // using input categories |
| 1146 | 1144 | for (port = machine.m_portlist.first(); port != NULL; port = port->next()) |
| 1147 | 1145 | { |
| 1148 | | for (field = port->fieldlist; field != NULL; field = field->next) |
| 1146 | for (field = port->fieldlist().first(); field != NULL; field = field->next()) |
| 1149 | 1147 | { |
| 1150 | 1148 | if (field->type == IPT_CATEGORY) |
| 1151 | 1149 | { |
| r11509 | r11510 | |
| 1154 | 1152 | return; |
| 1155 | 1153 | |
| 1156 | 1154 | // append all of the category settings |
| 1157 | | for (setting = field->settinglist; setting != NULL; setting = setting->next) |
| 1155 | for (setting = field->settinglist().first(); setting != NULL; setting = setting->next()) |
| 1158 | 1156 | { |
| 1159 | 1157 | command = ID_INPUT_0 + serial_number_from_input_item(machine, port, field, setting); |
| 1160 | 1158 | win_append_menu_utf8(submenu, MF_STRING, command, setting->name); |
| r11509 | r11510 | |
| 1241 | 1239 | UINT flags_for_writing; |
| 1242 | 1240 | device_image_interface *img = NULL; |
| 1243 | 1241 | int has_config, has_dipswitch, has_keyboard, has_analog, has_misc; |
| 1244 | | const input_port_config *port; |
| 1245 | | const input_field_config *field; |
| 1246 | | const input_setting_config *setting; |
| 1242 | input_port_config *port; |
| 1243 | input_field_config *field; |
| 1244 | input_setting_config *setting; |
| 1247 | 1245 | int frameskip; |
| 1248 | 1246 | int orientation; |
| 1249 | 1247 | int speed; |
| r11509 | r11510 | |
| 1278 | 1276 | has_analog = 0; |
| 1279 | 1277 | for (port = window->machine().m_portlist.first(); port != NULL; port = port->next()) |
| 1280 | 1278 | { |
| 1281 | | for (field = port->fieldlist; field != NULL; field = field->next) |
| 1279 | for (field = port->fieldlist().first(); field != NULL; field = field->next()) |
| 1282 | 1280 | { |
| 1283 | 1281 | if (port_type_is_analog(field->type)) |
| 1284 | 1282 | { |
| r11509 | r11510 | |
| 1340 | 1338 | { |
| 1341 | 1339 | for (port = window->machine().m_portlist.first(); port != NULL; port = port->next()) |
| 1342 | 1340 | { |
| 1343 | | for (field = port->fieldlist; field != NULL; field = field->next) |
| 1341 | for (field = port->fieldlist().first(); field != NULL; field = field->next()) |
| 1344 | 1342 | { |
| 1345 | 1343 | if (field->type == IPT_CATEGORY) |
| 1346 | 1344 | { |
| 1347 | 1345 | input_field_get_user_settings(field, &settings); |
| 1348 | | for (setting = field->settinglist; setting != NULL; setting = setting->next) |
| 1346 | for (setting = field->settinglist().first(); setting != NULL; setting = setting->next()) |
| 1349 | 1347 | { |
| 1350 | 1348 | command = ID_INPUT_0 + serial_number_from_input_item(window->machine(), port, field, setting); |
| 1351 | 1349 | set_command_state(menu_bar, command, (setting->value == settings.value) ? MFS_CHECKED : MFS_ENABLED); |
| r11509 | r11510 | |
| 1678 | 1676 | int dev_command; |
| 1679 | 1677 | device_image_interface *img; |
| 1680 | 1678 | UINT16 category; |
| 1681 | | const input_field_config *field; |
| 1682 | | const input_setting_config *setting; |
| 1679 | input_field_config *field; |
| 1680 | input_setting_config *setting; |
| 1683 | 1681 | LONG_PTR ptr = GetWindowLongPtr(wnd, GWLP_USERDATA); |
| 1684 | 1682 | win_window_info *window = (win_window_info *)ptr; |
| 1685 | 1683 | input_field_user_settings settings; |
| r11509 | r11510 | |
| 1884 | 1882 | input_field_get_user_settings(field, &settings); |
| 1885 | 1883 | category = 0; |
| 1886 | 1884 | |
| 1887 | | for (setting = field->settinglist; setting != NULL; setting = setting->next) |
| 1885 | for (setting = field->settinglist().first(); setting != NULL; setting = setting->next()) |
| 1888 | 1886 | { |
| 1889 | 1887 | if (settings.value == setting->value) |
| 1890 | 1888 | { |