mirror of
https://github.com/RPCS3/rpcs3.git
synced 2026-06-02 04:36:57 -06:00
input: Use smaller external structs for button and stick access outside of the pad_thread
This needs less memory and hides unwanted members from client code.
This commit is contained in:
parent
5f00b87a44
commit
fdce82fc24
@ -2183,7 +2183,7 @@ static void ds3_input_to_ext(u32 gem_num, gem_config::gem_controller& controller
|
||||
|
||||
ext.status = controller.ext_status;
|
||||
|
||||
for (const AnalogStick& stick : pad->m_sticks_external)
|
||||
for (const AnalogStickExternal& stick : pad->m_sticks_external)
|
||||
{
|
||||
switch (stick.m_offset)
|
||||
{
|
||||
@ -2195,7 +2195,7 @@ static void ds3_input_to_ext(u32 gem_num, gem_config::gem_controller& controller
|
||||
}
|
||||
}
|
||||
|
||||
for (const Button& button : pad->m_buttons_external)
|
||||
for (const ButtonExternal& button : pad->m_buttons_external)
|
||||
{
|
||||
if (!button.m_pressed)
|
||||
continue;
|
||||
|
||||
@ -418,7 +418,7 @@ void pad_get_data(u32 port_no, CellPadData* data, bool get_periph_data = false)
|
||||
}
|
||||
};
|
||||
|
||||
for (const Button& button : pad->m_buttons_external)
|
||||
for (const ButtonExternal& button : pad->m_buttons_external)
|
||||
{
|
||||
// here we check btns, and set pad accordingly,
|
||||
// if something changed, set btnChanged
|
||||
@ -497,7 +497,7 @@ void pad_get_data(u32 port_no, CellPadData* data, bool get_periph_data = false)
|
||||
}
|
||||
}
|
||||
|
||||
for (const AnalogStick& stick : pad->m_sticks_external)
|
||||
for (const AnalogStickExternal& stick : pad->m_sticks_external)
|
||||
{
|
||||
switch (stick.m_offset)
|
||||
{
|
||||
|
||||
@ -200,7 +200,7 @@ void usb_device_gametablet::interrupt_transfer(u32 buf_size, u8* buf, u32 /*endp
|
||||
const auto& pad = ::at32(pads, m_controller_index);
|
||||
if (pad->is_connected() && !pad->is_copilot())
|
||||
{
|
||||
for (Button& button : pad->m_buttons_external)
|
||||
for (ButtonExternal& button : pad->m_buttons_external)
|
||||
{
|
||||
if (!button.m_pressed)
|
||||
{
|
||||
|
||||
@ -93,7 +93,7 @@ public:
|
||||
if (!pad || pad->is_copilot())
|
||||
return;
|
||||
|
||||
for (const Button& button : pad->m_buttons_external)
|
||||
for (const ButtonExternal& button : pad->m_buttons_external)
|
||||
{
|
||||
if (button.m_pressed || !press_only)
|
||||
{
|
||||
@ -104,7 +104,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
for (const AnalogStick& stick : pad->m_sticks_external)
|
||||
for (const AnalogStickExternal& stick : pad->m_sticks_external)
|
||||
{
|
||||
if (handle_input(func, stick.m_offset, get_axis_keycode(stick.m_offset, stick.m_value), stick.m_value, true, true))
|
||||
{
|
||||
|
||||
@ -421,6 +421,14 @@ struct Button
|
||||
}
|
||||
};
|
||||
|
||||
struct ButtonExternal
|
||||
{
|
||||
u32 m_offset = 0;
|
||||
u32 m_outKeyCode = 0;
|
||||
u16 m_value = 0;
|
||||
bool m_pressed = false;
|
||||
};
|
||||
|
||||
struct AnalogStick
|
||||
{
|
||||
u32 m_offset = 0;
|
||||
@ -442,6 +450,12 @@ struct AnalogStick
|
||||
{}
|
||||
};
|
||||
|
||||
struct AnalogStickExternal
|
||||
{
|
||||
u32 m_offset = 0;
|
||||
u16 m_value = 128;
|
||||
};
|
||||
|
||||
struct AnalogSensor
|
||||
{
|
||||
u32 m_offset = 0;
|
||||
@ -519,8 +533,8 @@ struct Pad
|
||||
std::array<AnalogSensor, 4> m_sensors{};
|
||||
std::array<VibrateMotor, 2> m_vibrate_motors{};
|
||||
|
||||
std::vector<Button> m_buttons_external;
|
||||
std::array<AnalogStick, 4> m_sticks_external{};
|
||||
std::vector<ButtonExternal> m_buttons_external;
|
||||
std::array<AnalogStickExternal, 4> m_sticks_external{};
|
||||
|
||||
std::vector<std::shared_ptr<Pad>> copilots;
|
||||
|
||||
|
||||
@ -341,7 +341,7 @@ namespace rsx
|
||||
continue;
|
||||
}
|
||||
|
||||
for (const Button& button : pad->m_buttons_external)
|
||||
for (const ButtonExternal& button : pad->m_buttons_external)
|
||||
{
|
||||
pad_button button_id = pad_button::pad_button_max_enum;
|
||||
if (button.m_offset == CELL_PAD_BTN_OFFSET_DIGITAL1)
|
||||
@ -418,7 +418,7 @@ namespace rsx
|
||||
break;
|
||||
}
|
||||
|
||||
for (const AnalogStick& stick : pad->m_sticks_external)
|
||||
for (const AnalogStickExternal& stick : pad->m_sticks_external)
|
||||
{
|
||||
pad_button button_id = pad_button::pad_button_max_enum;
|
||||
pad_button release_id = pad_button::pad_button_max_enum;
|
||||
|
||||
@ -313,7 +313,7 @@ void pad_thread::apply_copilots()
|
||||
for (usz i = 0; i < pad->m_buttons.size(); i++)
|
||||
{
|
||||
const Button& src = pad->m_buttons[i];
|
||||
Button& dst = pad->m_buttons_external[i];
|
||||
ButtonExternal& dst = pad->m_buttons_external[i];
|
||||
|
||||
dst.m_offset = src.m_offset;
|
||||
dst.m_outKeyCode = src.m_outKeyCode;
|
||||
@ -324,7 +324,7 @@ void pad_thread::apply_copilots()
|
||||
for (usz i = 0; i < pad->m_sticks.size(); i++)
|
||||
{
|
||||
const AnalogStick& src = pad->m_sticks[i];
|
||||
AnalogStick& dst = pad->m_sticks_external[i];
|
||||
AnalogStickExternal& dst = pad->m_sticks_external[i];
|
||||
|
||||
dst.m_offset = src.m_offset;
|
||||
dst.m_value = src.m_value;
|
||||
@ -343,7 +343,7 @@ void pad_thread::apply_copilots()
|
||||
continue;
|
||||
}
|
||||
|
||||
for (Button& button : pad->m_buttons_external)
|
||||
for (ButtonExternal& button : pad->m_buttons_external)
|
||||
{
|
||||
for (const Button& other : copilot->m_buttons)
|
||||
{
|
||||
@ -366,7 +366,7 @@ void pad_thread::apply_copilots()
|
||||
}
|
||||
|
||||
// Merge sticks
|
||||
for (AnalogStick& stick : pad->m_sticks_external)
|
||||
for (AnalogStickExternal& stick : pad->m_sticks_external)
|
||||
{
|
||||
f32 accumulated_value = normalize(stick.m_value);
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user