diff --git a/Engine/ac/display.cpp b/Engine/ac/display.cpp index a9cf20a8d6..9386345c99 100644 --- a/Engine/ac/display.cpp +++ b/Engine/ac/display.cpp @@ -11,14 +11,11 @@ // https://opensource.org/license/artistic-2-0/ // //============================================================================= - +#include "ac/display.h" #include - #include #include "ac/display.h" #include "ac/common.h" -#include "font/agsfontrenderer.h" -#include "font/fonts.h" #include "ac/character.h" #include "ac/draw.h" #include "ac/game.h" @@ -27,26 +24,28 @@ #include "ac/global_audio.h" #include "ac/global_game.h" #include "ac/gui.h" +#include "ac/joystick.h" #include "ac/mouse.h" #include "ac/overlay.h" #include "ac/sys_events.h" #include "ac/screenoverlay.h" #include "ac/speech.h" +#include "ac/spritecache.h" #include "ac/string.h" #include "ac/system.h" +#include "ac/timer.h" +#include "ac/touch.h" #include "debug/debug_log.h" +#include "font/agsfontrenderer.h" +#include "font/fonts.h" #include "gfx/blender.h" +#include "gfx/gfx_util.h" #include "gui/guibutton.h" #include "gui/guimain.h" #include "main/game_run.h" +#include "media/audio/audio_system.h" #include "platform/base/agsplatformdriver.h" -#include "ac/spritecache.h" -#include "gfx/gfx_util.h" #include "util/string_utils.h" -#include "ac/mouse.h" -#include "media/audio/audio_system.h" -#include "ac/timer.h" -#include "joystick.h" using namespace AGS::Common; using namespace AGS::Common::BitmapHelper; @@ -333,7 +332,7 @@ bool display_check_user_input(int skip) { state_handled = true; } - else if ((skip & SKIP_KEYPRESS) && !play.IsIgnoringInput() && !IsAGSServiceKey(ki.Key)) + else if ((skip & SKIP_KEYPRESS) != 0 && !play.IsIgnoringInput() && !IsAGSServiceKey(ki.Key)) { play.SetWaitKeySkip(ki); state_handled = true; // stop display @@ -349,7 +348,7 @@ bool display_check_user_input(int skip) { state_handled = true; } - else if (skip & SKIP_MOUSECLICK && !play.IsIgnoringInput()) + else if ((skip & SKIP_MOUSECLICK) != 0 && !play.IsIgnoringInput()) { play.SetWaitSkipResult(SKIP_MOUSECLICK, mbut); state_handled = true; // stop display @@ -366,7 +365,7 @@ bool display_check_user_input(int skip) { state_handled = true; // stop display } - else if (skip & SKIP_GAMEPAD && !play.IsIgnoringInput() && + else if ((skip & SKIP_GAMEPAD) != 0 && !play.IsIgnoringInput() && is_default_gamepad_skip_button_pressed(gbn)) { play.SetWaitSkipResult(SKIP_GAMEPAD, gbn); @@ -374,6 +373,19 @@ bool display_check_user_input(int skip) } break; } + case kInputTouch: + { + TouchInput ti; + if (!run_service_touch_controls(ti) || play.fast_forward || state_handled) + continue; // handled by engine layer, or fast-forwarded, or resolved + // TODO: check skip cutscene? we might check if it's "skip by mouse" here + if ((skip & SKIP_TOUCH) != 0 && (ti.Phase == TouchPhase::Down) && !play.IsIgnoringInput()) + { + play.SetWaitSkipResult(SKIP_TOUCH); + state_handled = true; // stop display + } + break; + } default: ags_drop_next_inputevent(); break; diff --git a/Engine/ac/runtime_defines.h b/Engine/ac/runtime_defines.h index 3b20461b48..f116f32996 100644 --- a/Engine/ac/runtime_defines.h +++ b/Engine/ac/runtime_defines.h @@ -109,6 +109,7 @@ #define SKIP_KEYPRESS 0x02 #define SKIP_MOUSECLICK 0x04 #define SKIP_GAMEPAD 0x08 +#define SKIP_TOUCH 0x10 // Bit shift for packing skip type into result #define SKIP_RESULT_TYPE_SHIFT 24 // Bit mask for packing skip key/button data into result diff --git a/Engine/ac/speech.cpp b/Engine/ac/speech.cpp index 3e4cd903ab..fc9e305bd2 100644 --- a/Engine/ac/speech.cpp +++ b/Engine/ac/speech.cpp @@ -36,26 +36,31 @@ static String VoiceAssetPath; int user_to_internal_skip_speech(SkipSpeechStyle userval) { + // NOTE: After Gamepad and Touch controls were implemented, + // we treat "Skip by key" as "by key or gamepad button" + // and "Skip by mouse" as "by mouse or touch". switch (userval) { case kSkipSpeechNone: return SKIP_NONE; case kSkipSpeechKeyMouseTime: - return SKIP_AUTOTIMER | SKIP_KEYPRESS | SKIP_MOUSECLICK | SKIP_GAMEPAD; // FIXME: remake this as `kSkipAny` + // TODO: remake this as "kSkipAny"? + return SKIP_AUTOTIMER | SKIP_KEYPRESS | SKIP_MOUSECLICK | SKIP_GAMEPAD | SKIP_TOUCH; case kSkipSpeechKeyTime: - return SKIP_AUTOTIMER | SKIP_KEYPRESS; + return SKIP_AUTOTIMER | SKIP_KEYPRESS | SKIP_GAMEPAD; case kSkipSpeechTime: return SKIP_AUTOTIMER; case kSkipSpeechKeyMouse: - return SKIP_KEYPRESS | SKIP_MOUSECLICK; + // TODO: remake this as "kSkipAnyInput"? + return SKIP_KEYPRESS | SKIP_MOUSECLICK | SKIP_GAMEPAD | SKIP_TOUCH; case kSkipSpeechMouseTime: - return SKIP_AUTOTIMER | SKIP_MOUSECLICK; + return SKIP_AUTOTIMER | SKIP_MOUSECLICK | SKIP_TOUCH; case kSkipSpeechKey: - return SKIP_KEYPRESS; + return SKIP_KEYPRESS | SKIP_GAMEPAD; case kSkipSpeechMouse: - return SKIP_MOUSECLICK; + return SKIP_MOUSECLICK | SKIP_TOUCH; default: - quit("user_to_internal_skip_speech: unknown userval"); + debug_script_warn("user_to_internal_skip_speech: unknown userval"); return SKIP_NONE; } } diff --git a/Engine/main/game_run.h b/Engine/main/game_run.h index 21b67b0170..b485842e65 100644 --- a/Engine/main/game_run.h +++ b/Engine/main/game_run.h @@ -18,6 +18,7 @@ namespace AGS { namespace Engine { class IDriverDependantBitmap; }} struct GamepadInput; +struct TouchInput; // Loops game frames until certain event takes place (for blocking actions) void GameLoopUntilValueIsZero(const char *value); @@ -61,6 +62,9 @@ bool run_service_mb_controls(eAGSMouseButton &mbut, Point *mpos = nullptr); // Runs service gamepad controls, returns false if no button was pressed or if button input was claimed by the engine, // otherwise returns true and provides the gamepad input. bool run_service_gamepad_controls(GamepadInput &out_key); +// Runs service touch controls, returns false if not touch is active or if its event was claimed by the engine, +// otherwise returns true and provides TouchInput data +bool run_service_touch_controls(TouchInput &out_touch); // Polls few things (exit flag and debugger messages) // TODO: refactor this void update_polled_stuff();