key repetitions are now allowed for text input
parent
a27ece921a
commit
f4ef58b9bf
|
@ -407,7 +407,6 @@ void View::DrawUi () {
|
||||||
|
|
||||||
SelectFont("console.ttf");
|
SelectFont("console.ttf");
|
||||||
SetFontJustification (Engine::FontJustificationLeft);
|
SetFontJustification (Engine::FontJustificationLeft);
|
||||||
GetController()->EnableTextinput(true);
|
|
||||||
|
|
||||||
ViewState current_view_state = GetViewState();
|
ViewState current_view_state = GetViewState();
|
||||||
|
|
||||||
|
|
|
@ -47,6 +47,14 @@ MouseButton convert_sdl_button (Uint8 button) {
|
||||||
int ControllerBase::OnInit (int argc, char* argv[]) {
|
int ControllerBase::OnInit (int argc, char* argv[]) {
|
||||||
LogDebug ("Controller Init");
|
LogDebug ("Controller Init");
|
||||||
|
|
||||||
|
// we want to use key repeat so that we can keep e.g. backspace pressed in a
|
||||||
|
// LineEdit
|
||||||
|
SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
|
||||||
|
|
||||||
|
// we also enable unicode processing all the time as it is only little
|
||||||
|
// overhead and simplifies text input a lot
|
||||||
|
SDL_EnableUNICODE(1);
|
||||||
|
|
||||||
// clear all bindings
|
// clear all bindings
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < BINDING_KEYS_LAST; i++) {
|
for (i = 0; i < BINDING_KEYS_LAST; i++) {
|
||||||
|
@ -142,17 +150,6 @@ void ControllerBase::ProcessEvents () {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** \brief Activates or deactivates unicode processing and key delays of the keyboard inputs */
|
|
||||||
void ControllerBase::EnableTextinput (bool textinput_state) {
|
|
||||||
if (textinput_state) {
|
|
||||||
SDL_EnableUNICODE(1);
|
|
||||||
SDL_EnableKeyRepeat(500, 50);
|
|
||||||
} else {
|
|
||||||
SDL_EnableUNICODE(-1);
|
|
||||||
SDL_EnableKeyRepeat(0, 100);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ControllerBase::IMGUIFinish () {
|
void ControllerBase::IMGUIFinish () {
|
||||||
if (GetButtonState(MouseButtonLeft) == false) {
|
if (GetButtonState(MouseButtonLeft) == false) {
|
||||||
uistate.activeitem = 0;
|
uistate.activeitem = 0;
|
||||||
|
@ -169,7 +166,6 @@ void ControllerBase::IMGUIFinish () {
|
||||||
|
|
||||||
/** \brief Keyboard processing */
|
/** \brief Keyboard processing */
|
||||||
bool ControllerBase::OnKeyDown (const SDL_keysym &keysym) {
|
bool ControllerBase::OnKeyDown (const SDL_keysym &keysym) {
|
||||||
mButtonStates.set(keysym.sym, true);
|
|
||||||
uistate.last_keysym = keysym.sym;
|
uistate.last_keysym = keysym.sym;
|
||||||
uistate.last_key = keysym.sym;
|
uistate.last_key = keysym.sym;
|
||||||
|
|
||||||
|
@ -179,25 +175,22 @@ bool ControllerBase::OnKeyDown (const SDL_keysym &keysym) {
|
||||||
// LogMessage ("Received key down of %s and unicode %d", convert_keycode(keysym.sym), keysym.unicode);
|
// LogMessage ("Received key down of %s and unicode %d", convert_keycode(keysym.sym), keysym.unicode);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mView->mOverlayManager.SendKeyDown (keysym))
|
if (mBindings[keysym.sym].size () != 0
|
||||||
return true;
|
&& GetButtonState(keysym.sym) == false) {
|
||||||
|
|
||||||
if (mBindings[keysym.sym].size () != 0) {
|
|
||||||
QueueCommand (mBindings[keysym.sym]);
|
QueueCommand (mBindings[keysym.sym]);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SetButtonState (keysym.sym, true);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** \brief Keyboard processing */
|
/** \brief Keyboard processing */
|
||||||
bool ControllerBase::OnKeyUp (const SDL_keysym &keysym) {
|
bool ControllerBase::OnKeyUp (const SDL_keysym &keysym) {
|
||||||
mButtonStates.set(keysym.sym, false);
|
SetButtonState (keysym.sym, false);
|
||||||
|
|
||||||
uistate.keypressed_set.insert (keysym.sym);
|
uistate.keypressed_set.insert (keysym.sym);
|
||||||
|
|
||||||
if (mView->mOverlayManager.SendKeyUp (keysym))
|
|
||||||
return true;
|
|
||||||
|
|
||||||
if (mBindings[keysym.sym].size () != 0) {
|
if (mBindings[keysym.sym].size () != 0) {
|
||||||
if (mBindings[keysym.sym][0] == '+') {
|
if (mBindings[keysym.sym][0] == '+') {
|
||||||
std::string upcommand = mBindings[keysym.sym];
|
std::string upcommand = mBindings[keysym.sym];
|
||||||
|
|
|
@ -76,9 +76,6 @@ class ControllerBase : public Module {
|
||||||
}
|
}
|
||||||
bool BindKey (int key, const char *command);
|
bool BindKey (int key, const char *command);
|
||||||
|
|
||||||
/** \brief Activates or deactivates unicode processing and key delays of the keyboard inputs */
|
|
||||||
void EnableTextinput (bool textinput_state);
|
|
||||||
|
|
||||||
void IMGUIPrepare () {
|
void IMGUIPrepare () {
|
||||||
uistate.hotitem = 0;
|
uistate.hotitem = 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -322,9 +322,6 @@ bool LineEdit (int id, int x, int y, std::string &text_value, const int &maxleng
|
||||||
DrawBlock (x, y, w, h);
|
DrawBlock (x, y, w, h);
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_EnableKeyRepeat(500, 50);
|
|
||||||
|
|
||||||
|
|
||||||
// Rendering of the current value
|
// Rendering of the current value
|
||||||
float width, height;
|
float width, height;
|
||||||
view = EngineGetView ();
|
view = EngineGetView ();
|
||||||
|
|
|
@ -14,15 +14,6 @@ static Variable Var_ConsoleTransparency ("consoletransparency", "0.2");
|
||||||
|
|
||||||
bool SimpleConsoleOverlay::OnKeyDown (const SDL_keysym &keysym) {
|
bool SimpleConsoleOverlay::OnKeyDown (const SDL_keysym &keysym) {
|
||||||
if (keysym.sym == SDLK_F8) {
|
if (keysym.sym == SDLK_F8) {
|
||||||
if (mActive) {
|
|
||||||
// We have to call SetActive() to actually
|
|
||||||
// activate the unicode processing of SDL
|
|
||||||
EngineGetController()->EnableTextinput(false);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
EngineGetController()->EnableTextinput(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,7 +23,6 @@ bool SimpleConsoleOverlay::OnKeyDown (const SDL_keysym &keysym) {
|
||||||
// check for input that requires actions
|
// check for input that requires actions
|
||||||
switch (keysym.sym) {
|
switch (keysym.sym) {
|
||||||
case SDLK_ESCAPE:
|
case SDLK_ESCAPE:
|
||||||
EngineGetController()->EnableTextinput(false);
|
|
||||||
return true;
|
return true;
|
||||||
break;
|
break;
|
||||||
case SDLK_BACKSPACE:
|
case SDLK_BACKSPACE:
|
||||||
|
|
Loading…
Reference in New Issue