Title |
Changing mouse sensitivity in Photon |
Ref. No. |
QNX.000009550 |
Category(ies) |
Input Devices, Configuration |
Issue |
How do we change the mouse sensitivity in QNX4 Photon?
|
Solution |
The first time Photon is run a text file /etc/config/trap/input.$NODE is created. It contains the configuration for the input devices, and you can edit it manually. If you insert the rel -G and -T switches, you can modify the default mouse sensitivity. A simple example is:
kbd -R fd -d /dev/kbd ps2 -r kb -2 rel -G 1 -T 100
See the online help page of Input for more details.
Alternatively, if you would like to do this in code, here is a sample which will change the "gain":
#include <sys/pointer.h> #include <Ph.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <sys/kernel.h> #include <sys/sendmx.h>
union { struct { struct _Ph_msg_forward forward; } send; struct { struct _Ph_msg_hdr_reply hdr; int result; } reply; } msg;
struct { PhRegionDataHdr_t hdr; struct _interact_mgr info; } region_data;
main(int argc, char *argv[]) {
struct _Ph_ctrl *ph; int gain; PhConnectId_t conn_id; struct _pointer_ctrl ctrl; PhRect_t rect; PhRegion_t region; PhRid_t rids[10]; int nreg; int i; struct _pointer_ctrl pctrl; struct _mxfer_entry smx[2], rmx[2]; extern struct _Ph_ctrl *_Ph_;
if (argc > 1) gain = atoi(argv[1]); else gain = 2;
if ((ph = PhAttach(NULL, NULL)) == NULL) perror("PhAttach");
conn_id = PhGetConnectId();
if ((nreg = PhQueryRids(Ph_RIDQUERY_TOWARD, 0, 0, Ph_PTR_REGION, 0, 0, NULL, rids, 10)) <0) perror("PhQueryRids");
printf("Found %d ptr regions: %dn", nreg, rids[0]);
if (PhRegionQuery(rids[0], ®ion, &rect, ®ion_data, sizeof(region_data)) <0) perror("PhRegionQuery");
for(i = 0; i <MAX_DEVS_PER_MGR; i++) { if (region_data.info.devices[i].type == _INTERACT_TYPE_POINTER) { printf("Found a INTERACT_TYPE_POINTERn"); break; } }
pctrl.type.handle = region_data.info.devices[i].handle; pctrl.type.type = region_data.info.devices[i].type; pctrl.type.feedback = region_data.info.devices[i].feedback; pctrl.gain = gain; pctrl.threshold = 0;
msg.send.forward.hdr.type = _Ph_SERV_POINTER; msg.send.forward.hdr.subtype = _POINTERSETCTRL; msg.send.forward.pid = region.owner;
msg.send.forward.len = IOCPARM_LEN(_POINTERSETCTRL);
_setmx(&smx[0], &msg.send, sizeof(msg.send)); _setmx(&smx[1], &pctrl, sizeof(pctrl)); _setmx(&rmx[0], &msg.reply, sizeof(msg.reply)); _setmx(&rmx[1], &pctrl, sizeof(pctrl));
if (Sendfdmx(ph->fd, 2, 2, smx, rmx) <0) perror("Sendfdmx");
printf("Message sent successfullyn"); printf("Result code is %dn", msg.reply.result);
}
|
|