Skip to content

Commit

Permalink
more fixes....
Browse files Browse the repository at this point in the history
  • Loading branch information
Rosalie241 committed Jun 25, 2024
1 parent ef28d45 commit cc701cc
Show file tree
Hide file tree
Showing 15 changed files with 84 additions and 78 deletions.
7 changes: 7 additions & 0 deletions Source/3rdParty/mupen64plus-core/src/api/frontend.c
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,13 @@ EXPORT m64p_error CALL CoreDoCommand(m64p_command Command, int ParamInt, void *P
y = (ParamInt >> 16) & 0xffff;
event_mouse_move(x, y);
return M64ERR_SUCCESS;
case M64CMD_SET_MOUSE_BUTTON:
if (!g_EmulatorRunning)
return M64ERR_INVALID_STATE;
x = ParamInt & 0xffff;
y = (ParamInt >> 16) & 0xffff;
event_mouse_button(x, y);
return M64ERR_SUCCESS;
case M64CMD_SET_FRAME_CALLBACK:
*(void**)&g_FrameCallback = ParamPtr;
return M64ERR_SUCCESS;
Expand Down
2 changes: 2 additions & 0 deletions Source/3rdParty/mupen64plus-core/src/api/m64p_plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@ typedef void (*ptr_ReadController)(int Control, unsigned char *Command);
typedef void (*ptr_SDL_KeyDown)(int keymod, int keysym);
typedef void (*ptr_SDL_KeyUp)(int keymod, int keysym);
typedef void (*ptr_MouseMove)(int x, int y);
typedef void (*ptr_MouseButton)(int left, int right);
typedef void (*ptr_RenderCallback)(void);
typedef void (*ptr_SendVRUWord)(uint16_t length, uint16_t *word, uint8_t lang);
typedef void (*ptr_SetMicState)(int state);
Expand All @@ -280,6 +281,7 @@ EXPORT void CALL ReadController(int Control, unsigned char *Command);
EXPORT void CALL SDL_KeyDown(int keymod, int keysym);
EXPORT void CALL SDL_KeyUp(int keymod, int keysym);
EXPORT void CALL MouseMove(int x, int y);
EXPORT void CALL MouseButton(int left, int right);
EXPORT void CALL RenderCallback(void);
EXPORT void CALL SendVRUWord(uint16_t length, uint16_t *word, uint8_t lang);
EXPORT void CALL SetMicState(int state);
Expand Down
3 changes: 2 additions & 1 deletion Source/3rdParty/mupen64plus-core/src/api/m64p_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,8 @@ typedef enum {
M64CMD_ROM_SET_SETTINGS,
M64CMD_DISK_OPEN,
M64CMD_DISK_CLOSE,
M64CMD_SET_MOUSE_MOVE
M64CMD_SET_MOUSE_MOVE,
M64CMD_SET_MOUSE_BUTTON
} m64p_command;

typedef struct {
Expand Down
9 changes: 9 additions & 0 deletions Source/3rdParty/mupen64plus-core/src/main/eventloop.c
Original file line number Diff line number Diff line change
Expand Up @@ -712,6 +712,15 @@ void event_mouse_move(int x, int y)
}
}

void event_mouse_button(int left, int right)
{
if (input.mouseButton != NULL)
{
input.mouseButton(left, right);
}
}


int event_gameshark_active(void)
{
return GamesharkActive;
Expand Down
1 change: 1 addition & 0 deletions Source/3rdParty/mupen64plus-core/src/main/eventloop.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ extern void event_initialize(void);
extern void event_sdl_keydown(int keysym, int keymod);
extern void event_sdl_keyup(int keysym, int keymod);
extern void event_mouse_move(int x, int y);
extern void event_mouse_button(int left, int right);
extern int event_gameshark_active(void);
extern void event_set_gameshark(int active);

Expand Down
4 changes: 3 additions & 1 deletion Source/3rdParty/mupen64plus-core/src/plugin/plugin.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ static const input_plugin_functions dummy_input = {
dummyinput_SDL_KeyDown,
dummyinput_SDL_KeyUp,
NULL,
NULL,
dummyinput_RenderCallback
};

Expand Down Expand Up @@ -404,7 +405,8 @@ static m64p_error plugin_connect_input(m64p_dynlib_handle plugin_handle)
DebugMessage(M64MSG_WARNING, "Input plugin does not contain VRU support.");
}

if (!GET_FUNC(ptr_MouseMove, input.mouseMove, "MouseMove"))
if (!GET_FUNC(ptr_MouseMove, input.mouseMove, "MouseMove") ||
!GET_FUNC(ptr_MouseMove, input.mouseButton, "MouseButton"))
{
DebugMessage(M64MSG_WARNING, "Input plugin does not contain mouse support.");
}
Expand Down
1 change: 1 addition & 0 deletions Source/3rdParty/mupen64plus-core/src/plugin/plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ typedef struct _input_plugin_functions
ptr_SDL_KeyDown keyDown;
ptr_SDL_KeyUp keyUp;
ptr_MouseMove mouseMove;
ptr_MouseButton mouseButton;
ptr_RenderCallback renderCallback;
ptr_SendVRUWord sendVRUWord;
ptr_SetMicState setMicState;
Expand Down
6 changes: 3 additions & 3 deletions Source/RMG-Core/m64p/api/m64p_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,10 @@ typedef enum {
M64CMD_NETPLAY_CLOSE,
M64CMD_PIF_OPEN,
M64CMD_ROM_SET_SETTINGS,
M64CMD_SET_MOUSE_MOVE,
M64CMD_SET_MOUSE_BUTTON,
M64CMD_DISK_OPEN,
M64CMD_DISK_CLOSE
M64CMD_DISK_CLOSE,
M64CMD_SET_MOUSE_MOVE,
M64CMD_SET_MOUSE_BUTTON
} m64p_command;

typedef struct {
Expand Down
8 changes: 7 additions & 1 deletion Source/RMG-Input/UserInterface/MainDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ MainDialog::MainDialog(QWidget* parent, Thread::SDLThread* sdlThread, bool romCo
controllerWidget->AddInputDevice("Voice Recognition Unit", (int)InputDeviceType::EmulateVRU);
}
#endif // VRU
// TODO: shouldn't this be specific to 1 port??
controllerWidget->AddInputDevice("Mouse", (int)InputDeviceType::Mouse);

controllerWidget->AddInputDevice("None", (int)InputDeviceType::None);
controllerWidget->AddInputDevice("Automatic", (int)InputDeviceType::Automatic);
controllerWidget->AddInputDevice("Keyboard", (int)InputDeviceType::Keyboard);
Expand Down Expand Up @@ -114,8 +117,9 @@ void MainDialog::openInputDevice(QString deviceName, int deviceNum)
Widget::ControllerWidget* controllerWidget;
controllerWidget = this->controllerWidgets.at(this->tabWidget->currentIndex());

// we don't need to open a keyboard or VRU
// we don't need to open a mouse, keyboard or VRU
if (deviceNum == (int)InputDeviceType::None ||
deviceNum == (int)InputDeviceType::Mouse ||
deviceNum == (int)InputDeviceType::Keyboard ||
deviceNum == (int)InputDeviceType::EmulateVRU)
{
Expand Down Expand Up @@ -240,6 +244,7 @@ void MainDialog::on_ControllerWidget_CurrentInputDeviceChanged(ControllerWidget*

// only open device when needed
if (deviceNum != (int)InputDeviceType::None &&
deviceNum != (int)InputDeviceType::Mouse &&
deviceNum != (int)InputDeviceType::Keyboard &&
deviceNum != (int)InputDeviceType::EmulateVRU)
{
Expand Down Expand Up @@ -306,6 +311,7 @@ void MainDialog::on_tabWidget_currentChanged(int index)

// only open device when needed
if (deviceNum != (int)InputDeviceType::None &&
deviceNum != (int)InputDeviceType::Mouse &&
deviceNum != (int)InputDeviceType::Keyboard &&
deviceNum != (int)InputDeviceType::EmulateVRU)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ void ControllerImageWidget::SetMouseMode(bool value)
if (this->isMouseMode != value)
{
this->isMouseMode = value;
this->needImageUpdate = true;
}
}

Expand Down
8 changes: 2 additions & 6 deletions Source/RMG-Input/UserInterface/Widget/ControllerWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -726,6 +726,7 @@ void ControllerWidget::on_inputDeviceComboBox_currentIndexChanged(int value)
int deviceNum = this->inputDeviceComboBox->itemData(value).toInt();

this->ClearControllerImage();
this->controllerImageWidget->SetMouseMode((deviceNum == (int)InputDeviceType::Mouse));

if (this->isCurrentDeviceNotFound())
{
Expand Down Expand Up @@ -1443,7 +1444,7 @@ void ControllerWidget::on_MainDialog_SdlEvent(SDL_Event* event)
case SDL_MOUSEBUTTONDOWN:
case SDL_MOUSEBUTTONUP:
{ // mouse button press
if (this->inputTypeComboBox->currentIndex() != 1)
if (this->inputDeviceComboBox->currentIndex() != 0)
{ // no mouse
return;
}
Expand Down Expand Up @@ -1643,7 +1644,6 @@ void ControllerWidget::LoadSettings(QString sectionQString, bool loadUserProfile
}

this->deadZoneSlider->setValue(CoreSettingsGetIntValue(SettingsID::Input_Deadzone, section));
this->inputTypeComboBox->setCurrentIndex(CoreSettingsGetIntValue(SettingsID::Input_InputType, section));
this->optionsDialogSettings.RemoveDuplicateMappings = CoreSettingsGetBoolValue(SettingsID::Input_RemoveDuplicateMappings, section);
this->optionsDialogSettings.ControllerPak = CoreSettingsGetIntValue(SettingsID::Input_Pak, section);
this->optionsDialogSettings.GameboyRom = CoreSettingsGetStringValue(SettingsID::Input_GameboyRom, section);
Expand Down Expand Up @@ -1699,9 +1699,6 @@ void ControllerWidget::LoadSettings(QString sectionQString, bool loadUserProfile

// force refresh some UI elements
this->CheckInputDeviceSettings(sectionQString);

// TODO: is this correct?
this->on_inputTypeComboBox_currentIndexChanged(this->inputTypeComboBox->currentIndex());
this->on_deadZoneSlider_valueChanged(this->deadZoneSlider->value());
this->setPluggedIn(this->IsPluggedIn());
}
Expand Down Expand Up @@ -1843,7 +1840,6 @@ void ControllerWidget::SaveSettings(QString section)
this->GetCurrentInputDevice(deviceName, deviceNum, true);

CoreSettingsSetValue(SettingsID::Input_PluggedIn, sectionStr, this->IsPluggedIn());
CoreSettingsSetValue(SettingsID::Input_InputType, sectionStr, this->inputTypeComboBox->currentIndex());
CoreSettingsSetValue(SettingsID::Input_DeviceName, sectionStr, deviceName.toStdString());
CoreSettingsSetValue(SettingsID::Input_DeviceNum, sectionStr, deviceNum);
CoreSettingsSetValue(SettingsID::Input_Deadzone, sectionStr, this->deadZoneSlider->value());
Expand Down
63 changes: 20 additions & 43 deletions Source/RMG-Input/UserInterface/Widget/ControllerWidget.ui
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
</sizepolicy>
</property>
<property name="sizeAdjustPolicy">
<enum>QComboBox::AdjustToContents</enum>
<enum>QComboBox::SizeAdjustPolicy::AdjustToContents</enum>
</property>
</widget>
</item>
Expand Down Expand Up @@ -73,7 +73,7 @@
<item>
<spacer name="horizontalSpacer_8">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
Expand All @@ -83,29 +83,6 @@
</property>
</spacer>
</item>
<item>
<widget class="QGroupBox" name="groupBox_7">
<property name="title">
<string>Device Type</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<widget class="QComboBox" name="inputTypeComboBox">
<item>
<property name="text">
<string>Controller</string>
</property>
</item>
<item>
<property name="text">
<string>Mouse</string>
</property>
</item>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_4">
<property name="sizePolicy">
Expand All @@ -127,7 +104,7 @@
</sizepolicy>
</property>
<property name="sizeAdjustPolicy">
<enum>QComboBox::AdjustToContents</enum>
<enum>QComboBox::SizeAdjustPolicy::AdjustToContents</enum>
</property>
</widget>
</item>
Expand All @@ -150,7 +127,7 @@
<item>
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
Expand Down Expand Up @@ -181,10 +158,10 @@
<number>100</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="tickPosition">
<enum>QSlider::TicksBelow</enum>
<enum>QSlider::TickPosition::TicksBelow</enum>
</property>
<property name="tickInterval">
<number>10</number>
Expand All @@ -201,7 +178,7 @@
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
Expand All @@ -216,7 +193,7 @@
<item>
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
<enum>Qt::Orientation::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
Expand Down Expand Up @@ -648,10 +625,10 @@
<number>100</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="tickPosition">
<enum>QSlider::TicksBelow</enum>
<enum>QSlider::TickPosition::TicksBelow</enum>
</property>
<property name="tickInterval">
<number>15</number>
Expand All @@ -664,7 +641,7 @@
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
<enum>Qt::Orientation::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
Expand All @@ -686,7 +663,7 @@
<item>
<spacer name="horizontalSpacer_5">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
Expand Down Expand Up @@ -729,7 +706,7 @@
<item>
<spacer name="horizontalSpacer_7">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
Expand Down Expand Up @@ -776,7 +753,7 @@
<item>
<spacer name="horizontalSpacer_6">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
Expand Down Expand Up @@ -809,7 +786,7 @@
<item>
<spacer name="horizontalSpacer_10">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
Expand Down Expand Up @@ -857,7 +834,7 @@
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
Expand Down Expand Up @@ -905,7 +882,7 @@
<item>
<spacer name="horizontalSpacer_11">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
Expand All @@ -924,7 +901,7 @@
<item>
<spacer name="verticalSpacer_4">
<property name="orientation">
<enum>Qt::Vertical</enum>
<enum>Qt::Orientation::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
Expand Down Expand Up @@ -1253,7 +1230,7 @@
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
<enum>Qt::Orientation::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
Expand Down Expand Up @@ -1289,7 +1266,7 @@
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
Expand Down
Loading

0 comments on commit cc701cc

Please sign in to comment.