Browse Source

Move existing touch control logic to Vita platform

pull/2880/head
staphen 5 years ago committed by Anders Jenbo
parent
commit
b29141048a
  1. 4
      CMakeLists.txt
  2. 7
      Source/diablo.cpp
  3. 9
      Source/miniwin/misc_msg.cpp
  4. 9
      Source/platform/vita/touch.cpp
  5. 7
      Source/platform/vita/touch.h

4
CMakeLists.txt

@ -396,7 +396,6 @@ set(libdevilutionx_SRCS
Source/controls/menu_controls.cpp
Source/controls/modifier_hints.cpp
Source/controls/plrctrls.cpp
Source/controls/touch.cpp
Source/controls/keymapper.cpp
Source/engine/animationinfo.cpp
Source/engine/demomode.cpp
@ -501,7 +500,8 @@ endif()
if(VITA)
list(APPEND libdevilutionx_SRCS
Source/platform/vita/keyboard.cpp)
Source/platform/vita/keyboard.cpp
Source/platform/vita/touch.cpp)
endif()
if(NINTENDO_3DS)

7
Source/diablo.cpp

@ -65,6 +65,10 @@
#include "utils/language.h"
#include "utils/paths.h"
#ifdef __vita__
#include "platform/vita/touch.h"
#endif
#ifdef GPERF_HEAP_FIRST_GAME_ITERATION
#include <gperftools/heap-profiler.h>
#endif
@ -118,7 +122,6 @@ MouseActionType LastMouseButtonAction = MouseActionType::None;
// Controller support: Actions to run after updating the cursor state.
// Defined in SourceX/controls/plctrls.cpp.
extern void finish_simulated_mouse_clicks(int currentMouseX, int currentMouseY);
extern void plrctrls_after_check_curs_move();
extern void plrctrls_every_frame();
extern void plrctrls_after_game_logic();
@ -192,7 +195,7 @@ bool ProcessInput()
}
if (!gmenu_is_active() && sgnTimeoutCurs == CURSOR_NONE) {
#ifndef USE_SDL1
#ifdef __vita__
finish_simulated_mouse_clicks(MousePosition.x, MousePosition.y);
#endif
CheckCursMove();

9
Source/miniwin/misc_msg.cpp

@ -9,7 +9,6 @@
#include "controls/game_controls.h"
#include "controls/plrctrls.h"
#include "controls/remap_keyboard.h"
#include "controls/touch.h"
#include "cursor.h"
#include "engine/demomode.h"
#include "engine/rectangle.hpp"
@ -24,6 +23,10 @@
#include "utils/sdl_compat.h"
#include "utils/stubs.h"
#ifdef __vita__
#include "platform/vita/touch.h"
#endif
#ifdef __SWITCH__
#include "platform/switch/docking.h"
#include <switch.h>
@ -311,7 +314,7 @@ bool FetchMessage_Real(tagMSG *lpMsg)
return true;
}
#ifndef USE_SDL1
#ifdef __vita__
handle_touch(&e, MousePosition.x, MousePosition.y);
#endif
@ -434,7 +437,7 @@ bool FetchMessage_Real(tagMSG *lpMsg)
break;
}
return true;
#ifndef USE_SDL1
#ifdef __vita__
}
if (e.type < SDL_JOYAXISMOTION || (e.type >= SDL_FINGERDOWN && e.type < SDL_DOLLARGESTURE)) {
#else

9
Source/controls/touch.cpp → Source/platform/vita/touch.cpp

@ -1,4 +1,3 @@
#ifndef USE_SDL1
#include <cmath>
#include "options.h"
@ -29,10 +28,8 @@ static void InitTouch();
static void PreprocessEvents(SDL_Event *event);
static void PreprocessFingerDown(SDL_Event *event);
static void PreprocessFingerUp(SDL_Event *event);
#ifdef __vita__
static void preprocess_back_finger_down(SDL_Event *event);
static void preprocess_back_finger_up(SDL_Event *event);
#endif
static void PreprocessFingerMotion(SDL_Event *event);
static void SetMouseButtonEvent(SDL_Event *event, uint32_t type, uint8_t button, int32_t x, int32_t y);
static void SetMouseMotionEvent(SDL_Event *event, int32_t x, int32_t y, int32_t xrel, int32_t yrel);
@ -109,7 +106,6 @@ static void PreprocessEvents(SDL_Event *event)
// front (0) or back (1) panel
SDL_TouchID port = event->tfinger.touchId;
if (port != 0) {
#ifdef __vita__
if (devilution::sgOptions.Controller.bRearTouch) {
switch (event->type) {
case SDL_FINGERDOWN:
@ -120,7 +116,6 @@ static void PreprocessEvents(SDL_Event *event)
break;
}
}
#endif
return;
}
@ -177,7 +172,7 @@ static void PreprocessFingerDown(SDL_Event *event)
break;
}
}
#ifdef __vita__
static void preprocess_back_finger_down(SDL_Event *event)
{
// front (0) or back (1) panel
@ -215,7 +210,6 @@ static void preprocess_back_finger_up(SDL_Event *event)
event->caxis.axis = SDL_CONTROLLER_AXIS_TRIGGERRIGHT;
}
}
#endif
static void PreprocessFingerUp(SDL_Event *event)
{
@ -487,4 +481,3 @@ static void SetMouseMotionEvent(SDL_Event *event, int32_t x, int32_t y, int32_t
event->motion.xrel = xrel;
event->motion.yrel = yrel;
}
#endif

7
Source/controls/touch.h → Source/platform/vita/touch.h

@ -1,11 +1,14 @@
#pragma once
#ifdef __vita__
#include <SDL.h>
namespace devilution {
#ifndef USE_SDL1
void handle_touch(SDL_Event *event, int currentMouseX, int currentMouseY);
#endif
void finish_simulated_mouse_clicks(int currentMouseX, int currentMouseY);
} // namespace devilution
#endif
Loading…
Cancel
Save