fix android compile, fix windows system info log, implement touch/stylus events on windows
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -26,3 +26,4 @@ android/release
|
|||||||
PanoPainterPackage/_pkginfo.txt
|
PanoPainterPackage/_pkginfo.txt
|
||||||
PanoPainterPackage/AppPackages/
|
PanoPainterPackage/AppPackages/
|
||||||
PanoPainterPackage/BundleArtifacts/
|
PanoPainterPackage/BundleArtifacts/
|
||||||
|
Thumbs.db
|
||||||
|
|||||||
@@ -270,7 +270,7 @@ JNIEXPORT void JNICALL Java_com_omixlab_panopainter_MainActivity_pickExternalCal
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void pick_file(android_app* mApplication, std::function<void(std::string)> callback)
|
void android_pick_file(android_app* mApplication, std::function<void(std::string)> callback)
|
||||||
{
|
{
|
||||||
// Attaches the current thread to the JVM.
|
// Attaches the current thread to the JVM.
|
||||||
jint lResult;
|
jint lResult;
|
||||||
@@ -941,9 +941,6 @@ static void engine_handle_cmd(struct android_app* app, int32_t cmd) {
|
|||||||
void android_main(struct android_app* state) {
|
void android_main(struct android_app* state) {
|
||||||
struct engine engine;
|
struct engine engine;
|
||||||
|
|
||||||
// Make sure glue isn't stripped.
|
|
||||||
app_dummy();
|
|
||||||
|
|
||||||
memset(&engine, 0, sizeof(engine));
|
memset(&engine, 0, sizeof(engine));
|
||||||
state->userData = &engine;
|
state->userData = &engine;
|
||||||
state->onAppCmd = engine_handle_cmd;
|
state->onAppCmd = engine_handle_cmd;
|
||||||
|
|||||||
@@ -8,6 +8,11 @@ branch = check_output(["git", "rev-parse", "--abbrev-ref", "HEAD"]).rstrip().dec
|
|||||||
shorthash = check_output(["git", "log", "--pretty=format:%h", "-n 1"]).rstrip().decode("utf-8")
|
shorthash = check_output(["git", "log", "--pretty=format:%h", "-n 1"]).rstrip().decode("utf-8")
|
||||||
revcount = int(check_output(["git", "rev-list", "--count", "HEAD"]))
|
revcount = int(check_output(["git", "rev-list", "--count", "HEAD"]))
|
||||||
tag = check_output(["git", "describe", "--tags", "--abbrev=0"]).rstrip().decode("utf-8")
|
tag = check_output(["git", "describe", "--tags", "--abbrev=0"]).rstrip().decode("utf-8")
|
||||||
|
|
||||||
|
if (len(sys.argv) < 2)
|
||||||
|
print "Version generation failed, target not specified. Define release/debug."
|
||||||
|
exit(0)
|
||||||
|
|
||||||
config = sys.argv[2].lower()
|
config = sys.argv[2].lower()
|
||||||
|
|
||||||
version = "%s.%d (%s-%s-%s)" % (tag, revcount, shorthash, branch, config)
|
version = "%s.%d (%s-%s-%s)" % (tag, revcount, shorthash, branch, config)
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
#ifdef __ANDROID__
|
#ifdef __ANDROID__
|
||||||
void displayKeyboard(android_app* mApplication, bool pShow);
|
void displayKeyboard(android_app* mApplication, bool pShow);
|
||||||
void pick_file(android_app* mApplication, std::function<void(std::string)> callback);
|
void android_pick_file(android_app* mApplication, std::function<void(std::string)> callback);
|
||||||
#elif _WIN32
|
#elif _WIN32
|
||||||
std::string win32_open_file(const char* filter);
|
std::string win32_open_file(const char* filter);
|
||||||
std::string win32_open_dir();
|
std::string win32_open_dir();
|
||||||
@@ -63,7 +63,7 @@ void App::pick_image(std::function<void(std::string path)> callback)
|
|||||||
callback(path);
|
callback(path);
|
||||||
});
|
});
|
||||||
#elif __ANDROID__
|
#elif __ANDROID__
|
||||||
pick_file(and_app, callback);
|
android_pick_file(and_app, callback);
|
||||||
#elif _WIN32
|
#elif _WIN32
|
||||||
std::string path = win32_open_file("Image Files (*.jpg, *.png)\0*.jpg;*.png");
|
std::string path = win32_open_file("Image Files (*.jpg, *.png)\0*.jpg;*.png");
|
||||||
if (!path.empty())
|
if (!path.empty())
|
||||||
@@ -88,7 +88,7 @@ void App::pick_file(std::vector<std::string> types, std::function<void (std::str
|
|||||||
callback(path);
|
callback(path);
|
||||||
});
|
});
|
||||||
#elif __ANDROID__
|
#elif __ANDROID__
|
||||||
pick_file(and_app, callback);
|
//android_pick_file(and_app, callback);
|
||||||
#elif _WIN32
|
#elif _WIN32
|
||||||
std::string filter = "Image Files (";
|
std::string filter = "Image Files (";
|
||||||
bool first_type = true;
|
bool first_type = true;
|
||||||
|
|||||||
@@ -122,7 +122,7 @@ void LogRemote::log(const wchar_t* format, ...)
|
|||||||
//use converter (.to_bytes: wstr->str, .from_bytes: str->wstr)
|
//use converter (.to_bytes: wstr->str, .from_bytes: str->wstr)
|
||||||
//std::string converted_str = converter.to_bytes(string_to_convert);
|
//std::string converted_str = converter.to_bytes(string_to_convert);
|
||||||
|
|
||||||
m_mq.Post(std::move(converted));
|
m_mq.Post(std::string(converted));
|
||||||
if (m_logfile.is_open())
|
if (m_logfile.is_open())
|
||||||
{
|
{
|
||||||
auto line = converted + "\n";
|
auto line = converted + "\n";
|
||||||
|
|||||||
68
src/main.cpp
68
src/main.cpp
@@ -264,7 +264,8 @@ static void SetupExceptionHandler()
|
|||||||
BT_SetFlags(BTF_DETAILEDMODE | BTF_ATTACHREPORT | BTF_SCREENCAPTURE);
|
BT_SetFlags(BTF_DETAILEDMODE | BTF_ATTACHREPORT | BTF_SCREENCAPTURE);
|
||||||
|
|
||||||
// = BugTrapServer ===========================================
|
// = BugTrapServer ===========================================
|
||||||
BT_SetSupportServer(_T("omigamedev.ddns.net"), 8088);
|
//BT_SetSupportServer(_T("omigamedev.ddns.net"), 8088);
|
||||||
|
BT_SetSupportEMail(_T("info@panopainter.com"));
|
||||||
// - or -
|
// - or -
|
||||||
//BT_SetSupportServer(_T("127.0.0.1"), 9999);
|
//BT_SetSupportServer(_T("127.0.0.1"), 9999);
|
||||||
|
|
||||||
@@ -454,6 +455,12 @@ int main(int argc, char** argv)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// link: https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-registertouchwindow
|
||||||
|
if (RegisterTouchWindow(hWnd, 0) == 0)
|
||||||
|
{
|
||||||
|
LOG("RegisterTouchWindow error: %s", GetLastErrorAsString().c_str());
|
||||||
|
}
|
||||||
|
|
||||||
auto monitor = MonitorFromWindow(hWnd, MONITOR_DEFAULTTONEAREST);
|
auto monitor = MonitorFromWindow(hWnd, MONITOR_DEFAULTTONEAREST);
|
||||||
auto x = unsigned{};
|
auto x = unsigned{};
|
||||||
auto y = unsigned{};
|
auto y = unsigned{};
|
||||||
@@ -520,7 +527,6 @@ int main(int argc, char** argv)
|
|||||||
async_lock();
|
async_lock();
|
||||||
while (!working_list.empty())
|
while (!working_list.empty())
|
||||||
{
|
{
|
||||||
|
|
||||||
working_list.front()();
|
working_list.front()();
|
||||||
working_list.pop_front();
|
working_list.pop_front();
|
||||||
}
|
}
|
||||||
@@ -589,6 +595,12 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp)
|
|||||||
static bool leftDown = false;
|
static bool leftDown = false;
|
||||||
static DWORD lastTime;
|
static DWORD lastTime;
|
||||||
static POINT lastPoint;
|
static POINT lastPoint;
|
||||||
|
|
||||||
|
auto extra = GetMessageExtraInfo();
|
||||||
|
auto pointer_source = WacomTablet::I.m_stylus ? kEventSource::Stylus : kEventSource::Mouse;
|
||||||
|
if ((extra & 0xFFFFFF00) == 0xFF515700)
|
||||||
|
pointer_source = kEventSource::Touch;
|
||||||
|
|
||||||
switch (msg)
|
switch (msg)
|
||||||
{
|
{
|
||||||
case WM_USER_CLOSE:
|
case WM_USER_CLOSE:
|
||||||
@@ -624,13 +636,29 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp)
|
|||||||
}
|
}
|
||||||
case WM_ACTIVATE:
|
case WM_ACTIVATE:
|
||||||
{
|
{
|
||||||
int active = GET_WM_ACTIVATE_STATE(wp, lp);
|
std::lock_guard<std::mutex> lock(task_mutex);
|
||||||
WacomTablet::I.set_focus(active);
|
tasklist.emplace_back([=] {
|
||||||
|
int active = GET_WM_ACTIVATE_STATE(wp, lp);
|
||||||
|
WacomTablet::I.set_focus(active);
|
||||||
|
});
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
// case WM_TOUCH:
|
||||||
|
// {
|
||||||
|
// std::lock_guard<std::mutex> lock(task_mutex);
|
||||||
|
// tasklist.emplace_back([=] {
|
||||||
|
// //LOG("touch");
|
||||||
|
// });
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
case WT_PACKET:
|
case WT_PACKET:
|
||||||
WacomTablet::I.handle_message(hWnd, msg, wp, lp);
|
{
|
||||||
|
std::lock_guard<std::mutex> lock(task_mutex);
|
||||||
|
tasklist.emplace_back([=] {
|
||||||
|
WacomTablet::I.handle_message(hWnd, msg, wp, lp);
|
||||||
|
});
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case WM_SYSKEYDOWN:
|
case WM_SYSKEYDOWN:
|
||||||
case WM_KEYDOWN:
|
case WM_KEYDOWN:
|
||||||
{
|
{
|
||||||
@@ -660,45 +688,45 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp)
|
|||||||
case WM_MOUSEMOVE:
|
case WM_MOUSEMOVE:
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lock(task_mutex);
|
std::lock_guard<std::mutex> lock(task_mutex);
|
||||||
tasklist.emplace_back([lp, p = WacomTablet::I.get_pressure()]{
|
tasklist.emplace_back([lp, pointer_source, p = WacomTablet::I.get_pressure()]{
|
||||||
App::I.mouse_move((float)GET_X_LPARAM(lp), (float)GET_Y_LPARAM(lp), p, kEventSource::Mouse);
|
App::I.mouse_move((float)GET_X_LPARAM(lp), (float)GET_Y_LPARAM(lp), p, pointer_source);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case WM_LBUTTONDOWN:
|
case WM_LBUTTONDOWN:
|
||||||
SetCapture(hWnd);
|
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lock(task_mutex);
|
std::lock_guard<std::mutex> lock(task_mutex);
|
||||||
tasklist.emplace_back([lp, p = WacomTablet::I.get_pressure()]{
|
tasklist.emplace_back([lp, pointer_source, hWnd, p = WacomTablet::I.get_pressure()]{
|
||||||
App::I.mouse_down(0, (float)GET_X_LPARAM(lp), (float)GET_Y_LPARAM(lp), p, kEventSource::Mouse);
|
SetCapture(hWnd);
|
||||||
|
App::I.mouse_down(0, (float)GET_X_LPARAM(lp), (float)GET_Y_LPARAM(lp), p, pointer_source);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case WM_LBUTTONUP:
|
case WM_LBUTTONUP:
|
||||||
WacomTablet::I.reset_pressure();
|
|
||||||
ReleaseCapture();
|
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lock(task_mutex);
|
std::lock_guard<std::mutex> lock(task_mutex);
|
||||||
tasklist.emplace_back([lp]{
|
tasklist.emplace_back([lp, pointer_source]{
|
||||||
App::I.mouse_up(0, (float)GET_X_LPARAM(lp), (float)GET_Y_LPARAM(lp), kEventSource::Mouse);
|
WacomTablet::I.reset_pressure();
|
||||||
|
ReleaseCapture();
|
||||||
|
App::I.mouse_up(0, (float)GET_X_LPARAM(lp), (float)GET_Y_LPARAM(lp), pointer_source);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case WM_RBUTTONDOWN:
|
case WM_RBUTTONDOWN:
|
||||||
SetCapture(hWnd);
|
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lock(task_mutex);
|
std::lock_guard<std::mutex> lock(task_mutex);
|
||||||
tasklist.emplace_back([lp]{
|
tasklist.emplace_back([lp, pointer_source, hWnd]{
|
||||||
App::I.mouse_down(1, (float)GET_X_LPARAM(lp), (float)GET_Y_LPARAM(lp), 1.f, kEventSource::Mouse);
|
SetCapture(hWnd);
|
||||||
|
App::I.mouse_down(1, (float)GET_X_LPARAM(lp), (float)GET_Y_LPARAM(lp), 1.f, pointer_source);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case WM_RBUTTONUP:
|
case WM_RBUTTONUP:
|
||||||
ReleaseCapture();
|
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lock(task_mutex);
|
std::lock_guard<std::mutex> lock(task_mutex);
|
||||||
tasklist.emplace_back([lp]{
|
tasklist.emplace_back([lp, pointer_source]{
|
||||||
App::I.mouse_up(1, (float)GET_X_LPARAM(lp), (float)GET_Y_LPARAM(lp), kEventSource::Mouse);
|
ReleaseCapture();
|
||||||
|
App::I.mouse_up(1, (float)GET_X_LPARAM(lp), (float)GET_Y_LPARAM(lp), pointer_source);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -72,6 +72,7 @@ void NodeButton::parse_attributes(kAttribute ka, const tinyxml2::XMLAttribute* a
|
|||||||
color_normal = m_border->m_color;
|
color_normal = m_border->m_color;
|
||||||
color_hover = glm::clamp(m_border->m_color + glm::vec4(.1, .1, .1, 0), {0,0,0,0}, {1,1,1,1});
|
color_hover = glm::clamp(m_border->m_color + glm::vec4(.1, .1, .1, 0), {0,0,0,0}, {1,1,1,1});
|
||||||
color_down = glm::clamp(m_border->m_color + glm::vec4(.2, .2, .2, 0), {0,0,0,0}, {1,1,1,1});
|
color_down = glm::clamp(m_border->m_color + glm::vec4(.2, .2, .2, 0), {0,0,0,0}, {1,1,1,1});
|
||||||
|
break;
|
||||||
case kAttribute::Padding:
|
case kAttribute::Padding:
|
||||||
case kAttribute::Width:
|
case kAttribute::Width:
|
||||||
case kAttribute::Height:
|
case kAttribute::Height:
|
||||||
|
|||||||
@@ -49,11 +49,11 @@ kEventResult NodeButtonCustom::handle_event(Event* e)
|
|||||||
mouse_capture();
|
mouse_capture();
|
||||||
break;
|
break;
|
||||||
case kEventType::MouseUpL:
|
case kEventType::MouseUpL:
|
||||||
#if defined(__IOS__) || defined(__ANDROID__)
|
// if using touch or stylus, unfocus the button
|
||||||
m_color = color_normal;
|
if (((MouseEvent*)e)->m_source == kEventSource::Mouse)
|
||||||
#else
|
|
||||||
m_color = m_mouse_inside ? color_hover : color_normal;
|
m_color = m_mouse_inside ? color_hover : color_normal;
|
||||||
#endif
|
else
|
||||||
|
m_color = color_normal;
|
||||||
mouse_release();
|
mouse_release();
|
||||||
if (m_mouse_inside && on_click != nullptr)
|
if (m_mouse_inside && on_click != nullptr)
|
||||||
on_click(this);
|
on_click(this);
|
||||||
|
|||||||
@@ -14,5 +14,5 @@ public:
|
|||||||
NodeText* m_title;
|
NodeText* m_title;
|
||||||
virtual Node* clone_instantiate() const override;
|
virtual Node* clone_instantiate() const override;
|
||||||
virtual void init() override;
|
virtual void init() override;
|
||||||
virtual kEventResult handle_event(Event* e);
|
virtual kEventResult handle_event(Event* e) override;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user