Skip to content

Commit

Permalink
input: move pad_state_notify_state_change to pad_thread
Browse files Browse the repository at this point in the history
  • Loading branch information
Megamouse committed Jun 12, 2024
1 parent b0d4858 commit b8452d2
Show file tree
Hide file tree
Showing 26 changed files with 82 additions and 78 deletions.
2 changes: 1 addition & 1 deletion rpcs3/Emu/Io/Null/NullPadHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
class NullPadHandler final : public PadHandlerBase
{
public:
NullPadHandler(bool emulation) : PadHandlerBase(pad_handler::null, emulation)
NullPadHandler() : PadHandlerBase(pad_handler::null)
{
b_has_pressure_intensity_button = false;
}
Expand Down
19 changes: 1 addition & 18 deletions rpcs3/Emu/Io/PadHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@

cfg_input g_cfg_input;

extern void pad_state_notify_state_change(usz index, u32 state);

PadHandlerBase::PadHandlerBase(pad_handler type, bool emulation) : m_type(type), m_emulation(emulation)
PadHandlerBase::PadHandlerBase(pad_handler type) : m_type(type)
{
}

Expand Down Expand Up @@ -747,11 +745,6 @@ void PadHandlerBase::process()

pad->m_port_status |= CELL_PAD_STATUS_CONNECTED + CELL_PAD_STATUS_ASSIGN_CHANGES;

if (m_emulation && !pad->is_fake_pad)
{
pad_state_notify_state_change(i, CELL_PAD_STATUS_CONNECTED);
}

last_connection_status[i] = true;
connected_devices++;
}
Expand All @@ -775,11 +768,6 @@ void PadHandlerBase::process()

pad->m_port_status |= CELL_PAD_STATUS_CONNECTED + CELL_PAD_STATUS_ASSIGN_CHANGES;

if (m_emulation && !pad->is_fake_pad)
{
pad_state_notify_state_change(i, CELL_PAD_STATUS_CONNECTED);
}

last_connection_status[i] = true;
connected_devices++;
}
Expand All @@ -793,11 +781,6 @@ void PadHandlerBase::process()
pad->m_port_status &= ~CELL_PAD_STATUS_CONNECTED;
pad->m_port_status |= CELL_PAD_STATUS_ASSIGN_CHANGES;

if (m_emulation)
{
pad_state_notify_state_change(i, CELL_PAD_STATUS_DISCONNECTED);
}

last_connection_status[i] = false;
connected_devices--;
}
Expand Down
3 changes: 1 addition & 2 deletions rpcs3/Emu/Io/PadHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,6 @@ class PadHandlerBase

pad_handler m_type;
bool m_is_init = false;
bool m_emulation = false;

std::string name_string() const;
usz max_devices() const;
Expand All @@ -266,7 +265,7 @@ class PadHandlerBase
void convert_stick_values(u16& x_out, u16& y_out, s32 x_in, s32 y_in, u32 deadzone, u32 anti_deadzone, u32 padsquircling) const;

virtual bool Init() { return true; }
PadHandlerBase(pad_handler type = pad_handler::null, bool emulation = false);
PadHandlerBase(pad_handler type = pad_handler::null);
virtual ~PadHandlerBase() = default;
// Sets window to config the controller(optional)
virtual void SetPadData(const std::string& /*padId*/, u8 /*player_id*/, u8 /*large_motor*/, u8 /*small_motor*/, s32 /*r*/, s32 /*g*/, s32 /*b*/, bool /*player_led*/, bool /*battery_led*/, u32 /*battery_led_brightness*/) {}
Expand Down
4 changes: 2 additions & 2 deletions rpcs3/Input/ds3_pad_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ constexpr std::array<u8, 6> battery_capacity = {0, 1, 25, 50, 75, 100};

constexpr id_pair SONY_DS3_ID_0 = {0x054C, 0x0268};

ds3_pad_handler::ds3_pad_handler(bool emulation)
: hid_pad_handler(pad_handler::ds3, emulation, {SONY_DS3_ID_0})
ds3_pad_handler::ds3_pad_handler()
: hid_pad_handler(pad_handler::ds3, {SONY_DS3_ID_0})
{
button_list =
{
Expand Down
2 changes: 1 addition & 1 deletion rpcs3/Input/ds3_pad_handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ class ds3_pad_handler final : public hid_pad_handler<ds3_device>
#endif

public:
ds3_pad_handler(bool emulation);
ds3_pad_handler();
~ds3_pad_handler();

void SetPadData(const std::string& padId, u8 player_id, u8 large_motor, u8 small_motor, s32 r, s32 g, s32 b, bool player_led, bool battery_led, u32 battery_led_brightness) override;
Expand Down
4 changes: 2 additions & 2 deletions rpcs3/Input/ds4_pad_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ namespace
}*/
}

ds4_pad_handler::ds4_pad_handler(bool emulation)
: hid_pad_handler<DS4Device>(pad_handler::ds4, emulation, {SONY_DS4_ID_0, SONY_DS4_ID_1, SONY_DS4_ID_2, ZEROPLUS_ID_0})
ds4_pad_handler::ds4_pad_handler()
: hid_pad_handler<DS4Device>(pad_handler::ds4, {SONY_DS4_ID_0, SONY_DS4_ID_1, SONY_DS4_ID_2, ZEROPLUS_ID_0})
{
// Unique names for the config files and our pad settings dialog
button_list =
Expand Down
2 changes: 1 addition & 1 deletion rpcs3/Input/ds4_pad_handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ class ds4_pad_handler final : public hid_pad_handler<DS4Device>
};

public:
ds4_pad_handler(bool emulation);
ds4_pad_handler();
~ds4_pad_handler();

void SetPadData(const std::string& padId, u8 player_id, u8 large_motor, u8 small_motor, s32 r, s32 g, s32 b, bool player_led, bool battery_led, u32 battery_led_brightness) override;
Expand Down
4 changes: 2 additions & 2 deletions rpcs3/Input/dualsense_pad_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ namespace
constexpr id_pair SONY_DUALSENSE_ID_1 = {0x054C, 0x0DF2}; // DualSense Edge
}

dualsense_pad_handler::dualsense_pad_handler(bool emulation)
: hid_pad_handler<DualSenseDevice>(pad_handler::dualsense, emulation, {SONY_DUALSENSE_ID_0, SONY_DUALSENSE_ID_1})
dualsense_pad_handler::dualsense_pad_handler()
: hid_pad_handler<DualSenseDevice>(pad_handler::dualsense, {SONY_DUALSENSE_ID_0, SONY_DUALSENSE_ID_1})
{
// Unique names for the config files and our pad settings dialog
button_list =
Expand Down
2 changes: 1 addition & 1 deletion rpcs3/Input/dualsense_pad_handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ class dualsense_pad_handler final : public hid_pad_handler<DualSenseDevice>
};

public:
dualsense_pad_handler(bool emulation);
dualsense_pad_handler();
~dualsense_pad_handler();

void SetPadData(const std::string& padId, u8 player_id, u8 large_motor, u8 small_motor, s32 r, s32 g, s32 b, bool player_led, bool battery_led, u32 battery_led_brightness) override;
Expand Down
4 changes: 2 additions & 2 deletions rpcs3/Input/evdev_joystick_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@

LOG_CHANNEL(evdev_log, "evdev");

evdev_joystick_handler::evdev_joystick_handler(bool emulation)
: PadHandlerBase(pad_handler::evdev, emulation)
evdev_joystick_handler::evdev_joystick_handler()
: PadHandlerBase(pad_handler::evdev)
{
init_configs();

Expand Down
2 changes: 1 addition & 1 deletion rpcs3/Input/evdev_joystick_handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ class evdev_joystick_handler final : public PadHandlerBase
};

public:
evdev_joystick_handler(bool emulation);
evdev_joystick_handler();
~evdev_joystick_handler();

void init_config(cfg_pad* cfg) override;
Expand Down
16 changes: 8 additions & 8 deletions rpcs3/Input/gui_pad_thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,26 +201,26 @@ std::shared_ptr<PadHandlerBase> gui_pad_thread::GetHandler(pad_handler type)
// Makes no sense to use this if we are in the GUI anyway
return nullptr;
case pad_handler::ds3:
return std::make_shared<ds3_pad_handler>(false);
return std::make_shared<ds3_pad_handler>();
case pad_handler::ds4:
return std::make_shared<ds4_pad_handler>(false);
return std::make_shared<ds4_pad_handler>();
case pad_handler::dualsense:
return std::make_shared<dualsense_pad_handler>(false);
return std::make_shared<dualsense_pad_handler>();
case pad_handler::skateboard:
return std::make_shared<skateboard_pad_handler>(false);
return std::make_shared<skateboard_pad_handler>();
#ifdef _WIN32
case pad_handler::xinput:
return std::make_shared<xinput_pad_handler>(false);
return std::make_shared<xinput_pad_handler>();
case pad_handler::mm:
return std::make_shared<mm_joystick_handler>(false);
return std::make_shared<mm_joystick_handler>();
#endif
#ifdef HAVE_SDL2
case pad_handler::sdl:
return std::make_shared<sdl_pad_handler>(false);
return std::make_shared<sdl_pad_handler>();
#endif
#ifdef HAVE_LIBEVDEV
case pad_handler::evdev:
return std::make_shared<evdev_joystick_handler>(false);
return std::make_shared<evdev_joystick_handler>();
#endif
}

Expand Down
4 changes: 2 additions & 2 deletions rpcs3/Input/hid_pad_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ static std::mutex s_hid_mutex; // hid_pad_handler is created by pad_thread and p
static u8 s_hid_instances{0};

template <class Device>
hid_pad_handler<Device>::hid_pad_handler(pad_handler type, bool emulation, std::vector<id_pair> ids)
: PadHandlerBase(type, emulation), m_ids(std::move(ids))
hid_pad_handler<Device>::hid_pad_handler(pad_handler type, std::vector<id_pair> ids)
: PadHandlerBase(type), m_ids(std::move(ids))
{
std::scoped_lock lock(s_hid_mutex);
ensure(s_hid_instances++ < 255);
Expand Down
2 changes: 1 addition & 1 deletion rpcs3/Input/hid_pad_handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ template <class Device>
class hid_pad_handler : public PadHandlerBase
{
public:
hid_pad_handler(pad_handler type, bool emulation, std::vector<id_pair> ids);
hid_pad_handler(pad_handler type, std::vector<id_pair> ids);
~hid_pad_handler();

bool Init() override;
Expand Down
4 changes: 2 additions & 2 deletions rpcs3/Input/keyboard_pad_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ bool keyboard_pad_handler::Init()
return true;
}

keyboard_pad_handler::keyboard_pad_handler(bool emulation)
keyboard_pad_handler::keyboard_pad_handler()
: QObject()
, PadHandlerBase(pad_handler::keyboard, emulation)
, PadHandlerBase(pad_handler::keyboard)
{
init_configs();

Expand Down
2 changes: 1 addition & 1 deletion rpcs3/Input/keyboard_pad_handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class keyboard_pad_handler final : public QObject, public PadHandlerBase
public:
bool Init() override;

keyboard_pad_handler(bool emulation);
keyboard_pad_handler();

void SetTargetWindow(QWindow* target);
void processKeyEvent(QKeyEvent* event, bool pressed);
Expand Down
2 changes: 1 addition & 1 deletion rpcs3/Input/mm_joystick_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include "mm_joystick_handler.h"
#include "Emu/Io/pad_config.h"

mm_joystick_handler::mm_joystick_handler(bool emulation) : PadHandlerBase(pad_handler::mm, emulation)
mm_joystick_handler::mm_joystick_handler() : PadHandlerBase(pad_handler::mm)
{
init_configs();

Expand Down
2 changes: 1 addition & 1 deletion rpcs3/Input/mm_joystick_handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ class mm_joystick_handler final : public PadHandlerBase
};

public:
mm_joystick_handler(bool emulation);
mm_joystick_handler();

bool Init() override;

Expand Down
Loading

0 comments on commit b8452d2

Please sign in to comment.