Exemplo n.º 1
0
	TDevice* create_rawinput_device(running_machine &machine, PRAWINPUTDEVICELIST rawinputdevice)
	{
		TDevice* devinfo = nullptr;
		INT name_length = 0;
		// determine the length of the device name, allocate it, and fetch it if not nameless
		if (get_rawinput_device_info(rawinputdevice->hDevice, RIDI_DEVICENAME, NULL, &name_length) != 0)
			return nullptr;

		std::unique_ptr<TCHAR[]> tname = std::make_unique<TCHAR[]>(name_length + 1);
		if (name_length > 1 && get_rawinput_device_info(rawinputdevice->hDevice, RIDI_DEVICENAME, tname.get(), &name_length) == -1)
			return nullptr;

		// if this is an RDP name, skip it
		if (_tcsstr(tname.get(), TEXT("Root#RDP_")) != NULL)
			return nullptr;

		// improve the name and then allocate a device
		tname = std::unique_ptr<TCHAR[]>(rawinput_device_improve_name(tname.release()));

		// convert name to utf8
		auto osd_deleter = [](void *ptr) { osd_free(ptr); };
		auto utf8_name = std::unique_ptr<char, decltype(osd_deleter)>(utf8_from_tstring(tname.get()), osd_deleter);

		devinfo = devicelist()->create_device<TDevice>(machine, utf8_name.get(), *this);

		// Add the handle
		devinfo->set_handle(rawinputdevice->hDevice);

		return devinfo;
	}
Exemplo n.º 2
0
	TDevice* create_rawinput_device(running_machine &machine, PRAWINPUTDEVICELIST rawinputdevice)
	{
		TDevice* devinfo;
		UINT name_length = 0;
		// determine the length of the device name, allocate it, and fetch it if not nameless
		if ((*get_rawinput_device_info)(rawinputdevice->hDevice, RIDI_DEVICENAME, nullptr, &name_length) != 0)
			return nullptr;

		std::unique_ptr<TCHAR[]> tname = std::make_unique<TCHAR[]>(name_length + 1);
		if (name_length > 1 && (*get_rawinput_device_info)(rawinputdevice->hDevice, RIDI_DEVICENAME, tname.get(), &name_length) == -1)
			return nullptr;

		// if this is an RDP name, skip it
		if (_tcsstr(tname.get(), TEXT("Root#RDP_")) != nullptr)
			return nullptr;

		// improve the name and then allocate a device
		std::wstring name = rawinput_device_improve_name(tname.get());

		// convert name to utf8
		std::string utf8_name = osd::text::from_wstring(name.c_str());

		// set device id to raw input name
		std::string utf8_id = osd::text::from_wstring(tname.get());

		devinfo = devicelist()->create_device<TDevice>(machine, utf8_name.c_str(), utf8_id.c_str(), *this);

		// Add the handle
		devinfo->set_handle(rawinputdevice->hDevice);

		return devinfo;
	}
Exemplo n.º 3
0
TError TDevicesSubsystem::ApplyDevice(TCgroup &cg, const TDevice &device) {
    std::string rule;
    TError error;

    rule = device.CgroupRule(true);
    if (rule != "")
        error = cg.Set("devices.allow", rule);
    rule = device.CgroupRule(false);
    if (!error && rule != "")
        error = cg.Set("devices.deny", rule);
    return error;
}
Exemplo n.º 4
0
qboolean FFConfigParser::ParseSetDevices( const char **pos, TDevice &device )
{
	qboolean result = qboolean( pos != NULL );

	if ( pos )
	{
		char *token = COM_ParseExt( pos, qtrue );
		if ( token[ 0 ] == '{' )
		{
			for
			(	token = COM_ParseExt( pos, qtrue )
			;	token[ 0 ]
			&&	token[ 0 ] != '}'
			&&	result // fail if any problem
			;	token = COM_ParseExt( pos, qtrue )
			){
				device.insert( token );
			}

			result = qboolean( token[ 0 ] != 0 );
		}
		else
		{
			// expected '{'
			result = qfalse;
		}
	}

	return result;
}
Exemplo n.º 5
0
void SelectDrawWidget::GoToWWWDocumentation(DrawInfo *d) {
	if (d->IsValid() == false)
		return;
	TParam *p = d->GetParam()->GetIPKParam();
	TSzarpConfig* sc = p->GetSzarpConfig();

	wxString link = sc->GetDocumentationBaseURL();

	if (link.IsEmpty())
		link = _T("http://www.szarp.com");

	link += _T("/cgi-bin/param_docs.py?");
	link << _T("prefix=") << d->GetBasePrefix().c_str();

	link << _T("&param=") << encode_string(p->GetName().c_str());

	TUnit* u;
	if ((u = p->GetParentUnit())) {
		TDevice* dev = u->GetDevice();
		link << _T("&path=") << encode_string(dev->GetPath().c_str());
	}

	int validity = 8 * 3600;
	std::wstringstream tss;
	tss << (wxDateTime::Now().GetTicks() / validity * validity);

	link << _T("&id=") << sz_md5(tss.str());

#if __WXMSW__
	if (wxLaunchDefaultBrowser(link) == false)
#else
	if (wxExecute(wxString::Format(_T("xdg-open %s"), link.c_str())) == 0)
#endif
		wxMessageBox(_("I was not able to start default browser"), _("Error"), wxICON_ERROR | wxOK, this);


}