From a05a5adccbbc8d658548c32dafbe7b165cc22a1c Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Tue, 29 Jan 2013 22:20:32 +0100 Subject: [PATCH] [DEV] change the multiple event on keyboard --- sources/ewol/renderer/ResourceManager.cpp | 16 +- sources/ewol/renderer/ResourceManager.h | 14 +- sources/ewol/renderer/os/eSystem.cpp | 54 ++- sources/ewol/renderer/os/eSystem.h | 6 +- sources/ewol/renderer/os/gui.X11.cpp | 344 ++++++++++-------- .../ewol/renderer/resources/ConfigFile.cpp | 2 +- sources/ewol/renderer/resources/ConfigFile.h | 2 +- sources/ewol/renderer/resources/MeshObj.cpp | 4 +- sources/ewol/renderer/resources/Program.cpp | 2 +- sources/ewol/renderer/resources/Program.h | 2 +- sources/ewol/renderer/resources/Resource.h | 4 +- sources/ewol/renderer/resources/Shader.cpp | 2 +- sources/ewol/renderer/resources/Shader.h | 2 +- .../ewol/renderer/resources/TexturedFont.cpp | 2 +- .../ewol/renderer/resources/TexturedFont.h | 2 +- sources/ewol/widget/Button.cpp | 2 +- sources/ewol/widget/Scene.cpp | 5 +- sources/ewol/widget/Widget.cpp | 1 + sources/ewol/widget/Widget.h | 18 + 19 files changed, 272 insertions(+), 212 deletions(-) diff --git a/sources/ewol/renderer/ResourceManager.cpp b/sources/ewol/renderer/ResourceManager.cpp index 79198088..6c7eee2b 100644 --- a/sources/ewol/renderer/ResourceManager.cpp +++ b/sources/ewol/renderer/ResourceManager.cpp @@ -149,7 +149,7 @@ void ewol::resource::ContextHasBeenDestroyed(void) // internal generic keeper ... -static ewol::Resource* LocalKeep(etk::UString& filename) +static ewol::Resource* LocalKeep(const etk::UString& filename) { EWOL_VERBOSE("KEEP (DEFAULT) : file : \"" << filename << "\""); for (int32_t iii=0; iii(LocalKeep(filename)); @@ -197,7 +197,7 @@ bool ewol::resource::Keep(etk::UString& filename, ewol::TexturedFont*& object) } -bool ewol::resource::Keep(etk::UString& filename, ewol::FontBase*& object) +bool ewol::resource::Keep(const etk::UString& filename, ewol::FontBase*& object) { EWOL_VERBOSE("KEEP : Font : file : \"" << filename << "\""); object = static_cast(LocalKeep(filename)); @@ -214,7 +214,7 @@ bool ewol::resource::Keep(etk::UString& filename, ewol::FontBase*& object) return true; } -bool ewol::resource::Keep(etk::UString& filename, ewol::Program*& object) +bool ewol::resource::Keep(const etk::UString& filename, ewol::Program*& object) { EWOL_VERBOSE("KEEP : Program : file : \"" << filename << "\""); object = static_cast(LocalKeep(filename)); @@ -231,7 +231,7 @@ bool ewol::resource::Keep(etk::UString& filename, ewol::Program*& object) return true; } -bool ewol::resource::Keep(etk::UString& filename, ewol::Shader*& object) +bool ewol::resource::Keep(const etk::UString& filename, ewol::Shader*& object) { EWOL_VERBOSE("KEEP : Simpleshader : file : \"" << filename << "\""); object = static_cast(LocalKeep(filename)); @@ -296,7 +296,7 @@ static int32_t nextP2(int32_t value) return val; } -bool ewol::resource::Keep(etk::UString& filename, ewol::TextureFile*& object, ivec2 size) +bool ewol::resource::Keep(const etk::UString& filename, ewol::TextureFile*& object, ivec2 size) { ivec2 size2(nextP2(size.x()), nextP2(size.y())); etk::UString TmpFilename = filename; @@ -320,7 +320,7 @@ bool ewol::resource::Keep(etk::UString& filename, ewol::TextureFile*& object, iv return true; } -bool ewol::resource::Keep(etk::UString& filename, ewol::MeshObj*& object) +bool ewol::resource::Keep(const etk::UString& filename, ewol::MeshObj*& object) { object = static_cast(LocalKeep(filename)); if (NULL != object) { @@ -348,7 +348,7 @@ bool ewol::resource::Keep(const etk::UString& accesMode, ewol::VirtualBufferObje return true; } -bool ewol::resource::Keep(etk::UString& filename, ewol::ConfigFile*& object) +bool ewol::resource::Keep(const etk::UString& filename, ewol::ConfigFile*& object) { EWOL_INFO("KEEP : SimpleConfig : file : \"" << filename << "\""); object = static_cast(LocalKeep(filename)); diff --git a/sources/ewol/renderer/ResourceManager.h b/sources/ewol/renderer/ResourceManager.h index f68b0ba2..2446c9f8 100644 --- a/sources/ewol/renderer/ResourceManager.h +++ b/sources/ewol/renderer/ResourceManager.h @@ -66,15 +66,15 @@ namespace ewol * @note when you call the Keep function, you must call the Realease function ==> otherwise the resources will never be freed * @note The resources with the same name are loaded only one time, a counter prevent multiple loading... */ - bool Keep(etk::UString& filename, ewol::TexturedFont*& object); - bool Keep(etk::UString& filename, ewol::FontBase*& object); - bool Keep(etk::UString& filename, ewol::Program*& object); - bool Keep(etk::UString& filename, ewol::Shader*& object); + bool Keep(const etk::UString& filename, ewol::TexturedFont*& object); + bool Keep(const etk::UString& filename, ewol::FontBase*& object); + bool Keep(const etk::UString& filename, ewol::Program*& object); + bool Keep(const etk::UString& filename, ewol::Shader*& object); bool Keep(ewol::Texture*& object); // no name needed here ... - bool Keep(etk::UString& filename, ewol::TextureFile*& object, ivec2 size); + bool Keep(const etk::UString& filename, ewol::TextureFile*& object, ivec2 size); bool Keep(const etk::UString& accesMode, ewol::VirtualBufferObject*& object); - bool Keep(etk::UString& filename, ewol::MeshObj*& object); - bool Keep(etk::UString& filename, ewol::ConfigFile*& object); + bool Keep(const etk::UString& filename, ewol::MeshObj*& object); + bool Keep(const etk::UString& filename, ewol::ConfigFile*& object); bool Keep(ewol::Colored3DObject*& object); /** diff --git a/sources/ewol/renderer/os/eSystem.cpp b/sources/ewol/renderer/os/eSystem.cpp index 7d7a67cf..acc978c6 100644 --- a/sources/ewol/renderer/os/eSystem.cpp +++ b/sources/ewol/renderer/os/eSystem.cpp @@ -88,6 +88,7 @@ class eSystemMessage { // generic dimentions vec2 dimention; // keyboard events : + bool repeateKey; //!< special flag for the repeating key on the PC interface bool stateIsDown; uniChar_t keyboardChar; ewol::keyEvent::keyboard_te keyboardMove; @@ -99,6 +100,7 @@ class eSystemMessage { inputType(ewol::keyEvent::typeUnknow), inputId(-1), dimention(0,0), + repeateKey(false), stateIsDown(false), keyboardChar(0), keyboardMove(ewol::keyEvent::keyboardUnknow) @@ -157,25 +159,33 @@ void ewolProcessEvents(void) // Get the current Focused Widget : ewol::Widget * tmpWidget = ewol::widgetManager::FocusGet(); if (NULL != tmpWidget) { - // check Widget shortcut - if (false==tmpWidget->OnEventShortCut(data.keyboardSpecial, - data.keyboardChar, - data.keyboardMove, - data.stateIsDown) ) { - // generate the direct event ... - if (data.TypeMessage == THREAD_KEYBORAD_KEY) { - if(true == data.stateIsDown) { - tmpWidget->OnEventKb(ewol::keyEvent::statusDown, data.keyboardChar); - } else { - tmpWidget->OnEventKb(ewol::keyEvent::statusUp, data.keyboardChar); - } - } else { // THREAD_KEYBORAD_MOVE - EWOL_DEBUG("THREAD_KEYBORAD_MOVE" << data.keyboardMove << " " << data.stateIsDown); - if(true == data.stateIsDown) { - tmpWidget->OnEventKbMove(ewol::keyEvent::statusDown, data.keyboardMove); - } else { - tmpWidget->OnEventKbMove(ewol::keyEvent::statusUp, data.keyboardMove); + // check if the widget allow repeating key events. + //EWOL_DEBUG("repeating test :" << data.repeateKey << " widget=" << tmpWidget->GetKeyboardRepeate() << " state=" << data.stateIsDown); + if( false==data.repeateKey + || ( true==data.repeateKey + && true==tmpWidget->GetKeyboardRepeate()) ) { + // check Widget shortcut + if (false==tmpWidget->OnEventShortCut(data.keyboardSpecial, + data.keyboardChar, + data.keyboardMove, + data.stateIsDown) ) { + // generate the direct event ... + if (data.TypeMessage == THREAD_KEYBORAD_KEY) { + if(true == data.stateIsDown) { + tmpWidget->OnEventKb(ewol::keyEvent::statusDown, data.keyboardChar); + } else { + tmpWidget->OnEventKb(ewol::keyEvent::statusUp, data.keyboardChar); + } + } else { // THREAD_KEYBORAD_MOVE + EWOL_DEBUG("THREAD_KEYBORAD_MOVE" << data.keyboardMove << " " << data.stateIsDown); + if(true == data.stateIsDown) { + tmpWidget->OnEventKbMove(ewol::keyEvent::statusDown, data.keyboardMove); + } else { + tmpWidget->OnEventKbMove(ewol::keyEvent::statusUp, data.keyboardMove); + } } + } else { + EWOL_DEBUG("remove Repeate key ..."); } } } @@ -391,7 +401,8 @@ void eSystem::SetMouseState(int pointerID, bool isDown, float x, float y ) void eSystem::SetKeyboard(ewol::SpecialKey& special, uniChar_t myChar, - bool isDown) + bool isDown, + bool isARepeateKey) { if (true == isGlobalSystemInit) { eSystemMessage data; @@ -399,13 +410,15 @@ void eSystem::SetKeyboard(ewol::SpecialKey& special, data.stateIsDown = isDown; data.keyboardChar = myChar; data.keyboardSpecial = special; + data.repeateKey = isARepeateKey; l_msgSystem.Post(data); } } void eSystem::SetKeyboardMove(ewol::SpecialKey& special, ewol::keyEvent::keyboard_te move, - bool isDown) + bool isDown, + bool isARepeateKey) { if (true == isGlobalSystemInit) { eSystemMessage data; @@ -413,6 +426,7 @@ void eSystem::SetKeyboardMove(ewol::SpecialKey& special, data.stateIsDown = isDown; data.keyboardMove = move; data.keyboardSpecial = special; + data.repeateKey = isARepeateKey; l_msgSystem.Post(data); } } diff --git a/sources/ewol/renderer/os/eSystem.h b/sources/ewol/renderer/os/eSystem.h index 5df9f0c8..806ac91b 100644 --- a/sources/ewol/renderer/os/eSystem.h +++ b/sources/ewol/renderer/os/eSystem.h @@ -34,10 +34,12 @@ namespace eSystem void SetKeyboard(ewol::SpecialKey& special, uniChar_t myChar, - bool isDown); + bool isDown, + bool isARepeateKey=false); void SetKeyboardMove(ewol::SpecialKey& special, ewol::keyEvent::keyboard_te move, - bool isDown); + bool isDown, + bool isARepeateKey=false); void ClipBoardArrive(ewol::clipBoard::clipboardListe_te clipboardID); diff --git a/sources/ewol/renderer/os/gui.X11.cpp b/sources/ewol/renderer/os/gui.X11.cpp index c61a0370..acc9389a 100644 --- a/sources/ewol/renderer/os/gui.X11.cpp +++ b/sources/ewol/renderer/os/gui.X11.cpp @@ -855,172 +855,194 @@ void X11_Run(void) break; case KeyPress: case KeyRelease: - // filter repeate key : - if( event.type == KeyRelease - && XEventsQueued(m_display, QueuedAfterReading)) { - XEvent nev; - XPeekEvent(m_display, &nev); - if( nev.type == KeyPress - && nev.xkey.time == event.xkey.time - && nev.xkey.keycode == event.xkey.keycode) { - // Key was not actually released - // remove next event too ... - XNextEvent(m_display, &nev); - break; - } - } - X11_INFO("X11 event : " << event.type << " = \"KeyPress/KeyRelease\" "); { - X11_DEBUG("eventKey : " << event.xkey.keycode << " state : " << event.xkey.state); - if (event.xkey.state & (1<<0) ) { - //EWOL_DEBUG(" Special Key : SHIFT"); - guiKeyBoardMode.shift = true; - } else { - guiKeyBoardMode.shift = false; + bool thisIsAReapeateKey = false; + // filter repeate key : + if( event.type == KeyRelease + && XEventsQueued(m_display, QueuedAfterReading)) { + XEvent nev; + XPeekEvent(m_display, &nev); + if( nev.type == KeyPress + && nev.xkey.time == event.xkey.time + && nev.xkey.keycode == event.xkey.keycode) { + // Key was not actually released + // remove next event too ... + + //This remove repeate key + XNextEvent(m_display, &nev); + //break; + + thisIsAReapeateKey = true; + } } - if (event.xkey.state & (1<<1) ) { - //EWOL_DEBUG(" Special Key : CAPS_LOCK"); - guiKeyBoardMode.capLock = true; - } else { - guiKeyBoardMode.capLock = false; - } - if (event.xkey.state & (1<<2) ) { - //EWOL_DEBUG(" Special Key : Ctrl"); - guiKeyBoardMode.ctrl = true; - } else { - guiKeyBoardMode.ctrl = false; - } - if (event.xkey.state & (1<<3) ) { - //EWOL_DEBUG(" Special Key : Alt"); - guiKeyBoardMode.alt = true; - } else { - guiKeyBoardMode.alt = false; - } - if (event.xkey.state & (1<<4) ) { - //EWOL_DEBUG(" Special Key : VER_num"); - guiKeyBoardMode.numLock = true; - } else { - guiKeyBoardMode.numLock = false; - } - if (event.xkey.state & (1<<5) ) { - EWOL_DEBUG(" Special Key : MOD"); - } - if (event.xkey.state & (1<<6) ) { - //EWOL_DEBUG(" Special Key : META"); - guiKeyBoardMode.meta = true; - } else { - guiKeyBoardMode.meta = false; - } - if (event.xkey.state & (1<<7) ) { - //EWOL_DEBUG(" Special Key : ALT_GR"); - guiKeyBoardMode.altGr = true; - } else { - guiKeyBoardMode.altGr = false; - } - bool find = true; - ewol::keyEvent::keyboard_te keyInput; - switch (event.xkey.keycode) { - //case 80: // keypad - case 111: keyInput = ewol::keyEvent::keyboardUp; break; - //case 83: // keypad - case 113: keyInput = ewol::keyEvent::keyboardLeft; break; - //case 85: // keypad - case 114: keyInput = ewol::keyEvent::keyboardRight; break; - //case 88: // keypad - case 116: keyInput = ewol::keyEvent::keyboardDown; break; - //case 81: // keypad - case 112: keyInput = ewol::keyEvent::keyboardPageUp; break; - //case 89: // keypad - case 117: keyInput = ewol::keyEvent::keyboardPageDown; break; - //case 79: // keypad - case 110: keyInput = ewol::keyEvent::keyboardStart; break; - //case 87: // keypad - case 115: keyInput = ewol::keyEvent::keyboardEnd; break; - case 78: keyInput = ewol::keyEvent::keyboardStopDefil; break; - case 127: keyInput = ewol::keyEvent::keyboardWait; break; - //case 90: // keypad - case 118: - keyInput = ewol::keyEvent::keyboardInsert; - if(event.type == KeyRelease) { - if (true == guiKeyBoardMode.insert) { - guiKeyBoardMode.insert = false; + X11_INFO("X11 event : " << event.type << " = \"KeyPress/KeyRelease\" "); + { + X11_DEBUG("eventKey : " << event.xkey.keycode << " state : " << event.xkey.state); + if (event.xkey.state & (1<<0) ) { + //EWOL_DEBUG(" Special Key : SHIFT"); + guiKeyBoardMode.shift = true; + } else { + guiKeyBoardMode.shift = false; + } + if (event.xkey.state & (1<<1) ) { + //EWOL_DEBUG(" Special Key : CAPS_LOCK"); + guiKeyBoardMode.capLock = true; + } else { + guiKeyBoardMode.capLock = false; + } + if (event.xkey.state & (1<<2) ) { + //EWOL_DEBUG(" Special Key : Ctrl"); + guiKeyBoardMode.ctrl = true; + } else { + guiKeyBoardMode.ctrl = false; + } + if (event.xkey.state & (1<<3) ) { + //EWOL_DEBUG(" Special Key : Alt"); + guiKeyBoardMode.alt = true; + } else { + guiKeyBoardMode.alt = false; + } + if (event.xkey.state & (1<<4) ) { + //EWOL_DEBUG(" Special Key : VER_num"); + guiKeyBoardMode.numLock = true; + } else { + guiKeyBoardMode.numLock = false; + } + if (event.xkey.state & (1<<5) ) { + EWOL_DEBUG(" Special Key : MOD"); + } + if (event.xkey.state & (1<<6) ) { + //EWOL_DEBUG(" Special Key : META"); + guiKeyBoardMode.meta = true; + } else { + guiKeyBoardMode.meta = false; + } + if (event.xkey.state & (1<<7) ) { + //EWOL_DEBUG(" Special Key : ALT_GR"); + guiKeyBoardMode.altGr = true; + } else { + guiKeyBoardMode.altGr = false; + } + bool find = true; + ewol::keyEvent::keyboard_te keyInput; + switch (event.xkey.keycode) { + //case 80: // keypad + case 111: keyInput = ewol::keyEvent::keyboardUp; break; + //case 83: // keypad + case 113: keyInput = ewol::keyEvent::keyboardLeft; break; + //case 85: // keypad + case 114: keyInput = ewol::keyEvent::keyboardRight; break; + //case 88: // keypad + case 116: keyInput = ewol::keyEvent::keyboardDown; break; + //case 81: // keypad + case 112: keyInput = ewol::keyEvent::keyboardPageUp; break; + //case 89: // keypad + case 117: keyInput = ewol::keyEvent::keyboardPageDown; break; + //case 79: // keypad + case 110: keyInput = ewol::keyEvent::keyboardStart; break; + //case 87: // keypad + case 115: keyInput = ewol::keyEvent::keyboardEnd; break; + case 78: keyInput = ewol::keyEvent::keyboardStopDefil; break; + case 127: keyInput = ewol::keyEvent::keyboardWait; break; + //case 90: // keypad + case 118: + keyInput = ewol::keyEvent::keyboardInsert; + if(event.type == KeyRelease) { + if (true == guiKeyBoardMode.insert) { + guiKeyBoardMode.insert = false; + } else { + guiKeyBoardMode.insert = true; + } + } + break; + //case 84: keyInput = ewol::keyEvent::keyboardCenter; break; // Keypad + case 67: keyInput = ewol::keyEvent::keyboardF1; break; + case 68: keyInput = ewol::keyEvent::keyboardF2; break; + case 69: keyInput = ewol::keyEvent::keyboardF3; break; + case 70: keyInput = ewol::keyEvent::keyboardF4; break; + case 71: keyInput = ewol::keyEvent::keyboardF5; break; + case 72: keyInput = ewol::keyEvent::keyboardF6; break; + case 73: keyInput = ewol::keyEvent::keyboardF7; break; + case 74: keyInput = ewol::keyEvent::keyboardF8; break; + case 75: keyInput = ewol::keyEvent::keyboardF9; break; + case 76: keyInput = ewol::keyEvent::keyboardF10; break; + case 95: keyInput = ewol::keyEvent::keyboardF11; break; + case 96: keyInput = ewol::keyEvent::keyboardF12; break; + case 66: keyInput = ewol::keyEvent::keyboardCapLock; guiKeyBoardMode.capLock = (event.type == KeyPress) ? true : false; break; + case 50: keyInput = ewol::keyEvent::keyboardShiftLeft; guiKeyBoardMode.shift = (event.type == KeyPress) ? true : false; break; + case 62: keyInput = ewol::keyEvent::keyboardShiftRight; guiKeyBoardMode.shift = (event.type == KeyPress) ? true : false; break; + case 37: keyInput = ewol::keyEvent::keyboardCtrlLeft; guiKeyBoardMode.ctrl = (event.type == KeyPress) ? true : false; break; + case 105: keyInput = ewol::keyEvent::keyboardCtrlRight; guiKeyBoardMode.ctrl = (event.type == KeyPress) ? true : false; break; + case 133: keyInput = ewol::keyEvent::keyboardMetaLeft; guiKeyBoardMode.meta = (event.type == KeyPress) ? true : false; break; + case 134: keyInput = ewol::keyEvent::keyboardMetaRight; guiKeyBoardMode.meta = (event.type == KeyPress) ? true : false; break; + case 64: keyInput = ewol::keyEvent::keyboardAlt; guiKeyBoardMode.alt = (event.type == KeyPress) ? true : false; break; + case 108: keyInput = ewol::keyEvent::keyboardAltGr; guiKeyBoardMode.altGr = (event.type == KeyPress) ? true : false; break; + case 135: keyInput = ewol::keyEvent::keyboardContextMenu; break; + case 77: keyInput = ewol::keyEvent::keyboardNumLock; guiKeyBoardMode.numLock = (event.type == KeyPress) ? true : false; break; + case 91: // Suppr on keypad + find = false; + if(guiKeyBoardMode.numLock==true){ + eSystem::SetKeyboard(guiKeyBoardMode, '.', (event.type==KeyPress), thisIsAReapeateKey); + if (true==thisIsAReapeateKey) { + eSystem::SetKeyboard(guiKeyBoardMode, '.', !(event.type==KeyPress), thisIsAReapeateKey); + } } else { - guiKeyBoardMode.insert = true; + eSystem::SetKeyboard(guiKeyBoardMode, 0x7F, (event.type==KeyPress), thisIsAReapeateKey); + if (true==thisIsAReapeateKey) { + eSystem::SetKeyboard(guiKeyBoardMode, 0x7F, !(event.type==KeyPress), thisIsAReapeateKey); + } } + break; + case 23: // special case for TAB + find = false; + eSystem::SetKeyboard(guiKeyBoardMode, 0x09, (event.type==KeyPress), thisIsAReapeateKey); + if (true==thisIsAReapeateKey) { + eSystem::SetKeyboard(guiKeyBoardMode, 0x09, !(event.type==KeyPress), thisIsAReapeateKey); + } + break; + default: + find = false; + { + char buf[11]; + //EWOL_DEBUG("Keycode: " << event.xkey.keycode); + // change keystate for simple reson of the ctrl error... + int32_t keyStateSave = event.xkey.state; + if (event.xkey.state & (1<<2) ) { + event.xkey.state = event.xkey.state & 0xFFFFFFFB; + } + KeySym keysym; + XComposeStatus status; + int count = XLookupString(&event.xkey, buf, 10, &keysym, &status); + // retreave real keystate + event.xkey.state = keyStateSave; + buf[count] = '\0'; + // Replace \r error ... + if (buf[0] == '\r') { + buf[0] = '\n'; + buf[1] = '\0'; + } + if (count>0) { + // transform it in unicode + uniChar_t tmpChar = 0; + unicode::convertIsoToUnicode(unicode::EDN_CHARSET_ISO_8859_15, buf[0], tmpChar); + //EWOL_INFO("event Key : " << event.xkey.keycode << " char=\"" << buf << "\"'len=" << strlen(buf) << " unicode=" << unicodeValue); + eSystem::SetKeyboard(guiKeyBoardMode, tmpChar, (event.type==KeyPress), thisIsAReapeateKey); + if (true==thisIsAReapeateKey) { + eSystem::SetKeyboard(guiKeyBoardMode, tmpChar, !(event.type==KeyPress), thisIsAReapeateKey); + } + } else { + EWOL_WARNING("Unknow event Key : " << event.xkey.keycode); + } + } + break; + } + if (true == find) { + //EWOL_DEBUG("eventKey Move type : " << GetCharTypeMoveEvent(keyInput) ); + eSystem::SetKeyboardMove(guiKeyBoardMode, keyInput, (event.type==KeyPress), thisIsAReapeateKey); + if (true==thisIsAReapeateKey) { + eSystem::SetKeyboardMove(guiKeyBoardMode, keyInput, !(event.type==KeyPress), thisIsAReapeateKey); } - break; - //case 84: keyInput = ewol::keyEvent::keyboardCenter; break; // Keypad - case 67: keyInput = ewol::keyEvent::keyboardF1; break; - case 68: keyInput = ewol::keyEvent::keyboardF2; break; - case 69: keyInput = ewol::keyEvent::keyboardF3; break; - case 70: keyInput = ewol::keyEvent::keyboardF4; break; - case 71: keyInput = ewol::keyEvent::keyboardF5; break; - case 72: keyInput = ewol::keyEvent::keyboardF6; break; - case 73: keyInput = ewol::keyEvent::keyboardF7; break; - case 74: keyInput = ewol::keyEvent::keyboardF8; break; - case 75: keyInput = ewol::keyEvent::keyboardF9; break; - case 76: keyInput = ewol::keyEvent::keyboardF10; break; - case 95: keyInput = ewol::keyEvent::keyboardF11; break; - case 96: keyInput = ewol::keyEvent::keyboardF12; break; - case 66: keyInput = ewol::keyEvent::keyboardCapLock; guiKeyBoardMode.capLock = (event.type == KeyPress) ? true : false; break; - case 50: keyInput = ewol::keyEvent::keyboardShiftLeft; guiKeyBoardMode.shift = (event.type == KeyPress) ? true : false; break; - case 62: keyInput = ewol::keyEvent::keyboardShiftRight; guiKeyBoardMode.shift = (event.type == KeyPress) ? true : false; break; - case 37: keyInput = ewol::keyEvent::keyboardCtrlLeft; guiKeyBoardMode.ctrl = (event.type == KeyPress) ? true : false; break; - case 105: keyInput = ewol::keyEvent::keyboardCtrlRight; guiKeyBoardMode.ctrl = (event.type == KeyPress) ? true : false; break; - case 133: keyInput = ewol::keyEvent::keyboardMetaLeft; guiKeyBoardMode.meta = (event.type == KeyPress) ? true : false; break; - case 134: keyInput = ewol::keyEvent::keyboardMetaRight; guiKeyBoardMode.meta = (event.type == KeyPress) ? true : false; break; - case 64: keyInput = ewol::keyEvent::keyboardAlt; guiKeyBoardMode.alt = (event.type == KeyPress) ? true : false; break; - case 108: keyInput = ewol::keyEvent::keyboardAltGr; guiKeyBoardMode.altGr = (event.type == KeyPress) ? true : false; break; - case 135: keyInput = ewol::keyEvent::keyboardContextMenu; break; - case 77: keyInput = ewol::keyEvent::keyboardNumLock; guiKeyBoardMode.numLock = (event.type == KeyPress) ? true : false; break; - case 91: // Suppr on keypad - find = false; - if(guiKeyBoardMode.numLock==true){ - eSystem::SetKeyboard(guiKeyBoardMode, '.', (event.type==KeyPress)); - } else { - eSystem::SetKeyboard(guiKeyBoardMode, 0x7F, (event.type==KeyPress)); - } - break; - case 23: // special case for TAB - find = false; - eSystem::SetKeyboard(guiKeyBoardMode, 0x09, (event.type==KeyPress)); - break; - default: - find = false; - { - char buf[11]; - //EWOL_DEBUG("Keycode: " << event.xkey.keycode); - // change keystate for simple reson of the ctrl error... - int32_t keyStateSave = event.xkey.state; - if (event.xkey.state & (1<<2) ) { - event.xkey.state = event.xkey.state & 0xFFFFFFFB; - } - KeySym keysym; - XComposeStatus status; - int count = XLookupString(&event.xkey, buf, 10, &keysym, &status); - // retreave real keystate - event.xkey.state = keyStateSave; - buf[count] = '\0'; - // Replace \r error ... - if (buf[0] == '\r') { - buf[0] = '\n'; - buf[1] = '\0'; - } - if (count>0) { - // transform it in unicode - uniChar_t tmpChar = 0; - unicode::convertIsoToUnicode(unicode::EDN_CHARSET_ISO_8859_15, buf[0], tmpChar); - //EWOL_INFO("event Key : " << event.xkey.keycode << " char=\"" << buf << "\"'len=" << strlen(buf) << " unicode=" << unicodeValue); - eSystem::SetKeyboard(guiKeyBoardMode, tmpChar, (event.type==KeyPress)); - } else { - EWOL_WARNING("Unknow event Key : " << event.xkey.keycode); - } - } - break; - } - if (true == find) { - //EWOL_DEBUG("eventKey Move type : " << GetCharTypeMoveEvent(keyInput) ); - eSystem::SetKeyboardMove(guiKeyBoardMode, keyInput, (event.type==KeyPress)); + } } } break; diff --git a/sources/ewol/renderer/resources/ConfigFile.cpp b/sources/ewol/renderer/resources/ConfigFile.cpp index 78c6ba0a..00248dad 100644 --- a/sources/ewol/renderer/resources/ConfigFile.cpp +++ b/sources/ewol/renderer/resources/ConfigFile.cpp @@ -23,7 +23,7 @@ void ewol::SimpleConfigElement::Parse(etk::UString value) -ewol::ConfigFile::ConfigFile(etk::UString& filename): +ewol::ConfigFile::ConfigFile(const etk::UString& filename): ewol::Resource(filename) { EWOL_DEBUG("SFP : load \"" << filename << "\""); diff --git a/sources/ewol/renderer/resources/ConfigFile.h b/sources/ewol/renderer/resources/ConfigFile.h index 7d1480a4..21b165ed 100644 --- a/sources/ewol/renderer/resources/ConfigFile.h +++ b/sources/ewol/renderer/resources/ConfigFile.h @@ -42,7 +42,7 @@ namespace ewol etk::Vector m_list; etk::UString m_errorString; public: - ConfigFile(etk::UString& filename); + ConfigFile(const etk::UString& filename); virtual ~ConfigFile(void); const char* GetType(void) { return "ewol::SimpleConfigFile"; }; void Reload(void); diff --git a/sources/ewol/renderer/resources/MeshObj.cpp b/sources/ewol/renderer/resources/MeshObj.cpp index f2c2f4aa..ade10e5f 100644 --- a/sources/ewol/renderer/resources/MeshObj.cpp +++ b/sources/ewol/renderer/resources/MeshObj.cpp @@ -47,7 +47,7 @@ ewol::MeshObj::MeshObj(etk::UString _fileName) : if (inputDataLine[1]=='n') { // Vertice normal : vn 0.000000 0.000000 -1.000000 vec3 vertex(0,0,0); - sscanf(&inputDataLine[3], "%f %f %f", &vertex.m_floats[0], &vertex.m_floats[1], &vertex.m_floats[1] ); + sscanf(&inputDataLine[3], "%f %f %f", &vertex.m_floats[0], &vertex.m_floats[1], &vertex.m_floats[2] ); normals.PushBack(vertex); } else if (inputDataLine[1]=='t') { // Texture position : vt 0.748573 0.750412 @@ -57,7 +57,7 @@ ewol::MeshObj::MeshObj(etk::UString _fileName) : } else { // Vertice position : v 1.000000 -1.000000 -1.000000 vec3 vertex(0,0,0); - sscanf(&inputDataLine[2], "%f %f %f", &vertex.m_floats[0], &vertex.m_floats[1], &vertex.m_floats[1] ); + sscanf(&inputDataLine[2], "%f %f %f", &vertex.m_floats[0], &vertex.m_floats[1], &vertex.m_floats[2] ); vertices.PushBack(vertex); } } else if (inputDataLine[0]=='f') { diff --git a/sources/ewol/renderer/resources/Program.cpp b/sources/ewol/renderer/resources/Program.cpp index bd28d7d3..0dc30890 100644 --- a/sources/ewol/renderer/resources/Program.cpp +++ b/sources/ewol/renderer/resources/Program.cpp @@ -15,7 +15,7 @@ //#define LOCAL_DEBUG EWOL_VERBOSE #define LOCAL_DEBUG EWOL_DEBUG -ewol::Program::Program(etk::UString& filename) : +ewol::Program::Program(const etk::UString& filename) : ewol::Resource(filename), m_exist(false), m_program(0), diff --git a/sources/ewol/renderer/resources/Program.h b/sources/ewol/renderer/resources/Program.h index e6ad141c..b1893584 100644 --- a/sources/ewol/renderer/resources/Program.h +++ b/sources/ewol/renderer/resources/Program.h @@ -57,7 +57,7 @@ namespace ewol * @brief Contructor of an opengl Program. * @param[in] filename Standard file name format. see @ref etk::FSNode */ - Program(etk::UString& filename); + Program(const etk::UString& filename); /** * @brief Destructor, remove the current Program. */ diff --git a/sources/ewol/renderer/resources/Resource.h b/sources/ewol/renderer/resources/Resource.h index 9c6fad70..28b47f94 100644 --- a/sources/ewol/renderer/resources/Resource.h +++ b/sources/ewol/renderer/resources/Resource.h @@ -41,7 +41,7 @@ namespace ewol m_uniqueId = valBase; valBase++; }; - Resource(etk::UString& filename) : + Resource(const etk::UString& filename) : m_name(filename), m_counter(1), m_resourceLevel(MAX_RESOURCE_LEVEL-1) @@ -50,7 +50,7 @@ namespace ewol valBase++; }; virtual ~Resource(void) { }; - virtual bool HasName(etk::UString& fileName) + virtual bool HasName(const etk::UString& fileName) { EWOL_VERBOSE("G : check : " << fileName << " ?= " << m_name << " = " << (fileName==m_name) ); return fileName==m_name; diff --git a/sources/ewol/renderer/resources/Shader.cpp b/sources/ewol/renderer/resources/Shader.cpp index ca6f934f..1cd2e44f 100644 --- a/sources/ewol/renderer/resources/Shader.cpp +++ b/sources/ewol/renderer/resources/Shader.cpp @@ -13,7 +13,7 @@ -ewol::Shader::Shader(etk::UString& filename): +ewol::Shader::Shader(const etk::UString& filename): ewol::Resource(filename), m_exist(false), m_fileData(NULL), diff --git a/sources/ewol/renderer/resources/Shader.h b/sources/ewol/renderer/resources/Shader.h index 3d5c147d..9c9a03e3 100644 --- a/sources/ewol/renderer/resources/Shader.h +++ b/sources/ewol/renderer/resources/Shader.h @@ -31,7 +31,7 @@ namespace ewol * @brief Contructor of an opengl Shader * @param[in] filename Standard file name format. see @ref etk::FSNode */ - Shader(etk::UString& filename); + Shader(const etk::UString& filename); /** * @brief Destructor, remove the current Shader */ diff --git a/sources/ewol/renderer/resources/TexturedFont.cpp b/sources/ewol/renderer/resources/TexturedFont.cpp index bdc96eb2..e8001767 100644 --- a/sources/ewol/renderer/resources/TexturedFont.cpp +++ b/sources/ewol/renderer/resources/TexturedFont.cpp @@ -274,7 +274,7 @@ ewol::TexturedFont::~TexturedFont(void) } -bool ewol::TexturedFont::HasName(etk::UString& fileName) +bool ewol::TexturedFont::HasName(const etk::UString& fileName) { etk::UString tmpName = m_name; tmpName += ":"; diff --git a/sources/ewol/renderer/resources/TexturedFont.h b/sources/ewol/renderer/resources/TexturedFont.h index 9a006786..6158fe81 100644 --- a/sources/ewol/renderer/resources/TexturedFont.h +++ b/sources/ewol/renderer/resources/TexturedFont.h @@ -44,7 +44,7 @@ namespace ewol public: TexturedFont(etk::UString fontName); ~TexturedFont(void); - virtual bool HasName(etk::UString& fileName); + virtual bool HasName(const etk::UString& fileName); const char* GetType(void) { return "ewol::TexturedFont"; }; int32_t getFontSize(void) { return m_size; }; /** diff --git a/sources/ewol/widget/Button.cpp b/sources/ewol/widget/Button.cpp index 4799f763..a5bce343 100644 --- a/sources/ewol/widget/Button.cpp +++ b/sources/ewol/widget/Button.cpp @@ -209,7 +209,7 @@ void widget::Button::OnRegenerateDisplay(void) tmpTextOrigin += vec3(padding.x(), padding.y(), 0); localSize -= ivec2(2*padding.x(), 2*padding.y()); - tmpTextOrigin.setY(tmpTextOrigin.x()+ (m_minSize.y()-2*padding.y()) - minSize.y()); + tmpTextOrigin.setY(tmpTextOrigin.y()+ (m_minSize.y()-2*padding.y()) - minSize.y()); vec2 textPos(tmpTextOrigin.x(), tmpTextOrigin.y()); diff --git a/sources/ewol/widget/Scene.cpp b/sources/ewol/widget/Scene.cpp index 3eb72e7e..2680e1f2 100644 --- a/sources/ewol/widget/Scene.cpp +++ b/sources/ewol/widget/Scene.cpp @@ -207,8 +207,11 @@ widget::Scene::Scene(btDynamicsWorld* gameEngine) : { // this permit to display direct element ... ewol::resource::Keep(m_directDrawObject); - + // Remove repeating event from keyboard... + SetKeyboardRepeate(false); + // Can get the keybord events... SetCanHaveFocus(true); + // This widget change in time... PeriodicCallSet(true); m_zoom = 1.0/1000.0; m_ratioTime = 1.0f; diff --git a/sources/ewol/widget/Widget.cpp b/sources/ewol/widget/Widget.cpp index 5b464fe7..97a78b87 100644 --- a/sources/ewol/widget/Widget.cpp +++ b/sources/ewol/widget/Widget.cpp @@ -22,6 +22,7 @@ ewol::Widget::Widget(void) : m_userMaxSize(-1,-1) { + m_allowRepeateKeyboardEvent = true; m_limitMouseEvent = 3; m_needRegenerateDisplay = true; m_origin.setValue(0,0); diff --git a/sources/ewol/widget/Widget.h b/sources/ewol/widget/Widget.h index 7c49c89c..34d3d4bf 100644 --- a/sources/ewol/widget/Widget.h +++ b/sources/ewol/widget/Widget.h @@ -271,6 +271,24 @@ namespace ewol { */ void SetMouseLimit(int32_t numberState) { m_limitMouseEvent = numberState; }; + // ---------------------------------------------------------------------------------------------------------------- + // -- keyboard event properties Area + // ---------------------------------------------------------------------------------------------------------------- + private: + bool m_allowRepeateKeyboardEvent; //!< This remove the repeating keybord event due to the constant pressing key. + public: + /** + * @brief Get the keyboard repeating event supporting. + * @return true : the event can be repeated. + * @return false : the event must not be repeated. + */ + bool GetKeyboardRepeate(void) { return m_allowRepeateKeyboardEvent; }; + /** + * @brief Set the keyboard repeating event supporting. + * @param[in] state The repeating status (true: enable, false disable). + */ + void SetKeyboardRepeate(bool state) { m_allowRepeateKeyboardEvent = state; }; + // ---------------------------------------------------------------------------------------------------------------- // -- Periodic call Area // ----------------------------------------------------------------------------------------------------------------