@@ -443,14 +443,67 @@ void pad_thread::operator()()
443443
444444 input_log.notice (" Starting pad threads..." );
445445
446- for (const auto & handler : m_handlers)
446+ #if defined(__APPLE__)
447+ // Let's keep hid handlers on the same thread
448+ std::vector<std::shared_ptr<PadHandlerBase>> hid_handlers;
449+ std::vector<std::shared_ptr<PadHandlerBase>> handlers;
450+
451+ for (const auto & [type, handler] : m_handlers)
447452 {
448- if (handler. first == pad_handler::null )
453+ switch (type )
449454 {
450- continue ;
455+ case pad_handler::null:
456+ break ;
457+ case pad_handler::ds3:
458+ case pad_handler::ds4:
459+ case pad_handler::dualsense:
460+ case pad_handler::skateboard:
461+ case pad_handler::move:
462+ hid_handlers.push_back (handler);
463+ break ;
464+ default :
465+ handlers.push_back (handler);
466+ break ;
451467 }
468+ }
469+
470+ if (!hid_handlers.empty ())
471+ {
472+ threads.push_back (std::make_unique<named_thread<std::function<void ()>>>(" HID Thread" , [handlers = std::move (hid_handlers)]()
473+ {
474+ while (thread_ctrl::state () != thread_state::aborting)
475+ {
476+ if (!pad::g_enabled || !is_input_allowed ())
477+ {
478+ thread_ctrl::wait_for (30'000 );
479+ continue ;
480+ }
481+
482+ for (auto & handler : handlers)
483+ {
484+ handler->process ();
485+ }
452486
453- threads.push_back (std::make_unique<named_thread<std::function<void ()>>>(fmt::format (" %s Thread" , handler.second ->m_type ), [&handler = handler.second , &pad_mode]()
487+ u64 pad_sleep = g_cfg.io .pad_sleep ;
488+
489+ if (Emu.IsPaused ())
490+ {
491+ pad_sleep = std::max<u64 >(pad_sleep, 30'000 );
492+ }
493+
494+ thread_ctrl::wait_for (pad_sleep);
495+ }
496+ }));
497+ }
498+
499+ for (const auto & handler : handlers)
500+ {
501+ #else
502+ for (const auto & [type, handler] : m_handlers)
503+ {
504+ if (type == pad_handler::null) continue ;
505+ #endif
506+ threads.push_back (std::make_unique<named_thread<std::function<void ()>>>(fmt::format (" %s Thread" , handler->m_type ), [handler]()
454507 {
455508 while (thread_ctrl::state () != thread_state::aborting)
456509 {
0 commit comments