mirror of
https://github.com/jpd002/Play-.git
synced 2025-04-28 13:47:57 +03:00
Rename CPadListener->CPadInterface
This commit is contained in:
parent
0ea90b563a
commit
3cc0dbb1ab
11 changed files with 74 additions and 73 deletions
|
@ -454,8 +454,8 @@ set(COMMON_SRC_FILES
|
||||||
OpticalMedia.h
|
OpticalMedia.h
|
||||||
PadHandler.cpp
|
PadHandler.cpp
|
||||||
PadHandler.h
|
PadHandler.h
|
||||||
PadListener.cpp
|
PadInterface.cpp
|
||||||
PadListener.h
|
PadInterface.h
|
||||||
Pch.cpp
|
Pch.cpp
|
||||||
Pch.h
|
Pch.h
|
||||||
PH_Generic.cpp
|
PH_Generic.cpp
|
||||||
|
|
|
@ -19,7 +19,7 @@ CPadHandler::FactoryFunction CPH_Generic::GetFactoryFunction()
|
||||||
|
|
||||||
void CPH_Generic::Update(uint8* ram)
|
void CPH_Generic::Update(uint8* ram)
|
||||||
{
|
{
|
||||||
for(auto& listener : m_listeners)
|
for(auto& interface : m_interfaces)
|
||||||
{
|
{
|
||||||
for(unsigned int i = 0; i < PS2::CControllerInfo::MAX_BUTTONS; i++)
|
for(unsigned int i = 0; i < PS2::CControllerInfo::MAX_BUTTONS; i++)
|
||||||
{
|
{
|
||||||
|
@ -27,11 +27,11 @@ void CPH_Generic::Update(uint8* ram)
|
||||||
if(PS2::CControllerInfo::IsAxis(button))
|
if(PS2::CControllerInfo::IsAxis(button))
|
||||||
{
|
{
|
||||||
float buttonValue = ((m_axisStates[i] + 1.0f) / 2.0f) * 255.f;
|
float buttonValue = ((m_axisStates[i] + 1.0f) / 2.0f) * 255.f;
|
||||||
listener->SetAxisState(0, button, static_cast<uint8>(buttonValue), ram);
|
interface->SetAxisState(0, button, static_cast<uint8>(buttonValue), ram);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
listener->SetButtonState(0, button, m_buttonStates[i], ram);
|
interface->SetButtonState(0, button, m_buttonStates[i], ram);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
#include "PadHandler.h"
|
#include "PadHandler.h"
|
||||||
|
|
||||||
void CPadHandler::InsertListener(CPadListener* pListener)
|
void CPadHandler::InsertListener(CPadInterface* pListener)
|
||||||
{
|
{
|
||||||
m_listeners.push_back(pListener);
|
m_interfaces.push_back(pListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CPadHandler::RemoveAllListeners()
|
void CPadHandler::RemoveAllListeners()
|
||||||
{
|
{
|
||||||
m_listeners.clear();
|
m_interfaces.clear();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#ifndef _PADHANDLER_H_
|
#ifndef _PADHANDLER_H_
|
||||||
#define _PADHANDLER_H_
|
#define _PADHANDLER_H_
|
||||||
|
|
||||||
#include "PadListener.h"
|
#include "PadInterface.h"
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
|
||||||
|
@ -13,12 +13,12 @@ public:
|
||||||
CPadHandler() = default;
|
CPadHandler() = default;
|
||||||
virtual ~CPadHandler() = default;
|
virtual ~CPadHandler() = default;
|
||||||
virtual void Update(uint8*) = 0;
|
virtual void Update(uint8*) = 0;
|
||||||
void InsertListener(CPadListener*);
|
void InsertListener(CPadInterface*);
|
||||||
void RemoveAllListeners();
|
void RemoveAllListeners();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
typedef std::list<CPadListener*> ListenerList;
|
typedef std::list<CPadInterface*> ListenerList;
|
||||||
ListenerList m_listeners;
|
ListenerList m_interfaces;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,35 +1,35 @@
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include "PadListener.h"
|
#include "PadInterface.h"
|
||||||
|
|
||||||
using namespace PS2;
|
using namespace PS2;
|
||||||
|
|
||||||
uint32 CPadListener::GetButtonMask(CControllerInfo::BUTTON button)
|
uint32 CPadInterface::GetButtonMask(CControllerInfo::BUTTON button)
|
||||||
{
|
{
|
||||||
static uint32 buttonMask[CControllerInfo::MAX_BUTTONS] =
|
static uint32 buttonMask[CControllerInfo::MAX_BUTTONS] =
|
||||||
{
|
{
|
||||||
static_cast<uint32>(-1),
|
static_cast<uint32>(-1),
|
||||||
static_cast<uint32>(-1),
|
static_cast<uint32>(-1),
|
||||||
static_cast<uint32>(-1),
|
static_cast<uint32>(-1),
|
||||||
static_cast<uint32>(-1),
|
static_cast<uint32>(-1),
|
||||||
0x1000,
|
0x1000,
|
||||||
0x4000,
|
0x4000,
|
||||||
0x8000,
|
0x8000,
|
||||||
0x2000,
|
0x2000,
|
||||||
0x0100,
|
0x0100,
|
||||||
0x0800,
|
0x0800,
|
||||||
0x0080,
|
0x0080,
|
||||||
0x0010,
|
0x0010,
|
||||||
0x0020,
|
0x0020,
|
||||||
0x0040,
|
0x0040,
|
||||||
0x0004, //L1
|
0x0004, //L1
|
||||||
0x0001, //L2
|
0x0001, //L2
|
||||||
0x0200, //L3
|
0x0200, //L3
|
||||||
0x0008, //R1
|
0x0008, //R1
|
||||||
0x0002, //R2
|
0x0002, //R2
|
||||||
0x0400, //R3
|
0x0400, //R3
|
||||||
};
|
};
|
||||||
|
|
||||||
uint32 result = buttonMask[button];
|
uint32 result = buttonMask[button];
|
||||||
assert(result != -1);
|
assert(result != -1);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
|
@ -1,13 +1,13 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "Types.h"
|
#include "Types.h"
|
||||||
#include "ControllerInfo.h"
|
#include "ControllerInfo.h"
|
||||||
|
|
||||||
class CPadListener
|
class CPadInterface
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual ~CPadListener() = default;
|
virtual ~CPadInterface() = default;
|
||||||
virtual void SetButtonState(unsigned int, PS2::CControllerInfo::BUTTON, bool, uint8*) = 0;
|
virtual void SetButtonState(unsigned int, PS2::CControllerInfo::BUTTON, bool, uint8*) = 0;
|
||||||
virtual void SetAxisState(unsigned int, PS2::CControllerInfo::BUTTON, uint8, uint8*) = 0;
|
virtual void SetAxisState(unsigned int, PS2::CControllerInfo::BUTTON, uint8, uint8*) = 0;
|
||||||
static uint32 GetButtonMask(PS2::CControllerInfo::BUTTON);
|
static uint32 GetButtonMask(PS2::CControllerInfo::BUTTON);
|
||||||
};
|
};
|
|
@ -2,7 +2,8 @@
|
||||||
|
|
||||||
void CPH_GenericInput::Update(uint8* ram)
|
void CPH_GenericInput::Update(uint8* ram)
|
||||||
{
|
{
|
||||||
for(auto* listener : m_listeners)
|
std::map<unsigned int, std::pair<uint8, uint8>> vibMap;
|
||||||
|
for(auto* interface : m_interfaces)
|
||||||
{
|
{
|
||||||
for(unsigned int pad = 0; pad < CInputBindingManager::MAX_PADS; pad++)
|
for(unsigned int pad = 0; pad < CInputBindingManager::MAX_PADS; pad++)
|
||||||
{
|
{
|
||||||
|
@ -14,11 +15,11 @@ void CPH_GenericInput::Update(uint8* ram)
|
||||||
uint32 value = binding->GetValue();
|
uint32 value = binding->GetValue();
|
||||||
if(PS2::CControllerInfo::IsAxis(button))
|
if(PS2::CControllerInfo::IsAxis(button))
|
||||||
{
|
{
|
||||||
listener->SetAxisState(pad, button, value & 0xFF, ram);
|
interface->SetAxisState(pad, button, value & 0xFF, ram);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
listener->SetButtonState(pad, button, value != 0, ram);
|
interface->SetButtonState(pad, button, value != 0, ram);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
#include "Iop_Module.h"
|
#include "Iop_Module.h"
|
||||||
#include "Iop_SifMan.h"
|
#include "Iop_SifMan.h"
|
||||||
#include "../SifModuleAdapter.h"
|
#include "../SifModuleAdapter.h"
|
||||||
#include "../PadListener.h"
|
#include "../PadInterface.h"
|
||||||
#include "../GunListener.h"
|
#include "../GunListener.h"
|
||||||
#include "filesystem_def.h"
|
#include "filesystem_def.h"
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ namespace Iop
|
||||||
class CAcRam;
|
class CAcRam;
|
||||||
}
|
}
|
||||||
|
|
||||||
class CNamcoArcade : public CModule, public CPadListener, public CGunListener
|
class CNamcoArcade : public CModule, public CPadInterface, public CGunListener
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
enum class JVS_MODE
|
enum class JVS_MODE
|
||||||
|
@ -42,7 +42,7 @@ namespace Iop
|
||||||
void SetButton(unsigned int, PS2::CControllerInfo::BUTTON);
|
void SetButton(unsigned int, PS2::CControllerInfo::BUTTON);
|
||||||
void SetLightGunXform(const std::array<float, 4>&);
|
void SetLightGunXform(const std::array<float, 4>&);
|
||||||
|
|
||||||
//CPadListener
|
//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;
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
#include "Iop_Module.h"
|
#include "Iop_Module.h"
|
||||||
#include "Iop_SifMan.h"
|
#include "Iop_SifMan.h"
|
||||||
#include "Iop_SifModuleProvider.h"
|
#include "Iop_SifModuleProvider.h"
|
||||||
#include "../PadListener.h"
|
#include "../PadInterface.h"
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include "zip/ZipArchiveWriter.h"
|
#include "zip/ZipArchiveWriter.h"
|
||||||
#include "zip/ZipArchiveReader.h"
|
#include "zip/ZipArchiveReader.h"
|
||||||
|
@ -12,7 +12,7 @@
|
||||||
|
|
||||||
namespace Iop
|
namespace Iop
|
||||||
{
|
{
|
||||||
class CPadMan : public CModule, public CPadListener, public CSifModule, public CSifModuleProvider
|
class CPadMan : public CModule, public CPadInterface, public CSifModule, public CSifModuleProvider
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CPadMan() = default;
|
CPadMan() = default;
|
||||||
|
|
|
@ -2,12 +2,12 @@
|
||||||
|
|
||||||
#include "Types.h"
|
#include "Types.h"
|
||||||
#include "Iop_Intc.h"
|
#include "Iop_Intc.h"
|
||||||
#include "../PadListener.h"
|
#include "../PadInterface.h"
|
||||||
#include <deque>
|
#include <deque>
|
||||||
|
|
||||||
namespace Iop
|
namespace Iop
|
||||||
{
|
{
|
||||||
class CSio2 : public CPadListener
|
class CSio2 : public CPadInterface
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
enum
|
enum
|
||||||
|
|
|
@ -48,19 +48,19 @@ void CPH_Libretro_Input::UpdateInputState()
|
||||||
void CPH_Libretro_Input::Update(uint8* ram)
|
void CPH_Libretro_Input::Update(uint8* ram)
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lock(m_input_mutex);
|
std::lock_guard<std::mutex> lock(m_input_mutex);
|
||||||
for(auto* listener : m_listeners)
|
for(auto* interface : m_interfaces)
|
||||||
{
|
{
|
||||||
for(unsigned int i = 0; i < PS2::CControllerInfo::MAX_BUTTONS; i++)
|
for(unsigned int i = 0; i < PS2::CControllerInfo::MAX_BUTTONS; i++)
|
||||||
{
|
{
|
||||||
auto currentButtonId = static_cast<PS2::CControllerInfo::BUTTON>(i);
|
auto currentButtonId = static_cast<PS2::CControllerInfo::BUTTON>(i);
|
||||||
if(PS2::CControllerInfo::IsAxis(currentButtonId))
|
if(PS2::CControllerInfo::IsAxis(currentButtonId))
|
||||||
{
|
{
|
||||||
listener->SetAxisState(0, currentButtonId, m_axis_btn_state[currentButtonId], ram);
|
interface->SetAxisState(0, currentButtonId, m_axis_btn_state[currentButtonId], ram);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
uint32 val = m_btns_state & (1 << g_ds2_to_retro_btn_map[currentButtonId]);
|
uint32 val = m_btns_state & (1 << g_ds2_to_retro_btn_map[currentButtonId]);
|
||||||
listener->SetButtonState(0, currentButtonId, val != 0, ram);
|
interface->SetButtonState(0, currentButtonId, val != 0, ram);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue