Allegro.cc - Online Community

Allegro.cc Forums » Allegro Development » PLEASE FIX: Joystick rotation axis enumeration bug

Credits go to gnolam, miran, and Peter Wang for helping out!
This thread is locked; no one can reply to it. rss feed Print
 1   2 
PLEASE FIX: Joystick rotation axis enumeration bug
Cortex Commander
Member #7,908
October 2006

I've just ran into the problem of not being able to read two specific joystick axes (Rotation X and Y) which are used for the right analog stick on the Xbox 360 wired controller/gamepad. They're simply not enumerated by the Allegro 4.2 library.

It seems like it's a known bug approached in this thread:
http://www.allegro.cc/forums/thread/507375

Peter Wang's assessment seems correct: "I think the problem is in object_enum_callback() in src/win/wjoydx.c. I suspect the missing axis falls under GUID_RxAxis or GUID_RyAxis which is not being tested for there."

Is this going to be fixed? Can someone please follow up on this issue? I don't want to have to switch to SDL input handling... :(

Thanks so much in advance!

(Wait, could I make the bugfix myself to the allegro code? Should I start looking for the sourceforce repository?!)

- Dan T, working on Cortex Command
http://www.datarealms.com

Peter Wang
Member #23
April 2000

Quote:

(Wait, could I make the bugfix myself to the allegro code? Should I start looking for the sourceforce repository?!)

Yes, fix it and send us the patch, either to the [AD] mailing list, here, or on the SF.net bug tracker (as you have found). It's unlikely anyone else will fix it for you as we basically have no Windows developers any more.

tobing
Member #5,213
November 2004
avatar

Quote:

as we basically have no Windows developers any more

Oh! How come?

gnolam
Member #2,030
March 2002
avatar

The problem is that just adding checks for RxAxis and RyAxis doesn't help - the problem still persists. I tried that the last time around.

[EDIT]
Hmm. Actually, adding that check does make the missing Rotary show up - it just doesn't update. I think the problem might reside in joystick_dinput_poll() (or rather, that there might be an additional problem in joystick_dinput_poll()).

I think I'll try to wrap my head around Allegro's joystick code and see if I can produce a fix for this tonight. :)

[EDIT 2]
Way too many edits.

[EDIT 104]
Hah. I was right. It was a combination of all three guesses to what the problem was: not enough MAX_STICKS + no RxAxis/RyAxis checking in object_enum_callback() + a similar problem joystick_dinput_poll().
I've tested a "proof of concept" fix that works for my joystick at least. I'll try to convert it into a clean fix and make a diff of it later tonight.

--
Move to the Democratic People's Republic of Vivendi Universal (formerly known as Sweden) - officially democracy- and privacy-free since 2008-06-18!

Neil Walker
Member #210
April 2000
avatar

Good job gnolam :)

Though it sounds like the current joystick code is a crock of shite ;)

Neil.
MAME Cabinet Blog / AXL LIBRARY (a games framework) / AXL Documentation and Tutorial

wii:0356-1384-6687-2022, kart:3308-4806-6002. XBOX:chucklepie

gnolam
Member #2,030
March 2002
avatar

UPDATE: a proper fix will take a while, since trying to extract relevant information from MSDN is like repeatedly smashing a claw hammer into your groin. :P

Quote:

Though it sounds like the current joystick code is a crock of shite ;)

Well, it's certainly showing its age anyway... it makes me wonder if there's any chance of introducing an _ex family of joystick functions and structures (with, for example, > 8-bit detail on axis positions, configurable deadzone/range properties, etc).

--
Move to the Democratic People's Republic of Vivendi Universal (formerly known as Sweden) - officially democracy- and privacy-free since 2008-06-18!

CGamesPlay
Member #2,559
July 2002
avatar

I think we should make Allegro hacking a spectator sport.

--
Tomasu: Every time you read this: hugging!

Ryan Patterson - <http://cgamesplay.com/>

gnolam
Member #2,030
March 2002
avatar

Well, I have some good news and some bad news...
The bad news is that there's just no clean way to do this without a major rewrite.
The good news is that I've found out why I never managed to get axis/button name mapping right.

In more detail:
Allegro's name assignment is completely broken. When a device is initialized, its elements are counted and their names are read and copied into Allegro's JOYSTICK_INFO structure. However, when the device's state is actually polled, the order in which the axes are assigned data has nothing to do with their order in that structure.
This is also why I can't fix the polling routine cleanly - without it knowing which axes correspond to which on the physical device, it can't actually know if lRx and lRy exist or not (an axis which doesn't exist always has a value of 0, but that is also a valid state of an existing axis). Therefore, the best thing I can do is to tack them onto two additional axes after all the others have been read. It's a hack, and an ugly one at that, but I don't think it should break anything (num_axis should make sure they're never visible unless they're actually there). :P

The solution to both problems would be to actually associate each Allegro axis with a corresponding DirectX axis, but I'm not sure if I'm allowed to touch the internal structures...

IMO of course. There might actually be a clean way to do all this, but I'll leave finding it to someone who's not as tired. ;)

I will attach patches for testing in a minute or two.

[EDIT]
Attached.

[EDIT2]
I just realized I didn't make those patches against the SVN tree. I will rebuild them in a couple of minutes.

[EDIT3]
Reattached.

--
Move to the Democratic People's Republic of Vivendi Universal (formerly known as Sweden) - officially democracy- and privacy-free since 2008-06-18!

Edward Sheets
Member #4,734
June 2004
avatar

Good job, gnolam. It's always good to see progress being made on the Windows port. :)

---

Note: carving a pentagram on the top of a container of spoiled yogurt does not summon a yogurt demon. -Kikaru

Richard Phipps
Member #1,632
November 2001
avatar

Peter Wang
Member #23
April 2000

Unfortunately we can't bump MAX_JOYSTICK_AXIS and MAX_JOYSTICK_STICKS in the 4.2 branch as it would break ABI compatibility. Is it really necessary?

gnolam
Member #2,030
March 2002
avatar

Yes. STICKS, anyway.

Well, that's a load of work for nothing then. :P

--
Move to the Democratic People's Republic of Vivendi Universal (formerly known as Sweden) - officially democracy- and privacy-free since 2008-06-18!

Thomas Fjellstrom
Member #476
June 2000
avatar

Not nothing, it'll be able to be included in 4.3 at least :)

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

Cortex Commander
Member #7,908
October 2006

Wow you guys rock! Here I thought I wouldn't get much response for a while... gnolam you rock.

Props were due and given:
http://www.datarealms.com/devlog/cortex-command/open-sores-in-action/

A 4.3 update would be hot.

Thomas Fjellstrom
Member #476
June 2000
avatar

4.3 will be a little different than 4.2. some/alot of the api will change, as 4.3 is designated as part of the incremental update to "allegro 5". So you may have to "port" over stuff to 4.3, and aditional updates to 4.3 or 4.4+ will also have significant changes.

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

CGamesPlay
Member #2,559
July 2002
avatar

Don't install your modified Allegro binary to the system library directory, please!

--
Tomasu: Every time you read this: hugging!

Ryan Patterson - <http://cgamesplay.com/>

Cortex Commander
Member #7,908
October 2006

Seems like i'll have to use SDL for the joystick input after all.. oh well! ;p

Thanks for the quick help and effort though! Looking forward to a rewritten input module sometime!

miran
Member #2,407
June 2002

Quote:

Seems like i'll have to use SDL for the joystick input after all.. oh well! ;p

How did you arrive at this conclusion? Just apply gnolam's patch on your local SVN copy of Allegro and staticlink your game. Problem solved.

--
sig used to be here

gnolam
Member #2,030
March 2002
avatar

Quote:

Not nothing, it'll be able to be included in 4.3 at least :)

Right. I'll just come back and resubmit it in 5 years then...

--
Move to the Democratic People's Republic of Vivendi Universal (formerly known as Sweden) - officially democracy- and privacy-free since 2008-06-18!

Thomas Fjellstrom
Member #476
June 2000
avatar

Or you could apply it to 4.3 now.

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

gnolam
Member #2,030
March 2002
avatar

AFAIK, 4.3 is still a jumble of broken code with no actual API plan, so no.

(We've only been waiting for Allegro 4.2.1 for what, a year?)

--
Move to the Democratic People's Republic of Vivendi Universal (formerly known as Sweden) - officially democracy- and privacy-free since 2008-06-18!

Thomas Fjellstrom
Member #476
June 2000
avatar

AFAIK 4.3 compiles just fine.

its the old allegro_new branch or whatever that was totally broken.

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

gnolam
Member #2,030
March 2002
avatar

Maybe it does. But even if the patch should prove relevant, there's still the utter lack of documentation and planning. So no, I'm not planning on contributing anything to 4.3.

--
Move to the Democratic People's Republic of Vivendi Universal (formerly known as Sweden) - officially democracy- and privacy-free since 2008-06-18!

Thomas Fjellstrom
Member #476
June 2000
avatar

And thats why theres a lack to begin with. "I'm not going to do anything if noone else does!".

:'(

Actually, I'm nearly done the new file/path handling stuff for allegro 4.3. Including the unix and windows specific code.

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

gnolam
Member #2,030
March 2002
avatar

Quote:

And thats why theres a lack to begin with. "I'm not going to do anything if noone [sic] else does!".

No, that's not it. Try
"I'm not going to do anything since nobody has any idea what should be done."
or
"I'm not going to do anything unless the people who have done something tells other people what it is they have done."
or
"I'm not going to do anything since what I do might prove completely irrelevant because someone else has a different idea."

You don't start building a house without first drawing up detailed plans. Likewise, you don't contribute to a project with no apparent direction unless you get paid for it.

--
Move to the Democratic People's Republic of Vivendi Universal (formerly known as Sweden) - officially democracy- and privacy-free since 2008-06-18!

 1   2 


Go to: