Page 1 of 1

How to add a new input method to the STK source code

PostPosted: 29 Aug 2016, 14:42
by suiciwd
I am trying to create an app (which will be open sourced) which lets you control STK by rotating your device.But to do this without being hacky (I mean running a script while running STK) I need to add a new input method to STK.

Which part of the code should I modify / add my UDP server to (I am a C++ n00b :)

Re: How to add a new input method to the STK source code

PostPosted: 29 Aug 2016, 14:58
by MTres19
What kind of device? I would recommend writing a driver to emulate a gamepad or something instead; then STK will recognize it and work out-of-the-box.

Re: How to add a new input method to the STK source code

PostPosted: 30 Aug 2016, 02:01
by suiciwd
I want to be able to control STK by rotating my phone.I think that this should be integrated into STK but for testing an input driver would be okay.

Re: How to add a new input method to the STK source code

PostPosted: 30 Aug 2016, 02:13
by QwertyChouskie
I don't know if this helps, but this functionality already exists for Wiimotes, maybe you could make the phone emulate a Wiimote.

Re: How to add a new input method to the STK source code

PostPosted: 30 Aug 2016, 02:31
by Auria
Hi,

as a starting pointer, take a look at method "bool EventHandler::OnEvent" in guiengine/event_handler.cpp, this is where input events start being handled ( EET_KEY_INPUT_EVENT, EET_JOYSTICK_INPUT_EVENT )

Simulating a gamepad/joystick is indeed your best bet

Re: How to add a new input method to the STK source code

PostPosted: 30 Aug 2016, 04:35
by suiciwd
Also do you have any idea of why SuperTuxKart does not recognize my laptop's accelerometer (which is acts as a joystick) although Neverball does

Re: How to add a new input method to the STK source code

PostPosted: 31 Aug 2016, 07:27
by hiker
suiciwd {l Wrote}:Also do you have any idea of why SuperTuxKart does not recognize my laptop's accelerometer (which is acts as a joystick) although Neverball does

Most likely because we disabled it since it interferes with steering and/or changing the key bindings.

Cheers,
Joerg