Improve Input Mapping GUI

This commit is contained in:
Bruno Herbelin
2025-03-30 13:12:24 +02:00
parent 0af197fa98
commit bbcc5ee5d1

View File

@@ -106,7 +106,7 @@ Target InputMappingWindow::ComboSelectTarget(const Target &current)
selected = *sit;
}
}
for (size_t b = 0; b < Mixer::manager().session()->numBatch(); ++b){
for (size_t b = 0; b < ses->numBatch(); ++b){
label = std::string("Batch #") + std::to_string(b);
if (ImGui::Selectable( label.c_str() )) {
selected = b;
@@ -705,28 +705,6 @@ void InputMappingWindow::Render()
if ( ImGui::MenuItem( ICON_FA_BACKSPACE " Clear all" ) )
S->clearInputCallbacks();
// Gamepad selection
ImGui::Separator();
float combo_width = ImGui::GetTextLineHeightWithSpacing() * 7.f;
ImGui::SetNextItemWidth(combo_width);
char text_buf[256];
if ( glfwJoystickPresent( Settings::application.gamepad_id ) )
ImFormatString(text_buf, IM_ARRAYSIZE(text_buf), "%s", glfwGetJoystickName(Settings::application.gamepad_id));
else
ImFormatString(text_buf, IM_ARRAYSIZE(text_buf), "Joystick %d", Settings::application.gamepad_id);
if (ImGui::BeginCombo("Gamepad", text_buf, ImGuiComboFlags_None)) {
for( int g = GLFW_JOYSTICK_1; g < GLFW_JOYSTICK_LAST; ++g) {
if ( glfwJoystickPresent( g ) ) {
ImFormatString(text_buf, IM_ARRAYSIZE(text_buf), "%s", glfwGetJoystickName(g));
if (ImGui::Selectable(text_buf, Settings::application.gamepad_id == g) ) {
Settings::application.gamepad_id = g;
}
}
}
ImGui::EndCombo();
}
// output manager menu
ImGui::Separator();
bool pinned = Settings::application.widget.inputs_view == Settings::application.current_view;
@@ -1321,9 +1299,33 @@ void InputMappingWindow::Render()
{
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(2.f, g.Style.ItemSpacing.y * 2.f) );
ImGui::BeginChild("InputsMappingInterfacePanel", ImVec2(0, 0), false);
float w = ImGui::GetWindowWidth() *0.25f;
// selection of device for joystick mode
if ( Settings::application.mapping.mode == 3 ){
char text_buf[512];
if ( glfwJoystickPresent( Settings::application.gamepad_id ) )
ImFormatString(text_buf, IM_ARRAYSIZE(text_buf), "%s", glfwGetJoystickName(Settings::application.gamepad_id));
else
ImFormatString(text_buf, IM_ARRAYSIZE(text_buf), "Joystick %d", Settings::application.gamepad_id);
ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN);
if (ImGui::BeginCombo("Device", text_buf, ImGuiComboFlags_None)) {
for( int g = GLFW_JOYSTICK_1; g < GLFW_JOYSTICK_LAST; ++g) {
if ( glfwJoystickPresent( g ) ) {
ImFormatString(text_buf, IM_ARRAYSIZE(text_buf), "%s", glfwGetJoystickName(g));
if (ImGui::Selectable(text_buf, Settings::application.gamepad_id == g) ) {
Settings::application.gamepad_id = g;
}
}
}
ImGui::EndCombo();
}
}
// adding actions is possible only if there are sources in the session
if (!Mixer::manager().session()->empty()) {
///
/// list of input callbacks for the current input
///
@@ -1398,6 +1400,8 @@ void InputMappingWindow::Render()
///
/// Add a new interface
///
///
static bool temp_new_input = false;
static Target temp_new_target;
static uint temp_new_callback = 0;
@@ -1448,6 +1452,10 @@ void InputMappingWindow::Render()
}
}
}
}
else {
ImGui::Text("No source to perform an action.");
}
///
/// Sync info lower right corner