mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-02-19 03:39:54 +00:00
USB: GunCon3 updates
-Process the mouse buttons even when x/y_max aren't yet determined. -Allows to start the calibration without shaking the mouse before. -Extend support to 4 players. The games can't use more than 2, but it allows more flexibility to mix DS3 and GC3. -Avoid OOB for unsupported Pads
This commit is contained in:
parent
58d27a9438
commit
a1d2a72a78
@ -220,6 +220,13 @@ void usb_device_guncon3::interrupt_transfer(u32 buf_size, u8* buf, u32 endpoint,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (m_controller_index >= g_cfg_guncon3.players.size())
|
||||||
|
{
|
||||||
|
guncon3_log.warning("GunCon3 controllers are only supported for Player1 to Player%d", g_cfg_guncon3.players.size());
|
||||||
|
guncon3_encode(&gc, buf, m_key.data());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const auto input_callback = [&gc](guncon3_btn btn, u16 value, bool pressed)
|
const auto input_callback = [&gc](guncon3_btn btn, u16 value, bool pressed)
|
||||||
{
|
{
|
||||||
if (!pressed)
|
if (!pressed)
|
||||||
@ -261,15 +268,18 @@ void usb_device_guncon3::interrupt_transfer(u32 buf_size, u8* buf, u32 endpoint,
|
|||||||
auto& mouse_handler = g_fxo->get<MouseHandlerBase>();
|
auto& mouse_handler = g_fxo->get<MouseHandlerBase>();
|
||||||
std::lock_guard mouse_lock(mouse_handler.mutex);
|
std::lock_guard mouse_lock(mouse_handler.mutex);
|
||||||
|
|
||||||
mouse_handler.Init(2);
|
mouse_handler.Init(4);
|
||||||
|
|
||||||
if (m_controller_index >= mouse_handler.GetMice().size())
|
const u32 mouse_index = g_cfg.io.mouse == mouse_handler::basic ? 0 : m_controller_index;
|
||||||
|
if (mouse_index >= mouse_handler.GetMice().size())
|
||||||
{
|
{
|
||||||
guncon3_encode(&gc, buf, m_key.data());
|
guncon3_encode(&gc, buf, m_key.data());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Mouse& mouse_data = ::at32(mouse_handler.GetMice(), m_controller_index);
|
const Mouse& mouse_data = ::at32(mouse_handler.GetMice(), mouse_index);
|
||||||
|
cfg->handle_input(mouse_data, input_callback);
|
||||||
|
|
||||||
if (mouse_data.x_max <= 0 || mouse_data.y_max <= 0)
|
if (mouse_data.x_max <= 0 || mouse_data.y_max <= 0)
|
||||||
{
|
{
|
||||||
guncon3_encode(&gc, buf, m_key.data());
|
guncon3_encode(&gc, buf, m_key.data());
|
||||||
@ -279,8 +289,6 @@ void usb_device_guncon3::interrupt_transfer(u32 buf_size, u8* buf, u32 endpoint,
|
|||||||
// Expand 0..+wh to -32767..+32767
|
// Expand 0..+wh to -32767..+32767
|
||||||
gc.gun_x = (mouse_data.x_pos * USHRT_MAX / mouse_data.x_max) - SHRT_MAX;
|
gc.gun_x = (mouse_data.x_pos * USHRT_MAX / mouse_data.x_max) - SHRT_MAX;
|
||||||
gc.gun_y = (mouse_data.y_pos * -USHRT_MAX / mouse_data.y_max) + SHRT_MAX;
|
gc.gun_y = (mouse_data.y_pos * -USHRT_MAX / mouse_data.y_max) + SHRT_MAX;
|
||||||
|
|
||||||
cfg->handle_input(mouse_data, input_callback);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
guncon3_encode(&gc, buf, m_key.data());
|
guncon3_encode(&gc, buf, m_key.data());
|
||||||
|
@ -42,9 +42,9 @@ struct cfg_gc3 final : public emulated_pad_config<guncon3_btn>
|
|||||||
cfg_pad_btn<guncon3_btn> bs_y{this, "B-stick Y-Axis", guncon3_btn::bs_y, pad_button::rs_y};
|
cfg_pad_btn<guncon3_btn> bs_y{this, "B-stick Y-Axis", guncon3_btn::bs_y, pad_button::rs_y};
|
||||||
};
|
};
|
||||||
|
|
||||||
struct cfg_guncon3 final : public emulated_pads_config<cfg_gc3, 2>
|
struct cfg_guncon3 final : public emulated_pads_config<cfg_gc3, 4>
|
||||||
{
|
{
|
||||||
cfg_guncon3() : emulated_pads_config<cfg_gc3, 2>("guncon3") {};
|
cfg_guncon3() : emulated_pads_config<cfg_gc3, 4>("guncon3") {};
|
||||||
};
|
};
|
||||||
|
|
||||||
extern cfg_guncon3 g_cfg_guncon3;
|
extern cfg_guncon3 g_cfg_guncon3;
|
||||||
|
@ -191,7 +191,7 @@ void pad_thread::Init()
|
|||||||
}
|
}
|
||||||
|
|
||||||
m_pads[i]->is_fake_pad = (g_cfg.io.move == move_handler::fake && i >= (static_cast<u32>(CELL_PAD_MAX_PORT_NUM) - static_cast<u32>(CELL_GEM_MAX_NUM)))
|
m_pads[i]->is_fake_pad = (g_cfg.io.move == move_handler::fake && i >= (static_cast<u32>(CELL_PAD_MAX_PORT_NUM) - static_cast<u32>(CELL_GEM_MAX_NUM)))
|
||||||
|| (m_pads[i]->m_class_type >= CELL_PAD_FAKE_TYPE_FIRST && m_pads[i]->m_class_type <= CELL_PAD_FAKE_TYPE_LAST);
|
|| (m_pads[i]->m_class_type >= CELL_PAD_FAKE_TYPE_FIRST && m_pads[i]->m_class_type < CELL_PAD_FAKE_TYPE_LAST);
|
||||||
connect_usb_controller(i, input::get_product_by_vid_pid(m_pads[i]->m_vendor_id, m_pads[i]->m_product_id));
|
connect_usb_controller(i, input::get_product_by_vid_pid(m_pads[i]->m_vendor_id, m_pads[i]->m_product_id));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user