-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
47 changed files
with
2,433 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
set(SOURCES GameAgentManager.cpp | ||
set(SOURCES GameAgent.cpp | ||
GameAgentManager.cpp | ||
) | ||
|
||
set(HEADERS GameAgentManager.h | ||
set(HEADERS GameAgent.h | ||
GameAgentManager.h | ||
) | ||
|
||
core_add_library(games_agents) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
/* | ||
* Copyright (C) 2017-2023 Team Kodi | ||
* This file is part of Kodi - https://kodi.tv | ||
* | ||
* SPDX-License-Identifier: GPL-2.0-or-later | ||
* See LICENSES/README.md for more information. | ||
*/ | ||
|
||
#include "GameAgent.h" | ||
|
||
#include "games/agents/input/GameAgentJoystick.h" | ||
#include "games/controllers/Controller.h" | ||
#include "games/controllers/ControllerLayout.h" | ||
#include "peripherals/devices/Peripheral.h" | ||
|
||
using namespace KODI; | ||
using namespace GAME; | ||
|
||
CGameAgent::CGameAgent(PERIPHERALS::PeripheralPtr peripheral) | ||
: m_peripheral(std::move(peripheral)), | ||
m_joystick(std::make_unique<CGameAgentJoystick>(m_peripheral)) | ||
{ | ||
Initialize(); | ||
} | ||
|
||
CGameAgent::~CGameAgent() | ||
{ | ||
Deinitialize(); | ||
} | ||
|
||
void CGameAgent::Initialize() | ||
{ | ||
m_joystick->Initialize(); | ||
} | ||
|
||
void CGameAgent::Deinitialize() | ||
{ | ||
m_joystick->Deinitialize(); | ||
} | ||
|
||
std::string CGameAgent::GetPeripheralName() const | ||
{ | ||
std::string deviceName = m_peripheral->DeviceName(); | ||
|
||
// Handle unknown device name | ||
if (deviceName.empty()) | ||
{ | ||
ControllerPtr controller = m_peripheral->ControllerProfile(); | ||
if (controller) | ||
deviceName = controller->Layout().Label(); | ||
} | ||
|
||
return deviceName; | ||
} | ||
|
||
const std::string& CGameAgent::GetPeripheralLocation() const | ||
{ | ||
return m_peripheral->Location(); | ||
} | ||
|
||
ControllerPtr CGameAgent::GetController() const | ||
{ | ||
// Use joystick controller if joystick is initialized | ||
ControllerPtr controller = m_joystick->Appearance(); | ||
if (controller) | ||
return controller; | ||
|
||
// Use peripheral controller if joystick is deinitialized | ||
return m_peripheral->ControllerProfile(); | ||
} | ||
|
||
CDateTime CGameAgent::LastActive() const | ||
{ | ||
return m_peripheral->LastActive(); | ||
} | ||
|
||
float CGameAgent::GetActivation() const | ||
{ | ||
return m_joystick->GetActivation(); | ||
} |
Oops, something went wrong.