cellPad: move CellPadData to pad_types for convenience

This commit is contained in:
Megamouse 2023-02-12 11:33:23 +01:00
parent d4187242b9
commit 1dac708323
4 changed files with 11 additions and 10 deletions

View File

@ -207,7 +207,7 @@ void pad_get_data(u32 port_no, CellPadData* data)
} }
else if (pad->ldd) else if (pad->ldd)
{ {
std::memcpy(data, pad->ldd_data, sizeof(CellPadData)); pad->ldd_data = *data;
if (setting & CELL_PAD_SETTING_SENSOR_ON) if (setting & CELL_PAD_SETTING_SENSOR_ON)
data->len = CELL_PAD_LEN_CHANGE_SENSOR_ON; data->len = CELL_PAD_LEN_CHANGE_SENSOR_ON;
else else
@ -909,7 +909,7 @@ error_code cellPadLddDataInsert(s32 handle, vm::ptr<CellPadData> data)
if (!pads[handle]->ldd) if (!pads[handle]->ldd)
return CELL_PAD_ERROR_NO_DEVICE; return CELL_PAD_ERROR_NO_DEVICE;
memcpy(pads[handle]->ldd_data, data.get_ptr(), sizeof(CellPadData)); pads[handle]->ldd_data = *data;
return CELL_OK; return CELL_OK;
} }

View File

@ -126,12 +126,6 @@ enum
CELL_PADFILTER_IIR_CUTOFF_2ND_LPF_BT_010 = 2, // 10% Nyquist frequency CELL_PADFILTER_IIR_CUTOFF_2ND_LPF_BT_010 = 2, // 10% Nyquist frequency
}; };
struct CellPadData
{
be_t<s32> len;
be_t<u16> button[CELL_PAD_MAX_CODES];
};
struct CellPadInfo struct CellPadInfo
{ {
be_t<u32> max_connect; be_t<u32> max_connect;

View File

@ -1,6 +1,7 @@
#pragma once #pragma once
#include "util/types.hpp" #include "util/types.hpp"
#include "util/endian.hpp"
#include "Emu/Io/pad_config_types.h" #include "Emu/Io/pad_config_types.h"
#include <vector> #include <vector>
@ -170,6 +171,12 @@ enum
CELL_MAX_PADS = 127, CELL_MAX_PADS = 127,
}; };
struct CellPadData
{
be_t<s32> len;
be_t<u16> button[CELL_PAD_MAX_CODES];
};
static constexpr u16 DEFAULT_MOTION_X = 512; static constexpr u16 DEFAULT_MOTION_X = 512;
static constexpr u16 DEFAULT_MOTION_Y = 399; static constexpr u16 DEFAULT_MOTION_Y = 399;
static constexpr u16 DEFAULT_MOTION_Z = 512; static constexpr u16 DEFAULT_MOTION_Z = 512;
@ -324,7 +331,7 @@ struct Pad
u16 m_sensor_g{DEFAULT_MOTION_G}; u16 m_sensor_g{DEFAULT_MOTION_G};
bool ldd{false}; bool ldd{false};
u8 ldd_data[132] = {}; CellPadData ldd_data{};
explicit Pad(pad_handler handler, u32 port_status, u32 device_capability, u32 device_type) explicit Pad(pad_handler handler, u32 port_status, u32 device_capability, u32 device_type)
: m_pad_handler(handler) : m_pad_handler(handler)

View File

@ -423,7 +423,7 @@ void pad_thread::operator()()
continue; continue;
// Check if an LDD pad pressed the PS button (bit 0 of the first button) // Check if an LDD pad pressed the PS button (bit 0 of the first button)
if (pad->ldd && !!(static_cast<be_t<u16>>(pad->ldd_data[sizeof(be_t<u32>)]) & CELL_PAD_CTRL_LDD_PS)) if (pad->ldd && !!(pad->ldd_data.button[0] & CELL_PAD_CTRL_LDD_PS))
{ {
ps_button_pressed = true; ps_button_pressed = true;
break; break;