Create a device class for GunCon3 which is ignored by cellPad

This commit is contained in:
Florin9doi 2024-05-12 11:40:42 +03:00 committed by Megamouse
parent aa8fbf8102
commit 941c87f6d7
6 changed files with 39 additions and 3 deletions

View file

@ -152,6 +152,9 @@ void cellPad_NotifyStateChange(usz index, u64 /*state*/, bool locked)
case CELL_PAD_PCLASS_TYPE_SKATEBOARD:
product = input::get_product_info(input::product_type::ride_skateboard);
break;
case CELL_PAD_FAKE_TYPE_GUNCON3:
product = input::get_product_info(input::product_type::guncon_3);
break;
case CELL_PAD_PCLASS_TYPE_STANDARD:
default:
product = input::get_product_info(input::product_type::playstation_3_controller);

View file

@ -104,7 +104,7 @@ struct cfg_pad final : cfg::node
cfg::uint<0, 100> analog_lerp_factor{ this, "Analog Button Lerp Factor", 100 };
cfg::uint<0, 100> trigger_lerp_factor{ this, "Trigger Lerp Factor", 100 };
cfg::uint<CELL_PAD_PCLASS_TYPE_STANDARD, CELL_PAD_PCLASS_TYPE_SKATEBOARD> device_class_type{ this, "Device Class Type", 0 };
cfg::uint<CELL_PAD_PCLASS_TYPE_STANDARD, CELL_PAD_PCLASS_TYPE_MAX> device_class_type{ this, "Device Class Type", 0 };
cfg::uint<0, 65535> vendor_id{ this, "Vendor ID", 0 };
cfg::uint<0, 65535> product_id{ this, "Product ID", 0 };
};

View file

@ -134,6 +134,11 @@ enum
CELL_PAD_PCLASS_TYPE_DANCEMAT = 0x04,
CELL_PAD_PCLASS_TYPE_NAVIGATION = 0x05,
CELL_PAD_PCLASS_TYPE_SKATEBOARD = 0x8001,
// these are used together with pad->is_fake_pad to capture input events for usbd/gem/move without conflicting with cellPad
CELL_PAD_FAKE_TYPE_GUNCON3 = 0xa000,
CELL_PAD_PCLASS_TYPE_MAX // last item
};
// Profile of a Standard Type Controller

View file

@ -170,7 +170,6 @@ void pad_thread::Init()
cur_pad_handler->Init();
m_pads[i] = std::make_shared<Pad>(handler_type, CELL_PAD_STATUS_DISCONNECTED, pad_settings[i].device_capability, pad_settings[i].device_type);
m_pads[i]->is_fake_pad = (g_cfg.io.move == move_handler::fake && i >= (CELL_PAD_MAX_PORT_NUM - CELL_GEM_MAX_NUM));
if (pad_settings[i].is_ldd_pad)
{
@ -188,6 +187,9 @@ void pad_thread::Init()
input_log.notice("Pad %d: device='%s', handler=%s, VID=0x%x, PID=0x%x, class_type=0x%x, class_profile=0x%x",
i, cfg->device.to_string(), m_pads[i]->m_pad_handler, m_pads[i]->m_vendor_id, m_pads[i]->m_product_id, m_pads[i]->m_class_type, m_pads[i]->m_class_profile);
}
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_GUNCON3;
connect_usb_controller(i, input::get_product_by_vid_pid(m_pads[i]->m_vendor_id, m_pads[i]->m_product_id));
}
}

View file

@ -17,12 +17,14 @@ namespace input
harmonix_rockband_drum_kit_2,
rock_revolution_drum_kit,
ps_move_navigation,
ride_skateboard
ride_skateboard,
guncon_3,
};
enum vendor_id
{
sony_corp = 0x054C, // Sony Corp.
namco = 0x0B9A, // Namco
sony_cea = 0x12BA, // Sony Computer Entertainment America
konami_de = 0x1CCF, // Konami Digital Entertainment
};
@ -40,6 +42,7 @@ namespace input
ps_move_navigation = 0x042F, // PlayStation Move navigation controller
dance_dance_revolution_mat = 0x1010, // Dance Dance Revolution Dance Mat Controller
ride_skateboard = 0x0400, // Tony Hawk RIDE Skateboard Controller
guncon_3 = 0x0800, // GunCon 3 Controller
};
struct product_info
@ -233,6 +236,16 @@ namespace input
.capabilites = CELL_PAD_CAPABILITY_PS3_CONFORMITY | CELL_PAD_CAPABILITY_PRESS_MODE | CELL_PAD_CAPABILITY_SENSOR_MODE
};
}
case product_type::guncon_3:
{
return product_info{
.type = type,
.vendor_id = vendor_id::namco,
.product_id = product_id::guncon_3,
.pclass_profile = 0x0,
.capabilites = 0x0
};
}
case product_type::playstation_3_controller:
default: // GCC doesn't like it when there is no return value if if all enum values are covered
{
@ -305,6 +318,13 @@ namespace input
get_product_info(product_type::ride_skateboard)
};
}
case CELL_PAD_FAKE_TYPE_GUNCON3:
{
return
{
get_product_info(product_type::guncon_3)
};
}
}
}
};

View file

@ -181,6 +181,7 @@ pad_settings_dialog::pad_settings_dialog(std::shared_ptr<gui_settings> gui_setti
ui->chooseClass->addItem(tr("Dance Mat"), u32{CELL_PAD_PCLASS_TYPE_DANCEMAT});
ui->chooseClass->addItem(tr("PS Move Navigation"), u32{CELL_PAD_PCLASS_TYPE_NAVIGATION});
ui->chooseClass->addItem(tr("Skateboard"), u32{CELL_PAD_PCLASS_TYPE_SKATEBOARD});
ui->chooseClass->addItem(tr("GunCon 3"), u32{CELL_PAD_FAKE_TYPE_GUNCON3});
connect(ui->chooseClass, QOverload<int>::of(&QComboBox::currentIndexChanged), this, [this](int index)
{
@ -1682,6 +1683,11 @@ void pad_settings_dialog::HandleDeviceClassChange(u32 class_id) const
ui->chooseProduct->addItem(tr("RIDE Skateboard", "Tony Hawk RIDE Skateboard Controller"), static_cast<int>(product.type));
break;
}
case input::product_type::guncon_3:
{
ui->chooseProduct->addItem(tr("GunCon 3", "GunCon 3 Controller"), static_cast<int>(product.type));
break;
}
}
}
}