std::string PhoneEmailDetector::GetContentText(const WebKit::WebRange& range)
{
    if (m_foundResult == FOUND_COMPLETE) {
        if (m_prefix == kTelSchemaPrefix)
            return UTF16ToUTF8(m_findState.mStore);
        else
            return UTF16ToUTF8(range.toPlainText());
    }
    return std::string();
}
示例#2
0
std::string UTF16BEToUTF8(const char16_t* str, size_t max_size)
{
  const char16_t* str_end = std::find(str, str + max_size, '\0');
  std::wstring result(static_cast<size_t>(str_end - str), '\0');
  std::transform(str, str_end, result.begin(), static_cast<u16 (&)(u16)>(Common::swap16));
  return UTF16ToUTF8(result);
}
示例#3
0
std::string getStringUTFCharsJNI(JNIEnv* env, jstring srcjStr, bool* ret)
{
    std::string utf8Str;
    if(srcjStr != nullptr)
    {
        const unsigned short * unicodeChar = ( const unsigned short *)env->GetStringChars(srcjStr, nullptr);
        size_t unicodeCharLength = env->GetStringLength(srcjStr);
        const std::u16string unicodeStr((const char16_t *)unicodeChar, unicodeCharLength);
        bool flag = UTF16ToUTF8(unicodeStr, utf8Str);
        if (ret)
        {
            *ret = flag;
        }
        if (!flag)
        {
            utf8Str = "";
        }
        env->ReleaseStringChars(srcjStr, unicodeChar);
    }
    else
    {
        if (ret)
        {
            *ret = false;
        }
        utf8Str = "";
    }
    return utf8Str;
}
示例#4
0
void WiimoteScannerHidapi::FindWiimotes(std::vector<Wiimote*>& wiimotes, Wiimote*& board)
{
  hid_device_info* list = hid_enumerate(0x0, 0x0);
  for (hid_device_info* device = list; device; device = device->next)
  {
    const std::string name = device->product_string ? UTF16ToUTF8(device->product_string) : "";
    const bool is_wiimote =
        IsValidDeviceName(name) || (device->vendor_id == 0x057e &&
                                    (device->product_id == 0x0306 || device->product_id == 0x0330));
    if (!is_wiimote || !IsNewWiimote(device->path) || !IsDeviceUsable(device->path))
      continue;

    auto* wiimote = new WiimoteHidapi(device->path);
    const bool is_balance_board = IsBalanceBoardName(name) || wiimote->IsBalanceBoard();
    if (is_balance_board)
      board = wiimote;
    else
      wiimotes.push_back(wiimote);

    NOTICE_LOG(WIIMOTE, "Found %s at %s: %ls %ls (%04hx:%04hx)",
               is_balance_board ? "balance board" : "Wiimote", device->path,
               device->manufacturer_string, device->product_string, device->vendor_id,
               device->product_id);
  }
  hid_free_enumeration(list);
}
示例#5
0
void AutoUpdateChecker::TriggerUpdate(const AutoUpdateChecker::NewVersionInformation& info)
{
#ifdef _WIN32
  std::map<std::string, std::string> updater_flags;
  updater_flags["this-manifest-url"] = info.this_manifest_url;
  updater_flags["next-manifest-url"] = info.next_manifest_url;
  updater_flags["content-store-url"] = info.content_store_url;
  updater_flags["parent-pid"] = std::to_string(GetCurrentProcessId());
  updater_flags["install-base-path"] = File::GetExeDirectory();
  updater_flags["log-file"] = File::GetExeDirectory() + DIR_SEP + UPDATER_LOG_FILE;

  // Copy the updater so it can update itself if needed.
  std::string updater_path = File::GetExeDirectory() + DIR_SEP + UPDATER_FILENAME;
  std::string reloc_updater_path = File::GetExeDirectory() + DIR_SEP + UPDATER_RELOC_FILENAME;
  File::Copy(updater_path, reloc_updater_path);

  // Run the updater!
  std::wstring command_line = MakeUpdaterCommandLine(updater_flags);
  STARTUPINFO sinfo = {sizeof(info)};
  PROCESS_INFORMATION pinfo;
  INFO_LOG(COMMON, "Updater command line: %s", UTF16ToUTF8(command_line).c_str());
  if (!CreateProcessW(UTF8ToUTF16(reloc_updater_path).c_str(),
                      const_cast<wchar_t*>(command_line.c_str()), nullptr, nullptr, FALSE, 0,
                      nullptr, nullptr, &sinfo, &pinfo))
  {
    ERROR_LOG(COMMON, "Could not start updater process: error=%d", GetLastError());
  }
#endif
}
示例#6
0
// Connect to a Wiimote with a known device path.
bool WiimoteWindows::ConnectInternal()
{
  if (IsConnected())
    return true;

  if (!IsNewWiimote(UTF16ToUTF8(m_devicepath)))
    return false;

  auto const open_flags = FILE_SHARE_READ | FILE_SHARE_WRITE;

  m_dev_handle = CreateFile(m_devicepath.c_str(), GENERIC_READ | GENERIC_WRITE, open_flags, nullptr,
                            OPEN_EXISTING, FILE_FLAG_OVERLAPPED, nullptr);

  if (m_dev_handle == INVALID_HANDLE_VALUE)
  {
    m_dev_handle = nullptr;
    return false;
  }

#if 0
	TCHAR name[128] = {};
	pHidD_GetProductString(dev_handle, name, 128);

	//ERROR_LOG(WIIMOTE, "Product string: %s", TStrToUTF8(name).c_str());

	if (!IsValidBluetoothName(TStrToUTF8(name)))
	{
		CloseHandle(dev_handle);
		dev_handle = 0;
		return false;
	}
#endif

#if 0
	HIDD_ATTRIBUTES attr;
	attr.Size = sizeof(attr);
	if (!pHidD_GetAttributes(dev_handle, &attr))
	{
		CloseHandle(dev_handle);
		dev_handle = 0;
		return false;
	}
#endif

  // TODO: thread isn't started here now, do this elsewhere
  // This isn't as drastic as it sounds, since the process in which the threads
  // reside is normal priority. Needed for keeping audio reports at a decent rate
  /*
    if (!SetThreadPriority(m_wiimote_thread.native_handle(), THREAD_PRIORITY_TIME_CRITICAL))
    {
      ERROR_LOG(WIIMOTE, "Failed to set Wiimote thread priority");
    }
  */

  return true;
}
示例#7
0
		std::string OSInfo::processor_model_name() {
			if (processor_model_name_.empty()) {
				const wchar_t kProcessorNameString[] =
					L"HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0";
				base::win::RegKey key(HKEY_LOCAL_MACHINE, kProcessorNameString, KEY_READ);
				string16 value;
				key.ReadValue(L"ProcessorNameString", &value);
				processor_model_name_ = UTF16ToUTF8(value);
			}
			return processor_model_name_;
		}
    void OSExchangeDataProviderWin::SetString(const string16& data)
    {
        STGMEDIUM* storage = GetStorageForString16(data);
        data_->contents_.push_back(
            new DataObjectImpl::StoredDataInfo(CF_UNICODETEXT, storage));

        // Also add plain text.
        storage = GetStorageForString(UTF16ToUTF8(data));
        data_->contents_.push_back(
            new DataObjectImpl::StoredDataInfo(CF_TEXT, storage));
    }
示例#9
0
/**
@SYMTestCaseID          PDS-SQL-UT-4163
@SYMTestCaseDesc        Test for DEF144196: SQL, server code coverage can be improved
@SYMTestPriority        High
@SYMTestActions         Tests the UTF conversion functions implemented in SqlSrvUtil.cpp.
@SYMTestExpectedResults Test must not fail
@SYMDEF                 DEF144196
*/  
void UtfConversionTest()
    {
    /////////       UTF16ToUTF8()       ///////////////////////
    _LIT(KStr16, "abcd");
    _LIT8(KStr8, "abcd");
    TBuf8<KMaxFileName + 1> bufout;
    TBool rc = UTF16ToUTF8(KStr16, bufout);
    TEST(rc);
    TEST(bufout == KStr8);
    //Test where the input buffer contains non-convertible characters
    TBuf<2> name2;
    name2.SetLength(2);
    name2[0] = TChar(0xD800); 
    name2[1] = TChar(0xFC00); 
    rc = UTF16ToUTF8(name2, bufout);
    TEST(!rc);
    /////////       UTF16ToUTF8Z()       ///////////////////////
    _LIT8(KStr8Z, "abcd\x0");
    rc = UTF16ToUTF8Z(KStr16, bufout);
    TEST(rc);
    TEST(bufout == KStr8Z);
    //Test where the input buffer contains non-convertible characters
    rc = UTF16ToUTF8Z(name2, bufout);
    TEST(!rc);
    /////////       UTF16ZToUTF8Z()       ///////////////////////
    _LIT(KStr16Z, "abcd\x0");
    rc = UTF16ZToUTF8Z(KStr16Z, bufout);
    TEST(rc);
    TEST(bufout == KStr8Z);
    //Test where the input buffer contains non-convertible characters
    TBuf<3> name3;
    name3.SetLength(3);
    name3[0] = TChar(0xD800); 
    name3[1] = TChar(0xFC00); 
    name3[2] = TChar(0x0000); 
    rc = UTF16ZToUTF8Z(name3, bufout);
    TEST(!rc);
    }
示例#10
0
std::string GetDeviceName(const LPDIRECTINPUTDEVICE8 device)
{
  DIPROPSTRING str = {};
  str.diph.dwSize = sizeof(str);
  str.diph.dwHeaderSize = sizeof(str.diph);
  str.diph.dwHow = DIPH_DEVICE;

  std::string result;
  if (SUCCEEDED(device->GetProperty(DIPROP_PRODUCTNAME, &str.diph)))
  {
    result = StripSpaces(UTF16ToUTF8(str.wsz));
  }

  return result;
}
示例#11
0
// This returns true if a GPT partition matches the search criteria. If a match
// isn't found (or if the file doesn't contain a GPT), it returns false. The
// filename and partition number that matched is left in a global, since we
// could have multiple hits.
static int do_search(CgptFindParams *params, char *fileName) {
  int retval = 0;
  int i;
  struct drive drive;
  GptEntry *entry;
  char partlabel[GPT_PARTNAME_LEN];

  if (CGPT_OK != DriveOpen(fileName, &drive, O_RDONLY))
    return 0;

  if (GPT_SUCCESS != GptSanityCheck(&drive.gpt)) {
    (void) DriveClose(&drive, 0);
    return 0;
  }

  for (i = 0; i < GetNumberOfEntries(&drive); ++i) {
    entry = GetEntry(&drive.gpt, ANY_VALID, i);

    if (GuidIsZero(&entry->type))
      continue;

    int found = 0;
    if ((params->set_unique && GuidEqual(&params->unique_guid, &entry->unique))
        || (params->set_type && GuidEqual(&params->type_guid, &entry->type))) {
      found = 1;
    } else if (params->set_label) {
      if (CGPT_OK != UTF16ToUTF8(entry->name,
                                 sizeof(entry->name) / sizeof(entry->name[0]),
                                 (uint8_t *)partlabel, sizeof(partlabel))) {
        Error("The label cannot be converted from UTF16, so abort.\n");
        return 0;
      }
      if (!strncmp(params->label, partlabel, sizeof(partlabel)))
        found = 1;
    }
    if (found && match_content(params, &drive, entry)) {
      params->hits++;
      retval++;
      showmatch(params, fileName, i+1, entry);
      if (!params->match_partnum)
        params->match_partnum = i+1;
    }
  }

  (void) DriveClose(&drive, 0);

  return retval;
}
示例#12
0
bool CCharsetConvert::GBK18030ToUTF8(unsigned char *pMultiByte, int nMultiByteSize, unsigned char *pUTF8, int *pUTF8Size)
{
	bool bReturn = false;
	char *pszUtf16 = new char[nMultiByteSize * EXTEND_SIZE];
	int len = nMultiByteSize * EXTEND_SIZE;
	memset(pszUtf16,0,nMultiByteSize * EXTEND_SIZE);
	bReturn = GBK18030ToUTF16(pMultiByte,nMultiByteSize,(unsigned char*)pszUtf16,&len);
	if (!bReturn)
	{
		return bReturn;
	}

	bReturn = UTF16ToUTF8((unsigned char*)pszUtf16,len,(unsigned char*)pUTF8,pUTF8Size);

	delete []pszUtf16;
	return bReturn;
}
示例#13
0
文件: Volume.cpp 项目: DINKIN/dolphin
std::map<Language, std::string> Volume::ReadWiiNames(const std::vector<u8>& data)
{
  std::map<Language, std::string> names;
  for (size_t i = 0; i < NUMBER_OF_LANGUAGES; ++i)
  {
    size_t name_start = NAME_BYTES_LENGTH * i;
    size_t name_end = name_start + NAME_BYTES_LENGTH;
    if (data.size() >= name_end)
    {
      u16* temp = (u16*)(data.data() + name_start);
      std::wstring out_temp(NAME_STRING_LENGTH, '\0');
      std::transform(temp, temp + out_temp.size(), out_temp.begin(), (u16(&)(u16))Common::swap16);
      out_temp.erase(std::find(out_temp.begin(), out_temp.end(), 0x00), out_temp.end());
      std::string name = UTF16ToUTF8(out_temp);
      if (!name.empty())
        names[static_cast<Language>(i)] = name;
    }
  }
  return names;
}
示例#14
0
void EntryDetails(GptEntry *entry, uint32_t index, int raw) {
  char contents[256];                   // scratch buffer for formatting output
  uint8_t label[GPT_PARTNAME_LEN];
  char type[GUID_STRLEN], unique[GUID_STRLEN];

  UTF16ToUTF8(entry->name, sizeof(entry->name) / sizeof(entry->name[0]),
              label, sizeof(label));
  require(snprintf(contents, sizeof(contents),
                   "Label: \"%s\"", label) < sizeof(contents));
  printf(PARTITION_FMT, (int)entry->starting_lba,
         (int)(entry->ending_lba - entry->starting_lba + 1),
         index+1, contents);

  if (!raw && CGPT_OK == ResolveType(&entry->type, type)) {
    printf(PARTITION_MORE, "Type: ", type);
  } else {
    GuidToStr(&entry->type, type, GUID_STRLEN);
    printf(PARTITION_MORE, "Type: ", type);
  }
  GuidToStr(&entry->unique, unique, GUID_STRLEN);
  printf(PARTITION_MORE, "UUID: ", unique);

  if (!raw) {
    if (GuidEqual(&guid_chromeos_kernel, &entry->type)) {
      int tries = (entry->attrs.fields.gpt_att &
                   CGPT_ATTRIBUTE_TRIES_MASK) >>
          CGPT_ATTRIBUTE_TRIES_OFFSET;
      int successful = (entry->attrs.fields.gpt_att &
                        CGPT_ATTRIBUTE_SUCCESSFUL_MASK) >>
          CGPT_ATTRIBUTE_SUCCESSFUL_OFFSET;
      int priority = (entry->attrs.fields.gpt_att &
                      CGPT_ATTRIBUTE_PRIORITY_MASK) >>
          CGPT_ATTRIBUTE_PRIORITY_OFFSET;
      require(snprintf(contents, sizeof(contents),
                       "priority=%d tries=%d successful=%d",
                       priority, tries, successful) < sizeof(contents));
      printf(PARTITION_MORE, "Attr: ", contents);
    }
  } else {
示例#15
0
std::ostream& operator<<(std::ostream& out, const wchar_t* const wideStr) {
  out << UTF16ToUTF8(wideStr);
  return out;
}
示例#16
0
文件: main.cpp 项目: Sintendo/dolphin
void VideoBackend::InitBackendInfo()
{
  HRESULT hr = DX11::D3D::LoadDXGI();
  if (SUCCEEDED(hr))
    hr = DX11::D3D::LoadD3D();
  if (FAILED(hr))
  {
    DX11::D3D::UnloadDXGI();
    return;
  }

  g_Config.backend_info.api_type = APIType::D3D;
  g_Config.backend_info.MaxTextureSize = D3D11_REQ_TEXTURE2D_U_OR_V_DIMENSION;
  g_Config.backend_info.bUsesLowerLeftOrigin = false;
  g_Config.backend_info.bSupportsExclusiveFullscreen = true;
  g_Config.backend_info.bSupportsDualSourceBlend = true;
  g_Config.backend_info.bSupportsPrimitiveRestart = true;
  g_Config.backend_info.bSupportsOversizedViewports = false;
  g_Config.backend_info.bSupportsGeometryShaders = true;
  g_Config.backend_info.bSupportsComputeShaders = false;
  g_Config.backend_info.bSupports3DVision = true;
  g_Config.backend_info.bSupportsPostProcessing = true;
  g_Config.backend_info.bSupportsPaletteConversion = true;
  g_Config.backend_info.bSupportsClipControl = true;
  g_Config.backend_info.bSupportsDepthClamp = true;
  g_Config.backend_info.bSupportsReversedDepthRange = false;
  g_Config.backend_info.bSupportsLogicOp = true;
  g_Config.backend_info.bSupportsMultithreading = false;
  g_Config.backend_info.bSupportsGPUTextureDecoding = true;
  g_Config.backend_info.bSupportsST3CTextures = false;
  g_Config.backend_info.bSupportsCopyToVram = true;
  g_Config.backend_info.bSupportsLargePoints = false;
  g_Config.backend_info.bSupportsPartialDepthCopies = false;
  g_Config.backend_info.bSupportsBitfield = false;
  g_Config.backend_info.bSupportsDynamicSamplerIndexing = false;
  g_Config.backend_info.bSupportsBPTCTextures = false;
  g_Config.backend_info.bSupportsFramebufferFetch = false;
  g_Config.backend_info.bSupportsBackgroundCompiling = true;

  IDXGIFactory2* factory;
  IDXGIAdapter* ad;
  hr = DX11::PCreateDXGIFactory(__uuidof(IDXGIFactory2), (void**)&factory);
  if (FAILED(hr))
    PanicAlert("Failed to create IDXGIFactory object");

  // adapters
  g_Config.backend_info.Adapters.clear();
  g_Config.backend_info.AAModes.clear();
  while (factory->EnumAdapters((UINT)g_Config.backend_info.Adapters.size(), &ad) !=
         DXGI_ERROR_NOT_FOUND)
  {
    const size_t adapter_index = g_Config.backend_info.Adapters.size();

    DXGI_ADAPTER_DESC desc;
    ad->GetDesc(&desc);

    // TODO: These don't get updated on adapter change, yet
    if (adapter_index == g_Config.iAdapter)
    {
      std::vector<DXGI_SAMPLE_DESC> modes = DX11::D3D::EnumAAModes(ad);
      // First iteration will be 1. This equals no AA.
      for (unsigned int i = 0; i < modes.size(); ++i)
      {
        g_Config.backend_info.AAModes.push_back(modes[i].Count);
      }

      D3D_FEATURE_LEVEL feature_level = D3D::GetFeatureLevel(ad);
      bool shader_model_5_supported = feature_level >= D3D_FEATURE_LEVEL_11_0;
      g_Config.backend_info.MaxTextureSize = D3D::GetMaxTextureSize(feature_level);

      // Requires the earlydepthstencil attribute (only available in shader model 5)
      g_Config.backend_info.bSupportsEarlyZ = shader_model_5_supported;

      // Requires full UAV functionality (only available in shader model 5)
      g_Config.backend_info.bSupportsBBox =
          g_Config.backend_info.bSupportsFragmentStoresAndAtomics = shader_model_5_supported;

      // Requires the instance attribute (only available in shader model 5)
      g_Config.backend_info.bSupportsGSInstancing = shader_model_5_supported;

      // Sample shading requires shader model 5
      g_Config.backend_info.bSupportsSSAA = shader_model_5_supported;
    }
    g_Config.backend_info.Adapters.push_back(UTF16ToUTF8(desc.Description));
    ad->Release();
  }
  factory->Release();

  DX11::D3D::UnloadDXGI();
  DX11::D3D::UnloadD3D();
}
示例#17
0
文件: main.cpp 项目: stenzek/dolphin
void VideoBackend::InitBackendInfo()
{
    HRESULT hr = D3D::LoadDXGI();
    if (FAILED(hr))
        return;

    hr = D3D::LoadD3D();
    if (FAILED(hr))
    {
        D3D::UnloadDXGI();
        return;
    }

    g_Config.backend_info.api_type = APIType::D3D;
    g_Config.backend_info.bSupportsExclusiveFullscreen = false;
    g_Config.backend_info.bSupportsDualSourceBlend = true;
    g_Config.backend_info.bSupportsPrimitiveRestart = true;
    g_Config.backend_info.bSupportsOversizedViewports = false;
    g_Config.backend_info.bSupportsGeometryShaders = true;
    g_Config.backend_info.bSupports3DVision = true;
    g_Config.backend_info.bSupportsPostProcessing = false;
    g_Config.backend_info.bSupportsPaletteConversion = true;
    g_Config.backend_info.bSupportsClipControl = true;
    g_Config.backend_info.bSupportsDepthClamp = true;
    g_Config.backend_info.bSupportsReversedDepthRange = false;
    g_Config.backend_info.bSupportsMultithreading = false;
    g_Config.backend_info.bSupportsInternalResolutionFrameDumps = false;

    IDXGIFactory* factory;
    IDXGIAdapter* ad;
    hr = create_dxgi_factory(__uuidof(IDXGIFactory), (void**)&factory);
    if (FAILED(hr))
    {
        PanicAlert("Failed to create IDXGIFactory object");
        D3D::UnloadD3D();
        D3D::UnloadDXGI();
        return;
    }

    // adapters
    g_Config.backend_info.Adapters.clear();
    g_Config.backend_info.AAModes.clear();
    while (factory->EnumAdapters((UINT)g_Config.backend_info.Adapters.size(), &ad) !=
            DXGI_ERROR_NOT_FOUND)
    {
        const size_t adapter_index = g_Config.backend_info.Adapters.size();

        DXGI_ADAPTER_DESC desc;
        ad->GetDesc(&desc);

        // TODO: These don't get updated on adapter change, yet
        if (adapter_index == g_Config.iAdapter)
        {
            ID3D12Device* temp_device;
            hr = d3d12_create_device(ad, D3D_FEATURE_LEVEL_11_0, IID_PPV_ARGS(&temp_device));
            if (SUCCEEDED(hr))
            {
                std::string samples;
                std::vector<DXGI_SAMPLE_DESC> modes = D3D::EnumAAModes(temp_device);
                // First iteration will be 1. This equals no AA.
                for (unsigned int i = 0; i < modes.size(); ++i)
                {
                    g_Config.backend_info.AAModes.push_back(modes[i].Count);
                }

                // Requires the earlydepthstencil attribute (only available in shader model 5)
                g_Config.backend_info.bSupportsEarlyZ = true;

                // Requires full UAV functionality (only available in shader model 5)
                g_Config.backend_info.bSupportsBBox = true;

                // Requires the instance attribute (only available in shader model 5)
                g_Config.backend_info.bSupportsGSInstancing = true;

                // Sample shading requires shader model 5
                g_Config.backend_info.bSupportsSSAA = true;

                temp_device->Release();
            }
        }

        g_Config.backend_info.Adapters.push_back(UTF16ToUTF8(desc.Description));
        ad->Release();
    }
    factory->Release();

    // Clear ppshaders string vector
    g_Config.backend_info.PPShaders.clear();
    g_Config.backend_info.AnaglyphShaders.clear();

    D3D::UnloadD3D();
    D3D::UnloadDXGI();
}
示例#18
0
void InitBackendInfo()
{
	HRESULT hr = DX11::D3D::LoadDXGI();
	if (SUCCEEDED(hr)) hr = DX11::D3D::LoadD3D();
	if (FAILED(hr))
	{
		DX11::D3D::UnloadDXGI();
		return;
	}

	g_Config.backend_info.APIType = API_D3D11;
	g_Config.backend_info.bSupportedFormats[PC_TEX_FMT_BGRA32] = false;
	g_Config.backend_info.bSupportedFormats[PC_TEX_FMT_RGBA32] = true;
	g_Config.backend_info.bSupportedFormats[PC_TEX_FMT_I4_AS_I8] = false;
	g_Config.backend_info.bSupportedFormats[PC_TEX_FMT_IA4_AS_IA8] = false;
	g_Config.backend_info.bSupportedFormats[PC_TEX_FMT_I8] = false;
	g_Config.backend_info.bSupportedFormats[PC_TEX_FMT_IA8] = false;
	g_Config.backend_info.bSupportedFormats[PC_TEX_FMT_RGB565] = false;
	g_Config.backend_info.bSupportedFormats[PC_TEX_FMT_DXT1] = true;
	g_Config.backend_info.bSupportedFormats[PC_TEX_FMT_DXT3] = false;
	g_Config.backend_info.bSupportedFormats[PC_TEX_FMT_DXT5] = true;

	g_Config.backend_info.bSupportsExclusiveFullscreen = true;
	g_Config.backend_info.bSupportsDualSourceBlend = true;
	g_Config.backend_info.bSupportsPixelLighting = true;
	g_Config.backend_info.bNeedBlendIndices = false;
	g_Config.backend_info.bSupportsOversizedViewports = false;
	g_Config.backend_info.bSupportsGeometryShaders = true;
	g_Config.backend_info.bSupports3DVision = true;
	g_Config.backend_info.bSupportsPostProcessing = true;
	g_Config.backend_info.bSupportsClipControl = false;
	g_Config.backend_info.bSupportsSSAA = true;
	g_Config.backend_info.bSupportsNormalMaps = true;	IDXGIFactory* factory;
	IDXGIAdapter* ad;
	hr = DX11::PCreateDXGIFactory(__uuidof(IDXGIFactory), (void**)&factory);
	if (FAILED(hr))
		PanicAlert("Failed to create IDXGIFactory object");

	// adapters
	g_Config.backend_info.Adapters.clear();
	g_Config.backend_info.AAModes.clear();
	while (factory->EnumAdapters((UINT)g_Config.backend_info.Adapters.size(), &ad) != DXGI_ERROR_NOT_FOUND)
	{
		const size_t adapter_index = g_Config.backend_info.Adapters.size();

		DXGI_ADAPTER_DESC desc;
		ad->GetDesc(&desc);

		// TODO: These don't get updated on adapter change, yet
		if (adapter_index == g_Config.iAdapter)
		{
			char buf[32];
			std::vector<DXGI_SAMPLE_DESC> modes;
			modes = DX11::D3D::EnumAAModes(ad);
			for (unsigned int i = 0; i < modes.size(); ++i)
			{
				if (i == 0) sprintf_s(buf, 32, _trans("None"));
				else if (modes[i].Quality) sprintf_s(buf, 32, _trans("%d samples (quality level %d)"), modes[i].Count, modes[i].Quality);
				else sprintf_s(buf, 32, _trans("%d samples"), modes[i].Count);
				g_Config.backend_info.AAModes.push_back(buf);
			}

			bool shader_model_5_supported = (DX11::D3D::GetFeatureLevel(ad) >= D3D_FEATURE_LEVEL_11_0);
			// Requires the earlydepthstencil attribute (only available in shader model 5)
			g_Config.backend_info.bSupportsEarlyZ = shader_model_5_supported;
			// Requires full UAV functionality (only available in shader model 5)
			g_Config.backend_info.bSupportsBBox = shader_model_5_supported;
			// Requires the instance attribute (only available in shader model 5)
			g_Config.backend_info.bSupportsGSInstancing = shader_model_5_supported;
			g_Config.backend_info.bSupportsTessellation = shader_model_5_supported;
		}

		g_Config.backend_info.Adapters.push_back(UTF16ToUTF8(desc.Description));
		ad->Release();
	}

	factory->Release();

	// pp shaders
	g_Config.backend_info.PPShaders = GetShaders("");
	g_Config.backend_info.AnaglyphShaders = GetShaders(ANAGLYPH_DIR DIR_SEP);

	DX11::D3D::UnloadDXGI();
	DX11::D3D::UnloadD3D();
}
示例#19
0
std::string CP1252ToUTF8(const std::string& input)
{
	return UTF16ToUTF8(CPToUTF16(1252, input));
}
示例#20
0
std::string SHIFTJISToUTF8(const std::string& input)
{
	return UTF16ToUTF8(CPToUTF16(932, input));
}
示例#21
0
std::string SHIFTJISToUTF8(const std::string& input)
{
  return UTF16ToUTF8(CPToUTF16(CODEPAGE_SHIFT_JIS, input));
}
示例#22
0
文件: main.cpp 项目: braindx/dolphin
void InitBackendInfo()
{
	HRESULT hr = DX11::D3D::LoadDXGI();
	if (SUCCEEDED(hr)) hr = DX11::D3D::LoadD3D();
	if (FAILED(hr))
	{
		DX11::D3D::UnloadDXGI();
		return;
	}

	g_Config.backend_info.APIType = API_D3D;
	g_Config.backend_info.bUseRGBATextures = true; // the GX formats barely match any D3D11 formats
	g_Config.backend_info.bUseMinimalMipCount = true;
	g_Config.backend_info.bSupportsExclusiveFullscreen = true;
	g_Config.backend_info.bSupportsDualSourceBlend = true;
	g_Config.backend_info.bSupportsPrimitiveRestart = true;
	g_Config.backend_info.bSupportsOversizedViewports = false;

	IDXGIFactory* factory;
	IDXGIAdapter* ad;
	hr = DX11::PCreateDXGIFactory(__uuidof(IDXGIFactory), (void**)&factory);
	if (FAILED(hr))
		PanicAlert("Failed to create IDXGIFactory object");

	// adapters
	g_Config.backend_info.Adapters.clear();
	g_Config.backend_info.AAModes.clear();
	while (factory->EnumAdapters((UINT)g_Config.backend_info.Adapters.size(), &ad) != DXGI_ERROR_NOT_FOUND)
	{
		const size_t adapter_index = g_Config.backend_info.Adapters.size();

		DXGI_ADAPTER_DESC desc;
		ad->GetDesc(&desc);

		// TODO: These don't get updated on adapter change, yet
		if (adapter_index == g_Config.iAdapter)
		{
			std::string samples;
			std::vector<DXGI_SAMPLE_DESC> modes = DX11::D3D::EnumAAModes(ad);
			for (unsigned int i = 0; i < modes.size(); ++i)
			{
				if (i == 0)
					samples = _trans("None");
				else if (modes[i].Quality)
					samples = StringFromFormat(_trans("%d samples (quality level %d)"), modes[i].Count, modes[i].Quality);
				else
					samples = StringFromFormat(_trans("%d samples"), modes[i].Count);

				g_Config.backend_info.AAModes.push_back(samples);
			}

			// Requires the earlydepthstencil attribute (only available in shader model 5)
			g_Config.backend_info.bSupportsEarlyZ = (DX11::D3D::GetFeatureLevel(ad) == D3D_FEATURE_LEVEL_11_0);
		}

		g_Config.backend_info.Adapters.push_back(UTF16ToUTF8(desc.Description));
		ad->Release();
	}

	factory->Release();

	// Clear ppshaders string vector
	g_Config.backend_info.PPShaders.clear();

	DX11::D3D::UnloadDXGI();
	DX11::D3D::UnloadD3D();
}
FoundState FindPartialNumber(const UChar* chars, unsigned length,
    FindState* s)
{
    char* pattern = s->mPattern;
    UChar* store = s->mStorePtr;
    const UChar* start = chars;
    const UChar* end = chars + length;
    const UChar* lastDigit = 0;
    string16 search16(chars, length);
    std::string searchSpace = UTF16ToUTF8(search16);
retry:
    do {
        bool initialized = s->mInitialized;
        while (chars < end) {
            if (initialized == false) {
                s->mBackTwo = s->mBackOne;
                s->mBackOne = s->mCurrent;
            }
            UChar ch = s->mCurrent = *chars;
            do {
                char patternChar = *pattern;
                switch (patternChar) {
                    case '2':
                        if (initialized == false) {
                            s->mStartResult = chars - start;
                            initialized = true;
                        }
                    case '0':
                    case '1':
                        if (ch < patternChar || ch > '9')
                            goto resetPattern;
                        *store++ = ch;
                        pattern++;
                        lastDigit = chars;
                        goto nextChar;
                    case '\0':
                        if (WTF::isASCIIDigit(ch) == false) {
                            *store = '\0';
                            goto checkMatch;
                        }
                        goto resetPattern;
                    case ' ':
                        if (ch == patternChar)
                            goto nextChar;
                        break;
                    case '(':
                        if (ch == patternChar) {
                            s->mStartResult = chars - start;
                            initialized = true;
                            s->mOpenParen = true;
                        }
                        goto commonPunctuation;
                    case ')':
                        if ((ch == patternChar) ^ s->mOpenParen)
                            goto resetPattern;
                    default:
                    commonPunctuation:
                        if (ch == patternChar) {
                            pattern++;
                            goto nextChar;
                        }
                }
            } while (++pattern); // never false
    nextChar:
            chars++;
        }
        break;
resetPattern:
        if (s->mContinuationNode)
            return FOUND_NONE;
        FindResetNumber(s);
        pattern = s->mPattern;
        store = s->mStorePtr;
    } while (++chars < end);
checkMatch:
    /*
     * A few interesting cases:
     *  03122572251 3122572251     # two numbers, s->mBackOne = 0,                  return second
     *  013122572251 3122572251    # two numbers, s->mBackOne = 1, s->mBackTwo = 0, return second
     *  113122572251 3122572251    # two numbers, s->mBackOne = 1, s->mBackTwo = 1, return second
     *
     *  The prefix of above US phone number is "0" or "01" or "11".
     *  Such as three cases mentioned above, the first group phone number
     *  is invalid, but the detection blocks also have a telephone number,
     *  the second valid phone number should be detected.
     */
    if (WTF::isASCIIDigit(s->mBackOne != '1' ? s->mBackOne : s->mBackTwo)) {
        if(++chars < end) {
            if (s->mContinuationNode) {
                return FOUND_NONE;
            }
            FindResetNumber(s);
            pattern = s->mPattern;
            store = s->mStorePtr;
            goto retry;
        } else {
            return FOUND_NONE;
        }
    }
    *store = '\0';
    s->mStorePtr = store;
    s->mPattern = pattern;
    s->mEndResult = lastDigit - start + 1;
    char pState = pattern[0];
    return pState == '\0' ? FOUND_COMPLETE : pState == '(' || (WTF::isASCIIDigit(pState) && WTF::isASCIIDigit(pattern[-1])) ?
        FOUND_NONE : FOUND_PARTIAL;
}
示例#24
0
// Find and connect Wiimotes.
// Does not replace already found Wiimotes even if they are disconnected.
// wm is an array of max_wiimotes Wiimotes
// Returns the total number of found and connected Wiimotes.
void WiimoteScannerWindows::FindWiimotes(std::vector<Wiimote*>& found_wiimotes,
                                         Wiimote*& found_board)
{
  if (!s_loaded_ok)
    return;

  ProcessWiimotes(true, [](HANDLE hRadio, const BLUETOOTH_RADIO_INFO& rinfo,
                           BLUETOOTH_DEVICE_INFO_STRUCT& btdi) {
    ForgetWiimote(btdi);
    AttachWiimote(hRadio, rinfo, btdi);
  });

  // Get the device id
  GUID device_id;
  pHidD_GetHidGuid(&device_id);

  // Get all hid devices connected
  HDEVINFO const device_info =
      SetupDiGetClassDevs(&device_id, nullptr, nullptr, (DIGCF_DEVICEINTERFACE | DIGCF_PRESENT));

  SP_DEVICE_INTERFACE_DATA device_data = {};
  device_data.cbSize = sizeof(device_data);
  PSP_DEVICE_INTERFACE_DETAIL_DATA detail_data = nullptr;

  for (int index = 0;
       SetupDiEnumDeviceInterfaces(device_info, nullptr, &device_id, index, &device_data); ++index)
  {
    // Get the size of the data block required
    DWORD len;
    SetupDiGetDeviceInterfaceDetail(device_info, &device_data, nullptr, 0, &len, nullptr);
    detail_data = (PSP_DEVICE_INTERFACE_DETAIL_DATA)malloc(len);
    detail_data->cbSize = sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA);

    SP_DEVINFO_DATA device_info_data = {};
    device_info_data.cbSize = sizeof(SP_DEVINFO_DATA);

    // Query the data for this device
    if (SetupDiGetDeviceInterfaceDetail(device_info, &device_data, detail_data, len, nullptr,
                                        &device_info_data))
    {
      std::basic_string<TCHAR> device_path(detail_data->DevicePath);
      bool IsUsingToshibaStack = CheckForToshibaStack(device_info_data.DevInst);

      WinWriteMethod write_method = GetInitialWriteMethod(IsUsingToshibaStack);

      if (!IsNewWiimote(UTF16ToUTF8(device_path)) || !IsWiimote(device_path, write_method))
      {
        free(detail_data);
        continue;
      }

      auto* wiimote = new WiimoteWindows(device_path, write_method);
      if (wiimote->IsBalanceBoard())
        found_board = wiimote;
      else
        found_wiimotes.push_back(wiimote);
    }

    free(detail_data);
  }

  SetupDiDestroyDeviceInfoList(device_info);
}
示例#25
0
std::string CP1252ToUTF8(const std::string& input)
{
  return UTF16ToUTF8(CPToUTF16(CODEPAGE_WINDOWS_1252, input));
}
示例#26
0
 StringValue::StringValue(const string16& in_value)
     : Value(TYPE_STRING), value_(UTF16ToUTF8(in_value)) {}
std::string UTF16ToASCII(const std::u16string& utf16) {
#if 0
    DCHECK(isStringASCII(utf16)) << UTF16ToUTF8(utf16);
#endif
    return std::string(utf16.begin(), utf16.end());
}
示例#28
0
WebCore::KURL PepperPluginImpl::linkAtPosition(const WebCore::IntPoint& position) const{
  return WebCore::KURL(WebCore::KURL(), UTF16ToUTF8(instance_->GetLinkAtPosition(position)).c_str());
}
示例#29
0
void ProcessWiimotes(bool new_scan, T& callback)
{
  BLUETOOTH_DEVICE_SEARCH_PARAMS srch;
  srch.dwSize = sizeof(srch);
  srch.fReturnAuthenticated = true;
  srch.fReturnRemembered = true;
  // Does not filter properly somehow, so we need to do an additional check on
  // fConnected BT Devices
  srch.fReturnConnected = true;
  srch.fReturnUnknown = true;
  srch.fIssueInquiry = new_scan;
  // multiple of 1.28 seconds
  srch.cTimeoutMultiplier = 2;

  BLUETOOTH_FIND_RADIO_PARAMS radioParam;
  radioParam.dwSize = sizeof(radioParam);

  HANDLE hRadio;

  // TODO: save radio(s) in the WiimoteScanner constructor?

  // Enumerate BT radios
  HBLUETOOTH_RADIO_FIND hFindRadio = pBluetoothFindFirstRadio(&radioParam, &hRadio);
  while (hFindRadio)
  {
    BLUETOOTH_RADIO_INFO radioInfo;
    radioInfo.dwSize = sizeof(radioInfo);

    auto const rinfo_result = pBluetoothGetRadioInfo(hRadio, &radioInfo);
    if (ERROR_SUCCESS == rinfo_result)
    {
      srch.hRadio = hRadio;

      BLUETOOTH_DEVICE_INFO btdi;
      btdi.dwSize = sizeof(btdi);

      // Enumerate BT devices
      HBLUETOOTH_DEVICE_FIND hFindDevice = pBluetoothFindFirstDevice(&srch, &btdi);
      while (hFindDevice)
      {
        // btdi.szName is sometimes missing it's content - it's a bt feature..
        DEBUG_LOG(WIIMOTE, "Authenticated %i connected %i remembered %i ", btdi.fAuthenticated,
                  btdi.fConnected, btdi.fRemembered);

        if (IsValidDeviceName(UTF16ToUTF8(btdi.szName)))
        {
          callback(hRadio, radioInfo, btdi);
        }

        if (false == pBluetoothFindNextDevice(hFindDevice, &btdi))
        {
          pBluetoothFindDeviceClose(hFindDevice);
          hFindDevice = nullptr;
        }
      }
    }

    if (false == pBluetoothFindNextRadio(hFindRadio, &hRadio))
    {
      pBluetoothFindRadioClose(hFindRadio);
      hFindRadio = nullptr;
    }
  }
}
FoundState ChinaFindPhoneNum(const UChar* chars, unsigned length,
    FindState* s)
{
    #define PREPARE_GOTO_NEXT() \
       *store++ = ch; \
       pattern++; \
       lastDigit = chars;

    char* pattern = s->mPattern;
    UChar* store = s->mStorePtr;
    const UChar* start = chars;
    const UChar* end = chars + length;
    const UChar* lastDigit = 0;
    string16 search16(chars, length);
    std::string searchSpace = UTF16ToUTF8(search16);
retry:
    do {
        bool initialized = s->mInitialized;
        while (chars < end) {
            if (initialized == false) {
                s->mBackThree = s->mBackTwo;
                s->mBackTwo = s->mBackOne;
                s->mBackOne = s->mCurrent;
            }
            UChar ch = s->mCurrent = *chars;
            do {
                char patternChar = *pattern;
                switch (patternChar) {
                    case '1':
                        if (initialized == false) {
                            s->mStartResult = chars - start;
                            initialized = true;
                        }
                        if (ch != patternChar) {
                            goto resetPattern;
                        }
                        PREPARE_GOTO_NEXT();
                        goto nextChar;
                    case '3':
                        if (ch != '3' && ch != '5' && ch != '8') {
                            goto resetPattern;
                        }
                        PREPARE_GOTO_NEXT();
                        goto nextChar;
                    case '0':
                        if (ch < patternChar || ch > '9')
                            goto resetPattern;
                        PREPARE_GOTO_NEXT();
                        goto nextChar;
                    case '\0':
                        if (WTF::isASCIIDigit(ch) == false) {
                            *store = '\0';
                            goto checkMatch;
                        }
                        goto resetPattern;
                    case ' ':
                        if (ch == patternChar)
                            goto nextChar;
                        break;
                    default:
                    commonPunctuation:
                        if (ch == patternChar) {
                            pattern++;
                            goto nextChar;
                        }
                }
            } while (++pattern); // never false
    nextChar:
            chars++;
        }
        break;
resetPattern:
        if (s->mContinuationNode)
            return FOUND_NONE;
        ChinaFindResetNumber(s);
        pattern = s->mPattern;
        store = s->mStorePtr;
    } while (++chars < end);
checkMatch:
    if (WTF::isASCIIDigit((s->mBackOne == '6' && s->mBackTwo == '8') ?
            s->mBackThree : s->mBackOne) || s->mBackOne == '+') {
        if(++chars < end) {
            if (s->mContinuationNode) {
                return FOUND_NONE;
            }
            ChinaFindResetNumber(s);
            pattern = s->mPattern;
            store = s->mStorePtr;
            goto retry;
        } else {
            return FOUND_NONE;
        }
    }
    *store = '\0';
    s->mStorePtr = store;
    s->mPattern = pattern;
    s->mEndResult = lastDigit - start + 1;
    char pState = pattern[0];
    return pState == '\0' ? FOUND_COMPLETE : FOUND_NONE;
}