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 <stdio.h> 15 16 17 KeyboardSettings::KeyboardSettings() 18 { 19 if (get_key_repeat_rate(&fSettings.key_repeat_rate) != B_OK) 20 fSettings.key_repeat_rate = kb_default_key_repeat_rate; 21 22 if (get_key_repeat_delay(&fSettings.key_repeat_delay) != B_OK) 23 fSettings.key_repeat_delay = kb_default_key_repeat_delay; 24 25 fOriginalSettings = fSettings; 26 } 27 28 29 KeyboardSettings::~KeyboardSettings() 30 { 31 } 32 33 34 void 35 KeyboardSettings::SetKeyboardRepeatRate(int32 rate) 36 { 37 if (set_key_repeat_rate(rate) != B_OK) 38 fprintf(stderr, "error while set_key_repeat_rate!\n"); 39 fSettings.key_repeat_rate = rate; 40 } 41 42 43 void 44 KeyboardSettings::SetKeyboardRepeatDelay(bigtime_t delay) 45 { 46 if (set_key_repeat_delay(delay) != B_OK) 47 fprintf(stderr, "error while set_key_repeat_delay!\n"); 48 fSettings.key_repeat_delay = delay; 49 } 50 51 52 void 53 KeyboardSettings::Revert() 54 { 55 SetKeyboardRepeatDelay(fOriginalSettings.key_repeat_delay); 56 SetKeyboardRepeatRate(fOriginalSettings.key_repeat_rate); 57 } 58 59 60 void 61 KeyboardSettings::Defaults() 62 { 63 SetKeyboardRepeatDelay(kb_default_key_repeat_delay); 64 SetKeyboardRepeatRate(kb_default_key_repeat_rate); 65 } 66 67 68 bool 69 KeyboardSettings::IsDefaultable() const 70 { 71 return fSettings.key_repeat_delay != kb_default_key_repeat_delay 72 || fSettings.key_repeat_rate != kb_default_key_repeat_rate; 73 } 74