Touch screen gestures

Discussions related to mouse, keyboard, fonts and Graphical User Interface
Ric
Posts: 221
Joined: Tue 17 Apr 2018, 21:03

Touch screen gestures

Post by Ric »

Does anyone know how to implement touch screen gestures like pinch, stretch and multiple finger taps?
Kind Regards Ric.

6502 back in the day, BB4W 2017 onwards, BBCSDL from 2023
Richard Russell
Posts: 457
Joined: Tue 18 Jun 2024, 09:32

Re: Touch screen gestures

Post by Richard Russell »

Ric wrote: Sun 03 Aug 2025, 14:04 Does anyone know how to implement touch screen gestures like pinch, stretch and multiple finger taps?
The first thing to say is that, of course, zoom (pinch/stretch) and move (two-fingered drag) gestures are built into BBC BASIC for SDL 2.0 and are active all the time, by default. If they meet your needs, then there is nothing else you need to do; you get them for free!

But if the built-in gesture handling doesn't meet your needs, and you prefer not to code your own handlers from scratch, then you can copy (and possibly adapt) the relevant code from the supplied example program(s) which most closely match what you want.

For example mandel.bbc incorporates a trivial zoom handler, which simply modifies a global variable Zoom; you can't get simpler than that:

Code: Select all

      ON SYS Zoom *= 1 - @wparam% / &4000 : RETURN
For multiple finger touches, there's a supplied example program specifically for that: multitouch.bbc in the examples/general/ directory.

Failing any of the example programs doing what you want, or near enough to adapt, you'll have to write your own handlers based on the documentation for *SYS and the relevant SDL2 documentation for touch events and multigesture events
Ric
Posts: 221
Joined: Tue 17 Apr 2018, 21:03

Re: Touch screen gestures

Post by Ric »

Thanks Richard
Kind Regards Ric.

6502 back in the day, BB4W 2017 onwards, BBCSDL from 2023
Ric
Posts: 221
Joined: Tue 17 Apr 2018, 21:03

Re: Touch screen gestures

Post by Ric »

The multi touch program supplied is exactly what I need👍👍
Kind Regards Ric.

6502 back in the day, BB4W 2017 onwards, BBCSDL from 2023
Richard Russell
Posts: 457
Joined: Tue 18 Jun 2024, 09:32

Re: Touch screen gestures

Post by Richard Russell »

Ric wrote: Sun 03 Aug 2025, 15:26 The multi touch program supplied is exactly what I need
It's why I recommend that BBC BASIC users familiarise themselves with the supplied examples. They're not just there as a showcase, in many (probably most) cases they incorporate code which can be repurposed for use in users' own programs.

Whilst it should always be possible to generate code with equivalent functionality from scratch, based on what's in the documentation, the examples can save you a lot of work.
Richard Russell
Posts: 457
Joined: Tue 18 Jun 2024, 09:32

Re: Touch screen gestures

Post by Richard Russell »

For my own interest, I searched the BBCSDL documentation for 'gesture'. The only hit was ON SYS where it says "A statement which allows you to react to an Operating System event, not handled by the other ON interrupts. For example this may be clicking on a menu (in BBC BASIC for Windows) or a touch gesture (in BBC BASIC for SDL 2.0)".

Not a lot to go on there, I admit, although it does link to *SYS where some more information can be found. Unfortunately whilst ON SYS interrupts in BB4W are easy to cross-reference with Microsoft's documentation (because the @wparam% and @lparam% variables directly map to the WPARAM and LPARAM parameters) the same is not true of BBCSDL.

The SDL 2.0 event system has a more complicated interface than the Windows one, with a variable number of parameters compared with just two. For example the SDL_MULTIGESTURE event only passes the dDist, x and y values to your BASIC program (packed into @wparam% and @lparam%), the others are discarded.