예제 #1
0
void SettingsAudioOutput::OnOutputProperties(wxCommandEvent& event)
{
	wxTreeItemId selection = m_AudioOutput->GetSelection();
	AudioItemData* data = GetObject(selection);
	if (data && data->type == AudioItemData::AUDIO_NODE)
	{
		int latency = data->latency;
		latency = wxGetNumberFromUser(_("Desired output latency"), _("Desired latency:"), _("Audio device settings"), latency, 0, 999, this);
		if (latency == -1)
			return;
		data->latency = latency;
		UpdateDevice(selection);
	}
	else if (data && data->type == AudioItemData::GROUP_NODE)
	{
		wxString current = wxString::Format(wxT("%f"), data->volume >= -120 ? data->volume : -120);
		current = wxGetTextFromUser(_("Please enter new volume in dB:"), _("Change audio group"), current);
		if (current == wxEmptyString)
			return;
		double volume;
		if (!current.ToDouble(&volume) || volume < -120.0 || volume > 40.0)
		{
			wxMessageBox(_("Please enter a volume between -120 and 40 dB") , _("Error"), wxOK | wxICON_ERROR, this);
			return;
		}
		data->volume = volume;
		UpdateVolume(selection, data->volume);
	}
	UpdateButtons();
}
예제 #2
0
CodeOneRenderer::CodeOneRenderer(ID3D11Device * nd3ddev, ID3D11DeviceContext * ndevcon)
{
	if (!nd3ddev || !ndevcon)
	{
		Log("Error creating renderer : Device or DeviceContext was not found");
		std::exit(1);
	}
	UpdateDevice(nd3ddev, ndevcon);
}
// nsIDNSServiceResolveListener
NS_IMETHODIMP
LegacyMDNSDeviceProvider::OnServiceResolved(nsIDNSServiceInfo* aServiceInfo)
{
  MOZ_ASSERT(NS_IsMainThread());

  if (NS_WARN_IF(!aServiceInfo)) {
    return NS_ERROR_INVALID_ARG;
  }

  nsresult rv;

  nsAutoCString serviceName;
  if (NS_WARN_IF(NS_FAILED(rv = aServiceInfo->GetServiceName(serviceName)))) {
    return rv;
  }

  LOG_I("OnServiceResolved: %s", serviceName.get());

  nsAutoCString host;
  if (NS_WARN_IF(NS_FAILED(rv = aServiceInfo->GetHost(host)))) {
    return rv;
  }

  nsAutoCString address;
  if (NS_WARN_IF(NS_FAILED(rv = aServiceInfo->GetAddress(address)))) {
    return rv;
  }

  uint16_t port;
  if (NS_WARN_IF(NS_FAILED(rv = aServiceInfo->GetPort(&port)))) {
    return rv;
  }

  nsAutoCString serviceType;
  if (NS_WARN_IF(NS_FAILED(rv = aServiceInfo->GetServiceType(serviceType)))) {
    return rv;
  }

  uint32_t index;
  if (FindDeviceById(host, index)) {
    return UpdateDevice(index,
                        serviceName,
                        serviceType,
                        address,
                        port);
  } else {
    return AddDevice(host,
                     serviceName,
                     serviceType,
                     address,
                     port);
  }

  return NS_OK;
}
예제 #4
0
bool CRazberry::GetUpdates()
{
	std::string sResult;
#ifndef	DEBUG_ZWAVE_INT
	std::string szURL=GetControllerURL();
	bool bret;
	bret=HTTPClient::GET(szURL,sResult);
	if (!bret)
	{
		_log.Log(LOG_ERROR,"Razberry: Error getting update data!");
		return 0;
	}
#else
	sResult=readInputTestFile("update.json");
#endif
	Json::Value root;

	Json::Reader jReader;
	bool ret=jReader.parse(sResult,root);
	if (!ret)
	{
		_log.Log(LOG_ERROR,"Razberry: Invalid data received!");
		return 0;
	}

	for (Json::Value::iterator itt=root.begin(); itt!=root.end(); ++itt)
	{
		std::string kName=itt.key().asString();
		const Json::Value obj=(*itt);

		if (kName=="updateTime")
		{
			std::string supdateTime=obj.asString();
			m_updateTime=(time_t)atol(supdateTime.c_str());
		}
		else if (kName=="devices")
		{
			parseDevices(obj);
		}
		else
		{
			std::vector<std::string> results;
			StringSplit(kName,".",results);

			if (results.size()>1)
			{
				if (kName.find("lastReceived")==std::string::npos)
					UpdateDevice(kName,obj);
			}
		}
	}

	return true;
}
예제 #5
0
wxTreeItemId SettingsAudioOutput::AddDeviceNode(wxString name, unsigned desired_latency)
{
	wxTreeItemId current;
	if (name == wxEmptyString)
		name = m_Sound.GetDefaultAudioDevice();
	current = GetDeviceNode(name);
	if (current.IsOk())
		return current;
	current = m_AudioOutput->AppendItem(m_AudioOutput->GetRootItem(), wxEmptyString, -1, -1, new AudioItemData(name, desired_latency));
	UpdateDevice(current);
	m_AudioOutput->Expand(current);
	return current;
}
예제 #6
0
void CDirectInput::UpdateJoystick (int Joystick)
{
    // Check if the joystick number is correct
    ASSERT (Joystick >= 0 && Joystick < m_pJoysticks.size ());

    // Check if the joystick is at least supposed to be opened
    ASSERT (m_pJoysticks[Joystick]->Opened);

    // Update the device and get the latest real opened state
    m_pJoysticks[Joystick]->Opened = UpdateDevice (m_pJoysticks[Joystick]->pDevice, 
                                                   &m_pJoysticks[Joystick]->State, 
                                                   sizeof(m_pJoysticks[Joystick]->State));
}
예제 #7
0
void SettingsAudioOutput::OnOutputChange(wxCommandEvent& event)
{
	wxTreeItemId selection = m_AudioOutput->GetSelection();
	AudioItemData* data = GetObject(selection);
	if (data && data->type == AudioItemData::AUDIO_NODE)
	{
		int index;
		wxArrayString devs;
		std::vector<wxString> devices = GetRemainingAudioDevices();
		for(unsigned i = 0; i < devices.size(); i++)
			devs.Add(devices[i]);
		devs.Insert(data->name, 0);
		index = wxGetSingleChoiceIndex(_("Change audio device"), _("Change audio device"), devs, this);
		if (index == -1 || index == 0)
			return;
		unsigned channels = m_AudioOutput->GetChildrenCount(selection, false);
		bool error = false;
		for(unsigned i = 0; i < m_DeviceList.size(); i++)
			if (m_DeviceList[i].name == devs[index])
				if (channels > m_DeviceList[i].channels)
					error = true;
		if (error)
		{
			wxMessageBox(_("Too many audio channels configured for the new audio interface") , _("Error"), wxOK | wxICON_ERROR, this);
			return;
		}
		data->name = devs[index];

		UpdateDevice(selection);
	}
	else if (data && data->type == AudioItemData::GROUP_NODE)
	{
		int index;
		std::vector<std::pair<wxString, bool> > groups;
		wxArrayString names;
		groups = GetRemainingAudioGroups(m_AudioOutput->GetItemParent(selection));
		groups.insert(groups.begin(), std::pair<wxString, bool>(data->name, data->left));
		for(unsigned i = 0; i < groups.size(); i++)
			names.Add(wxString::Format(groups[i].second ? _("%s - left") : _("%s - right"), groups[i].first.c_str()));
		index = wxGetSingleChoiceIndex(_("Change audio group"), _("Change audio group"), names, this);
		if (index == -1 || index == 0)
			return;
		data->name = groups[index].first;
		data->left = groups[index].second;
		UpdateVolume(selection, data->volume);
	}
	UpdateButtons();
}
예제 #8
0
void CDirectInput::UpdateKeyboard (void)
{
    // Update the device and get the latest real opened state
    m_KeyboardOpened = UpdateDevice (m_pKeyboard, m_KeyState, MAX_KEYS);
}
예제 #9
0
void CInputSDL::UpdateKeyboard (void)
{

    UpdateDevice(m_KeyState, MAX_KEYS);

}
예제 #10
0
uint8_t RecvCommand() {
	uint8_t Cmd;
	char Username[32];
	uint8_t TargetUser = MAX_USERS+1;
	uint8_t DeviceType;
	uint16_t DeviceId;
	uint16_t AlarmId;
	uint8_t NewDevice;
	uint8_t UserId;

	// Read in the one-byte command
	if (!ReadBytes((unsigned char *)&Cmd, 1)) {
		return(0);
	}

	switch (Cmd) {
		case CMD_POWER_OFF:
			SendResp(RESP_SUCCESS, NULL);
			return(0);
			break;

		case CMD_ADD_USER:
			if (!AddUser()) {
				SendResp(RESP_ADD_USER_FAILED, NULL);
				return(1);
			}
			SendResp(RESP_SUCCESS, NULL);
			break;

		case CMD_DEL_USER:
			if (!DelUser()) {
				SendResp(RESP_DEL_USER_FAILED, NULL);
				return(1);
			}
			SendResp(RESP_SUCCESS, NULL);
			break;

		case CMD_ADD_DEVICE:
			// Read in the device type
			if (!ReadBytes((unsigned char *)&DeviceType, 1)) {
				return(0);
			}
			
		        // Find the next available device slot
			if ((NewDevice = FindAvailableDevice()) >= MAX_DEVICES) {
				SendResp(RESP_INVALID_CMD, NULL);
				return(0);
			}
			
			switch (DeviceType) {
				case DEVICE_KEYPAD:
					if (!(DeviceId = NewGenericDevice(DeviceType, NewDevice))) {
						SendResp(RESP_ADD_DEVICE_FAILED, NULL);
						return(0);
					}
					break;
				case DEVICE_SWIPE:
					if (!(DeviceId = NewGenericDevice(DeviceType, NewDevice))) {
						SendResp(RESP_ADD_DEVICE_FAILED, NULL);
						return(0);
					}
					break;
				case DEVICE_CONTACT:
					if (!(DeviceId = NewContact(NewDevice))) {
						SendResp(RESP_ADD_DEVICE_FAILED, NULL);
						return(0);
					}
					break;
				case DEVICE_MOTION:
					if (!(DeviceId = NewMotion(NewDevice))) {
						SendResp(RESP_ADD_DEVICE_FAILED, NULL);
						return(0);
					}
					break;
				case DEVICE_HEAT:
					if (!(DeviceId = NewHeat(NewDevice))) {
						SendResp(RESP_ADD_DEVICE_FAILED, NULL);
						return(0);
					}
					break;
				case DEVICE_SMOKE:
					if (!(DeviceId = NewSmoke(NewDevice))) {
						SendResp(RESP_ADD_DEVICE_FAILED, NULL);
						return(0);
					}
					break;
				case DEVICE_ALARM:
					if (!(DeviceId = NewGenericDevice(DeviceType, NewDevice))) {
						SendResp(RESP_ADD_DEVICE_FAILED, NULL);
						return(1);
					}
					break;
				default:
					SendResp(RESP_ADD_DEVICE_FAILED, NULL);
					break;
			}
			// Send success along with the generated DeviceId
			SendResp(RESP_SUCCESS, (unsigned char *)&DeviceId);
			break;	

		case CMD_DEL_DEVICE:
			// Read in the device id
			if (!ReadBytes((unsigned char *)&DeviceId, 2)) {
				return(0);
			}
			
			if (!DeleteDevice(DeviceId)) {
				SendResp(RESP_DEL_DEVICE_FAILED, NULL);
				return(1);
			}
			SendResp(RESP_SUCCESS, NULL);
			break;

		case CMD_GRANT_ACCESS:
			// Read in the device id
			if (!ReadBytes((unsigned char *)&DeviceId, 2)) {
				return(0);
			}
			
			// Read in the user id
			if (!ReadBytes((unsigned char *)&UserId, 1)) {
				return(0);
			}
			
			if (!GrantAccess(DeviceId, UserId)) {
				SendResp(RESP_GRANT_FAILED, NULL);
				return(1);
			}
			SendResp(RESP_SUCCESS, NULL);
			break;

		case CMD_UPDATE_DEVICE:
			// Read in the device id
			if (!ReadBytes((unsigned char *)&DeviceId, 2)) {
				return(0);
			}

			if (!UpdateDevice(DeviceId)) {
				SendResp(RESP_UPDATE_DEVICE_FAILED, NULL);
				return(1);
			}
			SendResp(RESP_SUCCESS, NULL);
			break;

		case CMD_ADD_DEVICE_TO_ALARM:
			// Read in the device id
			if (!ReadBytes((unsigned char *)&DeviceId, 2)) {
				return(0);
			}
			
			// Read in the alarm id
			if (!ReadBytes((unsigned char *)&AlarmId, 2)) {
				return(0);
			}

			if (!AddDeviceToAlarm(DeviceId, AlarmId)) {
				SendResp(RESP_ADD_DEVICE_TO_ALARM_FAILED, NULL);
				return(0);
			}

			SendResp(RESP_SUCCESS, NULL);
			break;

		case CMD_LIST_ALARM_CODES:
			// Read in the device id
			if (!ReadBytes((unsigned char *)&DeviceId, 2)) {
				return(0);
			}
			
			if (!ListValidAlarmCodes(DeviceId)) {
				SendResp(RESP_INVALID_CMD, NULL);
				return(0);
			}

			break;

		default:
			SendResp(RESP_INVALID_CMD, NULL);
			return(1);
			break;
	}

	return(1);
}