HP-UX Reference (11i v2 07/12) - 7 Device (Special) Files, 9 General Information, Index (vol 10)

p
ps2(7) ps2(7)
(PA-RISC Systems Only)
exit(1);
}
printf("Indicators off\n");
/* use scancode set 3 */
kbdbuf[0] = SCANCODE_3;
if( ioctl( fildes, PS2_SCANCODE, &kbdbuf) < 0){
perror("ioctl PS2_SCANCODE failed");
exit(1);
}
/* identify our scancode set */
kbdbuf[0] = GET_SCANCODE;
if( ioctl( fildes, PS2_SCANCODE, &kbdbuf) < 0){
perror("ioctl PS2_SCANCODE failed");
exit(1);
}
printf("Keyboard reports it is using scancode set %d\n",
(unsigned int) kbdbuf[0]);
/* now, loop forever while printing keycodes */
while( 1){
read( fildes, &inchar, 1);
printf("Keycode: %x\n", (unsigned int)inchar);
}
The following example puts the mouse in stream mode, sets the report limit to 80 per second, enables the
mouse, and then loops forever printing mouse reports. Assume that fildes is a valid file descriptor for a
ps2 port connected to a mouse.
#include <sys/ps2io.h>
unsigned char buf[3]; /* mouse report buffer */
unsigned char ioctl_buf[4]; /* mouse ioctl buffer */
/* first, disable the mouse */
if (ioctl( fildes, PS2_DISABLE) < 0){
perror("ioctl PS2_DISABLE failed\n");
exit(1);
}
printf("Mouse disabled\n");
/* Put mouse in stream mode */
if (ioctl( fildes, PS2_STREAMMODE) < 0){
perror("ioctl PS2_STREAMMODE failed\n");
exit(1);
}
printf("Mouse in stream mode\n");
/* set samplerate */
ioctl_buf[0] = SAMPLE_80;
if (ioctl( fildes, PS2_SAMPLERATE, ioctl_buf) < 0){
perror("ioctl PS2_SAMPLERATE failed\n");
exit(1);
}
printf("Mouse sample rate set to SAMPLE_80\n");
/* Enable mouse */
if (ioctl( fildes, PS2_ENABLE) < 0){
perror("ioctl PS2_ENABLE failed\n");
exit(1);
}
printf("Mouse enabled.\n");
118 Hewlett-Packard Company 7 HP-UX 11i Version 2: December 2007 Update