mirror of
https://github.com/SFML/SFML.git
synced 2024-11-24 20:31:05 +08:00
Return owning pointer type
This commit is contained in:
parent
119ea42e0a
commit
e432237b5d
@ -94,7 +94,7 @@ public:
|
|||||||
/// \return a retained CFDictionaryRef
|
/// \return a retained CFDictionaryRef
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
static CFDictionaryRef copyDevicesMask(std::uint32_t page, std::uint32_t usage);
|
static CFPtr<CFDictionaryRef> copyDevicesMask(std::uint32_t page, std::uint32_t usage);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Try to convert a character into a SFML key code
|
/// \brief Try to convert a character into a SFML key code
|
||||||
|
@ -69,21 +69,19 @@ long HIDInputManager::getLocationID(IOHIDDeviceRef device)
|
|||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
CFDictionaryRef HIDInputManager::copyDevicesMask(std::uint32_t page, std::uint32_t usage)
|
CFPtr<CFDictionaryRef> HIDInputManager::copyDevicesMask(std::uint32_t page, std::uint32_t usage)
|
||||||
{
|
{
|
||||||
// Create the dictionary.
|
// Create the dictionary.
|
||||||
CFMutableDictionaryRef dict = CFDictionaryCreateMutable(kCFAllocatorDefault,
|
auto dict = CFPtr<CFMutableDictionaryRef>(
|
||||||
2,
|
CFDictionaryCreateMutable(kCFAllocatorDefault, 2, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks));
|
||||||
&kCFTypeDictionaryKeyCallBacks,
|
|
||||||
&kCFTypeDictionaryValueCallBacks);
|
|
||||||
|
|
||||||
// Add the page value.
|
// Add the page value.
|
||||||
auto value = CFPtr<CFNumberRef>(CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &page));
|
auto value = CFPtr<CFNumberRef>(CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &page));
|
||||||
CFDictionarySetValue(dict, CFSTR(kIOHIDDeviceUsagePageKey), value.get());
|
CFDictionarySetValue(dict.get(), 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<CFNumberRef>(CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &usage));
|
value = CFPtr<CFNumberRef>(CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &usage));
|
||||||
CFDictionarySetValue(dict, CFSTR(kIOHIDDeviceUsageKey), value.get());
|
CFDictionarySetValue(dict.get(), CFSTR(kIOHIDDeviceUsageKey), value.get());
|
||||||
|
|
||||||
return dict;
|
return dict;
|
||||||
}
|
}
|
||||||
@ -929,7 +927,7 @@ void HIDInputManager::freeUp()
|
|||||||
CFPtr<CFSetRef> 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<CFDictionaryRef>(copyDevicesMask(page, usage));
|
const auto mask = copyDevicesMask(page, usage);
|
||||||
|
|
||||||
IOHIDManagerSetDeviceMatching(m_manager.get(), mask.get());
|
IOHIDManagerSetDeviceMatching(m_manager.get(), mask.get());
|
||||||
|
|
||||||
|
@ -72,11 +72,9 @@ HIDJoystickManager::HIDJoystickManager()
|
|||||||
{
|
{
|
||||||
m_manager = IOHIDManagerCreate(kCFAllocatorDefault, kIOHIDOptionsTypeNone);
|
m_manager = IOHIDManagerCreate(kCFAllocatorDefault, kIOHIDOptionsTypeNone);
|
||||||
|
|
||||||
const auto mask0 = CFPtr<CFDictionaryRef>(
|
const auto mask0 = HIDInputManager::copyDevicesMask(kHIDPage_GenericDesktop, kHIDUsage_GD_Joystick);
|
||||||
HIDInputManager::copyDevicesMask(kHIDPage_GenericDesktop, kHIDUsage_GD_Joystick));
|
|
||||||
|
|
||||||
const auto mask1 = CFPtr<CFDictionaryRef>(
|
const auto mask1 = 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<CFArrayRef>(
|
const auto mask = CFPtr<CFArrayRef>(
|
||||||
|
Loading…
Reference in New Issue
Block a user