Hi Alex,
please have a look into one of our Build Environments for STM32 - there you will find an example called 'DeviceIntegration'.
As soon as the user presses the hard button on the target, the device driver calls the method UpdateHardButtonCounter() of the corresponding device class, which updates a counter view on the display. This means, the content of the display is changed due to a changed value of the underlying hardware.
I think this is exactly what you are looking for...
Best regards,
Manfred.