8#include <QtCore/QDebug>
9#include <QtCore/QSocketNotifier>
10#include <QtCore/private/qcore_unix_p.h>
45 qCDebug(lcQpaQnxVirtualKeyboard) <<
"Starting keyboard event processing";
52 delete m_readNotifier;
61 pps_decoder_cleanup(m_decoder);
67 pps_encoder_cleanup(m_encoder);
80 m_encoder =
new pps_encoder_t;
81 m_decoder =
new pps_decoder_t;
83 pps_encoder_initialize(m_encoder,
false);
84 pps_decoder_initialize(m_decoder, 0);
87 m_fd = ::open(ms_PPSPath, O_RDWR);
90 qCDebug(lcQpaQnxVirtualKeyboard) <<
"Unable to open" << ms_PPSPath
91 <<
':' << strerror(errno);
96 m_buffer =
new char[ms_bufferSize];
97 if (Q_UNLIKELY(!m_buffer)) {
98 qCritical(
"QQnxVirtualKeyboard: Unable to allocate buffer of %zu bytes. "
99 "Size is unavailable.", ms_bufferSize);
106 m_readNotifier =
new QSocketNotifier(m_fd, QSocketNotifier::Read);
107 QObject::connect(m_readNotifier, SIGNAL(activated(QSocketDescriptor)),
this, SLOT(ppsDataReady()));
114 if (!prepareToSend())
118 pps_encoder_add_string(m_encoder,
"msg",
"info");
119 pps_encoder_add_string(m_encoder,
"id",
"1");
121 return writeCurrentPPSEncoder();
126 qint64 nread = qt_safe_read(m_fd, m_buffer, ms_bufferSize - 1);
128 qCDebug(lcQpaQnxVirtualKeyboard,
"keyboardMessage size: %lld", nread);
140 if (Q_UNLIKELY(
static_cast<size_t>(nread) > ms_bufferSize - 1)) {
141 qCritical(
"QQnxVirtualKeyboard: Keyboard buffer size too short; need %lld.", nread + 1);
147 pps_decoder_parse_pps_str(m_decoder, m_buffer);
148 pps_decoder_push(m_decoder, 0);
149#if defined(QQNXVIRTUALKEYBOARD_DEBUG)
150 pps_decoder_dump_tree(m_decoder, stderr);
154 if (Q_UNLIKELY(pps_decoder_get_string(m_decoder,
"error", &value) == PPS_DECODER_OK)) {
155 qCritical(
"QQnxVirtualKeyboard: Keyboard PPS decoder error: %s", value ? value :
"[null]");
159 if (pps_decoder_get_string(m_decoder,
"msg", &value) == PPS_DECODER_OK) {
160 if (strcmp(value,
"show") == 0)
162 else if (strcmp(value,
"hide") == 0)
164 else if (strcmp(value,
"info") == 0)
165 handleKeyboardInfoMessage();
166 else if (strcmp(value,
"connect") == 0)
167 qCDebug(lcQpaQnxVirtualKeyboard,
"Unhandled command 'connect'");
169 qCritical(
"QQnxVirtualKeyboard: Unexpected keyboard PPS msg value: %s", value ? value :
"[null]");
170 }
else if (pps_decoder_get_string(m_decoder,
"res", &value) == PPS_DECODER_OK) {
171 if (strcmp(value,
"info") == 0)
172 handleKeyboardInfoMessage();
174 qCritical(
"QQnxVirtualKeyboard: Unexpected keyboard PPS res value: %s", value ? value :
"[null]");
176 qCritical(
"QQnxVirtualKeyboard: Unexpected keyboard PPS message type");
184 if (Q_UNLIKELY(pps_decoder_push(m_decoder,
"dat") != PPS_DECODER_OK)) {
185 qCritical(
"QQnxVirtualKeyboard: Keyboard PPS dat object not found");
188 if (Q_UNLIKELY(pps_decoder_get_int(m_decoder,
"size", &newHeight) != PPS_DECODER_OK)) {
189 qCritical(
"QQnxVirtualKeyboard: Keyboard PPS size field not found");
192 setHeight(newHeight);
194 qCDebug(lcQpaQnxVirtualKeyboard,
"size=%d", newHeight);
199 qCDebug(lcQpaQnxVirtualKeyboard) << Q_FUNC_INFO;
201 if (!prepareToSend())
211 pps_encoder_reset(m_encoder);
214 pps_encoder_add_string(m_encoder,
"msg",
"show");
216 return writeCurrentPPSEncoder();
221 qCDebug(lcQpaQnxVirtualKeyboard) << Q_FUNC_INFO;
223 if (!prepareToSend())
226 pps_encoder_add_string(m_encoder,
"msg",
"hide");
228 return writeCurrentPPSEncoder();
233 if (m_fd == -1 && !connect())
236 pps_encoder_reset(m_encoder);
242 if (::write(m_fd, pps_encoder_buffer(m_encoder), pps_encoder_length(m_encoder)) == -1) {
251 if (!prepareToSend())
255 pps_encoder_add_string(m_encoder,
"msg",
"options");
256 pps_encoder_start_object(m_encoder,
"dat");
258 pps_encoder_add_string(m_encoder,
"enter", enterKeyTypeStr());
259 pps_encoder_add_string(m_encoder,
"type", keyboardModeStr());
261 pps_encoder_end_object(m_encoder);
263 writeCurrentPPSEncoder();
268 switch (keyboardMode()) {
288 return "alphanumeric";
298 switch (enterKeyType()) {
300 return "enter.default";
302 return "enter.connect";
312 return "enter.search";
316 return "enter.submit";
~QQnxVirtualKeyboardPps()
bool hideKeyboard() override
void applyKeyboardOptions() override
bool showKeyboard() override
Q_LOGGING_CATEGORY(lcEventDispatcher, "qt.eventdispatcher")