Custom Input Event Handling

Last modified by Microchip on 2024/10/30 14:52

Introduction

Microchip Graphics Suite (MGS) Harmony offers ready-to-use widgets that facilitate basic user inputs and controls, such as button presses, sliders, and keypads.

Custom event handling may be required for more advanced user interactions. These interactions include:

  • Dragging
  • Scrolling
  • Swiping
  • Drawing
  • Long press or hold

This document provides detailed information on utilizing the MGS Library's input service and event filter features to enable custom event handling.

Event Handling Basics

Figure 1 illustrates the lifecycle of a touch event, starting from its detection by the touch controller and proceeding through its processing by the Graphics Library.

Event Handling Diagram

Figure 1. Life cycle of a touch event

The Input System Service (ISS) receives touch events from the touch controller. The ISS uses an observer design that enables other tasks (observers) like the GFX library to be notified of input events by registering a callback function. The callback function injects these events into the GFX library's event queue for processing.

When processing events, the GFX library determines the widget in the screen that will acquire the event focus and handle the event. By default, only enabled widgets can acquire focus and only input widgets such as buttons, keypads and sliders can readily process these events.

Custom Event Handling

The MGS Harmony library allows for customizable event handling, either system-wide through the ISS or more specifically targeted using Widget Event Filters.

Input System Service

The ISS directly receives events from the touch controller, allowing the application to process touch input independently of the GFX library and the currently active screen.

Refer to the "How-To: Use Input System Service for Idle Timeout" page for instructions.

Widget Event Filters

Widget event filters allow applications to override and customize the default input handling for a widget. These filters ensure that input events are processed only within the widget's area or when the widget is in focus.

Refer to the "How-To: Use Widget Event Filters for Sliding Menus" page for instructions.

Back to Top