HPlogo HP Xlib Extensions: > Chapter 6 HP Input Device Extension Functions

Listing Available Input Devices

» 

Technical documentation

Complete book in PDF

 » Table of Contents

 » Index

To obtain a list of available input devices, use XHPListInputDevices.

XHPDeviceList *XHPListInputDevices(display, ndevices)
Display *display;
int *ndevices; /* RETURN */

Title not available (Listing Available Input Devices )

display

Specifies the connection to the X server.

ndevices

Specifies as a return value the number of devices available.

XHPListInputDevices returns information about the input devices that are available to the X server, including the standard X keyboard and pointer devices. Each time it is called it returns a pointer to an array of XHPDeviceList structures that contains information about each device. The ndevices value returned specifies the number of XHPDeviceList structures in the array. In < X11/XHPlib.h >, the XHPDeviceList structure is defined as follows:

typedef struct                         
    {                                  
    unsigned int      resolution;  
/* resolution in counts/meter */
    unsigned short    min_val;     
/* min value this axis returns*/
    unsigned short    max_val;     
/* max value this axis returns*/
    } XHPaxis_info;                    
typedef struct                         
    {                                  
    XID               x_id;        
/* device X identifier */
    char              *name;       
/* device name */
    XHPaxis_info      *axes;       
/* pointer to axes array */
    unsigned short    type;        
/* device type */
    unsigned short    min_keycode; 
/* min X keycode from this dev*/
    unsigned short    max_keycode; 
/* max X keycode from this dev*/
    unsigned char     hil_id;      
/* device HIL identifier */
    unsigned char     mode;        
/* ABSOLUTE or RELATIVE */
    unsigned char     num_axes;    
/* # axes this device has */
    unsigned char     num_buttons; 
/* # buttons on this device */
    unsigned char     num_keys;    
/* # keys on this device */
    unsigned char     io_byte;     
/* I/O descriptor byte for dev*/
    unsigned short    detailed_id; 
/* kbd interface + type */
    unsigned char     pad[6];      
/* reserved for future use */
    } XHPDeviceList;                   

The axes field of the HPDeviceList structure contains the address of an array of XHPaxis_info structures. The num_axes field contains the number of elements in this array. If the num_axes field contains 0 (zero), the contents of the axes field will be NULL. In the XHPaxis_info structure the resolution field contains the resolution of the device in counts per meter. If the mode field of the XHPDeviceList structure is ABSOLUTE, then the min_val and max_val fields contain the minimum and maximum values the device can report. For relative pointing devices, these fields contain 0 (zero).

The X pointer device is always the first device listed and has an x_id field equal to the constant XPOINTER. The X keyboard device is always listed second and has an x_id field equal to the constant XKEYBOARD. In general, attempting to access the X keyboard or pointer devices using the HP extension functions generates a BadDevice error.

A variety of device types are defined in < X11/XHPlib.h >.

Table 6-1 Device Type Names

Name

Device Type

MOUSE

HP-HIL mouse

TABLET

HP-HIL graphics tablet

KEYBOARD

HP-HIL keyboard

TOUCHSCREEN

HP-HIL touchscreen

TOUCHPAD

HP-HIL touchpad

BUTTONBOX

HP-HIL buttonbox

BARCODE

HP-HIL barcode reader

ONE_KNOB

HP-HIL single knob box

NINE_KNOB

HP-HIL nine knob box

TRACKBALL

HP-HIL trackball

QUADRATURE

HP-HIL quadrature

 

XHPDeviceList returns NULL if there are no input devices to list.

© 1995 Hewlett-Packard Development Company, L.P.