diff --git a/README.md b/README.md
index 415e85d22b4..1baf9926cc4 100644
--- a/README.md
+++ b/README.md
@@ -1,64 +1,73 @@
-fheroes2
-======
-[![Github Downloads (monthly)](https://img.shields.io/github/downloads/ihhub/fheroes2/total.svg)](https://github.com/ihhub/fheroes2/releases) [![Discord](https://img.shields.io/discord/733093692860137523.svg?label=&logo=discord&logoColor=ffffff&color=7389D8&labelColor=6A7EC2)](https://discord.gg/xF85vbZ) [![Facebook](https://img.shields.io/badge/Facebook-blue.svg)](https://www.facebook.com/groups/fheroes2) [![VK](https://img.shields.io/badge/VK-blue.svg)](https://vk.com/fheroes2) [![Donate](https://img.shields.io/badge/Donate-Patreon-green.svg)](https://www.patreon.com/fheroes2)
+This is a port of Free Heroes 2 (free implementation of Heroes of Might and Magic 2 engine) to Nintendo Switch.
+It's a homebrew app, so you need to be running custom firmware for it to work.
-Free implementation of Heroes of Might and Magic II engine.
-
+[1] BUILDING
+------------
-Download
----------------------------
-You can download a compiled version of the game for your operating system via [**Github releases**](https://github.com/ihhub/fheroes2/releases) of this project.
+If you're targeting Nintendo Switch, make sure you're using the `switch` branch. The `master` branch contains changes which are not specific to Switch and could be used on other platforms.
-Please note that for **32-bit** version of the game on **Windows OS** you have to install [**Visual Studio 2015 Redistributable (vc_redist.x86.exe)**](https://www.microsoft.com/en-sg/download/details.aspx?id=48145) if you face an error during application startup.
+You will need to install the [devkitPro](https://devkitpro.org/) toolchain. Make sure to include the following packages:
-Copyright
----------------------------
-All rights for the original game and its resources belong to former The 3DO Company. These rights were transferred to Ubisoft. We do not encourage and do not support any form of illegal usage of the original game. We strongly advise to purchase the original game on [**GOG**](https://www.gog.com) or [**Ubisoft Store**](https://store.ubi.com) platforms. Alternatively, you can download a free demo version of the game.
+ libnx switch-sdl2_image switch-sdl2_mixer switch-sdl2_ttf
-Requirements
----------------------------
-You are required to have at least a demo version of Heroes of Might and Magic II game to be able to play it. Please use one of our scripts to download the demo version of the original game. A script comes with the compiled game.
+Then follow the usual steps to build Free Heroes 2.
-MacOS and Linux
---------------------------
-Unix OSes need an explicit installation of SDL. Please go to `script/macos` or `script/linux` directory depending on your OS package and run **install_sdl_1.sh** or **install_sdl_2.sh** file. For Arch based Linux distributions use the command `sudo pacman -S sdl sdl_mixer` instead. RPM based distributions like Fedora/Red Hat use the commands `sudo yum/dnf install SDL*`. openSUSE supports the One-Click-Install via `SDL_mixer.ymp` file in `script/linux`. For MacOS we highly recommend to use SDL 2 as latest versions of MacOS do not fully support SDL 1.
+If you don't intend to do any coding and just want to play, grab the latest [release](https://github.com/dimag0g/fheroes2/releases) instead.
-Compilation
----------------------------
-[![Build status](https://travis-ci.org/ihhub/fheroes2.svg?branch=master)](https://travis-ci.org/ihhub/fheroes2) [![Build status](https://ci.appveyor.com/api/projects/status/ih6cw0yr1yuxf4ll?svg=true)](https://ci.appveyor.com/project/ihhub/fheroes2) [![Build Status](https://github.com/ihhub/fheroes2/workflows/GitHub%20Actions/badge.svg)](https://github.com/ihhub/fheroes2/actions)
+[2] SETUP
+---------
-[![Maintainability Rating](https://sonarcloud.io/api/project_badges/measure?project=ihhub_fheroes2&metric=sqale_rating)](https://sonarcloud.io/dashboard?id=ihhub_fheroes2) [![Reliability Rating](https://sonarcloud.io/api/project_badges/measure?project=ihhub_fheroes2&metric=reliability_rating)](https://sonarcloud.io/dashboard?id=ihhub_fheroes2) [![Bugs](https://sonarcloud.io/api/project_badges/measure?project=ihhub_fheroes2&metric=bugs)](https://sonarcloud.io/dashboard?id=ihhub_fheroes2) [![Code Smells](https://sonarcloud.io/api/project_badges/measure?project=ihhub_fheroes2&metric=code_smells)](https://sonarcloud.io/dashboard?id=ihhub_fheroes2) [![Duplicated Lines (%)](https://sonarcloud.io/api/project_badges/measure?project=ihhub_fheroes2&metric=duplicated_lines_density)](https://sonarcloud.io/dashboard?id=ihhub_fheroes2) [![Language grade: C/C++](https://img.shields.io/lgtm/grade/cpp/g/ihhub/fheroes2.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/ihhub/fheroes2/context:cpp) [![Total alerts](https://img.shields.io/lgtm/alerts/g/ihhub/fheroes2.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/ihhub/fheroes2/alerts/)
+You will need a copy of the official game to run this port.
-Please follow below instructions to be able to compile the project:
+Free Heroes 2 root directory is hardcoded as `/switch/fheroes2`. Put the game files there (specifically `ANIM`, `DATA`, `MAPS` and `MUSIC` folders),
+then copy over the `files` directory, as well as `fheroes2.nro`. `ANIM` and `MUSIC` folders are optional: you can play without any music or movies.
+If you don't have the `ANIM` folder, create it and copy whatever `*.smk` files you have from `DATA` to `ANIM`.
-Windows
-------------------------
-- **Optional step**: Install **7-zip** archiver at its default location as `C:\Program Files\7-Zip\7z.exe` or otherwise, you will need to manually extract each downloaded package (follow instructions shown by batch scripts mentioned below).
-- open `script/windows` directory and run **install_packages.bat** file. It installs necessary packages for Visual Studio build.
-- open `script/demo` directory and run **demo_windows.bat** file. It downloads a demo version of the game which is needed for minimum development.
-- open **fheroes.vcxproj** by Visual Studio and compile the project.
-MacOS and Linux
--------------------
-- open `script/macos` or `script/linux` directory depending on your OS and run **install_sdl_1.sh** or **install_sdl_2.sh** file. For MacOS we recommend to run SDL 2 as latest versions of MacOS does not support SDL 1 fully.
-- open `script/demo` directory and run **demo_macos.sh** or **demo_linux.sh** file depending on your OS. It downloads a demo version of the game which is needed for minimum development.
-- run `make` command in root directory of the project. For SDL 2 compilation please run `export WITH_SDL2="ON"` command before compiling the project.
+In the end you should have the following directory tree on your SD card:
-Contribution
----------------------------
-We welcome and appreciate any help, even if it is a tiny text or code change. Please read [contribution](https://github.com/ihhub/fheroes2/blob/master/CONTRIBUTING.md) page before starting work on a pull request. All contributors are listed in the project's wiki [page](https://github.com/ihhub/fheroes2/wiki/Contributors).
-Not sure what to start with? Feel free to refer to [good first issue](https://github.com/ihhub/fheroes2/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22) or [help wanted](https://github.com/ihhub/fheroes2/issues?q=is%3Aissue+is%3Aopen+label%3A%22help+wanted%22) tags.
+ switch
+ |
+ +-- ...
+ +-- fheroes2 <--- this is the game directory
+ |
+ +--- anim
+ +--- data
+ +--- files
+ +--- maps
+ +--- music
+ +--- fheroes2.nro
-License
----------------------------
-This project is under GNU General Public License v2.0. Please refer to file [**LICENSE**](https://github.com/ihhub/fheroes2/blob/master/LICENSE) for more details.
-The original project had been developed at [sourceforge](https://sourceforge.net/projects/fheroes2/)
+[3] RUNNING
+-----------
+
+This build of Free Heroes 2 was tested on 10.2.0|AMS 0.14.4|S (FAT32). exFAT is not recommended.
+Alternative controllers (keyboards, mouses, etc.) might work but weren't tested.
+
+Working controls controls are:
+- Touchscreen - emulates mouse, including dragging
+- L-stick - move mouse cursor
+- A - left mouse click
+- B - Right mouse click
+
+
+[4] TODO
+--------
+
+Here's a list of known bugs / missing features, approximately in order of priority. Don't bother reporting those as issues.
+
+- cursor is invisible
+- locales are not supported
+
+
+The game icon was downloaded from [this page](https://iconarchive.com/show/mega-games-pack-28-icons-by-3xhumed/Heroes-II-of-Might-and-Magic-2-icon.html)
+with the following copyright notice:
+
+>Artist: Exhumed
+>License: CC Attribution-Noncommercial-No Derivate 4.0
+>Commercial usage: Not allowed
-Donation
----------------------------
-Currently we accept donations via Patreon and PayPal. All donations will be used only for the future project development as we do not consider this project as a source of income by any means.
-[![Donate](https://img.shields.io/badge/Donate-Patreon-green.svg)](https://www.patreon.com/fheroes2) [![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.com/paypalme/fheroes2)
diff --git a/src/Makefile.switch b/src/Makefile.switch
new file mode 100644
index 00000000000..323dcb45d4c
--- /dev/null
+++ b/src/Makefile.switch
@@ -0,0 +1,13 @@
+PREFIX = $(DEVKITPRO)/devkitA64/bin/aarch64-none-elf-
+
+CC = $(PREFIX)gcc
+CXX = $(PREFIX)g++
+AR = $(PREFIX)ar
+
+ARCH = -march=armv8-a+crc+crypto -mtune=cortex-a57 -mtp=soft -fPIE
+CFLAGS := $(CFLAGS) $(ARCH) -D__SWITCH__ -DWITHOUT_MOUSE
+CXXFLAGS := $(CXXFLAGS) $(ARCH) -D__SWITCH__ -DWITHOUT_MOUSE
+CFLAGS_TP := $(CFLAGS_TP) $(ARCH)
+CXXFLAGS_TP := $(CXXFLAGS_TP) $(ARCH)
+
+LIBS := $(LIBS) -lSDL2 -lfreetype -lbz2 -lvorbisidec -lmodplug -lmpg123 -lm -lopusfile -logg -lopus -ljpeg -lwebp -specs=$(DEVKITPRO)/libnx/switch.specs
\ No newline at end of file
diff --git a/src/engine/engine.cpp b/src/engine/engine.cpp
index b334a047537..35240b0bd04 100644
--- a/src/engine/engine.cpp
+++ b/src/engine/engine.cpp
@@ -47,6 +47,12 @@ bool SDL::Init( const u32 system )
ERROR( SDL_GetError() );
return false;
}
+
+#ifdef __SWITCH__
+ SDL_InitSubSystem(SDL_INIT_JOYSTICK);
+ SDL_JoystickEventState(SDL_ENABLE);
+ SDL_JoystickOpen(0);
+#endif
if ( SDL_INIT_AUDIO & system )
Mixer::Init();
diff --git a/src/engine/localevent.cpp b/src/engine/localevent.cpp
index 8a8263f87b0..ae2d5e740b1 100644
--- a/src/engine/localevent.cpp
+++ b/src/engine/localevent.cpp
@@ -29,6 +29,36 @@
#define TAP_DELAY_EMULATE 1050
+#ifdef __SWITCH__
+#define JOY_DEADZONE 1000
+#define JOY_ANALOG
+#define JOY_XAXIS 0
+#define JOY_YAXIS 1
+#define JOY_XAXISR 2
+#define JOY_YAXISR 3
+
+
+enum {
+ BTN_LEFT = 12,
+ BTN_DOWN = 15,
+ BTN_RIGHT = 14,
+ BTN_UP = 1,
+
+ BTN_MINUS = 10,
+ BTN_PLUS = 11,
+
+ BTN_Y = 3,
+ BTN_X = 2,
+ BTN_B = 1,
+ BTN_A = 0,
+
+ BTN_R = 8,
+ BTN_L = 9
+};
+
+Uint32 lastTime = 0;
+#endif
+
LocalEvent::LocalEvent()
: modes( 0 )
, key_value( KEY_NONE )
@@ -44,7 +74,7 @@ LocalEvent::LocalEvent()
, _isSoundPaused( false )
{
#ifdef WITHOUT_MOUSE
- emulate_mouse = false;
+ emulate_mouse = true; //!
emulate_mouse_up = KEY_UP;
emulate_mouse_down = KEY_DOWN;
emulate_mouse_left = KEY_LEFT;
@@ -546,6 +576,21 @@ bool LocalEvent::HandleEvents( bool delay, bool allowExit )
}
}
break;
+#endif
+#if defined(__SWITCH__)
+ case SDL_JOYAXISMOTION:
+ HandleJoyAxisEvent(event.jaxis);
+ break;
+ case SDL_JOYBUTTONDOWN:
+ case SDL_JOYBUTTONUP:
+ HandleJoyButtonEvent(event.jbutton);
+ break;
+ case SDL_FINGERDOWN:
+
+ case SDL_FINGERUP:
+ case SDL_FINGERMOTION:
+ HandleTouchEvent(event.tfinger);
+ break;
#endif
// keyboard
case SDL_KEYDOWN:
@@ -605,12 +650,300 @@ bool LocalEvent::HandleEvents( bool delay, bool allowExit )
}
}
+#ifdef __SWITCH__
+ ProcessAxisMotion();
+#endif
if ( delay )
SDL_Delay( loop_delay );
return true;
}
+#if defined(VITA) || defined(__SWITCH__)
+Sint16 xaxis_value = 0;
+Sint16 yaxis_value = 0;
+float xaxis_float = 0;
+float yaxis_float = 0;
+float xaxis_starting = 0;
+float yaxis_starting = 0;
+float xcursor_starting = 0;
+float ycursor_starting = 0;
+bool secondTouchDown = false;
+
+void LocalEvent::HandleTouchEvent(const SDL_TouchFingerEvent & event)
+{
+ if(event.touchId != 0 || vita_touchcontrol_type == 0)
+ return;
+
+ //doesn't really work at this point..
+ if(event.fingerId == 1)
+ {
+ if (event.type == SDL_FINGERDOWN)
+ secondTouchDown = true;
+ else if (event.type == SDL_FINGERUP)
+ secondTouchDown = false;
+ return;
+ }
+
+ if (event.type == SDL_FINGERDOWN)
+ {
+ xaxis_starting = event.x * (float)960;
+ yaxis_starting = event.y * (float)544;
+ xcursor_starting = xaxis_float;
+ ycursor_starting = yaxis_float;
+ }
+
+ SetModes(MOUSE_MOTION);
+
+ if (vita_touchcontrol_type == 1)
+ {
+ int w = 960;
+ int h = 544;
+
+ //fullscreen touch location fix
+ {
+ w = fheroes2::Display::instance().width();
+ h = fheroes2::Display::instance().height();
+ }
+
+ xaxis_float = event.x * (float)w;
+ yaxis_float = event.y * (float)h;
+ }
+ else if (vita_touchcontrol_type == 2)
+ {
+ float deltaX = ((event.x * (float)960) - xaxis_starting) * (vita_touchcontrol_speed / 10.0f);
+ float deltaY = ((event.y * (float)544) - yaxis_starting) * (vita_touchcontrol_speed / 10.0f);
+ xaxis_float = xcursor_starting + deltaX;
+ yaxis_float = ycursor_starting + deltaY;
+ }
+
+ if(xaxis_float < 0) xaxis_float = 0;
+ if(yaxis_float < 0) yaxis_float = 0;
+ if(xaxis_float > fheroes2::Display::instance().width()) xaxis_float = fheroes2::Display::instance().width();
+ if(yaxis_float > fheroes2::Display::instance().height()) yaxis_float = fheroes2::Display::instance().height();
+
+ mouse_cu.x = static_cast(xaxis_float);
+ mouse_cu.y = static_cast(yaxis_float);
+
+ if((modes & MOUSE_MOTION) && redraw_cursor_func)
+ {
+ if(modes & MOUSE_OFFSET)
+ (*(redraw_cursor_func))(mouse_cu.x + mouse_st.x, mouse_cu.y + mouse_st.y);
+ else
+ (*(redraw_cursor_func))(mouse_cu.x, mouse_cu.y);
+ }
+
+ if(!secondTouchDown)
+ {
+ if(event.type == SDL_FINGERDOWN)
+ {
+ mouse_pl = mouse_cu;
+ SetModes(MOUSE_PRESSED);
+ SetModes(CLICK_LEFT);
+ }
+ else if(event.type == SDL_FINGERUP)
+ {
+ mouse_rl = mouse_cu;
+ ResetModes(MOUSE_PRESSED);
+ }
+ mouse_button = SDL_BUTTON_LEFT;
+ }
+ else
+ {
+ if(event.type == SDL_FINGERDOWN)
+ {
+ mouse_pr = mouse_cu;
+ SetModes(MOUSE_PRESSED);
+ }
+ else if(event.type == SDL_FINGERUP)
+ {
+ mouse_rr = mouse_cu;
+ ResetModes(MOUSE_PRESSED);
+ }
+ mouse_button = SDL_BUTTON_RIGHT;
+ }
+}
+
+void LocalEvent::HandleJoyAxisEvent(const SDL_JoyAxisEvent & motion)
+{
+ if (motion.axis == JOY_XAXIS)
+ {
+ if(std::abs(motion.value) > JOY_DEADZONE)
+ xaxis_value = motion.value;
+ else
+ xaxis_value = 0;
+ }
+ else if (motion.axis == JOY_YAXIS)
+ {
+ if(std::abs(motion.value) > JOY_DEADZONE)
+ yaxis_value = motion.value;
+ else
+ yaxis_value = 0;
+ }
+}
+#endif
+#if defined(VITA)
+void LocalEvent::HandleJoyButtonEvent(const SDL_JoyButtonEvent & button)
+{
+ if (button.state == SDL_PRESSED)
+ SetModes(KEY_PRESSED);
+ else if (button.state == SDL_RELEASED)
+ ResetModes(KEY_PRESSED);
+
+ if(button.button == BTN_CROSS)
+ {
+ if(modes & KEY_PRESSED)
+ {
+ mouse_pl = mouse_cu;
+ SetModes(MOUSE_PRESSED);
+ SetModes(CLICK_LEFT);
+ }
+ else
+ {
+ mouse_rl = mouse_cu;
+ ResetModes(MOUSE_PRESSED);
+ }
+ mouse_button = SDL_BUTTON_LEFT;
+
+ ResetModes(KEY_PRESSED);
+ }
+ else if(button.button == BTN_CIRCLE)
+ {
+ if(modes & KEY_PRESSED)
+ {
+ mouse_pr = mouse_cu;
+ SetModes(MOUSE_PRESSED);
+ }
+ else
+ {
+ mouse_rr = mouse_cu;
+ ResetModes(MOUSE_PRESSED);
+ }
+ mouse_button = SDL_BUTTON_RIGHT;
+
+ ResetModes(KEY_PRESSED);
+ }
+ else if(modes & KEY_PRESSED)
+ {
+ if(button.button == BTN_LEFT)
+ {
+ key_value = KEY_KP4;
+ }
+ else if(button.button == BTN_RIGHT)
+ {
+ key_value = KEY_KP6;
+ }
+ else if(button.button == BTN_UP)
+ {
+ key_value = KEY_KP8;
+ }
+ else if(button.button == BTN_DOWN)
+ {
+ key_value = KEY_KP2;
+ }
+ }
+}
+#elif defined(__SWITCH__)
+void LocalEvent::HandleJoyButtonEvent(const SDL_JoyButtonEvent & button)
+{
+ if(button.button == BTN_A)
+ {
+ if(button.state == SDL_PRESSED)
+ {
+ mouse_pl = mouse_cu;
+ SetModes(MOUSE_PRESSED);
+ SetModes(CLICK_LEFT);
+ }
+ else
+ {
+ mouse_rl = mouse_cu;
+ ResetModes(MOUSE_PRESSED);
+ }
+ mouse_button = SDL_BUTTON_LEFT;
+
+ ResetModes(KEY_PRESSED);
+ }
+ else if(button.button == BTN_B)
+ {
+ if(button.state == SDL_PRESSED)
+ {
+ mouse_pr = mouse_cu;
+ SetModes(MOUSE_PRESSED);
+ }
+ else
+ {
+ mouse_rr = mouse_cu;
+ ResetModes(MOUSE_PRESSED);
+ }
+ mouse_button = SDL_BUTTON_RIGHT;
+
+ ResetModes(KEY_PRESSED);
+ }
+ else if(button.state == SDL_PRESSED)
+ {
+ if(button.button == BTN_LEFT)
+ {
+ key_value = KEY_LEFT;
+ }
+ else if(button.button == BTN_RIGHT)
+ {
+ key_value = KEY_RIGHT;
+ }
+ else if(button.button == BTN_UP)
+ {
+ key_value = KEY_UP;
+ }
+ else if(button.button == BTN_DOWN)
+ {
+ key_value = KEY_DOWN;
+ }
+ else if(button.button == BTN_X)
+ {
+ key_value = KEY_ESCAPE;
+ }
+ else if(button.button == BTN_Y)
+ {
+ key_value = KEY_RETURN;
+ }
+ }
+}
+#endif
+
+#if defined(VITA) || defined(__SWITCH__)
+void LocalEvent::ProcessAxisMotion()
+{
+ float movementSpeed = 8192 * 20;
+ float settingsSpeedMod = static_cast(vita_pointer_speed) / 10.0f;
+
+ Uint32 currentTime = SDL_GetTicks();
+ float deltaTime = currentTime - lastTime;
+ lastTime = currentTime;
+
+ if (xaxis_value == 0 && yaxis_value == 0)
+ return;
+
+ SetModes(MOUSE_MOTION);
+
+ xaxis_float += ((pow(abs(xaxis_value), 1.03f) * (xaxis_value / abs(xaxis_value)) * deltaTime) / movementSpeed) * settingsSpeedMod;
+ yaxis_float += ((pow(abs(yaxis_value), 1.03f) * (yaxis_value / abs(yaxis_value)) * deltaTime) / movementSpeed) * settingsSpeedMod;
+
+ if(xaxis_float < 0) xaxis_float = 0;
+ if(yaxis_float < 0) yaxis_float = 0;
+ if(xaxis_float > fheroes2::Display::instance().width()) xaxis_float = fheroes2::Display::instance().width();
+ if(yaxis_float > fheroes2::Display::instance().height()) yaxis_float = fheroes2::Display::instance().height();
+
+ mouse_cu.x = static_cast(xaxis_float);
+ mouse_cu.y = static_cast(yaxis_float);
+
+ if((modes & MOUSE_MOTION) && redraw_cursor_func)
+ {
+ if(modes & MOUSE_OFFSET)
+ (*(redraw_cursor_func))(mouse_cu.x + mouse_st.x, mouse_cu.y + mouse_st.y);
+ else
+ (*(redraw_cursor_func))(mouse_cu.x, mouse_cu.y);
+ }
+}
+#endif
bool LocalEvent::MouseMotion( void ) const
{
return ( modes & MOUSE_MOTION ) == MOUSE_MOTION;
@@ -1013,11 +1346,21 @@ void LocalEvent::SetStateDefaults( void )
SetState( SDL_MOUSEBUTTONUP, true );
SetState( SDL_QUIT, true );
- SetState( SDL_JOYAXISMOTION, false );
- SetState( SDL_JOYBALLMOTION, false );
- SetState( SDL_JOYHATMOTION, false );
- SetState( SDL_JOYBUTTONUP, false );
- SetState( SDL_JOYBUTTONDOWN, false );
+#if defined(__SWITCH__)
+ SetState(SDL_JOYAXISMOTION, true);
+ SetState(SDL_JOYBUTTONUP, true);
+ SetState(SDL_JOYBUTTONDOWN, true);
+ SetState(SDL_FINGERMOTION, true);
+ SetState(SDL_FINGERDOWN, true);
+ SetState(SDL_FINGERUP, true);
+#else
+ SetState(SDL_JOYAXISMOTION, false);
+ SetState(SDL_JOYBUTTONUP, false);
+ SetState(SDL_JOYBUTTONDOWN, false);
+#endif
+
+ SetState(SDL_JOYBALLMOTION, false);
+ SetState(SDL_JOYHATMOTION, false);
SetState( SDL_SYSWMEVENT, false );
#if SDL_VERSION_ATLEAST( 2, 0, 0 )
diff --git a/src/engine/localevent.h b/src/engine/localevent.h
index 2f09f7287f8..7d6ec6003c0 100644
--- a/src/engine/localevent.h
+++ b/src/engine/localevent.h
@@ -273,6 +273,12 @@ class LocalEvent
void HandleMouseMotionEvent( const SDL_MouseMotionEvent & );
void HandleMouseButtonEvent( const SDL_MouseButtonEvent & );
void HandleKeyboardEvent( SDL_KeyboardEvent & );
+#if defined(__SWITCH__)
+ void HandleJoyAxisEvent(const SDL_JoyAxisEvent & motion);
+ void HandleJoyButtonEvent(const SDL_JoyButtonEvent & button);
+ void HandleTouchEvent(const SDL_TouchFingerEvent & event);
+ void ProcessAxisMotion(void);
+#endif
#if SDL_VERSION_ATLEAST( 2, 0, 0 )
void HandleMouseWheelEvent( const SDL_MouseWheelEvent & );
@@ -341,6 +347,11 @@ class LocalEvent
KeySym emulate_press_left;
KeySym emulate_press_right;
#endif
+#if defined(__SWITCH__)
+ int vita_pointer_speed = 10;
+ int vita_touchcontrol_type = 1;
+ int vita_touchcontrol_speed = 15;
+#endif
};
#endif
diff --git a/src/engine/screen.cpp b/src/engine/screen.cpp
index 2a7ecf8726e..0e22e4aec96 100644
--- a/src/engine/screen.cpp
+++ b/src/engine/screen.cpp
@@ -299,7 +299,7 @@ namespace
}
}
- filteredResolutions = FilterResolutions( resolutionSet );
+ //!filteredResolutions = FilterResolutions( resolutionSet );
}
return filteredResolutions;
@@ -641,7 +641,7 @@ namespace
}
}
- filteredResolutions = FilterResolutions( resolutionSet );
+ //!filteredResolutions = FilterResolutions( resolutionSet );
}
return filteredResolutions;
diff --git a/src/engine/system.cpp b/src/engine/system.cpp
index 6b969bc7e44..97acd96448e 100644
--- a/src/engine/system.cpp
+++ b/src/engine/system.cpp
@@ -100,9 +100,9 @@ std::string System::GetHomeDirectory( const std::string & prog )
std::string res;
#if SDL_VERSION_ATLEAST( 2, 0, 0 )
- char * path = SDL_GetPrefPath( "", prog.c_str() );
- res = path;
- SDL_free( path );
+ //!char * path = SDL_GetPrefPath( "", prog.c_str() );
+ //!res = path;
+ //!SDL_free( path );
#endif
if ( System::GetEnvironment( "HOME" ) )
@@ -222,7 +222,7 @@ int System::SetEnvironment( const char * name, const char * value )
return SDL_putenv( &str[0] );
#endif
#else
- return setenv( name, value, 1 );
+ //!return setenv( name, value, 1 );
#endif
}
diff --git a/src/engine/system.h b/src/engine/system.h
index d1b249d12d0..64b7e1523ae 100644
--- a/src/engine/system.h
+++ b/src/engine/system.h
@@ -44,9 +44,11 @@ namespace std
__android_log_print( ANDROID_LOG_INFO, "SDLHeroes2", "%s", osss.str().c_str() ); \
}
#else
+#include //!
+extern std::ofstream *log_file;
#define COUT( x ) \
{ \
- std::cerr << x << std::endl; \
+ *log_file << x << std::endl; log_file->flush(); \
}
#endif
diff --git a/src/fheroes2/game/fheroes2.cpp b/src/fheroes2/game/fheroes2.cpp
index d3e91084bf6..8a40befaaf1 100644
--- a/src/fheroes2/game/fheroes2.cpp
+++ b/src/fheroes2/game/fheroes2.cpp
@@ -66,9 +66,15 @@ std::string GetCaption( void )
#undef main
#endif
+#include //!
+std::ofstream *log_file;
+
int main( int argc, char ** argv )
{
Settings & conf = Settings::Get();
+
+ log_file = new std::ofstream ("fheroes2.log", std::ofstream::out);
+ //!std::cerr.rdbuf(log_file.rdbuf()); //!
DEBUG( DBG_ALL, DBG_INFO, "Free Heroes of Might and Magic II, " + conf.GetVersion() );
@@ -140,7 +146,7 @@ int main( int argc, char ** argv )
display.resize( conf.VideoMode().w, conf.VideoMode().h );
fheroes2::engine().setTitle( GetCaption() );
- SDL_ShowCursor( SDL_DISABLE ); // hide system cursor
+ //!SDL_ShowCursor( SDL_DISABLE ); // hide system cursor
// Ensure the mouse position is updated to prevent bad initial values.
LocalEvent::Get().RegisterCycling();
diff --git a/src/fheroes2/game/game_highscores.cpp b/src/fheroes2/game/game_highscores.cpp
index a6272cee300..29115a87740 100644
--- a/src/fheroes2/game/game_highscores.cpp
+++ b/src/fheroes2/game/game_highscores.cpp
@@ -246,7 +246,7 @@ int Game::HighScores()
// highscores loop
while ( le.HandleEvents() ) {
// key code info
- if ( Settings::Get().Debug() == 0x12 && le.KeyPress() )
+ if ( /*Settings::Get().Debug() == 0x12 &&*/ le.KeyPress() ) //!
Dialog::Message( "Key Press:", GetString( le.KeyValue() ), Font::SMALL, Dialog::OK );
if ( buttonCampain.isEnabled() ) {
le.MousePressLeft( buttonCampain.area() ) ? buttonCampain.drawOnPress() : buttonCampain.drawOnRelease();
diff --git a/src/fheroes2/system/settings.cpp b/src/fheroes2/system/settings.cpp
index ca1d5087568..35bec817954 100644
--- a/src/fheroes2/system/settings.cpp
+++ b/src/fheroes2/system/settings.cpp
@@ -38,6 +38,7 @@
bool IS_DEBUG( int name, int level )
{
+ return !(DBG_DEVEL & name); //!
const int debug = Settings::Get().Debug();
return ( ( DBG_ENGINE & name ) && ( ( DBG_ENGINE & debug ) >> 2 ) >= level ) || ( ( DBG_GAME & name ) && ( ( DBG_GAME & debug ) >> 4 ) >= level )
|| ( ( DBG_BATTLE & name ) && ( ( DBG_BATTLE & debug ) >> 6 ) >= level ) || ( ( DBG_AI & name ) && ( ( DBG_AI & debug ) >> 8 ) >= level )
@@ -973,9 +974,7 @@ ListDirs Settings::GetRootDirs( void )
ListDirs dirs;
// from build
-#ifdef CONFIGURE_FHEROES2_DATA
- dirs.push_back( CONFIGURE_FHEROES2_DATA );
-#endif
+ dirs.push_back( "/switch/fheroes2" );
// from env
if ( System::GetEnvironment( "FHEROES2_DATA" ) )