track keyrepeat sources

master
lsalzman 2013-03-06 14:03:11 +02:00
parent e424caf174
commit 3758e50f84
6 changed files with 13 additions and 10 deletions

View File

@ -1240,7 +1240,7 @@ void g3d_render()
{
if(fieldmode != FIELDSHOW) SDL_StartTextInput();
else SDL_StopTextInput();
keyrepeat(fieldmode!=FIELDSHOW || editmode);
keyrepeat(fieldmode!=FIELDSHOW, KR_GUI);
}
mousebuttons = 0;

View File

@ -256,7 +256,7 @@ void inputcommand(char *init, char *action = NULL, char *prompt = NULL, char *fl
commandmillis = init ? totalmillis : -1;
if(commandmillis >= 0) SDL_StartTextInput();
else SDL_StopTextInput();
if(!editmode) keyrepeat(commandmillis >= 0);
keyrepeat(commandmillis >= 0, KR_CONSOLE);
copystring(commandbuf, init ? init : "");
DELETEA(commandaction);
DELETEA(commandprompt);

View File

@ -590,6 +590,10 @@ extern void getfps(int &fps, int &bestdiff, int &worstdiff);
extern void swapbuffers();
extern int getclockmillis();
enum { KR_CONSOLE = 1<<0, KR_EDITMODE = 1<<2, KR_GUI = 1<<2 };
extern void keyrepeat(bool on, int mask = ~0);
// menu
extern void menuprocess();
extern void addchange(const char *desc, int type);

View File

@ -390,11 +390,13 @@ void renderprogress(float bar, const char *text, GLuint tex, bool background)
swapbuffers();
}
bool grabinput = false, minimized = false, canrelativemouse = true, relativemouse = false, allowrepeat = false;
bool grabinput = false, minimized = false, canrelativemouse = true, relativemouse = false;
int allowrepeat = 0;
void keyrepeat(bool on)
void keyrepeat(bool on, int mask)
{
allowrepeat = on;
if(on) allowrepeat |= mask;
else allowrepeat &= ~mask;
}
void inputgrab(bool on)
@ -1071,11 +1073,9 @@ int main(int argc, char **argv)
ASSERT(dedicated <= 1);
game::initclient();
logoutf("init: video: mode");
logoutf("init: video");
setupscreen();
logoutf("init: video: misc");
keyrepeat(false);
SDL_ShowCursor(SDL_FALSE);
SDL_StopTextInput(); // workaround for spurious text-input events getting sent on first text input toggle?

View File

@ -139,7 +139,7 @@ void toggleedit(bool force)
}
cancelsel();
stoppaintblendmap();
keyrepeat(editmode);
keyrepeat(editmode, KR_EDITMODE);
editing = entediting = editmode;
if(!force) game::edittoggled(editmode);
}

View File

@ -215,7 +215,6 @@ extern void renderentring(const extentity &e, float radius, int axis = 0);
// main
extern void fatal(const char *s, ...) PRINTFARGS(1, 2);
extern void keyrepeat(bool on);
// rendertext
extern const matrix3x4 *textmatrix;