The Input Server Table of Contents The Input Server Index

The Input Server

Incomplete. Look for an update in the Be Book on the Be Web site.

The Input Server is a system service that accepts user events (on the mouse and keyboard, typically) at one end, and dispatches them to the App Server at the other. In between, the Input Server runs the events through a series of filters that can inspect and modify them. The generation and filtering of events is performed by the add-ons that the Input Server loads; the Server itself just provides the plumbing. Event-generating add-ons (called input devices) typically correspond to one or more device drivers, although this isn't a requirement. An event-filtering add-on (input filter) processes the events that are fed to it; input filters aren't intended to correspond to hardware. A third catagory of Input Server add-ons—-input methods—are used to implement input method mechanisms, which convert standard keyboard characters into Kanji.

Each of these add-on types (input devices, filters, and methods) is represented by a C++ base class: BInputServerDevice, BInputServerFilter, and BInputServerMethod. For each add-on you want to create, you subclass the appropriate base class and override its hook functions. An additional class—BInput—lets a "normal" application send messages back through the Input Server to the add-ons; a BInput object can be useful if you're creating a preference app for a custom Input Server add-on, for example.

A map of the Input Server world looks like this:

Note that the Input Server and its add-ons (and BInput) all live in user space. There's nothing that a "normal" application can do that an Input Server add-on can't do.

The BeOS provides a few Input Server add-ons: It installs input devices that handle a variety of mice and keyboard drivers, and an input filter that the Screen Saver engine uses to detect user activity (on the mouse and keyboard). The BeOS doesn't have any built-in input method

Currently, events that are generated by the BeOS joystick drivers do not go through the Input Server.


Drivers and Input Devices

As mentioned above, most input devices (i.e. input-generating add-ons) correspond to one or more device drivers. For example, the BeOS mouse input device provided manages all the mouse drivers that the OS provides.

It's important to keep in mind that an input device is not the same as the device driver(s) it manages—they're separate pieces of code that execute in separate address spaces: The drivers run in the kernel, the add-ons run in the Input Server. An input device can open() a driver, but it mustn't explicitly load the driver. In other words, the add-on shouldn't re-invent or subvert the kernel's driver-loading mechanism.

Similar to drivers, Input Server add-ons must be scrupulous about managing their memory and threads:


Building

Like all add-ons, Input Server add-ons are compiled as shared libraries. The add-ons must link against input_server, renamed (as a symbolic link) to _APP_. In other words, you set up a symbolic link like this:

   $ cd <yourProjectDirectory>
   $ ln -s /boot/beos/system/servers/input_server _APP_

And then link against _APP_.


Installing

The input server looks for add-ons in the "input_server" directory within of B_BEOS_ADDONS_DIRECTORY, B_COMMON_ADDONS_DIRECTORY, and B_USER_ADDONS_DIRECTORY. Where you install your add-ons depends on what type of add-on it is:


Loading

The Input Server automatically loads (or attempts to load) all add-ons at boot time.

Currently, the Input Server doesn't dynamically load add-ons. This is a particular annoyance if you're developing and testing an add-on. To work around this lack, move your add-on into the appropriate directory, and then quit and restart the Input Server from a Terminal:

   /system/servers/input_server -q

This will gracefully shutdown the Input Server and then re-launch it. The first thing the Server does when it comes back up is re-load the add-ons from its add-on directories.

Your mouse and keyboard (and other input devices) will go dead for a moment while this is happening. This is normal.


The Input Server Table of Contents The Input Server Index


The Be Book,
...in lovely HTML...
for BeOS Release 4.5.

Copyright © 1999 Be, Inc. All rights reserved.

Text last modified June 5, 1999.