Tomb Raider Forums  

Go Back   Tomb Raider Forums > Tomb Raider Level Editor and Modding > Tomb Raider Level Editor > Software Development

Reply
 
Thread Tools
Old 05-01-15, 06:36   #1081
Joey79100
Member
 
Joey79100's Avatar
 
Joined: Mar 2012
Posts: 3,739
Default

Quote:
Originally Posted by Nickotte View Post
Is there any way to change the keyboard layout? Many characters are incompatible between my layout and the console.

EDIT: Nevermind, I just added the correct key codes and a switch for now.
How did you do if you don't mind? I'm in the same case but I don't know how to solve it.
Joey79100 is offline   Reply With Quote
Old 05-01-15, 08:36   #1082
SrDanielPonces
Member
 
SrDanielPonces's Avatar
 
Joined: Apr 2012
Posts: 10,343
Default

Quote:
Originally Posted by nickotte View Post
is there any way to change the keyboard layout? Many characters are incompatible between my layout and the console.

please ;-;
SrDanielPonces is offline   Reply With Quote
Old 05-01-15, 09:10   #1083
Lwmte
Member
 
Lwmte's Avatar
 
Joined: Aug 2010
Posts: 1,809
Default

SrDanielPonces, Joey79100: It's very easy, just open config.lua file and scroll to the end of it, there are bunch of commands like bind(act.jump, KEY_SPACE, JOY_3). These commands bind specific keys to specific actions. You can change KEY_SPACE to KEY_LALT in this command, so jump is now assigned to left ALT key.

Note that some bind commands have three arguments, e.g. aforementioned one, while some have only two, like bind(act.up, KEY_W). That's because you can have one or two different keys assigned for each action.

So, to change keyboard layout to default TR one, it will look like this:

Code:
bind(act.jump, KEY_LALT);
bind(act.action, KEY_LCTRL);
bind(act.roll, KEY_END);
bind(act.sprint, KEY_SLASH);
bind(act.crouch, KEY_PERIOD);
bind(act.walk, KEY_LSHIFT);
bind(act.up, KEY_UP);
bind(act.down, KEY_DOWN);
bind(act.left, KEY_LEFT);
bind(act.right, KEY_RIGHT);
bind(act.lookup, KEY_W, JOY_POVUP);
bind(act.lookdown, KEY_S, JOY_POVDOWN);
bind(act.lookleft, KEY_A, JOY_POVLEFT);
bind(act.lookright, KEY_D, JOY_POVRIGHT);
Nickotte: Sure, change everything you want to, that's the way I got used to the code, actually! You can clone a SF repo and make your own fork, then commit changes which will be integrated to main fork. That's the way Cochrane, vobject and Gh0stBlade did with their forks.
Lwmte is offline   Reply With Quote
Old 05-01-15, 15:55   #1084
Gh0stBlade
Member
 
Gh0stBlade's Avatar
 
Joined: Dec 2010
Posts: 2,773
Default

Last year was a great year for OpenTomb. I just wanted to take the time to congratulate the team for all their work!



Here's to another year of OpenTomb! I wonder what 2015 could bring? Seems like we may have another exciting year ahead of us!

Gh0stBlade is offline   Reply With Quote
Old 05-01-15, 16:27   #1085
Nickotte
Member
 
Nickotte's Avatar
 
Joined: May 2010
Posts: 256
Default

Game controls are ok, and they can easily be rebinded, that wasn't the problem; was I was referring to was the layout for console keys like < > , . : ; - + ( ) ! | ' " ^ etc. etc.

I added them manually in the source code and added a switch for them in the config-lua file, I'll upload it into a fork and post it ASAP

I just need to wait for a darn email from SF for resetting my account password.... waiting since 3 weeks ago ._.

Last edited by Nickotte; 05-01-15 at 16:32.
Nickotte is offline   Reply With Quote
Old 05-01-15, 18:03   #1086
Gh0stBlade
Member
 
Gh0stBlade's Avatar
 
Joined: Dec 2010
Posts: 2,773
Default

Quote:
Originally Posted by Nickotte View Post
Game controls are ok, and they can easily be rebinded, that wasn't the problem; was I was referring to was the layout for console keys like < > , . : ; - + ( ) ! | ' " ^ etc. etc.

I added them manually in the source code and added a switch for them in the config-lua file, I'll upload it into a fork and post it ASAP

I just need to wait for a darn email from SF for resetting my account password.... waiting since 3 weeks ago ._.
I had some serious issues with sourceforge where it wouldn't let me push to the repo I had forked from the original OpenTomb repo. So I just use bitbucket. It seems that SF is really buggy these days. Not sure why.
Gh0stBlade is offline   Reply With Quote
Old 05-01-15, 21:56   #1087
Nickotte
Member
 
Nickotte's Avatar
 
Joined: May 2010
Posts: 256
Default

Finally worked out the account problems now, it looks like it's working for me. Only minor issue I had was I set up SourceTree incorrectly.
Anybody can tell me if I'm doing it right?
https://sourceforge.net/u/banderi/op.../default/tree/

Last edited by Nickotte; 05-01-15 at 22:15.
Nickotte is offline   Reply With Quote
Old 05-01-15, 23:24   #1088
Lwmte
Member
 
Lwmte's Avatar
 
Joined: Aug 2010
Posts: 1,809
Default

Nickotte: Ah, sorry, now I understand what's the problem with keyboard layout. It seems more like a problem with SDL2, not with OpenTomb itself. While keycodes (SDLKs) should provide layout-dependent result, looks like they work like scancodes, which always return the same code.

I have checked your fork on SF, and there is a strange file called "main_SDL.cpp.orig", but I wonder where is the modified one? Your commit doesn't contain any changes to main_SDL.cpp. Also, some strange business with control_constants.lua file, seems diff is messed up, but I suppose it's because your editor changes formatting (it's a common problem when different people are using different editors - like, TeslaRus used NetBeans, I used CodeBlocks+Notepad++ - and we had constant formatting conflicts until I've changed some formatting options in Notepad++ ).

Gh0stBlade: Thanks! Surely it was very productive year - we finally have proper collision, working audiotrack player, pick-up items, basic inventory, static lighting in room geometry, and many more features... What I expect in 2015 is that we finally finish proper trigger support (the system is not yet developed at all!) and begin to integrate some shaders / graphical effects - maybe some basic ones, like glow, depth of field and SSAO... That would be plenty already!

Last edited by Lwmte; 05-01-15 at 23:27.
Lwmte is offline   Reply With Quote
Old 06-01-15, 00:02   #1089
Nickotte
Member
 
Nickotte's Avatar
 
Joined: May 2010
Posts: 256
Default

I'm using Code::Blocks & Notepad++ too, maybe it's the same problem XD
I actually noticed something similar with bluffy diffs yesterday, I didn't check again before committing. I tried fixing the commit, tell me if it's ok now.
Nickotte is offline   Reply With Quote
Old 07-01-15, 17:13   #1090
Tonttu
Member
 
Tonttu's Avatar
 
Joined: May 2006
Posts: 130
Default

Quote:
Originally Posted by Nickotte View Post
Game controls are ok, and they can easily be rebinded, that wasn't the problem; was I was referring to was the layout for console keys like < > , . : ; - + ( ) ! | ' " ^ etc. etc.
Quote:
Originally Posted by Lwmte View Post
Nickotte: Ah, sorry, now I understand what's the problem with keyboard layout. It seems more like a problem with SDL2, not with OpenTomb itself. While keycodes (SDLKs) should provide layout-dependent result, looks like they work like scancodes, which always return the same code.
I actually did a patch sometime ago to fix this by using SDL_TEXTINPUT because the console was annoying me but I forgot about it until I read this.
I've updated it so that it applies correctly to current version.
This is the first time that I've done something with SDL so I'm not sure if what I'm doing is the right way to do things but at least it seems to work (didn't crash while I was testing and the keys work in the console as expected)
It doesn't handle wide characters (å, ä, ö, € and probably others) although I guess they aren't really needed. Perhaps those could be supported by using wchar_t but I haven't tried it because I didn't need them.

Code:
diff -r 8f7a8c35435f src/controls.cpp
--- a/src/controls.cpp	Tue Jan 06 15:37:56 2015 +0300
+++ b/src/controls.cpp	Wed Jan 07 19:03:17 2015 +0200
@@ -104,12 +104,14 @@
                             Audio_Send(lua_GetGlobalSound(engine_lua, TR_AUDIO_SOUND_GLOBALID_MENUOPEN));
                             SDL_ShowCursor(1);
                             SDL_SetRelativeMouseMode(SDL_FALSE);
+                            SDL_StartTextInput();
                         }
                         else
                         {
                             Audio_Send(lua_GetGlobalSound(engine_lua, TR_AUDIO_SOUND_GLOBALID_MENUCLOSE));
                             SDL_ShowCursor(0);
                             SDL_SetRelativeMouseMode(SDL_TRUE);
+                            SDL_StopTextInput();
                         }
                     }
                     break;
@@ -361,192 +363,14 @@
         SDL_HapticRumblePlay(sdl_haptic, power, time);
 }
 
-int Controls_KeyConsoleFilter(int32_t key, int kmod_states)
+int Controls_KeyConsoleFilter(char *text)
 {
-    switch(key)
+    while (*text != '\0')
     {
-        case SDLK_SEMICOLON:
-            if( !(kmod_states & KMOD_SHIFT) )
-                return key;
-            else
-                return ':';
+        Con_Edit(*text);
+        text++;
+    }
 
-        case SDLK_BACKSLASH:
-            if( !(kmod_states & KMOD_SHIFT) )
-                return key;
-            else
-                return '|';
-
-        case SDLK_SLASH:
-            if( !(kmod_states & KMOD_SHIFT) )
-                return key;
-            else
-                return '?';
-        case SDLK_QUOTE:
-            if( !(kmod_states & KMOD_SHIFT) )
-                return key;
-            else
-                return '\"';
-        case SDLK_MINUS:
-            if( !(kmod_states & KMOD_SHIFT) )
-                return key;
-            else
-                return '_';
-
-        case SDLK_EQUALS:
-            if( !(kmod_states & KMOD_SHIFT) )
-                return key;
-            else
-                return '+';
-
-        case SDLK_COMMA:
-            if( !(kmod_states & KMOD_SHIFT) )
-                return key;
-            else
-                return '<';
-
-        case SDLK_PERIOD:
-            if( !(kmod_states & KMOD_SHIFT) )
-                return key;
-            else
-                return '>';
-
-        case SDLK_LEFTBRACKET:
-            if( !(kmod_states & KMOD_SHIFT) )
-                return key;
-            else
-                return '{';
-
-        case SDLK_RIGHTBRACKET:
-            if( !(kmod_states & KMOD_SHIFT) )
-                return key;
-            else
-                return '}';
-
-        case SDLK_KP_DIVIDE:
-            return SDLK_COLON;
-
-        case SDLK_KP_MULTIPLY:
-            return SDLK_ASTERISK;
-
-        case SDLK_KP_MINUS:
-            return SDLK_MINUS;
-
-        case SDLK_KP_PLUS:
-            return SDLK_PLUS;
-
-        case SDLK_KP_ENTER:
-            return SDLK_RETURN;
-
-        case SDLK_KP_EQUALS:
-            return SDLK_EQUALS;
-
-        case SDLK_BACKSPACE:
-        case SDLK_DELETE:
-        case SDLK_SPACE:
-        case SDLK_RETURN:
-        case SDLK_LEFT:
-        case SDLK_RIGHT:
-        case SDLK_UP:
-        case SDLK_DOWN:
-        case SDLK_HOME:
-        case SDLK_END:
-            return key;
-
-        case SDLK_KP_PERIOD:
-            return (kmod_states & KMOD_NUM)?(SDLK_PERIOD):(SDLK_DELETE);
-
-        case SDLK_KP_0:
-        case SDLK_KP_1:
-        case SDLK_KP_2:
-        case SDLK_KP_3:
-        case SDLK_KP_4:
-        case SDLK_KP_5:
-        case SDLK_KP_6:
-        case SDLK_KP_7:
-        case SDLK_KP_8:
-        case SDLK_KP_9:
-            if(kmod_states & KMOD_NUM)
-            {
-                return key - 208;
-            }
-            else
-            {
-                switch(key)
-                {
-                case SDLK_KP_1:
-                    return SDLK_END;
-                case SDLK_KP_2:
-                    return SDLK_DOWN;
-                case SDLK_KP_4:
-                    return SDLK_LEFT;
-                case SDLK_KP_6:
-                    return SDLK_RIGHT;
-                case SDLK_KP_7:
-                    return SDLK_HOME;
-                case SDLK_KP_8:
-                    return SDLK_UP;
-                default:
-                    return 0;
-                }
-            }
-
-        default:
-            if((key <= SDLK_9) && (key >= SDLK_0))
-            {
-                if( !(kmod_states & KMOD_SHIFT) )
-                {
-                    return key;
-                }
-                else switch(key)
-                {
-                    case SDLK_1:
-                        return '!';
-
-                    case SDLK_2:
-                        return '@';
-
-                    case SDLK_3:
-                        return '#';
-
-                    case SDLK_4:
-                        return '$';
-
-                    case SDLK_5:
-                        return '%';
-
-                    case SDLK_6:
-                        return '^';
-
-                    case SDLK_7:
-                        return '&';
-
-                    case SDLK_8:
-                        return '*';
-
-                    case SDLK_9:
-                        return '(';
-
-                    case SDLK_0:
-                        return ')';
-                }
-            }
-            else if((key <= SDLK_z) && (key >= SDLK_a))
-            {
-                if( (kmod_states & KMOD_SHIFT) || (kmod_states & KMOD_CAPS) )
-                {
-                    return key - SDLK_a + 'A';
-                }
-                else
-                {
-                    return key - SDLK_a + 'a';
-                }
-            }
-            else
-            {
-                return 0;
-            }
-    }
     return 0;
 }
 
diff -r 8f7a8c35435f src/controls.h
--- a/src/controls.h	Tue Jan 06 15:37:56 2015 +0300
+++ b/src/controls.h	Wed Jan 07 19:03:17 2015 +0200
@@ -92,7 +92,7 @@
     int8_t   use_joy;
     int8_t   joy_number;
     int8_t   joy_rumble;
-    
+
     // Look axis settings.
     btScalar joy_look_x;                        // Raw look axis data!
     btScalar joy_look_y;                        // Raw look axis data!
@@ -100,7 +100,7 @@
     int8_t   joy_look_invert_y;
     btScalar joy_look_sensitivity;
     int16_t  joy_look_deadzone;
-    
+
     // Move axis settings.
     btScalar joy_move_x;                        // Raw move axis data!
     btScalar joy_move_y;                        // Raw move axis data!
@@ -123,7 +123,7 @@
 void Controls_RefreshStates();
 void Controls_InitGlobals();
 
-int  Controls_KeyConsoleFilter(int32_t key, int kmod_states);
+int  Controls_KeyConsoleFilter(char *text);
 
 #endif /* CONTROLS_H */
 
diff -r 8f7a8c35435f src/main_SDL.cpp
--- a/src/main_SDL.cpp	Tue Jan 06 15:37:56 2015 +0300
+++ b/src/main_SDL.cpp	Wed Jan 07 19:03:17 2015 +0200
@@ -898,6 +898,18 @@
                     Controls_Key((event.jbutton.button + JOY_BUTTON_MASK), event.jbutton.state);
                 break;
 
+            case SDL_TEXTINPUT:
+            case SDL_TEXTEDITING:
+                if(con_base.show && event.key.state)
+                {
+                    if (event.text.text != NULL)
+                    {
+                        Controls_KeyConsoleFilter(event.text.text);
+                        return;
+                    }
+                }
+                break;
+
             case SDL_KEYUP:
             case SDL_KEYDOWN:
                 if( (event.key.keysym.sym == SDLK_F4) &&
@@ -910,7 +922,22 @@
 
                 if(con_base.show && event.key.state)
                 {
-                    Con_Edit(Controls_KeyConsoleFilter(event.key.keysym.sym, event.key.keysym.mod));
+                    switch (event.key.keysym.sym)
+                    {
+                        case SDLK_RETURN:
+                        case SDLK_UP:
+                        case SDLK_DOWN:
+                        case SDLK_LEFT:
+                        case SDLK_RIGHT:
+                        case SDLK_HOME:
+                        case SDLK_END:
+                        case SDLK_BACKSPACE:
+                        case SDLK_DELETE:
+                            Con_Edit(event.key.keysym.sym);
+                            break;
+                        default:
+                            break;
+                    }
                     return;
                 }
                 else

Last edited by Tonttu; 07-01-15 at 17:20.
Tonttu is offline   Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



All times are GMT. The time now is 09:09.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Tomb Raider Forums is not owned or operated by CDE Entertainment Ltd.
Lara Croft and Tomb Raider are trademarks of CDE Entertainment Ltd.