firmware+controller: Add match found state

This commit is contained in:
Jack O'Sullivan 2024-12-15 12:05:36 +00:00
parent 18831c3e0e
commit ea5f1a7902
6 changed files with 64 additions and 7 deletions

View File

@ -18,6 +18,8 @@ def main():
h.idle(None) h.idle(None)
h.queue_start(RiotPlayerInfo.dummy( h.queue_start(RiotPlayerInfo.dummy(
valorant=ValorantPlayerInfo(queue_type='unrated', is_party_owner=True))) 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() h.service()
finally: finally:

View File

@ -313,6 +313,9 @@ class HIDValconomyHandler(ValconomyHandler):
ms_not_comp = info.valorant.is_party_owner and info.valorant.queue_type == 'unrated' 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') 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): class GameState(Enum):
NONE = 0 NONE = 0
MENU = 1 MENU = 1

View File

@ -183,7 +183,7 @@ void val_ui_menu(bool was_idle) {
lv_anim_set_var(&a_title, l_main); lv_anim_set_var(&a_title, l_main);
lv_anim_set_values( lv_anim_set_values(
&a_title, &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_exec_cb(&a_title, anim_y_cb);
lv_anim_set_path_cb(&a_title, lv_anim_path_ease_in); lv_anim_set_path_cb(&a_title, lv_anim_path_ease_in);
lv_anim_set_duration(&a_title, 500); 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_var(&a_sub, l_subtitle);
lv_anim_set_values( lv_anim_set_values(
&a_sub, &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_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_exec_cb(&a_sub, anim_y_cb);
lv_anim_set_path_cb(&a_sub, lv_anim_path_ease_in); 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_t *l_subtitle = lv_label_create(o_active);
lv_obj_add_style(l_subtitle, &s_subtitle, 0); lv_obj_add_style(l_subtitle, &s_subtitle, 0);
lv_obj_center(l_subtitle); 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_t *spinner = lv_spinner_create(o_active);
lv_obj_set_size(spinner, 100, 100); lv_obj_set_size(spinner, 100, 100);
@ -301,7 +301,6 @@ void val_ui_queue_start(bool ms_not_comp) {
lv_obj_set_y( lv_obj_set_y(
spinner, spinner,
lv_obj_get_height(o_container) / 4); 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 // Animations
lv_anim_t a_title; 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_var(&a_title, l_main);
lv_anim_set_values( lv_anim_set_values(
&a_title, &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_exec_cb(&a_title, anim_x_cb);
lv_anim_set_path_cb(&a_title, lv_anim_path_ease_out); lv_anim_set_path_cb(&a_title, lv_anim_path_ease_out);
lv_anim_set_duration(&a_title, 750); 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_var(&a_sub, l_subtitle);
lv_anim_set_values( lv_anim_set_values(
&a_sub, &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_exec_cb(&a_sub, anim_x_cb);
lv_anim_set_path_cb(&a_sub, lv_anim_path_ease_out); lv_anim_set_path_cb(&a_sub, lv_anim_path_ease_out);
lv_anim_set_completed_cb(&a_sub, anim_state_ready_cb); 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); 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) { void val_lvgl_ui(lv_display_t *disp) {
color_primary = lv_color_hex(0xff4655); color_primary = lv_color_hex(0xff4655);
color_secondary = lv_color_hex(0xf7518f); color_secondary = lv_color_hex(0xf7518f);

View File

@ -16,5 +16,6 @@ void val_ui_none();
void val_ui_menu(bool was_idle); void val_ui_menu(bool was_idle);
void val_ui_idle(); void val_ui_idle();
void val_ui_queue_start(bool ms_not_comp); 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); void val_lvgl_ui(lv_display_t *disp);

View File

@ -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"); ESP_LOGE(TAG, "Failed to grab LVGL lock");
return; return;
} }
if (buf[0] > ST_QUEUE_START) { if (buf[0] > ST_MATCH_FOUND) {
ESP_LOGW(TAG, "Unknown state %hhu", buf[0]); ESP_LOGW(TAG, "Unknown state %hhu", buf[0]);
goto ret; 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]); val_ui_queue_start((bool)buf[1]);
break; 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: ret:

View File

@ -10,6 +10,7 @@ typedef enum val_state {
ST_MENU, ST_MENU,
ST_IDLE, ST_IDLE,
ST_QUEUE_START, ST_QUEUE_START,
ST_MATCH_FOUND,
} val_state_t; } val_state_t;
void val_usb_init(void); void val_usb_init(void);