Home
Developer Resources
QNX RTOS v4
QNX RTOS v4 Knowledge Base

QNX RTOS v4 Knowledge Base

Foundry27
Foundry27
QNX RTOS v4 project
Resources

QNX RTOS v4 Knowledge Base

Title Emitting Raw Events
Ref. No. QNX.000009828
Category(ies) Development
Issue We have a remote touchscreen device. In order to make it work, we have to emit raw PTR and Key event. We couldn't find any information about ph_EV_RAW in the documents. Where can we find relative information?

Solution Here is an example how to do this, and in PhT.h are the details on which button is pressed. There is also an example posted in /usr/free/qnx4/photon/contrib/record.tgz that shows how to trap and emit events(draw and pointer). This file is in the free software section of our webpage.

The function 'mousemove' is attached to a button in a PhAB application. 'init_system' must run before the mousemove callback.

/*standard headers*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>

/*Toolkit headers*/
#include <Ph.h>
#include <Pt.h>
#include <Ap.h>

/*Local headers*/
#include "abimport.h"
#include "proto.h"

PhRid_t    ptr_Rid;

int mousemove(PtWidget_t *widget, ApInfo_t *apinfo, PtCallbackInfo_t *cbinfo){
x09short x = 0, y = 0;
x09int count;
x09int click = 0;
x09
/*eliminate 'unreferenced' warnings*/
x09widget = widget, apinfo = apinfo, cbinfo = cbinfo;
x09init_system(cbinfo->event->input_group);
x09for(count = 0; count < 60; count++){
x09x09printf("x = %d, y = %d, click = %dn", x, y, count);
x09x09MoveMouse(x, y, cbinfo->event->input_group, click);
x09x09x++;
x09x09y++;
/*every 10 moves simulate mouse click*/
x09x09if(!(x%10))
x09x09x09click = Ph_BUTTON_SELECT;
x09x09else
x09x09x09click = 0;
x09x09sleep(1);
x09}
x09return(Pt_CONTINUE);
}
void MoveMouse(short x, short y, int group, int click){
x09PhEvent_t ev;
x09PhRawPtrEvent_t pev;
x09PhRect_t rect = {0,0,0,0};
/*setup event message*/
x09ev.type = Ph_EV_RAW;
x09ev.subtype = Ph_EV_RAW_PTR;
x09ev.flags = Ph_EVENT_INSLUSIVE;
x09ev.data_len = offset(PhRawPtrEvent_t, coord) + sizeof(PhRawPtrCoord_t);
x09ev.num_rects = 1;
x09ev.emitter.rid = ptr_Rid;
x09ev.input_group = group;
/*mouse events will be absolute coords, using 0 for .flags, in case of relative moves(e.g. increase X by x, Y by y) then use Ph_PTR_RAW_FLAG_XY_REL*/
x09if(click){
x09x09pev.button_state = click;
x09x09pev.flags = Ph_PTR_FLAG_Z_NONE;
x09x09pev.raw_flags = Ph_PTR_RAW_FLAG_XY_REL;
x09}else{
x09x09pev.button_state = 0;
x09x09pev.flags = Ph_PTR_FLAG_Z_NONE;
x09x09pev.raw_flags = Ph_PTR_RAW_FLAG_NO_BUTTONS |Ph_PTR_RAW_FLAG_XY_REL;
x09}
x09pev.msec = 0;
x09pev.num_coord = 1;
x09pev.coord[0].x = 5;
x09pev.coord[0].y = 5;
x09pev.coord[0].z = 0;
x09pev.coord[0].dmsec = 0;
x09PhEventEmit(&ev, &rect, &pev);
}
static int_system(int group){
x09PhRegion_t region, ptr_region;
x09PhRect_t rect;
x09PhArea_t area;
x09memset(&ptr_region, 0, sizeof(ptr_region
));
x09ptr_region.flags = Ph_PTR_REGION;
x09ptr_region.input_group = group;
x09rect.ul.x = rect.ul.y = rect.lr.x = rect.lr.y = 0;
x09if(!(ptr_Rid = PhRegionOpen(Ph_REGION_FLAGS | Ph_REGION_INPUT_GROUP | Ph_REGION_RECT, &ptr_region, &rect, NULL))){
x09x09fprintf(stderr, "Could not open regionn");
x09x09exit(EXIT_FAILURE);
x09}
x09return (0);
}
x09
x09