Skip to content
php-baremetal REGISTRY
Publish a package

php-baremetal/ext-input

bm-ext MIT

Touch input for php-baremetal: the Touch interface, the Pressed/Moved/Released/Gesture events and a C API for touch drivers. Platform-neutral.

Touch input for php-baremetal: the Baremetal\Input\Touch interface that touch drivers implement, the events Pressed, Moved, Released and Gesture (with the GestureType enum) on the event bus of ext-events, and a C API a driver uses to raise them. ext-input has no hardware code: it needs only ext-events, and a driver package (for a touch controller on I2C, for example) brings the chip.

Install

In a project created with phpbm init, a touch driver package pulls ext-input in. To use the classes without a driver:

bash
composer require php-baremetal/ext-input

Example

In the event-driven runtime, with a driver that implements Touch:

php
<?php
use Baremetal\Events;
use Baremetal\Input\{Pressed, Gesture, GestureType};

$touch->events();   // $touch: any Baremetal\Input\Touch

Events::listen(Pressed::class, function (Pressed $e) {
    printf("down at %d,%d\n", $e->x, $e->y);
});
Events::listen(Gesture::class, function (Gesture $e) {
    if ($e->type === GestureType::DoubleTap) {
        echo "double tap\n";
    }
});

Documentation

Read the full documentation