• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ IOHIDManagerOpen函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中IOHIDManagerOpen函数的典型用法代码示例。如果您正苦于以下问题:C++ IOHIDManagerOpen函数的具体用法?C++ IOHIDManagerOpen怎么用?C++ IOHIDManagerOpen使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了IOHIDManagerOpen函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: IOHIDManagerCreate

void CInputProviderMacOsHid::InputDeviceListenerThread()
{
	m_hidManager = IOHIDManagerCreate(kCFAllocatorDefault, 0);
	{
		CFDictionaryRef matchingDict[3];
		matchingDict[0] = CreateDeviceMatchingDictionary(kHIDPage_GenericDesktop, kHIDUsage_GD_Joystick);
		matchingDict[1] = CreateDeviceMatchingDictionary(kHIDPage_GenericDesktop, kHIDUsage_GD_GamePad);
		matchingDict[2] = CreateDeviceMatchingDictionary(kHIDPage_GenericDesktop, kHIDUsage_GD_MultiAxisController);

		CFArrayRef array = CFArrayCreate(kCFAllocatorDefault, (const void**)matchingDict, 3, &kCFTypeArrayCallBacks);
		CFRelease(matchingDict[0]);
		CFRelease(matchingDict[1]);
		CFRelease(matchingDict[2]);
		IOHIDManagerSetDeviceMatchingMultiple(m_hidManager, array);
	}

	IOHIDManagerRegisterDeviceMatchingCallback(m_hidManager, OnDeviceMatchedStub, this);

	IOHIDManagerOpen(m_hidManager, kIOHIDOptionsTypeNone);
	IOHIDManagerScheduleWithRunLoop(m_hidManager, CFRunLoopGetCurrent(), CFSTR("CustomLoop"));
	while(CFRunLoopRunInMode(CFSTR("CustomLoop"), 1, true) != kCFRunLoopRunStopped && m_running)
	{
	}

	IOHIDManagerClose(m_hidManager, 0);
}
开发者ID:jpd002,项目名称:Play-,代码行数:26,代码来源:InputProviderMacOsHid.cpp


示例2: setupHIDManager

static int setupHIDManager(yContextSt *ctx, OSX_HID_REF *hid, char *errmsg)
{
    int             c_vendorid = YOCTO_VENDORID;
    CFMutableDictionaryRef dictionary;
    CFNumberRef     Vendorid;
    IOReturn        tIOReturn;

    yInitializeCriticalSection(&hid->hidMCS);
    // Initialize HID Manager
    hid->manager = IOHIDManagerCreate(kCFAllocatorDefault, kIOHIDOptionsTypeNone);
    // create dictionary to match Yocto devices
    dictionary = CFDictionaryCreateMutable(kCFAllocatorDefault,1,&kCFTypeDictionaryKeyCallBacks,&kCFTypeDictionaryValueCallBacks);
    Vendorid = CFNumberCreate( kCFAllocatorDefault, kCFNumberIntType, &c_vendorid );
    CFDictionarySetValue( dictionary, CFSTR( kIOHIDVendorIDKey ), Vendorid );
    CFRelease(Vendorid);
    // register the dictionary
    IOHIDManagerSetDeviceMatching(hid->manager, dictionary );
    // now we can release the dictionary
    CFRelease(dictionary);
    // sechedulle the HID Manager with our global run loop
    IOHIDManagerScheduleWithRunLoop(hid->manager, ctx->usb_run_loop, kCFRunLoopDefaultMode);

    // Now open the IO HID Manager reference
    tIOReturn = IOHIDManagerOpen(hid->manager, kIOHIDOptionsTypeNone );
    if(kIOReturnSuccess != tIOReturn ||CFGetTypeID(hid->manager) != IOHIDManagerGetTypeID()){
        HALLOG("Unable to Open HID Manager");
        return YERRMSG(YAPI_NOT_SUPPORTED,"Unable to Open HID Manager");
    }
    return YAPI_SUCCESS;

}
开发者ID:LudovicRousseau,项目名称:yoctolib_cpp,代码行数:31,代码来源:ypkt_osx.c


示例3: init_hid_manager

static void init_hid_manager(void)
{
	CFMutableDictionaryRef dict;
	IOReturn ret;

	if (hid_manager) return;
	hid_manager = IOHIDManagerCreate(kCFAllocatorDefault, kIOHIDOptionsTypeNone);
	if (hid_manager == NULL || CFGetTypeID(hid_manager) != IOHIDManagerGetTypeID()) {
		if (hid_manager) CFRelease(hid_manager);
		printf_verbose("no HID Manager - maybe this is a pre-Leopard (10.5) system?\n");
		return;
	}
	dict = CFDictionaryCreateMutable(kCFAllocatorDefault, 0,
		&kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
	if (!dict) return;
	IOHIDManagerSetDeviceMatching(hid_manager, dict);
	CFRelease(dict);
	IOHIDManagerScheduleWithRunLoop(hid_manager, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode);
	IOHIDManagerRegisterDeviceMatchingCallback(hid_manager, attach_callback, NULL);
	IOHIDManagerRegisterDeviceRemovalCallback(hid_manager, detach_callback, NULL);
	ret = IOHIDManagerOpen(hid_manager, kIOHIDOptionsTypeNone);
	if (ret != kIOReturnSuccess) {
		IOHIDManagerUnscheduleFromRunLoop(hid_manager,
			CFRunLoopGetCurrent(), kCFRunLoopDefaultMode);
		CFRelease(hid_manager);
		printf_verbose("Error opening HID Manager");
	}
}
开发者ID:charliebruce,项目名称:waxbee,代码行数:28,代码来源:teensy.c


示例4: apple_hid_init

static bool apple_hid_init(void)
{
    CFMutableArrayRef matcher;
    
    if (!(g_hid_manager = IOHIDManagerCreate(
        kCFAllocatorDefault, kIOHIDOptionsTypeNone)))
        return false;
    
    matcher = CFArrayCreateMutable(kCFAllocatorDefault, 0,
                                   &kCFTypeArrayCallBacks);
    
    append_matching_dictionary(matcher, kHIDPage_GenericDesktop,
                               kHIDUsage_GD_Joystick);
    append_matching_dictionary(matcher, kHIDPage_GenericDesktop,
                               kHIDUsage_GD_GamePad);
    
    IOHIDManagerSetDeviceMatchingMultiple(g_hid_manager, matcher);
    CFRelease(matcher);
    
    IOHIDManagerRegisterDeviceMatchingCallback(g_hid_manager,
                                               add_device, 0);
    IOHIDManagerScheduleWithRunLoop(g_hid_manager, CFRunLoopGetMain(),
                                    kCFRunLoopCommonModes);
    
    IOHIDManagerOpen(g_hid_manager, kIOHIDOptionsTypeNone);
    
    return true;
}
开发者ID:maddox,项目名称:RetroArch,代码行数:28,代码来源:apple_joypad_hid.c


示例5: m_manager

HIDJoystickManager::HIDJoystickManager() :
m_manager(0),
m_joystickCount(0)
{
    m_manager = IOHIDManagerCreate(kCFAllocatorDefault, kIOHIDOptionsTypeNone);

    CFDictionaryRef mask0 = HIDInputManager::copyDevicesMask(kHIDPage_GenericDesktop,
                                                             kHIDUsage_GD_Joystick);

    CFDictionaryRef mask1 = HIDInputManager::copyDevicesMask(kHIDPage_GenericDesktop,
                                                             kHIDUsage_GD_GamePad);

    CFDictionaryRef maskArray[2];
    maskArray[0] = mask0;
    maskArray[1] = mask1;

    CFArrayRef mask = CFArrayCreate(NULL, (const void**)maskArray, 2, NULL);

    IOHIDManagerSetDeviceMatchingMultiple(m_manager, mask);
    CFRelease(mask);
    CFRelease(mask1);
    CFRelease(mask0);


    IOHIDManagerRegisterDeviceMatchingCallback(m_manager, pluggedIn, this);
    IOHIDManagerRegisterDeviceRemovalCallback(m_manager, pluggedOut, this);

    IOHIDManagerScheduleWithRunLoop(m_manager,
                                    CFRunLoopGetCurrent(),
                                    RunLoopMode);

    IOHIDManagerOpen(m_manager, kIOHIDOptionsTypeNone);
}
开发者ID:CastBart,项目名称:AndroidTesting,代码行数:33,代码来源:HIDJoystickManager.cpp


示例6: ConfigHIDManager

static SDL_bool
ConfigHIDManager(CFArrayRef matchingArray)
{
    CFRunLoopRef runloop = CFRunLoopGetCurrent();

    /* Run in a custom RunLoop mode just while initializing,
       so we can detect sticks without messing with everything else. */
    CFStringRef tempRunLoopMode = CFSTR("SDLJoystickInit");

    if (IOHIDManagerOpen(hidman, kIOHIDOptionsTypeNone) != kIOReturnSuccess) {
        return SDL_FALSE;
    }

    IOHIDManagerRegisterDeviceMatchingCallback(hidman, JoystickDeviceWasAddedCallback, NULL);
    IOHIDManagerScheduleWithRunLoop(hidman, runloop, tempRunLoopMode);
    IOHIDManagerSetDeviceMatchingMultiple(hidman, matchingArray);

    while (CFRunLoopRunInMode(tempRunLoopMode,0,TRUE)==kCFRunLoopRunHandledSource) {
        /* no-op. Callback fires once per existing device. */
    }

    /* Put this in the normal RunLoop mode now, for future hotplug events. */
    IOHIDManagerUnscheduleFromRunLoop(hidman, runloop, tempRunLoopMode);
    IOHIDManagerScheduleWithRunLoop(hidman, runloop, kCFRunLoopDefaultMode);

    return SDL_TRUE;  /* good to go. */
}
开发者ID:Helios-vmg,项目名称:CopperRat,代码行数:27,代码来源:SDL_sysjoystick.c


示例7: threadrun

void* threadrun(void* context){
    // Tell the device manager which devices we want to look for
    CFMutableArrayRef devices = CFArrayCreateMutable(kCFAllocatorDefault, 0, &kCFTypeArrayCallBacks);
    if(devices){
        int vendor = V_CORSAIR;
        int products[] = { P_K65, P_K70, P_K70_NRGB, P_K95, P_K95_NRGB };
        for(uint i = 0; i < sizeof(products) / sizeof(int); i++){
            int product = products[i];
            CFMutableDictionaryRef device = CFDictionaryCreateMutable(kCFAllocatorDefault, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
            if(device){
                CFDictionarySetValue(device, CFSTR(kIOHIDVendorIDKey), CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &vendor));
                CFDictionarySetValue(device, CFSTR(kIOHIDProductIDKey), CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &product));
                CFArrayAppendValue(devices, device);
                CFRelease(device);
            }
        }
        IOHIDManagerSetDeviceMatchingMultiple(usbmanager, devices);
        CFRelease(devices);
    }

    // Set up device add callback
    IOHIDManagerRegisterDeviceMatchingCallback(usbmanager, usbadd, 0);
    IOHIDManagerScheduleWithRunLoop(usbmanager, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode);
    IOHIDManagerOpen(usbmanager, kIOHIDOptionsTypeSeizeDevice);

    // Make a new thread to handle key repeats. The OS won't do it for us.
    pthread_create(&keyrepeatthread, 0, krthread, 0);

    // Run the event loop. Existing devices will be detected automatically.
    while(1){
        CFRunLoopRun();
    }
    return 0;
}
开发者ID:jsnel,项目名称:ckb,代码行数:34,代码来源:usb_mac.c


示例8: TeensyControls_usb_init

int TeensyControls_usb_init(void)
{
	CFMutableArrayRef array = NULL;
	IOReturn ret;

	hmgr = IOHIDManagerCreate(kCFAllocatorDefault, kIOHIDOptionsTypeNone);
	if (!hmgr) goto fail;
	if (CFGetTypeID(hmgr) != IOHIDManagerGetTypeID()) goto fail;
	array = CFArrayCreateMutable(kCFAllocatorDefault, 0, &kCFTypeArrayCallBacks);
	if (!array) goto fail;
	add_to_array(array, 0x16C0, 0x0488, 0xFF1C, 0xA739); // Teensyduino Flight Sim
	IOHIDManagerSetDeviceMatchingMultiple(hmgr, array);
	CFRelease(array);
	array = NULL;
	IOHIDManagerScheduleWithRunLoop(hmgr, CFRunLoopGetCurrent(), dev_run_mode);
	IOHIDManagerRegisterDeviceMatchingCallback(hmgr, attach_callback, NULL);
	IOHIDManagerRegisterDeviceRemovalCallback(hmgr, detach_callback, NULL);
	ret = IOHIDManagerOpen(hmgr, kIOHIDOptionsTypeNone);
	if (ret != kIOReturnSuccess) {
		IOHIDManagerUnscheduleFromRunLoop(hmgr,
			CFRunLoopGetCurrent(), dev_run_mode);
		goto fail;
	}
	CFRunLoopAddCommonMode(CFRunLoopGetCurrent(), dev_run_mode);
	return 1;
fail:
	if (array) CFRelease(array);
	if (hmgr) CFRelease(hmgr);
	return 0;
}
开发者ID:orthopteroid,项目名称:X-Plane_Plugin,代码行数:30,代码来源:usb.c


示例9: init_hid_manager

static void init_hid_manager(void)
{
	/* Initialize all the HID Manager Objects */
	hid_mgr = IOHIDManagerCreate(kCFAllocatorDefault, kIOHIDOptionsTypeNone);
	IOHIDManagerSetDeviceMatching(hid_mgr, NULL);
	IOHIDManagerScheduleWithRunLoop(hid_mgr, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode);
	IOHIDManagerOpen(hid_mgr, kIOHIDOptionsTypeNone);
}
开发者ID:taxilian,项目名称:hidapi,代码行数:8,代码来源:hid.c


示例10: HIDBuildMultiDeviceList

//*************************************************************************
//
// HIDBuildMultiDeviceList( inUsagePages, inUsages, inNumDeviceTypes )
//
// Purpose:	builds list of devices with elements
//
// Inputs:	inUsagePages		- inNumDeviceTypes sized array of matching usage pages
//			inUsages			- inNumDeviceTypes sized array of matching usages
//			inNumDeviceTypes	- number of usage pages & usages
//
// Returns:	Boolean		- if successful
//
Boolean HIDBuildMultiDeviceList( const UInt32 *inUsagePages, const UInt32 *inUsages, int inNumDeviceTypes )
{
	Boolean result = FALSE;                // assume failure ( pessimist! )
	Boolean first = ( !gIOHIDManagerRef ); // not yet created?

//	if ( first ) { // it appears this needs to happen every time?
		// create the manager
		gIOHIDManagerRef = IOHIDManagerCreate( kCFAllocatorDefault, kIOHIDOptionsTypeNone );
//	}

	if ( gIOHIDManagerRef ) {
		CFMutableArrayRef hidMatchingCFMutableArrayRef = NULL;

		if ( inUsages && inUsagePages && inNumDeviceTypes ) {
			hidMatchingCFMutableArrayRef = CFArrayCreateMutable( kCFAllocatorDefault, 0, &kCFTypeArrayCallBacks );

			if ( hidMatchingCFMutableArrayRef ) {
				int idx;
				for ( idx = 0; idx < inNumDeviceTypes; idx++ ) {    // for all usage and usage page types
					// Set up matching dictionary. returns NULL on error.
					CFMutableDictionaryRef hidMatchingCFDictRef = hu_SetUpMatchingDictionary( inUsagePages[idx], inUsages[idx] );

					if ( hidMatchingCFDictRef ) {
						CFArrayAppendValue( hidMatchingCFMutableArrayRef, (void*) hidMatchingCFDictRef );
						CFRelease( hidMatchingCFDictRef );
					} else {
						fprintf( stderr, "%s: Couldn’t create a matching dictionary.", __PRETTY_FUNCTION__ );
					}
				}
			} else {
				fprintf( stderr, "%s: Couldn’t create a matching array.", __PRETTY_FUNCTION__ );
			}
		}

		// set it for IOHIDManager to use to match against
		IOHIDManagerSetDeviceMatchingMultiple( gIOHIDManagerRef, hidMatchingCFMutableArrayRef );

		if ( hidMatchingCFMutableArrayRef ) {
			CFRelease( hidMatchingCFMutableArrayRef );
		}

		if ( first ) {
			// open it
			IOReturn tIOReturn = IOHIDManagerOpen( gIOHIDManagerRef, kIOHIDOptionsTypeNone );

			if ( kIOReturnSuccess != tIOReturn ) {
				fprintf( stderr, "%s: Couldn’t open IOHIDManager.", __PRETTY_FUNCTION__ );
				goto Oops;
			}
		}
		HIDRebuildDevices( );
		result = TRUE;
	} else {
		fprintf( stderr, "%s: Couldn’t create a IOHIDManager.", __PRETTY_FUNCTION__ );
	}
Oops:   ;
	return result;
}   // HIDBuildMultiDeviceList
开发者ID:2mc,项目名称:supercollider,代码行数:70,代码来源:HID_Utilities.c


示例11: HIDReportParser

  osxHIDInputDevice::osxHIDInputDevice(URI uri,
				       const char *device_description,
				       const char *elements_description):parser(0) {
    theDevice = 0 ;
    inputreport_callback = 0 ;
    inputreport_context = 0 ;
    value_callback = 0 ;
    value_context = 0 ;    
    queue_callback = 0 ;
    queue_context = 0 ;
    debugLevel = OSX_DEFAULT_DEBUGLEVEL ;
    seizeDevice = OSX_DEFAULT_SEIZEDEVICE ;

    this->uri = uri ;
    this->uri.generalize() ;
    URI::getQueryArg(uri.query, "debugLevel", &debugLevel) ;
    URI::getQueryArg(uri.query, "seize", &seizeDevice) ;
    parser = new HIDReportParser(NULL, 0, debugLevel);

    manager = IOHIDManagerCreate(kCFAllocatorDefault, kIOHIDOptionsTypeNone) ;
    if (!manager) 
      throw std::runtime_error("IOHIDManagerCreate failed") ;

    device_match = 0 ;
    if (device_description) {
      if (!strncmp(device_description, "<?xml", 5)) {
	device_match = (CFMutableDictionaryRef)getPropertyListFromXML(device_description) ;
	if (debugLevel>1) 
	  std::cerr << "Filtering devices based on XML description: " << device_description << std::endl ;
      } else {
	device_match = (CFMutableDictionaryRef)getPropertyListFromFile(device_description) ;
	if (debugLevel>1) 
	  std::cerr << "Filtering devices based on file " << device_description << std::endl ;
      }
    }
    IOHIDManagerSetDeviceMatching(manager, device_match) ;

    elements_match = 0 ;
    if (elements_description) {
      if (!strncmp(elements_description, "<?xml", 5)) {
	elements_match = (CFArrayRef)getPropertyListFromXML(elements_description) ;
	if (debugLevel>1) 
	  std::cerr << "Filtering elements based on XML description: " << elements_description << std::endl ;
      } else {
	elements_match = (CFArrayRef)getPropertyListFromFile(elements_description) ;
	if (debugLevel>1) 
	  std::cerr << "Filtering elements based on file " << elements_description << std::endl ;
      }
    }
  
    IOHIDManagerRegisterDeviceMatchingCallback(manager, AddDevice, (void*)this) ;
    IOHIDManagerRegisterDeviceRemovalCallback(manager, RemoveDevice, (void*)this) ;
    IOHIDManagerScheduleWithRunLoop(manager, CFRunLoopGetMain(), kCFRunLoopDefaultMode) ;

    IOOptionBits inOptions = seizeDevice ? kIOHIDOptionsTypeSeizeDevice : kIOHIDOptionsTypeNone ;
    if (IOHIDManagerOpen(manager, inOptions)!=kIOReturnSuccess) 
      throw std::runtime_error("IOHIDManagerOpen failed") ;
  }
开发者ID:INRIA,项目名称:libpointing,代码行数:58,代码来源:osxHIDInputDevice.cpp


示例12: QObject

UsbMonitor_mac::UsbMonitor_mac():
    QObject()
{
    // Create an HID Manager
    hidmanager = IOHIDManagerCreate(kCFAllocatorDefault,
                                                    kIOHIDOptionsTypeNone);

    // Create a Matching Dictionary for filtering HID devices
    CFMutableDictionaryRef matchDict = CFDictionaryCreateMutable(kCFAllocatorDefault,
                                                                 4,
                                                                 &kCFTypeDictionaryKeyCallBacks,
                                                                 &kCFTypeDictionaryValueCallBacks);

    // Set device info in the Matching Dictionary (pid/vid/usage/usagepage)

    //VendorID
    int val = MOOLTIPASS_VENDORID;
    CFNumberRef vid = CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &val);
    CFDictionarySetValue(matchDict, CFSTR(kIOHIDVendorIDKey), vid);
    CFRelease(vid);

    //ProductID
    val = MOOLTIPASS_PRODUCTID;
    CFNumberRef pid = CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &val);
    CFDictionarySetValue(matchDict, CFSTR(kIOHIDProductIDKey), pid);
    CFRelease(pid);

    //Usage
    val = MOOLTIPASS_USAGE;
    CFNumberRef usage = CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &val);
    CFDictionarySetValue(matchDict, CFSTR(kIOHIDDeviceUsageKey), usage);
    CFRelease(usage);

    //Usage Page
    val = MOOLTIPASS_USAGE_PAGE;
    CFNumberRef usagep = CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &val);
    CFDictionarySetValue(matchDict, CFSTR(kIOHIDDeviceUsagePageKey), usagep);
    CFRelease(usagep);

    // Register the Matching Dictionary to the HID Manager
    IOHIDManagerSetDeviceMatching(hidmanager, matchDict);

    // Register a callback for USB device detection with the HID Manager
    IOHIDManagerRegisterDeviceMatchingCallback(hidmanager, &_device_matching_callback, this);

    // Register a callback fro USB device removal with the HID Manager
    IOHIDManagerRegisterDeviceRemovalCallback(hidmanager, &_device_removal_callback, this);

    // Register the HID Manager on our app’s run loop
    // CFRunLoopGetCurrent() can safely be used because Qt uses CFRunloop in its backend platform plugin
    IOHIDManagerScheduleWithRunLoop(hidmanager, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode);

    // Open the HID Manager
    IOReturn ioret = IOHIDManagerOpen(hidmanager, kIOHIDOptionsTypeNone);
    if (ioret)
        qWarning() << "Failed to open IOHIDManager";
}
开发者ID:NicoHood,项目名称:moolticute,代码行数:57,代码来源:UsbMonitor_mac.cpp


示例13: m_pGameApp

Burger::Mouse::Mouse(GameApp *pGameApp) :
	m_pGameApp(pGameApp),
	m_MouseLock(),
	m_pHIDManager(NULL),
	m_uMiceCount(0),
	m_uX(0),
	m_uY(0),
	m_uBoundsX(640),
	m_uBoundsY(480),
	m_iDeltaX(0),
	m_iDeltaY(0),
	m_iMouseWheelX(0),
	m_iMouseWheelY(0),
	m_uButtons(0),
	m_uPressedButtons(0),
	m_bButtonSwap(FALSE),
	m_uArrayStart(0),
	m_uArrayEnd(0)
{
	// Back link to the game app
	CFMutableDictionaryRef pDictionary = Globals::CreateHIDDictionary(kHIDPage_GenericDesktop,kHIDUsage_GD_Mouse);
	if (pDictionary != NULL) {
		m_pHIDManager = IOHIDManagerCreate(kCFAllocatorDefault,kIOHIDOptionsTypeNone);
		if (m_pHIDManager != NULL) {
			CFRunLoopRef pRunLoop = CFRunLoopGetCurrent();
			IOHIDManagerRegisterDeviceMatchingCallback(m_pHIDManager,EnumerationCallback,this);
			IOHIDManagerScheduleWithRunLoop(m_pHIDManager,pRunLoop,g_BurgerMouse);
			IOHIDManagerSetDeviceMatching(m_pHIDManager,pDictionary);
			IOHIDManagerOpen(m_pHIDManager,kIOHIDOptionsTypeNone);
			// Handle the run loops
			Poll(this);
			// All scanned!
			IOHIDManagerUnscheduleFromRunLoop(m_pHIDManager,pRunLoop,g_BurgerMouse);
			IOHIDManagerRegisterDeviceMatchingCallback(m_pHIDManager,NULL, NULL);
			
			// Open all the located devices
			Word i;
			DeviceStruct *pRat = m_Mice;
			for (i = 0; i < m_uMiceCount; i++) {
				IOHIDDeviceRef pDevice = pRat->m_pDevice;
				if (IOHIDDeviceOpen(pDevice,kIOHIDOptionsTypeNone) != kIOReturnSuccess) {
					pRat->m_pDevice = NULL;		// Hmm. Toast it
					pRat->m_bUnplugged = FALSE;	// Don't attempt to reconnect
				} else {
					IOHIDDeviceRegisterRemovalCallback(pDevice,DisconnectionCallback,this);
					IOHIDDeviceRegisterInputValueCallback(pDevice,InputCallback,this);
					IOHIDDeviceScheduleWithRunLoop(pDevice,pRunLoop,g_BurgerMouse);
				}
				++pRat;
			}
			pGameApp->AddRoutine(Poll,NULL,this,RunQueue::PRIORITY_MOUSE);
        }
        CFRelease(pDictionary);
    }
}
开发者ID:Olde-Skuul,项目名称:burgerlib,代码行数:55,代码来源:brmousemacosx.cpp


示例14: Gamepad_init

void Gamepad_init() {
  if (hidManager == NULL) {
    CFStringRef keys[2];
    int value;
    CFNumberRef values[2];
    CFDictionaryRef dictionaries[3];
    CFArrayRef array;
		
    hidManager = IOHIDManagerCreate(kCFAllocatorDefault, kIOHIDOptionsTypeNone);
		
    keys[0] = CFSTR(kIOHIDDeviceUsagePageKey);
    keys[1] = CFSTR(kIOHIDDeviceUsageKey);
		
    value = kHIDPage_GenericDesktop;
    values[0] = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &value);
    value = kHIDUsage_GD_Joystick;
    values[1] = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &value);
    dictionaries[0] = CFDictionaryCreate(kCFAllocatorDefault, (const void **) keys, (const void **) values, 2, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
    CFRelease(values[0]);
    CFRelease(values[1]);
		
    value = kHIDPage_GenericDesktop;
    values[0] = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &value);
    value = kHIDUsage_GD_GamePad;
    values[1] = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &value);
    dictionaries[1] = CFDictionaryCreate(kCFAllocatorDefault, (const void **) keys, (const void **) values, 2, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
    CFRelease(values[0]);
    CFRelease(values[1]);
		
    value = kHIDPage_GenericDesktop;
    values[0] = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &value);
    value = kHIDUsage_GD_MultiAxisController;
    values[1] = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &value);
    dictionaries[2] = CFDictionaryCreate(kCFAllocatorDefault, (const void **) keys, (const void **) values, 2, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
    CFRelease(values[0]);
    CFRelease(values[1]);
		
    array = CFArrayCreate(kCFAllocatorDefault, (const void **) dictionaries, 3, &kCFTypeArrayCallBacks);
    CFRelease(dictionaries[0]);
    CFRelease(dictionaries[1]);
    CFRelease(dictionaries[2]);
    IOHIDManagerSetDeviceMatchingMultiple(hidManager, array);
    CFRelease(array);
		
    IOHIDManagerRegisterDeviceMatchingCallback(hidManager, onDeviceMatched, NULL);
    IOHIDManagerRegisterDeviceRemovalCallback(hidManager, onDeviceRemoved, NULL);
		
    IOHIDManagerOpen(hidManager, kIOHIDOptionsTypeNone);
		
    // Force gamepads to be recognized immediately. The normal run loop mode takes a few frames,
    // but we can run one iteration with a custom mode to do it without a delay.
    IOHIDManagerScheduleWithRunLoop(hidManager, CFRunLoopGetCurrent(), GAMEPAD_RUN_LOOP_MODE);
    CFRunLoopRunInMode(GAMEPAD_RUN_LOOP_MODE, 0, true);
  }
}
开发者ID:Shirakumo,项目名称:libstem_gamepad,代码行数:55,代码来源:Gamepad_macosx.c


示例15: init_hid_manager

static int init_hid_manager(void)
{
	IOReturn res;
	
	/* Initialize all the HID Manager Objects */
	hid_mgr = IOHIDManagerCreate(kCFAllocatorDefault, kIOHIDOptionsTypeNone);
	IOHIDManagerSetDeviceMatching(hid_mgr, NULL);
	IOHIDManagerScheduleWithRunLoop(hid_mgr, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode);
	res = IOHIDManagerOpen(hid_mgr, kIOHIDOptionsTypeNone);
	return (res == kIOReturnSuccess)? 0: -1;
}
开发者ID:AaronPerl,项目名称:HackRU-DigitalTheremin,代码行数:11,代码来源:hid.c


示例16: OSX_Mouse_Thread

static int OSX_Mouse_Thread(void *ctx)
{
	if (!ctx)
		return 0;
	struct osx_mouse_data *mdata = static_cast<struct osx_mouse_data *>(ctx);
	
	IOHIDManagerRef hid_manager = IOHIDManagerCreate(kCFAllocatorSystemDefault, kIOHIDOptionsTypeNone);
	if (!hid_manager) {
		SDL_DestroyMutex(mdata->mouse_mutex);
		delete mdata;
		return 0;
	}
	
	if (IOHIDManagerOpen(hid_manager, kIOHIDOptionsTypeNone) != kIOReturnSuccess) {
		CFRelease(hid_manager);
		SDL_DestroyMutex(mdata->mouse_mutex);
		delete mdata;
		return 0;
	}
	
	IOHIDManagerRegisterInputValueCallback(hid_manager, input_callback, mdata);
	IOHIDManagerScheduleWithRunLoop(hid_manager, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode);
		
	uint32_t page = kHIDPage_GenericDesktop;
	uint32_t usage = kHIDUsage_GD_Mouse;
	CFDictionaryRef dict = NULL;
	CFNumberRef pageNumRef = CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &page);
	CFNumberRef usageNumRef = CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &usage);
	const void *keys[2] = { CFSTR(kIOHIDDeviceUsagePageKey), CFSTR(kIOHIDDeviceUsageKey) };
	const void *vals[2] = { pageNumRef, usageNumRef };

	if (pageNumRef && usageNumRef)
		dict = CFDictionaryCreate(kCFAllocatorDefault, keys, vals, 2, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
	if (pageNumRef)
		CFRelease(pageNumRef);
	if (usageNumRef)
		CFRelease(usageNumRef);
	IOHIDManagerSetDeviceMatching(hid_manager, dict);
	if (dict)
		CFRelease(dict);

	while (!mdata->should_exit) {
		CFRunLoopRunInMode(kCFRunLoopDefaultMode, 1, false);
	}

	IOHIDManagerUnscheduleFromRunLoop(hid_manager, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode);
	IOHIDManagerClose(hid_manager, kIOHIDOptionsTypeNone);
	
	CFRelease(hid_manager);
	SDL_DestroyMutex(mdata->mouse_mutex);
	delete mdata;
	return 0;
}
开发者ID:blezek,项目名称:marathon-ios,代码行数:53,代码来源:mouse_cocoa.cpp


示例17: Gamepad_init

void Gamepad_init() {
	if (hidManager == NULL) {
		CFStringRef keys[2];
		int value;
		CFNumberRef values[2];
		CFDictionaryRef dictionaries[3];
		CFArrayRef array;
		
        hidManager = IOHIDManagerCreate(kCFAllocatorDefault, kIOHIDOptionsTypeNone);
        IOHIDManagerOpen(hidManager, kIOHIDOptionsTypeNone);
        IOHIDManagerScheduleWithRunLoop(hidManager, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode);
		
		keys[0] = CFSTR(kIOHIDDeviceUsagePageKey);
		keys[1] = CFSTR(kIOHIDDeviceUsageKey);
		
		value = kHIDPage_GenericDesktop;
		values[0] = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &value);
		value = kHIDUsage_GD_Joystick;
		values[1] = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &value);
		dictionaries[0] = CFDictionaryCreate(kCFAllocatorDefault, (const void **) keys, (const void **) values, 2, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
		CFRelease(values[0]);
		CFRelease(values[1]);
		
		value = kHIDPage_GenericDesktop;
		values[0] = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &value);
		value = kHIDUsage_GD_GamePad;
		values[1] = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &value);
		dictionaries[1] = CFDictionaryCreate(kCFAllocatorDefault, (const void **) keys, (const void **) values, 2, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
		CFRelease(values[0]);
		CFRelease(values[1]);
		
		value = kHIDPage_GenericDesktop;
		values[0] = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &value);
        value = kHIDUsage_GD_MultiAxisController;
		values[1] = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &value);
		dictionaries[2] = CFDictionaryCreate(kCFAllocatorDefault, (const void **) keys, (const void **) values, 2, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
		CFRelease(values[0]);
		CFRelease(values[1]);
		
		array = CFArrayCreate(kCFAllocatorDefault, (const void **) dictionaries, 3, &kCFTypeArrayCallBacks);
		CFRelease(dictionaries[0]);
		CFRelease(dictionaries[1]);
		CFRelease(dictionaries[2]);
        IOHIDManagerSetDeviceMatchingMultiple(hidManager, array);
		CFRelease(array);
		
		IOHIDManagerRegisterDeviceMatchingCallback(hidManager, onDeviceMatched, NULL);
        IOHIDManagerRegisterDeviceRemovalCallback(hidManager, onDeviceRemoved, NULL);


	}
}
开发者ID:arpg,项目名称:commander-node,代码行数:52,代码来源:Gamepad_macosx.cpp


示例18: CFRunLoopGetCurrent

void JoypadOSX::config_hid_manager(CFArrayRef p_matching_array) const {

	CFRunLoopRef runloop = CFRunLoopGetCurrent();
	IOReturn ret = IOHIDManagerOpen(hid_manager, kIOHIDOptionsTypeNone);
	ERR_FAIL_COND(ret != kIOReturnSuccess);

	IOHIDManagerSetDeviceMatchingMultiple(hid_manager, p_matching_array);
	IOHIDManagerRegisterDeviceMatchingCallback(hid_manager, joypad_added_callback, NULL);
	IOHIDManagerScheduleWithRunLoop(hid_manager, runloop, GODOT_JOY_LOOP_RUN_MODE);

	while (CFRunLoopRunInMode(GODOT_JOY_LOOP_RUN_MODE, 0, TRUE) == kCFRunLoopRunHandledSource) {
		/* no-op. Callback fires once per existing device. */
	}
}
开发者ID:rrrfffrrr,项目名称:godot,代码行数:14,代码来源:joypad_osx.cpp


示例19: initializeResumeNotifications

static void initializeResumeNotifications (void)	// see TN 2187
{
	IOHIDManagerRef hidManager = IOHIDManagerCreate(kCFAllocatorDefault, kIOHIDOptionsTypeNone);
	if (! hidManager) {
		message (LOG_ERR, "IOHIDManagerCreate failed\n");
		exit (1);
	}
	if (IOHIDManagerOpen(hidManager, kIOHIDOptionsTypeNone) != kIOReturnSuccess) {
		message (LOG_ERR, "IOHIDManagerOpen failed\n");
		exit (1);
	}
	IOHIDManagerScheduleWithRunLoop (hidManager, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode);
	IOHIDManagerSetDeviceMatchingMultiple (hidManager, createGenericDesktopMatchingDictionaries());
	IOHIDManagerRegisterInputValueCallback (hidManager, hidCallback, (void *) -1);
}
开发者ID:Gems,项目名称:majormaco,代码行数:15,代码来源:sleepwatcher.c


示例20: init_hid_manager

static int init_hid_manager(void)
{
	IOReturn res;
	
	/* Initialize all the HID Manager Objects */
	hid_mgr = IOHIDManagerCreate(kCFAllocatorDefault, kIOHIDOptionsTypeNone);
	IOHIDManagerSetDeviceMatching(hid_mgr, NULL);
	IOHIDManagerScheduleWithRunLoop(hid_mgr, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode);
	res = IOHIDManagerOpen(hid_mgr, kIOHIDOptionsTypeNone);
	if(res == kIOReturnSuccess)
		return 0;
	
	fprintf(stderr, "IOReturn error code: 0x%x\n", err_get_code(res));
	return -1;
}
开发者ID:darthrake,项目名称:hidapi,代码行数:15,代码来源:hid.c



注:本文中的IOHIDManagerOpen函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ IOHIDManagerScheduleWithRunLoop函数代码示例发布时间:2022-05-30
下一篇:
C++ IOHIDManagerCreate函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap