synaptiks::KeyboardMonitor Class Reference

Monitor the keyboard state and emit signals, if the keyboard becomes active or inactive. More...

#include <keyboardmonitor.h>

List of all members.

Public Types

enum  IgnoreKeys { IgnoreNoKeys = 0x0, IgnoreModifierKeys = 0x1, IgnoreModifierCombos = 0x2 }
 

Which keys to ignore when checking the keyboard state.

More...

Public Slots

void start ()
 Start monitoring the keyboard state.
void stop ()
 Stop monitoring the keyboard state.
IgnoreKeys ignoreKeys () const
 Which keys to ignore?
void setIgnoreKeys (IgnoreKeys keys)
 Ignore the given keys.
int idleTime () const
 Get the idle time.
void setIdleTime (int msec)
 Set the idle time.
int pollDelay () const
 Get the polling delay.
void setPollDelay (int msec)
 Set the polling delay.
bool isKeyboardActive () const
 Is the keyboard currently active?

Signals

void typingStarted ()
 Emitted, if the keyboard became active, e.g. the user started typing.
void typingStopped ()
 Emitted, if the keyboard became inactive, e.g. the user stopped typing.

Public Member Functions

 KeyboardMonitor (QObject *parent=0)
 Create a new instance.
virtual ~KeyboardMonitor ()

Properties

IgnoreKeys ignoreKeys
 Which keys to ignore.
int idleTime
 The time in ms between the end of the keyboard activity and emitting typingStopped().
int pollDelay
 The time in ms between to consecutive keyboard checks.
bool keyboardActive
 Is the keyboard active?

Detailed Description

Monitor the keyboard state and emit signals, if the keyboard becomes active or inactive.

This class polls the keyboard state periodically (see pollDelay). Whenever the keyboard state changes, the corresponding signals are emitted (see typingStarted() and typingStopped()). However, to minimize "false positives" (if the user is just making a short break during typing), this class waits a configurable amount of time (see idleTime), before emitting typingStopped().

Bug:

Polling is neither nice nor elegant, however the required XRecord extension is unfortunately broken as of Xorg server 1.6.


Member Enumeration Documentation

Which keys to ignore when checking the keyboard state.

Enumerator:
IgnoreNoKeys 

No keys are ignored, all keys change the keyboard state.

IgnoreModifierKeys 

Ignore modifier keys like Shift or Ctrl.

Note:
This does not include keys pressed in combinations with modifiers (e.g. Ctrl+A)
IgnoreModifierCombos 

Ignore keys pressing in combination with modifiers (e.g. Ctrl+A).

Note:
This causes uppercase letters (e.g. Shift+A) to be ignored, too.

Constructor & Destructor Documentation

KeyboardMonitor::KeyboardMonitor ( QObject *  parent = 0  ) 

Create a new instance.

Parameters:
parent same as for QObject(QObject *)
KeyboardMonitor::~KeyboardMonitor (  )  [virtual]

Destroy this instance.


Member Function Documentation

int synaptiks::KeyboardMonitor::idleTime (  )  const [slot]

Get the idle time.

Returns:
the idle time in milliseconds
See also:
idleTime
IgnoreKeys synaptiks::KeyboardMonitor::ignoreKeys (  )  const [slot]

Which keys to ignore?

Returns:
the keys to ignore
See also:
ignoreKeys
bool KeyboardMonitor::isKeyboardActive (  )  const [slot]

Is the keyboard currently active?

Returns:
true, if the keyboard is active right now, false otherwise.
See also:
keyboardActive
int synaptiks::KeyboardMonitor::pollDelay (  )  const [slot]

Get the polling delay.

Returns:
the polling delay in milliseconds.
See also:
pollDelay
void KeyboardMonitor::setIdleTime ( int  msec  )  [slot]

Set the idle time.

Parameters:
msec the idle time in milliseconds
See also:
idleTime
void KeyboardMonitor::setIgnoreKeys ( IgnoreKeys  keys  )  [slot]

Ignore the given keys.

Parameters:
keys which keys to ignore
See also:
ignoreKeys
void KeyboardMonitor::setPollDelay ( int  msec  )  [slot]

Set the polling delay.

Parameters:
msec the polling delay in milliseconds
See also:
pollDelay
void synaptiks::KeyboardMonitor::typingStopped (  )  [signal]

Emitted, if the keyboard became inactive, e.g. the user stopped typing.

See also:
setIdleTime()

Property Documentation

int KeyboardMonitor::idleTime [read, write]

The time in ms between the end of the keyboard activity and emitting typingStopped().

typingStopped() is not immediately emitted, when the keyboard becomes inactive. The user could just be making a short break. Instead, the class waits for the given amount of milliseconds, before emitting typingStopped().

The default is 2000 ms, which is 2 s.

See also:
setIdleTime(int)
idleTime()
KeyboardMonitor::IgnoreKeys KeyboardMonitor::ignoreKeys [read, write]

Which keys to ignore.

The default is to ignore no keys (IgnoreKeys::IgnoreNoKeys).

See also:
setIgnoreKeys(IgnoreKeys)
ignoreKeys()
bool synaptiks::KeyboardMonitor::keyboardActive [read]

Is the keyboard active?

See also:
isKeyboardActive()
int KeyboardMonitor::pollDelay [read, write]

The time in ms between to consecutive keyboard checks.

The polling delay is the time span between two consecutive queries of the keyboard state. The default is 200 ms, which is 0.2 s. This means, the keyboard will be checked every 200 ms.

See also:
setPollDelay(int)
pollDelay()

The documentation for this class was generated from the following files:
 All Classes Files Functions Typedefs Enumerations Enumerator Properties
Generated on Tue Apr 20 13:25:22 2010 for synaptiks by  doxygen 1.6.3