This version of this document is no longer maintained. For the latest documentation, see http://www.qnx.com/developers/docs. |
Add an input processing function
PtInputId_t *PtAppAddInput( PtAppContext_t app_context, pid_t pid, PtInputCallbackProc_t input_func, void *data );
ph
This routine adds a function to a PtMainLoop() input-event processing chain.
The app_context argument is the address of the application context, a structure that manages all the data associated with this application. Specify NULL for app_context, so that the default context is used.
The input function is executed whenever the application receives a message from process pid. If pid is negative, it's the ID of a Photon pulse.
If you specify a pid of 0, the input function is called for every non-Photon event message that's received, but only if there's no input function that catches messages from the sending pid specifically.
The rcvid argument that the input function gets may have a different value:
The input_func argument points to the input function to be invoked. The function takes this form:
int (*input_func)(void *data, int rcvid, void *message, size_t size);
The arguments are:
If you application knows the maximum size of a message that can be possibly sent to it, you can use PtResizeEventMsg() to ensure that the buffer is large enough.
Receiving a large Photon event may make the buffer bigger than was established by PtResizeEventMsg(). |
You can declare the function to be of type PtInputCallbackProcF_t to take advantage of the compiler's type-checking.
If the input function changes the display, it should call PtFlush() to make sure the display is updated. |
The input function must return one of the following:
PtAppAddInput() and name_attach() both try to create a channel with _NTO_CHF_COID_DISCONNECT and _NTO_CHF_DISCONNECT set (see the QNX Neutrino Library Reference). If your application calls both functions, you need to let Photon use the same channel as name_attach(). To do this, call these functions in this order:
See the Examples section of PhChannelAttach() for a sample of code that illustrates the correct order.
If you want to create a separate channel for Photon, it doesn't matter whether you create it and give it to PhChannelAttach() before or after calling name_attach(). But keep in mind that since certain mechanisms in Photon library expect the Photon channel to have the two DISCONNECT flags, they might not work properly if it doesn't. One such mechanism is the detection of broken connections (see PtConnectionClientSetError() and PtConnectionServerSetError()) and anything that relies on it.
A pointer to a PtInputId_t structure that uniquely identifies the specified input function for the given application context. If an error occurs, the function returns NULL.
See the example given in "Photon pulses" in the Interprocess Communication chapter of the Photon Programmer's Guide
Photon
Safety: | |
---|---|
Interrupt handler | No |
Signal handler | No |
Thread | No |
PhChannelAttach(), PtMainLoop(), PtAppCreatePulse(), PtAppRemoveInput(), PtSetParentWidget(), PtResizeEventMsg()
Interprocess Communication chapter of the Photon Programmer's Guide
name_attach() in the QNX Neutrino Library Reference