This repository has been archived by the owner on Nov 8, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change the timing of vrapi_SetDisplayRefreshRate because Ovr == NULL …
…on calling. Maybe fix #116 #197
- Loading branch information
1 parent
d24b646
commit e2ba009
Showing
7 changed files
with
80 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#include "common-utils.h" | ||
|
||
std::wstring ToWstring(const std::string &src) { | ||
// TODO: src is really UTF-8? | ||
std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> converter; | ||
return converter.from_bytes(src); | ||
} | ||
|
||
std::string ToUTF8(const std::wstring &src) { | ||
std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> converter; | ||
return converter.to_bytes(src); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#pragma once | ||
|
||
#include <string> | ||
#include <locale> | ||
#include <codecvt> | ||
|
||
std::wstring ToWstring(const std::string &src); | ||
std::string ToUTF8(const std::wstring &src); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#include <stdarg.h> | ||
#include <wchar.h> | ||
#include "exception.h" | ||
#include "common-utils.h" | ||
|
||
Exception FormatExceptionV(const wchar_t *format, va_list args) { | ||
wchar_t buf[10000]; | ||
#ifdef _WIN32_ | ||
_vsnwprintf_s(buf, sizeof(buf) / sizeof(buf[0]), format, args); | ||
#else | ||
vswprintf(buf, sizeof(buf) / sizeof(buf[0]), format, args); | ||
#endif | ||
return Exception(buf); | ||
} | ||
|
||
Exception FormatExceptionV(const char *format, va_list args) { | ||
char buf[10000]; | ||
|
||
#ifdef _WIN32_ | ||
_vsnprintf_s(buf, sizeof(buf) / sizeof(buf[0]), format, args); | ||
#else | ||
vsnprintf(buf, sizeof(buf) / sizeof(buf[0]), format, args); | ||
#endif | ||
return Exception(ToWstring(buf)); | ||
} | ||
|
||
Exception FormatException(const char *format, ...) { | ||
va_list args; | ||
va_start(args, format); | ||
Exception e = FormatExceptionV(format, args); | ||
va_end(args); | ||
|
||
return e; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,27 @@ | ||
#pragma once | ||
|
||
#include <string> | ||
|
||
class Exception : public std::exception { | ||
public: | ||
Exception(std::string what) | ||
Exception(std::wstring what) | ||
: m_what(what) { | ||
} | ||
Exception() { | ||
} | ||
|
||
virtual const char *what() { | ||
virtual const wchar_t *what() { | ||
return m_what.c_str(); | ||
} | ||
|
||
Exception& operator=(const Exception &src) { | ||
m_what = src.m_what; | ||
return *this; | ||
} | ||
private: | ||
const std::string m_what; | ||
std::wstring m_what; | ||
}; | ||
|
||
inline Exception FormatException(const char *format, ...) { | ||
va_list args; | ||
va_start(args, format); | ||
char buf[10000]; | ||
vsnprintf(buf, sizeof(buf), format, args); | ||
va_end(args); | ||
|
||
return Exception(buf); | ||
} | ||
|
||
inline Exception FormatExceptionV(const char *format, va_list args) { | ||
char buf[10000]; | ||
vsnprintf(buf, sizeof(buf), format, args); | ||
|
||
return Exception(buf); | ||
} | ||
Exception FormatExceptionV(const wchar_t *format, va_list args); | ||
Exception FormatExceptionV(const char *format, va_list args); | ||
Exception FormatException(const char *format, ...); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters