diff --git a/src/pc/controller/controller_keyboard.c b/src/pc/controller/controller_keyboard.c index 28343344..9370e3ed 100644 --- a/src/pc/controller/controller_keyboard.c +++ b/src/pc/controller/controller_keyboard.c @@ -44,6 +44,7 @@ bool keyboard_on_key_down(int scancode) { // see if interactable captures this scancode if (djui_interactable_on_key_down(scancode)) { + keyboard_lastkey = scancode; return FALSE; } diff --git a/src/pc/djui/djui_bind.c b/src/pc/djui/djui_bind.c index 5667001a..266af2f4 100644 --- a/src/pc/djui/djui_bind.c +++ b/src/pc/djui/djui_bind.c @@ -23,7 +23,6 @@ static void djui_bind_button_on_bind(struct DjuiBase* caller) { if (key == VK_INVALID) { return; } // invalidate key - if (key == VK_ESCAPE) { key = VK_INVALID; } for (int i = 0; i < MAX_BINDS; i++) { if (i == button->base.tag) { continue; } if (bind->configKey[i] == key) { diff --git a/src/pc/djui/djui_chat_box.c b/src/pc/djui/djui_chat_box.c index 0b0bec17..74b62ff6 100644 --- a/src/pc/djui/djui_chat_box.c +++ b/src/pc/djui/djui_chat_box.c @@ -40,6 +40,7 @@ static void djui_chat_box_input_enter(struct DjuiInputbox* chatInput) { } static void djui_chat_box_input_escape(struct DjuiInputbox* chatInput) { + djui_interactable_set_input_focus(NULL); djui_inputbox_set_text(chatInput, ""); djui_inputbox_select_all(chatInput); if (gDjuiChatBoxFocus) { djui_chat_box_toggle(); } diff --git a/src/pc/djui/djui_interactable.c b/src/pc/djui/djui_interactable.c index b8508b12..2d6dec3b 100644 --- a/src/pc/djui/djui_interactable.c +++ b/src/pc/djui/djui_interactable.c @@ -152,7 +152,7 @@ void djui_interactable_set_binding(struct DjuiBase* base) { } void djui_interactable_set_input_focus(struct DjuiBase* base) { - djui_interactable_on_focus_end(base); + djui_interactable_on_focus_end(sInteractableFocus); sInteractableFocus = base; djui_interactable_on_focus_begin(base); djui_cursor_set_visible(base == NULL); @@ -163,6 +163,9 @@ bool djui_interactable_is_input_focus(struct DjuiBase* base) { } bool djui_interactable_on_key_down(int scancode) { + if (sInteractableBinding != NULL) { + return true; + } bool keyFocused = (sInteractableFocus != NULL) && (sInteractableFocus->interactable != NULL) @@ -177,9 +180,10 @@ bool djui_interactable_on_key_down(int scancode) { } } - if (scancode == SCANCODE_ESCAPE) { + if (scancode == SCANCODE_ESCAPE && djui_panel_is_active()) { // pressed escape button on keyboard djui_panel_back(); + return true; } if (gDjuiChatBox != NULL && !gDjuiChatBoxFocus) { @@ -194,12 +198,14 @@ bool djui_interactable_on_key_down(int scancode) { } } - switch (scancode) { - case SCANCODE_UP: sKeyboardHoldDirection = PAD_HOLD_DIR_UP; return true; - case SCANCODE_DOWN: sKeyboardHoldDirection = PAD_HOLD_DIR_DOWN; return true; - case SCANCODE_LEFT: sKeyboardHoldDirection = PAD_HOLD_DIR_LEFT; return true; - case SCANCODE_RIGHT: sKeyboardHoldDirection = PAD_HOLD_DIR_RIGHT; return true; - case SCANCODE_ENTER: sKeyboardButtons |= PAD_BUTTON_A; return true; + if (gDjuiChatBoxFocus || djui_panel_is_active()) { + switch (scancode) { + case SCANCODE_UP: sKeyboardHoldDirection = PAD_HOLD_DIR_UP; return true; + case SCANCODE_DOWN: sKeyboardHoldDirection = PAD_HOLD_DIR_DOWN; return true; + case SCANCODE_LEFT: sKeyboardHoldDirection = PAD_HOLD_DIR_LEFT; return true; + case SCANCODE_RIGHT: sKeyboardHoldDirection = PAD_HOLD_DIR_RIGHT; return true; + case SCANCODE_ENTER: sKeyboardButtons |= PAD_BUTTON_A; return true; + } } return false;