Mouse wheel in SDL?

[…]

Like they say, those who fail to learn from history
are doomed to repeat it.

Yes.

However, the problem with software is that "planning for the future"
usually results in messy overkill designs that often eventually results
in a dead project, rather than a working solution.

This is even more important with Free/Open Source projects, as there’s
usually no money to “force” development. If it grows too hairy, people
just give up and go somewhere else…

//David Olofson — Programmer, Reologica Instruments AB

.- M A I A -------------------------------------------------.
| Multimedia Application Integration Architecture |
| A Free/Open Source Plugin API for Professional Multimedia |
----------------------------> http://www.linuxdj.com/maia -' .- David Olofson -------------------------------------------. | Audio Hacker - Open Source Advocate - Singer - Songwriter |-------------------------------------> http://olofson.net -'On Tuesday 12 March 2002 22:52, Jason Hoffoss wrote:

[…]

That’s just because we don’t want to force people to upgrade half
their system every two seconds.

X has already been upgrade now how many times since this hack was first
introduced? Probably quite a few now.

That has nothing to do with it, whatsoever. The reason you can’t just
change that kind of things is that it would break all applications that
use it, forcing users to upgrade them, hack them, replace them or just
accept that the feature doesn’t work.

(That is, in this case, it could have been worse - at least applications
wouldn’t crash…)

They still haven’t fixed it to
work cleanly instead of being a hack. Adding it to one of these
updates wouldn’t have forced anyone to upgrade any more quickly than
they already do, so that’s not the issue.

Right - as long as it’s ok that the wheel stops working in all
applications.

It seems to me like they are
failing to plan ahead in their designs, and willing to go with hacks if
it works good enough for now than replacing them with solid solutions.
They are reactive to technology changes, and don’t add support for them
until after they start becoming widely available. Then there’s lag
before anyone can use it in Linux, while Windows is already supporting
it all.

I have to agree here. I’d guess the reason is lack of resource, weak
management, or both. It’s hard to avoid without paying programmers to
deal with the less exciting tasks - one of the few real problems with
Free/Open Source development. Some projects still solve this nicely,
while others fail…

From what I’ve seen, btw, you don’t need to force people to upgrade
half their system constantly. They seem to enjoy doing that already on
their own.

…as long as it’s possible to find versions that work together. Not
all Linux users can or want to modify applications that aren’t updated as
frequently as some drivers and libraries, so it does matter whether or
not applications will work across driver/library versions.

And so what if you have, say, an Intellimouse Explorer, which has 5
buttons already, plus a mouse wheel? If all software assumes that
buttons 4 and 5 are the wheel, the real buttons 4 and 5 need to be
6 and 7 now? It’s just a bad system for handling it.

Yes it is. The hack is just another one that should not have been,
and that will take years to get rid of, now that every other toolkit
(including my VisTk) and application relies on it… heh

Yep, that’s why you try and avoid hacks in the first place, especially
in software that’s already widely available.

Yeah… I don’t know what the XFree86 guys were thinking, but at least, I
try to keep this problem in mind when I’m designing stuff - even though
it does increase the risk of a project dying before the beta stage.

//David Olofson — Programmer, Reologica Instruments AB

.- M A I A -------------------------------------------------.
| Multimedia Application Integration Architecture |
| A Free/Open Source Plugin API for Professional Multimedia |
----------------------------> http://www.linuxdj.com/maia -' .- David Olofson -------------------------------------------. | Audio Hacker - Open Source Advocate - Singer - Songwriter |-------------------------------------> http://olofson.net -'On Tuesday 12 March 2002 23:10, Jason Hoffoss wrote:

Perhaps SDL could hide this grossness a bit by (1) mapping the wheel
to buttons on X and Windows (which I gather is what it already does),
and (2) providing an API to say which buttons are the wheel buttons
(the implementation could default to reporting 4/5 on X, but use real
information on Windows). That’s at least backwards compatible.

I think the best way to hide it is to map buttons 4/5 to a Z axis instead.
Windows already reports data via a Z axis rather than buttons (remember,
that is just an X hack, so only X does it with 4/5 buttons). This is more
in line with how the hardware actually works, and if X does get fixed at
some point in the future, SDL would be able to handle it without an API
change. While at it, though, might as well allow for future expansion by
designing the API to not be limited to any small fix number of axes. Have a
structure something like this:

struct mouse_positional {
int num_axes;
struct axis[]; // array of axes
};

This would handle existing mice (up to 4 axes currently I believe max) and
future ones. Maybe in 2 years there will be the “3d glove” mouse, with 3
axes for position in 3d space, and 3 more axes for rotation reading around
the x, y and z axes. You just never know what’ll show up in the future.

-Jason

----- Original Message -----
From: tullmann@cs.utah.edu (Patrick Tullmann)
To:
Sent: Tuesday, March 12, 2002 3:40 PM
Subject: Re: [SDL] Mouse wheel in SDL??

[…]

Like they say, those who fail to learn from history
are doomed to repeat it.

Yes.

However, the problem with software is that "planning for the future"
usually results in messy overkill designs that often eventually results
in a dead project, rather than a working solution.

This is even more important with Free/Open Source projects, as there’s
usually no money to “force” development. If it grows too hairy, people
just give up and go somewhere else…

Ya, I’ve noticed quite a bit of overkill designs in my time. Nearly
anything Microsoft puts out is an example of that. I think it can be
avoided or reduced a lot, though. I guess the problem is education.
There’s nothing out there to teach you about this kind of thing, so everyone
reinvents the wheel themselves so to speak, and learn through trial and
error. SDL has been one of the very best examples I think of avoiding the
overkill and keeping the API simple. Although the event structures are
getting close to bad. “event.key.keysym.sym” seems a little excessive. I
think it would have been better to move the SDL_keysym into the
SDL_KeyboardEvent here. I think 3 dots is probably the most you want to
require from people.

Hmm, I wonder if anyone has tried writing any books yet on all this yet? If
not, maybe Sam should write one. :slight_smile:

-Jason

----- Original Message -----
From: david.olofson@reologica.se (David Olofson)
To:
Sent: Tuesday, March 12, 2002 5:42 PM
Subject: Re: [SDL] Mouse wheel in SDL??
On Tuesday 12 March 2002 22:52, Jason Hoffoss wrote:

[…]

That’s just because we don’t want to force people to upgrade half
their system every two seconds.

X has already been upgrade now how many times since this hack was first
introduced? Probably quite a few now.

That has nothing to do with it, whatsoever. The reason you can’t just
change that kind of things is that it would break all applications that
use it, forcing users to upgrade them, hack them, replace them or just
accept that the feature doesn’t work.

No no, haven’t you heard of backward’s compatibility? You write a new API
function, and then document it as the proper API function to use, and
document the API functions it replaces as obsolete. The old API would still
be supported, but new applicates shouldn’t be written to use the old API.
They should use the new API. Then at some point down the road, if/when old
applicates have been upgraded naturally (shouldn’t there be a new release at
least every 5 years or so? That doesn’t like it’s asking too much to me)
you can change the old functions from obsolete to being phased out, and
finally remove them even further down the road. If you handle it correctly,
no application would ever break.

I have to agree here. I’d guess the reason is lack of resource, weak
management, or both. It’s hard to avoid without paying programmers to
deal with the less exciting tasks - one of the few real problems with
Free/Open Source development. Some projects still solve this nicely,
while others fail…

I think another part of it is the attitude of things must be “supported by
all” or none of them. Why can’t you take advantage of features that are on
some systems but not others? Instead some people seem to like forcing
everyone to the same common denominator. Even SDL has a little of this.
SDL_GetTicks() could use higher resolution timers if they exist rather than
just holding to 10ms resolution. I think this issue is the biggest reason
why Linux isn’t as good a gaming platform as Windows is. I think people are
moving away from this attitude more these days, though, which is good. If
you’ve got it, use it. We still wouldn’t have accelerated 3d in Linux if
the attitude wasn’t changing probably. Of course, I still can’t get it
working under Linux, so setup still needs some work if you ask me.

Yeah… I don’t know what the XFree86 guys were thinking, but at least, I
try to keep this problem in mind when I’m designing stuff - even though
it does increase the risk of a project dying before the beta stage.

Oh? Why’s that? Do you find it makes developement take longer or
something?

-Jason

----- Original Message -----
From: david.olofson@reologica.se (David Olofson)
To:
Sent: Tuesday, March 12, 2002 5:59 PM
Subject: Re: [SDL] Mouse wheel in SDL??
On Tuesday 12 March 2002 23:10, Jason Hoffoss wrote:

I started a mouse driver that doesn’t require X. I works nicely, and is easily extendable.
I also retains compatability with older applications…
(It’s so flexible that it can be difficult to get the hang of, even though it is somewhat documented.)

If you are a brave soul, and can handle a bit of mouse routing :slight_smile: go grab JAM at:

http://jcatki.2y.net/jam

better yet, get the CVS…it contains support for the full intellimouse explorer (2 axis plus 1 wheel and 5 buttons)
JAM already conatins support for many mice, and more can easily be added.
JAM will also have an I/O based on unix sockets and TCP/IP, meaning your program can directly access the mouse and learn of the configuration of it.
Things like number of Axis, buttons, and wheels will be easy to learn by the application. making full use of every mouse a possibility…
What impact this has on the Linux SDL mouse handling is up to you :slight_smile: perhaps a patch will be nice to have…

JAM also pairs up with imwheel (CVS please) to support actions for the thumb buttons that you can assign…
IMWheel is at:

http://jcatki.2y.net/imwheel

the imwheel in CVS is pretty much going to be a final version (1.0)

if anyone wants to get involved with supporting either JAM or IMWheel, email me or catch me on IRC:

irc.openprojects.net #imwheel (I'm LIM)-- 
          -=<Long Island Man>=-
                Jon Atkins
          http://jcatki.2y.net/

[…]

No no, haven’t you heard of backward’s compatibility? You write a new
API function, and then document it as the proper API function to use,
and document the API functions it replaces as obsolete. The old API
would still be supported, but new applicates shouldn’t be written to
use the old API. They should use the new API.

Of course. You just have to motivate developers to learn and switch to
the new API - which seems to be hard sometimes… :slight_smile:

Then at some point down
the road, if/when old applicates have been upgraded naturally
(shouldn’t there be a new release at least every 5 years or so? That
doesn’t like it’s asking too much to me) you can change the old
functions from obsolete to being phased out, and finally remove them
even further down the road. If you handle it correctly, no application
would ever break.

Right, this does work - but I have a feeling that the XFree86 team would
have done something about it, if the problem wasn’t more complicated than
an API change. Remember that a major part of the “X design” is a network
protocol. It’s entirely possible that it can’t be extended as required
without breaking compatibility in one or both directions… Dunno. You’ll
have to ask someone else about the details. :slight_smile:

I have to agree here. I’d guess the reason is lack of resource, weak
management, or both. It’s hard to avoid without paying programmers to
deal with the less exciting tasks - one of the few real problems with
Free/Open Source development. Some projects still solve this nicely,
while others fail…

I think another part of it is the attitude of things must be “supported
by all” or none of them. Why can’t you take advantage of features that
are on some systems but not others? Instead some people seem to like
forcing everyone to the same common denominator.

Problem is that few features can be supported without forcing
applications that use them to take special measures if the features are
not available.

As an example, consider adding scaling and rotation to SDL’s blitting.
Sure, glSDL could accelerate it very easilly - but that would be the
only target to do that! Consequently, applications would just have to
stay away from those features unless they’re accelerated. Of course,
there would have to be a reliable way of finding out whether or not
they’re accelerated as well.

Even SDL has a little
of this. SDL_GetTicks() could use higher resolution timers if they
exist rather than just holding to 10ms resolution.

Sure, this could be useful for benchmarking, and possibly a few other
things. However, you’d also need an extension to find out what the actual
resolution is, and applications would have to make use of the data in
some way.

I think this issue
is the biggest reason why Linux isn’t as good a gaming platform as
Windows is.

Despite my defending the community, I think this is true to some extent.
Still, as to the defense, the main reason why this is so is that
supporting things like direct framebuffer access, triple buffering and so
on require deep, ugly hacks in the current driver archs - or major
redesign. Companies that want to sell new, cool hardware don’t hesitate
to do these kind of things, but Free/Open Source developers will often
not even consider it.

However, I’m qutie sure the biggest reason by far, is that Linux is a
rather small market for games.

While you can release a “bad” game for Windows and have good marketting
save your ass, there’s no way you can pull that off with a Linux game. If
it’s a great game, that “every Linux gamer will have to buy”, then
maybe you can make some money.

I think people are moving away from this attitude more
these days, though, which is good. If you’ve got it, use it. We still
wouldn’t have accelerated 3d in Linux if the attitude wasn’t changing
probably.

Right.

Of course, I still can’t get it working under Linux, so
setup still needs some work if you ask me.

Yeah… Another example of stuff that people won’t hack “for fun”.

Yeah… I don’t know what the XFree86 guys were thinking, but at
least, I try to keep this problem in mind when I’m designing stuff -
even though it does increase the risk of a project dying before the
beta stage.

Oh? Why’s that? Do you find it makes developement take longer or
something?

Well, if you try to keep “everything” in mind in the design stage, it’s
easy to end up with something that’s just too messy and complicated to
implement properly.

//David Olofson — Programmer, Reologica Instruments AB

.- M A I A -------------------------------------------------.
| Multimedia Application Integration Architecture |
| A Free/Open Source Plugin API for Professional Multimedia |
----------------------------> http://www.linuxdj.com/maia -' .- David Olofson -------------------------------------------. | Audio Hacker - Open Source Advocate - Singer - Songwriter |-------------------------------------> http://olofson.net -'On Wednesday 13 March 2002 00:50, Jason Hoffoss wrote:

[…]

No no, haven’t you heard of backward’s compatibility? You write a new
API function, and then document it as the proper API function to use,
and document the API functions it replaces as obsolete. The old API
would still be supported, but new applicates shouldn’t be written to
use the old API. They should use the new API.

Of course. You just have to motivate developers to learn and switch to
the new API - which seems to be hard sometimes… :slight_smile:

Perhaps. My experience is that a lot of programmers always seem to be
trying to learn new languages and skills. The primary motivation here is
probably getting better jobs/more money. It almost seems much more
complicated already with Unix than Windows, because there’s so much more
available. In Windows, people might know C/C++ and Java. A Unix programmer
however, will probably know those and shell scripting and perl as well. Not
to mention that Emacs or vi also has steep learning curves as well. Seems
like they shouldn’t mind a little learning if they got as far as they have
already. Maybe everyone eventually reaches a point of burnout or something,
though.

Anyone new who doesn’t know the API at all won’t have any problem learning
the new API rather than the old one, and that would help a lot as well. I
still haven’t learned how to do any X programming, so it would all be new to
me. I would prefer a new API, since a new API would have some benefits over
the old. Otherwise, why have a new API? That’s something else for the old
API users to consider too. Ya, you have to learn a new API, but there’s
benefits to doing so as well, so it’s a good thing really.

I think another part of it is the attitude of things must be “supported
by all” or none of them. Why can’t you take advantage of features that
are on some systems but not others? Instead some people seem to like
forcing everyone to the same common denominator.

Problem is that few features can be supported without forcing
applications that use them to take special measures if the features are
not available.

True, but that’s still better than not having it available at all. You can
just leave the choice up to the programmer as to whether they wish to use it
or not. No one is forcing them to, you know. If they decide not to, it’s
the same as if it wasn’t supported at all for them anyway, so where’s the
loss there? I can only see gains. The only cost really is in implementing
the features in the library/API.

As an example, consider adding scaling and rotation to SDL’s blitting.
Sure, glSDL could accelerate it very easilly - but that would be the
only target to do that! Consequently, applications would just have to
stay away from those features unless they’re accelerated. Of course,
there would have to be a reliable way of finding out whether or not
they’re accelerated as well.

I’m not sure that’s a good example of something to support in SDL itself. I
think it’s better in a seperate, more specialized library, and that’s
exactly where it is (glSDL). I’m thinking more applications that are not
trying for cross platform on every possible system in existance (even though
this seems to be rare these days). Maybe I’m only interested Windows and
Linux, using x86 architecture. Given this limited scope, you can rely on a
good many features always being there. 3D accelerated video is another good
example. It didn’t used to be as widespead as it is now, and even now,
there’s lots of people still that don’t have 3D cards, but people still want
to limit their application to requiring that. Should we have not allowed
accelerated 3D support just because not everyone will have that ability?

Even SDL has a little
of this. SDL_GetTicks() could use higher resolution timers if they
exist rather than just holding to 10ms resolution.

Sure, this could be useful for benchmarking, and possibly a few other
things. However, you’d also need an extension to find out what the actual
resolution is, and applications would have to make use of the data in
some way.

Ok. Why’s that a problem?

I think this issue
is the biggest reason why Linux isn’t as good a gaming platform as
Windows is.

Despite my defending the community, I think this is true to some extent.
Still, as to the defense, the main reason why this is so is that
supporting things like direct framebuffer access, triple buffering and so
on require deep, ugly hacks in the current driver archs - or major
redesign. Companies that want to sell new, cool hardware don’t hesitate
to do these kind of things, but Free/Open Source developers will often
not even consider it.

And that’s the problem right there, though. The more it’s avoided, the
worse the situation gets, making it even more unlikely a redesign will occur
to make things clean and simple. Also explains why Linux has such a steep
learning curve to brand new users. Things are only changed around when it
absolutely can’t be avoided any longer a lot of times it seems like. People
don’t realize the price to be paid for that I suppose. Such as Windows
being better for games, being easier to learn and use for beginners (which
is why it continues to be more popular than Linux to the majority), etc.

Anyway, Linux is improving slowly, and that’s good. I still don’t use it
very often, even though I would like to, because it’s still got a little
ways to go yet. But I’m still helping in my own way, by writing my games to
run on both Windows and Linux. Things can only get better with time.

However, I’m qutie sure the biggest reason by far, is that Linux is a
rather small market for games.

Because the foundation isn’t there. It’s starting to be now, thanks to SDL,
DGA, etc. The foundation is where it all has to start. Unfortunately, X is
a lot of the foundation, and it’s still lacking in a lot of ways. Improving
it isn’t going to quickly, for whatever reasons. Could be design flaws,
could be complexity, could be lots of things. I don’t really know, but I do
know that improving X is a big key making the Linux gaming market bigger.

While you can release a “bad” game for Windows and have good marketting
save your ass, there’s no way you can pull that off with a Linux game. If
it’s a great game, that “every Linux gamer will have to buy”, then
maybe you can make some money.

You could have sucky games in Linux as well, once things move ahead far
enough. If we can get to the point where Linux gets as many commercial game
releases and Windows does (maybe platform specific, maybe dual release), I’m
sure you’ll have the same things happening with Linux as Windows as far as
games go, which would include plenty of sucky Linux games that good
marketing manages to save. Linux isn’t very close to that point yet,
though.

Yeah… I don’t know what the XFree86 guys were thinking, but at
least, I try to keep this problem in mind when I’m designing stuff -
even though it does increase the risk of a project dying before the
beta stage.

Oh? Why’s that? Do you find it makes developement take longer or
something?

Well, if you try to keep “everything” in mind in the design stage, it’s
easy to end up with something that’s just too messy and complicated to
implement properly.

I’m not sure I’m convinced of that. I think there’s an art to it. For
example, comparing Direct3D and OpenGL, people will nearly always say that
OpenGL is much easier to use. They both let you accomplish baiscally the
same thing, though. One API is just superior is all. I’ve tried using
DirectX in the past, but never could seem to get the damn palette to set
properly in full screen mode. SDL works easily and beautifully for me, thou
gh. I also think it’s much simpler to use. Once again, a better API.
Design is the easy part perhaps, while making the design simple and elegant
is the hard part. Just another skill to improve I think, like programming
skill, debugging still, documenting skill, optimizing skill, etc.

-Jason

----- Original Message -----
From: david.olofson@reologica.se (David Olofson)
To:
Sent: Wednesday, March 13, 2002 2:09 PM
Subject: Re: [SDL] Mouse wheel in SDL??
On Wednesday 13 March 2002 00:50, Jason Hoffoss wrote: