[SOLVED] How can i use certain keys with CEGUI?

For help with general CEGUI usage:
- Questions about the usage of CEGUI and its features, if not explained in the documentation.
- Problems with the CMAKE configuration or problems occuring during the build process/compilation.
- Errors or unexpected behaviour.

Moderators: CEGUI MVP, CEGUI Team

standtall007
Just popping in
Just popping in
Posts: 9
Joined: Tue Jul 04, 2017 16:18

[SOLVED] How can i use certain keys with CEGUI?

Postby standtall007 » Tue Feb 06, 2018 05:40

Hi i am using Win32 Winapi with opengl to use the CEGUI, and i have stumbled upon an problem right now:
I can use every letter key, number key and sign keys, but i cannot use my arrow keys or backspae and enter / return and delete keys...

i have made my own input class for the different keys and mouse buttons but they are literally just renamed from the standard VK_ keys.

i have made them in a typedef enum, and the reason i tell this is because i have heard so many complaints about not giving enough information, so i try my best :) i also use the injectChar and also for the key down and key up where i use my enum input variables (i am danish so i am not 100% fluent in english) I hope someone can help me with my dilemma, because i would really love to move on, i have had problems with my winapi <--> CEGUI implementation for quite a while now and this is all i need to fix now to get it up and running again,

Thank you very much for any help i can get.

Cheers,
Standtall007.
Last edited by standtall007 on Wed Feb 07, 2018 19:25, edited 1 time in total.

User avatar
Ident
CEGUI Team
Posts: 1998
Joined: Sat Oct 31, 2009 13:57
Location: Austria

Re: How can i use certain keys with CEGUI?

Postby Ident » Tue Feb 06, 2018 06:52

Why can't you do it like everyone does with every other input library? http://cegui.org.uk/wiki/GLFW_to_CEGUI_ ... se_Mapping
CrazyEddie: "I don't like GUIs"

standtall007
Just popping in
Just popping in
Posts: 9
Joined: Tue Jul 04, 2017 16:18

Re: How can i use certain keys with CEGUI?

Postby standtall007 » Tue Feb 06, 2018 13:22

I have done it like that, only with my own setup like VK_RETURN is the equivalents to my own NZ_ENTER just like that.
If it's not what you meant, then i cannot see how i am supposed to use other input tables when i strictly use WINAPI for windows.

standtall007
Just popping in
Just popping in
Posts: 9
Joined: Tue Jul 04, 2017 16:18

Re: How can i use certain keys with CEGUI?

Postby standtall007 » Tue Feb 06, 2018 13:30

this is what i have done like you mentioned:

Code: Select all

CEGUI::Key::Scan NZKeyToCEGUIKey(int key)
{
   using namespace CEGUI;
   switch (key)
   {
   case NZ_BACKSPACE:    return Key::Backspace;
   case NZ_TAB:          return Key::Tab;
   case NZ_ENTER:       return Key::Return;
   case NZ_PAUSE:        return Key::Pause;
   case NZ_ESCAPE:       return Key::Escape;
   case NZ_SPACEBAR:        return Key::Space;
   case NZ_COMMA:        return Key::Comma;
   case NZ_MINUS:        return Key::Minus;
   case NZ_PERIOD:       return Key::Period;
   case NZ_0:            return Key::Zero;
   case NZ_1:            return Key::One;
   case NZ_2:            return Key::Two;
   case NZ_3:            return Key::Three;
   case NZ_4:            return Key::Four;
   case NZ_5:            return Key::Five;
   case NZ_6:            return Key::Six;
   case NZ_7:            return Key::Seven;
   case NZ_8:            return Key::Eight;
   case NZ_9:           return Key::Nine;
   case NZ_A:            return Key::A;
   case NZ_B:            return Key::B;
   case NZ_C:            return Key::C;
   case NZ_D:            return Key::D;
   case NZ_E:            return Key::E;
   case NZ_F:            return Key::F;
   case NZ_G:            return Key::G;
   case NZ_H:            return Key::H;
   case NZ_I:            return Key::I;
   case NZ_J:            return Key::J;
   case NZ_K:            return Key::K;
   case NZ_L:            return Key::L;
   case NZ_M:            return Key::M;
   case NZ_N:            return Key::N;
   case NZ_O:            return Key::O;
   case NZ_P:            return Key::P;
   case NZ_Q:            return Key::Q;
   case NZ_R:            return Key::R;
   case NZ_S:            return Key::S;
   case NZ_T:            return Key::T;
   case NZ_U:            return Key::U;
   case NZ_V:            return Key::V;
   case NZ_W:            return Key::W;
   case NZ_X:            return Key::X;
   case NZ_Y:            return Key::Y;
   case NZ_Z:            return Key::Z;
   case NZ_DELETE:       return Key::Delete;
   case NZ_0_NUM:          return Key::Numpad0;
   case NZ_1_NUM:          return Key::Numpad1;
   case NZ_2_NUM:          return Key::Numpad2;
   case NZ_3_NUM:          return Key::Numpad3;
   case NZ_4_NUM:          return Key::Numpad4;
   case NZ_5_NUM:          return Key::Numpad5;
   case NZ_6_NUM:          return Key::Numpad6;
   case NZ_7_NUM:          return Key::Numpad7;
   case NZ_8_NUM:          return Key::Numpad8;
   case NZ_9_NUM:          return Key::Numpad9;
   case NZ_UP_ARROW:           return Key::ArrowUp;
   case NZ_DOWN_ARROW:         return Key::ArrowDown;
   case NZ_RIGHT_ARROW:        return Key::ArrowRight;
   case NZ_LEFT_ARROW:         return Key::ArrowLeft;
   case NZ_F1:           return Key::F1;
   case NZ_F2:           return Key::F2;
   case NZ_F3:           return Key::F3;
   case NZ_F4:           return Key::F4;
   case NZ_F5:           return Key::F5;
   case NZ_F6:           return Key::F6;
   case NZ_F7:           return Key::F7;
   case NZ_F8:           return Key::F8;
   case NZ_F9:           return Key::F9;
   case NZ_F10:          return Key::F10;
   case NZ_F11:          return Key::F11;
   case NZ_F12:          return Key::F12;
   case NZ_F13:          return Key::F13;
   case NZ_F14:          return Key::F14;
   case NZ_F15:          return Key::F15;
   default:                return Key::Unknown;
   }
}


And inside my input.h:

Code: Select all

typedef enum NZKeys
{
   NZ_BUTTON_LEFT = 0x01,
   NZ_BUTTON_RIGHT = 0x02,
   NZ_BUTTON_MIDDLE = 0x04,
   NZ_BUTTON_X1 = 0x05,
   NZ_BUTTON_X2 = 0x06,
   
   NZ_CANCEL = 0x03,
   NZ_BACKSPACE = 0x08,
   NZ_TAB = 0x09,
   NZ_CLEAR = 0x0C,
   NZ_ENTER = 0x0D,
   NZ_SHIFT = 0x10,
   NZ_CONTROL = 0x11,
   NZ_ALT = 0x12,
   NZ_PAUSE = 0x13,
   NZ_CAPS_LOCK = 0x14,
   NZ_ESCAPE = 0x1B,
   NZ_SPACEBAR = 0x20,
   NZ_PAGE_UP = 0x21,
   NZ_PAGE_DOWN = 0x22,
   NZ_END = 0x23,
   NZ_HOME = 0x24,
   NZ_LEFT_ARROW = 0x25,
   NZ_UP_ARROW = 0x26,
   NZ_RIGHT_ARROW = 0x27,
   NZ_DOWN_ARROW = 0x28,
   NZ_SELECT = 0x29,
   NZ_PRINT = 0x2A,
   NZ_EXECUTE = 0x2B,
   NZ_PRINT_SCREEN = 0x2C,
   NZ_INSERT = 0x2D,
   NZ_DELETE = 0x2E,
   NZ_HELP = 0x2F,
   
   NZ_0 = 0x30,
   NZ_1 = 0x31,
   NZ_2 = 0x32,
   NZ_3 = 0x33,
   NZ_4 = 0x34,
   NZ_5 = 0x35,
   NZ_6 = 0x36,
   NZ_7 = 0x37,
   NZ_8 = 0x38,
   NZ_9 = 0x39,

   NZ_A = 0x41,
   NZ_B = 0x42,
   NZ_C = 0x43,
   NZ_D = 0x44,
   NZ_E = 0x45,
   NZ_F = 0x46,
   NZ_G = 0x47,
   NZ_H = 0x48,
   NZ_I = 0x49,
   NZ_J = 0x4A,
   NZ_K = 0x4B,
   NZ_L = 0x4C,
   NZ_M = 0x4D,
   NZ_N = 0x4E,
   NZ_O = 0x4F,
   NZ_P = 0x50,
   NZ_Q = 0x51,
   NZ_R = 0x52,
   NZ_S = 0x53,
   NZ_T = 0x54,
   NZ_U = 0x55,
   NZ_V = 0x56,
   NZ_W = 0x57,
   NZ_X = 0x58,
   NZ_Y = 0x59,
   NZ_Z = 0x5A,
   
   NZ_L_WIN = 0x5B,
   NZ_R_WIN = 0x5C,
   NZ_APPS = 0x5D,
   NZ_SLEEP = 0x5F,

   NZ_0_NUM = 0x60,
   NZ_1_NUM = 0x61,
   NZ_2_NUM = 0x62,
   NZ_3_NUM = 0x63,
   NZ_4_NUM = 0x64,
   NZ_5_NUM = 0x65,
   NZ_6_NUM = 0x66,
   NZ_7_NUM = 0x67,
   NZ_8_NUM = 0x68,
   NZ_9_NUM = 0x69,
   
   NZ_MULTIPLY = 0x6A,
   NZ_ADD = 0x6B,
   NZ_SEPERATOR = 0x6C,
   NZ_SUBTRACT = 0x6D,
   NZ_DECIMAL = 0x6E,
   NZ_DIVIDE = 0x6F,
   
   NZ_F1 = 0x70,
   NZ_F2 = 0x71,
   NZ_F3 = 0x72,
   NZ_F4 = 0x73,
   NZ_F5 = 0x74,
   NZ_F6 = 0x75,
   NZ_F7 = 0x76,
   NZ_F8 = 0x77,
   NZ_F9 = 0x78,
   NZ_F10 = 0x79,
   NZ_F11 = 0x7A,
   NZ_F12 = 0x7B,
   NZ_F13 = 0x7C,
   NZ_F14 = 0x7D,
   NZ_F15 = 0x7E,
   NZ_F16 = 0x7F,
   NZ_F17 = 0x80,
   NZ_F18 = 0x81,
   NZ_F19 = 0x82,
   NZ_F20 = 0x83,
   NZ_F21 = 0x84,
   NZ_F22 = 0x85,
   NZ_F23 = 0x86,
   NZ_F24 = 0x87,
   
   NZ_NUM_LOCK = 0x90,
   NZ_SCR_LOCK = 0x91,
   NZ_LSHIFT = 0xA0,
   NZ_RSHIFT = 0xA1,
   NZ_LCTRL = 0xA2,
   NZ_RCTRL = 0xA3,
   NZ_LMENU = 0xA4,
   NZ_RMENU = 0xA5,
   
   NZ_BROWSER_BACK = 0xA6,
   NZ_BROWSER_FORWARD = 0xA7,
   NZ_BROWSER_REFRESH = 0xA8,
   NZ_BROWSER_STOP = 0xA9,
   NZ_BROWSER_SEARCH = 0xAA,
   NZ_BROWSER_FAVORITES = 0xAB,
   NZ_BROWSER_HOME = 0xAC,
   
   NZ_VOLUME_MUTE = 0xAD,
   NZ_VOLUME_DOWN = 0xAE,
   NZ_VOLUME_UP = 0xAF,
   NZ_MEDIA_NEXT_TRACK = 0xB0,
   NZ_MEDIA_PREV_TRACK = 0xB1,
   NZ_MEDIA_STOP = 0xB2,
   NZ_MEDIA_PLAY_PAUSE = 0xB3,
   
   NZ_LAUNCH_MAIL = 0xB4,
   NZ_LAUNCH_MEDIA_SELECT = 0xB5,
   NZ_LAUNCH_APP1 = 0xB6,
   NZ_LAUNCH_APP2 = 0xB7,
   
   NZ_PLUS = 0xBB,
   NZ_COMMA = 0xBC,
   NZ_MINUS = 0xBD,
   NZ_PERIOD = 0xBE
} NZKeys;

User avatar
Ident
CEGUI Team
Posts: 1998
Joined: Sat Oct 31, 2009 13:57
Location: Austria

Re: How can i use certain keys with CEGUI?

Postby Ident » Tue Feb 06, 2018 19:21

Ok then I didnt understand what you originally meant: What do you mean by "cant use"? How does it surface that you cant use it?
CrazyEddie: "I don't like GUIs"

standtall007
Just popping in
Just popping in
Posts: 9
Joined: Tue Jul 04, 2017 16:18

Re: How can i use certain keys with CEGUI?

Postby standtall007 » Tue Feb 06, 2018 21:37

I mean that when i press the backspace button in / on a spinner which only contains numbers, then it won't delete the last number.

User avatar
Ident
CEGUI Team
Posts: 1998
Joined: Sat Oct 31, 2009 13:57
Location: Austria

Re: How can i use certain keys with CEGUI?

Postby Ident » Wed Feb 07, 2018 07:01

Ok, you should have said that right away ;)

The way you phrased it it sounded like a general issue, like you can't set it up or you can't compile with it or whatever.

Did you set a breakpoint in the function and check if an enter or delete is actually injected as an enter or delete as expected?`
Do you call the time update on both cegui system and renderer?
Do you call injectKeyDown and injectKeyUp ?
CrazyEddie: "I don't like GUIs"

standtall007
Just popping in
Just popping in
Posts: 9
Joined: Tue Jul 04, 2017 16:18

Re: How can i use certain keys with CEGUI?

Postby standtall007 » Wed Feb 07, 2018 19:25

Hello again Ident, thanks to your suggestions i have managed to get the backspace working again :)

I apparently could not use the typedef enum, i had to stay with my old setup which was using defines instead...

But at least it's working again :D

Thank you so much for your help and time, i really appreciate it!

Best regards,
Standtall007.

User avatar
Ident
CEGUI Team
Posts: 1998
Joined: Sat Oct 31, 2009 13:57
Location: Austria

Re: [SOLVED] How can i use certain keys with CEGUI?

Postby Ident » Wed Feb 07, 2018 21:13

Could you tell us what was actually wrong, in detail? Thanks
CrazyEddie: "I don't like GUIs"

standtall007
Just popping in
Just popping in
Posts: 9
Joined: Tue Jul 04, 2017 16:18

Re: [SOLVED] How can i use certain keys with CEGUI?

Postby standtall007 » Wed Feb 07, 2018 21:24

Yeah sure, i have a header and source script for my 3d opengl scene, and i had originally made all keyboard input from the scene scripts, and when i tried to set the CEGUI's input methods inside of my main.cpp and even inside my wndProc() function, then it began to respond properly to the backspace button. I have had problems with my SDL2 connections inside of my WINAPI / Win32 application and i had to change everything that was SDL2 related, to use WINAPI's input handling, but at least it works now :) i hope this is enough clarification :)

i would like to point out the reason for using WINAPI instead of SDL2, and that is simply that i found that WINAPI works more fluently with my PC, whenever i use SDL2, then it lags a little even in an empty scene with no sprites or 3d models, hence the switch :)

Cheers.

EDIT: What i mean is that when i used my 3d scene to make the keybaord input connection(s) to CEGUI, then it wouldn't work properly, only with 0 - 9 of numbers.


Return to “Help”

Who is online

Users browsing this forum: Bing [Bot] and 8 guests