1 /* 2 * Copyright 2004-2006, the Haiku project. All rights reserved. 3 * Distributed under the terms of the MIT License. 4 * 5 * Authors in chronological order: 6 * mccall@digitalparadise.co.uk 7 * Jérôme Duval 8 * Marcus Overhagen 9 */ 10 11 12 #include "KeyboardSettings.h" 13 14 #include <File.h> 15 #include <FindDirectory.h> 16 #include <Path.h> 17 #include <stdio.h> 18 19 20 KeyboardSettings::KeyboardSettings() 21 { 22 if (get_key_repeat_rate(&fSettings.key_repeat_rate) != B_OK) 23 fSettings.key_repeat_rate = kb_default_key_repeat_rate; 24 25 if (get_key_repeat_delay(&fSettings.key_repeat_delay) != B_OK) 26 fSettings.key_repeat_delay = kb_default_key_repeat_delay; 27 28 fOriginalSettings = fSettings; 29 } 30 31 32 KeyboardSettings::~KeyboardSettings() 33 { 34 } 35 36 37 void 38 KeyboardSettings::SetKeyboardRepeatRate(int32 rate) 39 { 40 if (set_key_repeat_rate(rate) != B_OK) 41 fprintf(stderr, "error while set_key_repeat_rate!\n"); 42 fSettings.key_repeat_rate = rate; 43 } 44 45 46 void 47 KeyboardSettings::SetKeyboardRepeatDelay(bigtime_t delay) 48 { 49 if (set_key_repeat_delay(delay) != B_OK) 50 fprintf(stderr, "error while set_key_repeat_delay!\n"); 51 fSettings.key_repeat_delay = delay; 52 } 53 54 55 void 56 KeyboardSettings::Revert() 57 { 58 SetKeyboardRepeatDelay(fOriginalSettings.key_repeat_delay); 59 SetKeyboardRepeatRate(fOriginalSettings.key_repeat_rate); 60 } 61 62 63 void 64 KeyboardSettings::Defaults() 65 { 66 SetKeyboardRepeatDelay(kb_default_key_repeat_delay); 67 SetKeyboardRepeatRate(kb_default_key_repeat_rate); 68 } 69 70 71 bool 72 KeyboardSettings::IsDefaultable() 73 { 74 return fSettings.key_repeat_delay != kb_default_key_repeat_delay 75 || fSettings.key_repeat_rate != kb_default_key_repeat_rate; 76 } 77