Add an input processing function
PtInputId_t *PtAppAddInput( PtAppContext_t app_context, pid_t pid, PtInputCallbackProc_t input_func, void *data );
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.
ph
This routine adds a function to a PtMainLoop() input-event processing chain.
The input_func 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 rcvid argument that the input function gets may have a different value:
You can define more than one input handler in your application for a pid. When a message is received from that process, the widget library starts calling the handlers in the list, starting with the last one registered, and continuing up the list in reverse order until a handler recognizes the message (that is, it doesn't return Pt_CONTINUE). See the description of Pt_CONTINUE below.
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(), PtAppAddInputRemote(), PtMainLoop(), PtAppCreatePulse(), PtAppRemoveInput(), PtResizeEventMsg()
Interprocess Communication chapter of the Photon Programmer's Guide
name_attach() in the QNX Neutrino Library Reference