Demo: Joystick Info

Showcase your libraries, tools and other projects that help your fellow love users.
Post Reply
User avatar
Gerrit
Prole
Posts: 46
Joined: Wed Mar 25, 2009 7:40 pm

Demo: Joystick Info

Post by Gerrit »

Hey!

I took a look into joystick input today and wrote a small program to display those infos. Please don't take a look inside, it's messy in there: No comments and I guess I could have done some things in an easier way but who cares :) At this moment you can view 2 connected joysticks (because I didn't implant "pages" or something to scroll down) but you can still change the windows height to get more joysticks onto the page ;) What you also should know: I only tested it with my joypad (2 axes, 8 buttons. So I don't know if it detecs analogue axes or triggers. At this moment I count all axes and divide them by 2. I should really buy that wifi thingy for my mac to use my xbox360 pad..

At this moment the program (v1) supports:
- unlimited number of joysticks (see above ;))
- name of the device
- about 20 buttons per joystick
- about 5 axes per joystick
- detection of viewhats & trackballs

Todo (if I ever work on this again):
- Multiple pages (for more then 2 joysticks)
- Info on viewhats & trackballs (if I ever get my hands on something that has a viewhat or a trackball)

Don't know:
- If analogue axes are supported and when, what I'll get back from them
- If analogue triggers are supported and where they are listed

This is how it looks like:
Image
Attachments
joystickInfo.love
v1
(1.66 KiB) Downloaded 228 times
User avatar
qubodup
Inner party member
Posts: 775
Joined: Sat Jun 21, 2008 9:21 pm
Location: Berlin, Germany
Contact:

Re: Demo: Joystick Info

Post by qubodup »

Hm. it seems to have horrible problems with my xbox 360 controller, but I think this might be a driver or love problem..

The axes boxes show only white circles when I hold the axe-things at specific positions. :(
lg.newImage("cat.png") -- made possible by lg = love.graphics
-- Don't force fullscreen (it frustrates those who want to try your game real quick) -- Develop for 1280x720 (so people can make HD videos)
User avatar
mikembley
Citizen
Posts: 72
Joined: Wed Dec 17, 2008 5:30 pm
Location: Blackburn, UK
Contact:

Re: Demo: Joystick Info

Post by mikembley »

I also tried it with my Xbox 360 controller

So it is not only specific to you qubodup, I am using Windows Vista

Can anyone else try and test this?
User avatar
Gerrit
Prole
Posts: 46
Joined: Wed Mar 25, 2009 7:40 pm

Re: Demo: Joystick Info

Post by Gerrit »

qubodup wrote:The axes boxes show only white circles when I hold the axe-things at specific positions. :(
Not sure what you mean. You know that the white circle in the middle should show the direction in which you're pressing your stick, right? Don't think that I think you're dumb. Just wanted to be clear on that one ;) Maybe you waited for some numbers to pop up.
mikembley wrote:I also tried it with my Xbox 360 controller

So it is not only specific to you qubodup, I am using Windows Vista

Can anyone else try and test this?
I still haven't bought the wireless thingy for my controller. But I changed the code a bit and present you: joystickRaw :) Just start it up and post what you get. I need:

- the number of axes
- which of the axes responds to which stick / direction
- what numbers do you get if you press it all the way (say left) and half to the left.

Then I can rewrite the JoystickInfo and we all know if Löve can handle analogue sticks :) Oh, and if you get more then 6 axes:

- press a trigger and post which axe responds
- post what number you get if you press if half way and all the way

Thanks in advance :)
Attachments
joystickRaw.love
joystickRaw (which can only handle one joystick I guess..)
(1.52 KiB) Downloaded 182 times
User avatar
mikembley
Citizen
Posts: 72
Joined: Wed Dec 17, 2008 5:30 pm
Location: Blackburn, UK
Contact:

Re: Demo: Joystick Info

Post by mikembley »

Xbox 360 Controller consists of:

5 Axes
Axe 0 = Left Analogue Stick X-axis (-1 to 1)
Axe 1 = Left Analogue Stick Y-axis (-1 to 1)
Axe 2 = Both Triggers, 1 = Left Trigger, -1 = Right Trigger
Axe 3 = Right Analogue Stick Y-axis (-1 to 1)
Axe 4 = Right Analogue Stick X-axis (-1 to 1 )

9 buttons in all
Button 0 = A
Button 1 = B
Button 2 = X
Button 3 = Y
Button 4 = LB
Button 5 = RB
Button 6 = BACK
Button 7 = START
Button 8 = Left Analogue Stick Depressed
Buton 9 = Right Analogue Stick Depressed

1 Viewhat ( Although i couldnt get the Viewhat data so i wrote my own )
0 = Unpressed
1 = North
3 = North East
2 = East
6 = South East
4 = South
12 = South West
8 = West
9 = North West

There is no apparent button for the Xbox Logo, but i dont think that matters :)
User avatar
Gerrit
Prole
Posts: 46
Joined: Wed Mar 25, 2009 7:40 pm

Re: Demo: Joystick Info

Post by Gerrit »

mikembley wrote:Xbox 360 Controller consists of:

5 Axes
Axe 0 = Left Analogue Stick X-axis (-1 to 1)
Axe 1 = Left Analogue Stick Y-axis (-1 to 1)
Axe 2 = Both Triggers, 1 = Left Trigger, -1 = Right Trigger
Axe 3 = Right Analogue Stick Y-axis (-1 to 1)
Axe 4 = Right Analogue Stick X-axis (-1 to 1 )
So it jump right from 0 to 1? Without anything between? That sucks. Not that I need it right now but it would be nice to have :) And why the hell did the have to add those triggers into the middle? If I ever need more then one Axis I would have to look up the type of the controller to catch this.
mikembley wrote: 1 Viewhat ( Although i couldnt get the Viewhat data so i wrote my own )
0 = Unpressed
1 = North
3 = North East
2 = East
6 = South East
4 = South
12 = South West
8 = West
9 = North West
Uhm. O.k. That's interesting. I would never guesses that the digital pad is shown as a viewhat.. THAT'S something I should have to look out for when making my game able to use a pad.
mikembley wrote: There is no apparent button for the Xbox Logo, but i dont think that matters :)
Right. We have enough buttons to choose from :)

Thanks for your effort! I guess I'm not the only one who like to have those infos now.
User avatar
mikembley
Citizen
Posts: 72
Joined: Wed Dec 17, 2008 5:30 pm
Location: Blackburn, UK
Contact:

Re: Demo: Joystick Info

Post by mikembley »

So it jump right from 0 to 1? Without anything between? That sucks. Not that I need it right now but it would be nice to have :) And why the hell did the have to add those triggers into the middle? If I ever need more then one Axis I would have to look up the type of the controller to catch this.
What i meant by -1 to 1 is that it ranges from -1 to 1 ( -1.0, -0.9, -0.8 .. .. .. .. 0 .. .. .. .. 0.7, 0.8, 0.9, 1.0)

It would be rather silly that the analogue sticks wouldnt be sensitive to anything more/less

Im not sure why it has triggers in the middle, i guess they've done it as it appears on the pad from left to right, This also messes with your method of counting all axes and then dividing them by 2
Post Reply

Who is online

Users browsing this forum: No registered users and 91 guests