Open mgrouch opened 3 years ago
Script to build wxWidgets 3.1.x for it and OpenCPN with GTK3
For wxWidgets
sudo apt-get -y install build-essential cmake gettext git-core libgtk-3-dev libgtk-3-0 libgl1-mesa-dev libglu1-mesa-dev \
zlib1g-dev libjpeg-dev libpng-dev libtiff5-dev libsm-dev autotools-dev autoconf libexpat1-dev libxt-dev \
libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev libwebkit2gtk-4.0-dev libnotify-dev
git clone --recurse-submodules https://github.com/wxWidgets/wxWidgets.git
cd wxWidgets || exit 255
git checkout 301e5ec9fe3719fac8a2786e8675b19e2242183e
mkdir build-gtk
cd build-gtk || exit 255
../configure \
--with-gtk=3 \
--with-libpng=sys \
--with-libjpeg=sys \
--with-libtiff=sys \
--with-regex=sys \
--with-zlib=sys \
--with-expat=sys \
--enable-display \
--enable-geometry \
--enable-graphics_ctx \
--enable-mediactrl \
--enable-sound \
--with-opengl \
--enable-webview
make -sj5
sudo make install
sudo ldconfig
For OpenCPN (see comments below for manual steps):
sudo apt-get -y install build-essential cmake gettext git-core gpsd gpsd-clients libgps-dev \
libglu1-mesa-dev libgtk-3-dev libbz2-dev libtinyxml-dev libportaudio2 portaudio19-dev libcurl4-openssl-dev \
libexpat1-dev libcairo2-dev libarchive-dev liblzma-dev libexif-dev libelf-dev libsqlite3-dev \
bc bison flex libssl-dev python3 ddd htop
git clone -b PPA-5.2.0.8 https://github.com/opencpn/opencpn.git
cd opencpn && mkdir build
# in CMakeLists.txt replace references to 3.0 wxWidgets to 3.1 wxWidgets
cd build || exit 255
cmake -DOCPN_BUNDLE_TCDATA=ON -DOCPN_BUNDLE_GSHHS=ON -DOCPN_USE_GL=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DOCPN_USE_CRASHREPORT=ON -DOCPN_ENABLE_PORTAUDIO=OFF -DOCPN_ENABLE_SYSTEM_CMD_SOUND=ON -DOCPN_FORCE_GTK3=ON ..
# in ../src/glChartCanvas.cpp add #include <GL/glx.h>
make -sj5
sudo make install
Ok. I'm now able to add touch event listeners and receive them in OpenCPN. Now the issue is how to make it work with fewer code changes. I tried to post right click event from long touch event handler in MyFrame class but it doesn't seem have any effect. I've tried to post wxContextMenuEvent to no effect. Great that I receive touch events in the code but my total lack of experience with wxWidgets stops me there.
Any help? Thanks
Simplest thing to do is to post virtual mouse events into the ChartCanvas class.
Long touch->Right click emulation: chcanv.cpp:8587 Pinch zoom: Suggest following logic of "wheel zoom"...chcanv.cpp:8620
Good job so far..... Good Luck going forward Dave
I've put in chcanv.cpp into constructor
printf("%s\n", "registering events");
if ( !EnableTouchEvents( wxTOUCH_PRESS_GESTURES ) )
{
printf("%s\n", "failed to enable touch events");
// Still bind event handlers just in case they still work?
}
Bind(wxEVT_LONG_PRESS, &ChartCanvas::OnLongPress, this);
Bind(wxEVT_TWO_FINGER_TAP, &ChartCanvas::OnTwoFingerTap, this);
Bind(wxEVT_PRESS_AND_TAP, &ChartCanvas::OnPressAndTap, this);
and added methods
void ChartCanvas::OnLongPress( wxLongPressEvent& event )
{
printf("%s\n", "long press!!!");
wxEvtHandler *evthp = GetEventHandler();
wxMouseEvent ev( wxEVT_RIGHT_UP );
ev.m_x = event.GetPosition().x;
ev.m_y = event.GetPosition().y;
::wxPostEvent( evthp, ev );
}
void ChartCanvas::OnTwoFingerTap( wxTwoFingerTapEvent& event )
{
}
void ChartCanvas::OnPressAndTap(wxPressAndTapEvent& event)
{
}
I see that long touch gets caught but context menu doesn't pop up
For tight click, you need something like: CallPopupMenu(mx , my); See the code...
Ok
with this in chcanv.cpp into constructor (and obvious include file additions)
printf("%s\n", "registering events");
if ( !EnableTouchEvents( wxTOUCH_PRESS_GESTURES | wxTOUCH_ZOOM_GESTURE ) )
{
printf("%s\n", "failed to enable touch events");
// Still bind event handlers just in case they still work?
}
Bind(wxEVT_LONG_PRESS, &ChartCanvas::OnLongPress, this);
Bind(wxEVT_TWO_FINGER_TAP, &ChartCanvas::OnTwoFingerTap, this);
Bind(wxEVT_PRESS_AND_TAP, &ChartCanvas::OnPressAndTap, this);
Bind(wxEVT_GESTURE_ZOOM, &ChartCanvas::OnZoom, this);
and added methods
void ChartCanvas::OnZoom(wxZoomGestureEvent& event)
{
if ( event.IsGestureStart() )
{
printf("%s\n", "Zoom gesture started");
}
if ( event.IsGestureEnd() )
{
printf("%s\n", "Zoom gesture ended");
ZoomCanvas( event.GetZoomFactor(), true, false );
}
}
void ChartCanvas::OnLongPress( wxLongPressEvent& event )
{
printf("%s\n", "long press!!!");
CallPopupMenu(event.GetPosition().x, event.GetPosition().y);
}
void ChartCanvas::OnTwoFingerTap( wxTwoFingerTapEvent& event )
{
}
void ChartCanvas::OnPressAndTap(wxPressAndTapEvent& event)
{
}
Zoom gesture works (tested on raspberry pi) I see popup menu, but it goes away as I let long touch go. And how about other places (not on chart) which need right click emulation? Right click (long touch) definitely need more of your attention and you need to test on raspberry pi (where most of touch screen cockpit displays would be). BTW this builds on GTK3 (better for wayland, better for innovation)
GTK3 has a bug with touch menus. I have to rollback to using GTK2
See https://gitlab.gnome.org/GNOME/gtk/-/issues/945
and merge request
Going back to GTK2 doesn't help. Touch events do not work at all. Handlers fail to register. So instead I've went with upgrade of GTK3 to the latest tag. Now menu works fine, touch two finger zoom work fine, long touch right click works (only on chart canvas so far). But dragging a map with the finger stopped working. Here is how I could build it:
Step1 Build GTK3 from debian source on raspberry pi 4 with latest 32-bit Buster
sudo apt-get -y install build-essential cmake bc bison flex \
at-spi2-core \
dh-sequence-gir \
fonts-cantarell \
gnome-pkg-tools \
gobject-introspection \
gtk-doc-tools \
libcolord-dev \
libcups2-dev \
libgdk-pixbuf2.0-dev \
libgirepository1.0-dev \
libjson-glib-dev \
librest-dev \
libxkbfile-dev \
sassc \
xvfb \
libcairo2-doc \
xsltproc
git clone -b "debian/2.40.0+dfsg-5" https://salsa.debian.org/gnome-team/gdk-pixbuf.git
cd gdk-pixbuf || exit 255
sudo apt-get -y install dh-exec meson
dpkg-buildpackage -rfakeroot -b -uc -us
sudo dpkg -i ../libgdk-pixbuf2.0-bin_2.40.0+dfsg-5_armhf.deb
sudo dpkg -i ../libgdk-pixbuf2.0-common_2.40.0+dfsg-5_all.deb
sudo dpkg -i ../libgdk-pixbuf2.0-0_2.40.0+dfsg-5_armhf.deb
sudo dpkg -i ../gir1.2-gdkpixbuf-2.0_2.40.0+dfsg-5_armhf.deb
sudo dpkg -i ../libgdk-pixbuf2.0-dev_2.40.0+dfsg-5_armhf.deb
cd ..
git clone -b "debian/3.24.23-2" https://salsa.debian.org/gnome-team/gtk3.git
cd gtk3 || exit 255
dpkg-buildpackage -rfakeroot -b -uc -us
sudo dpkg -i ../libgtk-3-common_3.24.23-2_all.deb
sudo dpkg -i ../libgtk-3-0_3.24.23-2_armhf.deb
sudo dpkg -i ../gir1.2-gtk-3.0_3.24.23-2_armhf.deb
sudo dpkg -i ../libgtk-3-dev_3.24.23-2_armhf.deb
Step2. Build wxWidgets 3.1.x from source against GTK3
# Build gtk3 before
# See ../gtk3-rpi/
sudo apt-get -y install build-essential cmake gettext git-core libgtk-3-dev libgl1-mesa-dev libglu1-mesa-dev \
libgtk2.0-dev \
zlib1g-dev libjpeg-dev libpng-dev libtiff5-dev libsm-dev autotools-dev autoconf libexpat1-dev libxt-dev \
libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev libwebkit2gtk-4.0-dev libnotify-dev
git clone --recurse-submodules https://github.com/wxWidgets/wxWidgets.git
cd wxWidgets || exit 255
#git checkout 301e5ec9fe3719fac8a2786e8675b19e2242183e
mkdir build-gtk3
cd build-gtk3 || exit 255
../configure \
--with-gtk=3 \
--with-libpng=sys \
--with-libjpeg=sys \
--with-libtiff=sys \
--with-regex=sys \
--with-zlib=sys \
--with-expat=sys \
--enable-display \
--enable-geometry \
--enable-graphics_ctx \
--enable-mediactrl \
--enable-sound \
--with-opengl \
--enable-webview
make -sj5
sudo make install
sudo ldconfig
Step3 Build OpenCPN against wxWidgets3.1.x (see manual steps in comments and the changes I applied in .h, .cpp code in the posts above)
# Build wxWidgets before
# See ../wxWidgets-rpi/
sudo apt-get -y install build-essential cmake gettext git-core gpsd gpsd-clients libgps-dev \
libglu1-mesa-dev libgtk-3-dev libbz2-dev libtinyxml-dev libportaudio2 portaudio19-dev libcurl4-openssl-dev \
libexpat1-dev libcairo2-dev libarchive-dev liblzma-dev libexif-dev libelf-dev libsqlite3-dev \
bc bison flex libssl-dev python3 ddd htop
git clone -b PPA-5.2.0.8 https://github.com/opencpn/opencpn.git
cd opencpn && mkdir build
# in CMakeLists.txt replace references to 3.0 wxWidgets to 3.1 wxWidgets
cd build || exit 255
cmake -DOCPN_BUNDLE_TCDATA=ON -DOCPN_BUNDLE_GSHHS=ON -DOCPN_USE_GL=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DOCPN_USE_CRASHREPORT=ON -DOCPN_ENABLE_PORTAUDIO=OFF -DOCPN_ENABLE_SYSTEM_CMD_SOUND=ON -DOCPN_FORCE_GTK3=ON ..
# in ../src/glChartCanvas.cpp add #include <GL/glx.h>
make -sj5
sudo make install
Ok
with this in src/chcanv.cpp into constructor (and obvious include file additions)
if ( !EnableTouchEvents( wxTOUCH_PRESS_GESTURES | wxTOUCH_ZOOM_GESTURE | wxTOUCH_PAN_GESTURES ))
{
wxLogError("Failed to enable touch events");
// Still bind event handlers just in case they still work?
}
Bind(wxEVT_LONG_PRESS, &ChartCanvas::OnLongPress, this);
Bind(wxEVT_TWO_FINGER_TAP, &ChartCanvas::OnTwoFingerTap, this);
Bind(wxEVT_PRESS_AND_TAP, &ChartCanvas::OnPressAndTap, this);
Bind(wxEVT_GESTURE_ZOOM, &ChartCanvas::OnZoom, this);
Bind(wxEVT_GESTURE_PAN, &ChartCanvas::OnPan, this);
include include/chcanv.h
void OnZoom(wxZoomGestureEvent& event);
void OnLongPress(wxLongPressEvent& event);
void OnTwoFingerTap(wxTwoFingerTapEvent& event);
void OnPressAndTap(wxPressAndTapEvent& event);
void OnPan(wxPanGestureEvent& event);
and added methods
void ChartCanvas::OnPan(wxPanGestureEvent& event)
{
wxEvtHandler *evthp = GetEventHandler();
wxMouseEvent ev( wxEVT_MOTION );
ev.m_x = event.GetPosition().x + event.GetDelta().x; //mouse_x;
ev.m_y = event.GetPosition().y + event.GetDelta().y; //mouse_y;
ev.m_leftDown = true;
::wxPostEvent( evthp, ev );
}
void ChartCanvas::OnZoom(wxZoomGestureEvent& event)
{
if ( event.IsGestureEnd() )
{
if (event.GetZoomFactor() > 1.1 || event.GetZoomFactor() < 0.9)
ZoomCanvas( event.GetZoomFactor(), true, false );
}
}
void ChartCanvas::OnLongPress( wxLongPressEvent& event )
{
wxEvtHandler *evthp = GetEventHandler();
wxMouseEvent ev( wxEVT_RIGHT_DOWN );
ev.m_x = event.GetPosition().x;
ev.m_y = event.GetPosition().y;
::wxPostEvent( evthp, ev );
}
void ChartCanvas::OnTwoFingerTap( wxTwoFingerTapEvent& event )
{
}
void ChartCanvas::OnPressAndTap(wxPressAndTapEvent& event)
{
}
Now finger zoom works again. Right click with long touch works too.
There are couple of issues:
Thanks, --MG
OK. Finally. I've found solution on how to do right click emulation with long touch using external separate program.
So in previous patch replace EnableTouchEvents call with
if ( !EnableTouchEvents( wxTOUCH_ZOOM_GESTURE | wxTOUCH_PAN_GESTURES ))
This (and the code changes above) will make OpenCPN to support zoom and pan with touch gestures.
Right click gesture will be supported on whole linux desktop using this solution:
wget https://raw.githubusercontent.com/bareboat-necessities/my-bareboat/master/right-click-emu/right-click-emu.sh
chmod +x right-click-emu.sh
./right-click-emu.sh
reboot
Thanks, --MG
Found one more issue. Two finger zoom with OpenGL enabled most of the time is recognized as pan instead of zoom. Weird...
Hmm. Somehow with openGL enabled zoom action requires 3 fingers. 2 fingers do pan.
With this and OpenGL enabled it looks better. However zoom requires 3 fingers.
void ChartCanvas::OnPan(wxPanGestureEvent& event)
{
if ( event.IsGestureEnd() )
{
wxEvtHandler *evthp = GetEventHandler();
wxMouseEvent ev( wxEVT_MOTION );
ev.m_x = event.GetPosition().x + event.GetDelta().x; //mouse_x;
ev.m_y = event.GetPosition().y + event.GetDelta().y; //mouse_y;
ev.m_leftDown = true;
::wxPostEvent( evthp, ev );
}
}
I've put my commits in this branch
https://github.com/bareboat-necessities/OpenCPN
So you can build it now like this:
# Build wxWidgets before
# See ../wxWidgets-rpi/
sudo apt-get -y install build-essential cmake gettext git-core gpsd gpsd-clients libgps-dev \
libglu1-mesa-dev libgtk-3-dev libbz2-dev libtinyxml-dev libportaudio2 portaudio19-dev libcurl4-openssl-dev \
libexpat1-dev libcairo2-dev libarchive-dev liblzma-dev libexif-dev libelf-dev libsqlite3-dev \
bc bison flex libssl-dev python3 ddd htop
git clone https://github.com/bareboat-necessities/OpenCPN.git
cd OpenCPN && mkdir build
#git clone -b PPA-5.2.0.8 https://github.com/opencpn/opencpn.git
#cd opencpn && mkdir build
cd build || exit 255
cmake -DOCPN_BUNDLE_TCDATA=ON -DOCPN_BUNDLE_GSHHS=ON -DOCPN_USE_GL=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DOCPN_USE_CRASHREPORT=ON -DOCPN_ENABLE_PORTAUDIO=OFF -DOCPN_ENABLE_SYSTEM_CMD_SOUND=ON -DOCPN_FORCE_GTK3=ON ..
make -sj5
sudo make install
Right click gesture will be supported on whole linux desktop using this solution:
wget https://raw.githubusercontent.com/bareboat-necessities/my-bareboat/master/right-click-emu/right-click-emu.sh
chmod +x right-click-emu.sh
./right-click-emu.sh
reboot
I've put it under circleCI build from here:
https://github.com/bareboat-necessities/OpenCPN
which gets deployed to https://cloudsmith.io/~bbn-projects/repos/bbn-repo/packages/ (Click "Set me up" on that page for instructions for your distro)
and Ubuntu builds are here:
https://launchpad.net/~bbn-projects/+archive/ubuntu/bbn-opencpn/+packages
Is this have any chance to become a pull request or be manually implemented by opencpn team ?
This function also relates to recent Android work. So I expect we can see this in the master branch fairly soon. I'll study your PR, and co-ordinate with Android implementation. Thanks for the reminder
Off Topic, but related https://github.com/OpenCPN/OpenCPN/issues/762 Is this still an issue, or is it fixed?
2 fingers zoom still an issue
Sent from my iPhone
On Apr 23, 2021, at 10:18 AM, Rick Gleason @.***> wrote:
Off Topic, but related #762 Is this still an issue, or is it fixed?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.
Mike, Thanks. Have you noticed what Didier wrote about in https://github.com/OpenCPN/OpenCPN/issues/762 "Don't defer Leftup Event when dragging" ? He provided some code for that too, but I wonder if you have noticed this problem while using the touch interface? I'm trying to figure out if #762 can be closed.
I haven’t had many issues with dragging. I’ve seen some small jumps at the beginning of drag which were not too big of a deal. Might that’s what that fix trying to address.
Sent from my iPhone
On Apr 23, 2021, at 10:29 AM, Rick Gleason @.***> wrote:
Mike, Thanks. Have you noticed what Didier wrote about in #762 "Don't defer Leftup Event when dragging" ? He provided some code for that too, but I wonder if you have noticed this problem while using the touch interface?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.
See https://github.com/OpenCPN/OpenCPN/pull/2333 that fixes all the mentioned issues
FYI. Even with current released version 5.2.4 I've managed to make it work without changing it with external program twofing and udev rules.
You can check how it works in BBN OS 2021-09-10
https://bareboat-necessities.github.io/my-bareboat/bareboat-os.html
Thanks
Mikhail, I think you should have a look on master branch of OpenCPN. My changed have been integrated, without the need for an external program, simplifying the integration. It needs wxWidgets > 3.1.1, though. Thanks !
Le 12/09/2021 à 01:01, Mikhail Grushinskiy a écrit :
FYI. Even with current released version 5.2.4 I've managed to make it work without changing it with external program twofing and udev rules.
You can check how it works in BBN OS 2021-09-10
https://bareboat-necessities.github.io/my-bareboat/bareboat-os.html https://bareboat-necessities.github.io/my-bareboat/bareboat-os.html
Thanks
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/OpenCPN/OpenCPN/issues/2057#issuecomment-917498398, or unsubscribe https://github.com/notifications/unsubscribe-auth/AASGXTW5OPSGYPNS2R755YDUBPNTZANCNFSM4SGVL7ZQ. Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
Mgrouch can this be closed now?
Closing has to wait till wxWidgets comes out as 3.2.x
3.1.x versions are not going to be in Debian
See also #2396
One of the reasons to use WxWidgets 3.2.x
Mgrouch... Reviving this for discussion. In OCPN 5.9.1, I have implemented the EnableTouchEvents() in chcanv.cpp. But for some reason, using RPi4/bookworm, I do not ever get any events. Any ideas?
#ifdef HAVE_WX_GESTURE_EVENTS
if (!EnableTouchEvents(wxTOUCH_ZOOM_GESTURE |
wxTOUCH_PRESS_GESTURES)) {
wxLogError("Failed to enable touch events");
}
Bind(wxEVT_GESTURE_ZOOM, &ChartCanvas::OnZoom, this);
Bind(wxEVT_LONG_PRESS, &ChartCanvas::OnLongPress, this);
Dave
The is also touch PAN event. and there was PR more recent than my original patches.
Might be worth trying enabling all touch events and adding handles only for some.
Also long touch for right click should be enabled somewhere else. Otherwise it works only on chart canvas. And it’s needed in other places too. select all in chart downloader would be one example.
I get no events, not even long touch. If I can get that one simple touch event to work, the rest come easily. Funny thing is that these touch events apparently work on flatpak build, as reported on CF. I begin to suspect the wxWidgets build has error. Very strange.
On Wayland or on X11?
Also we might watch out for an impact by this:
I am testing on X11. Now rebuilding wxWidgets to current github master, to test. More info as I find it.
What’s the version of the wxWidgets which upholds having issue with? Debian or Ubuntu packaged?
Debian, wxw 3.2.2
EDIT: Flatpak is on 3.2.4, so there is an obvious test top do. This is under way.
New hardware. Running locally built wx3.2.2.1, I can now get LongTouch events in OCPN. This is some progress. However, I have not succeeded in getting two-finger zoom events. The events are enabled.they just never come.
Same with wx3.2.4 Clearly something is missing here...
More debug, testing new touchscreen monitor and "official" rPI 7" display. Neither setup will produce multi-touch events.
Built the "event" sample from wxWidgets distribution. This has a test module that catches all wxGesture events, and reports as debug output. Only gestures recognized by this sample are "long-touch" and "pan", both of which are single point gestures. Never see any multi-touch events.
Built gtk3 locally, adding printf debug looking for gesture events. No multi-point gestures seen.
For good measure, tested flatpak OCPN beta. And pinch zoom gestures are handled correctly, actually works very nicely.
So, some tentative conclusions:
Looking for any/all input on this. I'm running out of ideas.
mgrouch... Have you tried the wxWidgets sample called "event" on your current hardware?
Does two finger zoom work in Chromium browser on your system? Worth checking to eliminate lower lever set up issues
Yes, it does. I wonder if Chromium is talking directly to the hardware, not depending on the linux kernel stack?
Yes, it does. I wonder if Chromium is talking directly to the hardware, not depending on the linux kernel stack?
No it doesn’t talk directly to hardware. It uses input event stack libraries.
It would be interesting to compare output of
ldd opencpn
of regular build with flatpak build.
Which libraries versions would be different?
Checked ldd. There are huge differences in the system libraries. Almost every one is different. Will study. Any hints on libs critical to multitouch?
I checked horse example and two finger zoom didn’t work in it. WxWidgets 3.2.2 example.
Trying to build WxWidgets 3.2.5
OK, thanks, same result as me with the horse, wx3.2.4
Trying to build WxWidgets 3.2.5
There are wx3.2.5 packages available at http://mumin.crabdance.com/wx/3.25/. This is just the source package from Debian Sid, backported to bookwoem
We are working to test the wxWidgets samples, included when built locally, to remove any OCPN questions. There is a sample called "event", which tracks and reports gesture events as seen by wx. If this sample demo fails on multi-touch, O will also fail.
Indeed. It should be perfectly possible to build this sample against the 3.2.5 packages to test also that combination without having t make yet another painful arm wxw rebuild.
Add touch gestures hangling for two finger zoom and long press as a right click emulation. It is possible with wxWidgets 3.1.x
For examples see:
in wxWidgets 3.1.4 code.
With this there will be no need for twofing and evdev-rce hacks. It will work on linux (raspberry pi, etc) right after installing OpenCPN.
Thanks, --MG