mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2024-10-23 23:55:42 +00:00
b6f871d2b9
* CPU/Recompiler: Use rel32 call where possible for no-args * JitCodeBuffer: Support using preallocated buffer * CPU/Recompiler/AArch64: Use bl instead of blr for short branches * CPU/CodeCache: Allocate recompiler buffer in program space This means we don't need 64-bit moves for every call out of the recompiler. * GTE: Don't store as u16 and load as u32 * CPU/Recompiler: Add methods to emit global load/stores * GTE: Convert class to namespace * CPU/Recompiler: Call GTE functions directly * Settings: Turn into a global variable * GPU: Replace local pointers with global * InterruptController: Turn into a global pointer * System: Replace local pointers with global * Timers: Turn into a global instance * DMA: Turn into a global instance * SPU: Turn into a global instance * CDROM: Turn into a global instance * MDEC: Turn into a global instance * Pad: Turn into a global instance * SIO: Turn into a global instance * CDROM: Move audio FIFO to the heap * CPU/Recompiler: Drop ASMFunctions No longer needed since we have code in the same 4GB window. * CPUCodeCache: Turn class into namespace * Bus: Local pointer -> global pointers * CPU: Turn class into namespace * Bus: Turn into namespace * GTE: Store registers in CPU state struct Allows relative addressing on ARM. * CPU/Recompiler: Align code storage to page size * CPU/Recompiler: Fix relative branches on A64 * HostInterface: Local references to global * System: Turn into a namespace, move events out * Add guard pages * Android: Fix build
82 lines
2.2 KiB
C++
82 lines
2.2 KiB
C++
#include "controller_interface.h"
|
|
#include "common/assert.h"
|
|
#include "common/log.h"
|
|
#include "core/controller.h"
|
|
#include "core/system.h"
|
|
#include <cmath>
|
|
Log_SetChannel(ControllerInterface);
|
|
|
|
ControllerInterface::ControllerInterface() = default;
|
|
|
|
ControllerInterface::~ControllerInterface() = default;
|
|
|
|
bool ControllerInterface::Initialize(CommonHostInterface* host_interface)
|
|
{
|
|
m_host_interface = host_interface;
|
|
return true;
|
|
}
|
|
|
|
void ControllerInterface::Shutdown()
|
|
{
|
|
m_host_interface = nullptr;
|
|
}
|
|
|
|
void ControllerInterface::SetHook(Hook::Callback callback)
|
|
{
|
|
std::unique_lock<std::mutex> lock(m_event_intercept_mutex);
|
|
Assert(!m_event_intercept_callback);
|
|
m_event_intercept_callback = std::move(callback);
|
|
}
|
|
|
|
void ControllerInterface::ClearHook()
|
|
{
|
|
std::unique_lock<std::mutex> lock(m_event_intercept_mutex);
|
|
if (m_event_intercept_callback)
|
|
m_event_intercept_callback = {};
|
|
}
|
|
|
|
bool ControllerInterface::DoEventHook(Hook::Type type, int controller_index, int button_or_axis_number, float value)
|
|
{
|
|
std::unique_lock<std::mutex> lock(m_event_intercept_mutex);
|
|
if (!m_event_intercept_callback)
|
|
return false;
|
|
|
|
const Hook ei{type, controller_index, button_or_axis_number, value};
|
|
const Hook::CallbackResult action = m_event_intercept_callback(ei);
|
|
if (action == Hook::CallbackResult::StopMonitoring)
|
|
m_event_intercept_callback = {};
|
|
|
|
return true;
|
|
}
|
|
|
|
void ControllerInterface::OnControllerConnected(int host_id)
|
|
{
|
|
Log_InfoPrintf("Host controller %d connected, updating input map", host_id);
|
|
m_host_interface->UpdateInputMap();
|
|
}
|
|
|
|
void ControllerInterface::OnControllerDisconnected(int host_id)
|
|
{
|
|
Log_InfoPrintf("Host controller %d disconnected, updating input map", host_id);
|
|
m_host_interface->UpdateInputMap();
|
|
}
|
|
|
|
void ControllerInterface::ClearBindings() {}
|
|
|
|
bool ControllerInterface::BindControllerAxis(int controller_index, int axis_number, AxisCallback callback)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
bool ControllerInterface::BindControllerButton(int controller_index, int button_number, ButtonCallback callback)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
bool ControllerInterface::BindControllerAxisToButton(int controller_index, int axis_number, bool direction,
|
|
ButtonCallback callback)
|
|
{
|
|
return false;
|
|
}
|
|
|