mirror of
https://github.com/Rosalie241/RMG.git
synced 2026-07-11 01:24:01 +02:00
compile fixes & add mouse patch to mupen64plus-core
This commit is contained in:
@@ -169,6 +169,7 @@ EXPORT m64p_error CALL CoreDoCommand(m64p_command Command, int ParamInt, void *P
|
||||
{
|
||||
m64p_error rval;
|
||||
int keysym, keymod;
|
||||
int x, y;
|
||||
|
||||
if (!l_CoreInit)
|
||||
return M64ERR_NOT_INIT;
|
||||
@@ -315,6 +316,13 @@ EXPORT m64p_error CALL CoreDoCommand(m64p_command Command, int ParamInt, void *P
|
||||
keymod = (ParamInt >> 16) & 0xffff;
|
||||
event_sdl_keyup(keysym, keymod);
|
||||
return M64ERR_SUCCESS;
|
||||
case M64CMD_SET_MOUSE_MOVE:
|
||||
if (!g_EmulatorRunning)
|
||||
return M64ERR_INVALID_STATE;
|
||||
x = ParamInt & 0xffff;
|
||||
y = (ParamInt >> 16) & 0xffff;
|
||||
event_mouse_move(x, y);
|
||||
return M64ERR_SUCCESS;
|
||||
case M64CMD_SET_FRAME_CALLBACK:
|
||||
*(void**)&g_FrameCallback = ParamPtr;
|
||||
return M64ERR_SUCCESS;
|
||||
|
||||
@@ -139,6 +139,7 @@ typedef struct {
|
||||
/*** Controller types ****/
|
||||
#define CONT_TYPE_STANDARD 0
|
||||
#define CONT_TYPE_VRU 1
|
||||
#define CONT_TYPE_MOUSE 2
|
||||
|
||||
typedef struct {
|
||||
int Present;
|
||||
@@ -264,6 +265,7 @@ typedef void (*ptr_InitiateControllers)(CONTROL_INFO ControlInfo);
|
||||
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_RenderCallback)(void);
|
||||
typedef void (*ptr_SendVRUWord)(uint16_t length, uint16_t *word, uint8_t lang);
|
||||
typedef void (*ptr_SetMicState)(int state);
|
||||
@@ -277,6 +279,7 @@ EXPORT void CALL InitiateControllers(CONTROL_INFO ControlInfo);
|
||||
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 RenderCallback(void);
|
||||
EXPORT void CALL SendVRUWord(uint16_t length, uint16_t *word, uint8_t lang);
|
||||
EXPORT void CALL SetMicState(int state);
|
||||
|
||||
+2
-1
@@ -171,7 +171,8 @@ typedef enum {
|
||||
M64CMD_PIF_OPEN,
|
||||
M64CMD_ROM_SET_SETTINGS,
|
||||
M64CMD_DISK_OPEN,
|
||||
M64CMD_DISK_CLOSE
|
||||
M64CMD_DISK_CLOSE,
|
||||
M64CMD_SET_MOUSE_MOVE
|
||||
} m64p_command;
|
||||
|
||||
typedef struct {
|
||||
|
||||
@@ -704,6 +704,14 @@ void event_sdl_keyup(int keysym, int keymod)
|
||||
}
|
||||
}
|
||||
|
||||
void event_mouse_move(int x, int y)
|
||||
{
|
||||
if (input.mouseMove != NULL)
|
||||
{
|
||||
input.mouseMove(x, y);
|
||||
}
|
||||
}
|
||||
|
||||
int event_gameshark_active(void)
|
||||
{
|
||||
return GamesharkActive;
|
||||
|
||||
@@ -26,6 +26,7 @@ extern int event_set_core_defaults(void);
|
||||
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 int event_gameshark_active(void);
|
||||
extern void event_set_gameshark(int active);
|
||||
|
||||
|
||||
+7
-6
@@ -1778,12 +1778,13 @@ m64p_error main_run(void)
|
||||
}
|
||||
/* otherwise let the core do the processing */
|
||||
else {
|
||||
/* select appropriate controller
|
||||
* FIXME: assume for now that only standard controller is compatible
|
||||
* Use the rom db to know if other peripherals are compatibles (VRU, mouse, train, ...)
|
||||
*/
|
||||
const struct game_controller_flavor* cont_flavor =
|
||||
&g_standard_controller_flavor;
|
||||
const struct game_controller_flavor* cont_flavor;
|
||||
|
||||
if (Controls[i].Type == CONT_TYPE_MOUSE) {
|
||||
cont_flavor = &g_mouse_controller_flavor;
|
||||
} else {
|
||||
cont_flavor = &g_standard_controller_flavor;
|
||||
}
|
||||
|
||||
joybus_devices[i] = &g_dev.controllers[i];
|
||||
ijoybus_devices[i] = &g_ijoybus_device_controller;
|
||||
|
||||
@@ -101,6 +101,7 @@ static const input_plugin_functions dummy_input = {
|
||||
dummyinput_RomOpen,
|
||||
dummyinput_SDL_KeyDown,
|
||||
dummyinput_SDL_KeyUp,
|
||||
NULL,
|
||||
dummyinput_RenderCallback
|
||||
};
|
||||
|
||||
@@ -403,6 +404,11 @@ 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"))
|
||||
{
|
||||
DebugMessage(M64MSG_WARNING, "Input plugin does not contain mouse support.");
|
||||
}
|
||||
|
||||
/* check the version info */
|
||||
(*input.getVersion)(&PluginType, &PluginVersion, &APIVersion, NULL, NULL);
|
||||
if (PluginType != M64PLUGIN_INPUT || (APIVersion & 0xffff0000) != (INPUT_API_VERSION & 0xffff0000) || APIVersion < 0x020100)
|
||||
|
||||
@@ -100,6 +100,7 @@ typedef struct _input_plugin_functions
|
||||
ptr_RomOpen romOpen;
|
||||
ptr_SDL_KeyDown keyDown;
|
||||
ptr_SDL_KeyUp keyUp;
|
||||
ptr_MouseMove mouseMove;
|
||||
ptr_RenderCallback renderCallback;
|
||||
ptr_SendVRUWord sendVRUWord;
|
||||
ptr_SetMicState setMicState;
|
||||
|
||||
@@ -284,16 +284,6 @@ bool apply_plugin_settings(std::string pluginSettings[4])
|
||||
return false;
|
||||
}
|
||||
|
||||
// register mouse callback for input plugin,
|
||||
// if it exists
|
||||
if (pluginType == CorePluginType::Input)
|
||||
{
|
||||
if (plugin->SetResetMousePositionCallback != nullptr)
|
||||
{
|
||||
plugin->SetResetMousePositionCallback(ResetMousePositionCallback);
|
||||
}
|
||||
}
|
||||
|
||||
l_PluginFiles[i] = settingValue;
|
||||
|
||||
CoreAddCallbackMessage(CoreDebugMessageType::Info,
|
||||
|
||||
@@ -42,6 +42,7 @@ EXPORT m64p_error CALL PluginConfig2(int);
|
||||
typedef int (*ptr_PluginConfig2HasRomConfig)(void);
|
||||
#if defined(M64P_PLUGIN_PROTOTYPES) || defined(M64P_CORE_PROTOTYPES)
|
||||
EXPORT int CALL PluginConfig2HasRomConfig(void);
|
||||
#endif
|
||||
|
||||
/* SetResetMousePositionCallback()
|
||||
*
|
||||
@@ -59,4 +60,4 @@ EXPORT void CALL SetResetMousePositionCallback(ptr_ResetMousePositionCallback);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // M64P_CUSTOM_H
|
||||
#endif // M64P_CUSTOM_H
|
||||
@@ -696,10 +696,6 @@ void ControllerWidget::on_inputTypeComboBox_currentIndexChanged(int value)
|
||||
{
|
||||
groupBox_4,
|
||||
deadZoneGroupBox,
|
||||
groupBox,
|
||||
groupBox_2,
|
||||
groupBox_3,
|
||||
groupBox_6,
|
||||
};
|
||||
|
||||
if (value == 1)
|
||||
@@ -1175,11 +1171,11 @@ void ControllerWidget::on_MainDialog_SdlEvent(SDL_Event* event)
|
||||
{
|
||||
if (!sdlHatCentered && sdlHatDirection == direction)
|
||||
{
|
||||
this->controllerImageWidget->SetButtonState(button.button, true);
|
||||
this->controllerImageWidget->SetControllerButtonState(button.button, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
this->controllerImageWidget->SetButtonState(button.button, false);
|
||||
this->controllerImageWidget->SetControllerButtonState(button.button, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1846,16 +1842,16 @@ void ControllerWidget::SaveSettings(QString section)
|
||||
|
||||
this->GetCurrentInputDevice(deviceName, deviceNum, true);
|
||||
|
||||
CoreSettingsSetValue(SettingsID::Input_PluggedIn, section, this->IsPluggedIn());
|
||||
CoreSettingsSetValue(SettingsID::Input_InputType, section, this->inputTypeComboBox->currentIndex());
|
||||
CoreSettingsSetValue(SettingsID::Input_DeviceName, section, deviceName.toStdString());
|
||||
CoreSettingsSetValue(SettingsID::Input_DeviceNum, section, deviceNum);
|
||||
CoreSettingsSetValue(SettingsID::Input_Deadzone, section, this->deadZoneSlider->value());
|
||||
CoreSettingsSetValue(SettingsID::Input_Pak, section, this->optionsDialogSettings.ControllerPak);
|
||||
CoreSettingsSetValue(SettingsID::Input_GameboyRom, section, this->optionsDialogSettings.GameboyRom);
|
||||
CoreSettingsSetValue(SettingsID::Input_GameboySave, section, this->optionsDialogSettings.GameboySave);
|
||||
CoreSettingsSetValue(SettingsID::Input_RemoveDuplicateMappings, section, this->optionsDialogSettings.RemoveDuplicateMappings);
|
||||
CoreSettingsSetValue(SettingsID::Input_InvertAxis, section, this->optionsDialogSettings.InvertAxis);
|
||||
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());
|
||||
CoreSettingsSetValue(SettingsID::Input_Pak, sectionStr, this->optionsDialogSettings.ControllerPak);
|
||||
CoreSettingsSetValue(SettingsID::Input_GameboyRom, sectionStr, this->optionsDialogSettings.GameboyRom);
|
||||
CoreSettingsSetValue(SettingsID::Input_GameboySave, sectionStr, this->optionsDialogSettings.GameboySave);
|
||||
CoreSettingsSetValue(SettingsID::Input_RemoveDuplicateMappings, sectionStr, this->optionsDialogSettings.RemoveDuplicateMappings);
|
||||
//CoreSettingsSetValue(SettingsID::Input_InvertAxis, sectionStr, this->optionsDialogSettings.InvertAxis);
|
||||
CoreSettingsSetValue(SettingsID::Input_FilterEventsForButtons, sectionStr, this->optionsDialogSettings.FilterEventsForButtons);
|
||||
CoreSettingsSetValue(SettingsID::Input_FilterEventsForAxis, sectionStr, this->optionsDialogSettings.FilterEventsForAxis);
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@ enum class N64ControllerButton
|
||||
|
||||
enum class InputDeviceType
|
||||
{
|
||||
Mouse = -5,
|
||||
EmulateVRU = -4,
|
||||
None = -3,
|
||||
Automatic = -2,
|
||||
@@ -46,12 +47,6 @@ enum class N64MouseButton
|
||||
Invalid
|
||||
};
|
||||
|
||||
enum class InputDeviceType
|
||||
{
|
||||
Controller = 0,
|
||||
Mouse
|
||||
};
|
||||
|
||||
enum class InputType
|
||||
{
|
||||
Keyboard = -1,
|
||||
|
||||
+28
-27
@@ -69,7 +69,7 @@ struct InputProfile
|
||||
int DeadzoneValue = 0;
|
||||
int SensitivityValue = 100;
|
||||
|
||||
InputDeviceType DeviceType = InputDeviceType::Controller;
|
||||
InputDeviceType DeviceType = InputDeviceType::Mouse;
|
||||
|
||||
N64ControllerPak ControllerPak = N64ControllerPak::None;
|
||||
|
||||
@@ -449,7 +449,7 @@ static void apply_controller_profiles(void)
|
||||
l_ControlInfo.Controls[i].Type = CONT_TYPE_STANDARD;
|
||||
}
|
||||
|
||||
l_ControlInfo.Controls[i].Type = (profile->DeviceType == InputDeviceType::Controller ? CONT_TYPE_STANDARD : CONT_TYPE_MOUSE);
|
||||
l_ControlInfo.Controls[i].Type = (profile->DeviceType != InputDeviceType::Mouse ? CONT_TYPE_STANDARD : CONT_TYPE_MOUSE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1285,36 +1285,37 @@ EXPORT void CALL GetKeys(int Control, BUTTONS* Keys)
|
||||
if (Control == 0)
|
||||
{
|
||||
// mouse
|
||||
if (profile->DeviceType == InputDeviceType::Mouse)
|
||||
{ // n64 mouse
|
||||
l_MouseMutex.lock();
|
||||
if (profile->DeviceType == InputDeviceType::Mouse)
|
||||
{ // n64 mouse
|
||||
l_MouseMutex.lock();
|
||||
|
||||
// set left & right button state
|
||||
Keys->A_BUTTON = l_MouseButtonState[0];
|
||||
Keys->B_BUTTON = l_MouseButtonState[1];
|
||||
// set left & right button state
|
||||
Keys->A_BUTTON = l_MouseButtonState[0];
|
||||
Keys->B_BUTTON = l_MouseButtonState[1];
|
||||
|
||||
if (!l_MouseMovements.empty())
|
||||
{
|
||||
// calculate how much the mouse has moved
|
||||
const int x = l_MouseMovements.front().x - l_MouseMovements.back().x;
|
||||
const int y = l_MouseMovements.front().y - l_MouseMovements.back().y;
|
||||
if (!l_MouseMovements.empty())
|
||||
{
|
||||
// calculate how much the mouse has moved
|
||||
const int x = l_MouseMovements.front().x - l_MouseMovements.back().x;
|
||||
const int y = l_MouseMovements.front().y - l_MouseMovements.back().y;
|
||||
|
||||
// set axis state
|
||||
Keys->X_AXIS = -x;
|
||||
Keys->Y_AXIS = y;
|
||||
// set axis state
|
||||
Keys->X_AXIS = -x;
|
||||
Keys->Y_AXIS = y;
|
||||
|
||||
l_MouseMovements.clear();
|
||||
l_MouseMovements.clear();
|
||||
}
|
||||
|
||||
l_MouseMutex.unlock();
|
||||
|
||||
// request front-end to reset mouse position
|
||||
if (l_ResetMousPositionCallback != nullptr)
|
||||
{
|
||||
l_ResetMousPositionCallback();
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
l_MouseMutex.unlock();
|
||||
|
||||
// request front-end to reset mouse position
|
||||
if (l_ResetMousPositionCallback != nullptr)
|
||||
{
|
||||
l_ResetMousPositionCallback();
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
Keys->A_BUTTON = get_button_state(profile, &profile->Button_A);
|
||||
|
||||
@@ -112,13 +112,3 @@ void CoreCallbacks::coreStateCallback(CoreStateCallbackType type, int value)
|
||||
|
||||
emit l_CoreCallbacks->OnCoreStateCallback(type, value);
|
||||
}
|
||||
|
||||
void CoreCallbacks::resetMousePositionCallback(void)
|
||||
{
|
||||
if (l_CoreCallbacks == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
emit l_CoreCallbacks->OnResetMousePositionCallback();
|
||||
}
|
||||
|
||||
@@ -51,8 +51,6 @@ signals:
|
||||
void OnCoreDebugCallback(QList<CoreCallbackMessage> callbackMessages);
|
||||
void OnCoreStateCallback(CoreStateCallbackType type, int value);
|
||||
|
||||
static void resetMousePositionCallback(void);
|
||||
|
||||
signals:
|
||||
void OnCoreDebugCallback(CoreDebugMessageType type, QString context, QString message);
|
||||
void OnResetMousePositionCallback(void);
|
||||
|
||||
@@ -90,7 +90,7 @@ bool MainWindow::Init(QApplication* app, bool showUI, bool launchROM)
|
||||
this->coreCallBacks = new CoreCallbacks(this);
|
||||
|
||||
// connect signals early due to pending debug callbacks
|
||||
connect(coreCallBacks, &CoreCallbacks::OnCoreDebugCallback, this, &MainWindow::on_Core_DebugCallback);
|
||||
//connect(coreCallBacks, &CoreCallbacks::OnCoreDebugCallback, this, &MainWindow::on_Core_DebugCallback);
|
||||
connect(coreCallBacks, &CoreCallbacks::OnCoreStateCallback, this, &MainWindow::on_Core_StateCallback);
|
||||
connect(app, &QGuiApplication::applicationStateChanged, this, &MainWindow::on_QGuiApplication_applicationStateChanged);
|
||||
|
||||
@@ -105,12 +105,6 @@ bool MainWindow::Init(QApplication* app, bool showUI, bool launchROM)
|
||||
{
|
||||
this->addActions();
|
||||
}
|
||||
|
||||
connect(coreCallBacks, &CoreCallbacks::OnCoreDebugCallback, this, &MainWindow::on_Core_DebugCallback);
|
||||
connect(coreCallBacks, &CoreCallbacks::OnCoreDebugCallback, &this->logDialog, &Dialog::LogDialog::AddLogLine);
|
||||
connect(coreCallBacks, &CoreCallbacks::OnResetMousePositionCallback, this, &MainWindow::on_Core_ResetMousPositionCallback, Qt::BlockingQueuedConnection);
|
||||
connect(app, &QGuiApplication::applicationStateChanged, this, &MainWindow::on_QGuiApplication_applicationStateChanged);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user