How to Compile on Ubuntu Karmic (Guide)

Problems compiling the game? Ask Here
Post Reply
oviorus
Posts: 1
Joined: Sat Jun 05, 2010 5:35 am

How to Compile on Ubuntu Karmic (Guide)

Post by oviorus » Sat Jun 05, 2010 6:16 am

Hello, I'm new to the forums, I just wanted to share my experiences while trying to compile the sources on ubuntu karmic.

The reason I wanted to recompile is because the game wouldn't recognize my left or right trigger (assigned to left shift and right shift if I am right), so I couldn't change the game phase... I couldn't even change the key bindings in-game because to reach that part of the menu I needed to press those buttons.

So I followed the instructions here http://wololo.net/miki/index.php/Wagic/Compiling and the first problem I encountered was that fmod3.75 is no longer supported at fmod.org so all links to that library were broken. I was able to find the libfmod-3.75.so inside some Wiinstrument-thingy package someone was distributing.

When trying to compile JGE library got some error about printf not receiving a literal string inside JLogger.cpp. It seems that doing something like this is now considered a security risk

Code: Select all

void JLogger::Log(const char * text){
printf(text);
}
I had to replace it for this.

Code: Select all

void JLogger::Log(const char * text){
printf("%s",text);
}
I'm not sure if that still does what was intended, but that change let me compile without problems.

Then I would finally modify the defaultKeybindings in Xmain.cpp. I added the following:

Code: Select all

    { XK_q,	JGE_BTN_PREV },
    { XK_e,	JGE_BTN_NEXT },
    { XK_s,	JGE_BTN_OK },
but even after recompiling nothing happened. Long after that I found a file mtg/bin/Res/settings/options.txt that contains some bindings but even after changing those nothing would happen.

As it happens the only file I had to modify was mtg/bin/Res/player/options.txt with the corresponding keys found on /usr/include/X11/keysymdef.h

Now I can finally press those triggers!. So I think it was worthwhile because I was able to learn some interesting stuff, next step is to install wagic on my psp, and maybe someday to make my own homebrews!.

So thank you all for this amazing work. I thing I will really enjoy this game.
See you around and sorry for my english.

[EDIT ABRA : Change the title of your post from "it works" to the actual one, it is more clear for other users that might have the same problem]

kotuk
Posts: 2
Joined: Sat Jun 26, 2010 9:21 am

Re: How to Compile on Ubuntu Karmic (Guide)

Post by kotuk » Sat Jun 26, 2010 10:04 am

oviorus wrote: As it happens the only file I had to modify was mtg/bin/Res/player/options.txt with the corresponding keys found on /usr/include/X11/keysymdef.h

Now I can finally press those triggers!. So I think it was worthwhile because I was able to learn some interesting stuff, next step is to install wagic on my psp, and maybe someday to make my own homebrews!.

So thank you all for this amazing work. I thing I will really enjoy this game.
See you around and sorry for my english.
Sorry for my bad english.
mtg/bin/Res/player/options.txt contain :

Code: Select all

keybindings_x=32:10,65288:3,65289:11,65293:2,65307:2,65361:7,65362:8,65363:6,65364:9,65406:12,65430:7,65431:8,65432:6,65433:9,65505:14,
/usr/include/X11/keysymdef.h contain :

Code: Select all

#define XK_A                             0x0041  /* U+0041 LATIN CAPITAL LETTER A */
#define XK_B                             0x0042  /* U+0042 LATIN CAPITAL LETTER B */
#define XK_C                             0x0043  /* U+0043 LATIN CAPITAL LETTER C */
How i can translate one to another?
Can u post your file options.txt ?

Jean
Posts: 32
Joined: Tue Nov 18, 2008 5:12 am

Re: How to Compile on Ubuntu Karmic (Guide)

Post by Jean » Sat Jun 26, 2010 2:48 pm

oviorus wrote:So I followed the instructions here http://wololo.net/miki/index.php/Wagic/Compiling and the first problem I encountered was that fmod3.75 is no longer supported at fmod.org so all links to that library were broken. I was able to find the libfmod-3.75.so inside some Wiinstrument-thingy package someone was distributing.
Yes, unfortunately we still use this library. We have plans to get rid of it, but someone has to do it...

Anyway, the build system automatically detects if you have it or not now. So even without it, you can compile and run the game. The drawback is of course, you will not have any sound. On 64-bit architectures, firelight technologies just do not provide support, and they do not give accesses to the source, so we can only complain to them.
But anyway, if you don't care too much about sound, you can just skip using fmod.
oviorus wrote:When trying to compile JGE library got some error about printf not receiving a literal string inside JLogger.cpp. It seems that doing something like this is now considered a security risk
Indeed, it is. Many developers in the project use tools that do not report this error, so they do not notice and commit possibly erroneous code that will not compile on a platform with more thorough checks. When we notice them, we do fix them though ; I remember having fixed the one you mentioned a few days before the 0.12 release.
By the way, your way to fix it was right.

oviorus wrote:but even after recompiling nothing happened. Long after that I found a file mtg/bin/Res/settings/options.txt that contains some bindings but even after changing those nothing would happen.
I'm a little surprised by this :
- Binding are handled platform-by-platform, so you can't have bindings from your PSP getting in the way of your linux installation even if you copy the whole directory.
- The options.txt file does not contain any key binding in the svn - actually the file isn't even inside

So basically you having a keybindings_x in the file means you probably copied the file from another unix where you already had key bindings. And it happens the two machines do not use the same values for the keys.
This would not have happened with a fresh install - I think ; actually it raises the issue of, if you don't have the same values for X keysyms as the place the stuff was compiled, the default keys would not work. Whatever the values are, you could still rebind them however you like and it would work, but that's if you can reach the menu...

I'm not sure whether there really are places with different values for the keysyms - I never encountered one. But the possibility does exist.

Maybe we should either use extremely stable values for default keys (like, A B C - those are pretty much guaranteed to have the same values everywhere) or the symbol names instead of the numbers, which are presumably more stable and less prone to variation from one machine to another...

Anyway, I'm sorry you had that problem, and glad you could solve it :)

kotuk wrote: keybindings_x=32:10,65288:3,65289:11,65293:2,65307:2,65361:7,65362:8,65363:6,65364:9,65406:12,65430:7,65431:8,65432:6,65433:9,65505:14,

/usr/include/X11/keysymdef.h contain :
CODE: SELECT ALL
#define XK_A 0x0041 /* U+0041 LATIN CAPITAL LETTER A */
#define XK_B 0x0042 /* U+0042 LATIN CAPITAL LETTER B */
#define XK_C 0x0043 /* U+0043 LATIN CAPITAL LETTER C */

How i can translate one to another?
This cryptic line basically is a comma-separated list of "localkey:function". The first number is the local key, it is what you see in your keysymdef.h. The second one is the function in the game ; the list can be found in the source, in JGE/include/JTypes.h at line 221. Left and right trigger are 14 and 15, respectively.
So as you see 0x0041, that means 41 in hexadecimal, which is just another way of saying 4*16+1 = 65.
So if you want to change the binding for left trigger to the A key, you could search for the place where it says <some number>:14 and change the number with 65. For example, in the file you posted, you would replace 65505:14 with 65:14.

It's convoluted, but it's meant to be easy for a computer to read, not for humans, who are supposed to use the game interface :)

kotuk
Posts: 2
Joined: Sat Jun 26, 2010 9:21 am

Re: How to Compile on Ubuntu Karmic (Guide)

Post by kotuk » Sat Jun 26, 2010 5:22 pm

Jean wrote: This cryptic line basically is a comma-separated list of "localkey:function". The first number is the local key, it is what you see in your keysymdef.h. The second one is the function in the game ; the list can be found in the source, in JGE/include/JTypes.h at line 221. Left and right trigger are 14 and 15, respectively.
So as you see 0x0041, that means 41 in hexadecimal, which is just another way of saying 4*16+1 = 65.
So if you want to change the binding for left trigger to the A key, you could search for the place where it says <some number>:14 and change the number with 65. For example, in the file you posted, you would replace 65505:14 with 65:14.

It's convoluted, but it's meant to be easy for a computer to read, not for humans, who are supposed to use the game interface :)
Thanks for fast answer.
I experiment whith letter A and B, as are you say :
rofile=Default
Lang=en
maxGrade=0: Borderline (99% OK)
keybindings_x=32:10,65288:3,65289:11,65293:2,65307:2,65361:7,65362:8,65363:6,65364:9,65406:12,65430:7,65431:8,65432:6,65433:9,65:14,66:15,65507:10,65508:10,65509:13
But still can't navigate between tabs in options menu
At this time functional only next keys: arrow keys, Esc, Ctrl & Space
Big letter A and B not work
Try to add next :
keybindings_x=65470:14
65470 = FFBE
in keysmdef.h
#define XK_F1 0xffbe
#define XK_F2 0xffbf
Situation didn't change :oops:

ogui
Posts: 1
Joined: Wed Aug 11, 2010 9:36 am

Re: How to Compile on Ubuntu Karmic (Guide)

Post by ogui » Wed Aug 11, 2010 10:11 am

Solution : I figured out out to change the keymapping / keybinding in my profile based on the information posted above.

Summary:
  • The first step is to give yourself operational Trigger keys for the Left (14) and Right (15) Trigger so you can select the Key Binding tab menu in the in-game 'Option' menu
  • Once that's done, you'll be able to access Key Bindings in Options and change the keybinding to your system's own keycodes and your own preference from within the game. Easy.
  • Shortcut : you can also copy paste my key configuration from the /PSP/GAME/WTH/Res/player/options.txt
In order to add new keybindings to my Left and Right triggers, I assigned them the PageUp and PageDown on my keyboard by adding

Code: Select all

65365:14,65366:15,
at the beginning of line 8 in file /PSP/GAME/WTH/Res/player/options.txt :

Code: Select all

keybindings_x=32:10,65288:3,65365:14,65366:15,65289:11,65293:2,65307:2,65361:7,65362:8,65363:6,65364:9,65406:12,65430:7,65431:8,65432:6,65433:9,65505:14,65506:15,65507:10,65508:10,65509:13
Note : It works if you change these values in the player folder, not in the settings folder which are both under Res. Maybe that was the mislead in the previous post

Now start the game, go to Options (using the right arrow key of the keyboard), I used the Left Control key to go in, then the moment of truth: try your PageUp and PageDown keys on your keyboard. Normally it should take you from one Tab menu to another until Key Bindings.
There you can use your Up and Down arrow to choose "New binding ...", press a key on your keyboard, then choose a corresponding Controller action in the list (you need to use the Down key to scroll the list further down, not all options are visible).
Always remember to select "New binding ..." in the menu in order to add a new one.
Once you've added your own Key Bindings, you can also delete the default ones. Go down in the list, use Left_Control key (corresponds to Circle I think) and then choose delete in the menu.

For illustration, once I had redefined all keybinding, my /PSP/GAME/WTH/Res/player/options.txt now looks like this:

Code: Select all

Theme=Default
musicVolume=50
sfxVolume=70
closed_hand=visible
disable_cards=1
maxGrade=0: Borderline (99% OK)
interruptSeconds=5
keybindings_x=65:7,67:15,68:10,69:6,70:16,81:12,83:13,87:14,88:13,90:11,65288:3,65293:2,65307:2,65361:7,65362:8,65363:6,65364:9,65365:14,65366:15,65430:7,65431:8,65432:6,65433:9,65507:6
unlocked_10E=2010/8/10@16:45 
It corresponds as follow on my USA layout keyboard:

Left Trigger = Z
Right Trigger = C
Left = Q
Right = E

Circle = D
Cross = S or X
Triangle = W
Square = A

The rest is unchanged:
ESC or ENTER for menu
Arrow keys for directional buttons
etc...
That mapping works nicely : left index has D for activating all menus and C to move to the next phase of the game.

For reference, I've numbered the JGE buttons in the Source file JGE/include/JTypes.h which correspond to the numbers in the option.txt file:

Code: Select all

typedef enum Buttons
  {
 0    JGE_BTN_NONE = 0,   // No button pressed 
 1    JGE_BTN_QUIT,   // Home on PSP
 2    JGE_BTN_MENU,   // Start on PSP
 3    JGE_BTN_CTRL,   // Select
 4    JGE_BTN_POWER,  // Hold
 5    JGE_BTN_SOUND,  // Music note
 6    JGE_BTN_RIGHT,
 7    JGE_BTN_LEFT,
 8    JGE_BTN_UP,
 9    JGE_BTN_DOWN,
10    JGE_BTN_OK,     // Circle in Japan, Cross in Europe
11    JGE_BTN_CANCEL, // Triangle
12    JGE_BTN_PRI,    // Square (primary)
13    JGE_BTN_SEC,    // Cross or Circle (secondary)
14    JGE_BTN_PREV,   // Left trigger
15    JGE_BTN_NEXT,    // Right trigger
16    JGE_BTN_FULLSCREEN,    // Switch to fullscreen (obviously, PC only)
    JGE_BTN_MAX = JGE_BTN_NEXT + 1
  } JButton;
This might save someone the trouble of getting the SVN sources just to check it.

Thanks for the previous posts.
The HEX to Decimal conversion worked for me.

Post Reply