예제 #1
0
HRESULT hsGDirect3DTnLEnumerate::D3DEnum_SelectDefaultMode(int width, int height, int depth)
{
    hsAssert(GetCurrentDriver() && GetCurrentDevice(), "Must have selected device already");

    BOOL windowed = false;
    if (depth == 0)
    {
        // Legacy code writes out 0 bit depth to mean windowed
        windowed = true;
        depth = 32;
    }

    D3DEnum_DeviceInfo* device = GetCurrentDevice();
    int i;
    for( i = 0; i < device->fModes.GetCount(); i++ )
    {
        D3DEnum_ModeInfo* mode = &device->fModes[i];
        if (mode->fWindowed != windowed)
            continue;

        if( depth )
        {
            if( width < mode->fDDmode.Width )
                continue;
            if( height < mode->fDDmode.Height )
                continue;
        }
        if( depth < mode->fBitDepth )
            continue;

        if( GetCurrentMode() )
        {
            D3DEnum_ModeInfo* curMode = GetCurrentDriver()->fCurrentMode;
            if( depth )
            {
                if( curMode->fDDmode.Width > mode->fDDmode.Width )
                    continue;
                if( curMode->fDDmode.Height > mode->fDDmode.Height )
                    continue;
            }
            if( curMode->fBitDepth > mode->fBitDepth )
                continue;

        }

        SetCurrentMode(mode);
    }
    return S_OK;
}
예제 #2
0
//---------------------------------------------------------------------------
void __fastcall TFrDeviceExplorer::btnWriteClick(TObject *Sender)
{
	TBluetoothLEDevice * ADevice = NULL;
	ADevice = GetCurrentDevice();
	if(ADevice != NULL) {
		TBluetoothGattService * AService = ADevice->Services->Items[CurrentService];
		TBluetoothGattCharacteristic * AChar = AService->Characteristics->Items[CurrentCharacteristic];
		if((AChar->Properties.Contains(TBluetoothProperty::Write)) || (AChar->Properties.Contains(TBluetoothProperty::WriteNoResponse))
			|| (AChar->Properties.Contains(TBluetoothProperty::SignedWrite)))
		{
			if(CbWriteTypes->ItemIndex ==  0) AChar->SetValueAsString(EdCharacWrite->Text);
			if(CbWriteTypes->ItemIndex ==  1) AChar->SetValueAsString(EdCharacWrite->Text, false);
			if(CbWriteTypes->ItemIndex ==  2) AChar->SetValueAsUInt8(UInt8(StrToInt(EdCharacWrite->Text)));
			if(CbWriteTypes->ItemIndex ==  3) AChar->SetValueAsUInt16(UInt16(StrToInt(EdCharacWrite->Text)));
			if(CbWriteTypes->ItemIndex ==  4) AChar->SetValueAsUInt32(UInt32(StrToInt(EdCharacWrite->Text)));
			if(CbWriteTypes->ItemIndex ==  5) AChar->SetValueAsUInt64(StrToInt(EdCharacWrite->Text));
			if(CbWriteTypes->ItemIndex ==  6) AChar->SetValueAsInt8(Int8(StrToInt(EdCharacWrite->Text)));
			if(CbWriteTypes->ItemIndex ==  7) AChar->SetValueAsInt16(Int16(StrToInt(EdCharacWrite->Text)));
			if(CbWriteTypes->ItemIndex ==  8) AChar->SetValueAsInt32(Int32(StrToInt(EdCharacWrite->Text)));
			if(CbWriteTypes->ItemIndex ==  9) AChar->SetValueAsInt64(StrToInt(EdCharacWrite->Text));
			if(CbWriteTypes->ItemIndex == 10) AChar->SetValueAsDouble(StrToFloat(EdCharacWrite->Text));
			if(CbWriteTypes->ItemIndex == 11) AChar->SetValueAsSingle(StrToFloat(EdCharacWrite->Text));
			ADevice->WriteCharacteristic(AChar);
		}
		else {
			ShowMessage("This characteristic doesn''t allow Write");
        }
	}
	else {
		ShowMessage(EdCurrentDevice->Text + " is not available");
	}
}
예제 #3
0
//---------------------------------------------------------------------------
void __fastcall TFrDeviceExplorer::btnGetValuesClick(TObject *Sender)
{
	TBluetoothLEDevice * ADevice;
	TBluetoothGattCharacteristic * AChar;
	TBluetoothGattService * AService;
	TBluetoothGattCharacteristicList * CharList;
	if(TvCharacteristics->Count > 0) {
		ADevice = GetCurrentDevice();
		if(ADevice != NULL) {
			ADevice->OnCharacteristicRead = DidCharacteristicRead;
			for(int i = 0; i < ADevice->Services->Count; i++) {
				AChar = NULL;
				AService = ADevice->Services->Items[i];
				CharList = AService->Characteristics;
				for(int j = 0; j < CharList->Count; j++) {
					AChar = CharList->Items[j];
					if ((AChar->Properties.Contains(TBluetoothProperty::Read)) ||
						(AChar->Properties.Contains(TBluetoothProperty::Notify))) {
                        ADevice->ReadCharacteristic(AChar);
                    }
                }
            }
		}
	}
	else {
        ShowMessage(EdCurrentDevice->Text + " is not available");
    }
}
예제 #4
0
bool DataManager::HasRecord(std::wstring recordType)
{
	if ( L"" == GetCurrentDevice() )
		return true;

	return GetRecordCount(recordType) != 0;
}
예제 #5
0
bool
BL_CDEngine::IsDeviceOpened()
{
  if (GetCurrentDevice() < 0) {
    return FALSE;
  } else {
    return TRUE;
  }
}
예제 #6
0
//---------------------------------------------------------------------------
void __fastcall TFrDeviceExplorer::CornerButton3Click(TObject *Sender)
{
	TBluetoothLEDevice * ADevice;
	ADevice = NULL;
	ADevice = GetCurrentDevice();
	if(ADevice != NULL) {
		PbServices->Value = 0;
		ADevice->OnServicesDiscovered = ServicesDiscovered;
		tmAnimateFindDevices->Enabled = ADevice->DiscoverServices();
	}
}
예제 #7
0
//---------------------------------------------------------------------------
void __fastcall TFrDeviceExplorer::btnRefreshClick(TObject *Sender)
{
	TBluetoothLEDevice * ADevice = NULL;
	ADevice = GetCurrentDevice();
	if(ADevice != NULL) {
		ADevice->OnCharacteristicRead = DidCharacteristicRead;
		TBluetoothGattService *AService = ADevice->Services->Items[CurrentService];
		TBluetoothGattCharacteristic *AChar = AService->Characteristics->Items[CurrentCharacteristic];
		if(AChar->Properties.Contains(TBluetoothProperty::Read)) {
			ADevice->ReadCharacteristic(AChar);
		}
		else {
			ShowMessage(EdCurrentDevice->Text + " is not available");
        }
	}
}
예제 #8
0
//---------------------------------------------------------------------------
void __fastcall TFrDeviceExplorer::btnSuscribeClick(TObject *Sender)
{
	TBluetoothLEDevice * ADevice = NULL;
	ADevice = GetCurrentDevice();
	if(ADevice != NULL) {
		TBluetoothGattCharacteristic * AChar = NULL;
		TBluetoothGattService * AService = ADevice->Services->Items[CurrentService];
		AChar = AService->Characteristics->Items[CurrentCharacteristic];
		if(AChar->Properties.Contains(TBluetoothProperty::Notify)) {
			ADevice->SetCharacteristicNotification(AChar, true);
		}
		else {
			ShowMessage("This characteristic doesn't allow notifications");
		}
	}
	else {
        ShowMessage(EdCurrentDevice->Text + " is not available");
    }
}
예제 #9
0
void DataManager::ExtractBackupFile(std::wstring key)
{
	if ( DEV_TYPE_ANDROID == m_deviceMap[GetCurrentDevice()].baseDevInfo.devType )
	{
		Utils::ExtractBackUp(m_dirPath + L"\\" + key + L"\\backup.ab");

		std::wstring findStr = m_dirPath + L"\\" + key + L"\\*@*";
		WIN32_FIND_DATA fd = {0};
		HANDLE hf = FindFirstFile(findStr.c_str(), &fd);

		if ( INVALID_HANDLE_VALUE == hf )
		{
			int err = GetLastError();
			return;
		}

		do 
		{
			AndroidImageAdapter::ExtractImageFile(m_dirPath + L"\\" + key + L"\\" + fd.cFileName);

		} while ( FindNextFile(hf, &fd) );

		FindClose(hf);
	}
	else
	{
		if ( !IosBackupAdapter::UnBackup(m_dirPath + L"\\" + key, m_iosBackupPasswrod) )
		{
			m_errNo = EXTRACT_IOS_BACKUP_FAILED;
			return;
		}

		m_errNo = 0;

		IosBackupAdapter::GenerateKeyChain(m_dirPath + L"\\" + key);
	}
}
예제 #10
0
//---------------------------------------------------------------------------
void __fastcall TFrDeviceExplorer::RefreshCurrentCharacteristic(void)
{
	TBluetoothLEDevice * ADevice;
	ADevice = GetCurrentDevice();
	if(ADevice != NULL) {
		TBluetoothGattService * AService = ADevice->Services->Items[CurrentService];
		TBluetoothGattCharacteristic * AChar = AService->Characteristics->Items[CurrentCharacteristic];
		lbCurrentService->Text = AService->UUIDName;
		EdCharacName->Text = AChar->UUIDName;
		EdCharacUID->Text = GUIDToString(AChar->UUID);
		cbBroadcast->IsChecked = AChar->Properties.Contains(TBluetoothProperty::Broadcast);
		cbExtendedProp->IsChecked = AChar->Properties.Contains(TBluetoothProperty::ExtendedProps);
		cbNotify->IsChecked = AChar->Properties.Contains(TBluetoothProperty::Notify);
		cbIndicate->IsChecked =  AChar->Properties.Contains(TBluetoothProperty::Indicate);
		CbRead->IsChecked =  AChar->Properties.Contains(TBluetoothProperty::Read);
		CbWrite->IsChecked =  AChar->Properties.Contains(TBluetoothProperty::Write);
		cbWriteNoResponse->IsChecked =  AChar->Properties.Contains(TBluetoothProperty::WriteNoResponse);
		cbSignedWrite->IsChecked =  AChar->Properties.Contains(TBluetoothProperty::SignedWrite);

		if ((AChar->Value.Length > 0) && (CbRead->IsChecked)) {
			LbCurrentValue->Items->Clear();
			try {
				LbCurrentValue->Items->Add("HEX: " +  ConverToHex(AChar->GetValue()));
			} catch (...) {
			}
			try {
			  LbCurrentValue->Items->Add("String(UTF8): " + AChar->GetValueAsString());
			} catch (...) {
			}
			try {
			  LbCurrentValue->Items->Add("String(NOUTF8): " +  AChar->GetValueAsString(1,false));
			} catch (...) {
			}
			try {
			  LbCurrentValue->Items->Add("Int8: " +  IntToStr(AChar->GetValueAsInt8()));
			} catch (...) {
			}
			try {
			  LbCurrentValue->Items->Add("Int16: " +  IntToStr(AChar->GetValueAsInt16()));
			} catch (...) {
			}
			try {
			  LbCurrentValue->Items->Add("Int32: " +  IntToStr(AChar->GetValueAsInt32()));
			} catch (...) {
			}
			try {
			  LbCurrentValue->Items->Add("Int64: " +  IntToStr(AChar->GetValueAsInt64()));
			} catch (...) {
			}
			try {
			  LbCurrentValue->Items->Add("UInt8: " +  IntToStr(AChar->GetValueAsUInt8()));
			} catch (...) {
			}
			try {
			  LbCurrentValue->Items->Add("UInt16: " +  IntToStr(AChar->GetValueAsUInt16()));
			} catch (...) {
			}
			try {
			  LbCurrentValue->Items->Add("UInt32: " +  IntToStr((int)AChar->GetValueAsUInt32()));
			} catch (...) {
			}
			try {
			  LbCurrentValue->Items->Add("UInt64: " +  IntToStr((__int64)AChar->GetValueAsUInt64()));
			} catch (...) {
			}
			try {
			  LbCurrentValue->Items->Add("Double: " + FloatToStr(AChar->GetValueAsDouble()));
			} catch (...) {
			}
			try {
			  LbCurrentValue->Items->Add("Single: " + FloatToStr(AChar->GetValueAsSingle()));
			} catch (...) {
			}
		}
	}
}
예제 #11
0
HRESULT hsGDirect3DTnLEnumerate::SelectFromDevMode(const hsG3DDeviceRecord* devRec, const hsG3DDeviceMode* devMode)
{

    int i;
    for( i = 0; i < GetNumDrivers(); i++ )
    {
        if( !stricmp(GetDriver(i)->fAdapterInfo.Description, devRec->GetDriverDesc()) )
        {
            int j;
            for( j = 0; j < GetDriver(i)->fDevices.GetCount(); j++ )
            {
                if( !stricmp(GetDriver(i)->fDevices[j].fStrName, devRec->GetDeviceDesc()) )
                {
                    SetCurrentDriver(GetDriver(i));
                    SetCurrentDevice(&GetDriver(i)->fDevices[j]);
                    D3DEnum_SelectDefaultMode(
                        devMode->GetWidth(),
                        devMode->GetHeight(),
                        devMode->GetColorDepth());
                    return false;
                }
            }
        }
    }
    char errStr[256];

    sprintf(errStr, "Can't find requested device - %s:%s:%s:%s:%s",
            devRec->GetG3DDeviceTypeName(),
            devRec->GetDriverDesc(),
            devRec->GetDriverName(),
            devRec->GetDriverVersion(),
            devRec->GetDeviceDesc());

    DWORD enumFlags = 0;
    int width = devMode->GetWidth();
    int height = devMode->GetHeight();
    int colorDepth = devMode->GetColorDepth();
    // for a window, take whatever colordepth we can get.
    if( !colorDepth )
        enumFlags |= D3DENUM_CANWINDOW;
    enumFlags |= D3DENUM_TNLHAL;
#ifdef HS_ALLOW_D3D_REF_DRIVER
    enumFlags |= D3DENUM_REFERENCERAST;
#endif

    D3DEnum_SelectDefaultDriver(enumFlags);

    // If we didn't get what we want, try for anything.
    if( !GetCurrentDriver() || !GetCurrentDevice() )
    {
        enumFlags = colorDepth ? 0 : D3DENUM_CANWINDOW;
        D3DEnum_SelectDefaultDriver(enumFlags);
    }
    if( !GetCurrentDriver() || !GetCurrentDevice() )
        D3DEnum_SelectDefaultDriver(0);
    if( !GetCurrentDriver() || !GetCurrentDevice() )
    {
        if( !*GetEnumeErrorStr() )
            SetEnumeErrorStr("Error finding device");
        return true;
    }
    D3DEnum_SelectDefaultMode(width, height, colorDepth);
    if( !GetCurrentMode() )
    {
        if( !*GetEnumeErrorStr() )
            SetEnumeErrorStr("Error finding mode");
        return true;
    }

    return false;
}