Renamed GunListener to ScreenPositionListener

This commit is contained in:
LapisRegia 2024-02-17 17:34:45 +08:00
parent 0d1a080394
commit 669cd24960
19 changed files with 63 additions and 63 deletions

View file

@ -249,7 +249,7 @@ set(COMMON_SRC_FILES
FrameDump.h FrameDump.h
FrameLimiter.cpp FrameLimiter.cpp
FrameLimiter.h FrameLimiter.h
GunListener.h ScreenPositionListener.h
InputConfig.cpp InputConfig.cpp
InputConfig.h InputConfig.h
GenericMipsExecutor.h GenericMipsExecutor.h

View file

@ -1,9 +0,0 @@
#pragma once
class CGunListener
{
public:
virtual ~CGunListener() = default;
virtual void SetGunPosition(float, float) = 0;
virtual void ReleaseTouchPosition() = 0;
};

View file

@ -136,7 +136,7 @@ bool CPS2VM::HasGunListener() const
return m_gunListener != nullptr; return m_gunListener != nullptr;
} }
void CPS2VM::SetGunListener(CGunListener* listener) void CPS2VM::SetGunListener(CScreenPositionListener* listener)
{ {
m_gunListener = listener; m_gunListener = listener;
} }
@ -145,7 +145,7 @@ void CPS2VM::ReportGunPosition(float x, float y)
{ {
if(m_gunListener) if(m_gunListener)
{ {
m_gunListener->SetGunPosition(x, y); m_gunListener->SetScreenPosition(x, y);
} }
} }
@ -154,7 +154,7 @@ bool CPS2VM::HasTouchListener() const
return m_touchListener != nullptr; return m_touchListener != nullptr;
} }
void CPS2VM::SetTouchListener(CGunListener* listener) void CPS2VM::SetTouchListener(CScreenPositionListener* listener)
{ {
m_touchListener = listener; m_touchListener = listener;
} }
@ -163,15 +163,15 @@ void CPS2VM::ReportTouchPosition(float x, float y)
{ {
if(m_touchListener) if(m_touchListener)
{ {
m_touchListener->SetGunPosition(x, y); m_touchListener->SetScreenPosition(x, y);
} }
} }
void CPS2VM::ReleaseTouchPosition() void CPS2VM::ReleaseScreenPosition()
{ {
if(m_touchListener) if(m_touchListener)
{ {
m_touchListener->ReleaseTouchPosition(); m_touchListener->ReleaseScreenPosition();
} }
} }

View file

@ -7,7 +7,7 @@
#include "MIPS.h" #include "MIPS.h"
#include "MailBox.h" #include "MailBox.h"
#include "PadHandler.h" #include "PadHandler.h"
#include "GunListener.h" #include "ScreenPositionListener.h"
#include "OpticalMedia.h" #include "OpticalMedia.h"
#include "VirtualMachine.h" #include "VirtualMachine.h"
#include "ee/Ee_SubSystem.h" #include "ee/Ee_SubSystem.h"
@ -87,12 +87,12 @@ public:
void ReportGunPosition(float, float); void ReportGunPosition(float, float);
bool HasGunListener() const; bool HasGunListener() const;
void SetGunListener(CGunListener*); void SetGunListener(CScreenPositionListener*);
void ReportTouchPosition(float, float); void ReportTouchPosition(float, float);
bool HasTouchListener() const; bool HasTouchListener() const;
void SetTouchListener(CGunListener*); void SetTouchListener(CScreenPositionListener*);
void ReleaseTouchPosition(); void ReleaseScreenPosition();
OpticalMediaPtr m_cdrom0; OpticalMediaPtr m_cdrom0;
CPadHandler* m_pad = nullptr; CPadHandler* m_pad = nullptr;
@ -193,8 +193,8 @@ private:
int m_spuBlockCount = 0; int m_spuBlockCount = 0;
CSoundHandler* m_soundHandler = nullptr; CSoundHandler* m_soundHandler = nullptr;
CGunListener* m_gunListener = nullptr; CScreenPositionListener* m_gunListener = nullptr;
CGunListener* m_touchListener = nullptr; CScreenPositionListener* m_touchListener = nullptr;
CProfiler::ZoneHandle m_eeProfilerZone = 0; CProfiler::ZoneHandle m_eeProfilerZone = 0;
CProfiler::ZoneHandle m_iopProfilerZone = 0; CProfiler::ZoneHandle m_iopProfilerZone = 0;

View file

@ -0,0 +1,9 @@
#pragma once
class CScreenPositionListener
{
public:
virtual ~CScreenPositionListener() = default;
virtual void SetScreenPosition(float, float) = 0;
virtual void ReleaseScreenPosition() = 0;
};

View file

@ -403,10 +403,10 @@ void CSys246::ProcessJvsPacket(const uint8* input, uint8* output)
if(m_jvsMode == JVS_MODE::LIGHTGUN) if(m_jvsMode == JVS_MODE::LIGHTGUN)
{ {
assert(channel == 2); assert(channel == 2);
(*output++) = static_cast<uint8>(m_jvsGunPosX >> 8); //Pos X MSB (*output++) = static_cast<uint8>(m_jvsScreenPosX >> 8); //Pos X MSB
(*output++) = static_cast<uint8>(m_jvsGunPosX); //Pos X LSB (*output++) = static_cast<uint8>(m_jvsScreenPosX); //Pos X LSB
(*output++) = static_cast<uint8>(m_jvsGunPosY >> 8); //Pos Y MSB (*output++) = static_cast<uint8>(m_jvsScreenPosY >> 8); //Pos Y MSB
(*output++) = static_cast<uint8>(m_jvsGunPosY); //Pos Y LSB (*output++) = static_cast<uint8>(m_jvsScreenPosY); //Pos Y LSB
} }
else if(m_jvsMode == JVS_MODE::DRUM) else if(m_jvsMode == JVS_MODE::DRUM)
{ {
@ -443,10 +443,10 @@ void CSys246::ProcessJvsPacket(const uint8* input, uint8* output)
(*output++) = 0x01; //Command success (*output++) = 0x01; //Command success
(*output++) = static_cast<uint8>(m_jvsGunPosX >> 8); //Pos X MSB (*output++) = static_cast<uint8>(m_jvsScreenPosX >> 8); //Pos X MSB
(*output++) = static_cast<uint8>(m_jvsGunPosX); //Pos X LSB (*output++) = static_cast<uint8>(m_jvsScreenPosX); //Pos X LSB
(*output++) = static_cast<uint8>(m_jvsGunPosY >> 8); //Pos Y MSB (*output++) = static_cast<uint8>(m_jvsScreenPosY >> 8); //Pos Y MSB
(*output++) = static_cast<uint8>(m_jvsGunPosY); //Pos Y LSB (*output++) = static_cast<uint8>(m_jvsScreenPosY); //Pos Y LSB
(*dstSize) += 5; (*dstSize) += 5;
} }
@ -486,9 +486,9 @@ void CSys246::SetButton(unsigned int buttonIndex, PS2::CControllerInfo::BUTTON b
m_jvsButtonBits[buttonValue] = (1 << buttonIndex); m_jvsButtonBits[buttonValue] = (1 << buttonIndex);
} }
void CSys246::SetLightGunXform(const std::array<float, 4>& lightGunXform) void CSys246::SetScreenPosXform(const std::array<float, 4>& screenPosXform)
{ {
m_lightGunXform = lightGunXform; m_screenPosXform = screenPosXform;
} }
void CSys246::SetButtonState(unsigned int padNumber, PS2::CControllerInfo::BUTTON button, bool pressed, uint8* ram) void CSys246::SetButtonState(unsigned int padNumber, PS2::CControllerInfo::BUTTON button, bool pressed, uint8* ram)
@ -606,16 +606,16 @@ void CSys246::SetAxisState(unsigned int padNumber, PS2::CControllerInfo::BUTTON
} }
} }
void CSys246::SetGunPosition(float x, float y) void CSys246::SetScreenPosition(float x, float y)
{ {
m_jvsGunPosX = static_cast<int16>((x * m_lightGunXform[0]) + m_lightGunXform[1]); m_jvsScreenPosX = static_cast<int16>((x * m_screenPosXform[0]) + m_screenPosXform[1]);
m_jvsGunPosY = static_cast<int16>((y * m_lightGunXform[2]) + m_lightGunXform[3]); m_jvsScreenPosY = static_cast<int16>((y * m_screenPosXform[2]) + m_screenPosXform[3]);
} }
void CSys246::ReleaseTouchPosition() void CSys246::ReleaseScreenPosition()
{ {
m_jvsGunPosX = 0xFFFF; m_jvsScreenPosX = 0xFFFF;
m_jvsGunPosY = 0xFFFF; //Y position is negligible m_jvsScreenPosY = 0xFFFF; //Y position is negligible
} }
bool CSys246::Invoke001(uint32 method, uint32* args, uint32 argsSize, uint32* ret, uint32 retSize, uint8* ram) bool CSys246::Invoke001(uint32 method, uint32* args, uint32 argsSize, uint32* ret, uint32 retSize, uint8* ram)

View file

@ -5,7 +5,7 @@
#include "../Iop_SifMan.h" #include "../Iop_SifMan.h"
#include "../../SifModuleAdapter.h" #include "../../SifModuleAdapter.h"
#include "../../PadInterface.h" #include "../../PadInterface.h"
#include "../../GunListener.h" #include "../../ScreenPositionListener.h"
#include "filesystem_def.h" #include "filesystem_def.h"
namespace Iop namespace Iop
@ -16,7 +16,7 @@ namespace Iop
{ {
class CAcRam; class CAcRam;
class CSys246 : public CModule, public CPadInterface, public CGunListener class CSys246 : public CModule, public CPadInterface, public CScreenPositionListener
{ {
public: public:
enum class JVS_MODE enum class JVS_MODE
@ -40,16 +40,16 @@ namespace Iop
void SetJvsMode(JVS_MODE); void SetJvsMode(JVS_MODE);
void SetButton(unsigned int, PS2::CControllerInfo::BUTTON); void SetButton(unsigned int, PS2::CControllerInfo::BUTTON);
void SetLightGunXform(const std::array<float, 4>&); void SetScreenPosXform(const std::array<float, 4>&);
//CPadInterface //CPadInterface
void SetButtonState(unsigned int, PS2::CControllerInfo::BUTTON, bool, uint8*) override; void SetButtonState(unsigned int, PS2::CControllerInfo::BUTTON, bool, uint8*) override;
void SetAxisState(unsigned int, PS2::CControllerInfo::BUTTON, uint8, uint8*) override; void SetAxisState(unsigned int, PS2::CControllerInfo::BUTTON, uint8, uint8*) override;
void GetVibration(unsigned int, uint8& largeMotor, uint8& smallMotor) override{}; void GetVibration(unsigned int, uint8& largeMotor, uint8& smallMotor) override{};
//CGunListener //CScreenPositionListener
void SetGunPosition(float, float) override; void SetScreenPosition(float, float) override;
void ReleaseTouchPosition() override; void ReleaseScreenPosition() override;
private: private:
enum MODULE_ID enum MODULE_ID
@ -119,13 +119,13 @@ namespace Iop
uint32 m_sendAddr = 0; uint32 m_sendAddr = 0;
JVS_MODE m_jvsMode = JVS_MODE::DEFAULT; JVS_MODE m_jvsMode = JVS_MODE::DEFAULT;
std::array<float, 4> m_lightGunXform = {65535, 0, 65535, 0}; std::array<float, 4> m_screenPosXform = {65535, 0, 65535, 0};
std::array<uint16, PS2::CControllerInfo::MAX_BUTTONS> m_jvsButtonBits = {}; std::array<uint16, PS2::CControllerInfo::MAX_BUTTONS> m_jvsButtonBits = {};
uint16 m_jvsButtonState[JVS_PLAYER_COUNT] = {}; uint16 m_jvsButtonState[JVS_PLAYER_COUNT] = {};
uint16 m_jvsSystemButtonState = 0; uint16 m_jvsSystemButtonState = 0;
uint16 m_jvsGunPosX = 0x7FFF; uint16 m_jvsScreenPosX = 0x7FFF;
uint16 m_jvsGunPosY = 0x7FFF; uint16 m_jvsScreenPosY = 0x7FFF;
uint16 m_jvsDrumChannels[JVS_DRUM_CHANNEL_MAX] = {}; uint16 m_jvsDrumChannels[JVS_DRUM_CHANNEL_MAX] = {};
uint16 m_jvsWheelChannels[JVS_WHEEL_CHANNEL_MAX] = {}; uint16 m_jvsWheelChannels[JVS_WHEEL_CHANNEL_MAX] = {};
uint16 m_jvsWheel = 0x0; uint16 m_jvsWheel = 0x0;

View file

@ -892,7 +892,7 @@ void MainWindow::outputWindow_mouseReleaseEvent(QMouseEvent* ev)
m_qtMouseInputProvider->OnMouseRelease(ev->button()); m_qtMouseInputProvider->OnMouseRelease(ev->button());
if(m_virtualMachine->HasTouchListener()) if(m_virtualMachine->HasTouchListener())
{ {
m_virtualMachine->ReleaseTouchPosition(); m_virtualMachine->ReleaseScreenPosition();
} }
} }

View file

@ -40,7 +40,7 @@ struct ARCADE_MACHINE_DEF
std::string nandFileName; std::string nandFileName;
std::map<unsigned int, PS2::CControllerInfo::BUTTON> buttons; std::map<unsigned int, PS2::CControllerInfo::BUTTON> buttons;
INPUT_MODE inputMode = INPUT_MODE::DEFAULT; INPUT_MODE inputMode = INPUT_MODE::DEFAULT;
std::array<float, 4> lightGunXform = {65535, 0, 65535, 0}; std::array<float, 4> screenPosXform = {65535, 0, 65535, 0};
uint32 eeFreqScaleNumerator = 1; uint32 eeFreqScaleNumerator = 1;
uint32 eeFreqScaleDenominator = 1; uint32 eeFreqScaleDenominator = 1;
std::string boot; std::string boot;

View file

@ -166,14 +166,14 @@ ARCADE_MACHINE_DEF ReadArcadeMachineDefinition(const fs::path& arcadeDefPath)
std::string inputModeString = defJson["inputMode"]; std::string inputModeString = defJson["inputMode"];
def.inputMode = ParseEnumValue(inputModeString.c_str(), std::begin(g_inputModeValues), std::end(g_inputModeValues)); def.inputMode = ParseEnumValue(inputModeString.c_str(), std::begin(g_inputModeValues), std::end(g_inputModeValues));
} }
if(defJson.contains("lightGunXform")) if(defJson.contains("screenPosXform"))
{ {
auto lightGunXformArray = defJson["lightGunXform"]; auto screenPosXformArray = defJson["screenPosXform"];
if(lightGunXformArray.is_array() && (lightGunXformArray.size() >= 4)) if(screenPosXformArray.is_array() && (screenPosXformArray.size() >= 4))
{ {
for(int i = 0; i < 4; i++) for(int i = 0; i < 4; i++)
{ {
def.lightGunXform[i] = lightGunXformArray[i]; def.screenPosXform[i] = screenPosXformArray[i];
} }
} }
} }

View file

@ -123,7 +123,7 @@ void CNamcoSys246Driver::PrepareEnvironment(CPS2VM* virtualMachine, const ARCADE
case ARCADE_MACHINE_DEF::INPUT_MODE::LIGHTGUN: case ARCADE_MACHINE_DEF::INPUT_MODE::LIGHTGUN:
virtualMachine->SetGunListener(namcoArcadeModule.get()); virtualMachine->SetGunListener(namcoArcadeModule.get());
namcoArcadeModule->SetJvsMode(Iop::Namco::CSys246::JVS_MODE::LIGHTGUN); namcoArcadeModule->SetJvsMode(Iop::Namco::CSys246::JVS_MODE::LIGHTGUN);
namcoArcadeModule->SetLightGunXform(def.lightGunXform); namcoArcadeModule->SetScreenPosXform(def.screenPosXform);
break; break;
case ARCADE_MACHINE_DEF::INPUT_MODE::DRUM: case ARCADE_MACHINE_DEF::INPUT_MODE::DRUM:
namcoArcadeModule->SetJvsMode(Iop::Namco::CSys246::JVS_MODE::DRUM); namcoArcadeModule->SetJvsMode(Iop::Namco::CSys246::JVS_MODE::DRUM);
@ -134,7 +134,7 @@ void CNamcoSys246Driver::PrepareEnvironment(CPS2VM* virtualMachine, const ARCADE
case ARCADE_MACHINE_DEF::INPUT_MODE::TOUCH: case ARCADE_MACHINE_DEF::INPUT_MODE::TOUCH:
virtualMachine->SetTouchListener(namcoArcadeModule.get()); virtualMachine->SetTouchListener(namcoArcadeModule.get());
namcoArcadeModule->SetJvsMode(Iop::Namco::CSys246::JVS_MODE::TOUCH); namcoArcadeModule->SetJvsMode(Iop::Namco::CSys246::JVS_MODE::TOUCH);
namcoArcadeModule->SetLightGunXform(def.lightGunXform); namcoArcadeModule->SetScreenPosXform(def.screenPosXform);
break; break;
default: default:
break; break;

View file

@ -15,7 +15,7 @@
"3": "circle" "3": "circle"
}, },
"inputMode": "lightgun", "inputMode": "lightgun",
"lightGunXform": [ -65535, 0, 65535, 0 ], "screenPosXform": [ -65535, 0, 65535, 0 ],
"eeFrequencyScale": [4, 3], "eeFrequencyScale": [4, 3],
"boot": "ac0:CBRLOAD", "boot": "ac0:CBRLOAD",
"patches": "patches":

View file

@ -11,7 +11,7 @@
"name": "NM00022 IDM1-HA (HDD).chd" "name": "NM00022 IDM1-HA (HDD).chd"
}, },
"inputMode": "touch", "inputMode": "touch",
"lightGunXform": [ 65535, 0, -65535, 0 ], "screenPosXform": [ 65535, 0, -65535, 0 ],
"eeFrequencyScale": [4, 3], "eeFrequencyScale": [4, 3],
"boot": "ac0:IDLLOAD", "boot": "ac0:IDLLOAD",
"patches": "patches":

View file

@ -11,7 +11,7 @@
"name": "NM00022 IDM1-HA (HDD).chd" "name": "NM00022 IDM1-HA (HDD).chd"
}, },
"inputMode": "touch", "inputMode": "touch",
"lightGunXform": [ 65535, 0, -65535, 0 ], "screenPosXform": [ 65535, 0, -65535, 0 ],
"eeFrequencyScale": [4, 3], "eeFrequencyScale": [4, 3],
"boot": "ac0:IDLLOAD", "boot": "ac0:IDLLOAD",
"patches": "patches":

View file

@ -11,7 +11,7 @@
"name": "tst1dvd0.chd" "name": "tst1dvd0.chd"
}, },
"inputMode": "lightgun", "inputMode": "lightgun",
"lightGunXform": [ 660, 16053, 220, 16273 ], "screenPosXform": [ 660, 16053, 220, 16273 ],
"boot": "ac0:TC3LOAD", "boot": "ac0:TC3LOAD",
"patches": "patches":
[ [

View file

@ -12,7 +12,7 @@
"name": "tst1dvd0.chd" "name": "tst1dvd0.chd"
}, },
"inputMode": "lightgun", "inputMode": "lightgun",
"lightGunXform": [ 660, 16053, 220, 16273 ], "screenPosXform": [ 660, 16053, 220, 16273 ],
"boot": "ac0:TC3LOAD", "boot": "ac0:TC3LOAD",
"patches": "patches":
[ [

View file

@ -12,7 +12,7 @@
"name": "tst1dvd0.chd" "name": "tst1dvd0.chd"
}, },
"inputMode": "lightgun", "inputMode": "lightgun",
"lightGunXform": [ 660, 16053, 220, 16273 ], "screenPosXform": [ 660, 16053, 220, 16273 ],
"boot": "ac0:TC3LOAD", "boot": "ac0:TC3LOAD",
"patches": "patches":
[ [

View file

@ -15,7 +15,7 @@
"3": "circle" "3": "circle"
}, },
"inputMode": "lightgun", "inputMode": "lightgun",
"lightGunXform": [ -65535, 0, 65535, 0 ], "screenPosXform": [ -65535, 0, 65535, 0 ],
"eeFrequencyScale": [3, 2], "eeFrequencyScale": [3, 2],
"boot": "ac0:TC4LOAD", "boot": "ac0:TC4LOAD",
"patches": "patches":

View file

@ -11,7 +11,7 @@
"name": "vpn1cd0.chd" "name": "vpn1cd0.chd"
}, },
"inputMode": "lightgun", "inputMode": "lightgun",
"lightGunXform": [ 53000, 7000, -48146, 50321 ], "screenPosXform": [ 53000, 7000, -48146, 50321 ],
"boot": "ac0:VPNGAME", "boot": "ac0:VPNGAME",
"patches": "patches":
[ [