Oops, added missiong file

This commit is contained in:
pelya
2013-02-02 23:53:48 +02:00
parent a9ae3ff346
commit 8f57488043
2 changed files with 87 additions and 5 deletions

View File

@@ -40,14 +40,10 @@
#include "SDL_androidvideo.h"
#include "SDL_androidinput.h"
#include "jniwrapperstuff.h"
// #include "touchscreentheme.h" // Not used yet
#include "atan2i.h"
// TODO: this code is a HUGE MESS
#define MIN(X, Y) ((X) < (Y) ? (X) : (Y))
#define MAX(X, Y) ((X) > (Y) ? (X) : (Y))
enum { MAX_BUTTONS = SDL_ANDROID_SCREENKEYBOARD_BUTTON_NUM-1, MAX_BUTTONS_AUTOFIRE = 2, BUTTON_TEXT_INPUT = SDL_ANDROID_SCREENKEYBOARD_BUTTON_TEXT, BUTTON_ARROWS = MAX_BUTTONS } ; // Max amount of custom buttons
int SDL_ANDROID_isTouchscreenKeyboardUsed = 0;

View File

@@ -0,0 +1,86 @@
#ifndef _UNICODE_STUFF_H_
#define _UNICODE_STUFF_H_
#include "SDL_androidinput.h"
// I'm too lazy to move code into .c file
static inline int UnicodeToUtf8(int src, char * dest)
{
int len = 0;
if ( src <= 0x007f) {
*dest++ = (char)src;
len = 1;
} else if (src <= 0x07ff) {
*dest++ = (char)0xc0 | (src >> 6);
*dest++ = (char)0x80 | (src & 0x003f);
len = 2;
} else if (src == 0xFEFF) {
// nop -- zap the BOM
} else if (src >= 0xD800 && src <= 0xDFFF) {
// surrogates not supported
} else if (src <= 0xffff) {
*dest++ = (char)0xe0 | (src >> 12);
*dest++ = (char)0x80 | ((src >> 6) & 0x003f);
*dest++ = (char)0x80 | (src & 0x003f);
len = 3;
} else if (src <= 0xffff) {
*dest++ = (char)0xf0 | (src >> 18);
*dest++ = (char)0x80 | ((src >> 12) & 0x3f);
*dest++ = (char)0x80 | ((src >> 6) & 0x3f);
*dest++ = (char)0x80 | (src & 0x3f);
len = 4;
} else {
// out of Unicode range
}
*dest = 0;
return len;
}
static inline SDL_keysym asciiToKeysym(int ascii, int unicode)
{
SDL_keysym keysym;
keysym.scancode = ascii;
keysym.sym = ascii;
keysym.mod = KMOD_NONE;
keysym.unicode = 0;
#if SDL_VERSION_ATLEAST(1,3,0)
keysym.sym = SDL_GetScancodeFromKey(ascii);
#else
if ( SDL_TranslateUNICODE )
#endif
keysym.unicode = unicode;
return keysym;
}
static inline int checkShiftRequired( int * sym )
{
switch( *sym )
{
case '!': *sym = '1'; return 1;
case '@': *sym = '2'; return 1;
case '#': *sym = '3'; return 1;
case '$': *sym = '4'; return 1;
case '%': *sym = '5'; return 1;
case '^': *sym = '6'; return 1;
case '&': *sym = '7'; return 1;
case '*': *sym = '8'; return 1;
case '(': *sym = '9'; return 1;
case ')': *sym = '0'; return 1;
case '_': *sym = '-'; return 1;
case '+': *sym = '='; return 1;
case '|': *sym = '\\';return 1;
case '<': *sym = ','; return 1;
case '>': *sym = '.'; return 1;
case '?': *sym = '/'; return 1;
case ':': *sym = ';'; return 1;
case '"': *sym = '\'';return 1;
case '{': *sym = '['; return 1;
case '}': *sym = ']'; return 1;
case '~': *sym = '`'; return 1;
default: if( *sym >= 'A' && *sym <= 'Z' ) { *sym += 'a' - 'A'; return 1; };
}
return 0;
}
#endif