Пример #1
0
void GamepadPage::DetectControl(wxCommandEvent& event)
{
	ControlButton* btn = (ControlButton*)event.GetEventObject();

	// find device :/
	ControllerInterface::Device* const dev = g_controller_interface.FindDevice(controller->default_device);
	if (dev)
	{
		btn->SetLabel(_("[ waiting ]"));

		// apparently, this makes the "waiting" text work on Linux
		wxTheApp->Yield();

		std::lock_guard<std::recursive_mutex> lk(m_plugin.controls_lock);
		ControllerInterface::Device::Control* const ctrl = btn->control_reference->Detect(DETECT_WAIT_TIME, dev);

		// if we got input, update expression and reference
		if (ctrl)
		{
			btn->control_reference->expression = ctrl->GetName();
			g_controller_interface.UpdateReference(btn->control_reference, controller->default_device);
		}

		btn->SetLabel(WXSTR_FROM_STR(btn->control_reference->expression));
	}
}
Пример #2
0
void GamepadPage::DetectControl(wxCommandEvent& event)
{
	ControlButton* btn = (ControlButton*)event.GetEventObject();

	// find device :/
	Device* const dev = g_controller_interface.FindDevice(controller->default_device);
	if (dev)
	{
		btn->SetLabel(_("[ waiting ]"));

		// This makes the "waiting" text work on Linux. true (only if needed) prevents crash on Windows
		wxTheApp->Yield(true);

		std::lock_guard<std::recursive_mutex> lk(m_plugin.controls_lock);
		Device::Control* const ctrl = btn->control_reference->Detect(DETECT_WAIT_TIME, dev);

		// if we got input, update expression and reference
		if (ctrl)
		{
			wxString control_name = ctrl->GetName();
			wxString expr;
			GetExpressionForControl(expr, control_name);
			btn->control_reference->expression = expr;
			g_controller_interface.UpdateReference(btn->control_reference, controller->default_device);
		}
	}

	UpdateGUI();
}