Skip to content

Commit

Permalink
Merge pull request #91 from RogueMaster/gameOnly
Browse files Browse the repository at this point in the history
Game only
  • Loading branch information
RogueMaster authored Jul 7, 2022
2 parents 905fc36 + a17e061 commit c3332e6
Show file tree
Hide file tree
Showing 3 changed files with 113 additions and 22 deletions.
1 change: 1 addition & 0 deletions applications/desktop/desktop_settings/desktop_settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,5 @@ typedef struct {
uint8_t is_locked;
uint32_t auto_lock_delay_ms;
uint8_t displayBatteryPercentage;
bool is_dumbmode;
} DesktopSettings;
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,17 @@ const char* const battery_view_count_text[BATTERY_VIEW_COUNT] = {
const uint32_t displayBatteryPercentage_value[BATTERY_VIEW_COUNT] =
{0, 1, 2, 3, 4};


#define DUMBMODE 1
#define NOT_DUMBMODE 0
#define DUMBMODE_COUNT 2
const char* const dumbmode_text[DUMBMODE_COUNT] = {
"OFF",
"ON",
};

const uint32_t dumbmode_value[DUMBMODE_COUNT] = {NOT_DUMBMODE, DUMBMODE};

static void desktop_settings_scene_start_var_list_enter_callback(void* context, uint32_t index) {
DesktopSettingsApp* app = context;
view_dispatcher_send_custom_event(app->view_dispatcher, index);
Expand All @@ -58,6 +69,13 @@ static void desktop_settings_scene_start_battery_view_changed(VariableItem* item
app->settings.displayBatteryPercentage = index;
}

static void desktop_settings_scene_start_dumbmode_changed(VariableItem* item) {
DesktopSettingsApp* app = variable_item_get_context(item);
uint8_t index = variable_item_get_current_value_index(item);

variable_item_set_current_value_text(item, dumbmode_text[index]);
app->settings.is_dumbmode = dumbmode_value[index];
}

void desktop_settings_scene_start_on_enter(void* context) {
DesktopSettingsApp* app = context;
Expand All @@ -81,8 +99,6 @@ void desktop_settings_scene_start_on_enter(void* context) {
desktop_settings_scene_start_auto_lock_delay_changed,
app);

variable_item_list_set_enter_callback(
variable_item_list, desktop_settings_scene_start_var_list_enter_callback, app);
value_index = value_index_uint32(
app->settings.auto_lock_delay_ms, auto_lock_delay_value, AUTO_LOCK_DELAY_COUNT);
variable_item_set_current_value_index(item, value_index);
Expand All @@ -102,6 +118,19 @@ void desktop_settings_scene_start_on_enter(void* context) {
variable_item_set_current_value_index(item, value_index);
variable_item_set_current_value_text(item, battery_view_count_text[value_index]);

item = variable_item_list_add(
variable_item_list,
"Games Only",
DUMBMODE_COUNT,
desktop_settings_scene_start_dumbmode_changed,
app);

value_index = value_index_uint32(app->settings.is_dumbmode, dumbmode_value, DUMBMODE_COUNT);
variable_item_set_current_value_index(item, value_index);
variable_item_set_current_value_text(item, dumbmode_text[value_index]);

variable_item_list_set_enter_callback(
variable_item_list, desktop_settings_scene_start_var_list_enter_callback, app);
view_dispatcher_switch_to_view(app->view_dispatcher, DesktopSettingsAppViewVarItemList);
}

Expand Down
101 changes: 81 additions & 20 deletions applications/desktop/views/desktop_view_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

#include "../desktop_i.h"
#include "desktop_view_main.h"
#include <applications/desktop/desktop_settings/desktop_settings.h>
uint32_t codeSequence = 0;

struct DesktopMainView {
View* view;
Expand Down Expand Up @@ -44,27 +46,86 @@ bool desktop_main_input(InputEvent* event, void* context) {

DesktopMainView* main_view = context;

if(event->type == InputTypeShort) {
if(event->key == InputKeyOk) {
main_view->callback(DesktopMainEventOpenMenu, main_view->context);
} else if(event->key == InputKeyUp) {
main_view->callback(DesktopMainEventOpenLockMenu, main_view->context);
} else if(event->key == InputKeyDown) {
main_view->callback(DesktopMainEventOpenArchive, main_view->context);
} else if(event->key == InputKeyLeft) {
main_view->callback(DesktopMainEventOpenFavoritePrimary, main_view->context);
} else if(event->key == InputKeyRight) {
main_view->callback(DesktopMainEventOpenPassport, main_view->context);
DesktopSettings* desktop_settings = malloc(sizeof(DesktopSettings));
LOAD_DESKTOP_SETTINGS(desktop_settings);
if(!desktop_settings->is_dumbmode) {
if(event->type == InputTypeShort) {
if(event->key == InputKeyOk) {
main_view->callback(DesktopMainEventOpenMenu, main_view->context);
} else if(event->key == InputKeyUp) {
main_view->callback(DesktopMainEventOpenLockMenu, main_view->context);
} else if(event->key == InputKeyDown) {
main_view->callback(DesktopMainEventOpenArchive, main_view->context);
} else if(event->key == InputKeyLeft) {
main_view->callback(DesktopMainEventOpenFavoritePrimary, main_view->context);
} else if(event->key == InputKeyRight) {
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);
} else if(event->key == InputKeyDown) {
main_view->callback(DesktopMainEventOpenDebug, main_view->context);
} else if(event->key == InputKeyLeft) {
main_view->callback(DesktopMainEventOpenFavoriteSecondary, main_view->context);
} else if(event->key == InputKeyRight) {
// THIS DOESNT WORK
}
}
} else if(event->type == InputTypeLong) {
if(event->key == InputKeyDown) {
main_view->callback(DesktopMainEventOpenDebug, main_view->context);
} else if(event->key == InputKeyLeft) {
main_view->callback(DesktopMainEventOpenFavoriteSecondary, main_view->context);
} else if(event->key == InputKeyUp) {
main_view->callback(DesktopMainEventOpenFavoriteGame, main_view->context);
} else if (event->key == InputKeyOk) {
main_view->callback(DesktopAnimationEventNewIdleAnimation, main_view->context);
} else {
if(event->type == InputTypeShort) {
if(event->key == InputKeyOk) {
// PREFER TO OPEN GAMES MENU, SINCE RIGHT ONLY WORKS FOR PASSPORT NEED TO USE TO EXIT GAME MODE
if(codeSequence==5 || codeSequence==7) {
codeSequence++;
} else {
codeSequence=0;
main_view->callback(DesktopAnimationEventNewIdleAnimation, main_view->context);
}
} else if(event->key == InputKeyUp) {
if(codeSequence==0 || codeSequence==1) {
codeSequence++;
} else {
codeSequence=0;
main_view->callback(DesktopMainEventOpenFavoriteGame, main_view->context);
}
} else if(event->key == InputKeyDown) {
if(codeSequence==2 || codeSequence==3) {
codeSequence++;
} else {
codeSequence=0;
}
} else if(event->key == InputKeyLeft) {
if(codeSequence==4 || codeSequence==6) {
codeSequence++;
} else {
codeSequence=0;
main_view->callback(DesktopMainEventOpenFavoritePrimary, main_view->context);
}
} else if(event->key == InputKeyRight) {
// GOES TO PASSPORT NO MATTER WHAT
}
if(codeSequence==8) {
// UNLOCK!
main_view->callback(DesktopMainEventOpenMenu, main_view->context);
codeSequence=0;
}
} 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);
} else if(event->key == InputKeyDown) {
// main_view->callback(DesktopMainEventOpenMenu, main_view->context);
} else if(event->key == InputKeyLeft) {
// PREFER TO OPEN CLOCK INSTEAD OF FAVORITE PRIMARY, BUT THIS WILL DO
main_view->callback(DesktopMainEventOpenFavoritePrimary, main_view->context);
// main_view->callback(DesktopMainEventOpenPassport, main_view->context); THIS ONLY WORKS ON MENU RIGHT WITH NO HOLD
} else if(event->key == InputKeyRight) {
// THIS DOESNT WORK, PASSPORT WILL ONLY OPEN ON REGULAR RIGHT, NOTHING CAN GET ASSIGNED HERE
}
}
}

Expand Down

0 comments on commit c3332e6

Please sign in to comment.