Support Unicode Keyboard Input
This commit is contained in:
parent
689aebf264
commit
144d10b682
@ -97,6 +97,8 @@ GFX2_GLOBAL dword Key;
|
|||||||
/// This is mostly used when the user enters text (filename, etc).
|
/// This is mostly used when the user enters text (filename, etc).
|
||||||
GFX2_GLOBAL dword Key_ANSI;
|
GFX2_GLOBAL dword Key_ANSI;
|
||||||
|
|
||||||
|
GFX2_GLOBAL dword Key_UNICODE;
|
||||||
|
|
||||||
// Keyboard modifiers
|
// Keyboard modifiers
|
||||||
// (Name conflict with windows.h)
|
// (Name conflict with windows.h)
|
||||||
#ifdef MOD_SHIFT
|
#ifdef MOD_SHIFT
|
||||||
|
|||||||
@ -383,6 +383,9 @@ int Handle_key_press(SDL_KeyboardEvent event)
|
|||||||
|
|
||||||
Key = Keysym_to_keycode(event.keysym);
|
Key = Keysym_to_keycode(event.keysym);
|
||||||
Key_ANSI = Keysym_to_ANSI(event.keysym);
|
Key_ANSI = Keysym_to_ANSI(event.keysym);
|
||||||
|
Key_UNICODE = event.keysym.unicode;
|
||||||
|
if (Key_UNICODE == 0)
|
||||||
|
Key_UNICODE = Key_ANSI;
|
||||||
switch(event.keysym.sym)
|
switch(event.keysym.sym)
|
||||||
{
|
{
|
||||||
case SDLK_RSHIFT:
|
case SDLK_RSHIFT:
|
||||||
@ -847,6 +850,7 @@ int Get_input(int sleep_time)
|
|||||||
// some user input.
|
// some user input.
|
||||||
Flush_update();
|
Flush_update();
|
||||||
Key_ANSI = 0;
|
Key_ANSI = 0;
|
||||||
|
Key_UNICODE = 0;
|
||||||
Key = 0;
|
Key = 0;
|
||||||
Mouse_moved=0;
|
Mouse_moved=0;
|
||||||
Input_new_mouse_X = Mouse_X;
|
Input_new_mouse_X = Mouse_X;
|
||||||
|
|||||||
@ -30,8 +30,8 @@
|
|||||||
/// This is the keyboard/mouse/joystick input polling function.
|
/// This is the keyboard/mouse/joystick input polling function.
|
||||||
/// Returns 1 if a significant changed occurred, such as a mouse button pressed
|
/// Returns 1 if a significant changed occurred, such as a mouse button pressed
|
||||||
/// or depressed, or a new keypress was in the keyboard buffer.
|
/// or depressed, or a new keypress was in the keyboard buffer.
|
||||||
/// The latest input variables are held in ::Key, ::Key_ANSI, ::Mouse_X, ::Mouse_Y, ::Mouse_K.
|
/// The latest input variables are held in ::Key, ::Key_ANSI, ::Key_UNICODE, ::Mouse_X, ::Mouse_Y, ::Mouse_K.
|
||||||
/// Note that ::Key and ::Key_ANSI are not persistent, they will be reset to 0
|
/// Note that ::Key, ::Key_ANSI and ::Key_UNICODE are not persistent, they will be reset to 0
|
||||||
/// on subsequent calls to ::Get_input().
|
/// on subsequent calls to ::Get_input().
|
||||||
int Get_input(int sleep_time);
|
int Get_input(int sleep_time);
|
||||||
|
|
||||||
|
|||||||
@ -633,7 +633,7 @@ word Keysym_to_ANSI(SDL_keysym keysym)
|
|||||||
// This part was removed from the MacOSX port, but I put it back for others
|
// This part was removed from the MacOSX port, but I put it back for others
|
||||||
// as on Linux and Windows, it's what allows editing a text line with the keys
|
// as on Linux and Windows, it's what allows editing a text line with the keys
|
||||||
// SDLK_LEFT, SDLK_RIGHT, SDLK_HOME, SDLK_END etc.
|
// SDLK_LEFT, SDLK_RIGHT, SDLK_HOME, SDLK_END etc.
|
||||||
#if !(defined(__macosx__) || defined(__FreeBSD__))
|
#if !defined(__macosx__)
|
||||||
if ( keysym.unicode == 0)
|
if ( keysym.unicode == 0)
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -722,6 +722,8 @@ word Keysym_to_ANSI(SDL_keysym keysym)
|
|||||||
return 'º'; // º
|
return 'º'; // º
|
||||||
case 0xC600:
|
case 0xC600:
|
||||||
return 'ã'; // ã
|
return 'ã'; // ã
|
||||||
|
case 0x20AC:
|
||||||
|
return '\x80'; // Euro sign is 20AC in unicode, 80 in CP1252
|
||||||
}
|
}
|
||||||
|
|
||||||
// Key entre 127 et 255
|
// Key entre 127 et 255
|
||||||
|
|||||||
@ -172,7 +172,7 @@ int Valid_character(word c, int input_type)
|
|||||||
#endif
|
#endif
|
||||||
int position;
|
int position;
|
||||||
|
|
||||||
if (c < ' ' || c > 255)
|
if (c < ' ')
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
for (position=0; position<(long)sizeof(forbidden_char); position++)
|
for (position=0; position<(long)sizeof(forbidden_char); position++)
|
||||||
@ -649,7 +649,7 @@ byte Readline_ex_unicode(word x_pos,word y_pos,char * str,word * str_unicode,byt
|
|||||||
do
|
do
|
||||||
{
|
{
|
||||||
Get_input(20);
|
Get_input(20);
|
||||||
input_key=Key_ANSI;
|
input_key = (str_unicode == NULL) ? Key_ANSI : Key_UNICODE;
|
||||||
if (Mouse_K)
|
if (Mouse_K)
|
||||||
input_key=SDLK_RETURN;
|
input_key=SDLK_RETURN;
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user