Page 1 of 1

keyboard / string problem

PostPosted: May 9, 2006 @ 12:06pm
by Nic-Gun
can edge accept keystroke from keyboard without colliding with the keyup, keydown, or keybuttonA etc? like using getch() or kbhit()?

and one more thing, my code below :

char name[2][3];

int i=0;
ClassEStd::StrCpy(name[i], "MAX");

i++;
ClassEStd::StrCpy(name[i], "KIN");

for (i=0; i<2; i++)
display->buffer.DrawFont(150, 70+(i*20), &display->internal, name[i], EFX_COLORKEY | EFO_VCENTER);

resulted in :

name[0] = "MAXKIN"
name[1] = "KIN"

while :

char name[2][3];

int i=0;
ClassEStd::StrCpy(name[i], "MAX");
display->buffer.DrawFont(150, 70+(i*20), &display->internal, name[i], EFX_COLORKEY | EFO_VCENTER);

i++;
ClassEStd::StrCpy(name[i], "KIN");
display->buffer.DrawFont(150, 70+(i*20), &display->internal, name[i], EFX_COLORKEY | EFO_VCENTER);

resulted in :

name[0] = "MAX"
name[1] = "KIN"

is there any problem with StrCpy()?

PostPosted: May 9, 2006 @ 12:47pm
by edge
You can catch al keyboard input, but incoming keys (from OnButtonDown()) can overlap with keymappings defined in EBUTTONLIST. This is something that can't be prevented.

I suggest saving a control type state, and change it to a keyboard type when a player needs to enter his name, or unlock code. When in keyboard input state, treat all keyboard characters (such as 'A' to 'Z', spacebar, backspace, etc.) as a keyboard key, and use the directional pad to browse through selections and default button (usually inside the d-pad) as a "confirm" key.

You can solve the string problem easily by reserving an extra character. Your strings take 4 characters (including the terminating zero character).