7#include <QtCore/QDebug>
8#include <QtCore/QSocketNotifier>
9#include <QtCore/private/qcore_unix_p.h>
25const char *QQnxVirtualKeyboardPps::ms_PPSPath =
"/pps/services/input/control";
26const size_t QQnxVirtualKeyboardPps::ms_bufferSize = 2048;
44 qCDebug(lcQpaQnxVirtualKeyboard) <<
"Starting keyboard event processing";
49void QQnxVirtualKeyboardPps::close()
51 delete m_readNotifier;
60 pps_decoder_cleanup(m_decoder);
66 pps_encoder_cleanup(m_encoder);
75bool QQnxVirtualKeyboardPps::connect()
79 m_encoder =
new pps_encoder_t;
80 m_decoder =
new pps_decoder_t;
82 pps_encoder_initialize(m_encoder,
false);
83 pps_decoder_initialize(m_decoder, 0);
86 m_fd =
::open(ms_PPSPath, O_RDWR);
89 qCDebug(lcQpaQnxVirtualKeyboard) <<
"Unable to open" << ms_PPSPath
90 <<
':' << strerror(errno);
95 m_buffer =
new char[ms_bufferSize];
97 qCritical(
"QQnxVirtualKeyboard: Unable to allocate buffer of %zu bytes. "
98 "Size is unavailable.", ms_bufferSize);
111bool QQnxVirtualKeyboardPps::queryPPSInfo()
113 if (!prepareToSend())
117 pps_encoder_add_string(m_encoder,
"msg",
"info");
118 pps_encoder_add_string(m_encoder,
"id",
"1");
120 return writeCurrentPPSEncoder();
123void QQnxVirtualKeyboardPps::ppsDataReady()
127 qCDebug(lcQpaQnxVirtualKeyboard,
"keyboardMessage size: %lld", nread);
139 if (
Q_UNLIKELY(
static_cast<size_t>(nread) > ms_bufferSize - 1)) {
140 qCritical(
"QQnxVirtualKeyboard: Keyboard buffer size too short; need %lld.", nread + 1);
146 pps_decoder_parse_pps_str(m_decoder, m_buffer);
147 pps_decoder_push(m_decoder, 0);
148#if defined(QQNXVIRTUALKEYBOARD_DEBUG)
149 pps_decoder_dump_tree(m_decoder, stderr);
153 if (
Q_UNLIKELY(pps_decoder_get_string(m_decoder,
"error", &
value) == PPS_DECODER_OK)) {
154 qCritical(
"QQnxVirtualKeyboard: Keyboard PPS decoder error: %s",
value ?
value :
"[null]");
158 if (pps_decoder_get_string(m_decoder,
"msg", &
value) == PPS_DECODER_OK) {
159 if (strcmp(
value,
"show") == 0)
161 else if (strcmp(
value,
"hide") == 0)
163 else if (strcmp(
value,
"info") == 0)
164 handleKeyboardInfoMessage();
165 else if (strcmp(
value,
"connect") == 0)
166 qCDebug(lcQpaQnxVirtualKeyboard,
"Unhandled command 'connect'");
168 qCritical(
"QQnxVirtualKeyboard: Unexpected keyboard PPS msg value: %s",
value ?
value :
"[null]");
169 }
else if (pps_decoder_get_string(m_decoder,
"res", &
value) == PPS_DECODER_OK) {
170 if (strcmp(
value,
"info") == 0)
171 handleKeyboardInfoMessage();
173 qCritical(
"QQnxVirtualKeyboard: Unexpected keyboard PPS res value: %s",
value ?
value :
"[null]");
175 qCritical(
"QQnxVirtualKeyboard: Unexpected keyboard PPS message type");
179void QQnxVirtualKeyboardPps::handleKeyboardInfoMessage()
183 if (
Q_UNLIKELY(pps_decoder_push(m_decoder,
"dat") != PPS_DECODER_OK)) {
184 qCritical(
"QQnxVirtualKeyboard: Keyboard PPS dat object not found");
187 if (
Q_UNLIKELY(pps_decoder_get_int(m_decoder,
"size", &newHeight) != PPS_DECODER_OK)) {
188 qCritical(
"QQnxVirtualKeyboard: Keyboard PPS size field not found");
193 qCDebug(lcQpaQnxVirtualKeyboard,
"size=%d", newHeight);
200 if (!prepareToSend())
210 pps_encoder_reset(m_encoder);
213 pps_encoder_add_string(m_encoder,
"msg",
"show");
215 return writeCurrentPPSEncoder();
222 if (!prepareToSend())
225 pps_encoder_add_string(m_encoder,
"msg",
"hide");
227 return writeCurrentPPSEncoder();
230bool QQnxVirtualKeyboardPps::prepareToSend()
232 if (m_fd == -1 && !connect())
235 pps_encoder_reset(m_encoder);
239bool QQnxVirtualKeyboardPps::writeCurrentPPSEncoder()
241 if (
::write(m_fd, pps_encoder_buffer(m_encoder), pps_encoder_length(m_encoder)) == -1) {
250 if (!prepareToSend())
254 pps_encoder_add_string(m_encoder,
"msg",
"options");
255 pps_encoder_start_object(m_encoder,
"dat");
257 pps_encoder_add_string(m_encoder,
"enter", enterKeyTypeStr());
258 pps_encoder_add_string(m_encoder,
"type", keyboardModeStr());
260 pps_encoder_end_object(m_encoder);
262 writeCurrentPPSEncoder();
265const char* QQnxVirtualKeyboardPps::keyboardModeStr()
const
287 return "alphanumeric";
295const char* QQnxVirtualKeyboardPps::enterKeyTypeStr()
const
299 return "enter.default";
301 return "enter.connect";
311 return "enter.search";
315 return "enter.submit";
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
void setHeight(int height)
void setVisible(bool visible)
EnterKeyType enterKeyType() const
KeyboardMode keyboardMode() const
~QQnxVirtualKeyboardPps()
bool hideKeyboard() override
void applyKeyboardOptions() override
bool showKeyboard() override
Combined button and popup list for selecting options.
static qint64 qt_safe_read(int fd, void *data, qint64 maxlen)
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
#define Q_LOGGING_CATEGORY(name,...)
#define qCDebug(category,...)
file open(QIODevice::ReadOnly)
gzip write("uncompressed data")