• Aucun résultat trouvé

Virtual User Input Device

Dans le document System Programmer's Guide sun® (Page 55-58)

Chapter 6 Desktops

7.1. Virtual User Input Device

NOTE

What Kind of Devices?

7

Workstations

This chapter discusses the manipulation of workstation data, which comprises mostly global data related to input and input devices. Some calls in the

Desktops

chapter also affect workstations. This overlap is purely historical. This chapter also explains parts of the Virtual User Input Device interface that were not covered in the

Handling Input

chapter of the

SunView Programmer's Guide.

That chapter gave the possible event codes in SunView 1; this chapter explains the mechanism which sets up input devices to generate them.

The Virtual User Input Device

(vuid)

is an interface between input devices and their clients. The interface defines an idealized user input device that may not correspond to any existing physical collection of input devices. A client of Sun-View doesn't access vuid devices directly. Instead, the window system reads vuid devices, serializing input from all the vuid devices and then makes the input available to windows as Sun View vuid events.

You don't have to write a vuid interface to use your own device in SunView: you can use any input device that generates ASCII. But if your device is hooked up using vuid, then your SunView programs can interface with it using the Sun View input event mechanism.

Since SunView's input system is built on top of vuid, it is explained in some detail.

Vuid is targeted to input devices that gather command data from humans, e.g., mice, keyboards, tablets, joysticks, light pens, knobs, sliders, buttons, ascii termi-nals, etc. IS The vuid interface is not designed to support input devices that pro-duce voluminous amounts of data, such as input scanners, disk drives, voice packets.

Here are some of the properties that are expected of a typical client of vuid, e.g., SunView:

o The client has a richer user interface than can be supported by a simple ASCII terminal.

15 The appendix titled Writing a Virtual User Input Device Driver discusses how to write a device driver that speaks the vuid protocol for a new input device.

39 Revision A, of March 27,1990

Vuid Features

Vuid Station Codes

Address Space Layout

D The client serializes multiple input devices being used by the user into a sin-gle stream of events.

D The client preserves the entire state of its input so that it may query this state.

Vuid provides, among others, the following services to clients:

D A client may extend the capabilities of the predefined vuid by adding input devices. A client wants to be able to do this in a way that fits smoothly with its existing input paradigm.

D A client's code may be input device independent. A client can replace the physical device(s) underlying the virtual user input device and not have to change any input or event handlers, only the input device driver. In fact, the vuid interface doesn't care about physical devices. One physical device can masquerade as many logical devices and many physical devices can look like a single logical device.

This sectioo defines the layout of the address space of vuid station codes. It explains how to extend the vuid address space for your own purposes. The meaning of vuid station codes is covered in the

Handling Input

chapter of the

SunView Programmer's Guide.

The programmatic details of the vuid interface are covered in

Writing a Virtual User Input Device Driver

appendix to this docu-ment,

The address space for vuid events is 16 bits long, from 0 to 65535 inclusive. It is broken into 256

segments

that are 256 entries long (VUID_SEG_SIZE). The top 8 bits contain a vuid segment identifier value. The bottom 8 bits contain a segment specific value from 0 to 255. Some segments have been predefine and some are available for expansion. Here is how the address space is currently bro-ken down:

D ASCII_DEVID (OxOO) - ASCII codes, which include META codes.

D TOP _DEVID (OxOl) - Top codes, which are ASCII with the 9th bit on.

D Reserved (Ox02 to Ox7B) - for Sun vuid implementations.

D SUNVIEW_DEVID (Ox7C) - SunView semantic "action" events generated inside Sun View by keymapping.

D PANEL_DEVID (Ox7D) - Panel subwindow package event codes used internally in the panel package (see <suntool/panel . h».

D SCROLL _ DEVID (Ox7E) - Scrollbar package event codes passed to scrollbar clients on interesting scrollbar activity (see

<suntool/scrollbar . h».

sun

Revision A, of March 27,1990

microsystems

This device is a bit of a hodge-podge for historical reasons; the middle of the address space has SunView-related events in it (see

<sunwindow/win input. h», and the virtual keyboard and virtual locator are thrown together.

Adding a New Segment

Chapter 7 - Workstations 41

o WORKSTATION_DEVID (Ox7F) - Virtual keyboard and locator (mouse) related event codes that describe a basic "workstation" device collection (see

<sundev /vuid _ event. h».

o Reserved for Sun customers (Ox80 to OxFF) - if you are writing a new vuid, you can use a segment in here; see the next section.

<sundev /vuid_ event. h> is the central registry of virtual user input dev-ices. To allocate a new vuid you must modify this file:

o Choose an unused portion of the address space. Vuids from OxOO to Ox7F are reserved for use by Sun. Vuids from 0x80 to OxFF are reserved for Sun customers.

o Add the new device with a

* _

DEVID # def ine in this file. Briefly describe the purpose/usage of the device. Mention the place where more information can be found.

o Add the new device to the Vuid device enumeration with a VUID_devname entry.

o List the specific event codes in another header file that is specific to the new device. ASCII_DEVID, TOP _DEVID and WORKSTATION_DEVID events are listed in <sundev /vuid_ event. h> for historical reasons.

NOTE A new vuid device can just as easily be a pure software construction as it can be a set ojunique codes emitted by a new physical device driver.

Input State Access The complete state of the virtual input device is available. For example, one can ask questions about the up/down state of arbitrary keys.

Un encoded Input

int

win_get_vuid_value{windowfd, id) int windowfdi

short idi

id is one of the event codes from <sundev /vuid_event. h> or

<sunwindow/win_input. h>. windowfd can be any window file descrip-tor.

The result returned for keys is 0 for key is up and 1 for key is down; some vuid events return a range of numbers, such as mouse position. There is no error code for "no such key" because, by definition, the vuid event address space is the entire range of shorts and therefore you can't ask an incorrect question. 0 is the default event state.

Unencoded keyboard input is supported, for those customers who cannot use the normal keyboard input mechanism.

A new keyboard translation was introduced in 3.2. The type of translation is set by the KIOCTRANS ioctl (see kb(4S) and kbd(4S». Old values were:

Revision A, of March 27,1990

NOTE

7.2. User Input Device

Dans le document System Programmer's Guide sun® (Page 55-58)