mirror of
https://github.com/celisej567/mcpe.git
synced 2026-09-04 19:36:43 +03:00
Allow Changing Input Mode
This commit is contained in:
committed by
iProgramInCpp
parent
7771bc20a7
commit
c989ffa721
1
platforms/sdl/android/.idea/misc.xml
generated
1
platforms/sdl/android/.idea/misc.xml
generated
@@ -1,4 +1,3 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="jbr-17" project-jdk-type="JavaSDK">
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include <sstream>
|
||||
#include <fstream>
|
||||
#include <sys/stat.h>
|
||||
#include <cstdlib>
|
||||
|
||||
#ifdef __EMSCRIPTEN__
|
||||
#include <emscripten.h>
|
||||
@@ -31,6 +32,26 @@ void AppPlatform_sdl_base::_init(std::string storageDir, SDL_Window *window)
|
||||
|
||||
m_pLogger = new Logger;
|
||||
m_pSoundSystem = nullptr;
|
||||
|
||||
// Default Touchscreen Mode
|
||||
#ifdef ANDROID
|
||||
m_bIsTouchscreen = true;
|
||||
#else
|
||||
m_bIsTouchscreen = false;
|
||||
#endif
|
||||
// Custom Touchscreen Mode
|
||||
const char *mode = getenv("MCPE_INPUT_MODE");
|
||||
if (mode)
|
||||
{
|
||||
if (strcmp(mode, "touch") == 0)
|
||||
{
|
||||
m_bIsTouchscreen = true;
|
||||
}
|
||||
else if (strcmp(mode, "mouse") == 0)
|
||||
{
|
||||
m_bIsTouchscreen = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AppPlatform_sdl_base::initSoundSystem()
|
||||
@@ -244,3 +265,7 @@ void AppPlatform_sdl_base::hideKeyboard()
|
||||
SDL_StopTextInput();
|
||||
}
|
||||
}
|
||||
|
||||
bool AppPlatform_sdl_base::isTouchscreen() {
|
||||
return m_bIsTouchscreen;
|
||||
}
|
||||
|
||||
@@ -38,8 +38,6 @@ public:
|
||||
// Also add these to allow proper text input within the game.
|
||||
bool shiftPressed() override;
|
||||
void setShiftPressed(bool b, bool isLeft);
|
||||
|
||||
bool isTouchscreen() override { return false; }
|
||||
|
||||
static MouseButtonType GetMouseButtonType(SDL_Event event);
|
||||
static bool GetMouseButtonState(SDL_Event event);
|
||||
@@ -48,6 +46,9 @@ public:
|
||||
// On-screen keyboard
|
||||
void showKeyboard(int x, int y, int w, int h) override;
|
||||
void hideKeyboard() override;
|
||||
|
||||
// Configure Touchscreen
|
||||
bool isTouchscreen() override;
|
||||
private:
|
||||
SDL_Window *_window;
|
||||
|
||||
@@ -62,6 +63,8 @@ private:
|
||||
Logger* m_pLogger;
|
||||
SoundSystem* m_pSoundSystem;
|
||||
|
||||
bool m_bIsTouchscreen;
|
||||
|
||||
static SDL_Surface* getSurfaceForTexture(const Texture* const texture);
|
||||
protected:
|
||||
std::string _storageDir;
|
||||
|
||||
@@ -47,7 +47,11 @@
|
||||
|
||||
return canvas;
|
||||
})(),
|
||||
arguments: [String(window.innerWidth), String(window.innerHeight)]
|
||||
arguments: [String(window.innerWidth), String(window.innerHeight)],
|
||||
preRun: [function () {
|
||||
const urlParams = new URLSearchParams(window.location.search);
|
||||
ENV.MCPE_INPUT_MODE = urlParams.get('inputMode');
|
||||
}]
|
||||
};
|
||||
</script>
|
||||
<script async type="text/javascript" src="reminecraftpe.js"></script>
|
||||
|
||||
@@ -295,7 +295,7 @@ void Screen::mouseReleased(int xPos, int yPos, int d)
|
||||
|
||||
if (m_pClickedButton)
|
||||
{
|
||||
if (m_pMinecraft->isTouchscreen() && button->clicked(m_pMinecraft, xPos, yPos))
|
||||
if (m_pMinecraft->isTouchscreen() && m_pClickedButton->clicked(m_pMinecraft, xPos, yPos))
|
||||
{
|
||||
m_pMinecraft->m_pSoundEngine->play("random.click");
|
||||
buttonClicked(m_pClickedButton);
|
||||
|
||||
Reference in New Issue
Block a user