Qt 4.8
Public Functions | Private Slots | Properties | List of all members
QDirectFBKeyboardHandlerPrivate Class Reference
Inheritance diagram for QDirectFBKeyboardHandlerPrivate:
QObject

Public Functions

 QDirectFBKeyboardHandlerPrivate (QDirectFBKeyboardHandler *handler)
 
void resume ()
 
void suspend ()
 
 ~QDirectFBKeyboardHandlerPrivate ()
 
- Public Functions inherited from QObject
bool blockSignals (bool b)
 If block is true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke anything connected to it). More...
 
const QObjectListchildren () const
 Returns a list of child objects. More...
 
bool connect (const QObject *sender, const char *signal, const char *member, Qt::ConnectionType type=Qt::AutoConnection) const
 
bool disconnect (const char *signal=0, const QObject *receiver=0, const char *member=0)
 
bool disconnect (const QObject *receiver, const char *member=0)
 
void dumpObjectInfo ()
 Dumps information about signal connections, etc. More...
 
void dumpObjectTree ()
 Dumps a tree of children to the debug output. More...
 
QList< QByteArraydynamicPropertyNames () const
 Returns the names of all properties that were dynamically added to the object using setProperty(). More...
 
virtual bool event (QEvent *)
 This virtual function receives events to an object and should return true if the event e was recognized and processed. More...
 
virtual bool eventFilter (QObject *, QEvent *)
 Filters events if this object has been installed as an event filter for the watched object. More...
 
template<typename T >
findChild (const QString &aName=QString()) const
 Returns the child of this object that can be cast into type T and that is called name, or 0 if there is no such object. More...
 
template<typename T >
QList< T > findChildren (const QString &aName=QString()) const
 Returns all children of this object with the given name that can be cast to type T, or an empty list if there are no such objects. More...
 
template<typename T >
QList< T > findChildren (const QRegExp &re) const
 
bool inherits (const char *classname) const
 Returns true if this object is an instance of a class that inherits className or a QObject subclass that inherits className; otherwise returns false. More...
 
void installEventFilter (QObject *)
 Installs an event filter filterObj on this object. More...
 
bool isWidgetType () const
 Returns true if the object is a widget; otherwise returns false. More...
 
void killTimer (int id)
 Kills the timer with timer identifier, id. More...
 
virtual const QMetaObjectmetaObject () const
 Returns a pointer to the meta-object of this object. More...
 
void moveToThread (QThread *thread)
 Changes the thread affinity for this object and its children. More...
 
QString objectName () const
 
QObjectparent () const
 Returns a pointer to the parent object. More...
 
QVariant property (const char *name) const
 Returns the value of the object's name property. More...
 
Q_INVOKABLE QObject (QObject *parent=0)
 Constructs an object with parent object parent. More...
 
void removeEventFilter (QObject *)
 Removes an event filter object obj from this object. More...
 
void setObjectName (const QString &name)
 
void setParent (QObject *)
 Makes the object a child of parent. More...
 
bool setProperty (const char *name, const QVariant &value)
 Sets the value of the object's name property to value. More...
 
void setUserData (uint id, QObjectUserData *data)
 
bool signalsBlocked () const
 Returns true if signals are blocked; otherwise returns false. More...
 
int startTimer (int interval)
 Starts a timer and returns a timer identifier, or returns zero if it could not start a timer. More...
 
QThreadthread () const
 Returns the thread in which the object lives. More...
 
QObjectUserDatauserData (uint id) const
 
virtual ~QObject ()
 Destroys the object, deleting all its child objects. More...
 

Private Slots

void readKeyboardData ()
 

Properties

int bytesRead
 
DFBEvent event
 
IDirectFBEventBuffer * eventBuffer
 
QDirectFBKeyboardHandlerhandler
 
QSocketNotifierkeyboardNotifier
 
int lastKeycode
 
Qt::KeyboardModifiers lastModifiers
 
int lastUnicode
 

Additional Inherited Members

- Public Slots inherited from QObject
void deleteLater ()
 Schedules this object for deletion. More...
 
- Signals inherited from QObject
void destroyed (QObject *=0)
 This signal is emitted immediately before the object obj is destroyed, and can not be blocked. More...
 
- Static Public Functions inherited from QObject
static bool connect (const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
 Creates a connection of the given type from the signal in the sender object to the method in the receiver object. More...
 
static bool connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type=Qt::AutoConnection)
 
static bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *member)
 Disconnects signal in object sender from method in object receiver. More...
 
static bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &member)
 
static uint registerUserData ()
 
static QString tr (const char *sourceText, const char *comment=0, int n=-1)
 
static QString trUtf8 (const char *sourceText, const char *comment=0, int n=-1)
 
- Static Public Variables inherited from QObject
static const QMetaObject staticMetaObject
 This variable stores the meta-object for the class. More...
 
- Protected Functions inherited from QObject
virtual void childEvent (QChildEvent *)
 This event handler can be reimplemented in a subclass to receive child events. More...
 
virtual void connectNotify (const char *signal)
 This virtual function is called when something has been connected to signal in this object. More...
 
virtual void customEvent (QEvent *)
 This event handler can be reimplemented in a subclass to receive custom events. More...
 
virtual void disconnectNotify (const char *signal)
 This virtual function is called when something has been disconnected from signal in this object. More...
 
 QObject (QObjectPrivate &dd, QObject *parent=0)
 
int receivers (const char *signal) const
 Returns the number of receivers connected to the signal. More...
 
QObjectsender () const
 Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; otherwise it returns 0. More...
 
int senderSignalIndex () const
 
virtual void timerEvent (QTimerEvent *)
 This event handler can be reimplemented in a subclass to receive timer events for the object. More...
 
- Protected Variables inherited from QObject
QScopedPointer< QObjectDatad_ptr
 
- Static Protected Variables inherited from QObject
static const QMetaObject staticQtMetaObject
 

Detailed Description

Definition at line 66 of file qdirectfbkeyboard.cpp.

Constructors and Destructors

◆ QDirectFBKeyboardHandlerPrivate()

QDirectFBKeyboardHandlerPrivate::QDirectFBKeyboardHandlerPrivate ( QDirectFBKeyboardHandler handler)

Definition at line 88 of file qdirectfbkeyboard.cpp.

91 {
93 
94  IDirectFB *fb = QDirectFBScreen::instance()->dfb();
95  if (!fb) {
96  qCritical("QDirectFBKeyboardHandler: DirectFB not initialized");
97  return;
98  }
99 
100  DFBResult result;
101  result = fb->CreateInputEventBuffer(fb, DICAPS_KEYS, DFB_TRUE,
102  &eventBuffer);
103  if (result != DFB_OK) {
104  DirectFBError("QDirectFBKeyboardHandler: "
105  "Unable to create input event buffer", result);
106  return;
107  }
108 
109  int fd;
110  result = eventBuffer->CreateFileDescriptor(eventBuffer, &fd);
111  if (result != DFB_OK) {
112  DirectFBError("QDirectFBKeyboardHandler: "
113  "Unable to create file descriptor", result);
114  return;
115  }
116 
117  int flags = ::fcntl(fd, F_GETFL, 0);
118  ::fcntl(fd, F_SETFL, flags | O_NONBLOCK);
119 
120  memset(&event, 0, sizeof(event));
121 
123  connect(keyboardNotifier, SIGNAL(activated(int)),
124  this, SLOT(readKeyboardData()));
125  resume();
126 }
Q_GUI_EXPORT QScreen * qt_screen
Definition: qscreen_qws.cpp:69
#define SLOT(a)
Definition: qobjectdefs.h:226
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
The QSocketNotifier class provides support for monitoring activity on a file descriptor.
#define SIGNAL(a)
Definition: qobjectdefs.h:227
static bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
Creates a connection of the given type from the signal in the sender object to the method in the rece...
Definition: qobject.cpp:2580
Qt::KeyboardModifiers lastModifiers
IDirectFB * dfb()
QDirectFBKeyboardHandler * handler
int fcntl(int, int,...)
static QDirectFBScreen * instance()
IDirectFBEventBuffer * eventBuffer
Q_CORE_EXPORT void qCritical(const char *,...)

◆ ~QDirectFBKeyboardHandlerPrivate()

QDirectFBKeyboardHandlerPrivate::~QDirectFBKeyboardHandlerPrivate ( )

Definition at line 139 of file qdirectfbkeyboard.cpp.

140 {
141  if (eventBuffer)
142  eventBuffer->Release(eventBuffer);
143 }
IDirectFBEventBuffer * eventBuffer

Functions

◆ readKeyboardData

void QDirectFBKeyboardHandlerPrivate::readKeyboardData ( )
privateslot

Definition at line 145 of file qdirectfbkeyboard.cpp.

Referenced by QDirectFBKeyboardHandlerPrivate().

146 {
147  if(!qt_screen)
148  return;
149 
150  for (;;) {
151  // GetEvent returns DFB_UNSUPPORTED after CreateFileDescriptor().
152  // This seems stupid and I really hope it's a bug which will be fixed.
153 
154  // DFBResult ret = eventBuffer->GetEvent(eventBuffer, &event);
155 
156  char *buf = reinterpret_cast<char*>(&event);
157  int ret = ::read(keyboardNotifier->socket(),
158  buf + bytesRead, sizeof(DFBEvent) - bytesRead);
159  if (ret == -1) {
160  if (errno != EAGAIN)
161  qWarning("QDirectFBKeyboardHandlerPrivate::readKeyboardData(): %s",
162  strerror(errno));
163  return;
164  }
165 
166  Q_ASSERT(ret >= 0);
167  bytesRead += ret;
168  if (bytesRead < int(sizeof(DFBEvent)))
169  break;
170  bytesRead = 0;
171 
172  Q_ASSERT(event.clazz == DFEC_INPUT);
173 
174  const DFBInputEvent input = event.input;
175 
176  Qt::KeyboardModifiers modifiers = Qt::NoModifier;
177 
178  // Not implemented:
179  // if (input.modifiers & DIMM_SUPER)
180  // if (input.modifiers & DIMM_HYPER)
181 
182  if (!(input.flags & DIEF_KEYSYMBOL) ||
183  !(input.flags & DIEF_KEYID) ||
184  !(input.type & (DIET_KEYPRESS|DIET_KEYRELEASE)))
185  {
186  static bool first = true;
187  if (first) {
188  qWarning("QDirectFBKeyboardHandler - Getting unexpected non-keyboard related events");
189  first = false;
190  }
191  break;
192  }
193 
194  if (input.flags & DIEF_MODIFIERS) {
195  if (input.modifiers & DIMM_SHIFT)
196  modifiers |= Qt::ShiftModifier;
197  if (input.modifiers & DIMM_CONTROL)
198  modifiers |= Qt::ControlModifier;
199  if (input.modifiers & DIMM_ALT)
200  modifiers |= Qt::AltModifier;
201  if (input.modifiers & DIMM_ALTGR)
202  modifiers |= Qt::AltModifier;
203  if (input.modifiers & DIMM_META)
204  modifiers |= Qt::MetaModifier;
205  }
206 
207 
208  const bool press = input.type & DIET_KEYPRESS;
209  DFBInputDeviceKeySymbol symbol = input.key_symbol;
210  int unicode = -1;
211  int keycode = 0;
212 
213  keycode = keymap()->value(symbol);
214  if (DFB_KEY_TYPE(symbol) == DIKT_UNICODE)
215  unicode = symbol;
216 
217  if (unicode != -1 || keycode != 0) {
218  bool autoRepeat = false;
219  if (press) {
220  if (unicode == lastUnicode && keycode == lastKeycode && modifiers == lastModifiers) {
221  autoRepeat = true;
222  } else {
223  lastUnicode = unicode;
225  lastModifiers = modifiers;
226  }
227  } else {
228  lastUnicode = lastKeycode = -1;
229  lastModifiers = 0;
230  }
231  if (autoRepeat) {
232  handler->processKeyEvent(unicode, keycode,
233  modifiers, false, autoRepeat);
234 
235  }
236 
237  handler->processKeyEvent(unicode, keycode,
238  modifiers, press, autoRepeat);
239  }
240  }
241 }
Q_GUI_EXPORT QScreen * qt_screen
Definition: qscreen_qws.cpp:69
int keycode
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
Qt::KeyboardModifiers lastModifiers
Q_CORE_EXPORT void qWarning(const char *,...)
QDirectFBKeyboardHandler * handler
virtual void processKeyEvent(int unicode, int keycode, Qt::KeyboardModifiers modifiers, bool isPress, bool autoRepeat)
Sends a key event to the Qt for Embedded Linux server application.
Definition: qkbd_qws.cpp:363
int errno
int socket() const
Returns the socket identifier specified to the constructor.

◆ resume()

void QDirectFBKeyboardHandlerPrivate::resume ( )

Definition at line 133 of file qdirectfbkeyboard.cpp.

Referenced by QDirectFBKeyboardHandlerPrivate().

134 {
135  eventBuffer->Reset(eventBuffer);
137 }
void setEnabled(bool)
If enable is true, the notifier is enabled; otherwise the notifier is disabled.
IDirectFBEventBuffer * eventBuffer

◆ suspend()

void QDirectFBKeyboardHandlerPrivate::suspend ( )

Definition at line 128 of file qdirectfbkeyboard.cpp.

129 {
131 }
void setEnabled(bool)
If enable is true, the notifier is enabled; otherwise the notifier is disabled.

Properties

◆ bytesRead

int QDirectFBKeyboardHandlerPrivate::bytesRead
private

Definition at line 81 of file qdirectfbkeyboard.cpp.

Referenced by readKeyboardData().

◆ event

DFBEvent QDirectFBKeyboardHandlerPrivate::event
private

Definition at line 80 of file qdirectfbkeyboard.cpp.

Referenced by QDirectFBKeyboardHandlerPrivate(), and readKeyboardData().

◆ eventBuffer

IDirectFBEventBuffer* QDirectFBKeyboardHandlerPrivate::eventBuffer
private

◆ handler

QDirectFBKeyboardHandler* QDirectFBKeyboardHandlerPrivate::handler
private

Definition at line 77 of file qdirectfbkeyboard.cpp.

Referenced by readKeyboardData().

◆ keyboardNotifier

QSocketNotifier* QDirectFBKeyboardHandlerPrivate::keyboardNotifier
private

◆ lastKeycode

int QDirectFBKeyboardHandlerPrivate::lastKeycode
private

Definition at line 82 of file qdirectfbkeyboard.cpp.

Referenced by readKeyboardData().

◆ lastModifiers

Qt::KeyboardModifiers QDirectFBKeyboardHandlerPrivate::lastModifiers
private

Definition at line 83 of file qdirectfbkeyboard.cpp.

Referenced by readKeyboardData().

◆ lastUnicode

int QDirectFBKeyboardHandlerPrivate::lastUnicode
private

Definition at line 82 of file qdirectfbkeyboard.cpp.

Referenced by readKeyboardData().


The documentation for this class was generated from the following file: