Example #1
0
	virtual void OnClientLogin() {
		// Associate client with the user/network
		CDevice *pDevice = DeviceForClient(*m_pClient);
		if (pDevice && m_pNetwork) {
			pDevice->AddNetwork(*m_pNetwork);
		}
	}
Example #2
0
	virtual void OnClientDisconnect() {
		CDevice *pDevice = DeviceForClient(*m_pClient);
		if (pDevice) {
			pDevice->SetInNegotiation(false);
			pDevice->RemoveClient(*m_pClient);
		}
	}
Example #3
0
void CRoom::OnAnyButton( UINT nID )
{
	CString deviceName;
	CString buttonText;
	int row = searchRowFromId(nID);
	GetDlgItem(nID)->GetWindowTextW(buttonText);
	GetDlgItem(2000 + row)->GetWindowTextW(deviceName);
	CDevice* tmpDevice = NULL;
	if(buttonText == _T("Details"))
	{
		POSITION pos;
		for (pos = phandleData->get_deviceList()->GetHeadPosition(); pos != NULL;)
		{	
			tmpDevice = ((CDevice*)phandleData->get_deviceList()->GetNext(pos));
			if(tmpDevice->get_name() == deviceName)
			{
				CDetailsDIM dlg;
				dlg.device = tmpDevice;
				dlg.phandleData = phandleData;
				dlg.DoModal();
			}
		}
		
	}
	else
	{
		if(buttonText == _T("An") || buttonText == _T("Auf"))
			phandleData->sendCommandtoFhem(deviceName, _T("on"));
		else if(buttonText == _T("Aus") || buttonText == _T("Ab"))
			phandleData->sendCommandtoFhem(deviceName, _T("off"));
	}
	//AfxMessageBox(buttonText + _T(" fรผr Gerรคt ") + deviceName);
}
Example #4
0
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	int wmId, wmEvent;
	PAINTSTRUCT ps;
	HDC hdc;
	static HANDLE hDrawThread = NULL;
	static HANDLE hAppThread = NULL;

	switch (message)
	{
	case WM_CHAR:
		if (wParam == VK_ESCAPE)
			PostQuitMessage(0);
		break;

	case WM_KEYDOWN:
		g_dev.OnKeyDown( (int)wParam );
		break;

	case WM_KEYUP:
		g_dev.OnKeyUp( (int)wParam );
		break;

	case WM_COMMAND:
		wmId    = LOWORD(wParam);
		wmEvent = HIWORD(wParam);
		break;

	case WM_PAINT:
		hdc = BeginPaint(hWnd, &ps);
		g_dev.Blit( hdc );
		EndPaint(hWnd, &ps);
		break;

	case WM_CREATE:
	{
		g_running = TRUE;
		hDrawThread = CreateThread( NULL, NULL, &ThreadProcDraw, NULL, NULL, NULL );
		hAppThread = CreateThread( NULL, NULL, &ThreadProcApp, NULL, NULL, NULL );
		break;
	}

	case WM_CLOSE:
		g_running = FALSE;
		Sleep(10);
		DestroyWindow(hWnd);
		break;

	case WM_DESTROY:
		TerminateThread( hDrawThread, 1 );
		TerminateThread( hAppThread, 1 );
		PostQuitMessage(0);
		break;

	default:
		return DefWindowProc(hWnd, message, wParam, lParam);
	}
	return 0;
}
CDevice* CDevice::NewL()
    {
    __MSFNSLOG
	CDevice* r = new (ELeave) CDevice();
	CleanupStack::PushL(r);

	r->ConstructL();
	CleanupStack::Pop();
	return r;
    }
Example #6
0
void MainChoice::openInfoWindow(){

    CDevice *device = new CDevice();

    device->setTheshold(0, 100);
    device->setTemperature(0, 100);
    device->setCurrentMode(3);
    infoSystem *is = new infoSystem();
    is->setDevice(device);
    is->refreshData();
    is->show();
    close();
}
Example #7
0
void CPlanet::Draw()
{
    CDevice* device = m_engine->GetDevice();
    float eyeDirH = m_engine->GetEyeDirH();
    float eyeDirV = m_engine->GetEyeDirV();

    Math::Vector n = Math::Vector(0.0f, 0.0f, -1.0f);  // normal
    float dp = 0.5f/256.0f;

    for (const auto& planet : m_planets)
    {
        if (planet.type != m_visibleType)
            continue;

        m_engine->SetTexture(planet.name);

        if (planet.transparent)
            m_engine->SetState(ENG_RSTATE_WRAP | ENG_RSTATE_ALPHA);
        else
            m_engine->SetState(ENG_RSTATE_WRAP | ENG_RSTATE_TTEXTURE_BLACK);

        Math::Point p1, p2;

        float a = eyeDirH + planet.angle.x;
        p1.x = Math::Mod(a, Math::PI*2.0f)-0.5f;

        a = eyeDirV + planet.angle.y;
        p1.y = 0.4f+(Math::Mod(a+Math::PI, Math::PI*2.0f)-Math::PI)*(2.0f/Math::PI);

        p1.x -= planet.dim/2.0f*0.75f;
        p1.y -= planet.dim/2.0f;
        p2.x = p1.x+planet.dim*0.75f;
        p2.y = p1.y+planet.dim;

        float u1 = planet.uv1.x + dp;
        float v1 = planet.uv1.y + dp;
        float u2 = planet.uv2.x - dp;
        float v2 = planet.uv2.y - dp;

        Vertex quad[4] =
        {
            Vertex(Math::Vector(p1.x, p1.y, 0.0f), n, Math::Point(u1, v2)),
            Vertex(Math::Vector(p1.x, p2.y, 0.0f), n, Math::Point(u1, v1)),
            Vertex(Math::Vector(p2.x, p1.y, 0.0f), n, Math::Point(u2, v2)),
            Vertex(Math::Vector(p2.x, p2.y, 0.0f), n, Math::Point(u2, v1))
        };

        device->DrawPrimitive(PRIMITIVE_TRIANGLE_STRIP, quad, 4);
        m_engine->AddStatisticTriangle(2);
    }
}
Example #8
0
void CPlanet::Draw()
{
    CDevice* device = m_engine->GetDevice();
    float eyeDirH = m_engine->GetEyeDirH();
    float eyeDirV = m_engine->GetEyeDirV();

    Math::Vector n = Math::Vector(0.0f, 0.0f, -1.0f);  // normal
    float dp = 0.5f/256.0f;

    for (int i = 0; i < static_cast<int>( m_planet[m_mode].size() ); i++)
    {
        m_engine->SetTexture("textures/"+m_planet[m_mode][i].name);

        if (m_planet[m_mode][i].transparent)
            m_engine->SetState(ENG_RSTATE_WRAP | ENG_RSTATE_ALPHA);
        else
            m_engine->SetState(ENG_RSTATE_WRAP | ENG_RSTATE_TTEXTURE_BLACK);

        Math::Point p1, p2;

        float a = eyeDirH + m_planet[m_mode][i].angle.x;
        p1.x = Math::Mod(a, Math::PI*2.0f)-0.5f;

        a = eyeDirV + m_planet[m_mode][i].angle.y;
        p1.y = 0.4f+(Math::Mod(a+Math::PI, Math::PI*2.0f)-Math::PI)*(2.0f/Math::PI);

        p1.x -= m_planet[m_mode][i].dim/2.0f*0.75f;
        p1.y -= m_planet[m_mode][i].dim/2.0f;
        p2.x = p1.x+m_planet[m_mode][i].dim*0.75f;
        p2.y = p1.y+m_planet[m_mode][i].dim;

        float u1 = m_planet[m_mode][i].uv1.x + dp;
        float v1 = m_planet[m_mode][i].uv1.y + dp;
        float u2 = m_planet[m_mode][i].uv2.x - dp;
        float v2 = m_planet[m_mode][i].uv2.y - dp;

        Vertex quad[4] =
        {
            Vertex(Math::Vector(p1.x, p1.y, 0.0f), n, Math::Point(u1, v2)),
            Vertex(Math::Vector(p1.x, p2.y, 0.0f), n, Math::Point(u1, v1)),
            Vertex(Math::Vector(p2.x, p1.y, 0.0f), n, Math::Point(u2, v2)),
            Vertex(Math::Vector(p2.x, p2.y, 0.0f), n, Math::Point(u2, v1))
        };

        device->DrawPrimitive(PRIMITIVE_TRIANGLE_STRIP, quad, 4);
        m_engine->AddStatisticTriangle(2);
    }
}
Example #9
0
		virtual uint update( float t )
		{
			for ( uint i=0; i<items.size(); i++ ) 
			{
				items[i].val = dev.getState( items[i].event, items[i].channel, items[i].key ); 
			}
			return 1;
		}
Example #10
0
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
//    MainWindow w;
//    w.show();
    
//    CDevice *device = new CDevice();



    QDir path;
    QLibrary lib("libusb-1.0.dll");

    if(!lib.load()){
        QMessageBox * msg = new QMessageBox();
        msg->setText("NO Lib");
        msg->show();
    }

    QTextCodec *utfcodec = QTextCodec::codecForName("cp1251");
    QTextCodec::setCodecForTr(utfcodec);
    QTextCodec::setCodecForCStrings(utfcodec);

    CDevice *device = new CDevice();

    device->setTheshold(0, 100);
    device->setTemperature(0, 100);
    device->setCurrentMode(3);
    infoSystem is;
    is.setDevice(device);
    is.refreshData();
    is.show();

//    device->setTheshold(0, 100);
//    device->setTemperature(0, 100);
//    device->setCurrentMode(3);
//    infoSystem is;
//    is.setDevice(device);
//    is.refreshData();
//    is.show();

    return a.exec();
}
Example #11
0
File: dsBios.cpp Project: 5rm/DS203
DWORD WINAPI ThreadProcDraw(HANDLE handle) 
{
	while ( !g_hwnd )
		Sleep( 10 );

	ShowWindow( g_hwnd, SW_SHOW );
	HDC hdc = GetDC( g_hwnd );

	while (g_running) 
	{
		g_dev.Blit( hdc );
		Sleep( 10 );
	}
	return 0;
}
Example #12
0
//
//  FUNCTION: WndProc(HWND, UINT, WPARAM, LPARAM)
//
//  PURPOSE:  Processes messages for the main window.
//
//  WM_COMMAND	- process the application menu
//  WM_PAINT	- Paint the main window
//  WM_DESTROY	- post a quit message and return
//
//
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	int wmId, wmEvent;
	PAINTSTRUCT ps;
	HDC hdc;

	switch (message)
	{
	case WM_CHAR:
		if (wParam == VK_ESCAPE)
			PostQuitMessage(0);
		break;
	case WM_KEYDOWN:
		dev.OnKey( (int)wParam );
		break;
	case WM_TIMER:
		InvalidateRect(hWnd, NULL, FALSE);
		break;
	case WM_COMMAND:
		wmId    = LOWORD(wParam);
		wmEvent = HIWORD(wParam);
		break;
	case WM_PAINT:
		hdc = BeginPaint(hWnd, &ps);
		dev.Blit( hdc );
		// TODO: Add any drawing code here...
		EndPaint(hWnd, &ps);
		break;
	case WM_DESTROY:
		PostQuitMessage(0);
		break;
	default:
		return DefWindowProc(hWnd, message, wParam, lParam);
	}
	return 0;
}
bool CDeviceXml::Deserialize(const TiXmlElement* pElement, CDevice& record)
{
  const char* name = pElement->Attribute(BUTTONMAP_XML_ATTR_DEVICE_NAME);
  if (!name)
  {
    esyslog("<%s> tag has no \"%s\" attribute", DEVICES_XML_ELEM_DEVICE, BUTTONMAP_XML_ATTR_DEVICE_NAME);
    return false;
  }
  record.SetName(name);

  const char* provider = pElement->Attribute(BUTTONMAP_XML_ATTR_DEVICE_PROVIDER);
  if (!provider)
  {
    esyslog("<%s> tag has no \"%s\" attribute", DEVICES_XML_ELEM_DEVICE, BUTTONMAP_XML_ATTR_DEVICE_PROVIDER);
    return false;
  }
  record.SetProvider(provider);

  const char* vid = pElement->Attribute(BUTTONMAP_XML_ATTR_DEVICE_VID);
  if (vid)
    record.SetVendorID(CStorageUtils::HexStringToInt(vid));

  const char* pid = pElement->Attribute(BUTTONMAP_XML_ATTR_DEVICE_PID);
  if (pid)
    record.SetProductID(CStorageUtils::HexStringToInt(pid));

  const char* buttonCount = pElement->Attribute(BUTTONMAP_XML_ATTR_DEVICE_BUTTONCOUNT);
  if (buttonCount)
    record.SetButtonCount(std::atoi(buttonCount));

  const char* hatCount = pElement->Attribute(BUTTONMAP_XML_ATTR_DEVICE_HATCOUNT);
  if (hatCount)
    record.SetHatCount(std::atoi(hatCount));

  const char* axisCount = pElement->Attribute(BUTTONMAP_XML_ATTR_DEVICE_AXISCOUNT);
  if (axisCount)
    record.SetAxisCount(std::atoi(axisCount));

  const char* index = pElement->Attribute(BUTTONMAP_XML_ATTR_DEVICE_INDEX);
  if (index)
    record.SetIndex(std::atoi(index));

  return true;
}
Example #14
0
int update_v1()
{
	char str[1024];
	int required_build, required_version;
	uint32_t required_crc32;

	required_build = detect_firmware_build((uint8_t*)firmware, firmware_length);
	required_version = detect_bootloader_version((uint8_t*)bootloader, bootloader_length);
	required_crc32 = bootloader_get_crc32((uint8_t*)bootloader, bootloader_length);

	//check firmware version
	if (fdsemu->dev->Version < required_build) {
		sprintf(str, "Firmware is outdated, the required minimum version is %d\n\nUpgrading will take about 5 seconds.\n\nPress OK to upgrade, press Cancel to quit.", required_build);
		if (MessageBox(0, str, "FDSemu", MB_OKCANCEL) != IDOK) {
			delete fdsemu;
			return(0);
		}
		if (upload_firmware(firmware, firmware_length, 0) == false) {
			MessageBox(0, "Error updating firmware.", "FDSemu", MB_OK);
			delete fdsemu;
			return(0);
		}
	}

	//check bootloader version
	uint32_t bootcrc32 = dev.VerifyBootloader();
	if (bootcrc32 != required_crc32) {
		sprintf(str, "Bootloader is outdated (current version is %08X, required is %08X)\n\nUpgrading will take about 2 seconds.\n\nPress OK to upgrade, press Cancel to quit.", bootcrc32, required_crc32);
		if (MessageBox(0, str, "FDSemu", MB_OKCANCEL) != IDOK) {
			delete fdsemu;
			return(0);
		}
		if (upload_bootloader(bootloader, bootloader_length) == false) {
			MessageBox(0, "Error updating bootloader.", "FDSemu", MB_OK);
			delete fdsemu;
			return(0);
		}
	}
	return(1);
}
Example #15
0
void CCloud::Draw()
{
    if (! m_enabled) return;
    if (m_level == 0.0f) return;
    if (m_lines.empty()) return;

    std::vector<VertexTex2> vertices((m_brickCount+2)*2, VertexTex2());

    float iDeep = m_engine->GetDeepView();
    float deep = (m_brickCount*m_brickSize)/2.0f;
    m_engine->SetDeepView(deep);
    m_engine->SetFocus(m_engine->GetFocus());
    m_engine->UpdateMatProj();  // increases the depth of view

    float fogStart = deep*0.15f;
    float fogEnd   = deep*0.24f;

    CDevice* device = m_engine->GetDevice();

    // TODO: do this better?
    device->SetFogParams(FOG_LINEAR, m_engine->GetFogColor( m_engine->GetRankView() ),
                        fogStart, fogEnd, 1.0f);

    device->SetTransform(TRANSFORM_VIEW, m_engine->GetMatView());

    Material material;
    material.diffuse = m_diffuse;
    material.ambient = m_ambient;
    m_engine->SetMaterial(material);

    m_engine->SetTexture(m_fileName, 0);
    m_engine->SetTexture(m_fileName, 1);

    m_engine->SetState(ENG_RSTATE_TTEXTURE_BLACK | ENG_RSTATE_FOG | ENG_RSTATE_WRAP);

    Math::Matrix matrix;
    matrix.LoadIdentity();
    device->SetTransform(TRANSFORM_WORLD, matrix);

    float size = m_brickSize/2.0f;
    Math::Vector eye = m_engine->GetEyePt();
    Math::Vector n = Math::Vector(0.0f, -1.0f, 0.0f);

    // Draws all the lines
    for (int i = 0; i < static_cast<int>( m_lines.size() ); i++)
    {
        Math::Vector pos;
        pos.y = m_level;
        pos.z = m_lines[i].pz;
        pos.x = m_lines[i].px1;

        int vertexIndex = 0;

        Math::Vector p;
        Math::Point uv1, uv2;

        p.x = pos.x-size;
        p.z = pos.z+size;
        p.y = pos.y;
        AdjustLevel(p, eye, deep, uv1, uv2);
        vertices[vertexIndex++] = VertexTex2(p, n, uv1, uv2);

        p.x = pos.x-size;
        p.z = pos.z-size;
        p.y = pos.y;
        AdjustLevel(p, eye, deep, uv1, uv2);
        vertices[vertexIndex++] = VertexTex2(p, n, uv1, uv2);

        for (int j = 0; j < m_lines[i].len; j++)
        {
            p.x = pos.x+size;
            p.z = pos.z+size;
            p.y = pos.y;
            AdjustLevel(p, eye, deep, uv1, uv2);
            vertices[vertexIndex++] = VertexTex2(p, n, uv1, uv2);

            p.x = pos.x+size;
            p.z = pos.z-size;
            p.y = pos.y;
            AdjustLevel(p, eye, deep, uv1, uv2);
            vertices[vertexIndex++] = VertexTex2(p, n, uv1, uv2);

            pos.x += size*2.0f;
        }

        device->DrawPrimitive(PRIMITIVE_TRIANGLE_STRIP, &vertices[0], vertexIndex);
        m_engine->AddStatisticTriangle(vertexIndex - 2);
    }

    m_engine->SetDeepView(iDeep);
    m_engine->SetFocus(m_engine->GetFocus());
    m_engine->UpdateMatProj();  // gives depth to initial
}
Example #16
0
void CLightning::Draw()
{
    if (!m_lightningExists) return;
    if (m_phase != LP_FLASH) return;

    CDevice* device = m_engine->GetDevice();

    Math::Matrix mat;
    mat.LoadIdentity();
    device->SetTransform(TRANSFORM_WORLD, mat);

    m_engine->SetTexture("effect00.png");
    m_engine->SetState(ENG_RSTATE_TTEXTURE_BLACK);

    Math::Point texInf;
    texInf.x = 64.5f/256.0f;
    texInf.y = 33.0f/256.0f;
    Math::Point texSup;
    texSup.x = 95.5f/256.0f;
    texSup.y = 34.0f/256.0f;  // blank

    Math::Vector p1 = m_pos;
    Math::Vector eye = m_engine->GetEyePt();
    float a = Math::RotateAngle(eye.x-p1.x, eye.z-p1.z);
    Math::Vector n = Math::Normalize(p1-eye);

    Math::Vector corner[4];
    Vertex vertex[4];

    for (int i = 0; i < FLASH_SEGMENTS-1; i++)
    {
        Math::Vector p2 = p1;
        p2.y += 8.0f+0.2f*i;

        Math::Point rot;

        Math::Vector p = p1;
        p.x += m_width[i];
        rot = Math::RotatePoint(Math::Point(p1.x, p1.z), a+Math::PI/2.0f, Math::Point(p.x, p.z));
        corner[0].x = rot.x+m_shift[i].x;
        corner[0].y = p1.y;
        corner[0].z = rot.y+m_shift[i].y;
        rot = Math::RotatePoint(Math::Point(p1.x, p1.z), a-Math::PI/2.0f, Math::Point(p.x, p.z));
        corner[1].x = rot.x+m_shift[i].x;
        corner[1].y = p1.y;
        corner[1].z = rot.y+m_shift[i].y;

        p = p2;
        p.x += m_width[i+1];
        rot = Math::RotatePoint(Math::Point(p2.x, p2.z), a+Math::PI/2.0f, Math::Point(p.x, p.z));
        corner[2].x = rot.x+m_shift[i+1].x;
        corner[2].y = p2.y;
        corner[2].z = rot.y+m_shift[i+1].y;
        rot = Math::RotatePoint(Math::Point(p2.x, p2.z), a-Math::PI/2.0f, Math::Point(p.x, p.z));
        corner[3].x = rot.x+m_shift[i+1].x;
        corner[3].y = p2.y;
        corner[3].z = rot.y+m_shift[i+1].y;

        if (p2.y < p1.y)
        {
            vertex[0] = Vertex(corner[1], n, Math::Point(texSup.x, texSup.y));
            vertex[1] = Vertex(corner[0], n, Math::Point(texInf.x, texSup.y));
            vertex[2] = Vertex(corner[3], n, Math::Point(texSup.x, texInf.y));
            vertex[3] = Vertex(corner[2], n, Math::Point(texInf.x, texInf.y));
        }
        else
        {
            vertex[0] = Vertex(corner[0], n, Math::Point(texSup.x, texSup.y));
            vertex[1] = Vertex(corner[1], n, Math::Point(texInf.x, texSup.y));
            vertex[2] = Vertex(corner[2], n, Math::Point(texSup.x, texInf.y));
            vertex[3] = Vertex(corner[3], n, Math::Point(texInf.x, texInf.y));
        }

        device->DrawPrimitive(PRIMITIVE_TRIANGLE_STRIP, vertex, 4);
        m_engine->AddStatisticTriangle(2);

        p1 = p2;
    }
}
Example #17
0
QVariant CEnvironmentDetailsModel::data(const QModelIndex & index, int role) const {
    if (!m_Environment || (!index.isValid()))
        return QVariant();

    if ((role == Qt::DecorationRole) && (index.column() == ENVDET_MOD_STATEMENT)) {
        CDevice * device = qobject_cast<CDevice *>(m_Environment->parent());
        if (m_Environment == device->getActiveEnvironment()) {
            if ((qint8)(m_Environment->getSelectResults()[index.internalId()]))
                return QIcon(UI_ICON_SELECTED);
        }
        return QIcon(UI_ICON_UNSELECTED);
    }

    if (role != Qt::DisplayRole)
        return QVariant();

    switch (index.column()) {
    case ENVDET_MOD_STATEMENT:
        if (m_SelectConfig.filters[index.internalId()].invert)
            switch (m_SelectConfig.filters[index.internalId()].selType) {
            case SelectType::USER:
                return tr("not by user");
            case SelectType::ARP:
                return tr("not by arp");
            case SelectType::ESSID:
                return tr("not by ssid");
            case SelectType::AND_BLOCK:
                return tr("at least one not");
            case SelectType::OR_BLOCK:
                return tr("all not");
            default:
                break;
            }
        else
            switch (m_SelectConfig.filters[index.internalId()].selType) {
            case SelectType::USER:
                return tr("by user");
            case SelectType::ARP:
                return tr("by arp");
            case SelectType::ESSID:
                return tr("by ssid");
            case SelectType::AND_BLOCK:
                return tr("all");
            case SelectType::OR_BLOCK:
                return tr("at least one");
            default:
                break;
            }
    case ENVDET_MOD_VALUE:
        switch (m_SelectConfig.filters[index.internalId()].selType) {
        case SelectType::ARP:
            if (m_SelectConfig.filters[index.internalId()].macAddr.valid())
                return m_SelectConfig.filters[index.internalId()].ipAddr.toString() + ", "+
                       m_SelectConfig.filters[index.internalId()].macAddr.toString();
            else
                return m_SelectConfig.filters[index.internalId()].ipAddr.toString();
        case SelectType::ESSID:
            return m_SelectConfig.filters[index.internalId()].essid;
        default:
            break;
        }
    default:
        break;
    }

    return QVariant();
}
Example #18
0
	void HandleListCommand(const CString &sLine) {
		if (m_pUser->IsAdmin() == false) {
			PutModule("Permission denied");
			return;
		}

		CTable Table;

		Table.AddColumn("Device");
		Table.AddColumn("User");
		Table.AddColumn("Network");
		Table.AddColumn("Negotiating");

		for (std::vector<CDevice*>::const_iterator it = m_vDevices.begin();
				it != m_vDevices.end(); ++it)
		{
			CDevice &device = **it;

			const std::map<CString, VCString> msvsNetworks = device.GetNetworks();
			std::map<CString, VCString>::const_iterator it2 = msvsNetworks.begin();
			for (;it2 != msvsNetworks.end(); ++it2) {
				const CString sUsername = it2->first;
				const VCString &networks = it2->second;

				for (VCString::const_iterator it3 = networks.begin(); it3 != networks.end(); ++it3) {
					const CString sNetwork = *it3;

					Table.AddRow();
					Table.SetCell("Device", device.GetToken());
					Table.SetCell("User", sUsername);
					Table.SetCell("Network", sNetwork);
					Table.SetCell("Negotiating", CString(device.InNegotiation()));
				}

				if (networks.size() == 0) {
					Table.SetCell("Device", device.GetToken());
					Table.SetCell("User", sUsername);
					Table.SetCell("Network", "");
					Table.SetCell("Negotiating", CString(device.InNegotiation()));
				}
			}

			if (msvsNetworks.size() == 0) {
				Table.SetCell("Device", device.GetToken());
				Table.SetCell("User", "");
				Table.SetCell("Network", "");
				Table.SetCell("Negotiating", CString(device.InNegotiation()));
			}
		}

		if (PutModule(Table) == 0) {
			PutModule("There are no devices registered with this server.");
		}

		CDevice *pDevice = DeviceForClient(*m_pClient);
		if (pDevice) {
			PutModule("You are connected from Palaver. (" + pDevice->GetToken() + ")");
		} else {
			PutModule("You are not connected from a Palaver client.");
		}
	}
Example #19
0
	virtual EModRet HandleUserRaw(CClient* pClient, CString& sLine) {
		if (sLine.Token(0).Equals(kPLVCommand)) {
			CString sCommand = sLine.Token(1);

			if (sCommand.Equals("BACKGROUND")) {
				m_pClient->SetAway(true);
			} else if (sCommand.Equals("FOREGROUND")) {
				m_pClient->SetAway(false);
			} else if (sCommand.Equals("IDENTIFY")) {
				CDevice *pDevice = DeviceForClient(*pClient);
				if (pDevice) {
					pDevice->RemoveClient(*pClient);
				}

				CString sToken = sLine.Token(2);
				CString sVersion = sLine.Token(3);

				CDevice& device = DeviceWithToken(sToken);

				if (device.InNegotiation() == false && device.GetVersion().Equals(sVersion) == false) {
					pClient->PutClient("PALAVER REQ *");
					device.SetInNegotiation(true);
				}

				device.AddClient(*pClient);

				if (m_pNetwork) {
					device.AddNetwork(*m_pNetwork);
				}
			} else if (sCommand.Equals("BEGIN")) {
				CString sToken = sLine.Token(2);
				CString sVersion = sLine.Token(3);
				CDevice& device = DeviceWithToken(sToken);

				device.ResetDevice();
				device.SetInNegotiation(true);
				device.SetVersion(sVersion);

				device.AddClient(*pClient);
			} else if (sCommand.Equals("END")) {
				CDevice *pDevice = DeviceForClient(*pClient);

				if (pDevice) {
					pDevice->SetInNegotiation(false);
				}
			} else if (sCommand.Equals("SET")) {
				CString sKey = sLine.Token(2);
				CString sValue = sLine.Token(3, true);

				CDevice *pDevice = DeviceForClient(*pClient);

				if (pDevice) {
					if (sKey.Equals("VERSION")) {
						pDevice->SetVersion(sValue);
					} else if (sKey.Equals(kPLVPushEndpointKey)) {
						pDevice->SetPushEndpoint(sValue);
					}
				}
			} else if (sCommand.Equals("ADD")) {
				CString sKey = sLine.Token(2);
				CString sValue = sLine.Token(3, true);

				CDevice *pDevice = DeviceForClient(*pClient);

				if (pDevice) {
					if (sKey.Equals(kPLVIgnoreKeywordKey)) {
						pDevice->AddIgnoreKeyword(sValue);
					} else if (sKey.Equals(kPLVIgnoreChannelKey)) {
						pDevice->AddIgnoreChannel(sValue);
					} else if (sKey.Equals(kPLVIgnoreNickKey)) {
						pDevice->AddIgnoreNick(sValue);
					} else if (sKey.Equals(kPLVMentionKeywordKey)) {
						pDevice->AddMentionKeyword(sValue);
					} else if (sKey.Equals(kPLVMentionChannelKey)) {
						pDevice->AddMentionChannel(sValue);
					} else if (sKey.Equals(kPLVMentionNickKey)) {
						pDevice->AddMentionNick(sValue);
					}
				}
			}

			return HALT;
		}

		return CONTINUE;
	}
bool CDeviceXml::Serialize(const CDevice& record, TiXmlElement* pElement)
{
  pElement->SetAttribute(BUTTONMAP_XML_ATTR_DEVICE_NAME, record.Name());
  pElement->SetAttribute(BUTTONMAP_XML_ATTR_DEVICE_PROVIDER, record.Provider());
  if (record.IsVidPidKnown())
  {
    pElement->SetAttribute(BUTTONMAP_XML_ATTR_DEVICE_VID, CStorageUtils::FormatHexString(record.VendorID()));
    pElement->SetAttribute(BUTTONMAP_XML_ATTR_DEVICE_PID, CStorageUtils::FormatHexString(record.ProductID()));
  }
  if (record.ButtonCount() != 0)
    pElement->SetAttribute(BUTTONMAP_XML_ATTR_DEVICE_BUTTONCOUNT, record.ButtonCount());
  if (record.HatCount() != 0)
    pElement->SetAttribute(BUTTONMAP_XML_ATTR_DEVICE_HATCOUNT, record.HatCount());
  if (record.AxisCount() != 0)
    pElement->SetAttribute(BUTTONMAP_XML_ATTR_DEVICE_AXISCOUNT, record.AxisCount());
  if (record.Index() != 0)
    pElement->SetAttribute(BUTTONMAP_XML_ATTR_DEVICE_INDEX, record.Index());
  return true;
}
Example #21
0
bool AppDelegate::applicationDidFinishLaunching()
{

    CDevice *pDevice = CDevice::sharedDevice();
    pDevice->setDeviceSupportOrientation(LandscapeLeft|LandscapeRight);

    // initialize director
    CCDirector *pDirector = CCDirector::sharedDirector();
    CCEGLView *pOpenGLView = CCEGLView::sharedOpenGLView();
    pDirector->setOpenGLView(pOpenGLView);

    CApplication *pApp = CApplication::sharedApplication();
    const char *lpcszResourcePath = pApp->getResourcePath();
    // adapter any size

    CCSize deviceScreenSize = pDirector->getWinSize();
    float fHeight = deviceScreenSize.height;
    float fRatio = deviceScreenSize.width / fHeight;


    if( !pDevice->isPad() )     //640
    {
        fHeight = 640.0f;
        pDevice->setCodeSizeRatio(1.0f);

        std::vector<std::string> searchPaths;
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID )
        char szSearchPath[1024];
        sprintf(szSearchPath,"%s%s", lpcszResourcePath, "Image@640/");
        searchPaths.push_back(szSearchPath);
        sprintf(szSearchPath,"%s060/%s", lpcszResourcePath, "Image@640/");
        searchPaths.push_back(szSearchPath);
        searchPaths.push_back(lpcszResourcePath);
        searchPaths.push_back("Image@640/");
        searchPaths.push_back("");
#elif (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
        char szSearchPath[1024];
        sprintf(szSearchPath,"%s%s", lpcszResourcePath, "Image@640/");
        searchPaths.push_back(szSearchPath);
        sprintf(szSearchPath,"%s060/%s", lpcszResourcePath, "Image@640/");
        searchPaths.push_back(szSearchPath);
        searchPaths.push_back(lpcszResourcePath);
        searchPaths.push_back("Image@640/");
        searchPaths.push_back("");
#endif
        CCFileUtils::sharedFileUtils()->setSearchPaths(searchPaths);
    }
    else    //768
    {
        fHeight = 768.0f;
        pDevice->setCodeSizeRatio(1.2f);

        std::vector<std::string> searchPaths;
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID )
        char szSearchPath[1024];
        sprintf(szSearchPath,"%s%s", pApp->getResourcePath(), "Image@768/");
        searchPaths.push_back(szSearchPath);
        sprintf(szSearchPath,"%s060/%s", pApp->getResourcePath(), "Image@768/");
        searchPaths.push_back(szSearchPath);
        searchPaths.push_back(lpcszResourcePath);
        searchPaths.push_back("Image@768/");
        searchPaths.push_back("");
#elif (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
        char szSearchPath[1024];
        sprintf(szSearchPath,"%s%s", pApp->getResourcePath(), "Image@768/");
        searchPaths.push_back(szSearchPath);
        sprintf(szSearchPath,"%s060/%s", pApp->getResourcePath(), "Image@768/");
        searchPaths.push_back(szSearchPath);
        searchPaths.push_back(lpcszResourcePath);
        searchPaths.push_back("Image@768/");
        searchPaths.push_back("");
#endif
        CCFileUtils::sharedFileUtils()->setSearchPaths(searchPaths);
    }

    //

    CCLOG("search path begin");
    for(std::vector<std::string>::const_iterator it = CCFileUtils::sharedFileUtils()->getSearchPaths().begin();
        it != CCFileUtils::sharedFileUtils()->getSearchPaths().end(); it++)
    {
        CCLOG("%s", (*it).c_str() );
    }
    CCLOG("search path end");

    //
    pOpenGLView->setDesignResolutionSize((fHeight * fRatio), fHeight, kResolutionShowAll);

    //
    // turn on display FPS
    pDirector->setDisplayStats(false);

    // set FPS. the default value is 1.0/60 if you don't call this
    pDirector->setAnimationInterval(1.0 / 60);



    //ptola::CDevice *pDevice = ptola::CDevice::sharedDevice();
    //CCSize s = pDevice->getScreenSize();
    // register lua engine
    CCLuaEngine* pEngine = CCLuaEngine::defaultEngine();
    CCScriptEngineManager::sharedManager()->setScriptEngine(pEngine);
    ptola::script::CLuaClassSupport::initialize(pEngine);


    ///sdk request&&http request begin
    //////////////////////////////////////////////
//    รท;
    //////////////////////////////////////////////

    //    CCScene *pScene = CCScene::create();
//    HttpClientTest *pLayer = new HttpClientTest();
//    pScene->addChild(pLayer);
//    pDirector->runWithScene(pScene);

//    CCScene *pScene = TestScene::scene();
//    pDirector->runWithScene(pScene);

//    CCScene *pScene = CLoginScene::scene();
//    pDirector->runWithScene(pScene);

//    CCScene *pSdkScene = C553_SDK::scene();
//    pDirector->runWithScene(pSdkScene);

    //IAPP_IOS_IAP iap;

//    CAPP_IOS_IAP cap;
//    cap.initialize(NULL);
    
    CCScene *pScene = CCScene::create();
    CCDirector::sharedDirector()->runWithScene(pScene);
    
    
    char vedioName[64] = "piantou.mp4";
    VideoPlatform::playVedio(vedioName);
    
    return true;
}
Example #22
0
int main(int argc, char **argv)
{
    if (argc != 2)
    {    
        printf("Usage: %s [video device index]\n", argv[0]);
        return 0;
    }

    gtk_init(&argc, &argv);

	if (atoi(argv[1]) < 0)
	{
		ScreenDevice dev;
		dev.Init(1);
        CGui gui(dev);
        gui.CreateWindow();
        return 0;
	}

    CamAbstractionLayerV4L cam;
   	cam.Init(atoi(argv[1]));

    CDevice *pDevice = cam.GetDevice();

    if (!pDevice)
    {    
        printf("Cannot get device!\n");
        return 0;
    }

    std::string deviceName = pDevice->GetDevId();
    printf("device: %s selected\n", deviceName.c_str());

    printDevCapabilities(deviceName);

    std::deque<DeviceInput> inputList;
    cam.GetInputList(inputList);

    printf("\n");
    printf("This device has %u inputs\n", inputList.size());
    printf("\n");
    
    for (int index=0; index<inputList.size(); index++)     
        printf("index: %u - name: %s\n", inputList[index].index, inputList[index].name.c_str());   
    
    printf("\n");
    int selectedInput = 0;

    if (inputList.size() > 1)
    {
        printf("\n");
        char szInput[10];

        printf("\n");
        printf("Choose input:\n");
        printf("\n");  
        printf("Input: ");  scanf("%s", szInput);
    
        selectedInput = atoi(szInput);
        cam.SelectInput(selectedInput);
    }

    printf("\"%s\" selected\n", inputList[selectedInput].name.c_str());

    std::deque<PixFmt> pixFmtList;
    std::deque<FrameDimension> dimensionList; 
        
    std::string pixFmtDesc;

    pDevice->GetSupportedPixelFmt(pixFmtList);
    printf("\n");
    printf("This device supports %u types of pixel format\n", pixFmtList.size());    
    printf("We list them below:\n");
    printf("\n");

    unsigned uMenuItem = 0;

    for (unsigned i=0; i < pixFmtList.size(); i++)
    {
        pDevice->GetSupportedDimensions(pixFmtList[i], dimensionList);
        GetPixFmtDesc(pixFmtList[i], pixFmtDesc);         

        for (unsigned j=0; j < dimensionList.size(); j++)    
            printf("%u. %s - %ux%u\n", ++uMenuItem, pixFmtDesc.c_str(), dimensionList[j].uWidth, dimensionList[j].uHeight);
            
        printf("\n");
    }

    unsigned standardsCount=0;
    cam.GetAnagStdCount(standardsCount);

    printf("\n");
    printf("This device has %u standards\n", standardsCount);
    printf("\n");

    if (standardsCount)
    {
        int stdCounter=0;
        std::deque<AnagVideoStd> allAvailableStds;

        for (int i=0; i<standardsCount; i++)
        {
            printf("Index: %u\n", i);

            std::deque<AnagVideoStd> videoStdList;         
            cam.EnumAnagStd(i, videoStdList);

            for (int j=0; j<videoStdList.size(); j++)
            {    
                printf("%u -", stdCounter);            
                printStandardInfo(videoStdList[j]);
                allAvailableStds.push_back(videoStdList[j]);
                stdCounter++;
            }
            printf("\n");
        }

        unsigned selectedStd=0;
        char szSelectedStd[10];
        printf("\n");
        printf("Choose analog video format: (0 - %u)\n", stdCounter-1);
        printf("\n");
        printf("Format: "); scanf("%s", szSelectedStd);
 
        selectedStd = atoi(szSelectedStd);

        printf("You selected: ");
        printStandardInfo(allAvailableStds[selectedStd]);
        printf("\n");

        cam.SelectAnagStd(allAvailableStds[selectedStd]);
    }

    char szWidth[10],
         szHeight[10];

    unsigned uWidth  = 0,
             uHeight = 0;

    printf("\n");
    printf("Choose capture frame dimensions:\n");
    printf("\n");
  
    printf("Width: ");  scanf("%s", szWidth);
    printf("Height: "); scanf("%s", szHeight);

    uWidth  = atoi(szWidth);
    uHeight = atoi(szHeight);

    if ( (uWidth > 0) && (uWidth < MAX_FRAME_DIMENSION) && (uHeight > 0) && (uHeight < MAX_FRAME_DIMENSION))
    {
        cam.SelectFormat(uWidth, uHeight, RGB24);
        cam.StartCapture();

        CGui gui(cam);
        gui.CreateWindow();
    
        cam.StopCapture();
        cam.Close();
    }
    else
        printf("Error: Width and Height should be in range 0 - %u\n", MAX_FRAME_DIMENSION);

    return 0;
}
Example #23
0
void CRoom::draw()
{
	POSITION pos;
	CButton* Button;
	CStatic* staticText;
	CString btnText[2];
	CDevice* tmpDevice;
	int top = 10;
	int bottom = 30;
	int i = 0;
	int countButtonID = 3001;
	int countStaticID = 2001;
	CObList* list = phandleData->get_deviceList();
	for (pos = list->GetHeadPosition(); pos != NULL;)
	{	
		tmpDevice = (CDevice*)list->GetNext(pos);
		if(tmpDevice->get_room() != room)
			continue;
		if(tmpDevice->get_typ() == _T("fs20rsu"))
		{
			btnText[0] = _T("Auf");
			btnText[1] = _T("Ab");
		}
		else
		{
			btnText[0] = _T("An");
			btnText[1] = _T("Aus");
		}
		staticText = new CStatic();
		DWORD dwStyleStatic  = WS_EX_STATICEDGE;
		staticText->Create(tmpDevice->get_name(),dwStyleStatic,CRect(10,top,260,bottom),this,countStaticID);
		staticText->ShowWindow(TRUE);

		Button = new CButton();
		DWORD dwStyle = WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON;
		Button->Create(btnText[0], dwStyle, CRect(300,top,340,bottom), this, countButtonID);
		Button->ShowWindow(TRUE);
		Button = NULL;
		buttonIDs[i][i] = countButtonID;
		countButtonID++;

		Button = new CButton();
		Button->Create(btnText[1], dwStyle, CRect(360,top,400,bottom), this, countButtonID);
		Button->ShowWindow(TRUE);
		Button = NULL;
		buttonIDs[i][i+1] = countButtonID;
		countButtonID++;

		Button = new CButton();
		Button->Create(_T("Details"), dwStyle, CRect(420,top,480,bottom), this, countButtonID);
		Button->ShowWindow(TRUE);
		Button = NULL;
		buttonIDs[i][i+2] = countButtonID;

		top += 30;
		bottom += 30;
		staticText = NULL;
		countButtonID++;
		countStaticID++;
		i++;
	}
}
Example #24
0
		CMidiInput() 
		{
			unique("MidiInput");
			dev.init(0);
		}