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.
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"
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
)
60 m_inputPollHandle
->Activate();
62 m_inputPollHandle
->Deactivate();
65 void CRetroPlayerInput::EnableInput(bool bEnabled
)
67 m_bEnabled
= bEnabled
;
70 void CRetroPlayerInput::PollInput()
72 m_inputPollHandle
->HandleEvents(true);