Skip to content

Commit

Permalink
add right mouse button support to rt64
Browse files Browse the repository at this point in the history
  • Loading branch information
Rosalie241 committed May 28, 2024
1 parent 32c7bf2 commit f466f37
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
7 changes: 6 additions & 1 deletion Source/3rdParty/rt64/src/api/rt64_api_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ DLLEXPORT void CALL MouseMove(int x, int y)
event.motion.y = y;

if (RT64::API.app->presentQueue->inspector != nullptr) {
printf("MouseMove x = %i, y = %i\n", x,y);
//printf("MouseMove x = %i, y = %i\n", x,y);
ImGui_ImplSDL2_ProcessEvent(&event);
}
}
Expand All @@ -253,9 +253,14 @@ DLLEXPORT void CALL MouseButton(int left, int right)
if (RT64::API.app->presentQueue->inspector != nullptr) {
printf("MouseButton left = %i\n", left);
SDL_Event event;

event.type = left ? SDL_MOUSEBUTTONDOWN : SDL_MOUSEBUTTONUP;
event.button.button = SDL_BUTTON_LEFT;
ImGui_ImplSDL2_ProcessEvent(&event);

event.type = right ? SDL_MOUSEBUTTONDOWN : SDL_MOUSEBUTTONUP;
event.button.button = SDL_BUTTON_RIGHT;
ImGui_ImplSDL2_ProcessEvent(&event);
}
}

Expand Down
10 changes: 8 additions & 2 deletions Source/RMG/UserInterface/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1281,7 +1281,10 @@ void MainWindow::on_EventFilter_MouseButtonPressed(QMouseEvent *event)
return;
}

CoreSetMouseButton((event->button() == Qt::MouseButton::LeftButton ? 1 : 0), (event->button() == Qt::MouseButton::RightButton ? 1 : 0));
this->ui_LeftMouseButtonState = (event->button() == Qt::MouseButton::LeftButton ? 1 : this->ui_LeftMouseButtonState);
this->ui_RightMouseButtonState = (event->button() == Qt::MouseButton::RightButton ? 1 : this->ui_RightMouseButtonState);

CoreSetMouseButton(this->ui_LeftMouseButtonState, this->ui_RightMouseButtonState);
}

void MainWindow::on_EventFilter_MouseButtonReleased(QMouseEvent *event)
Expand All @@ -1292,7 +1295,10 @@ void MainWindow::on_EventFilter_MouseButtonReleased(QMouseEvent *event)
return;
}

CoreSetMouseButton((event->button() == Qt::MouseButton::LeftButton ? 0 : 1), (event->button() == Qt::MouseButton::RightButton ? 0 : 1));
this->ui_LeftMouseButtonState = (event->button() == Qt::MouseButton::LeftButton ? 0 : this->ui_LeftMouseButtonState);
this->ui_RightMouseButtonState = (event->button() == Qt::MouseButton::RightButton ? 0 : this->ui_RightMouseButtonState);

CoreSetMouseButton(this->ui_LeftMouseButtonState, this->ui_RightMouseButtonState);
}

void MainWindow::on_EventFilter_FileDropped(QDropEvent *event)
Expand Down
3 changes: 3 additions & 0 deletions Source/RMG/UserInterface/MainWindow.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,9 @@ class MainWindow : public QMainWindow, private Ui::MainWindow
int ui_LoadSaveStateSlotCounter = 0;
int ui_LoadSaveStateSlotTimerId = -1;

int ui_LeftMouseButtonState = 0;
int ui_RightMouseButtonState = 0;

QString ui_WindowTitle;

Dialog::LogDialog logDialog;
Expand Down

0 comments on commit f466f37

Please sign in to comment.