emitting keypresses in Photon 2.0/RTP

I’m porting keypad from /usr/free (a virtual keyboard).
The app works perfectly under QNX4.25/Photon 1.14,
but does not seem to be emitting the keypresses correctly
under RTP.

The keys are emitted twice, in stead of just once.
The callbacks are executed once only (verified through printfs).
The callbacks are attached once only per button too (also

The code that does this is attached:
send_key does the actual emitting.
keypress is the callback.

process_button: attaches the callback to a button.
attach_callbacks: walks all button and call process_button.