new developer question (kart speed/joystick/general setup

new developer question (kart speed/joystick/general setup

Postby terrysmith2000 » 01 Jun 2015, 02:27

I am still finding my feet here. Patience appreciated.

I am able to build STK (windows 8/strong machine). I have a USB joystick and I am trying to get speeds between stopped and full throttle.

When I press the up arrow and drive with the left/right arrows on the keyboard, I see changes in speed as we hit hills and go into turns. So I can see variable speed.

But when I use a controller, I basically only create those states: key pressed & key not pressed. I've checked with windows control panel. My controller is acting right. I can see behavior from -1 (back) to zero to +1 (full forward) and many steps in between.

I am trying similar stuff described here: viewtopic.php?f=17&t=2806

I also tried supertuxkart.exe --console --log=0 which did not have much effect. I was trying to see my speed as an integer and find out what other debug info developers liked would be shown.

I want to achieve "medium speeds" with my controller.

Bonus points: any tutorial/explanation of how to see internal state is appreciate. In the link I give Auria offers help with where to put debug statements. That is the kind of stuff I am looking for.

thanks
terrysmith2000
 
Posts: 6
Joined: 26 May 2015, 03:05

Re: new developer question (kart speed/joystick/general setu

Postby Auria » 02 Jun 2015, 01:20

Hi,

this is pretty weird, but we've seen so many weird controller behaviors by now that little surprises me anymore (seems like no 2 devices and 2 drivers behave the same way)

A good place to look would be in input/input_manager.cpp, in method InputManager::dispatchInput
You could log parameters "axisDirection" and "value". in something like
{l Code}: {l Select All Code}
if (type == Input::IT_STICKMOTION)
    Log::info("InputDebug", "axisDirection : %i, value: %i", (int)axisDirection, (int)value);


Checking if those values are correct would be the right first step
Image
User avatar
Auria
STK Moderator
 
Posts: 2976
Joined: 07 Dec 2009, 03:52

Re: new developer question (kart speed/joystick/general setu

Postby terrysmith2000 » 02 Jun 2015, 02:08

Thanks, I found that code tonight and it is heartening to see that I am in the right place. I'm using warn because it was faster than figuring out where the log level is set <wince>.

Now with the same controller, I am able to get intermediate speeds. It may be that seeing a digital readout of stick value is helping me use the controller. Or it could be this very inexpensive controller does not work the same way all the time. That said, I am empowered to figure it out. Thanks!

If anyone finds this in the future, consider wrapping the debug statement in an if statement like below. Then a neutral stick will not print info.
if (abs(*value) > 500) { }
terrysmith2000
 
Posts: 6
Joined: 26 May 2015, 03:05

Re: new developer question (kart speed/joystick/general setu

Postby hiker » 02 Jun 2015, 03:19

terrysmith2000 {l Wrote}:Now with the same controller, I am able to get intermediate speeds. It may be that seeing a digital readout of stick value is helping me use the controller. Or it could be this very inexpensive controller does not work the same way all the time. That said, I am empowered to figure it out. Thanks!

I have used a cheap controller in the past, and it actually had two different modes (selected by pressing a certain button on the controller): one analog mode, and one digital. Perhaps your controller does the same and you had it in the wrong mode?

Cheers,
Joerg
hiker
 
Posts: 1435
Joined: 07 Dec 2009, 12:15
Location: Melbourne, Australia

Who is online

Users browsing this forum: No registered users and 1 guest