Skip to content

Commit

Permalink
cellPad: move CellPadData to pad_types for convenience
Browse files Browse the repository at this point in the history
  • Loading branch information
Megamouse committed Feb 12, 2023
1 parent 8ad41b4 commit 09f2621
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
4 changes: 2 additions & 2 deletions rpcs3/Emu/Cell/Modules/cellPad.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ void pad_get_data(u32 port_no, CellPadData* data)
}
else if (pad->ldd)
{
std::memcpy(data, pad->ldd_data, sizeof(CellPadData));
pad->ldd_data = *data;
if (setting & CELL_PAD_SETTING_SENSOR_ON)
data->len = CELL_PAD_LEN_CHANGE_SENSOR_ON;
else
Expand Down Expand Up @@ -909,7 +909,7 @@ error_code cellPadLddDataInsert(s32 handle, vm::ptr<CellPadData> data)
if (!pads[handle]->ldd)
return CELL_PAD_ERROR_NO_DEVICE;

memcpy(pads[handle]->ldd_data, data.get_ptr(), sizeof(CellPadData));
pads[handle]->ldd_data = *data;

return CELL_OK;
}
Expand Down
6 changes: 0 additions & 6 deletions rpcs3/Emu/Cell/Modules/cellPad.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,6 @@ enum
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
{
be_t<u32> max_connect;
Expand Down
9 changes: 8 additions & 1 deletion rpcs3/Emu/Io/pad_types.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#include "util/types.hpp"
#include "util/endian.hpp"
#include "Emu/Io/pad_config_types.h"

#include <vector>
Expand Down Expand Up @@ -170,6 +171,12 @@ enum
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_Y = 399;
static constexpr u16 DEFAULT_MOTION_Z = 512;
Expand Down Expand Up @@ -324,7 +331,7 @@ struct Pad
u16 m_sensor_g{DEFAULT_MOTION_G};

bool ldd{false};
u8 ldd_data[132] = {};
CellPadData ldd_data{};

explicit Pad(pad_handler handler, u32 port_status, u32 device_capability, u32 device_type)
: m_pad_handler(handler)
Expand Down
2 changes: 1 addition & 1 deletion rpcs3/Input/pad_thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ void pad_thread::operator()()
continue;

// 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;
break;
Expand Down

0 comments on commit 09f2621

Please sign in to comment.