Page 1 of 1

New key binding

PostPosted: 05 May 2018, 18:24
by Cloter
How can I create a new binding for a key, let's say PgUp/PgDn, and have them do the same action as 'arrow up/arrow down". After I get this to work I can go from there and have PgUp/PgDn alter a new variable (to be created). So far ... I've created a new binding in the 'input.h' and also in 'keyboard_config.cpp'.. But I'm missing the next steps to make the event get to the input_manager.cpp. I'm stuck... :( I appreciate any help on this!

Re: New key binding

PostPosted: 05 May 2018, 19:45
by Alayan
Why are you trying to edit the code, rather than editing the configuration ?

And if you want 2 keys able to do the same action, create a second config, put all the unwanted menu actions under a menu key controlled by the first config (this disable them), and put the wanted keys for the wanted actions in the second config.

Re: New key binding

PostPosted: 05 May 2018, 20:03
by Cloter
Yes, I am editing the code. The second configuration file wont do for me.. I mentioned PgUp/Pgdn as an example only - sorry if it was confusing.. I want to understand how to create a new biding in the code because I will be working with a new variable I am going to create.

Re: New key binding

PostPosted: 05 May 2018, 23:52
by Auria
Could you describe a bit more precisely what you are trying to achieve? It's hard to offer proper guidance when I'm unsure what you're trying to do

Anyway, take a look at the "input" folder in the STK source folder. "input_manager" is the central point, and there's objects to manage configurations and various device types (keyboard, gamepad)

Re: New key binding

PostPosted: 06 May 2018, 13:42
by Cloter
Thanks Auria, I'll look into it (input_manager and related objects). Later I'll post more specific stuff about what I'm doing! And, of course, great project!

Re: New key binding

PostPosted: 05 Jun 2018, 02:16
by Cloter
OK, Auria, so it's like this: I wanted to control STK with a different external controller, and this controller is a (gym) spinning bike. Also, the STK controls the spinning bike, i.e., it controls the load (how heavy the bike feels) based on several info from the World, Kart and Race Manger classes. I have buttons on the bike mapped to basic kart control and actions. One of these functions is the accelerate function that corresponds to how fast the person is pedalling on the bike. The new key binding I needed was to control the general difficulty (to match the person's physical aptitude). Ups and downs of the track, crashes, hitting things, bubblegum or bananas, getting nitros and the boxes... all of this increases or decreases the load on the bike, and each effect (or game event) has its own duration and strength. I think I understood how the game handles theses events and I added a bunch of command line options to control how the game behaves regarding controlling the load. I tried to follow the recommended programming style, but being an electrical engineer and not a real programmer, I must have made some ugly choices. It uses USB ports (one for each of 4 possible bikes) to talk to the bikes – but I’ll go bluetooth soon. It's possible to do a "race" with up to 4 players on spinning bikes effectively feeling all the ups and downs of the tracks and the events of the game as variations of the load on the bike pedals. This is a link for a semi-edited video of kids using the bike with a modified STK in a local school: https://www.youtube.com/watch?v=WAt9RA-Dgpo

Re: New key binding

PostPosted: 05 Jun 2018, 02:33
by QwertyChouskie
Woah, sounds awesome! Way better than the TVs they have in gyms, this actually makes it a competition! Can't wait to see the vid :)

Re: New key binding

PostPosted: 06 Jun 2018, 00:06
by Auria
That is really cool, nice work and thanks for sharing :)

Re: New key binding

PostPosted: 06 Jun 2018, 04:25
by GeekPenguinBR
Hi! Cloter.

I really liked your initiative and this simulator. It's a very good idea to make everyone keeps fit while playing STK. Every school in our country should have one. ;)

Gostei mesmo da iniciativa. Até eu gostaria de experimentar isso. :) Fazer exercícios enquanto se pilota um kart no STK é muito mais divertido que simplesmente pedalar e pedalar buscando um resultado futuro (e incerto). O bom disso é que, além de promover a atividade física de um modo não enfadonho, vocês ainda podem ajudar a divulgar o STK nesses eventos nas escolas e nos shopping centers daí e de outras partes do Brasil. Vocês são de qual lugar do Paraná? Ponta Grossa, mesmo? A cada evento como esse (https://www.youtube.com/watch?v=2ogzk4M6J3o), além de testar e divulgar o simulador, vocês poderão - também- fazer surgir centenas de novos fãs do STK. Aposto que a maior parte da galerinha ali nem conhece o jogo, ainda.

Acredito que tem tudo para ser um sucesso. Dá para imaginar um futuro a médio prazo com os usuários acessando uma tela de toque para escolher o jogo de corridas preferido que jogarão enquanto realizam a rotina passada pelo professor.

Parabéns!

Re: New key binding

PostPosted: 06 Jun 2018, 05:41
by Cloter
@GeekPenguinBR, I'll answer in English for the benefit of the other folks! Yes, we are in Ponta Grossa, PR (southern Brazil) and are launching the simulator this semester. The idea is exactly that, to motivate people to engage in more physical activity using this awesome game, the STK! So far we have done demonstrations in schools and shopping malls, mainly to debug the game and validate the features. We feel that we have most details worked out so we can start selling the simulator, as a complete bike (with the load control system) or just a load control kit that can be installed in a pre-existing spinning bike. STK will be installed mostly unmodified in its appearance - logos and all. Also, we will promote the game everywhere to kids and adults. STK is brilliant in channeling the love for Mario Kart that at least two generations of games have. It's also interesting to see that most people attracted to pedal with the game are sedentary people that just can't resist the appeal of playing STK. Big touch screen attached to the front of the bike is in the works, as well as other kinds of physical activity machines!

Re: New key binding

PostPosted: 06 Jun 2018, 17:44
by Alayan
While if you can get 4 bikes/players at once, you don't need anything more, it seems more tricky to balance it well against the AI. How do you manage this ?

Re: New key binding

PostPosted: 07 Jun 2018, 01:16
by QwertyChouskie
It's probably fine given STK's AI weakness. Also the video shows what looks like Novice or Intermediate. Also, where can the code be found? I'd like to see it :)

Re: New key binding

PostPosted: 07 Jun 2018, 01:35
by Cloter
I'm going only up to 4 bikes, and I don't intend to expand this. I'll let STK be STK, and only add the changes that allow communication with the bikes and some internal handling of events in the game. I don't want to change so much that could make it hard to go to a new version. Actually, I will get in touch with the developers to understand where STK is going in the future so the changes I need won't conflict with that. As for my code now, I would say it's pre beta, it's needs to mature a little more for a public release. Also, the difficulty I used for the video is Intermediate and I only tested with up to three bikes. 1/2/3 bikes is just like 1/2/3 players using keyboards or game controllers. I never tested with 4 human players, not even in the game itself, without the mods.

Re: New key binding

PostPosted: 07 Jun 2018, 02:08
by QwertyChouskie
The Git version of STK actually allows for 8 players. Is your code based on 0.9.3 or git?

Re: New key binding

PostPosted: 07 Jun 2018, 13:03
by Cloter
It's based on 0.9.3 (thanks for the info). I'll try the mods as patches, time permitting, so I can use other versions (git, for example) more quickly.

Re: New key binding

PostPosted: 07 Jun 2018, 21:14
by QwertyChouskie
There has been some refactoring to separate the graphics from the physics in the git version, so the code may need some tweaking. Things have mostly settled down after the refactoring, so once the code works with the git version, it should continue to do so with minimal tweaking.

Re: New key binding

PostPosted: 08 Jun 2018, 01:54
by Cloter
Thanks again, I'ĺl look into this. ;)