diff --git a/src/xrEngine/key_binding_registrator_script.cpp b/src/xrEngine/key_binding_registrator_script.cpp index fa04ac58c2d..0e1096eddb8 100644 --- a/src/xrEngine/key_binding_registrator_script.cpp +++ b/src/xrEngine/key_binding_registrator_script.cpp @@ -167,6 +167,9 @@ SCRIPT_EXPORT(KeyBindings, (), value("kUI_MOVE_SECONDARY", int(kUI_MOVE_SECONDARY)), + value("kUI_CLICK_1", int(kUI_CLICK_1)), + value("kUI_CLICK_2", int(kUI_CLICK_2)), + value("kUI_ACCEPT", int(kUI_ACCEPT)), value("kUI_BACK", int(kUI_BACK)), value("kUI_ACTION_1", int(kUI_ACTION_1)), diff --git a/src/xrEngine/xr_level_controller.cpp b/src/xrEngine/xr_level_controller.cpp index cf5815ccf1f..443afbe9622 100644 --- a/src/xrEngine/xr_level_controller.cpp +++ b/src/xrEngine/xr_level_controller.cpp @@ -164,6 +164,9 @@ game_action actions[] = { "ui_move_secondary", kUI_MOVE_SECONDARY, _both, EKeyContext::UI }, + { "ui_click_1", kUI_CLICK_1, _both, EKeyContext::UI }, + { "ui_click_2", kUI_CLICK_2, _both, EKeyContext::UI }, + { "ui_accept", kUI_ACCEPT, _both, EKeyContext::UI }, { "ui_back", kUI_BACK, _both, EKeyContext::UI }, { "ui_action_1", kUI_ACTION_1, _both, EKeyContext::UI }, @@ -998,6 +1001,9 @@ class CCC_DefControls : public CCC_UnBindAll { kUI_MOVE_SECONDARY, { SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, XR_CONTROLLER_AXIS_LEFT } }, + { kUI_CLICK_1, { SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, XR_CONTROLLER_AXIS_TRIGGER_RIGHT } }, + { kUI_CLICK_2, { SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, XR_CONTROLLER_AXIS_TRIGGER_LEFT } }, + { kUI_ACCEPT, { SDL_SCANCODE_RETURN, SDL_SCANCODE_F, XR_CONTROLLER_BUTTON_A } }, { kUI_BACK, { SDL_SCANCODE_ESCAPE, SDL_SCANCODE_G, XR_CONTROLLER_BUTTON_B } }, { kUI_ACTION_1, { SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_Y, XR_CONTROLLER_BUTTON_X } }, diff --git a/src/xrEngine/xr_level_controller.h b/src/xrEngine/xr_level_controller.h index 5d38037391e..ac25eb63b77 100644 --- a/src/xrEngine/xr_level_controller.h +++ b/src/xrEngine/xr_level_controller.h @@ -145,6 +145,9 @@ enum EGameActions : u32 kUI_MOVE_SECONDARY, + kUI_CLICK_1, + kUI_CLICK_2, + kUI_ACCEPT, kUI_BACK, kUI_ACTION_1, diff --git a/src/xrGame/UIDialogHolder.cpp b/src/xrGame/UIDialogHolder.cpp index cb46f9a4d27..52b17c49a5d 100644 --- a/src/xrGame/UIDialogHolder.cpp +++ b/src/xrGame/UIDialogHolder.cpp @@ -306,6 +306,7 @@ bool CDialogHolder::IR_UIOnKeyboardPress(int dik) return false; if (!TIR->IR_process()) return false; + // mouse click if (dik == MOUSE_1 || dik == MOUSE_2 || dik == MOUSE_3) { @@ -510,6 +511,22 @@ bool CDialogHolder::IR_UIOnControllerPress(int dik, float x, float y) if (TIR->OnControllerAction(dik, x, y, WINDOW_KEY_PRESSED)) return true; + // simulate mouse click + if (TIR->NeedCursor()) + { + int action = -1; + if (IsBinded(kUI_CLICK_1, dik, EKeyContext::UI)) + action = WINDOW_LBUTTON_DOWN; + else if (IsBinded(kUI_CLICK_2, dik, EKeyContext::UI)) + action = WINDOW_RBUTTON_DOWN; + if (action != -1) + { + Fvector2 cp = GetUICursor().GetCursorPosition(); + if (TIR->OnMouseAction(cp.x, cp.y, (EUIMessages)action)) + return true; + } + } + if (!TIR->StopAnyMove() && g_pGameLevel) { IGameObject* O = Level().CurrentEntity(); @@ -540,6 +557,22 @@ bool CDialogHolder::IR_UIOnControllerRelease(int dik, float x, float y) if (TIR->OnControllerAction(dik, x, y, WINDOW_KEY_RELEASED)) return true; + // simulate mouse click + if (TIR->NeedCursor()) + { + int action = -1; + if (IsBinded(kUI_CLICK_1, dik, EKeyContext::UI)) + action = WINDOW_LBUTTON_UP; + else if (IsBinded(kUI_CLICK_2, dik, EKeyContext::UI)) + action = WINDOW_RBUTTON_UP; + if (action != -1) + { + Fvector2 cp = GetUICursor().GetCursorPosition(); + if (TIR->OnMouseAction(cp.x, cp.y, (EUIMessages)action)) + return true; + } + } + if (!TIR->StopAnyMove() && g_pGameLevel) { IGameObject* O = Level().CurrentEntity();