diff --git a/src/client/Minecraft.cpp b/src/client/Minecraft.cpp index 04598b1..1cfd938 100755 --- a/src/client/Minecraft.cpp +++ b/src/client/Minecraft.cpp @@ -715,7 +715,7 @@ void Minecraft::tickInput() { #endif } #endif - #if defined(RPI) + #if defined(PLATFORM_DESKTOP) if (key == Keyboard::KEY_E) { screenChooser.setScreen(SCREEN_BLOCKSELECTION); } @@ -831,7 +831,7 @@ void Minecraft::tickInput() { } #endif - #ifndef RPI + #ifndef PLATFORM_DESKTOP if (key == 82) pauseGame(false); #else @@ -1242,7 +1242,7 @@ void Minecraft::_reloadInput() { #ifndef STANDALONE_SERVER delete inputHolder; - if (useTouchscreen()) { + if (useTouchscreen() && !PLATFORM_DESKTOP) { inputHolder = new TouchInputHolder(this, &options); } else { #if defined(ANDROID) || defined(__APPLE__) diff --git a/src/client/MouseHandler.cpp b/src/client/MouseHandler.cpp index 4044941..7855e41 100755 --- a/src/client/MouseHandler.cpp +++ b/src/client/MouseHandler.cpp @@ -5,6 +5,10 @@ #include #endif +#ifdef PLATFORM_GLFW +#include +#endif + MouseHandler::MouseHandler( ITurnInput* turnInput ) : _turnInput(turnInput) {} @@ -29,6 +33,10 @@ void MouseHandler::grab() { SDL_WM_GrabInput(SDL_GRAB_ON); SDL_ShowCursor(0); #endif + +#ifdef PLATFORM_GLFW + glfwSetInputMode(glfwGetCurrentContext(), GLFW_CURSOR, GLFW_CURSOR_DISABLED); +#endif } void MouseHandler::release() { @@ -37,6 +45,10 @@ void MouseHandler::release() { SDL_WM_GrabInput(SDL_GRAB_OFF); SDL_ShowCursor(1); #endif + +#ifdef PLATFORM_GLFW + glfwSetInputMode(glfwGetCurrentContext(), GLFW_CURSOR, GLFW_CURSOR_NORMAL); +#endif } void MouseHandler::poll() { diff --git a/src/client/gui/Gui.cpp b/src/client/gui/Gui.cpp index ef8bf95..e4d809c 100755 --- a/src/client/gui/Gui.cpp +++ b/src/client/gui/Gui.cpp @@ -66,7 +66,11 @@ void Gui::render(float a, bool mouseFree, int xMouse, int yMouse) { //minecraft->gameRenderer->setupGuiScreen(); Font* font = minecraft->font; +#ifdef PLATFORM_DESKTOP + const bool isTouchInterface = false; +#else const bool isTouchInterface = minecraft->useTouchscreen(); +#endif const int screenWidth = (int)(minecraft->width * InvGuiScale); const int screenHeight = (int)(minecraft->height * InvGuiScale); blitOffset = -90; @@ -391,7 +395,6 @@ void Gui::onConfigChanged( const Config& c ) { //LOGI("x,y: %f, %f\n", xx, yy); } rcFeedbackInner = t.end(true, rcFeedbackInner.vboId); - if (c.minecraft->useTouchscreen()) { // I'll bump this up to 6. int num = 6; // without "..." dots @@ -614,27 +617,27 @@ void Gui::renderBubbles() { } } -static OffsetPosTranslator posTranslator; -void Gui::onLevelGenerated() { - if (Level* level = minecraft->level) { - Pos p = level->getSharedSpawnPos(); - posTranslator = OffsetPosTranslator((float)-p.x, (float)-p.y, (float)-p.z); - } -} +static OffsetPosTranslator posTranslator; +void Gui::onLevelGenerated() { + if (Level* level = minecraft->level) { + Pos p = level->getSharedSpawnPos(); + posTranslator = OffsetPosTranslator((float)-p.x, (float)-p.y, (float)-p.z); + } +} void Gui::renderDebugInfo() { - static char buf[256]; - float xx = minecraft->player->x; - float yy = minecraft->player->y - minecraft->player->heightOffset; - float zz = minecraft->player->z; - posTranslator.to(xx, yy, zz); - sprintf(buf, "pos: %3.1f, %3.1f, %3.1f\n", xx, yy, zz); - Tesselator& t = Tesselator::instance; - t.beginOverride(); - t.scale2d(InvGuiScale, InvGuiScale); - minecraft->font->draw(buf, 2, 2, 0xffffff); - t.resetScale(); - t.endOverrideAndDraw(); + static char buf[256]; + float xx = minecraft->player->x; + float yy = minecraft->player->y - minecraft->player->heightOffset; + float zz = minecraft->player->z; + posTranslator.to(xx, yy, zz); + sprintf(buf, "pos: %3.1f, %3.1f, %3.1f\n", xx, yy, zz); + Tesselator& t = Tesselator::instance; + t.beginOverride(); + t.scale2d(InvGuiScale, InvGuiScale); + minecraft->font->draw(buf, 2, 2, 0xffffff); + t.resetScale(); + t.endOverrideAndDraw(); } void Gui::renderSleepAnimation( const int screenWidth, const int screenHeight ) { diff --git a/src/client/gui/screens/touch/TouchSelectWorldScreen.cpp b/src/client/gui/screens/touch/TouchSelectWorldScreen.cpp index bc0d977..4ebf5fd 100755 --- a/src/client/gui/screens/touch/TouchSelectWorldScreen.cpp +++ b/src/client/gui/screens/touch/TouchSelectWorldScreen.cpp @@ -401,7 +401,7 @@ void SelectWorldScreen::tick() minecraft->hostMultiplayer(); minecraft->setScreen(new ProgressScreen()); _hasStartedLevel = true; - #elif defined(WIN32) + #elif defined(PLATFORM_DESKTOP) std::string name = getUniqueLevelName("perf"); minecraft->setScreen(new SimpleChooseLevelScreen(name)); #else diff --git a/src/client/renderer/GameRenderer.cpp b/src/client/renderer/GameRenderer.cpp index e8fb874..0b8e74e 100755 --- a/src/client/renderer/GameRenderer.cpp +++ b/src/client/renderer/GameRenderer.cpp @@ -152,7 +152,8 @@ void GameRenderer::render(float a) { int xMouse = (int)(Mouse::getX() * Gui::InvGuiScale); int yMouse = (int)(Mouse::getY() * Gui::InvGuiScale); - if (mc->useTouchscreen()) { +#ifndef PLATFORM_DESKTOP + if (mc->useTouchscreen()) { const int pid = Multitouch::getFirstActivePointerIdExThisUpdate(); if (pid >= 0) { xMouse = (int)(Multitouch::getX(pid) * Gui::InvGuiScale); @@ -162,6 +163,7 @@ void GameRenderer::render(float a) { yMouse = -9999; } } +#endif TIMER_POP(); bool hasClearedColorBuffer = false; @@ -652,8 +654,11 @@ void GameRenderer::pick(float a) { float range = mc->gameMode->getPickRange(); bool isPicking = true; - +#ifndef PLATFORM_DESKTOP bool freeform = mc->useTouchscreen() && !mc->options.isJoyTouchArea; +#else + bool freeform = false; +#endif if (freeform) { isPicking = updateFreeformPickDirection(a, pickDirection); } else { diff --git a/src/main_glfw.h b/src/main_glfw.h index 7314088..06c4491 100755 --- a/src/main_glfw.h +++ b/src/main_glfw.h @@ -60,6 +60,8 @@ static void cursor_position_callback(GLFWwindow* window, double xpos, double ypo } void mouse_button_callback(GLFWwindow* window, int button, int action, int mods) { + if(action == GLFW_REPEAT) return; + double xpos, ypos; glfwGetCursorPos(window, &xpos, &ypos); diff --git a/src/platform/CThread.cpp b/src/platform/CThread.cpp index e93575e..604dbdb 100755 --- a/src/platform/CThread.cpp +++ b/src/platform/CThread.cpp @@ -25,12 +25,12 @@ &m_threadID // pointer to receive thread ID ); #endif - #if defined(LINUX) || defined(ANDROID) || defined(__APPLE__) || defined(POSIX) + #if defined(__linux__) || defined(ANDROID) || defined(__APPLE__) || defined(POSIX) mp_threadFunc = (pthread_fn)threadFunc; pthread_attr_init(&m_attributes); pthread_attr_setdetachstate( &m_attributes, PTHREAD_CREATE_DETACHED ); - /*int error =*/ pthread_create(&m_thread, &m_attributes, mp_threadFunc,threadParam); + /*int error =*/ pthread_create(&m_thread, &m_attributes, mp_threadFunc, threadParam); #endif #ifdef MACOSX mp_threadFunc = (TaskProc) threadFunc; diff --git a/src/platform/CThread.h b/src/platform/CThread.h index 25e5b77..3e2c975 100755 --- a/src/platform/CThread.h +++ b/src/platform/CThread.h @@ -13,7 +13,7 @@ typedef void *( * pthread_fn )( void * ); -#if defined(LINUX) || defined(ANDROID) || defined(__APPLE__) || defined(POSIX) +#if defined(__linux__) || defined(ANDROID) || defined(__APPLE__) || defined(POSIX) #include #include @@ -38,7 +38,7 @@ typedef void *( * pthread_fn )( void * ); DWORD m_threadID; HANDLE m_threadHandle; #endif - #if defined(LINUX) || defined(ANDROID) || defined(__APPLE__) || defined(POSIX) + #if defined(__linux__) || defined(ANDROID) || defined(__APPLE__) || defined(POSIX) pthread_fn mp_threadFunc; pthread_t m_thread; pthread_attr_t m_attributes;