Skip to content

Commit

Permalink
Better bottom bar appearance iOS handling
Browse files Browse the repository at this point in the history
  • Loading branch information
XITRIX committed Oct 27, 2024
1 parent 57af4b3 commit c0be1b8
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/include/streaming_view.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class StreamingView : public brls::Box {
bool tempInputLock = false;
brls::Event<brls::KeyState>::Subscription keysSubscription;
int touchScrollCounter = 0;
size_t bottombarDelayTask = -1;

void handleInput();
void handleOverlayCombo();
Expand Down
31 changes: 31 additions & 0 deletions app/src/streaming_view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,22 @@
#include <chrono>
#include <nanovg.h>

#if defined(__SDL2__)
#include <SDL2/SDL.h>
#endif

using namespace brls;

#ifdef PLATFORM_TVOS
extern void updatePreferredDisplayMode(bool streamActive);
#endif

void setBottomBarStatus(const char *value) {
#if defined(__SDL2__)
SDL_SetHint(SDL_HINT_IOS_HIDE_HOME_INDICATOR, value);
#endif
}

StreamingView::StreamingView(const Host& host, const AppInfo& app) : host(host), app(app) {
Application::getPlatform()->disableScreenDimming(true);

Expand Down Expand Up @@ -207,6 +217,8 @@ void StreamingView::onFocusGained() {
});

Application::getPlatform()->getInputManager()->setPointerLock(true);

setBottomBarStatus("1");
}

void StreamingView::onFocusLost() {
Expand All @@ -222,6 +234,11 @@ void StreamingView::onFocusLost() {

removeKeyboard();
Application::getPlatform()->getInputManager()->setPointerLock(false);

setBottomBarStatus("2");

if (bottombarDelayTask != -1)
cancelDelay(bottombarDelayTask);
}

void StreamingView::draw(NVGcontext* vg, float x, float y, float width,
Expand Down Expand Up @@ -360,6 +377,20 @@ void StreamingView::handleInput() {
} else {
MoonlightInputManager::instance().handleInput();
}

if (Application::currentTouchState.size() > 0) {
setBottomBarStatus("2");

if (bottombarDelayTask != -1)
cancelDelay(bottombarDelayTask);

ASYNC_RETAIN
bottombarDelayTask = delay(3000, [ASYNC_TOKEN]() {
ASYNC_RELEASE
setBottomBarStatus("1");
bottombarDelayTask = -1;
});
}
}

void StreamingView::handleOverlayCombo() {
Expand Down

0 comments on commit c0be1b8

Please sign in to comment.