static void values_from_dialog(int changedport, bool reset)
{
	int i;
	int changed = 0;
	int prevport;

  if(reset)
    inputdevice_compa_clear (&workprefs, changedport);

	for (i = 0; i < MAX_JPORTS; i++) {
		int prevport = workprefs.jports[i].id;
		int max = JSEM_LASTKBD + inputdevice_get_device_total (IDTYPE_JOYSTICK);
		if (i < 2)
			max += inputdevice_get_device_total (IDTYPE_MOUSE);
    int id = cboPorts[i]->getSelected() - 1;
		if (id < 0) {
			workprefs.jports[i].id = JPORT_NONE;
		} else if (id >= max) {
			workprefs.jports[i].id = JPORT_NONE;
		} else if (id < JSEM_LASTKBD) {
			workprefs.jports[i].id = JSEM_KBDLAYOUT + id;
		} else if (id >= JSEM_LASTKBD + inputdevice_get_device_total (IDTYPE_JOYSTICK)) {
			workprefs.jports[i].id = JSEM_MICE + id - inputdevice_get_device_total (IDTYPE_JOYSTICK) - JSEM_LASTKBD;
		} else {
			workprefs.jports[i].id = JSEM_JOYS + id - JSEM_LASTKBD;
		}

		if (workprefs.jports[i].id != prevport)
			changed = 1;

	  if (i >= 2)
	    continue;

		if(cboPortModes[i] != NULL)
		  workprefs.jports[i].mode = inputmode_val[cboPortModes[i]->getSelected()];
		if(cboAutofires[i] != NULL)
		  workprefs.jports[i].autofire = cboAutofires[i]->getSelected();
	}

  if (changed)
    inputdevice_validate_jports (&workprefs, changedport, NULL);        

	RefreshPanelGamePort();

  inputdevice_config_change();
  if(reset)
    inputdevice_forget_unplugged_device(changedport);
}
Exemple #2
0
static int port_insert (int inputmap_port, int devicetype, DWORD flags, const TCHAR *name)
{
	int devicetype2;

	write_log (L"port_insert %d '%s'\n", inputmap_port, name);

	if (inputmap_port < 0 || inputmap_port >= maxjports)
		return FALSE;
	
	inputdevice_compa_clear (&changed_prefs, inputmap_port);
	
	if (_tcslen (name) == 0) {
		inputdevice_joyport_config (&changed_prefs, _T("none"), inputmap_port, 0, 0);
		return TRUE;
	}
	devicetype2 = -1;
	for (int i = 0; inputdevmode[i * 2]; i++) {
		if (inputdevmode[i * 2 + 0] == devicetype) {
			devicetype2 = inputdevmode[i * 2 + 1];
			break;
		}
	}
	if (devicetype2 < 0)
		return FALSE;

	if (!_tcsncmp (name, KEYBOARDCUSTOM, _tcslen (KEYBOARDCUSTOM))) {
		return port_insert_custom (inputmap_port, devicetype, flags, name + _tcslen (KEYBOARDCUSTOM));
	}

	for (int i = 0; i < 10; i++) {
		TCHAR tmp2[100];
		_stprintf (tmp2, _T("KeyboardLayout%d"), i);
		if (!_tcscmp (tmp2, name)) {
			_stprintf (tmp2, _T("kbd%d"), i + 1);
			return inputdevice_joyport_config (&changed_prefs, tmp2, inputmap_port, devicetype2, 0);
		}
	}
	return inputdevice_joyport_config (&changed_prefs, name, inputmap_port, devicetype2, 1);
}