Skip to content

Commit

Permalink
Merge pull request #187 from AlwinEsch/Matrix-change
Browse files Browse the repository at this point in the history
[Matrix] remove own StringUtils and do via new dev kit headers about
  • Loading branch information
AlwinEsch authored Oct 8, 2020
2 parents a1b2b48 + d77c409 commit 79d166a
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 270 deletions.
6 changes: 2 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ set(JOYSTICK_SOURCES src/addon.cpp
src/storage/xml/ButtonMapXml.cpp
src/storage/xml/DatabaseXml.cpp
src/storage/xml/DeviceXml.cpp
src/storage/xml/JoystickFamiliesXml.cpp
src/utils/StringUtils.cpp)
src/storage/xml/JoystickFamiliesXml.cpp)

set(JOYSTICK_HEADERS src/addon.h
src/api/IJoystickInterface.h
Expand Down Expand Up @@ -107,8 +106,7 @@ set(JOYSTICK_HEADERS src/addon.h
src/storage/xml/DeviceXml.h
src/storage/xml/JoystickFamiliesXml.h
src/storage/xml/JoystickFamilyDefinitions.h
src/utils/CommonMacros.h
src/utils/StringUtils.h)
src/utils/CommonMacros.h)

if(CORE_SYSTEM_NAME MATCHES windows)
list(APPEND JOYSTICK_SOURCES src/utils/windows/CharsetConverter.cpp)
Expand Down
2 changes: 1 addition & 1 deletion peripheral.joystick/addon.xml.in
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<addon
id="peripheral.joystick"
version="1.7.0"
version="1.7.1"
name="Joystick Support"
provider-name="Team Kodi">
<requires>@ADDON_DEPENDS@</requires>
Expand Down
7 changes: 4 additions & 3 deletions src/api/Joystick.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
#include "log/Log.h"
#include "settings/Settings.h"
#include "utils/CommonMacros.h"
#include "utils/StringUtils.h"

#include <kodi/tools/StringUtils.h>

using namespace JOYSTICK;

Expand All @@ -40,10 +41,10 @@ bool CJoystick::Equals(const CJoystick* rhs) const

void CJoystick::SetName(const std::string& strName)
{
std::string strSanitizedFilename = StringUtils::MakeSafeString(strName);
std::string strSanitizedFilename = kodi::tools::StringUtils::MakeSafeString(strName);

// Remove Bluetooth MAC address as seen in Sony Playstation controllers
StringUtils::RemoveMACAddress(strSanitizedFilename);
strSanitizedFilename = kodi::tools::StringUtils::RemoveMACAddress(strSanitizedFilename);

kodi::addon::Joystick::SetName(strSanitizedFilename);
}
Expand Down
4 changes: 2 additions & 2 deletions src/storage/JustABunchOfFiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
#include "StorageUtils.h"
#include "filesystem/DirectoryUtils.h"
#include "log/Log.h"
#include "utils/StringUtils.h"

#include <algorithm>
#include <kodi/tools/StringUtils.h>

using namespace JOYSTICK;

Expand Down Expand Up @@ -306,7 +306,7 @@ void CJustABunchOfFiles::IndexDirectory(const std::string& path, unsigned int fo
items.erase(std::remove_if(items.begin(), items.end(),
[this](const kodi::vfs::CDirEntry& item)
{
return !item.IsFolder() && !StringUtils::EndsWith(item.Path(), this->m_strExtension);
return !item.IsFolder() && !kodi::tools::StringUtils::EndsWith(item.Path(), this->m_strExtension);
}), items.end());

m_directoryCache.UpdateDirectory(path, items);
Expand Down
7 changes: 4 additions & 3 deletions src/storage/StorageManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@
#include "storage/api/DatabaseJoystickAPI.h"
//#include "storage/retroarch/DatabaseRetroarch.h" // TODO
#include "storage/xml/DatabaseXml.h"
#include "utils/StringUtils.h"

#include "addon.h"

#include <kodi/tools/StringUtils.h>

using namespace JOYSTICK;

// Resources folder for add-on and user data
Expand Down Expand Up @@ -59,8 +60,8 @@ bool CStorageManager::Initialize(CPeripheralJoystick* peripheralLib)
return false;

// Remove slash at end
StringUtils::TrimRight(strUserPath, "\\/");
StringUtils::TrimRight(strAddonPath, "\\/");
kodi::tools::StringUtils::TrimRight(strUserPath, "\\/");
kodi::tools::StringUtils::TrimRight(strAddonPath, "\\/");

strUserPath += "/" USER_RESOURCES_FOLDER;
strAddonPath += "/" ADDON_RESOURCES_FOLDER;
Expand Down
16 changes: 8 additions & 8 deletions src/storage/StorageUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
#include "Device.h"
#include "filesystem/DirectoryUtils.h"
#include "log/Log.h"
#include "utils/StringUtils.h"

#include <algorithm>
#include <kodi/tools/StringUtils.h>
#include <set>
#include <sstream>
#include <stdio.h>
Expand Down Expand Up @@ -43,7 +43,7 @@ bool CStorageUtils::EnsureDirectoryExists(const std::string& path)

std::string CStorageUtils::RootFileName(const kodi::addon::Joystick& device)
{
std::string baseFilename = StringUtils::MakeSafeUrl(device.Name());
std::string baseFilename = kodi::tools::StringUtils::MakeSafeUrl(device.Name());

// Limit filename to a sane number of characters.
if (baseFilename.length() > 50)
Expand Down Expand Up @@ -84,15 +84,15 @@ std::string CStorageUtils::FormatHexString(int iVal)
if (iVal > 65536)
iVal = 65536;

return StringUtils::Format("%04X", iVal);
return kodi::tools::StringUtils::Format("%04X", iVal);
};

std::string CStorageUtils::PrimitiveToString(const kodi::addon::DriverPrimitive& primitive)
{
switch (primitive.Type())
{
case JOYSTICK_DRIVER_PRIMITIVE_TYPE_BUTTON:
return StringUtils::Format("button %u", primitive.DriverIndex());
return kodi::tools::StringUtils::Format("button %u", primitive.DriverIndex());
case JOYSTICK_DRIVER_PRIMITIVE_TYPE_HAT_DIRECTION:
switch (primitive.HatDirection())
{
Expand All @@ -109,15 +109,15 @@ std::string CStorageUtils::PrimitiveToString(const kodi::addon::DriverPrimitive&
}
break;
case JOYSTICK_DRIVER_PRIMITIVE_TYPE_SEMIAXIS:
return StringUtils::Format("axis %s%u",
return kodi::tools::StringUtils::Format("axis %s%u",
primitive.SemiAxisDirection() == JOYSTICK_DRIVER_SEMIAXIS_POSITIVE ? "+" : "-",
primitive.DriverIndex());
case JOYSTICK_DRIVER_PRIMITIVE_TYPE_MOTOR:
return StringUtils::Format("motor %u", primitive.DriverIndex());
return kodi::tools::StringUtils::Format("motor %u", primitive.DriverIndex());
case JOYSTICK_DRIVER_PRIMITIVE_TYPE_KEY:
return StringUtils::Format("key \"%s\"", primitive.Keycode().c_str());
return kodi::tools::StringUtils::Format("key \"%s\"", primitive.Keycode().c_str());
case JOYSTICK_DRIVER_PRIMITIVE_TYPE_MOUSE_BUTTON:
return StringUtils::Format("mouse button %u", primitive.MouseIndex());
return kodi::tools::StringUtils::Format("mouse button %u", primitive.MouseIndex());
case JOYSTICK_DRIVER_PRIMITIVE_TYPE_RELPOINTER_DIRECTION:
switch (primitive.RelPointerDirection())
{
Expand Down
174 changes: 0 additions & 174 deletions src/utils/StringUtils.cpp

This file was deleted.

Loading

0 comments on commit 79d166a

Please sign in to comment.