cancel
Showing results for 
Search instead for 
Did you mean: 

handleKeyEvent() - where is it called from?

CHech.1
Associate III

Hi,

I'm working with STM32L496AG Discovery's built-in joystick and trying to understand how the Designer receives input from it (I configured a Hardware Button Trigger).

By looking at the code, it seems like the following method is a dead end:

//Handles when a key is pressed
void Screen1ViewBase::handleKeyEvent(uint8_t key)

The Cube IDE says it is not referenced anywhere.

Should I assume that it is interrupt based, and that the hardware calls this method directly?

If so, how can I "tell the hardware/interrupt" to call another method?

If not, then how\where is it called and why can't I find it using the IDE?

Thanks in advance!

5 REPLIES 5
MM..1
Chief III

This handler is invoked when a key (or button) event has been detected by the system.

Parameters:

cThe key or button pressed.

Perfect way for understand and test is place to this for example

if (key == ´A´) ...

and when run simulator press A on keyboard PC.

How to invoke this for GPIO or EXTI is showed in examples. But simply in handletickevent check GPIO and call handleKeyEvent(´A´)

Thank you for the answer.

I may have been not clear.

I understand what happens "in the method", what I don't understand is how is it called.

The IDE says it isn't called anywhere, although it is definitely called as I programmed a menu screen which is navigable using the joystick, and the "goLeft()/goRight()" methods that are used in it are called only from the handleKeyEvent() method.

So, I'd like to know how "the system detects an event" as you said, and where does it happen.

As I thought all interrupts must first pass through "EXTI9_5_IRQHandler" or similar methods in "stm32lxx_it.c" , but none of these leads to handleKeyEvent().

Again, thank you!

I dont check, but in normal is called from Application class. And in older releases TouchGFX i invoke this semihardware buttons by call

if (HAL_GPIO_ReadPin(SW_PWR_GPIO_Port, SW_PWR_Pin) == GPIO_PIN_RESET && filter == false && timeout1.t == 0)
 {
   filter = true;
   static_cast<FrontendApplication*>(Application::getInstance())->handleKeyEvent(85);
 }

I have same question. I read this page (https://support.touchgfx.com/docs/basic-concepts/rendering)

But I can NOT track where handleKeyEvent() is actually called.

----

The Screen class has the following event handlers. These are called by the graphics engine when the corresponding external event has been collected:

framework/include/touchgfx/Screen.hpp

virtual void handleClickEvent(const ClickEvent& event);

virtual void handleDragEvent(const DragEvent& event);

virtual void handleGestureEvent(const GestureEvent& event);

virtual void handleTickEvent();

virtual void handleKeyEvent(uint8_t key);

----

Checking "..\touchgfx\framework\source\platform\hal\simulator\sdl2\HALSDL2.cpp",
it is sampled by every frame by the HAL.
You can break on HALSDL2::sampleKey in the msvc project to see it.

This is similar to the button controller.


TL;DR
Poll/frame: HAL::sampleKey()
if true, trigger handleKeyEvent()