Stop using identifiers with __ prefix

This commit is contained in:
Chris Thrasher 2024-09-16 17:50:17 -04:00
parent 35653dacc5
commit 119ea42e0a
No known key found for this signature in database
GPG Key ID: 56FB686C9DFC8E2C
9 changed files with 26 additions and 26 deletions

View File

@ -41,7 +41,7 @@
namespace sf::priv namespace sf::priv
{ {
using IOHIDElements = std::vector<CFPtr<__IOHIDElement>>; using IOHIDElements = std::vector<CFPtr<IOHIDElementRef>>;
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief sf::priv::InputImpl helper /// \brief sf::priv::InputImpl helper
@ -247,7 +247,7 @@ private:
/// \return a retained, non-empty __CFSet pointer of IOHIDDeviceRef or a null pointer /// \return a retained, non-empty __CFSet pointer of IOHIDDeviceRef or a null pointer
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
CFPtr<const __CFSet> copyDevices(std::uint32_t page, std::uint32_t usage); CFPtr<CFSetRef> copyDevices(std::uint32_t page, std::uint32_t usage);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Check if a key is pressed /// \brief Check if a key is pressed
@ -287,7 +287,7 @@ private:
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
// Member data // Member data
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
CFPtr<__IOHIDManager> m_manager{}; ///< Underlying HID Manager CFPtr<IOHIDManagerRef> m_manager; ///< Underlying HID Manager
bool m_keysInitialized{}; ///< Has initializeKeyboard been called at least once? bool m_keysInitialized{}; ///< Has initializeKeyboard been called at least once?
EnumArray<Keyboard::Scancode, IOHIDElements, Keyboard::ScancodeCount> m_keys; ///< All the keys on any connected keyboard EnumArray<Keyboard::Scancode, IOHIDElements, Keyboard::ScancodeCount> m_keys; ///< All the keys on any connected keyboard
EnumArray<Keyboard::Key, Keyboard::Scancode, Keyboard::KeyCount> m_keyToScancodeMapping{}; ///< Mapping from Key to Scancode EnumArray<Keyboard::Key, Keyboard::Scancode, Keyboard::KeyCount> m_keyToScancodeMapping{}; ///< Mapping from Key to Scancode

View File

@ -78,11 +78,11 @@ CFDictionaryRef HIDInputManager::copyDevicesMask(std::uint32_t page, std::uint32
&kCFTypeDictionaryValueCallBacks); &kCFTypeDictionaryValueCallBacks);
// Add the page value. // Add the page value.
auto value = CFPtr<const __CFNumber>(CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &page)); auto value = CFPtr<CFNumberRef>(CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &page));
CFDictionarySetValue(dict, CFSTR(kIOHIDDeviceUsagePageKey), value.get()); CFDictionarySetValue(dict, CFSTR(kIOHIDDeviceUsagePageKey), value.get());
// Add the usage value (which is only valid if page value exists). // Add the usage value (which is only valid if page value exists).
value = CFPtr<const __CFNumber>(CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &usage)); value = CFPtr<CFNumberRef>(CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &usage));
CFDictionarySetValue(dict, CFSTR(kIOHIDDeviceUsageKey), value.get()); CFDictionarySetValue(dict, CFSTR(kIOHIDDeviceUsageKey), value.get());
return dict; return dict;
@ -710,7 +710,7 @@ String HIDInputManager::getDescription(Keyboard::Scancode code)
HIDInputManager::HIDInputManager() HIDInputManager::HIDInputManager()
{ {
// Create an HID Manager reference // Create an HID Manager reference
m_manager = CFPtr<__IOHIDManager>(IOHIDManagerCreate(kCFAllocatorDefault, kIOHIDOptionsTypeNone)); m_manager = CFPtr<IOHIDManagerRef>(IOHIDManagerCreate(kCFAllocatorDefault, kIOHIDOptionsTypeNone));
const IOReturn openStatus = IOHIDManagerOpen(m_manager.get(), kIOHIDOptionsTypeNone); const IOReturn openStatus = IOHIDManagerOpen(m_manager.get(), kIOHIDOptionsTypeNone);
if (openStatus != kIOReturnSuccess) if (openStatus != kIOReturnSuccess)
@ -770,8 +770,7 @@ void HIDInputManager::initializeKeyboard()
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void HIDInputManager::loadKeyboard(IOHIDDeviceRef keyboard) void HIDInputManager::loadKeyboard(IOHIDDeviceRef keyboard)
{ {
const auto underlying = CFPtr<const __CFArray>( const auto underlying = CFPtr<CFArrayRef>(IOHIDDeviceCopyMatchingElements(keyboard, nullptr, kIOHIDOptionsTypeNone));
IOHIDDeviceCopyMatchingElements(keyboard, nullptr, kIOHIDOptionsTypeNone));
if ((underlying == nullptr) || (CFArrayGetCount(underlying.get()) == 0)) if ((underlying == nullptr) || (CFArrayGetCount(underlying.get()) == 0))
{ {
err() << "Detected a keyboard without any keys." << std::endl; err() << "Detected a keyboard without any keys." << std::endl;
@ -809,7 +808,7 @@ void HIDInputManager::buildMappings()
m_scancodeToKeyMapping.fill(Keyboard::Key::Unknown); m_scancodeToKeyMapping.fill(Keyboard::Key::Unknown);
// Get the current keyboard layout // Get the current keyboard layout
const auto tis = CFPtr<__TISInputSource>(TISCopyCurrentKeyboardLayoutInputSource()); const auto tis = CFPtr<TISInputSourceRef>(TISCopyCurrentKeyboardLayoutInputSource());
const auto* layoutData = static_cast<CFDataRef>(TISGetInputSourceProperty(tis.get(), kTISPropertyUnicodeKeyLayoutData)); const auto* layoutData = static_cast<CFDataRef>(TISGetInputSourceProperty(tis.get(), kTISPropertyUnicodeKeyLayoutData));
if (layoutData == nullptr) if (layoutData == nullptr)
@ -927,14 +926,14 @@ void HIDInputManager::freeUp()
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
CFPtr<const __CFSet> HIDInputManager::copyDevices(std::uint32_t page, std::uint32_t usage) CFPtr<CFSetRef> HIDInputManager::copyDevices(std::uint32_t page, std::uint32_t usage)
{ {
// Filter and keep only the requested devices // Filter and keep only the requested devices
const auto mask = CFPtr<const __CFDictionary>(copyDevicesMask(page, usage)); const auto mask = CFPtr<CFDictionaryRef>(copyDevicesMask(page, usage));
IOHIDManagerSetDeviceMatching(m_manager.get(), mask.get()); IOHIDManagerSetDeviceMatching(m_manager.get(), mask.get());
auto devices = CFPtr<const __CFSet>(IOHIDManagerCopyDevices(m_manager.get())); auto devices = CFPtr<CFSetRef>(IOHIDManagerCopyDevices(m_manager.get()));
if (devices == nullptr) if (devices == nullptr)
return nullptr; return nullptr;

View File

@ -61,9 +61,9 @@ unsigned int HIDJoystickManager::getJoystickCount()
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
CFPtr<const __CFSet> HIDJoystickManager::copyJoysticks() CFPtr<CFSetRef> HIDJoystickManager::copyJoysticks()
{ {
return CFPtr<const __CFSet>(IOHIDManagerCopyDevices(m_manager)); return CFPtr<CFSetRef>(IOHIDManagerCopyDevices(m_manager));
} }
@ -72,14 +72,14 @@ HIDJoystickManager::HIDJoystickManager()
{ {
m_manager = IOHIDManagerCreate(kCFAllocatorDefault, kIOHIDOptionsTypeNone); m_manager = IOHIDManagerCreate(kCFAllocatorDefault, kIOHIDOptionsTypeNone);
const auto mask0 = CFPtr<const __CFDictionary>( const auto mask0 = CFPtr<CFDictionaryRef>(
HIDInputManager::copyDevicesMask(kHIDPage_GenericDesktop, kHIDUsage_GD_Joystick)); HIDInputManager::copyDevicesMask(kHIDPage_GenericDesktop, kHIDUsage_GD_Joystick));
const auto mask1 = CFPtr<const __CFDictionary>( const auto mask1 = CFPtr<CFDictionaryRef>(
HIDInputManager::copyDevicesMask(kHIDPage_GenericDesktop, kHIDUsage_GD_GamePad)); HIDInputManager::copyDevicesMask(kHIDPage_GenericDesktop, kHIDUsage_GD_GamePad));
std::array maskArray = {mask0.get(), mask1.get()}; std::array maskArray = {mask0.get(), mask1.get()};
const auto mask = CFPtr<const __CFArray>( const auto mask = CFPtr<CFArrayRef>(
CFArrayCreate(nullptr, reinterpret_cast<const void**>(maskArray.data()), maskArray.size(), nullptr)); CFArrayCreate(nullptr, reinterpret_cast<const void**>(maskArray.data()), maskArray.size(), nullptr));
IOHIDManagerSetDeviceMatchingMultiple(m_manager, mask.get()); IOHIDManagerSetDeviceMatchingMultiple(m_manager, mask.get());

View File

@ -78,7 +78,7 @@ public:
/// \return a retained __CFSet pointer of IOHIDDeviceRef or a null pointer /// \return a retained __CFSet pointer of IOHIDDeviceRef or a null pointer
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
CFPtr<const __CFSet> copyJoysticks(); CFPtr<CFSetRef> copyJoysticks();
private: private:
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////

View File

@ -212,7 +212,7 @@ void setMousePosition(Vector2i position)
const CGPoint pos = CGPointMake(position.x / scale, position.y / scale); const CGPoint pos = CGPointMake(position.x / scale, position.y / scale);
// Place the cursor. // Place the cursor.
const auto event = CFPtr<__CGEvent>( const auto event = CFPtr<CGEventRef>(
CGEventCreateMouseEvent(nullptr, CGEventCreateMouseEvent(nullptr,
kCGEventMouseMoved, kCGEventMouseMoved,
pos, pos,

View File

@ -132,7 +132,7 @@ bool JoystickImpl::isConnected(unsigned int index)
if (connectedCount > openedCount) if (connectedCount > openedCount)
{ {
// Get all devices // Get all devices
const auto devices = CFPtr<const __CFSet>(HIDJoystickManager::getInstance().copyJoysticks()); const auto devices = CFPtr<CFSetRef>(HIDJoystickManager::getInstance().copyJoysticks());
if (devices != nullptr) if (devices != nullptr)
{ {
@ -209,7 +209,7 @@ bool JoystickImpl::open(unsigned int index)
m_identification.productId = getDeviceUint(self, CFSTR(kIOHIDProductIDKey), m_index); m_identification.productId = getDeviceUint(self, CFSTR(kIOHIDProductIDKey), m_index);
// Get a list of all elements attached to the device. // Get a list of all elements attached to the device.
const auto elements = CFPtr<const __CFArray>(IOHIDDeviceCopyMatchingElements(self, nullptr, kIOHIDOptionsTypeNone)); const auto elements = CFPtr<CFArrayRef>(IOHIDDeviceCopyMatchingElements(self, nullptr, kIOHIDOptionsTypeNone));
if (elements == nullptr) if (elements == nullptr)
return false; return false;
@ -218,7 +218,7 @@ bool JoystickImpl::open(unsigned int index)
const CFIndex elementsCount = CFArrayGetCount(elements.get()); const CFIndex elementsCount = CFArrayGetCount(elements.get());
for (int i = 0; i < elementsCount; ++i) for (int i = 0; i < elementsCount; ++i)
{ {
auto element = std::shared_ptr(CFPtr<__IOHIDElement>( auto element = std::shared_ptr(CFPtr<IOHIDElementRef>(
static_cast<IOHIDElementRef>(const_cast<void*>(CFArrayGetValueAtIndex(elements.get(), i))))); static_cast<IOHIDElementRef>(const_cast<void*>(CFArrayGetValueAtIndex(elements.get(), i)))));
switch (IOHIDElementGetUsagePage(element.get())) switch (IOHIDElementGetUsagePage(element.get()))
{ {

View File

@ -28,6 +28,7 @@
// Headers // Headers
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
#include <memory> #include <memory>
#include <type_traits>
namespace sf::priv namespace sf::priv
@ -50,5 +51,5 @@ struct CFDeleter
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
template <typename T> template <typename T>
using CFPtr = std::unique_ptr<T, CFDeleter>; using CFPtr = std::unique_ptr<std::remove_pointer_t<T>, CFDeleter>;
} // namespace sf::priv } // namespace sf::priv

View File

@ -44,7 +44,7 @@ std::vector<VideoMode> VideoModeImpl::getFullscreenModes()
std::vector<VideoMode> modes; std::vector<VideoMode> modes;
// Retrieve all modes available for main screen only. // Retrieve all modes available for main screen only.
const auto cgmodes = CFPtr<const __CFArray>(CGDisplayCopyAllDisplayModes(CGMainDisplayID(), nullptr)); const auto cgmodes = CFPtr<CFArrayRef>(CGDisplayCopyAllDisplayModes(CGMainDisplayID(), nullptr));
if (cgmodes == nullptr) if (cgmodes == nullptr)
{ {

View File

@ -39,7 +39,7 @@ namespace sf::priv
unsigned int modeBitsPerPixel(CGDisplayModeRef mode) unsigned int modeBitsPerPixel(CGDisplayModeRef mode)
{ {
// Compare encoding. // Compare encoding.
const auto pixEnc = CFPtr<const __CFString>(CGDisplayModeCopyPixelEncoding(mode)); const auto pixEnc = CFPtr<CFStringRef>(CGDisplayModeCopyPixelEncoding(mode));
if (CFStringCompare(pixEnc.get(), CFSTR(IO32BitDirectPixels), kCFCompareCaseInsensitive) == kCFCompareEqualTo) if (CFStringCompare(pixEnc.get(), CFSTR(IO32BitDirectPixels), kCFCompareCaseInsensitive) == kCFCompareEqualTo)
return 32; return 32;
if (CFStringCompare(pixEnc.get(), CFSTR(IO16BitDirectPixels), kCFCompareCaseInsensitive) == kCFCompareEqualTo) if (CFStringCompare(pixEnc.get(), CFSTR(IO16BitDirectPixels), kCFCompareCaseInsensitive) == kCFCompareEqualTo)