Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Author
Message
badkneecap
16
Years of Service
User Offline
Joined: 21st Jun 2010
Location:
Posted: 28th Jun 2010 15:56
I have a Logitech game controller connected to my computer that I wanted to use to control the movement and camera for my game. It's very similar to an Xbox or PS2 controller. I can easily read it for up/down/left, right. However, The left and right joysticks are pressure sensitive. How can I read in those values? When presses a little, I want it to move a little. Is there a set of functions that I can use to get this info?
DVader
22
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 28th Jun 2010 16:51 Edited at: 28th Jun 2010 16:52
Hmm, are you looking for the joystick x,y z commands? I don't actually own a analogue joystick I could connect to my PC anymore (no game ports). I assume that those commands give you the analogue position of each axis. Other than that maybe set control device may be useful for you.

http://s6.bitefight.org/c.php?uid=103081
Van B
Moderator
23
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 28th Jun 2010 17:07
Yeah, it should just be a case of checking the correct joystick axis - that's how it works with my joystick, and XBox controller.

Best to just experiment I think - make a little program to simply display the values of the joystick axis', then record the details that you are interested in. You might want to introduce your own dead zone, or smooth things out a bit for example. The tricky part is Hat switches, those little mini-joysticks that are often used for looking around - those actually return the angle of movement, just to confuse matters.


Health, Ammo, and bacon and eggs!
badkneecap
16
Years of Service
User Offline
Joined: 21st Jun 2010
Location:
Posted: 28th Jun 2010 20:07
How do you tell the difference between the left joystick and the right?
Mobiius
Valued Member
23
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 28th Jun 2010 23:32
Quote: "How do you tell the difference between the left joystick and the right?"

They use different command to return their positions. I'll post my complete working code for using them tomorrow if I remember. I use this code in my current game.

My signature is NOT a moderator plaything! Stop changing it!
The Zoq2
16
Years of Service
User Offline
Joined: 4th Nov 2009
Location: Linköping, Sweden
Posted: 1st Jul 2010 00:05
jouystick x,y is the left ans joystick twist x,y is right.

joystick z is th triggers

Srry about my english im from sweeden
Mobiius
Valued Member
23
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 1st Jul 2010 09:36 Edited at: 1st Jul 2010 09:38
Here's my complete joypad code. Everything you need to get working joypads in DBP using standard commands.


Just call InitialiseJoypad() first. This will check to see if a saved joypad profile exists. If it does, it will load it and your joypad is ready to go. If the profile does not exist, then you'll need to call CalibrateJoypad( Stage ) a number of times.

Call it with stage = 2 first. This is when you wiggle all the axis to set the upper and lower boundaries of movement. Then call it with stage 1 which sets the neutral point, then call stage 2 again which confirms everything is working.

Call UpdateJoypad() to get the current stick/hat angles.

Call GetJoypadValue#( Name$ ) to get the value of a stick/hat.
For example, GetJoypadValue#( "hatx" ) will return the hat X axis in a range of -1.0, to 1.0, GetJoypadValue#( "rightthumby" ) will return the Right Thumbsticks Y Axis in a range of -1.0, to 1.0.

Axis$ = GetJoypadName$() will get the name of the stick/hat your using. (This is only really useful when your setting up which axis does what in your game.) Call this, move a stick/hat and it'll tell you which one you moved.

All axes return values from -1.0 to 1.0.

Any questions then just ask.

My signature is NOT a moderator plaything! Stop changing it!
The Viking
17
Years of Service
User Offline
Joined: 21st Oct 2008
Location: Asgard
Posted: 3rd Jul 2010 18:47
I have a logitech as well, this is what I use for the basic controls: And just so you know... The logitech controller does NOT use the same axis as the 360 controller does. So, if you plan to use it for a game, either you will have to have multiple settings, or to play it properly, other people would have to use the same controller as you. One of the annoying draw backs I have found to using a controller for games.



I found this code somewhere here, but had to make modifications to suit the logitech.

www.myspace.com/norseblod
=PRoF=
23
Years of Service
User Offline
Joined: 17th Mar 2003
Location: Milton Keynes, UK
Posted: 4th Jul 2010 19:18
@Mobiius:
Thats a very interesting snippet of code that looks like it warrants a more extensive look at if I can ever get my children off the pc with the controller.

I wrote my own userInput functions, which use an array to store keyboard/controller mappings; but I don't think I ever implemented the dual analogue sticks on the controller.

Mobiius
Valued Member
23
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 5th Jul 2010 12:15
Thanks. I wrote it to go into the game I'm writing. I literally just ripped it out and posted it! It works well enough for me.

My signature is NOT a moderator plaything! Stop changing it!

Login to post a reply

Server time is: 2026-07-25 08:13:27
Your offset time is: 2026-07-25 08:13:27