2008-11-28 15:42:52 +01:00
|
|
|
/****************************************************************************
|
|
|
|
* graphics/nxmu/nxmu_kbdin.c
|
|
|
|
*
|
2021-02-05 11:12:53 +01:00
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed with
|
|
|
|
* this work for additional information regarding copyright ownership. The
|
|
|
|
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
|
|
|
* "License"); you may not use this file except in compliance with the
|
|
|
|
* License. You may obtain a copy of the License at
|
2008-11-28 15:42:52 +01:00
|
|
|
*
|
2021-02-05 11:12:53 +01:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2008-11-28 15:42:52 +01:00
|
|
|
*
|
2021-02-05 11:12:53 +01:00
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
|
|
* License for the specific language governing permissions and limitations
|
|
|
|
* under the License.
|
2008-11-28 15:42:52 +01:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Included Files
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include <nuttx/config.h>
|
|
|
|
|
2009-12-15 19:12:29 +01:00
|
|
|
#include <stdint.h>
|
2008-12-04 04:19:59 +01:00
|
|
|
#include <stdlib.h>
|
2008-11-28 15:42:52 +01:00
|
|
|
#include <errno.h>
|
|
|
|
#include <debug.h>
|
|
|
|
|
2013-03-09 22:12:20 +01:00
|
|
|
#include <nuttx/kmalloc.h>
|
2011-07-24 22:49:01 +02:00
|
|
|
#include <nuttx/nx/nx.h>
|
2013-03-09 22:12:20 +01:00
|
|
|
|
2019-03-13 16:16:30 +01:00
|
|
|
#include "nxmu.h"
|
2008-11-28 15:42:52 +01:00
|
|
|
|
|
|
|
#ifdef CONFIG_NX_KBD
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Public Functions
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: nxmu_kbdin
|
|
|
|
*
|
2013-12-29 18:11:48 +01:00
|
|
|
* Description:
|
2008-11-28 15:42:52 +01:00
|
|
|
* New keyboard data has been received from the thread or interrupt
|
|
|
|
* handler that manages some kind of keyboard/keypad hardware. Route that
|
|
|
|
* positional data to the appropriate window client.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2019-04-05 16:24:46 +02:00
|
|
|
void nxmu_kbdin(FAR struct nxmu_state_s *nxmu, uint8_t nch, FAR uint8_t *ch)
|
2008-11-28 15:42:52 +01:00
|
|
|
{
|
2008-12-04 04:19:59 +01:00
|
|
|
FAR struct nxclimsg_kbdin_s *outmsg;
|
2008-11-28 15:42:52 +01:00
|
|
|
int size;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
/* Allocate a bigger message to account for the variable amount of
|
|
|
|
* character data.
|
|
|
|
*/
|
|
|
|
|
2008-12-04 04:19:59 +01:00
|
|
|
size = sizeof(struct nxclimsg_kbdin_s) + nch - 1;
|
2014-09-01 01:26:36 +02:00
|
|
|
outmsg = (FAR struct nxclimsg_kbdin_s *)kmm_malloc(size);
|
2008-11-28 15:42:52 +01:00
|
|
|
if (outmsg)
|
|
|
|
{
|
|
|
|
/* Give the keypad input only to the top child */
|
|
|
|
|
2008-12-04 04:19:59 +01:00
|
|
|
outmsg->msgid = NX_CLIMSG_KBDIN;
|
2019-04-05 16:24:46 +02:00
|
|
|
outmsg->wnd = nxmu->be.topwnd;
|
2008-12-04 04:19:59 +01:00
|
|
|
outmsg->nch = nch;
|
2008-11-28 15:42:52 +01:00
|
|
|
|
2008-12-04 04:19:59 +01:00
|
|
|
for (i = 0; i < nch; i++)
|
2008-11-28 15:42:52 +01:00
|
|
|
{
|
|
|
|
outmsg->ch[i] = ch[i];
|
|
|
|
}
|
|
|
|
|
2020-01-02 17:49:34 +01:00
|
|
|
nxmu_sendclientwindow(nxmu->be.topwnd, outmsg, size);
|
2014-09-01 01:04:02 +02:00
|
|
|
kmm_free(outmsg);
|
2008-11-28 15:42:52 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* CONFIG_NX_KBD */
|