From bf964fffdd2c1d730623673987a6de32a3f7c92f Mon Sep 17 00:00:00 2001 From: RogueMaster Date: Sun, 18 Sep 2022 01:27:44 -0400 Subject: [PATCH] games fix --- .../desktop/scenes/desktop_scene_main.c | 42 ++++++++++++++++- .../services/desktop/views/desktop_events.h | 7 ++- .../desktop/views/desktop_view_main.c | 45 ++++++++++--------- 3 files changed, 70 insertions(+), 24 deletions(-) diff --git a/applications/services/desktop/scenes/desktop_scene_main.c b/applications/services/desktop/scenes/desktop_scene_main.c index efdf9f89690..4cbb001fe1d 100644 --- a/applications/services/desktop/scenes/desktop_scene_main.c +++ b/applications/services/desktop/scenes/desktop_scene_main.c @@ -172,7 +172,7 @@ bool desktop_scene_main_on_event(void* context, SceneManagerEvent event) { } break; } - case DesktopMainEventOpenGameMenu: { + case DesktopMainEventOpenSnake: { LoaderStatus status = loader_start( desktop->loader, "Applications", EXT_PATH("/apps/Games/GAME_Snake.fap")); if(status != LoaderStatusOk) { @@ -180,6 +180,46 @@ bool desktop_scene_main_on_event(void* context, SceneManagerEvent event) { } break; } + case DesktopMainEventOpen2048: { + LoaderStatus status = loader_start( + desktop->loader, "Applications", EXT_PATH("/apps/Games/GAME_2048.fap")); + if(status != LoaderStatusOk) { + FURI_LOG_E(TAG, "loader_start failed: %d", status); + } + break; + } + case DesktopMainEventOpenZombiez: { + LoaderStatus status = loader_start( + desktop->loader, "Applications", EXT_PATH("/apps/Games/GAME_Zombiez.fap")); + if(status != LoaderStatusOk) { + FURI_LOG_E(TAG, "loader_start failed: %d", status); + } + break; + } + case DesktopMainEventOpenTetris: { + LoaderStatus status = loader_start( + desktop->loader, "Applications", EXT_PATH("/apps/Games/GAME_Tetris.fap")); + if(status != LoaderStatusOk) { + FURI_LOG_E(TAG, "loader_start failed: %d", status); + } + break; + } + case DesktopMainEventOpenDOOM: { + LoaderStatus status = loader_start( + desktop->loader, "Applications", EXT_PATH("/apps/Games/GAME_DOOM.fap")); + if(status != LoaderStatusOk) { + FURI_LOG_E(TAG, "loader_start failed: %d", status); + } + break; + } + case DesktopMainEventOpenDice: { + LoaderStatus status = loader_start( + desktop->loader, "Applications", EXT_PATH("/apps/Games/GAME_Dice.fap")); + if(status != LoaderStatusOk) { + FURI_LOG_E(TAG, "loader_start failed: %d", status); + } + break; + } case DesktopLockedEventUpdate: desktop_view_locked_update(desktop->locked_view); consumed = true; diff --git a/applications/services/desktop/views/desktop_events.h b/applications/services/desktop/views/desktop_events.h index 30f14ce120d..6d32fb7077b 100644 --- a/applications/services/desktop/views/desktop_events.h +++ b/applications/services/desktop/views/desktop_events.h @@ -12,7 +12,12 @@ typedef enum { DesktopMainEventOpenPassport, DesktopMainEventOpenPowerOff, - DesktopMainEventOpenGameMenu, + DesktopMainEventOpenSnake, + DesktopMainEventOpen2048, + DesktopMainEventOpenZombiez, + DesktopMainEventOpenTetris, + DesktopMainEventOpenDOOM, + DesktopMainEventOpenDice, DesktopLockedEventUnlocked, DesktopLockedEventUpdate, diff --git a/applications/services/desktop/views/desktop_view_main.c b/applications/services/desktop/views/desktop_view_main.c index c360098ef81..8535f5c7deb 100644 --- a/applications/services/desktop/views/desktop_view_main.c +++ b/applications/services/desktop/views/desktop_view_main.c @@ -71,65 +71,66 @@ bool desktop_main_input_callback(InputEvent* event, void* context) { } else if(event->key == InputKeyLeft) { main_view->callback(DesktopMainEventOpenFavoritePrimary, main_view->context); } else if(event->key == InputKeyRight) { + // Right key is handled by animation manager + // GOES TO PASSPORT NO MATTER WHAT + // THIS DOESNT WORK, PASSPORT WILL ONLY OPEN ON REGULAR RIGHT, NOTHING CAN GET ASSIGNED HERE main_view->callback(DesktopMainEventOpenPassport, main_view->context); } } else if(event->type == InputTypeLong) { if(event->key == InputKeyOk) { main_view->callback(DesktopAnimationEventNewIdleAnimation, main_view->context); } else if(event->key == InputKeyUp) { - // main_view->callback(DesktopMainEventOpenFavoriteGame, main_view->context); + main_view->callback(DesktopMainEventOpenDOOM, main_view->context); // OPENS DOOM } else if(event->key == InputKeyDown) { - // main_view->callback(DesktopMainEventOpenGames, main_view->context); - main_view->callback(DesktopMainEventOpenDebug, main_view->context); + main_view->callback(DesktopMainEventOpenZombiez, main_view->context); // OPENS Zombiez } else if(event->key == InputKeyLeft) { main_view->callback(DesktopMainEventOpenFavoriteSecondary, main_view->context); - } else if(event->key == InputKeyRight) { - // THIS DOESNT WORK } } } else if(main_view->is_gamemode == true) { if(event->type == InputTypeShort) { if(event->key == InputKeyOk) { - // main_view->callback(DesktopMainEventOpenGames, main_view->context); - main_view->callback(DesktopMainEventOpenGameMenu, main_view->context); // OPENS SNAKE + main_view->callback(DesktopMainEventOpenDice, main_view->context); // OPENS Dice } else if(event->key == InputKeyUp) { - // main_view->callback(DesktopMainEventOpenFavoriteGame, main_view->context); - main_view->callback(DesktopMainEventOpenGameMenu, main_view->context); // OPENS SNAKE + main_view->callback(DesktopMainEventOpenSnake, main_view->context); // OPENS SNAKE } else if(event->key == InputKeyDown) { // PREFER TO OPEN GAMES MENU - main_view->callback(DesktopMainEventOpenGameMenu, main_view->context); // OPENS SNAKE + main_view->callback(DesktopMainEventOpen2048, main_view->context); // OPENS 2048 } else if(event->key == InputKeyLeft) { main_view->callback(DesktopMainEventOpenClock, main_view->context); - } else if(event->key == InputKeyRight) { - // GOES TO PASSPORT NO MATTER WHAT } } else if(event->type == InputTypeLong) { if(event->key == InputKeyOk) { main_view->callback(DesktopAnimationEventNewIdleAnimation, main_view->context); } else if(event->key == InputKeyUp) { - // main_view->callback(DesktopMainEventOpenFavoriteGame, main_view->context); - main_view->callback(DesktopMainEventOpenGameMenu, main_view->context); // OPENS SNAKE + main_view->callback(DesktopMainEventOpenDOOM, main_view->context); // OPENS DOOM } else if(event->key == InputKeyDown) { - // main_view->callback(DesktopMainEventOpenGames, main_view->context); - main_view->callback(DesktopMainEventOpenGameMenu, main_view->context); // OPENS SNAKE + main_view->callback(DesktopMainEventOpenZombiez, main_view->context); // OPENS Zombiez } else if(event->key == InputKeyLeft) { - main_view->callback(DesktopMainEventOpenClock, main_view->context); - } else if(event->key == InputKeyRight) { - // THIS DOESNT WORK, PASSPORT WILL ONLY OPEN ON REGULAR RIGHT, NOTHING CAN GET ASSIGNED HERE + main_view->callback(DesktopMainEventOpenTetris, main_view->context); // OPENS TETRIS } } } else { if(event->type == InputTypeShort) { if(event->key == InputKeyOk) { - main_view->callback(DesktopMainEventOpenGameMenu, main_view->context); // OPENS SNAKE + main_view->callback(DesktopMainEventOpenDice, main_view->context); // OPENS Dice } else if(event->key == InputKeyUp) { main_view->callback(DesktopMainEventOpenLockMenu, main_view->context); } else if(event->key == InputKeyDown) { - main_view->callback(DesktopMainEventOpenPassport, main_view->context); + main_view->callback(DesktopMainEventOpen2048, main_view->context); // OPENS 2048 } else if(event->key == InputKeyLeft) { main_view->callback(DesktopMainEventOpenPassport, main_view->context); } - // Right key is handled by animation manager + } else if(event->type == InputTypeLong) { + if(event->key == InputKeyOk) { + main_view->callback(DesktopAnimationEventNewIdleAnimation, main_view->context); + } else if(event->key == InputKeyUp) { + main_view->callback(DesktopMainEventOpenSnake, main_view->context); // OPENS SNAKE + } else if(event->key == InputKeyDown) { + main_view->callback(DesktopMainEventOpenTetris, main_view->context); // OPENS TETRIS + } else if(event->key == InputKeyLeft) { + main_view->callback(DesktopMainEventOpenClock, main_view->context); + } } }