Use SDL_TextInputEvent for input
FossilOrigin-Name: 4c092023dc2a717a1cf2df148d04b1c35a0371f43fcfc8aa69e60093ee4a4be2
This commit is contained in:
parent
02d0afa3c7
commit
dae9d5553c
3 changed files with 22 additions and 12 deletions
10
src/Cube.mm
10
src/Cube.mm
|
@ -239,8 +239,12 @@ VARP(minmillis, 0, 5, 1000);
|
|||
case SDL_KEYUP:
|
||||
if (_repeatsKeys || event.key.repeat == 0)
|
||||
keypress(event.key.keysym.sym,
|
||||
event.key.state == SDL_PRESSED,
|
||||
event.key.keysym.sym);
|
||||
event.key.state == SDL_PRESSED);
|
||||
break;
|
||||
case SDL_TEXTINPUT:
|
||||
@autoreleasepool {
|
||||
input(@(event.text.text));
|
||||
}
|
||||
break;
|
||||
case SDL_MOUSEMOTION:
|
||||
if (ignore) {
|
||||
|
@ -257,7 +261,7 @@ VARP(minmillis, 0, 5, 1000);
|
|||
break;
|
||||
|
||||
keypress(-event.button.button,
|
||||
event.button.state != 0, 0);
|
||||
event.button.state != 0);
|
||||
lasttype = event.type;
|
||||
lastbut = event.button.button;
|
||||
break;
|
||||
|
|
|
@ -181,11 +181,11 @@ history(int n)
|
|||
COMMAND(history, ARG_1INT)
|
||||
|
||||
void
|
||||
keypress(int code, bool isdown, int cooked)
|
||||
keypress(int code, bool isDown)
|
||||
{
|
||||
if (saycommandon) // keystrokes go to commandline
|
||||
{
|
||||
if (isdown) {
|
||||
// keystrokes go to commandline
|
||||
if (saycommandon) {
|
||||
if (isDown) {
|
||||
switch (code) {
|
||||
case SDLK_RETURN:
|
||||
break;
|
||||
|
@ -226,8 +226,6 @@ keypress(int code, bool isdown, int cooked)
|
|||
|
||||
default:
|
||||
resetcomplete();
|
||||
if (cooked)
|
||||
[commandbuf appendFormat:@"%c", cooked];
|
||||
}
|
||||
} else {
|
||||
if (code == SDLK_RETURN) {
|
||||
|
@ -259,20 +257,27 @@ keypress(int code, bool isdown, int cooked)
|
|||
saycommand(NULL);
|
||||
}
|
||||
}
|
||||
} else if (!menukey(code, isdown)) {
|
||||
} else if (!menukey(code, isDown)) {
|
||||
// keystrokes go to menu
|
||||
|
||||
for (KeyMapping *mapping in keyMappings) {
|
||||
if (mapping.code == code) {
|
||||
// keystrokes go to game, lookup in keymap and
|
||||
// execute
|
||||
execute(mapping.action, isdown);
|
||||
execute(mapping.action, isDown);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
input(OFString *text)
|
||||
{
|
||||
if (saycommandon)
|
||||
[commandbuf appendString:text];
|
||||
}
|
||||
|
||||
OFString *
|
||||
getcurcommand()
|
||||
{
|
||||
|
|
|
@ -17,7 +17,8 @@ extern OFString *getalias(OFString *name);
|
|||
extern void writecfg();
|
||||
|
||||
// console
|
||||
extern void keypress(int code, bool isdown, int cooked);
|
||||
extern void keypress(int code, bool isDown);
|
||||
extern void input(OFString *text);
|
||||
extern void renderconsole();
|
||||
extern void conoutf(OFConstantString *format, ...);
|
||||
extern OFString *getcurcommand();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue