Merge pull request #26126 from stephan49/fix-pipewire-unlock-error
[xbmc.git] / xbmc / cores / RetroPlayer / RetroPlayerInput.cpp
blob70f6242b9feaba62905a042e0b3464d14dc4d680
1 /*
2 * Copyright (C) 2017-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
9 #include "RetroPlayerInput.h"
11 #include "cores/RetroPlayer/process/RPProcessInfo.h"
12 #include "cores/RetroPlayer/rendering/RenderContext.h"
13 #include "peripherals/Peripherals.h"
14 #include "peripherals/events/EventPollHandle.h"
15 #include "utils/log.h"
17 using namespace KODI;
18 using namespace RETRO;
20 CRetroPlayerInput::CRetroPlayerInput(PERIPHERALS::CPeripherals& peripheralManager,
21 CRPProcessInfo& processInfo,
22 GAME::GameClientPtr gameClient)
23 : m_peripheralManager(peripheralManager),
24 m_processInfo(processInfo),
25 m_gameClient(std::move(gameClient))
27 CLog::Log(LOGDEBUG, "RetroPlayer[INPUT]: Initializing input");
29 m_inputPollHandle = m_peripheralManager.RegisterEventPoller();
32 CRetroPlayerInput::~CRetroPlayerInput()
34 CLog::Log(LOGDEBUG, "RetroPlayer[INPUT]: Deinitializing input");
36 m_inputPollHandle.reset();
39 void CRetroPlayerInput::StartAgentManager()
41 if (!m_bAgentManagerStarted)
43 m_bAgentManagerStarted = true;
44 m_processInfo.GetRenderContext().StartAgentInput(m_gameClient);
48 void CRetroPlayerInput::StopAgentManager()
50 if (m_bAgentManagerStarted)
52 m_bAgentManagerStarted = false;
53 m_processInfo.GetRenderContext().StopAgentInput();
57 void CRetroPlayerInput::SetSpeed(double speed)
59 if (speed != 0)
60 m_inputPollHandle->Activate();
61 else
62 m_inputPollHandle->Deactivate();
65 void CRetroPlayerInput::EnableInput(bool bEnabled)
67 m_bEnabled = bEnabled;
70 void CRetroPlayerInput::PollInput()
72 m_inputPollHandle->HandleEvents(true);