Re[2]: [AD] Proposal for first step towards new api

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


PW> I agree.  We shouldn't try to hide that different input devices work
PW> differently.  Trying to cram everything into a generalised interface
PW> is like plugging a round hole with a square peg.

First of all: I'm not going to hide difference between devices.
Some kind of keyboard-joystick emulation is in my opinion
app thing, not library.

What I want to achive is better devices management. If all devices are
inited by one function they can be easily closed by one function or
polled at once. We can also implement some device indepentent
functions like saving device state (who likes calibrating joystick,
mouse...), record/playback support. Debuging can be probably easier.

Another matter is way of getting information from input. Allegro is
quite messy in it:
We have global table of keys, readkey function, mouse_xyzb functions
and functions/global tables for joystick.
It's like windows, where enumaration of different things is performed
differently by callback functions, buffers, findfirst/next functions.
What I proposed was rather unix like. Do you call
device/network/files/pipes/shared memory management through one
consistent vfs plugging a round hole with a square peg?

>> I think I'd just make an interface more like:
>>     joy1 = al_install_joystick();
>>     al_update_joystick (joy1);
>> where joy1 is a pointer to a struct containing driver-specific
>> data....
Why driver specific? It can be a something like
struct AL_DEVICE
{
  int device_type;
  some common variables like memory/cpu usage...
  ....
  void *driver_specific;
}

My modified proposal:

We leave device specific functions.
Let's make device specific functions a bit simmilar like:
al_get_keyboard(device,key)
al_get_mouse_button(device,key)
al_get_mouse_axis(device,axis)
al_get_joy_button(device,key)
al_get_joy_axis(device,axis)
It would be easier for programmer who has never used joystick
functions (like me) to learn them. All API looks nicer anyway.

PW> Who has two keyboards in the one machine?
There is no software that use two keyboards. Maybe if there is such
software somebody would buy second keyboard. Each invention makes
people think it's unnecassary ;].

-- 
Best regards,
 Grzegorz                            mailto:Grzegorz.Godlewski@xxxxxxxxxx




Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/