Esempio n. 1
0
bool DPMSSupport::PlatformSpecificEnablePowerSaving(PowerSavingMode mode)
{
  bool status;
  // http://lists.apple.com/archives/Cocoa-dev/2007/Nov/msg00267.html
  // This is an unsupported system call that might kernel panic on PPC boxes
  // The reported OSX-PPC panic is unverified so we are going to enable this until
  // we find out which OSX-PPC boxes have problems, then add detect/disable for those boxes.
  io_registry_entry_t r = IORegistryEntryFromPath(kIOMasterPortDefault, "IOService:/IOResources/IODisplayWrangler");
  if(!r) return false;

  switch(mode)
  {
  case OFF:
    // Turn off display
    status = (IORegistryEntrySetCFProperty(r, CFSTR("IORequestIdle"), kCFBooleanTrue) == 0);
    break;
  case STANDBY:
    // Set display to low power
    status = (IORegistryEntrySetCFProperty(r, CFSTR("IORequestIdle"), kCFBooleanTrue) == 0);
    break;
  default:
    status = false;
    break;
  }
  return status;
}
Esempio n. 2
0
int
main(int argc, char **argv)
{
    kern_return_t kr;
    CFTypeRef obj;
	
    io_registry_entry_t regEntry;
	
    regEntry = IORegistryEntryFromPath(kIOMasterPortDefault, 
									   kIOServicePlane ":/IOResources/IODisplayWrangler");
	
    obj = CFRetain(kCFBooleanTrue);
    if (argc > 1)
    {
		SInt32 num = 1000 * strtol(argv[1], 0, 0);
		obj = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &num);
    }
	
    kr = IORegistryEntrySetCFProperty(regEntry, CFSTR("IORequestIdle"), obj);
	
    printf("IORegistryEntrySetCFProperty(IORequestIdle) 0x%x\n", kr);
	
    CFRelease(obj);
    IOObjectRelease(regEntry);
	
    return (0);
}
Esempio n. 3
0
void setPstate(unsigned int newState){
	io_service_t	IOService  = IOServiceGetMatchingService(0, IOServiceMatching(SERVICE_NAME));
	if (! IOService )
		return;

	integer_t state = newState;
	IORegistryEntrySetCFProperty(IOService, CFSTR("P-State"),
		CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &state));
}
Esempio n. 4
0
int main (int argc, char *argv[]) {
	io_registry_entry_t io = IORegistryEntryFromPath(kIOMasterPortDefault, kIOServicePlane ":/IOResources/IODisplayWrangler");
	if (io != MACH_PORT_NULL) {
		usleep(300000);
		IORegistryEntrySetCFProperty(io, CFSTR("IORequestIdle"), kCFBooleanTrue);
		IOObjectRelease(io);
		return 0;
	}
	return 1;
}
Esempio n. 5
0
Boolean dimDisplayNow(void) 
{
    io_registry_entry_t entry = IORegistryEntryFromPath(kIOMasterPortDefault, "IOService:/IOResources/IODisplayWrangler");
    if (!entry) return 0;
    
    OSErr err = IORegistryEntrySetCFProperty(entry, CFSTR("IORequestIdle"), kCFBooleanTrue);
    IOObjectRelease(entry);

    return (err == noErr);
}
Esempio n. 6
0
int main() {
    io_registry_entry_t registryEntry =
        IORegistryEntryFromPath(kIOMasterPortDefault, 
	    "IOService:/IOResources/IODisplayWrangler");
    if(!registryEntry) return 1;
    int err = IORegistryEntrySetCFProperty(registryEntry,
        CFSTR("IORequestIdle"), kCFBooleanTrue);
    IOObjectRelease(registryEntry);
    return err;
}
Esempio n. 7
0
bool DPMSSupport::PlatformSpecificDisablePowerSaving()
{
  // http://lists.apple.com/archives/Cocoa-dev/2007/Nov/msg00267.html
  // This is an unsupported system call that might kernel panic on PPC boxes
  // The reported OSX-PPC panic is unverified so we are going to enable this until
  // we find out which OSX-PPC boxes have problems, then add detect/disable for those boxes.
  io_registry_entry_t r = IORegistryEntryFromPath(kIOMasterPortDefault, "IOService:/IOResources/IODisplayWrangler");
  if(!r) return false;

  // Turn display on
  return (IORegistryEntrySetCFProperty(r, CFSTR("IORequestIdle"), kCFBooleanFalse) == 0);
}
Esempio n. 8
0
static void SendMouseCount(int nCount)
{
    if (g_ioservice)
    {
        CFStringRef cf_key = CFStringCreateWithCString(kCFAllocatorDefault, "MouseCount", CFStringGetSystemEncoding());
        CFNumberRef cf_number = CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &nCount);
        kern_return_t kr = IORegistryEntrySetCFProperty(g_ioservice, cf_key, cf_number);
        if (KERN_SUCCESS != kr)
            DEBUG_LOG("IORegistryEntrySetCFProperty() returned error 0x%08x\n", kr);
        CFRelease(cf_key);
        CFRelease(cf_number);
    }
}
Esempio n. 9
0
void DeviceNotification( void *		refCon,
                         io_service_t 	service,
                         natural_t 	messageType,
                         void *		messageArgument )
{
    if (messageType == kIOMessageServiceIsTerminated)
    {
        printf("Device 0x%08x removed.\n", service);

        // Run lock via idle
        //
        printf("Yubikey removed. Lock the screen.\n");
        io_registry_entry_t reg = IORegistryEntryFromPath(kIOMasterPortDefault, "IOService:/IOResources/IODisplayWrangler");
        if (reg) {
            IORegistryEntrySetCFProperty(reg, CFSTR("IORequestIdle"), kCFBooleanTrue);
            IOObjectRelease(reg);
        }

    }
}
Esempio n. 10
0
void
COSXScreen::enter()
{
	showCursor();

	if (m_isPrimary) {
		CGSetLocalEventsSuppressionInterval(0.0);
		
		// enable global hotkeys
		//setGlobalHotKeysEnabled(true);
	}
	else {
		// reset buttons
		m_buttonState.reset();

		// patch by Yutaka Tsutano
		// wakes the client screen
		// http://synergy-foss.org/spit/issues/details/3287#c12
		io_registry_entry_t entry = IORegistryEntryFromPath(
			kIOMasterPortDefault,
			"IOService:/IOResources/IODisplayWrangler");
		if (entry != MACH_PORT_NULL) {
			IORegistryEntrySetCFProperty(entry, CFSTR("IORequestIdle"), kCFBooleanFalse);
			IOObjectRelease(entry);
		}

		// avoid suppression of local hardware events
		// [email protected]
		CGSetLocalEventsFilterDuringSupressionState(
								kCGEventFilterMaskPermitAllEvents,
								kCGEventSupressionStateSupressionInterval);
		CGSetLocalEventsFilterDuringSupressionState(
								(kCGEventFilterMaskPermitLocalKeyboardEvents |
								kCGEventFilterMaskPermitSystemDefinedEvents),
								kCGEventSupressionStateRemoteMouseDrag);
	}

	// now on screen
	m_isOnScreen = true;
}
Esempio n. 11
0
static Boolean LoadSettingsForUser(CFStringRef username) {
	io_iterator_t		iter = 0;
	io_registry_entry_t	regEntry = 0;
	CFDictionaryRef		newSettings = NULL;
	const char			* name;
	Boolean				success = TRUE;

	if(username != NULL) {
		name = CFStringGetCStringPtr(username, kCFStringEncodingMacRoman);
		write_log(LOG_NOTICE, "Loading settings for user '%s'.", name);
	
		CFPreferencesSynchronize(CFSTR(kDriverAppID), username, 
									kCFPreferencesAnyHost);
		newSettings = CFPreferencesCopyValue(CFSTR(kCurrentParametersKey), 
											CFSTR(kDriverAppID), username, 
											kCFPreferencesAnyHost);
		if(newSettings == NULL)
			write_log(LOG_NOTICE, "No custom settings found.");
	}
	
	if(newSettings == NULL) {
		write_log(LOG_NOTICE, "Loading default settings.");
	
		CFPreferencesSynchronize(CFSTR(kDriverAppID), 
								kCFPreferencesAnyUser, 
								kCFPreferencesCurrentHost);
		newSettings = CFPreferencesCopyValue(CFSTR(kDefaultParametersKey), 
											 CFSTR(kDriverAppID), 
											 kCFPreferencesAnyUser, 
											 kCFPreferencesCurrentHost);
		if(newSettings == NULL) {
			write_log(LOG_ERR, "No default settings found.");
			success = FALSE;
			goto EXIT;
		}
	}
	
	if(IOServiceGetMatchingServices(kIOMasterPortDefault, 
									IOServiceMatching(kIOHIDSystemClass),
									&iter) != KERN_SUCCESS) {
		iter = 0;
		write_log(LOG_ERR, "Error locating HIDSystem service!");
		success = FALSE;
		goto EXIT;
	}
	
	regEntry = IOIteratorNext(iter);
	if(regEntry == 0) {
		write_log(LOG_ERR, "No HIDSystem service found!");
		success = FALSE;
		goto EXIT;
	}
	
	if(IORegistryEntrySetCFProperty(regEntry, CFSTR(kiScroll2SettingsKey), 
									newSettings) != KERN_SUCCESS) {
		write_log(LOG_ERR, "Error setting HIDSystem properties!");
		success = FALSE;
		goto EXIT;
	}
	
EXIT:
	if(newSettings != NULL) {
		CFRelease(newSettings);
		newSettings = NULL;
	}
	if(regEntry != 0) {
		IOObjectRelease(regEntry);
		regEntry = 0;
	}
	if(iter != 0) {
		IOObjectRelease(iter);
		iter = 0;
	}
	return success;
}