[Y-devel] Input Device Wiki

Fred P. fprog26 at hotmail.com
Sat Feb 28 03:01:34 GMT 2004


Hi griffon,

I'm the one (Fred) who created the Wiki page, from the MaillingList 
archives...

https://y-win-wiki.jciteassist.org/y-win-wiki/InputDevice

I inserted your content at the top of the page.

Feel free to rearrange/comment this document.

Since some people don't read wiki, here's the content under discussion there 
[RAW format]:

##language:en
#pragma section-numbers on

[[TableOfContents]]

[[Anchor(Head)]]

= InputDevice =

If the author of the section below could please contact me 
(griffon26 at kfk4ever.com) so we can consolidate what is
on this page with [https://www.kfk4ever.com/~griffon26/input.html what I have 
prepared on my own page].
Once it is a nicely structured and complete document, the current contents 
of this page can be replaced with the
new merged version.

= Griffon InputDevice paper =

== Input Subsystem requirements and design ==
* I have decided to not use the X terminology with respect to keyboard 
handling,
* because it might lead people to assume things work in a certain way just 
because they work that way in X.
* I try to use terms in such a way that their exact meaning can be 
determined from their context.
* If you have a proposal for a better name, please let me know.

* The first time each term is used, it will be bold-faced. and colored.

* Device input has several layers of abstraction.
* To describe these layers I will first focus only on keyboards and later 
extend this for mice and other input devices.

== Physical layer ==
* At the lowest layer an event will be generated corresponding to a scan 
code.
* The scan code identifies the position of the key on the keyboard and is 
therefore both hardware dependent and keymap independent.
* Input drivers are on this level.
* At this level, all keys generate an event when they are pressed as well as 
an event when they are released.
* This includes modifier keys like shift an alt.

== Logical layer ==
* The middle layer is responsible for converting the scan codes received 
from the drivers to unique key code.
* The keymap determines the mapping between any sequence of scan codes and a 
key code.
* In other words, pressing the keys labeled a,b,c after eachother could 
result in one key code being generated, just like pressing ctrl+v.
* This layer will have a state machine as described in the following message 
to the Y-devel mailing list:

== [Y-devel] about keyboard layouts ==
By Alexey Boyko [mailto:smartly_AT_gala.net]
Thu Feb 26 20:51:02 GMT 2004

== Application layer ==
* The goal of the upper layer is to convert key codes to actions.
* Actions are features that a lot of applications provide and
* that make sense to users even outside the context of the specific 
applications.
* Examples are: copy, paste, save file, close program, maximize window, 
interrupt output.
* The rationale for defining a system-wide list of actions is to stimulate 
consistency across applications.

* The system-wide translation table can map any number of key codes to a 
single action.
* Let's assume for a minute that there is a key code called CTRL_V that is 
generated
* if the logical layer determines someone is pressing CTRL together with V.
* Let's also assume there is an action called PASTE.
* If it is common to map paste to CTRL + V, then the system default for key 
code CTRL_V would be PASTE.
* If it is common in Russia to paste by pressing a key that generates 
CYRILLIC_KEY_CODE_X,
* then the system default for key code CYRILLIC_KEY_CODE_X would also be 
PASTE.

* Now if an application provides the feature to paste,
* it will during initialisation register with the system for the PASTE 
action.
* A notification will then be sent each time the user presses a key that 
results
* in a CTRL_V or a CYRILLIC_KEY_CODE_X key code.

== Now there are at least two important things I have not described yet: ==

* Not all features for which a shortcut can be selected,
* have a corresponding defined system-wide action Applications usually allow 
the user to remap shortcuts,
* but does this mean a local change or a global one?
* With your help I will try to figure out a nice way to solve this.
* Things to keep in mind are:
* If the action list of Y is expanded in the future,
* application developers should have to change as little as possible to 
adapt to this.
* This implies similar handling of features with and without a corresponding 
action.
* Application programmers should be encouraged to use the provisions and 
thereby increase consistency.
* Using actions should be easier than using keycodes.

== Another thing that is still open for discussion is the following: ==
* At the moment key codes are bound to actions and
* the currently active keymap only plays a role in the translation from scan 
codes into key codes.
* The result of this is that if two keymaps each have a different key that 
generates the same key code,
* then applications shortcuts will be triggered by different physical keys 
(scan codes) based on the active keymap.
* In my opinion this is desired behaviour, but I have heard of at least one 
person on the list who doesn't agree.

-- Maurice 'Griffon26' van der Pot


= Architecture design =

* I have tried to summarize various ideas for the design of a user input 
system, partly modifying/extending what people have been discussing.
* I was working on a kind of design spec thing and this came out of it.

A complete user input system to manage devices might offer the following 
high-level architectural features:

* A modular, layered user input processing system which abstracts input 
devices into logical and wire-level devices,
* within the capabilities of the host O/S.
* Universal input device support.
* Arbitrary mappings of wire-level (or driver-level? depends on O/S) devices 
to sets of wire-level input elements:
   i. keys,
   i. buttons,
   i. wheels,
   i. axes,
   i. what-have-you..
* Support for virtual devices, whereby software can emulate a wire-level 
device.
* Standardized logical input objects:
   i. state-based objects with binary (0/1) or
   i. continual state values (ranging from -1.0 .. 0.0 .. 1.0, or just 0.0 
.. 1.0).
   * For example, a mouse ball has two states: horizontal and vertical rate 
of motion.
* Logical input devices: collections of logical input objects.
   * For example: a mouse offers both motion information (direction and 
speed) and location in {x,y} co-ordinates.
* A software layer to manage mapping of input elements and devices to 
logical input objects.
* A software layer to manage sets of input objects and
* their translation into event objects for use by the desktop environment 
(windows and widgets).

* This is mostly in response to the idea that a keyboard is less a single 
device than it is a collection of keys, which are basically just on/off 
switches.
* Logically, they are no different from the buttons on a mouse or a 
joystick.
* Likewise,
   i. track balls,
   i. mouse balls or
   i. optical sensors,
   i. mouse wheels, and
   i. joystick continual devices
* all share the common feature of a range of values, which basically provide 
a cartesian space.
* So, there are really only two logical input controls:
   i. buttons (on/off devices) and
   i. sliders (continual devices which can be mapped to a range, either 
-1..1 or 0..1).

== Virtual buttons ==

* While there are thousands of virtual buttons needed to produce all of the 
characters in unicode,
* it has been shown that an input processing system can accept a string of 
input and convert that to a single
character --
* in effect, it is converting a series of real button presses into a single 
logical button press.
* Similarly, but mostly theoretically, any two slider-type input devices can 
be used to produce mouse-style 2D-vector movement, and this can be 
extrapolated to 3D or whatever.
* The reverse is also true: the mouse's up/down and left/right components 
can be extracted and used in some other way.

* It would be great if the input manager was good enough to be perfect for 
every application,
* but probably some software would rather talk to devices at the driver 
level or even at the wire level directly.
* I guess they can use the host operating system to do that anyway.
* Not sure if it would make sense for Y to duplicate that or not, possibly 
by providing standardization.

* One thing I'm not clear on is whether Y would actually require different 
device drivers over and above those used by the host O/S.
* I would think probably not,
* but that driver communication would still be considered low level enough 
to need logical interpretation to conform to a standard logical input object 
model
* (again, a logical input object is a logical button or slider which 
represents some combination of states of one or more actual input controls 
-- keys, buttons, wheels -- and not entire devices).
* The driver-to-logical conversion is a simple state machine (or set of 
machines),
* treating sequences of control state changes as strings of input tokens, 
and
* outputting new strings of logical object state changes on accept.
* If it is a single machine, it is a modified machine, with the accept 
states numbered and corresponding to a table of logical devices.
* Actually, a state machine might only work for buttons.
* Continual controls might require something more sophisticated in order to 
pass on a numerical value.


= Many device at once =

[https://www.y-windows.org/pipermail/y-devel/2004-February/000624.html]

* That reminds me of a library for Mac OS 9 called InputSprockets, designed 
primarily for games.
* Basically it allowed the program to bind actions to various inputs from 
various devices.

* What I'd like is for input and output devices to be completely abstract.
* For example, to see an N64 controller (best example I have handy) as a 
device with:
   i. 10 buttons, 2 axes, and an 8-way digital control pad.
* If output devices were treated like that too, it could be set up so that 
(for example) two people could play a game where neither one can see the 
other person's screen.
* That would be an improvement over most console gaming systems! :)

* This would have to be at a very low level, of course.
* Probably right between the driver and UI levels.

* I would be willing to work on such a task.
* In case anyone needs clarification, I'll write up some preliminary header 
files and post them to the list.

{{{
On Wed, 2004-02-25 at 10:35, Mikko Rantalainen wrote:
>[Flying high... just try to follow my line of thought.]
>
>[snip]
>
>One more thing to consider: current PCs have USB connectors and you
>can attach, say, two keyboards and three mouses plus one tablet
>device. Say, in addition, we have multiple displays and two users.
>Wouldn't it be nice to be able to bind one mouse and one keyboard to
>one user that could use one of the displays to surf the web while
>the another user continued to work with another keyboard. I think it
>could be implemented by having a focus per keyboard and pointer
>would be used to change the focus for that keyboard only.
>
>However, instead of requiring a keyboard, we should use virtual
>input devices. A virtual input device might be "implemented" with
>one keyboard, two mouses and one joystick. Logically that's a
>keyboard that has all the buttons of keyboard plus all the buttons
>of both two mice and all the buttons in the joystick. In addition to
>that, that virtual device also contains 2 (or more!) axis for both
>the mice and at least two axis for the joystick. And possibly one or
>more axis integrated in the keyboard. There should be a method to
>map some (one or more) of those axis to horizontal 2D pointer used
>to move "mouse cursor" and so on. For the Y, this input device has
>(say) total of 103+3+3+8 buttons and 3+3+4 axis. Some of the buttons
>generate "mouse button events" and some don't. Similarly, some of
>the axis generate "mouse cursor" movement and some don't. Each
>virtual input device like this would have a single focus in Y.
>
>I think a virtual device should be able to output at least raw
>button events for every button, cursor movement for at least three
>dimensions, ideally for unlimited dimensions (user can map every
>axis to different dimension of every axis to the same dimension, and
>we don't know how many axis the virtual device might have) and
>character output for whatever character input method the user might
>be using. (I don't have a clue how, for example, Chinese could be
>written with a keyboard and how that looks to the OS/GUI.)
>
>In short, Y should have some kind of support for more than two axis.
>I'd expect that in the future we'll have trackball on top of our
>mouse where we normally have a mouse wheel. Y should be able to map
>the trackball movement to window scrolling or for modifying Z-axis
>in 3d world and zooming with the another axis. Also, precision of
>more than a single pixel should be supported.
>
>I'm not saying that Y must implement code for such features but that
>the APIs that we decide must be generic enough to not remove
>possibilities for future extensions.
>
>And for heavens sake, don't make artificial limitations between
>mapping mouse actions as they were keyboard actions and wise versa.
>If your mouse has only two buttons but some application needs four,
>you should be able to use F11 and F12 for the missing mouse buttons
>if that's what you want.
>
}}}

= GUI Design Docs =

[https://www.y-windows.org/pipermail/y-devel/2004-February/000651.html]

{{{
>How about defining a large list of common user interface actions in Y
>itself? You could keep the bindings of keys to these actions within Y
>and provide an interface for the applications to use them.
[...]
>Of course there would be way more key combinations than keys, so a
>selection would have to be made. If the user assigns ctrl-c both to
>copying a selection and interrupting some output and the application
>uses only one of these actions, there is no problem. If the application
>uses both actions, the {first key binding|first action|least dangerous
>option} would be chosen. We'll have to think about a sensible choice here.
>Also the application should have the opportunity to bind some other
>key to the action for which it does not use the default key.
>
>I don't have solutions for these last two issues, but I think the
>general idea of system-wide key-action bindings is very useful.

I just thought it over a little more and I think I figured out how to
do this.

Some definitions:
Action - Some action that is known by the whole system, like copy,
         save file, close subwindow, exit application, etc
Key    - This probably isn't an actual key press, but rather a key
         event that can be the result of a key combination of some
         kind or maybe even a mouse gesture... in any case, that is
         irrelevant for this particular idea

When an application is initialising, it sends a list of all Actions
it is interested in to the system. The system responds with a list
of Actions and corresponding Keys. This second list is a subset of
the first[1]. The application has now been registered with the system
for all Actions returned in the second list and will receive
notifications for them[2]. The application can now optionally use
any Keys that were not returned in the second list for binding
any of the remaining Actions or any of the functions for which
no Action is defined[3].

[1] The reason that the second list is a subset of the first is
that multiple Actions can have the same Key bound to it. If that
is the case, the system makes the choice of which Action to return.
Whatever this decision is based on, letting the system choose will
improve consistency between applications.

[2] It may not be nice from a design point of view to register for
one set of notifications by sending the list of actions and register
for the rest later by using another interface. It may be better to
have the system simply return the list of Key/Action pairs and
do subscription to notifications somewhere else.

[3] I don't really like the difference between Actions and other
functions of the application. Maybe there should be a way to pass
_ALL_ bindable functions of an application to the system. If the
application programmer would just use some UNDEFINED_ACTION value
for functions that are not supported at the time of creating the
application, then all he would have to do in the next version of
his application is replace UNDEFINED_ACTION with any Action values
that have been defined by the Y-windows people in the mean time.
The system would of course never return UNDEFINED_ACTION with a
Key back to the application.
}}}

_________________________________________________________________
Add photos to your e-mail with MSN 8. Get 2 months FREE*.  
https://join.msn.com/?page=features/photos&pgmarket=en-ca&RU=http%3a%2f%2fjoin.msn.com%2f%3fpage%3dmisc%2fspecialoffers%26pgmarket%3den-ca




More information about the Y-devel mailing list









2026 © www.Y-Windows.Org - All Rights Reserved