Exemplo n.º 1
0
void init_keyboard_hardware()
{
    KConfigGroup config(KSharedConfig::openConfig( "kcminputrc" ), "Keyboard");

	QString keyRepeatStr = config.readEntry("KeyboardRepeating", TriStateHelper::getString(STATE_ON));
	TriState keyRepeat = STATE_UNCHANGED;
	if( keyRepeatStr == "true" || keyRepeatStr == TriStateHelper::getString(STATE_ON) ) {
		keyRepeat = STATE_ON;
	}
	else if( keyRepeatStr == "false" || keyRepeatStr == TriStateHelper::getString(STATE_OFF) ) {
		keyRepeat = STATE_OFF;
	}

	int clickVolumePercent = config.readEntry("ClickVolume", -1);
	if( clickVolumePercent != -1 && keyRepeat != STATE_UNCHANGED ) {
		set_volume(clickVolumePercent, keyRepeat);
	}

	if( keyRepeat == STATE_ON ) {
		int delay_ = config.readEntry("RepeatDelay", 250);
		double rate_ = config.readEntry("RepeatRate", 30.);
		set_repeatrate(delay_, rate_);
	}


	TriState numlockState = TriStateHelper::getTriState( config.readEntry( "NumLock", TriStateHelper::getInt(STATE_UNCHANGED) ) );
	if( numlockState != STATE_UNCHANGED ) {
		numlockx_change_numlock_state(QX11Info::display(), numlockState == STATE_ON );
	}
}
Exemplo n.º 2
0
void KeyboardConfig::init_keyboard()
{
	KConfig *config = new KConfig("kcminputrc", true); // Read-only, no globals
	config->setGroup("Keyboard");

	XKeyboardState   kbd;
	XKeyboardControl kbdc;

	XGetKeyboardControl(kapp->getDisplay(), &kbd);
	bool key = config->readBoolEntry("KeyboardRepeating", true);
	kbdc.key_click_percent = config->readNumEntry("ClickVolume", kbd.key_click_percent);
	kbdc.auto_repeat_mode = (key ? AutoRepeatModeOn : AutoRepeatModeOff);

	XChangeKeyboardControl(kapp->getDisplay(),
						   KBKeyClickPercent | KBAutoRepeatMode,
						   &kbdc);

	if( key ) {
		int delay_ = config->readNumEntry("RepeatDelay", 250);
		double rate_ = config->readDoubleNumEntry("RepeatRate", 30);
		set_repeatrate(delay_, rate_);
	}


	int numlockState = config->readNumEntry( "NumLock", 2 );
	if( numlockState != 2 )
		numlockx_change_numlock_state( numlockState == 0 );

	delete config;
}