[SOLVED]How compile on Linux & change key event system

Spiegel

Wheel Shatterer
How compile on Linux & change key event system

Tested on Ubuntu - Updated 12/06/2020
With this thread you'll be able to use azerty layout with the game (or dvorak or anything else)

Build Sonic Robo Blast 2

Compilation
Installing dependencies :
Code:
sudo apt install -y libgme-dev libsdl2-mixer-dev libsdl2-dev zlib1g-dev libpng-dev nasm build-essential git libcurl4 libcurl4-openssl-dev
Download Source code :
Code:
https://github.com/STJr/SRB2.git
Locate the folder :
Code:
cd SRB2
Start Compiling :
Code:
export LIBGME_CFLAGS=
export LIBGME_LDFLAGS=-lgme
make -C src/ LINUX64=1

One line copy past to build :
Code:
sudo apt install -y libgme-dev libsdl2-mixer-dev libsdl2-dev zlib1g-dev libpng-dev nasm build-essential git libcurl4 libcurl4-openssl-dev ; git clone https://github.com/B4rabbas/SRB2.git ; cd SRB2 ; export LIBGME_CFLAGS= ; export LIBGME_LDFLAGS=-lgme ; make -C src/ LINUX64=1

Your compiled executable is in
~/SRB2/bin/Linux64/Release/

Build Sonic Robo Blast 2 Kart

Installing dependencies :
Code:
sudo apt install -y libgme-dev libsdl2-mixer-dev libsdl2-dev zlib1g-dev libpng-dev nasm build-essential git libcurl4 libcurl4-openssl-dev
Download Source code :
Code:
git clone https://github.com/STJr/Kart-Public.git
Locate the folder :
Code:
cd Kart-Public
Start Compiling :
Code:
export LIBGME_CFLAGS=
export LIBGME_LDFLAGS=-lgme
make -C src/ LINUX64=1

One line copy past to build :
Code:
sudo apt install -y libgme-dev libsdl2-mixer-dev libsdl2-dev zlib1g-dev libpng-dev nasm build-essential git libcurl4 libcurl4-openssl-dev ; git clone https://github.com/STJr/Kart-Public.git ; cd Kart-Public ; export LIBGME_CFLAGS= ; export LIBGME_LDFLAGS=-lgme ; make -C src/ LINUX64=1

Your compiled executable is in
~/Kart-Public/bin/Linux64/Release/

How change the key event system

Before start the compilation, open "src/sdl/i_video.c" in your favorite text editor

There is few replacements to do

Replace
(SDL_Scancode code)
by
(SDL_Keycode code)


code >= SDL_SCANCODE_
by
code >= SDLK_


code <= SDL_SCANCODE_
by
code <= SDLK_


code - SDL_SCANCODE_
by
code - SDLK_


code == SDL_
by
code == SDLK_


event.data1 = Impl_SDL_Scancode_To_Keycode(evt.keysym.scancode);
by
event.data1 = Impl_SDL_Scancode_To_Keycode(evt.keysym.sym);


case SDL_SCANCODE_
by
case SDLK_


Then add

#ifdef HWRENDER
DBG_Printf("Unknown incoming scancode: %d, represented %c\n",
code,
SDL_GetKeyName(SDL_GetKeyFromScancode(code)));
#endif
return 0;
}


before
static void SDLdoGrabMouse(void)



Original post
Edit : Solved, thanks to thevintagemood who explain what modifications to do. Here is the src/sdl/i_video.c edited to be used for every keyboard layour.
https://github.com/B4rabbas/Sonic-Kart/blob/master/src/sdl/i_video.c
Due to the need the subject isn't anymore an help for some command scripting but for code modifications. The goal is to use azerty keyboard (or dvorak or any type of keyboard layout) with the game.

The real problem the non qwerty users are experiencing is the the key event use the scan code, and don't care about the layout is associated with it at your home, you can change your layout at home this will not work, it don't care 'cause this dont change the scancode.

Thanks to discord community who've helped me, especially AlamTaz for his patience.

So if I have understood correctly in SRB2/blob/master/libs/SDL2/include/SDL_keyboard.h
https://github.com/STJr/SRB2/blob/master/libs/SDL2/include/SDL_keyboard.h
I have (maybe not tried yet) to replace all mention to "SDL_Scancode" by "SDL_Keycode" in the file.

I'll give more info of this sacred quest :°)

Hello Folks,

I'm looking wich command I should use to rebind a key linto an other key.

By exemple I would like to bind A to type Q in chatrrom
I've try
Code:
bind a "Q"
or
Code:
bind a "q"
or
Code:
bind a "KEYq"
or
Code:
bind a "KEYQ"

But there is no change, here is some missing argument in my command ?

Many Thanks. :)

Ps : if you just want to compile srb2 on your linux debian system (or derivated as ubuntu, not sure for others gnu etc) jump to this post. :)
 
Last edited:
You can't rebind a key to another key through the bind command.
The command is only for binding one or multiple commands to a key, not reassigning functionality.
 
I was thinking I've already done this on srb2 one or two years ago, I was able to rebind the layout at least for the chat room.

Really confusing.

Anyway in the case I'm mistaking myself, any chance to improve terminal with a new command , or make addon to do this ?

I've just try xmodmap on my linux terminal
Code:
xmodmap -e "keycode 24=a"

It don't work neither :/

Here is any way to force theses input inapp ?
Any launch argument to do this maybe ?


I'ld really enjoy to chat with other players in multiplayer.
 
Last edited:
If you want to make it so that pressing A makes you send a "Q" message into the text chat, try...
Code:
bind a "say Q"
...or replace "say" with "sayteam" if you want to tell "Q" to only your teammates in a team-based game.

If you want to make it so that pressing A while the console or text chat input are open types a Q into the console or text chat input, you can't do that without doing a source code modification of Sonic Robo Blast 2 and/or using other third-party software to "remap" the keyboard input.
 
For whatever reason, SRB2 will force the qwerty keyboard layout on you even if you have azerty or something else (This is, I assume, the problem you're facing). I haven't really found any way to go around this and had to get used to it over the years, it seems to completely overwrite any setting you could have on your machine for some reason as well.

Binds can only be used to execute commands when you press keys as stated above, so sadly they can't be used to fix that either.
The only proper fix I could think of would be to directly go ahead and edit the source code.
 
If you want to make it so that pressing A makes you send a "Q" message into the text chat, try...
Code:
bind a "say Q"
...or replace "say" with "sayteam" if you want to tell "Q" to only your teammates in a team-based game. (...)
Hi,
Unfortunatly, the "Say*" command will immediatly send the entry you've setup
If I type Hello you will see in chat box :
Spiegel : H
Spiegel : e
Spiegel : l
Spiegel : l
Spiegel : o

(...)
If you want to make it so that pressing A while the console or text chat input are open types a Q into the console or text chat input, you can't do that without doing a source code modification of Sonic Robo Blast 2 and/or using other third-party software to "remap" the keyboard input.
About third-party software, have you any utility to suggest ? Actually xmodmap don't work.
For source modifications, in with file is set the layout ?

For whatever reason, SRB2 will force the qwerty keyboard layout on you even if you have azerty or something else (This is, I assume, the problem you're facing). I haven't really found any way to go around this and had to get used to it over the years, it seems to completely overwrite any setting you could have on your machine for some reason as well.

Binds can only be used to execute commands when you press keys as stated above, so sadly they can't be used to fix that either.
The only proper fix I could think of would be to directly go ahead and edit the source code.

Yeah, I don't think that should be too hard to build but where is set the layout in the code ? :°)



However thanks for answering, that's kind attitude, much appreciated.


If anybody else had third party software to suggest (xmodmap and de facto autokey don't work) or know where is set the layout (which file and line) in the source code.

Spiegel


EDIT : I've to much trouble for cross compiling 32bit on my 64 bit ubuntu (especially for getting 32bit dep).
I give up the idea to modify source code to compile modified version.
I don't have enough experience and I'll not bother devteam with this, I don't think they would to take me by the hand to explain how to build it when there is stable release. (btw the compiling infos are not really user friendly and relevant, and I think there is some dep issue on 64 make with libgme)
 
Last edited:
EDIT : I've to much trouble for cross compiling 32bit on my 64 bit ubuntu (especially for getting 32bit dep).
I give up the idea to modify source code to compile modified version.
I don't have enough experience and I'll not bother devteam with this, I don't think they would to take me by the hand to explain how to build it when there is stable release. (btw the compiling infos are not really user friendly and relevant, and I think there is some dep issue on 64 make with libgme)
Your experience trying to get a build environment set up for SRB2 is far from unique. Traditionally, these issues get solved by asking alam for help on the public discord - though there's a hardcoding channel there as well, so somebody else may recognize the issue off the bat if you run through it there. Don't feel bad about asking - we're happy to help new people learn how to edit the game.

https://discord.gg/pYDXzpX

If you can write down what was missing from the build instructions afterwards, that would be appreciated too.
 
Last edited:
Spiegel said:
[...] About third-party software, have you any utility to suggest ? Actually xmodmap don't work. [...]
No, I don't.

Spiegel said:
[...] For source modifications, in with file is set the layout ? [...]
I don't remember, but look around for the "english" console command; It sets the keyboard layout to an English one (presumably United States of American English), though there aren't any other keyboard-map console commands at the moment.
 
I can't view the Ubuntu way to do this that you sent, maybe it's privated?
damn.
spr_pizzelle_talk_or_something_lol.gif
 

Who is viewing this thread (Total: 1, Members: 0, Guests: 1)

Back
Top