git-svn-id: https://svn.eduke32.com/eduke32@838 1a8010ca-5511-0410-912e-c29ae57300e0

This commit is contained in:
terminx 2008-07-04 02:13:48 +00:00
parent 275fdc8552
commit 9a29dae7b3
4 changed files with 188 additions and 193 deletions

View file

@ -67,7 +67,7 @@ void OSD_CaptureKey(int sc);
// handles keyboard input when capturing input. returns 0 if key was handled // handles keyboard input when capturing input. returns 0 if key was handled
// or the scancode if it should be handled by the game. // or the scancode if it should be handled by the game.
int OSD_HandleScanCode(int sc, int press); int OSD_HandleScanCode(int sc, int press);
int OSD_HandleChars(void); int OSD_HandleChars(char ch);
// handles the readjustment when screen resolution changes // handles the readjustment when screen resolution changes
void OSD_ResizeDisplay(int w,int h); void OSD_ResizeDisplay(int w,int h);

View file

@ -641,20 +641,14 @@ static int OSD_FindDiffPoint(const char *str1, const char *str2)
// be passed on to the game. // be passed on to the game.
// //
int OSD_HandleChars(void) int OSD_HandleChar(char ch)
{ {
int i,j; int i,j;
symbol_t *tabc = NULL; symbol_t *tabc = NULL;
static symbol_t *lastmatch = NULL; static symbol_t *lastmatch = NULL;
char ch;
if (!osdinited) return 1; if (!osdinited || !osdinput) return ch;
if (!osdinput)
return 1;
while ((ch = bgetchar()))
{
if (ch != 9) lastmatch = NULL; // tab if (ch != 9) lastmatch = NULL; // tab
if (ch == 1) // control a. jump to beginning of line if (ch == 1) // control a. jump to beginning of line
{ {
@ -670,7 +664,7 @@ int OSD_HandleChars(void)
} }
else if (ch == 8 || ch == 127) // control h, backspace else if (ch == 8 || ch == 127) // control h, backspace
{ {
if (!osdeditcursor || !osdeditlen) continue; if (!osdeditcursor || !osdeditlen) return 0;
if (!osdovertype) if (!osdovertype)
{ {
if (osdeditcursor < osdeditlen) if (osdeditcursor < osdeditlen)
@ -844,7 +838,7 @@ int OSD_HandleChars(void)
else if (ch >= 32) // text char else if (ch >= 32) // text char
{ {
if (!osdovertype && osdeditlen == EDITLENGTH) // buffer full, can't insert another char if (!osdovertype && osdeditlen == EDITLENGTH) // buffer full, can't insert another char
continue; return 0;
if (!osdovertype) if (!osdovertype)
{ {
@ -861,7 +855,6 @@ int OSD_HandleChars(void)
osdeditcursor++; osdeditcursor++;
if (osdeditcursor>osdeditwinend) osdeditwinstart++,osdeditwinend++; if (osdeditcursor>osdeditwinend) osdeditwinstart++,osdeditwinend++;
} }
}
return 0; return 0;
} }

View file

@ -1419,10 +1419,12 @@ int handleevents(void)
if (code != osdkey && ev.key.keysym.unicode != 0 && ev.key.type == SDL_KEYDOWN && if (code != osdkey && ev.key.keysym.unicode != 0 && ev.key.type == SDL_KEYDOWN &&
(ev.key.keysym.unicode & 0xff80) == 0 && (ev.key.keysym.unicode & 0xff80) == 0 &&
((keyasciififoend+1)&(KEYFIFOSIZ-1)) != keyasciififoplc) ((keyasciififoend+1)&(KEYFIFOSIZ-1)) != keyasciififoplc)
{
if (OSD_HandleChars(ev.key.keysym.unicode & 0x7f))
{ {
keyasciififo[keyasciififoend] = ev.key.keysym.unicode & 0x7f; keyasciififo[keyasciififoend] = ev.key.keysym.unicode & 0x7f;
keyasciififoend = ((keyasciififoend+1)&(KEYFIFOSIZ-1)); keyasciififoend = ((keyasciififoend+1)&(KEYFIFOSIZ-1));
OSD_HandleChars(); }
} }
// hook in the osd // hook in the osd

View file

@ -4125,9 +4125,9 @@ static LRESULT CALLBACK WndProcCallback(HWND hWnd, UINT uMsg, WPARAM wParam, LPA
if (((keyasciififoend+1)&(KEYFIFOSIZ-1)) == keyasciififoplc) return 0; if (((keyasciififoend+1)&(KEYFIFOSIZ-1)) == keyasciififoplc) return 0;
if ((keyasciififoend - keyasciififoplc) > 0) return 0; if ((keyasciififoend - keyasciififoplc) > 0) return 0;
if (Btolower(scantoasc[osdkey]) == Btolower((unsigned char)wParam)) return 0; if (Btolower(scantoasc[osdkey]) == Btolower((unsigned char)wParam)) return 0;
if (!OSD_HandleChar((unsigned char)wParam)) return 0;
keyasciififo[keyasciififoend] = (unsigned char)wParam; keyasciififo[keyasciififoend] = (unsigned char)wParam;
keyasciififoend = ((keyasciififoend+1)&(KEYFIFOSIZ-1)); keyasciififoend = ((keyasciififoend+1)&(KEYFIFOSIZ-1));
OSD_HandleChars();
//OSD_Printf("WM_CHAR %d, %d-%d\n",wParam,keyasciififoplc,keyasciififoend); //OSD_Printf("WM_CHAR %d, %d-%d\n",wParam,keyasciififoplc,keyasciififoend);
return 0; return 0;