Merge branch 'master' of https://bitbucket.org/omigamedev/new_engine
This commit is contained in:
@@ -77,7 +77,7 @@
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
<IncludePath>libs\glm;libs\glew-2.0.0\include;libs\stb;libs\tinyxml2;libs\yoga;libs\curl-win\include;libs\jpeg;libs\wacom;libs\bugtrap-client\include;libs\poly2tri\poly2tri;libs\base64;$(IncludePath)</IncludePath>
|
||||
<IncludePath>libs\glm;libs\glew-2.0.0\include;libs\stb;libs\tinyxml2;libs\yoga;libs\curl-win\include;libs\jpeg;libs\wacom;libs\bugtrap-client\include;libs\poly2tri\poly2tri;libs\base64;libs\sqlite3;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>libs\curl-win\lib\dll-$(Configuration)-$(PlatformShortName);libs\glew-2.0.0\lib\Release\$(Platform);libs\bugtrap-client\lib;$(LibraryPath)</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
@@ -87,7 +87,7 @@
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<IncludePath>libs\glm;libs\glew-2.0.0\include;libs\stb;libs\tinyxml2;libs\yoga;libs\curl-win\include;libs\jpeg;libs\wacom;libs\bugtrap-client\include;libs\poly2tri\poly2tri;libs\base64;$(IncludePath)</IncludePath>
|
||||
<IncludePath>libs\glm;libs\glew-2.0.0\include;libs\stb;libs\tinyxml2;libs\yoga;libs\curl-win\include;libs\jpeg;libs\wacom;libs\bugtrap-client\include;libs\poly2tri\poly2tri;libs\base64;libs\sqlite3;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>libs\curl-win\lib\dll-$(Configuration)-$(PlatformShortName);libs\glew-2.0.0\lib\Release\$(Platform);libs\bugtrap-client\lib;$(LibraryPath)</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
@@ -167,6 +167,10 @@
|
||||
</PreBuildEvent>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="libs\sqlite3\sqlite3.c">
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">NotUsing</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">NotUsing</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\action.cpp" />
|
||||
<ClCompile Include="src\app.cpp" />
|
||||
<ClCompile Include="src\app_cloud.cpp" />
|
||||
@@ -292,6 +296,8 @@
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="libs\sqlite3\sqlite3.h" />
|
||||
<ClInclude Include="libs\sqlite3\sqlite3ext.h" />
|
||||
<ClInclude Include="src\action.h" />
|
||||
<ClInclude Include="src\app.h" />
|
||||
<ClInclude Include="src\asset.h" />
|
||||
|
||||
@@ -40,6 +40,9 @@
|
||||
<Filter Include="extras">
|
||||
<UniqueIdentifier>{e631ac80-1b9b-424f-8adf-e2bab71a566d}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="libs\sqlite3">
|
||||
<UniqueIdentifier>{ef44d179-f28b-458c-b3df-be2895553149}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="src\app.cpp">
|
||||
@@ -264,6 +267,9 @@
|
||||
<ClCompile Include="src\node_dialog_resize.cpp">
|
||||
<Filter>Source Files\ui</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="libs\sqlite3\sqlite3.c">
|
||||
<Filter>libs\sqlite3</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="src\app.h">
|
||||
@@ -473,6 +479,12 @@
|
||||
<ClInclude Include="src\node_dialog_resize.h">
|
||||
<Filter>Header Files\ui</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="libs\sqlite3\sqlite3.h">
|
||||
<Filter>libs\sqlite3</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="libs\sqlite3\sqlite3ext.h">
|
||||
<Filter>libs\sqlite3</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="PanoPainter.rc">
|
||||
|
||||
@@ -61,7 +61,9 @@ BOOL LoadWintab( void )
|
||||
{
|
||||
// ghWintab = LoadLibraryA( "C:\\dev\\mainline\\Wacom\\Win\\Win32\\Debug\\Wacom_Tablet.dll" );
|
||||
// ghWintab = LoadLibraryA( "C:\\dev\\mainline\\Wacom\\Win\\Win32\\Debug\\Wintab32.dll" );
|
||||
ghWintab = LoadLibraryA( "Wintab32.dll" );
|
||||
LOG("calling LoadLibrary");
|
||||
ghWintab = LoadLibrary(L"Wintab32.dll");
|
||||
LOG("LoadLibrary called");
|
||||
|
||||
if ( !ghWintab )
|
||||
{
|
||||
@@ -71,6 +73,8 @@ BOOL LoadWintab( void )
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
LOG("WinTab found");
|
||||
|
||||
// Explicitly find the exported Wintab functions in which we are interested.
|
||||
// We are using the ASCII, not unicode versions (where applicable).
|
||||
GETPROCADDRESS( WTOPENA, WTOpenA );
|
||||
|
||||
@@ -208,15 +208,13 @@ int progress_callback_upload(void *clientp, curl_off_t dltotal,
|
||||
return 0;
|
||||
}
|
||||
|
||||
void App::download(std::string filename, std::function<void(float)> progress)
|
||||
void App::download(std::string url, std::string dest_filepath, std::function<void(float)> progress)
|
||||
{
|
||||
CURL *curl = curl_easy_init();
|
||||
if (curl)
|
||||
{
|
||||
auto dest = data_path + "/" + filename;
|
||||
FILE* fp = fopen(dest.c_str(), "wb");
|
||||
std::string url = "https://panopainter.com/cloud/cloud-dwl.php?file=" + filename;
|
||||
LOG("download %s to %s", url.c_str(), dest.c_str());
|
||||
FILE* fp = fopen(dest_filepath.c_str(), "wb");
|
||||
LOG("download %s to %s", url.c_str(), dest_filepath.c_str());
|
||||
curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
|
||||
curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp);
|
||||
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, curl_data_write);
|
||||
|
||||
@@ -69,6 +69,7 @@ public:
|
||||
std::string doc_path;
|
||||
std::string doc_dir;
|
||||
std::string doc_filename;
|
||||
bool has_stylus = false;
|
||||
float width;
|
||||
float height;
|
||||
bool keys[256];
|
||||
@@ -132,6 +133,7 @@ public:
|
||||
bool key_up(kKey key);
|
||||
bool key_char(char key);
|
||||
void toggle_ui();
|
||||
void set_stylus();
|
||||
void message_box(const std::string& title, const std::string& text);
|
||||
|
||||
void rec_clear();
|
||||
@@ -165,7 +167,7 @@ public:
|
||||
void cloud_upload_all();
|
||||
void cloud_browse();
|
||||
void upload(std::string filename, std::string name = "", std::function<void(float)> progress = nullptr);
|
||||
void download(std::string filename, std::function<void(float)> progress = nullptr);
|
||||
void download(std::string url, std::string dest_filepath, std::function<void(float)> progress = nullptr);
|
||||
bool check_license();
|
||||
|
||||
std::shared_ptr<NodeProgressBar> show_progress(const std::string& title);
|
||||
|
||||
@@ -146,7 +146,8 @@ void App::cloud_browse()
|
||||
m->m_message->set_text("Download in progress");
|
||||
async_redraw();
|
||||
async_end();
|
||||
download(dialog->selected_path, [this,m](float p){
|
||||
std::string url = "https://panopainter.com/cloud/cloud-dwl.php?file=" + dialog->selected_file;
|
||||
download(url, dialog->selected_path, [this,m](float p){
|
||||
static char progress[256];
|
||||
sprintf(progress, "Download in progress %.2f%%", p * 100.f);
|
||||
async_start();
|
||||
|
||||
@@ -303,3 +303,10 @@ void App::toggle_ui()
|
||||
m->m_children[i]->m_display = fullscreen;
|
||||
fullscreen = !fullscreen;
|
||||
}
|
||||
|
||||
void App::set_stylus()
|
||||
{
|
||||
has_stylus = true;
|
||||
if (canvas)
|
||||
canvas->m_canvas->m_touch_lock = true;
|
||||
}
|
||||
|
||||
@@ -207,8 +207,8 @@ void ui::Stroke::add_point(glm::vec2 pos, float pressure)
|
||||
m_curve = glm::min(m_curve + 0.1f, 1.f);
|
||||
//pressure = pressure * glm::pow(m_curve, 2.f);
|
||||
#endif // __IOS__
|
||||
m_pressure_buff.add(pressure);
|
||||
pressure = m_pressure_buff.average();
|
||||
//m_pressure_buff.add(pressure);
|
||||
//pressure = m_pressure_buff.average();
|
||||
|
||||
if (m_brush.m_tip_size_pressure)
|
||||
m_step = glm::max(m_brush.m_tip_spacing * m_brush.m_tip_size * pressure * 800.f, 1.f);
|
||||
|
||||
@@ -115,7 +115,7 @@ public:
|
||||
static Canvas* I;
|
||||
NodeCanvas* m_node = nullptr;
|
||||
bool m_alpha_lock = false;
|
||||
bool m_touch_lock = true;
|
||||
bool m_touch_lock = false;
|
||||
glm::mat4 m_mv{ 1 };
|
||||
glm::mat4 m_proj{ 1 };
|
||||
glm::vec4 m_box{ 0 };
|
||||
|
||||
@@ -16,8 +16,20 @@ void CanvasModeBasicCamera::on_MouseEvent(MouseEvent* me, glm::vec2& loc)
|
||||
switch (me->m_type)
|
||||
{
|
||||
case kEventType::MouseDownL:
|
||||
// if (canvas->m_touch_lock && me->m_source == kEventSource::Touch)
|
||||
// {
|
||||
// m_draggingR = true;
|
||||
// m_dragR_start = me->m_pos;
|
||||
// m_pan_start = canvas->m_pan;
|
||||
// node->mouse_capture();
|
||||
// }
|
||||
break;
|
||||
case kEventType::MouseUpL:
|
||||
// if (canvas->m_touch_lock && me->m_source == kEventSource::Touch)
|
||||
// {
|
||||
// m_draggingR = false;
|
||||
// node->mouse_release();
|
||||
// }
|
||||
break;
|
||||
case kEventType::MouseDownR:
|
||||
if (App::I.keys[(int)kKey::KeyAlt])
|
||||
|
||||
@@ -25,6 +25,7 @@ public:
|
||||
class CanvasModeBasicCamera : public CanvasMode
|
||||
{
|
||||
bool m_draggingR = false;
|
||||
bool m_draggingT = false; // touch drag
|
||||
glm::vec2 m_dragR_start;
|
||||
glm::vec2 m_pan_start;
|
||||
float m_camera_fov;
|
||||
|
||||
@@ -115,7 +115,7 @@ void LogRemote::log(const wchar_t* format, ...)
|
||||
|
||||
mbstate_t st = {};
|
||||
std::string converted;
|
||||
converted.reserve(string_to_convert.size());
|
||||
converted.resize(string_to_convert.size());
|
||||
const wchar_t * wptr = string_to_convert.c_str();
|
||||
std::wcsrtombs((char*)converted.data(), &wptr, converted.capacity(), &st);
|
||||
|
||||
|
||||
240
src/main.cpp
240
src/main.cpp
@@ -30,6 +30,9 @@ int gl_count = 0;
|
||||
std::deque<std::packaged_task<void()>> tasklist;
|
||||
std::mutex task_mutex;
|
||||
float timer_stylus = 0;
|
||||
float timer_ink_touch = 0;
|
||||
float timer_ink_pen = 0;
|
||||
bool sandboxed = false;
|
||||
|
||||
//Returns the last Win32 error, in string format. Returns an empty string if there is no error.
|
||||
std::string GetLastErrorAsString()
|
||||
@@ -184,14 +187,38 @@ int read_WMI_info()
|
||||
|
||||
auto log_field = [](const wchar_t* section, IWbemClassObject* clsObj, const wchar_t* field) {
|
||||
VARIANT vRet;
|
||||
CIMTYPE pType;
|
||||
VariantInit(&vRet);
|
||||
if (SUCCEEDED(clsObj->Get(field, 0, &vRet, NULL, NULL)) && vRet.vt == VT_BSTR)
|
||||
if (SUCCEEDED(clsObj->Get(field, 0, &vRet, &pType, NULL)))
|
||||
{
|
||||
LOGW(L"%s %s: %s", section, field, vRet.bstrVal);
|
||||
if (pType == CIM_STRING && pType != CIM_EMPTY && pType != CIM_ILLEGAL)
|
||||
{
|
||||
LOGW(L"%s %s: %s", section, field, vRet.bstrVal);
|
||||
}
|
||||
else if (pType == CIM_UINT32 && pType != CIM_EMPTY && pType != CIM_ILLEGAL)
|
||||
{
|
||||
LOGW(L"%s %s: %d", section, field, vRet.uintVal);
|
||||
}
|
||||
|
||||
VariantClear(&vRet);
|
||||
}
|
||||
};
|
||||
|
||||
auto get_int = [](IWbemClassObject* clsObj, const wchar_t* field) {
|
||||
VARIANT vRet;
|
||||
CIMTYPE pType;
|
||||
VariantInit(&vRet);
|
||||
int ret = 0;
|
||||
if (SUCCEEDED(clsObj->Get(field, 0, &vRet, &pType, NULL)))
|
||||
{
|
||||
if (pType == CIM_UINT32 && pType != CIM_EMPTY && pType != CIM_ILLEGAL)
|
||||
ret = vRet.uintVal;
|
||||
VariantClear(&vRet);
|
||||
}
|
||||
return ret;
|
||||
};
|
||||
|
||||
|
||||
// GET DEVICE INFO
|
||||
{
|
||||
IEnumWbemClassObject* pEnumerator = NULL;
|
||||
@@ -249,7 +276,69 @@ int read_WMI_info()
|
||||
pEnumerator->Release();
|
||||
}
|
||||
|
||||
|
||||
pService->Release();
|
||||
pService = NULL;
|
||||
if (FAILED(hRes = pLocator->ConnectServer(L"root\\Microsoft\\Windows\\DeviceGuard", NULL, NULL, NULL, WBEM_FLAG_CONNECT_USE_MAX_WAIT, NULL, NULL, &pService)))
|
||||
{
|
||||
pLocator->Release();
|
||||
LOG("Unable to connect to \"DeviceGuard\": %x", hRes);
|
||||
return 1;
|
||||
}
|
||||
|
||||
// GET DEVICE GUARD
|
||||
{
|
||||
IEnumWbemClassObject* pEnumerator = NULL;
|
||||
if (FAILED(hRes = pService->ExecQuery(L"WQL", L"SELECT * FROM Win32_DeviceGuard", WBEM_FLAG_FORWARD_ONLY, NULL, &pEnumerator)))
|
||||
{
|
||||
pLocator->Release();
|
||||
pService->Release();
|
||||
LOG("Unable to retrive desktop monitors: %x", hRes);
|
||||
return 1;
|
||||
}
|
||||
|
||||
IWbemClassObject* clsObj = NULL;
|
||||
int numElems;
|
||||
while ((hRes = pEnumerator->Next(WBEM_INFINITE, 1, &clsObj, (ULONG*)&numElems)) != WBEM_S_FALSE)
|
||||
{
|
||||
if (FAILED(hRes))
|
||||
break;
|
||||
|
||||
if (get_int(clsObj, L"CodeIntegrityPolicyEnforcementStatus") > 0)
|
||||
{
|
||||
LOG("SANDBOX DETECTED");
|
||||
sandboxed = true;
|
||||
}
|
||||
|
||||
SAFEARRAY *psaNames = NULL;
|
||||
if (SUCCEEDED(clsObj->GetNames(0, WBEM_FLAG_ALWAYS | WBEM_FLAG_NONSYSTEM_ONLY, 0, &psaNames)))
|
||||
{
|
||||
// Get the number of properties.
|
||||
long lLower, lUpper;
|
||||
BSTR PropName = NULL;
|
||||
SafeArrayGetLBound(psaNames, 1, &lLower);
|
||||
SafeArrayGetUBound(psaNames, 1, &lUpper);
|
||||
|
||||
for (long i = lLower; i <= lUpper; i++)
|
||||
{
|
||||
// Get this property.
|
||||
SafeArrayGetElement(psaNames, &i, &PropName);
|
||||
|
||||
LOGW(L"Prop: %s", PropName);
|
||||
log_field(L"DeviceGuard", clsObj, PropName);
|
||||
|
||||
SysFreeString(PropName);
|
||||
}
|
||||
|
||||
SafeArrayDestroy(psaNames);
|
||||
}
|
||||
|
||||
clsObj->Release();
|
||||
}
|
||||
pEnumerator->Release();
|
||||
}
|
||||
|
||||
|
||||
pLocator->Release();
|
||||
CoUninitialize();
|
||||
|
||||
@@ -261,6 +350,7 @@ static void SetupExceptionHandler()
|
||||
{
|
||||
// Setup exception handler
|
||||
BT_SetAppName(_T("PanoPainter"));
|
||||
BT_SetAppVersion(g_version_w);
|
||||
//BT_SetSupportEMail(_T("your@email.com"));
|
||||
BT_SetFlags(BTF_DETAILEDMODE | BTF_ATTACHREPORT | BTF_SCREENCAPTURE);
|
||||
|
||||
@@ -273,6 +363,7 @@ static void SetupExceptionHandler()
|
||||
// = BugTrapWebServer ========================================
|
||||
//BT_SetSupportServer(_T("http://localhost/BugTrapWebServer/RequestHandler.aspx"), BUGTRAP_HTTP_PORT);
|
||||
//BT_SetSupportServer(_T("http://omigamedev.ddns.net:8088/source/Server/BugTrapWebServer/RequestHandler.aspx"), BUGTRAP_HTTP_PORT);
|
||||
BT_SetSupportServer(_T("http://panopainter.com/bug/"), BUGTRAP_HTTP_PORT);
|
||||
|
||||
// required for VS 2005 & 2008
|
||||
BT_InstallSehFilter();
|
||||
@@ -284,8 +375,10 @@ static void SetupExceptionHandler()
|
||||
// BT_SetLogEchoMode(g_iLogHandle, BTLE_STDERR | BTLE_DBGOUT);
|
||||
//
|
||||
// PCTSTR pszLogFileName = BT_GetLogFileName(g_iLogHandle);
|
||||
TCHAR wpath[1024];
|
||||
GetFullPathNameW(L"panopainter-log.txt", 1024, wpath, nullptr);
|
||||
TCHAR wpath[MAX_PATH];
|
||||
//GetFullPathNameW(L"panopainter-log.txt", 1024, wpath, nullptr);
|
||||
auto log_file = App::I.data_path + "/panopainter-log.txt";
|
||||
std::mbstowcs(wpath, log_file.c_str(), log_file.size());
|
||||
BT_AddLogFile(wpath);
|
||||
|
||||
BT_SetPreErrHandler([](INT_PTR){
|
||||
@@ -365,10 +458,16 @@ int main(int argc, char** argv)
|
||||
|
||||
RegisterClass(&wc);
|
||||
|
||||
auto monitor = MonitorFromWindow(0, MONITOR_DEFAULTTOPRIMARY);
|
||||
auto x = unsigned{};
|
||||
auto y = unsigned{};
|
||||
GetDpiForMonitor(monitor, MDT_EFFECTIVE_DPI, &x, &y);
|
||||
App::I.zoom = (float)x / 96.f;
|
||||
|
||||
AdjustWindowRect(&clientRect, WS_OVERLAPPEDWINDOW, false);
|
||||
hWnd = CreateWindow(wc.lpszClassName, L"PanoPainter", WS_OVERLAPPEDWINDOW,
|
||||
CW_USEDEFAULT, CW_USEDEFAULT, clientRect.right - clientRect.left,
|
||||
clientRect.bottom - clientRect.top, 0, 0, hInst, 0);
|
||||
hWnd = CreateWindow(wc.lpszClassName, L"PanoPainter", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT,
|
||||
(float)(clientRect.right - clientRect.left) * App::I.zoom,
|
||||
(float)(clientRect.bottom - clientRect.top) * App::I.zoom, 0, 0, hInst, 0);
|
||||
|
||||
// Setup GL Rendering Context
|
||||
pfd.nSize = sizeof(pfd);
|
||||
@@ -427,9 +526,9 @@ int main(int argc, char** argv)
|
||||
wglDeleteContext(hRC);
|
||||
DestroyWindow(hWnd);
|
||||
|
||||
hWnd = CreateWindow(wc.lpszClassName, window_title, WS_OVERLAPPEDWINDOW,
|
||||
CW_USEDEFAULT, CW_USEDEFAULT, clientRect.right - clientRect.left,
|
||||
clientRect.bottom - clientRect.top, 0, 0, hInst, 0);
|
||||
hWnd = CreateWindow(wc.lpszClassName, window_title, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT,
|
||||
(float)(clientRect.right - clientRect.left) * App::I.zoom,
|
||||
(float)(clientRect.bottom - clientRect.top) * App::I.zoom, 0, 0, hInst, 0);
|
||||
|
||||
hDC = GetDC(hWnd);
|
||||
wglChoosePixelFormatARB(hDC, pixel_attribs, nullptr, 1, &pxfmt, &numFormat);
|
||||
@@ -462,35 +561,38 @@ int main(int argc, char** argv)
|
||||
LOG("RegisterTouchWindow error: %s", GetLastErrorAsString().c_str());
|
||||
}
|
||||
|
||||
auto monitor = MonitorFromWindow(hWnd, MONITOR_DEFAULTTONEAREST);
|
||||
auto x = unsigned{};
|
||||
auto y = unsigned{};
|
||||
GetDpiForMonitor(monitor, MDT_EFFECTIVE_DPI, &x, &y);
|
||||
App::I.zoom = (float)x / 96.f;
|
||||
|
||||
LOG("init app");
|
||||
App::I.init();
|
||||
|
||||
LOG("show main window");
|
||||
ShowWindow(hWnd, SW_NORMAL);
|
||||
WacomTablet::I.init(hWnd);
|
||||
|
||||
if (!sandboxed)
|
||||
{
|
||||
LOG("init WinTab");
|
||||
WacomTablet::I.init(hWnd);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("SKIP init WinTab");
|
||||
}
|
||||
|
||||
LOG("change icon");
|
||||
SendMessage(hWnd, WM_SETICON, ICON_SMALL,
|
||||
(LPARAM)LoadIcon(GetModuleHandle(0), MAKEINTRESOURCE(IDI_ICON1)));
|
||||
|
||||
LOG("set redraw interval");
|
||||
SetTimer(hWnd, 1, 500, [](HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime) {
|
||||
App::I.redraw = true;
|
||||
});
|
||||
|
||||
SetWindowPos(hWnd, NULL, 0, 0,
|
||||
(float)(clientRect.right - clientRect.left) * App::I.zoom,
|
||||
(float)(clientRect.bottom - clientRect.top) * App::I.zoom,
|
||||
SWP_NOMOVE | SWP_NOZORDER | SWP_NOOWNERZORDER);
|
||||
|
||||
bool running = true;
|
||||
std::mutex render_mutex;
|
||||
std::condition_variable render_cv;
|
||||
|
||||
std::thread renderer([&] {
|
||||
BT_SetTerminate();
|
||||
LOG("start render thread");
|
||||
const float target_fps = 10;
|
||||
const float target_tick_rate = 60;
|
||||
unsigned long t0 = GetTickCount();
|
||||
@@ -507,6 +609,8 @@ int main(int argc, char** argv)
|
||||
render_timer += dt;
|
||||
frame_timer += dt;
|
||||
timer_stylus += dt;
|
||||
timer_ink_touch += dt;
|
||||
timer_ink_pen += dt;
|
||||
t0 = t1;
|
||||
|
||||
if (one_sec > 1.f)
|
||||
@@ -548,12 +652,23 @@ int main(int argc, char** argv)
|
||||
App::I.redraw = true;
|
||||
render_timer = 0;
|
||||
}
|
||||
if (timer_stylus > 0.1 && WacomTablet::I.m_stylus)
|
||||
if (timer_stylus > 0.1 && (WacomTablet::I.m_stylus || WacomTablet::I.m_eraser))
|
||||
{
|
||||
WacomTablet::I.m_stylus = false;
|
||||
WacomTablet::I.m_eraser = false;
|
||||
App::I.redraw = true;
|
||||
}
|
||||
if (timer_ink_pen > 0.1 && WacomTablet::I.m_ink_pen)
|
||||
{
|
||||
WacomTablet::I.m_ink_pen = false;
|
||||
App::I.redraw = true;
|
||||
}
|
||||
if (timer_ink_touch > 0.1 && WacomTablet::I.m_ink_touch)
|
||||
{
|
||||
WacomTablet::I.m_ink_touch = false;
|
||||
App::I.redraw = true;
|
||||
}
|
||||
|
||||
if (App::I.redraw)
|
||||
{
|
||||
async_lock();
|
||||
@@ -575,6 +690,7 @@ int main(int argc, char** argv)
|
||||
});
|
||||
|
||||
MSG msg;
|
||||
LOG("start main loop");
|
||||
while (running)
|
||||
{
|
||||
// If there any message in the queue process it
|
||||
@@ -664,6 +780,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp)
|
||||
// }
|
||||
case WT_PACKET:
|
||||
{
|
||||
App::I.set_stylus();
|
||||
timer_stylus = 0;
|
||||
std::lock_guard<std::mutex> lock(task_mutex);
|
||||
tasklist.emplace_back([=] {
|
||||
@@ -701,9 +818,17 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(task_mutex);
|
||||
tasklist.emplace_back([lp, extra, p = WacomTablet::I.get_pressure()]{
|
||||
auto pointer_source = WacomTablet::I.m_stylus ? kEventSource::Stylus : kEventSource::Mouse;
|
||||
if ((extra & 0xFFFFFF00) == 0xFF515700)
|
||||
pointer_source = kEventSource::Touch;
|
||||
kEventSource pointer_source;
|
||||
if (WacomTablet::I.m_ink_pen || WacomTablet::I.m_ink_touch)
|
||||
{
|
||||
pointer_source = WacomTablet::I.m_ink_pen ? kEventSource::Stylus : kEventSource::Touch;
|
||||
}
|
||||
else
|
||||
{
|
||||
pointer_source = WacomTablet::I.m_stylus ? kEventSource::Stylus : kEventSource::Mouse;
|
||||
if ((extra & 0xFFFFFF00) == 0xFF515700)
|
||||
pointer_source = kEventSource::Touch;
|
||||
}
|
||||
App::I.mouse_move((float)GET_X_LPARAM(lp), (float)GET_Y_LPARAM(lp), p, pointer_source, WacomTablet::I.m_eraser);
|
||||
});
|
||||
}
|
||||
@@ -713,9 +838,17 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp)
|
||||
std::lock_guard<std::mutex> lock(task_mutex);
|
||||
tasklist.emplace_back([lp, extra, hWnd, p = WacomTablet::I.get_pressure()]{
|
||||
SetCapture(hWnd);
|
||||
auto pointer_source = WacomTablet::I.m_stylus ? kEventSource::Stylus : kEventSource::Mouse;
|
||||
if ((extra & 0xFFFFFF00) == 0xFF515700)
|
||||
pointer_source = kEventSource::Touch;
|
||||
kEventSource pointer_source;
|
||||
if (WacomTablet::I.m_ink_pen || WacomTablet::I.m_ink_touch)
|
||||
{
|
||||
pointer_source = WacomTablet::I.m_ink_pen ? kEventSource::Stylus : kEventSource::Touch;
|
||||
}
|
||||
else
|
||||
{
|
||||
pointer_source = WacomTablet::I.m_stylus ? kEventSource::Stylus : kEventSource::Mouse;
|
||||
if ((extra & 0xFFFFFF00) == 0xFF515700)
|
||||
pointer_source = kEventSource::Touch;
|
||||
}
|
||||
App::I.mouse_down(0, (float)GET_X_LPARAM(lp), (float)GET_Y_LPARAM(lp), p, pointer_source, WacomTablet::I.m_eraser);
|
||||
});
|
||||
}
|
||||
@@ -726,9 +859,17 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp)
|
||||
tasklist.emplace_back([lp, extra]{
|
||||
WacomTablet::I.reset_pressure();
|
||||
ReleaseCapture();
|
||||
auto pointer_source = WacomTablet::I.m_stylus ? kEventSource::Stylus : kEventSource::Mouse;
|
||||
if ((extra & 0xFFFFFF00) == 0xFF515700)
|
||||
pointer_source = kEventSource::Touch;
|
||||
kEventSource pointer_source;
|
||||
if (WacomTablet::I.m_ink_pen || WacomTablet::I.m_ink_touch)
|
||||
{
|
||||
pointer_source = WacomTablet::I.m_ink_pen ? kEventSource::Stylus : kEventSource::Touch;
|
||||
}
|
||||
else
|
||||
{
|
||||
pointer_source = WacomTablet::I.m_stylus ? kEventSource::Stylus : kEventSource::Mouse;
|
||||
if ((extra & 0xFFFFFF00) == 0xFF515700)
|
||||
pointer_source = kEventSource::Touch;
|
||||
}
|
||||
App::I.mouse_up(0, (float)GET_X_LPARAM(lp), (float)GET_Y_LPARAM(lp), pointer_source, WacomTablet::I.m_eraser);
|
||||
});
|
||||
}
|
||||
@@ -738,9 +879,17 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp)
|
||||
std::lock_guard<std::mutex> lock(task_mutex);
|
||||
tasklist.emplace_back([lp, extra, hWnd]{
|
||||
SetCapture(hWnd);
|
||||
auto pointer_source = WacomTablet::I.m_stylus ? kEventSource::Stylus : kEventSource::Mouse;
|
||||
if ((extra & 0xFFFFFF00) == 0xFF515700)
|
||||
pointer_source = kEventSource::Touch;
|
||||
kEventSource pointer_source;
|
||||
if (WacomTablet::I.m_ink_pen || WacomTablet::I.m_ink_touch)
|
||||
{
|
||||
pointer_source = WacomTablet::I.m_ink_pen ? kEventSource::Stylus : kEventSource::Touch;
|
||||
}
|
||||
else
|
||||
{
|
||||
pointer_source = WacomTablet::I.m_stylus ? kEventSource::Stylus : kEventSource::Mouse;
|
||||
if ((extra & 0xFFFFFF00) == 0xFF515700)
|
||||
pointer_source = kEventSource::Touch;
|
||||
}
|
||||
App::I.mouse_down(1, (float)GET_X_LPARAM(lp), (float)GET_Y_LPARAM(lp), 1.f, pointer_source, 0);
|
||||
});
|
||||
}
|
||||
@@ -750,9 +899,17 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp)
|
||||
std::lock_guard<std::mutex> lock(task_mutex);
|
||||
tasklist.emplace_back([lp, extra]{
|
||||
ReleaseCapture();
|
||||
auto pointer_source = WacomTablet::I.m_stylus ? kEventSource::Stylus : kEventSource::Mouse;
|
||||
if ((extra & 0xFFFFFF00) == 0xFF515700)
|
||||
pointer_source = kEventSource::Touch;
|
||||
kEventSource pointer_source;
|
||||
if (WacomTablet::I.m_ink_pen || WacomTablet::I.m_ink_touch)
|
||||
{
|
||||
pointer_source = WacomTablet::I.m_ink_pen ? kEventSource::Stylus : kEventSource::Touch;
|
||||
}
|
||||
else
|
||||
{
|
||||
pointer_source = WacomTablet::I.m_stylus ? kEventSource::Stylus : kEventSource::Mouse;
|
||||
if ((extra & 0xFFFFFF00) == 0xFF515700)
|
||||
pointer_source = kEventSource::Touch;
|
||||
}
|
||||
App::I.mouse_up(1, (float)GET_X_LPARAM(lp), (float)GET_Y_LPARAM(lp), pointer_source, 0);
|
||||
});
|
||||
}
|
||||
@@ -808,6 +965,9 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp)
|
||||
// success, process touchInfo
|
||||
// mark as handled to skip call to DefWindowProc
|
||||
//fHandled = TRUE;
|
||||
timer_ink_touch = 0;
|
||||
WacomTablet::I.m_ink_touch = true;
|
||||
WacomTablet::I.m_pen_pres = 1;
|
||||
}
|
||||
break;
|
||||
case PT_PEN:
|
||||
@@ -822,6 +982,10 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp)
|
||||
// mark as handled to skip call to DefWindowProc
|
||||
//fHandled = TRUE;
|
||||
//penInfo.pressure
|
||||
timer_ink_pen = 0;
|
||||
WacomTablet::I.m_ink_pen = true;
|
||||
WacomTablet::I.m_pen_pres = (float)penInfo.pressure / 1024.f;
|
||||
App::I.set_stylus();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
||||
@@ -126,6 +126,7 @@ bool WacomTablet::init(HWND hWnd)
|
||||
if (ret != sizeof(LOGCONTEXTA))
|
||||
return false;
|
||||
#endif // _DEBUG
|
||||
LOG("TabletInit");
|
||||
g_hCtx = TabletInit(hWnd);
|
||||
if (!g_hCtx)
|
||||
{
|
||||
@@ -166,6 +167,9 @@ void WacomTablet::handle_message(HWND hwnd, UINT Msg, WPARAM wParam, LPARAM lPar
|
||||
static POINT ptOld, ptNew;
|
||||
static UINT prsOld, prsNew;
|
||||
|
||||
if (!gpWTPacket)
|
||||
return;
|
||||
|
||||
if (gpWTPacket((HCTX)lParam, (UINT)wParam, &pkt))
|
||||
{
|
||||
if (HIWORD(pkt.pkButtons) == TBN_DOWN)
|
||||
|
||||
@@ -20,6 +20,8 @@ public:
|
||||
bool m_mouse_down = false;
|
||||
bool m_stylus = false;
|
||||
bool m_eraser = false;
|
||||
bool m_ink_pen = false;
|
||||
bool m_ink_touch = false;
|
||||
|
||||
HCTX TabletInit(HWND hWnd);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user