1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CHROMEOS_IME_IME_KEYBOARD_H_
6 #define CHROMEOS_IME_IME_KEYBOARD_H_
11 #include "base/basictypes.h"
12 #include "chromeos/chromeos_export.h"
15 namespace input_method
{
17 struct AutoRepeatRate
{
18 AutoRepeatRate() : initial_delay_in_ms(0), repeat_interval_in_ms(0) {}
19 unsigned int initial_delay_in_ms
;
20 unsigned int repeat_interval_in_ms
;
24 kSearchKey
= 0, // Customizable.
25 kControlKey
, // Customizable.
26 kAltKey
, // Customizable.
30 // IMPORTANT: You should update kCustomizableKeys[] in .cc file, if you
31 // add a customizable key.
35 class InputMethodUtil
;
37 class CHROMEOS_EXPORT ImeKeyboard
{
41 // Called when the caps lock state has changed.
42 virtual void OnCapsLockChanged(bool enabled
) = 0;
45 virtual ~ImeKeyboard() {}
47 // Adds/removes observer.
48 virtual void AddObserver(Observer
* observer
) = 0;
49 virtual void RemoveObserver(Observer
* observer
) = 0;
51 // Sets the current keyboard layout to |layout_name|. This function does not
52 // change the current mapping of the modifier keys. Returns true on success.
53 virtual bool SetCurrentKeyboardLayoutByName(
54 const std::string
& layout_name
) = 0;
56 // Sets the current keyboard layout again. We have to call the function every
57 // time when "XI_HierarchyChanged" XInput2 event is sent to Chrome. See
58 // xinput_hierarchy_changed_event_listener.h for details.
59 virtual bool ReapplyCurrentKeyboardLayout() = 0;
61 // Updates keyboard LEDs on all keyboards.
62 // XKB asymmetrically propagates keyboard modifier indicator state changes to
63 // slave keyboards. If the state change is initiated from a client to the
64 // "core/master keyboard", XKB changes global state and pushes an indication
65 // change down to all keyboards. If the state change is initiated by one slave
66 // (physical) keyboard, it changes global state but only pushes an indicator
67 // state change down to that one keyboard.
68 // This function changes LEDs on all keyboards by explicitly updating the
69 // core/master keyboard.
70 virtual void ReapplyCurrentModifierLockStatus() = 0;
72 // Disables the num lock.
73 virtual void DisableNumLock() = 0;
75 // Sets the caps lock status to |enable_caps_lock|. Do not call the function
76 // from non-UI threads.
77 virtual void SetCapsLockEnabled(bool enable_caps_lock
) = 0;
79 // Returns true if caps lock is enabled. Do not call the function from non-UI
81 virtual bool CapsLockIsEnabled() = 0;
83 // Returns true if the current layout supports ISO Level 5 shift.
84 virtual bool IsISOLevel5ShiftAvailable() const = 0;
86 // Returns true if the current layout supports alt gr.
87 virtual bool IsAltGrAvailable() const = 0;
89 // Turns on and off the auto-repeat of the keyboard. Returns true on success.
90 // Do not call the function from non-UI threads.
91 virtual bool SetAutoRepeatEnabled(bool enabled
) = 0;
93 // Sets the auto-repeat rate of the keyboard, initial delay in ms, and repeat
94 // interval in ms. Returns true on success. Do not call the function from
96 virtual bool SetAutoRepeatRate(const AutoRepeatRate
& rate
) = 0;
98 // Returns true if auto repeat is enabled. This function is protected: for
100 static CHROMEOS_EXPORT
bool GetAutoRepeatEnabledForTesting();
102 // On success, set current auto repeat rate on |out_rate| and returns true.
103 // Returns false otherwise. This function is protected: for testability.
104 static CHROMEOS_EXPORT
bool GetAutoRepeatRateForTesting(
105 AutoRepeatRate
* out_rate
);
107 // Returns false if |layout_name| contains a bad character.
108 static CHROMEOS_EXPORT
bool CheckLayoutNameForTesting(
109 const std::string
& layout_name
);
111 // Note: At this moment, classes other than InputMethodManager should not
112 // instantiate the ImeKeyboard class.
113 static ImeKeyboard
* Create();
116 } // namespace input_method
117 } // namespace chromeos
119 #endif // CHROMEOS_IME_IME_KEYBOARD_H_