HPlogo HP Xlib Extensions: > Chapter 5 X Input Device Extension Functions

Feedback Control

» 

Technical documentation

Complete book in PDF

 » Table of Contents

 » Index

These functions are provided to manipulate input devices that support feedbacks. A BadMatch error will be generated if the requested device does not support feedbacks. Whether or not a given device supports feedbacks can be determined by examining the information returned by the XOpenDevice request. For those devices that support feedbacks, XOpenDevice will return an XInputClassInfo structure with the input_class field equal to the constant FeedbackClass (defined in the file XI.h).

Each class of feedback is described by a structure specific to that class. These structures are defined in the file XInput.h. XFeedbackState and XFeedbackControl are generic structures that contain three fields that are at the beginning of each class of feedback:

typedef struct {
XID class;
int length;
XID id;
} XFeedbackState, XFeedbackControl;

The XKbdFeedbackState structure defines the attributes that are returned for feedbacks equivalent to those on the X keyboard.

typedef struct {
XID class;
int length;
XID id;
int click;
int percent;
int pitch;
int duration;
int led_mask;
int global_auto_repeat;
char auto_repeats[32];
} XKbdFeedbackState;

The click field specifies the key-click volume, with values in the range of 0 (off) to 100 (loud). The percent field specifies the bell volume, with a range of 0 (off) to 100 (loud). The pitch field specifies the bell pitch in Hz. The range of the value is implementation-dependent. The duration field specifies the duration in milliseconds of the bell. The led_mask field is a bit mask that describes the current state of up to 32 LEDs. A value of 1 in a bit indicates that the corresponding LED is on. The global_auto_repeat field has a value of AutoRepeatModeOn or AutoRepeatModeOff. The auto_repeats field is a bit vector. Each bit set to 1 indicates that the auto-repeat is enabled for the corresponding key.

The XPtrFeedbackState structure defines the attributes that are returned for feedbacks equivalent to those on the X pointer.

typedef struct {
XID class;
int length;
XID id;
int accelNum;
int accelDenom;
int threshold;
} XPtrFeedbackState;

The accelNum field returns the numerator for the acceleration multiplier. The accelDenom field returns the denominator for the acceleration multiplier. The threshold field returns the threshold for the acceleration.

The XIntegerFeedbackState structure defines the attributes that are returned for integer feedbacks.

typedef struct {
XID class;
int length;
XID id;
int resolution;
int minVal;
int maxVal;
} XIntegerFeedbackState;

The resolution field specifies the number of digits that the feedback can display. The minVal field specifies the minimum value that the feedback can display. The maxVal field specifies the maximum value that the feedback can display.

The XStringFeedbackState structure defines the attributes that are returned for string feedbacks.

typedef struct {
XID class;
int length;
XID id;
int max_symbols;
int num_syms_supported;
KeySym *syms_supported;
} XStringFeedbackState;

The max_symbols field specifies the maximum number of symbols that can be displayed. The syms_supported field is a pointer to the list of supported symbols. The num_syms_supported field specifies the length of the list of supported symbols.

The XBellFeedbackState structure defines the attributes that are returned for Bell feedbacks.

typedef struct {
XID class;
int length;
XID id;
int percent;
int pitch;
int duration;
} XBellFeedbackState;

Bell feedbacks are those that can generate a sound. Some implementations may support a bell as part of a KbdFeedback feedback. Class BellFeedback is provided for implementations that do not choose to do so, and for devices that support multiple feedbacks that can produce sound. The meaning of the fields is the same as that of the corresponding fields in the XKbdFeedbackState structure.

The XLedFeedbackState structure defines the attributes that are returned for Led feedbacks.

typedef struct {
XID class;
int length;
XID id;
int led_values;
int led_mask;
} XLedFeedbackState;

LED feedbacks are those that can generate a light. Up to 32 lights per feedback are supported. Each bit in led_mask corresponds to one light, and the corresponding bit in led_values indicates whether that light should be on or off. Some implementations may support LEDs as part of a KbdFeedback feedback. Class LedFeedback is provided for implementations that do not choose to do so, and for devices that support multiple LED feedbacks. The meaning of the led_values field is the same as that in the XKbdFeedbackState structure.

The XPtrFeedbackControl structure defines the attributes that can be controlled for feedbacks equivalent to those on the X pointer.

#define DvAccelnum      (1L<<0)
#define DvAccelDenom (1L<<1)
#define DvThreshold (1L<<2)
typedef struct {
XID class;
int length;
XID id;
int accelNum;
int accelDenom;
int threshold;
} XPtrFeedbackControl;

The acceleration, expressed as a fraction, is a multiplier for movement. For example, specifying 3/1 means that the device moves three times as fast as normal. The fraction may be rounded arbitrarily by the X server. Accelerations only takes effect if the device moves more that the threshold pixels at once and only applies to the amount beyond the value in the threshold argument. Setting a value to -1 restores the default. The values of the accelNum and threshold fields must be nonzero for the pointer values to be set. Otherwise, the parameter will be unchanged.

The XKbdFeedbackControl structure defines the attributes that can be controlled for feedbacks equivalent to those on the X keyboard.

#define         DvKeyClickPercent      (1L<<0)
#define DvPercent (1L<<1)
#define DvPitch (1L<<2)
#define DvDuration (1L<<3)
#define DvLed (1L<<4)
#define DvLedMode (1L<<5)
#define DvKey (1L<<6)
#define DvAutoRepeatMode (1L<<7)
typedef struct {
XID class;
int length;
XID id;
int click;
int percent;
int pitch;
int duration;
int led_mask;
int led_value;
int key;
int auto_repeat_mode;
} XKbdFeedbackControl;

The XStringFeedbackControl structure defines the attributes that can be controlled for String feedbacks.

#define         DvString          (1L<<0)
typedef struct {
XID class;
int length;
XID id;
int num_keysyms;
KeySym *syms_to_display;
} XStringFeedbackControl;

The XIntegerFeedbackControl structure defines the attributes that can be controlled for integer feedbacks.

#define         DvInteger        (1L<<0)
typedef struct {
XID class;
int length;
XID id;
int int_to_display;
} XIntegerFeedbackControl;

The XBellFeedbackControl structure defines the attributes that can be controlled for Bell feedbacks.

#define         DvPercent       (1L<<1)
#define DvPitch (1L<<2)
#define DvDuration (1L<<3)
typedef struct {
XID class;
int length;
XID id;
int percent;
int pitch;
int duration;
} XBellFeedbackControl;

The XLedFeedbackControl structure defines the attributes that can be controlled for Led feedbacks.

#define         DvLed           (1L<<4)
#define DvLedMode (1L<<5)
typedef struct {
XID class;
int length;
XID id;
int led_mask;
int led_values;
} XLedFeedbackControl;

Querying Input Device Feedbacks

To query input device feedbacks, use XGetFeedbackControl.

XFeedbackState *XGetFeedbackControl(display, device,
num_feedbacks)
Display *display;
XDevice *device;
int *num_feedbacks;

Title not available (Querying Input Device Feedbacks )

display

Specifies the connection to the X server.

device

Specifies the device whose feedbacks are to be queried.

num_feedbacks

Specifies an address into which the number of feedbacks supported by the device is to be returned.

The XGetFeedbackControl function returns a pointer to a list of XFeedbackState structures. Each item in this list describes one of the feedbacks supported by the device. The items are variable length, so each contains its length to allow traversal to the next item in the list.

The feedback classes that are currently defined are: KbdFeedbackClass, PtrFeedbackClass, StringFeedbackClass, IntegerFeedbackClass, LedFeedbackClass, and BellFeedbackClass. These constants are defined in the file XI.h. An input device may support zero or more classes of feedback, and may support multiple feedbacks of the same class. Each feedback contains a class identifier and an id that is unique within that class for that input device. The id is used to identify the feedback when making an XChangeFeedbackControl request.

XGetFeedbackControl can generate a BadDevice or BadMatch error.

Changing Input Device Feedbacks

To change input device feedbacks, use XChangeFeedbackControl.

int XChangeFeedbackControl(display, device, mask, control)
Display *display;
XDevice *device;
Mask mask;
XFeedbackControl *control;

Title not available (Changing Input Device Feedbacks )

display

Specifies the connection to the X server.

device

Specifies the device whose feedbacks are to be modified.

mask

Specifies a mask specific to each type of feedback that describes how the feedback is modified.

control

Specifies the address of an XFeedbackControl structure that contains the new values for the feedback.

The XChangeFeedbackControl function modifies the values of one feedback on the specified device. The feedback is identified by the id field of the XFeedbackControl structure that is passed with the request. The fields of the feedback that are to be modified are identified by the bits of the mask that is passed with the request.

XChangeFeedbackControl can generate a BadDevice, BadMatch, or BadValue error.

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