@@ -139,6 +139,8 @@ void ConfigureMotionTouch::SetConfiguration() {
139139 ui->touch_provider ->findData (QString::fromStdString (touch_engine)));
140140 ui->touch_from_button_checkbox ->setChecked (
141141 Settings::values.current_input_profile .use_touch_from_button );
142+ ui->touchpad_checkbox ->setChecked (
143+ Settings::values.current_input_profile .use_touchpad );
142144 touch_from_button_maps = Settings::values.touch_from_button_maps ;
143145 for (const auto & touch_map : touch_from_button_maps) {
144146 ui->touch_from_button_map ->addItem (QString::fromStdString (touch_map.name ));
@@ -164,7 +166,9 @@ void ConfigureMotionTouch::SetConfiguration() {
164166void ConfigureMotionTouch::UpdateUiDisplay () {
165167 const std::string motion_engine = ui->motion_provider ->currentData ().toString ().toStdString ();
166168 const std::string touch_engine = ui->touch_provider ->currentData ().toString ().toStdString ();
167-
169+ ui->touchpad_config_btn ->setEnabled (
170+ ui->touchpad_checkbox ->isChecked ()
171+ );
168172 if (motion_engine == " motion_emu" ) {
169173 ui->motion_sensitivity_label ->setVisible (true );
170174 ui->motion_sensitivity ->setVisible (true );
@@ -229,6 +233,32 @@ void ConfigureMotionTouch::ConnectEvents() {
229233 poll_timer->start (200 ); // Check for new inputs every 200ms
230234 }
231235 });
236+ connect (ui->touchpad_checkbox ,&QCheckBox::checkStateChanged, this , [this ]() {UpdateUiDisplay (); });
237+ connect (ui->touchpad_config_btn , &QPushButton::clicked, this , [this ]() {
238+ if (QMessageBox::information (this , tr (" Information" ),
239+ tr (" After pressing OK, tap the trackpad on the controller"
240+ " that you want to track." ),
241+ QMessageBox::Ok | QMessageBox::Cancel) == QMessageBox::Ok) {
242+ ui->touchpad_config_btn ->setText (tr (" [press touchpad]" ));
243+ ui->touchpad_config_btn ->setFocus ();
244+
245+ input_setter = [this ](const Common::ParamPackage& params) {
246+ tpguid = params.Get (" guid" , " 0" );
247+ tpport = params.Get (" port" , 0 );
248+ tp = params.Get (" touchpad" ,0 );
249+ };
250+
251+ device_pollers =
252+ InputCommon::Polling::GetPollers (InputCommon::Polling::DeviceType::Touchpad);
253+
254+ for (auto & poller : device_pollers) {
255+ poller->Start ();
256+ }
257+
258+ timeout_timer->start (5000 ); // Cancel after 5 seconds
259+ poll_timer->start (200 ); // Check for new inputs every 200ms
260+ }
261+ });
232262 connect (ui->udp_test , &QPushButton::clicked, this , &ConfigureMotionTouch::OnCemuhookUDPTest);
233263 connect (ui->touch_calibration_config , &QPushButton::clicked, this ,
234264 &ConfigureMotionTouch::OnConfigureTouchCalibration);
@@ -253,7 +283,7 @@ void ConfigureMotionTouch::SetPollingResult(const Common::ParamPackage& params,
253283 if (!abort && input_setter) {
254284 (*input_setter)(params);
255285 }
256-
286+ ui-> touchpad_config_btn -> setText ( tr ( " Configure " ));
257287 ui->motion_controller_button ->setText (tr (" Configure" ));
258288 input_setter.reset ();
259289}
@@ -291,7 +321,6 @@ void ConfigureMotionTouch::OnConfigureTouchCalibration() {
291321 " UDP touchpad calibration config success: min_x={}, min_y={}, max_x={}, max_y={}" ,
292322 min_x, min_y, max_x, max_y);
293323 UpdateUiDisplay ();
294- } else {
295324 LOG_ERROR (Frontend, " UDP touchpad calibration config failed" );
296325 }
297326 ui->touch_calibration_config ->setEnabled (true );
@@ -374,12 +403,22 @@ void ConfigureMotionTouch::ApplyConfiguration() {
374403 touch_param.Set (" max_y" , max_y);
375404 }
376405
406+ Common::ParamPackage touchpad_param{};
407+ if (ui->touchpad_checkbox ->isChecked ()) {
408+ touchpad_param.Set (" engine" , " sdl" );
409+ touchpad_param.Set (" guid" , tpguid);
410+ touchpad_param.Set (" port" , tpport);
411+ touchpad_param.Set (" touchpad" ,tp);
412+ }
377413 Settings::values.current_input_profile .motion_device = motion_param.Serialize ();
378414 Settings::values.current_input_profile .touch_device = touch_param.Serialize ();
379415 Settings::values.current_input_profile .use_touch_from_button =
380416 ui->touch_from_button_checkbox ->isChecked ();
381417 Settings::values.current_input_profile .touch_from_button_map_index =
382418 ui->touch_from_button_map ->currentIndex ();
419+ Settings::values.current_input_profile .use_touchpad =
420+ ui->touchpad_checkbox ->isChecked ();
421+ Settings::values.current_input_profile .controller_touch_device = touchpad_param.Serialize ();
383422 Settings::values.touch_from_button_maps = touch_from_button_maps;
384423 Settings::values.current_input_profile .udp_input_address = ui->udp_server ->text ().toStdString ();
385424 Settings::values.current_input_profile .udp_input_port =
0 commit comments