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:
|
case SDL_KEYUP:
|
||||||
if (_repeatsKeys || event.key.repeat == 0)
|
if (_repeatsKeys || event.key.repeat == 0)
|
||||||
keypress(event.key.keysym.sym,
|
keypress(event.key.keysym.sym,
|
||||||
event.key.state == SDL_PRESSED,
|
event.key.state == SDL_PRESSED);
|
||||||
event.key.keysym.sym);
|
break;
|
||||||
|
case SDL_TEXTINPUT:
|
||||||
|
@autoreleasepool {
|
||||||
|
input(@(event.text.text));
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case SDL_MOUSEMOTION:
|
case SDL_MOUSEMOTION:
|
||||||
if (ignore) {
|
if (ignore) {
|
||||||
|
@ -257,7 +261,7 @@ VARP(minmillis, 0, 5, 1000);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
keypress(-event.button.button,
|
keypress(-event.button.button,
|
||||||
event.button.state != 0, 0);
|
event.button.state != 0);
|
||||||
lasttype = event.type;
|
lasttype = event.type;
|
||||||
lastbut = event.button.button;
|
lastbut = event.button.button;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -181,11 +181,11 @@ history(int n)
|
||||||
COMMAND(history, ARG_1INT)
|
COMMAND(history, ARG_1INT)
|
||||||
|
|
||||||
void
|
void
|
||||||
keypress(int code, bool isdown, int cooked)
|
keypress(int code, bool isDown)
|
||||||
{
|
{
|
||||||
if (saycommandon) // keystrokes go to commandline
|
// keystrokes go to commandline
|
||||||
{
|
if (saycommandon) {
|
||||||
if (isdown) {
|
if (isDown) {
|
||||||
switch (code) {
|
switch (code) {
|
||||||
case SDLK_RETURN:
|
case SDLK_RETURN:
|
||||||
break;
|
break;
|
||||||
|
@ -226,8 +226,6 @@ keypress(int code, bool isdown, int cooked)
|
||||||
|
|
||||||
default:
|
default:
|
||||||
resetcomplete();
|
resetcomplete();
|
||||||
if (cooked)
|
|
||||||
[commandbuf appendFormat:@"%c", cooked];
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (code == SDLK_RETURN) {
|
if (code == SDLK_RETURN) {
|
||||||
|
@ -259,20 +257,27 @@ keypress(int code, bool isdown, int cooked)
|
||||||
saycommand(NULL);
|
saycommand(NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (!menukey(code, isdown)) {
|
} else if (!menukey(code, isDown)) {
|
||||||
// keystrokes go to menu
|
// keystrokes go to menu
|
||||||
|
|
||||||
for (KeyMapping *mapping in keyMappings) {
|
for (KeyMapping *mapping in keyMappings) {
|
||||||
if (mapping.code == code) {
|
if (mapping.code == code) {
|
||||||
// keystrokes go to game, lookup in keymap and
|
// keystrokes go to game, lookup in keymap and
|
||||||
// execute
|
// execute
|
||||||
execute(mapping.action, isdown);
|
execute(mapping.action, isDown);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
input(OFString *text)
|
||||||
|
{
|
||||||
|
if (saycommandon)
|
||||||
|
[commandbuf appendString:text];
|
||||||
|
}
|
||||||
|
|
||||||
OFString *
|
OFString *
|
||||||
getcurcommand()
|
getcurcommand()
|
||||||
{
|
{
|
||||||
|
|
|
@ -17,7 +17,8 @@ extern OFString *getalias(OFString *name);
|
||||||
extern void writecfg();
|
extern void writecfg();
|
||||||
|
|
||||||
// console
|
// 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 renderconsole();
|
||||||
extern void conoutf(OFConstantString *format, ...);
|
extern void conoutf(OFConstantString *format, ...);
|
||||||
extern OFString *getcurcommand();
|
extern OFString *getcurcommand();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue