add USVFB IAL engine

This commit is contained in:
Vincent Wei
2018-07-29 21:02:12 +08:00
parent 8b73fe0022
commit cde8a653b4
4 changed files with 245 additions and 1 deletions
+3 -1
View File
@@ -48,6 +48,8 @@ CISCO_TOUCHPAD_SRCS = cisco_touchpad.h cisco_touchpad.c
MSTAR_SRCS = mstarial.h mstarial.c
DFB_SRCS = dfb.h dfb.c
USVFB_SRCS = usvfbinput.c usvfbinput.h
if MGIAL_CONSOLE
native_libial_la_LIBADD = native/libnative.la
endif
@@ -73,4 +75,4 @@ libial_la_SOURCES = $(COMMON_SRCS) $(DUMMY_SRCS) $(JZ4740_SRCS) \
$(COMMINPUT_SRCS) $(QVFB_SRCS) $(WVFB_SRCS) \
$(QEMU_SRCS) $(IPAQ_H3600_SRCS) $(IPAQ_H5400_SRCS) \
$(TSLIB_SRCS) $(SHANDONG_LIDE_SRCS) $(CISCO_TOUCHPAD_SRCS) \
$(MSTAR_SRCS) $(DFB_SRCS)
$(MSTAR_SRCS) $(DFB_SRCS) $(USVFB_SRCS)
+6
View File
@@ -114,6 +114,9 @@
#ifdef _MGIAL_DFB
#include "dfb.h"
#endif
#ifdef _MGIAL_USVFB
#include "usvfbinput.h"
#endif
#define LEN_ENGINE_NAME 16
#define LEN_MTYPE_NAME 16
@@ -190,6 +193,9 @@ static INPUT inputs [] =
#ifdef _MGIAL_DFB
{"dfb", InitDFBInput, TermDFBInput},
#endif
#ifdef _MGIAL_USVFB
{"usvfb", InitUSVFBInput, TermUSVFBInput},
#endif
/* ... end of general IAL engines */
};
+181
View File
@@ -0,0 +1,181 @@
/*
* This file is part of MiniGUI, a mature cross-platform windowing
* and Graphics User Interface (GUI) support system for embedded systems
* and smart IoT devices.
*
* Copyright (C) 2002~2018, Beijing FMSoft Technologies Co., Ltd.
* Copyright (C) 1998~2002, WEI Yongming
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Or,
*
* As this program is a library, any link to this program must follow
* GNU General Public License version 3 (GPLv3). If you cannot accept
* GPLv3, you need to be licensed from FMSoft.
*
* If you have got a commercial license of this program, please use it
* under the terms and conditions of the commercial license.
*
* For more information about the commercial license, please refer to
* <http://www.minigui.com/en/about/licensing-policy/>.
*/
/*
** usvfbinput.c: Input Engine for UnixSocket Virtual Frame Buffer
**
** Created by Vincent Wei, 2018/07/29
*/
#include <stdio.h>
#include <stdlib.h>
#include "common.h"
#ifdef _MGIAL_USVFB
#include "minigui.h"
#include "misc.h"
#include "ial.h"
#include "usvfbinput.h"
#define USVFB_MOUSEINPUT 0x01
#define USVFB_KBINPUT 0x02
#define USVFB_MOUSELBUTTON 0x01
#define USVFB_MOUSERBUTTON 0x04
/* ----------------------------------------------------------------------- */
// OS input driver or application must implement these input functions
// hardware must be initialized before this engine can be used.
extern int __comminput_init (void);
extern int __comminput_ts_getdata (short *x, short *y, short *button);
extern int __comminput_kb_getdata (short *key, short *status);
extern int __comminput_wait_for_input (struct timeval *timeout);
extern void __comminput_deinit (void);
/* ----------------------------------------------------------------------- */
static short MOUSEX = 0, MOUSEY = 0, MOUSEBUTTON = 0;
static short KEYCODE = 0, KEYSTATUS = 0;
/************************ Low Level Input Operations **********************/
static int mouse_update (void)
{
return 1;
}
static void mouse_getxy (int *x, int* y)
{
*x = MOUSEX;
*y = MOUSEY;
}
static int mouse_getbutton (void)
{
int button = 0;
if (MOUSEBUTTON == USVFB_MOUSELBUTTON)
button |= IAL_MOUSE_LEFTBUTTON;
else if (MOUSEBUTTON == USVFB_MOUSERBUTTON)
button |= IAL_MOUSE_RIGHTBUTTON;
MOUSEBUTTON = 0;
return button;
}
static unsigned char kbd_state [NR_KEYS];
static int keyboard_update (void)
{
if (KEYCODE == 0)
return 0;
return KEYCODE + 1;
}
static const char* keyboard_getstate (void)
{
return (const char*)kbd_state;
}
static int wait_event (int which, int maxfd, fd_set *in, fd_set *out, fd_set *except,
struct timeval *timeout)
{
int retvalue;
retvalue = __comminput_wait_for_input (timeout);
if (retvalue > 0) {
if (retvalue & USVFB_MOUSEINPUT) {
if (__comminput_ts_getdata (&MOUSEX, &MOUSEY, &MOUSEBUTTON) == 0)
retvalue = IAL_MOUSEEVENT;
else
retvalue = -1;
}
else if (retvalue & USVFB_KBINPUT) {
if (__comminput_kb_getdata (&KEYCODE, &KEYSTATUS) == 0) {
if (kbd_state[KEYCODE] == KEYSTATUS) {
retvalue = -1;
}
kbd_state[KEYCODE] = KEYSTATUS;
retvalue = IAL_KEYEVENT;
}
else
retvalue = -1;
}
else
retvalue = -1;
}
else if (retvalue < 0) {
retvalue = -1;
}
return retvalue;
}
BOOL InitUSVFBInput (INPUT* input, const char* mdev, const char* mtype)
{
/* input hardware should be initialized before this function is called */
if (__comminput_init ())
return FALSE;
input->update_mouse = mouse_update;
input->get_mouse_xy = mouse_getxy;
input->set_mouse_xy = NULL;
input->get_mouse_button = mouse_getbutton;
input->set_mouse_range = NULL;
input->suspend_mouse= NULL;
input->resume_mouse = NULL;
input->update_keyboard = keyboard_update;
input->get_keyboard_state = keyboard_getstate;
input->suspend_keyboard = NULL;
input->resume_keyboard = NULL;
input->set_leds = NULL;
input->wait_event = wait_event;
return TRUE;
}
void TermUSVFBInput (void)
{
__comminput_deinit ();
}
#endif /* _MGIAL_USVFB */
+55
View File
@@ -0,0 +1,55 @@
/*
* This file is part of MiniGUI, a mature cross-platform windowing
* and Graphics User Interface (GUI) support system for embedded systems
* and smart IoT devices.
*
* Copyright (C) 2002~2018, Beijing FMSoft Technologies Co., Ltd.
* Copyright (C) 1998~2002, WEI Yongming
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Or,
*
* As this program is a library, any link to this program must follow
* GNU General Public License version 3 (GPLv3). If you cannot accept
* GPLv3, you need to be licensed from FMSoft.
*
* If you have got a commercial license of this program, please use it
* under the terms and conditions of the commercial license.
*
* For more information about the commercial license, please refer to
* <http://www.minigui.com/en/about/licensing-policy/>.
*/
/*
** usvfbinput.h: head file for USVFB IAL Engine
**
** Created by Vincent Wei, 2018/07/29
*/
#ifndef _IAL_USVFB_H
#define _IAL_USVFB_H
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
BOOL InitUSVFBInput (INPUT* input, const char* mdev, const char* mtype);
void TermUSVFBInput (void);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* _IAL_USVFB_H */