From 69993f8c59dbfdfc30ffc4357be6e5b35db25476 Mon Sep 17 00:00:00 2001 From: Edouard Dupin Date: Wed, 15 Aug 2012 23:51:08 +0200 Subject: [PATCH] grep mouse event in the Windows platform --- Build | 2 +- Sources/libetk/etk/File.cpp | 6 +- Sources/libewol/ewol/base/guiWindows.cpp | 94 ++++++++++++++++++++---- Sources/libewol/ewol/base/guiX11.cpp | 8 +- 4 files changed, 87 insertions(+), 23 deletions(-) diff --git a/Build b/Build index 3db5b49b..d51a2118 160000 --- a/Build +++ b/Build @@ -1 +1 @@ -Subproject commit 3db5b49b02a5f2fea62b6113d3e01efd5974cc3c +Subproject commit d51a211876127e44d0618683d0aeff154f87d64f diff --git a/Sources/libetk/etk/File.cpp b/Sources/libetk/etk/File.cpp index ce36cd5e..790fca51 100644 --- a/Sources/libetk/etk/File.cpp +++ b/Sources/libetk/etk/File.cpp @@ -44,7 +44,7 @@ etk::UString baseApplName = "ewolNoName"; etk::UString baseFolderCache = "/sdcard/.tmp/cache/"; // Temporary data (can be removed the next time) #else etk::UString baseFolderHome = "~"; // home folder - etk::UString baseFolderData = "assets/"; // program Data + etk::UString baseFolderData = "share/"; // program Data etk::UString baseFolderDataUser = "~/.tmp/userData/"; // Data specific user (local modification) etk::UString baseFolderCache = "~/.tmp/cache/"; // Temporary data (can be removed the next time) #endif @@ -122,11 +122,11 @@ void etk::InitDefaultFolder(const char * applName) #else char cCurrentPath[FILENAME_MAX]; if (!getcwd(cCurrentPath, FILENAME_MAX)) { - baseFolderData = "./assets/"; + baseFolderData = "./share/"; } else { cCurrentPath[FILENAME_MAX - 1] = '\0'; baseFolderData = cCurrentPath; - baseFolderData += "/assets/"; + baseFolderData += "/share/"; } #endif baseFolderDataUser = baseFolderHome; diff --git a/Sources/libewol/ewol/base/guiWindows.cpp b/Sources/libewol/ewol/base/guiWindows.cpp index 84ca1a34..ad9beefb 100644 --- a/Sources/libewol/ewol/base/guiWindows.cpp +++ b/Sources/libewol/ewol/base/guiWindows.cpp @@ -24,6 +24,8 @@ #include #include + +#include #include #include #include @@ -40,6 +42,9 @@ int32_t separateClickTime = 300000; int32_t offsetMoveClicked = 10000; int32_t offsetMoveClickedDouble = 20000; +bool inputIsPressed[20]; + + void ewol::SetTitle(etk::UString title) { // TODO ... @@ -48,7 +53,7 @@ void ewol::SetTitle(etk::UString title) void EWOL_NativeRender(void) { - EWOL_GenericDraw(false); + EWOL_GenericDraw(true); glFlush(); } @@ -115,7 +120,14 @@ void guiAbstraction::GetAbsPos(int32_t & x, int32_t & y) bool guiAbstraction::IsPressedInput(int32_t inputID) { - return false; + if( NB_MAX_INPUT > inputID + && 0 <= inputID) + { + return inputIsPressed[inputID]; + } else { + EWOL_WARNING("Wrong input ID : " << inputID); + return false; + } } @@ -211,6 +223,11 @@ int main(int argc, char *argv[]) } } } + + for (int32_t iii=0; iii pos; switch (message) { - + /* ************************************************************************** + * Gui event + * **************************************************************************/ case WM_CREATE: EWOL_DEBUG("WM_CREATE"); return 0; @@ -317,11 +336,19 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) EWOL_DEBUG("WM_CLOSE"); PostQuitMessage( 0 ); return 0; - case WM_DESTROY: EWOL_DEBUG("WM_DESTROY"); return 0; + case WM_MOVE: + EWOL_DEBUG("WM_MOVE"); + return 0; + case WM_SIZE: + EWOL_DEBUG("WM_SIZE"); + return 0; + /* ************************************************************************** + * Keyboard management + * **************************************************************************/ case WM_KEYDOWN: EWOL_DEBUG("WM_KEYDOWN"); switch ( wParam ) { @@ -330,21 +357,56 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) return 0; } return 0; - case WM_MOVE: - EWOL_DEBUG("WM_MOVE"); + /* ************************************************************************** + * Mouse management + * **************************************************************************/ + case WM_LBUTTONUP: + mouseButtonIsDown = false; + case WM_LBUTTONDOWN: + mouseButtonId = 1; + pos.x = GET_X_LPARAM(lParam); + pos.y = GET_Y_LPARAM(lParam); + inputIsPressed[mouseButtonId] = mouseButtonIsDown; + guiSystem::event::SetMouseState(mouseButtonId, mouseButtonIsDown, (float)pos.x, (float)pos.y); return 0; - case WM_SIZE: - EWOL_DEBUG("WM_SIZE"); + case WM_MBUTTONUP: + mouseButtonIsDown = false; + case WM_MBUTTONDOWN: + mouseButtonId = 2; + pos.x = GET_X_LPARAM(lParam); + pos.y = GET_Y_LPARAM(lParam); + inputIsPressed[mouseButtonId] = mouseButtonIsDown; + guiSystem::event::SetMouseState(mouseButtonId, mouseButtonIsDown, (float)pos.x, (float)pos.y); return 0; + + case WM_RBUTTONUP: + mouseButtonIsDown = false; + case WM_RBUTTONDOWN: + mouseButtonId = 3; + pos.x = GET_X_LPARAM(lParam); + pos.y = GET_Y_LPARAM(lParam); + inputIsPressed[mouseButtonId] = mouseButtonIsDown; + guiSystem::event::SetMouseState(mouseButtonId, mouseButtonIsDown, (float)pos.x, (float)pos.y); + return 0; + + // TODO : Set the other bt ... + + case WM_MOUSEHOVER: case WM_MOUSEMOVE: - { - int32_t posX = GET_X_LPARAM(lParam); - int32_t posY = GET_Y_LPARAM(lParam); - EWOL_DEBUG("WM_MOUSEMOVE : (" << posX << "," << posY << ")"); + pos.x = GET_X_LPARAM(lParam); + pos.y = GET_Y_LPARAM(lParam); + for (int32_t iii=0; iii