s5p4418 qt5.7.1移植与虚拟键盘修改
Posted 红尘六欲
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了s5p4418 qt5.7.1移植与虚拟键盘修改相关的知识,希望对你有一定的参考价值。
以下是s5p4418上qt5.7.1的移植记录,下载qt5.7.1源码qt-everywhere-opensource-src-5.7.1.tar.gz这个可以去官方网站下载.
修改qtbase/mkspecs/linux-arm-gnueabi-g++/qmake.conf,修改为如下:
#
# qmake configuration for building with arm-cortex_a9-linux-gnueabi-g++
#
MAKEFILE_GENERATOR = UNIX
CONFIG += incremental
QMAKE_INCREMENTAL_STYLE = sublib
#QT_QPA_DEFAULT_PLATFORM = linux
QT_QPA_DEFAULT_PLATFORM = eglfs
QMAKE_CFLAGS_RELEASE += -O2 -march=armv7-a -mcpu=cortex-a9
QMAKE_CXXFLAGS_RELEASE += -O2 -march=armv7-a -mcpu=cortex-a9
include(../common/linux.conf)
include(../common/gcc-base-unix.conf)
include(../common/g++-unix.conf)
include(./opengl.conf)
# modifications to g++.conf
QMAKE_CC = arm-cortex_a9-linux-gnueabi-gcc
QMAKE_CXX = arm-cortex_a9-linux-gnueabi-g++
QMAKE_LINK = arm-cortex_a9-linux-gnueabi-g++
QMAKE_LINK_SHLIB = arm-cortex_a9-linux-gnueabi-g++
# modifications to linux.conf
QMAKE_AR = arm-cortex_a9-linux-gnueabi-ar cqs
QMAKE_OBJCOPY = arm-cortex_a9-linux-gnueabi-objcopy
QMAKE_NM = arm-cortex_a9-linux-gnueabi-nm -P
QMAKE_STRIP = arm-cortex_a9-linux-gnueabi-strip
EGLFS_PLATFORM_HOOKS_SOURCES = $$PWD/qeglfshooks_icool4418.cpp
# Preferred eglfs backend
#EGLFS_DEVICE_INTEGRATION = eglfs_viv
load(qt_config)
其中需要注意的有两个地方,一个是include(./opengl.conf)一个是EGLFS_PLATFORM_HOOKS_SORCES中的qeglfshooks_icool4418.cpp
这个文件与qmake.conf在同一级目录下,内容如下:
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the qmake spec of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 3 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL3 included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 3 requirements
** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 2.0 or (at your option) the GNU General
** Public license version 3 or any later version approved by the KDE Free
** Qt Foundation. The licenses are as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-2.0.html and
** https://www.gnu.org/licenses/gpl-3.0.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "qeglfshooks.h"
#include <unistd.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <linux/fb.h>
#include <QDebug>
#include <private/qcore_unix_p.h>
#include <EGL/fbdev_window.h>
//#define CONFIG_TEST 1
QT_BEGIN_NAMESPACE
struct my_window {
unsigned int width;
unsigned int height;
};
class QEglFSICOOL4418Hooks : public QEglFSHooks
{
public:
#ifndef CONFIG_TEST
virtual QSize screenSize() const;
virtual EGLNativeWindowType createNativeWindow(QPlatformWindow *window, const QSize &size, const QSurfaceFormat &format);
virtual void destroyNativeWindow(EGLNativeWindowType window);
#else
void platformInit() Q_DECL_OVERRIDE;
QSize screenSize() const Q_DECL_OVERRIDE;
EGLNativeWindowType createNativeWindow(QPlatformWindow *window, const QSize &size, const QSurfaceFormat &format) Q_DECL_OVERRIDE;
void destroyNativeWindow(EGLNativeWindowType window) Q_DECL_OVERRIDE;
EGLNativeDisplayType platformDisplay() const Q_DECL_OVERRIDE;
#endif
#ifdef CONFIG_TEST
private:
QSize mScreenSize;
EGLNativeDisplayType mNativeDisplay;
#endif
};
#ifdef CONFIG_TEST
void QEglFSICOOL4418Hooks::platformInit()
{
QEGLDeviceIntegration::platformInit();
int width, height;
mNativeDisplay = fbGetDisplayByIndex(framebufferIndex());
fbGetDisplayGeometry(mNativeDisplay, &width, &height);
qWarning()<< "QEglFSICOOL4418Hooks::platformInit width: " << width;
mScreenSize.setHeight(height);
mScreenSize.setWidth(width);
}
EGLNativeDisplayType QEglFSICOOL4418Hooks::platformDisplay() const
{
return mNativeDisplay;
}
#endif
QSize QEglFSICOOL4418Hooks::screenSize() const
{
#ifndef CONFIG_TEST
int fd = open("/dev/fb0", O_RDONLY);
if (fd == -1) {
qFatal("Failed to open fb to detect screen resolution!");
}
struct fb_var_screeninfo vinfo;
if (ioctl(fd, FBIOGET_VSCREENINFO, &vinfo) == -1) {
qFatal("Could not get variable screen info");
}
//close(fd);
qt_safe_close(fd);
//qWarning()<< "QEglFSICOOL4418Hooks::screenSize";
return QSize(vinfo.xres, vinfo.yres);
#else
return mScreenSize;
#endif
}
EGLNativeWindowType QEglFSICOOL4418Hooks::createNativeWindow(QPlatformWindow *window, const QSize &size, const QSurfaceFormat &format)
{
#ifndef CONFIG_TEST
Q_UNUSED(window)
Q_UNUSED(format)
//hclydao debug
//qWarning()<< "QEglFSICOOL4418Hooks::createNativeWindow";
//end
fbdev_window *fbwin = reinterpret_cast<fbdev_window *>(malloc(sizeof(fbdev_window)));
//fbdev_window *fbwin = reinterpret_cast<fbdev_window *>(malloc(sizeof(fbdev_window)));
if (NULL == fbwin)
return 0;
fbwin->width = size.width();
fbwin->height = size.height();
//hclydao debug
//qWarning()<< "+++++QEglFSICOOL4418Hooks fbwin.width(): " << fbwin->width << "fbwin.height()" << fbwin->height;
//end
return (EGLNativeWindowType)fbwin;
#else
Q_UNUSED(window)
Q_UNUSED(format)
qWarning()<< "QEglFSICOOL4418Hooks::createNativeWindow";
EGLNativeWindowType eglWindow = fbCreateWindow(mNativeDisplay, 0, 0, size.width(), size.height());
return eglWindow;
#endif
}
void QEglFSICOOL4418Hooks::destroyNativeWindow(EGLNativeWindowType window)
{
#ifndef CONFIG_TEST
free((void*)window);
#else
fbDestroyWindow(window);
#endif
}
QEglFSICOOL4418Hooks eglFSICOOL4418Hooks;
QEglFSHooks *platformHooks = &eglFSICOOL4418Hooks;
QT_END_NAMESPACE
然后在qt源码的同一级目录,新建一个buildarm.sh,内容如下:
#/bin/sh
MYDIR=$PWD
TSLIB=$PWD/tslib/usr
target=/opt/qt5.7.1-icool4418
OPENGLINC=$PWD/opengl/include
OPENGLLIB=$PWD/opengl/libs
if [ -d $target ]; then
rm -rf $target
fi
#sudo add-apt-repository ppa:ubuntu-toolchain-r/test
#sudo apt-get update
#1 install apt-get install gcc-4.8 g++-4.8
#2 modify qtbase/mkspecs/linux-arm-gnueabi-g++/qmake.conf
./clean.sh
cd qt-everywhere-opensource-src-5.7.1
if [ -f ./qtbase/mkspecs/linux-arm-gnueabi-g++/opengl.conf ]; then
rm ./qtbase/mkspecs/linux-arm-gnueabi-g++/opengl.conf
fi
echo "QMAKE_INCDIR_OPENGL_ES2 = $OPENGLINC" >> ./qtbase/mkspecs/linux-arm-gnueabi-g++/opengl.conf
echo "QMAKE_LIBDIR_OPENGL_ES2 = $OPENGLLIB" >> ./qtbase/mkspecs/linux-arm-gnueabi-g++/opengl.conf
echo "QMAKE_INCDIR_OPENGL_ES1 = $OPENGLINC" >> ./qtbase/mkspecs/linux-arm-gnueabi-g++/opengl.conf
echo "QMAKE_LIBDIR_OPENGL_ES1 = $OPENGLLIB" >> ./qtbase/mkspecs/linux-arm-gnueabi-g++/opengl.conf
echo "QMAKE_INCDIR_EGL = $OPENGLINC" >> ./qtbase/mkspecs/linux-arm-gnueabi-g++/opengl.conf
echo "QMAKE_LIBDIR_EGL = $OPENGLLIB" >> ./qtbase/mkspecs/linux-arm-gnueabi-g++/opengl.conf
echo "QMAKE_LIBS_OPENGL_ES2 += -lEGL -lGLESv1_CM -lGLESv2 -lVR" >> ./qtbase/mkspecs/linux-arm-gnueabi-g++/opengl.conf
echo "QMAKE_LIBS_OPENGL_ES1 += -lEGL -lGLESv1_CM -lGLESv2 -lVR" >> ./qtbase/mkspecs/linux-arm-gnueabi-g++/opengl.conf
echo "QMAKE_LIBS_EGL += -lEGL -lGLESv1_CM -lGLESv2 -lVR" >> ./qtbase/mkspecs/linux-arm-gnueabi-g++/opengl.conf
echo yes | ./configure \\
-v \\
-prefix $target \\
-release \\
-xplatform linux-arm-gnueabi-g++ \\
-opensource \\
-no-accessibility \\
-make libs \\
-optimized-qmake \\
-pch \\
-qt-sql-sqlite \\
-qt-zlib \\
-tslib \\
-no-sse2 \\
-no-cups \\
-no-glib \\
-I$TSLIB/include -L$TSLIB/lib \\
-qt-libjpeg \\
-no-openssl \\
-gui \\
-opengl es2 \\
-qt-libpng \\
-widgets \\
-qpa eglfs \\
-make examples \\
-nomake tests \\
-no-iconv \\
-no-directfb \\
-egl \\
-eglfs \\
-linuxfb \\
-no-separate-debug-info \\
-no-icu \\
-no-pkg-config \\
-no-qml-debug \\
-no-xcb
CPU_NUM=$(cat /proc/cpuinfo |grep processor|wc -l)
CPU_NUM=$((CPU_NUM+1))
make -j${CPU_NUM} && make install || exit 1
echo "####build successful!#####"
echo "####install $target#####"
cd $MYDIR
./mktarget.sh
其中buildarm.sh中会新建opengl.conf并向里面填充内容.
同时需要tslib和你的opengl相关的头文件和库,目录结构如下图所示:
opengl相关头文件和库可以直接拷贝android源码下的
tslib相关的文件,就是tslib编译安装后生成的所有文件,tslib移植这里就不说明了
clean.sh内容如下:
#!/bin/sh
cd qt-everywhere-opensource-src-5.7.1
filelist="qtbase/examples
qtbase/qmake
qtbase/tests
qtconnectivity
qtquickcontrols
qtscxml
qtserialbus
qtwebview"
if [ -f ./qtbase/Makefile ]; then
cd ./qtbase
make distclean
cd -
make distclean
rm -f `find -name *.o`
rm -f `find -name *.a`
rm -f `find -name *.version.in`
rm -f `find -name *_wrapper.sh`
rm -f ./qtbase/bin/qmake
rm -f ./qtbase/config.status
rm -rf `find -name .rcc`
for filedir in $filelist; do
cd $filedir
#echo "---$PWD"
rm -f `find -name Makefile`
cd -
done
fi
echo "#####clean end ######"
mktarget.sh内容如下:
#!/bin/sh
SRC_DIR=/opt/qt5.7.1-icool4418
echo "....mktarget start please waiting...."
if [ -f target-qt5.7.1.tar.bz2 ]; then
rm target-qt5.7.1.tar.bz2
fi
list=`cat << EOF
$SRC_DIR/lib/*
$SRC_DIR/plugins/*
$SRC_DIR/qml/*
$SRC_DIR/translations/*
$SRC_DIR/examples/quick/views/*
$SRC_DIR/examples/quick/rendercontrol/*
$SRC_DIR/examples/quick/demos/samegame/*
$SRC_DIR/examples/sql/books/*
$SRC_DIR/examples/opengl/qopenglwidget/*
$SRC_DIR/examples/qt3d/scene3d/*
$SRC_DIR/examples/quickcontrols2/gallery/*
$SRC_DIR/examples/virtualkeyboard/basic/*
$SRC_DIR/examples/widgets/painting/deform/*
$SRC_DIR/examples/widgets/painting/pathstroke/*
$SRC_DIR/examples/widgets/widgets/wiggly/*
$SRC_DIR/examples/widgets/painting/concentriccircles/*
$SRC_DIR/examples/svg/embeddedsvgviewer/*
$SRC_DIR/examples/quick/quickwidgets/quickwidget/*
$SRC_DIR/examples/opengl/qopenglwindow/*
$SRC_DIR/examples/widgets/mainwindows/mainwindow/*
$SRC_DIR/examples/svg/embedded/fluidlauncher/*
$SRC_DIR/qtvirtualkeyboard/pinyin/dict_pinyin.dat
EOF
`
tar -cjvf target-qt5.7.1.tar.bz2 $list
chmod 777 target-qt5.7.1.tar.bz2
echo "....mktarget done...."
echo "+++target:$PWD/target-qt5.7.1.tar.bz2++++"
编译完成最后会在当前目录下生成一个target-qt5.7.1.tar.bz2的文件,直接拷贝根文件系统目录下解压,就可以开始使用了
如果需要使用虚拟键盘,还需要修改qtvirtualkeyboard/src/config.pri在
# Enable features by languages
contains(CONFIG, lang-ja.*): CONFIG += openwnn
上加上
#add by hclydao
CONFIG += disable-desktop
CONFIG += lang-zh_CN
然后修改qtvirtualkeyboard/examples/virtualkeyboard/basic/basic.pro如下
#add by hclydao
CONFIG += disable-desktop
disable-desktop|!isEmpty(CROSS_COMPILE)|qnx {
DEFINES += MAIN_QML=\\\\\\"basic-b2qt.qml\\\\\\"
} else {
DEFINES += MAIN_QML=\\\\\\"Basic.qml\\\\\\"
}
加上了disable-desktop
qt5启动脚本文件如下:
#!/bin/sh
TSLIB_TSDEVICE=/dev/input/event0
TSLIB_CONFFILE=/etc/ts.conf
export TSLIB_TSDEVICE
export TSLIB_CONFFILE
export TSLIB_PLUGINDIR=/usr/lib/ts
export TSLIB_CALIBFILE=/etc/pointercal
export TSLIB_CONSOLEDEVICE=none
export TSLIB_FBDEVICE=/dev/fb0
export QTDIR=/opt/qt5.7.1-icool4418
export LD_LIBRARY_PATH=$QTDIR/lib:$LD_LIBRARY_PATH:$TSLIB_ROOT/lib
export QT_QPA_PLATFORM_PLUGIN_PATH=$QTDIR/plugins
export QT_QPA_FONTDIR=/lib/fonts
export QT_QPA_GENERIC_PLUGINS=tslib:$TSLIB_TSDEVICE
export QML2_IMPORT_PATH=$QTDIR/qml
export QML_IMPORT_PATH=$QTDIR/qml
export LD_PRELOAD=/usr/lib/libts.so
export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
export PATH=/bin:/sbin:/usr/bin/:/usr/sbin:/usr/local/bin
#export QT_QPA_PLATFORM=linuxfb:fb=/dev/fb0:size=1024x600:mmSize=1024x600:offset=0x0:tty=/dev/tty1
export QT_QPA_PLATFORM=eglfs
export QT_QPA_EGLFS_WIDTH=1024
export QT_QPA_EGLFS_HEIGHT=600
export QT_QPA_EGLFS_PHYSICAL_WIDTH=252
export QT_QPA_EGLFS_PHYSICAL_HEIGHT=160
export QT_IM_MODULE=qtvirtualkeyboard
export QT_QPA_EGLFS_TSLIB=1
#export QT_QPA_FB_TSLIB=1
export QT_VIRTUALKEYBOARD_PINYIN_DICTIONARY=$QTDIR/qtvirtualkeyboard/pinyin/dict_pinyin.dat
#export QT_VIRTUALKEYBOARD_STYLE=retro
if [ -c ${TSLIB_TSDEVICE} ]; then
export QPA_MOUSE_PROTO="Tslib MouseMan:/dev/input/mice"
if [ ! -s /etc/pointercal ] ; then
if [ -f /etc/pointercal ]; then
rm /etc/pointercal
fi
/usr/bin/ts_calibrate
fi
else
export QPA_MOUSE_PROTO="MouseMan:/dev/input/mice"
fi
export QPA_KEYBOARD=TTY:/dev/tty1
export HOME=/root
$QTDIR/examples/svg/embedded/fluidlauncher/fluidlauncher
hotplug
运行截图:
============================================
作者:hclydao
http://blog.csdn.net/hclydao
版权没有,但是转载请保留此段声明
============================================
以上是关于s5p4418 qt5.7.1移植与虚拟键盘修改的主要内容,如果未能解决你的问题,请参考以下文章
QT Linux/Ubuntu 平台安装qt5.7.1 2016.12.25