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

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

Postby suiciwd » 29 Aug 2016, 14:42

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 :)
Graphic Designer & Website Developer
User avatar
suiciwd
 
Posts: 52
Joined: 26 Aug 2016, 12:52

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

Postby MTres19 » 29 Aug 2016, 14:58

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.
User avatar
MTres19
 
Posts: 191
Joined: 17 Aug 2015, 20:15

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

Postby suiciwd » 30 Aug 2016, 02:01

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.
Graphic Designer & Website Developer
User avatar
suiciwd
 
Posts: 52
Joined: 26 Aug 2016, 12:52

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

Postby QwertyChouskie » 30 Aug 2016, 02:13

I don't know if this helps, but this functionality already exists for Wiimotes, maybe you could make the phone emulate a Wiimote.
Contributor to/fan of STK (Upstreamed Cartoon theme, numerous random big fixes/tweaks)
User avatar
QwertyChouskie
 
Posts: 559
Joined: 29 Jun 2016, 14:57

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

Postby Auria » 30 Aug 2016, 02:31

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
Image
User avatar
Auria
STK Moderator
 
Posts: 2976
Joined: 07 Dec 2009, 03:52

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

Postby suiciwd » 30 Aug 2016, 04:35

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
Graphic Designer & Website Developer
User avatar
suiciwd
 
Posts: 52
Joined: 26 Aug 2016, 12:52

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

Postby hiker » 31 Aug 2016, 07:27

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
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