diff --git a/controller/hid-test.py b/controller/hid-test.py index 1033c2e..8c91bb9 100755 --- a/controller/hid-test.py +++ b/controller/hid-test.py @@ -18,6 +18,8 @@ def main(): h.idle(None) h.queue_start(RiotPlayerInfo.dummy( valorant=ValorantPlayerInfo(queue_type='unrated', is_party_owner=True))) + h.match_found(RiotPlayerInfo.dummy(valorant=ValorantPlayerInfo(queue_type='premier-seasonmatch'))) + h.match_found(RiotPlayerInfo.dummy(valorant=ValorantPlayerInfo())) h.service() finally: diff --git a/controller/valconomy.py b/controller/valconomy.py index 800f50d..5e5b05c 100644 --- a/controller/valconomy.py +++ b/controller/valconomy.py @@ -313,6 +313,9 @@ class HIDValconomyHandler(ValconomyHandler): ms_not_comp = info.valorant.is_party_owner and info.valorant.queue_type == 'unrated' self._enq(3, 1 if ms_not_comp else 0, fmt='B') + def match_found(self, info: RiotPlayerInfo): + self._enq(4, 1 if info.valorant.queue_type == 'premier-seasonmatch' else 0, fmt='B') + class GameState(Enum): NONE = 0 MENU = 1 diff --git a/firmware/main/ui.c b/firmware/main/ui.c index f436732..9cf41c2 100644 --- a/firmware/main/ui.c +++ b/firmware/main/ui.c @@ -183,7 +183,7 @@ void val_ui_menu(bool was_idle) { lv_anim_set_var(&a_title, l_main); lv_anim_set_values( &a_title, - -(lv_obj_get_height(o_container) - lv_obj_get_height(l_main)) / 2, 0); + -(lv_obj_get_height(o_container) + lv_obj_get_height(l_main)) / 2, 0); lv_anim_set_exec_cb(&a_title, anim_y_cb); lv_anim_set_path_cb(&a_title, lv_anim_path_ease_in); lv_anim_set_duration(&a_title, 500); @@ -193,7 +193,7 @@ void val_ui_menu(bool was_idle) { lv_anim_set_var(&a_sub, l_subtitle); lv_anim_set_values( &a_sub, - (lv_obj_get_height(o_container) - lv_obj_get_height(l_main)) / 2, + (lv_obj_get_height(o_container) + lv_obj_get_height(l_main)) / 2, (lv_obj_get_height(l_main) + lv_obj_get_height(l_subtitle)) / 2 + 5); lv_anim_set_exec_cb(&a_sub, anim_y_cb); lv_anim_set_path_cb(&a_sub, lv_anim_path_ease_in); @@ -284,7 +284,7 @@ void val_ui_queue_start(bool ms_not_comp) { lv_obj_t *l_subtitle = lv_label_create(o_active); lv_obj_add_style(l_subtitle, &s_subtitle, 0); lv_obj_center(l_subtitle); - lv_label_set_text_static(l_subtitle, ms_not_comp ? "UHHH SHOULD THAT BE COMP?" : "I HOPE IT'S NOT SPLIT..."); + lv_label_set_text_static(l_subtitle, ms_not_comp ? "UHHH SHOULD THAT BE COMP?" : "HOPE YOU FIND A GAME QUICKLY!"); lv_obj_t *spinner = lv_spinner_create(o_active); lv_obj_set_size(spinner, 100, 100); @@ -301,7 +301,6 @@ void val_ui_queue_start(bool ms_not_comp) { lv_obj_set_y( spinner, lv_obj_get_height(o_container) / 4); - // offset + (lv_obj_get_height(l_main)/2) + lv_obj_get_height(l_subtitle) + (lv_obj_get_height(spinner)/2) + 15); // Animations lv_anim_t a_title; @@ -309,7 +308,7 @@ void val_ui_queue_start(bool ms_not_comp) { lv_anim_set_var(&a_title, l_main); lv_anim_set_values( &a_title, - -(lv_obj_get_width(o_container) - lv_obj_get_width(l_main)) / 2, 0); + -(lv_obj_get_width(o_container) + lv_obj_get_width(l_main)) / 2, 0); lv_anim_set_exec_cb(&a_title, anim_x_cb); lv_anim_set_path_cb(&a_title, lv_anim_path_ease_out); lv_anim_set_duration(&a_title, 750); @@ -319,7 +318,7 @@ void val_ui_queue_start(bool ms_not_comp) { lv_anim_set_var(&a_sub, l_subtitle); lv_anim_set_values( &a_sub, - (lv_obj_get_width(o_container) - lv_obj_get_width(l_subtitle)) / 2, 0); + (lv_obj_get_width(o_container) + lv_obj_get_width(l_subtitle)) / 2, 0); lv_anim_set_exec_cb(&a_sub, anim_x_cb); lv_anim_set_path_cb(&a_sub, lv_anim_path_ease_out); lv_anim_set_completed_cb(&a_sub, anim_state_ready_cb); @@ -347,6 +346,50 @@ void val_ui_queue_start(bool ms_not_comp) { lv_anim_timeline_start(at_active); } +void val_ui_match_found(bool is_premier) { + setup_next_state(); + + // Widgets + lv_obj_t *l_main = lv_label_create(o_active); + lv_obj_add_style(l_main, &s_hero, 0); + lv_obj_center(l_main); + lv_label_set_text_static(l_main, "MATCH FOUND"); + + lv_obj_t *l_subtitle = lv_label_create(o_active); + lv_obj_add_style(l_subtitle, &s_subtitle, 0); + lv_obj_center(l_subtitle); + lv_label_set_text_static(l_subtitle, is_premier ? "DO THE COSMONAUTS PROUD!" : "I HOPE IT'S NOT SPLIT..."); + + lv_obj_update_layout(o_active); + + // Animations + lv_anim_t a_title; + lv_anim_init(&a_title); + lv_anim_set_var(&a_title, l_main); + lv_anim_set_values( + &a_title, + (lv_obj_get_height(o_container) + lv_obj_get_height(l_main)) / 2, 0); + lv_anim_set_exec_cb(&a_title, anim_y_cb); + lv_anim_set_path_cb(&a_title, lv_anim_path_ease_in); + lv_anim_set_duration(&a_title, 500); + + lv_anim_t a_sub; + lv_anim_init(&a_sub); + lv_anim_set_var(&a_sub, l_subtitle); + lv_anim_set_values( + &a_sub, + -(lv_obj_get_height(o_container) + lv_obj_get_height(l_main)) / 2, + (lv_obj_get_height(l_main) + lv_obj_get_height(l_subtitle)) / 2 + 5); + lv_anim_set_exec_cb(&a_sub, anim_y_cb); + lv_anim_set_path_cb(&a_sub, lv_anim_path_ease_in); + lv_anim_set_completed_cb(&a_sub, anim_state_ready_cb); + lv_anim_set_duration(&a_sub, 500); + + lv_anim_timeline_add(at_active, 0, &a_title); + lv_anim_timeline_add(at_active, 0, &a_sub); + lv_anim_timeline_start(at_active); +} + void val_lvgl_ui(lv_display_t *disp) { color_primary = lv_color_hex(0xff4655); color_secondary = lv_color_hex(0xf7518f); diff --git a/firmware/main/ui.h b/firmware/main/ui.h index 9ebd4b1..e28daf4 100644 --- a/firmware/main/ui.h +++ b/firmware/main/ui.h @@ -16,5 +16,6 @@ void val_ui_none(); void val_ui_menu(bool was_idle); void val_ui_idle(); void val_ui_queue_start(bool ms_not_comp); +void val_ui_match_found(bool is_premier); void val_lvgl_ui(lv_display_t *disp); diff --git a/firmware/main/usb.c b/firmware/main/usb.c index b92f299..aff1a48 100644 --- a/firmware/main/usb.c +++ b/firmware/main/usb.c @@ -101,7 +101,7 @@ void tud_hid_set_report_cb(uint8_t instance, uint8_t report_id, hid_report_type_ ESP_LOGE(TAG, "Failed to grab LVGL lock"); return; } - if (buf[0] > ST_QUEUE_START) { + if (buf[0] > ST_MATCH_FOUND) { ESP_LOGW(TAG, "Unknown state %hhu", buf[0]); goto ret; } @@ -130,6 +130,13 @@ void tud_hid_set_report_cb(uint8_t instance, uint8_t report_id, hid_report_type_ } val_ui_queue_start((bool)buf[1]); break; + case ST_MATCH_FOUND: + if (bufsize < 2) { + ESP_LOGE(TAG, "Invalid ST_MATCH_FOUND command"); + goto ret; + } + val_ui_match_found((bool)buf[1]); + break; } ret: diff --git a/firmware/main/usb.h b/firmware/main/usb.h index 9b6fc29..61cf899 100644 --- a/firmware/main/usb.h +++ b/firmware/main/usb.h @@ -10,6 +10,7 @@ typedef enum val_state { ST_MENU, ST_IDLE, ST_QUEUE_START, + ST_MATCH_FOUND, } val_state_t; void val_usb_init(void);