StripSpaces: only strip spaces

StripWhitespace maintains old behavior
This commit is contained in:
Shawn Hoffman
2022-07-19 15:13:26 -07:00
parent e4ff49769c
commit f92541fbd9
20 changed files with 44 additions and 32 deletions

View File

@ -41,7 +41,7 @@ std::string GetDeviceName(const LPDIRECTINPUTDEVICE8 device)
HRESULT hr = device->GetProperty(DIPROP_PRODUCTNAME, &str.diph);
if (SUCCEEDED(hr))
{
result = StripSpaces(WStringToUTF8(str.wsz));
result = StripWhitespace(WStringToUTF8(str.wsz));
}
else
{

View File

@ -139,7 +139,7 @@ static std::string GetDeviceRefName(IOHIDDeviceRef inIOHIDDeviceRef)
{
const NSString* name = reinterpret_cast<const NSString*>(
IOHIDDeviceGetProperty(inIOHIDDeviceRef, CFSTR(kIOHIDProductKey)));
return (name != nullptr) ? std::string(StripSpaces([name UTF8String])) : "Unknown device";
return (name != nullptr) ? std::string(StripWhitespace([name UTF8String])) : "Unknown device";
}
static void DeviceRemovalCallback(void* inContext, IOReturn inResult, void* inSender,

View File

@ -164,7 +164,7 @@ std::string Joystick::Button::GetName() const
{
std::ostringstream s;
s << IOHIDElementGetUsage(m_element);
return std::string("Button ").append(StripSpaces(s.str()));
return std::string("Button ").append(StripWhitespace(s.str()));
}
Joystick::Axis::Axis(IOHIDElementRef element, IOHIDDeviceRef device, direction dir)
@ -210,7 +210,7 @@ Joystick::Axis::Axis(IOHIDElementRef element, IOHIDDeviceRef device, direction d
std::ostringstream s;
s << "CK-";
s << elementCookie;
description = StripSpaces(s.str());
description = StripWhitespace(s.str());
break;
}
}

View File

@ -272,7 +272,7 @@ void PopulateDevices()
}
Joystick::Joystick(SDL_Joystick* const joystick, const int sdl_index)
: m_joystick(joystick), m_name(StripSpaces(GetJoystickName(sdl_index)))
: m_joystick(joystick), m_name(StripWhitespace(GetJoystickName(sdl_index)))
{
// really bad HACKS:
// to not use SDL for an XInput device

View File

@ -784,7 +784,7 @@ void PopulateDevices()
if (SUCCEEDED(hr = rgc2->get_DisplayName(&hstr)) && hstr)
{
device_name =
StripSpaces(WStringToUTF8(g_WindowsGetStringRawBuffer_address(hstr, nullptr)));
StripWhitespace(WStringToUTF8(g_WindowsGetStringRawBuffer_address(hstr, nullptr)));
}
}

View File

@ -52,7 +52,7 @@ protected:
{
if (const char* code_name = libevdev_event_code_get_name(EV_KEY, m_code))
{
const auto name = StripSpaces(code_name);
const auto name = StripWhitespace(code_name);
for (auto remove_prefix : {"BTN_", "KEY_"})
{
@ -441,7 +441,7 @@ bool evdevDevice::AddNode(std::string devnode, int fd, libevdev* dev)
m_nodes.emplace_back(Node{std::move(devnode), fd, dev});
// Take on the alphabetically first name.
const auto potential_new_name = StripSpaces(libevdev_get_name(dev));
const auto potential_new_name = StripWhitespace(libevdev_get_name(dev));
if (m_name.empty() || potential_new_name < m_name)
m_name = potential_new_name;