On-screen keyboard visible size - buttons are smaller but touch area is still big
This commit is contained in:
@@ -60,6 +60,7 @@ class Globals {
|
||||
public static boolean UseAccelerometerAsArrowKeys = false;
|
||||
public static boolean UseTouchscreenKeyboard = true;
|
||||
public static int TouchscreenKeyboardSize = 0;
|
||||
public static int TouchscreenKeyboardDrawSize = 1;
|
||||
public static int TouchscreenKeyboardTheme = 2;
|
||||
public static int TouchscreenKeyboardTransparency = 2;
|
||||
public static int AccelerometerSensitivity = 2;
|
||||
|
||||
@@ -142,6 +142,7 @@ class Settings
|
||||
for(int i = 0; i < Globals.OptionalDataDownload.length; i++)
|
||||
out.writeBoolean(Globals.OptionalDataDownload[i]);
|
||||
out.writeBoolean(Globals.BrokenLibCMessageShown);
|
||||
out.writeInt(Globals.TouchscreenKeyboardDrawSize);
|
||||
|
||||
out.close();
|
||||
settingsLoaded = true;
|
||||
@@ -277,6 +278,7 @@ class Settings
|
||||
for(int i = 0; i < Globals.OptionalDataDownload.length; i++)
|
||||
Globals.OptionalDataDownload[i] = settingsFile.readBoolean();
|
||||
Globals.BrokenLibCMessageShown = settingsFile.readBoolean();
|
||||
Globals.TouchscreenKeyboardDrawSize = settingsFile.readInt();
|
||||
|
||||
settingsLoaded = true;
|
||||
|
||||
@@ -604,6 +606,7 @@ class Settings
|
||||
{
|
||||
new ScreenKeyboardThemeConfig(),
|
||||
new ScreenKeyboardSizeConfig(),
|
||||
new ScreenKeyboardDrawSizeConfig(),
|
||||
new ScreenKeyboardTransparencyConfig(),
|
||||
new RemapScreenKbConfig(),
|
||||
new CustomizeScreenKbLayout(),
|
||||
@@ -994,6 +997,44 @@ class Settings
|
||||
}
|
||||
}
|
||||
|
||||
static class ScreenKeyboardDrawSizeConfig extends Menu
|
||||
{
|
||||
String title(final MainActivity p)
|
||||
{
|
||||
return p.getResources().getString(R.string.controls_screenkb_drawsize);
|
||||
}
|
||||
void run (final MainActivity p)
|
||||
{
|
||||
final CharSequence[] items = { p.getResources().getString(R.string.controls_screenkb_large),
|
||||
p.getResources().getString(R.string.controls_screenkb_medium),
|
||||
p.getResources().getString(R.string.controls_screenkb_small),
|
||||
p.getResources().getString(R.string.controls_screenkb_tiny) };
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
||||
builder.setTitle(p.getResources().getString(R.string.controls_screenkb_drawsize));
|
||||
builder.setSingleChoiceItems(items, Globals.TouchscreenKeyboardDrawSize, new DialogInterface.OnClickListener()
|
||||
{
|
||||
public void onClick(DialogInterface dialog, int item)
|
||||
{
|
||||
Globals.TouchscreenKeyboardDrawSize = item;
|
||||
|
||||
dialog.dismiss();
|
||||
goBack(p);
|
||||
}
|
||||
});
|
||||
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
|
||||
{
|
||||
public void onCancel(DialogInterface dialog)
|
||||
{
|
||||
goBack(p);
|
||||
}
|
||||
});
|
||||
AlertDialog alert = builder.create();
|
||||
alert.setOwnerActivity(p);
|
||||
alert.show();
|
||||
}
|
||||
}
|
||||
|
||||
static class ScreenKeyboardThemeConfig extends Menu
|
||||
{
|
||||
String title(final MainActivity p)
|
||||
@@ -2358,6 +2399,7 @@ class Settings
|
||||
{
|
||||
nativeSetTouchscreenKeyboardUsed();
|
||||
nativeSetupScreenKeyboard( Globals.TouchscreenKeyboardSize,
|
||||
Globals.TouchscreenKeyboardDrawSize,
|
||||
Globals.TouchscreenKeyboardTheme,
|
||||
Globals.AppTouchscreenKeyboardKeysAmountAutoFire,
|
||||
Globals.TouchscreenKeyboardTransparency );
|
||||
@@ -2446,7 +2488,7 @@ class Settings
|
||||
private static native void nativeSetSmoothVideo();
|
||||
private static native void nativeSetCompatibilityHacks();
|
||||
private static native void nativeSetVideoMultithreaded();
|
||||
private static native void nativeSetupScreenKeyboard(int size, int theme, int nbuttonsAutoFire, int transparency);
|
||||
private static native void nativeSetupScreenKeyboard(int size, int drawsize, int theme, int nbuttonsAutoFire, int transparency);
|
||||
private static native void nativeSetupScreenKeyboardButtons(byte[] img);
|
||||
private static native void nativeInitKeymap();
|
||||
private static native int nativeGetKeymapKey(int key);
|
||||
|
||||
@@ -133,4 +133,5 @@
|
||||
<string name="display_size_small">Klein (Telefon)</string>
|
||||
<string name="display_size_tiny">Uberklein (Xperia Mini)</string>
|
||||
<string name="show_more_options">Weitere Optionen</string>
|
||||
<string name="controls_screenkb_drawsize">Größe der Schaltfläche Bilder</string>
|
||||
</resources>
|
||||
|
||||
@@ -133,4 +133,5 @@
|
||||
<string name="display_size_small">Pieni (puhelin)</string>
|
||||
<string name="display_size_tiny">Tiny (Xperia Mini)</string>
|
||||
<string name="show_more_options">Näytä enemmän vaihtoehtoja</string>
|
||||
<string name="controls_screenkb_drawsize">Koko painike kuvia</string>
|
||||
</resources>
|
||||
|
||||
@@ -136,4 +136,5 @@
|
||||
<string name="display_size_small">Petit (téléphone)</string>
|
||||
<string name="display_size_tiny">Très petit (Xperia Mini)</string>
|
||||
<string name="show_more_options">Afficher plus d\u0026#39;options</string>
|
||||
<string name="controls_screenkb_drawsize">Taille des images de bouton</string>
|
||||
</resources>
|
||||
|
||||
@@ -128,4 +128,5 @@
|
||||
<string name="show_more_options">Показать больше параметров</string>
|
||||
<string name="broken_libc_title">Обнаружена бракованная прошивка</string>
|
||||
<string name="broken_libc_text">Ваше устройство содержит дефективные системные библиотеки, данное приложение скорее всего не будет работать. Пожалуйста, установите обновление, либо установите неофициальную прошивку, либо скопируйте /system/lib/libc.so с другого устройства (только для специалистов!)</string>
|
||||
<string name="controls_screenkb_drawsize">Размер изображения кнопок</string>
|
||||
</resources>
|
||||
|
||||
@@ -126,4 +126,5 @@
|
||||
<string name="display_size_small">Маленький (телефон)</string>
|
||||
<string name="display_size_tiny">Крихiтний (Xperia Mini)</string>
|
||||
<string name="show_more_options">Показати більше параметрів</string>
|
||||
<string name="controls_screenkb_drawsize">Розмір зображення кнопок</string>
|
||||
</resources>
|
||||
|
||||
@@ -39,6 +39,7 @@
|
||||
<string name="controls_accelnav">Accelerometer</string>
|
||||
|
||||
<string name="controls_screenkb_size">On-screen keyboard size</string>
|
||||
<string name="controls_screenkb_drawsize">Size of button images</string>
|
||||
<string name="controls_screenkb_large">Large</string>
|
||||
<string name="controls_screenkb_medium">Medium</string>
|
||||
<string name="controls_screenkb_small">Small</string>
|
||||
|
||||
@@ -27,8 +27,8 @@ StartupMenuButtonTimeout=3000
|
||||
HiddenMenuOptions=''
|
||||
FirstStartMenuOptions=''
|
||||
MultiABI=n
|
||||
AppVersionCode=3509
|
||||
AppVersionName="0.3.5.09"
|
||||
AppVersionCode=35009
|
||||
AppVersionName="0.3.5.0.09"
|
||||
CompiledLibraries="tremor ogg"
|
||||
CustomBuildScript=n
|
||||
AppCflags='-finline-functions -O2 -DTREMOR=1 -DBUILD_TYPE=LINUX32 -DTARGET_LNX=1 -Werror=strict-aliasing -Werror=cast-align -Werror=pointer-arith -Werror=address'
|
||||
|
||||
@@ -1807,7 +1807,6 @@ JAVA_EXPORT_NAME(Settings_nativeSetScreenKbKeyLayout) (JNIEnv* env, jobject thiz
|
||||
{
|
||||
SDL_Rect rect = {x1, y1, x2-x1, y2-y1};
|
||||
int key = -1;
|
||||
//__android_log_print(ANDROID_LOG_INFO, "libSDL", "nativeSetScreenKbKeyLayout: %d %d %d %d", (int)rect.x, (int)rect.y, (int)rect.w, (int)rect.h);
|
||||
if( keynum == 0 )
|
||||
key = SDL_ANDROID_SCREENKEYBOARD_BUTTON_DPAD;
|
||||
if( keynum == 1 )
|
||||
|
||||
@@ -53,9 +53,11 @@ static int touchscreenKeyboardTheme = 0;
|
||||
static int touchscreenKeyboardShown = 1;
|
||||
static int AutoFireButtonsNum = 0;
|
||||
static int buttonsize = 1;
|
||||
static int buttonDrawSize = 1;
|
||||
static int transparency = 128;
|
||||
|
||||
static SDL_Rect arrows, buttons[MAX_BUTTONS], buttonsAutoFireRect[MAX_BUTTONS_AUTOFIRE];
|
||||
static SDL_Rect arrowsDraw, buttonsDraw[MAX_BUTTONS];
|
||||
static SDLKey buttonKeysyms[MAX_BUTTONS] = {
|
||||
SDL_KEY(SDL_KEY_VAL(SDL_ANDROID_SCREENKB_KEYCODE_0)),
|
||||
SDL_KEY(SDL_KEY_VAL(SDL_ANDROID_SCREENKB_KEYCODE_1)),
|
||||
@@ -197,17 +199,17 @@ int SDL_ANDROID_drawTouchscreenKeyboard()
|
||||
|
||||
beginDrawingTex();
|
||||
if( blendFactor == 0 )
|
||||
drawCharTex( &arrowImages[0], NULL, &arrows, 255, 255, 255, transparency );
|
||||
drawCharTex( &arrowImages[0], NULL, &arrowsDraw, 255, 255, 255, transparency );
|
||||
else
|
||||
{
|
||||
if( SDL_GetKeyboardState(NULL)[SDL_KEY(LEFT)] )
|
||||
drawCharTex( &arrowImages[1], NULL, &arrows, 255, 255, 255, transparency / blendFactor );
|
||||
drawCharTex( &arrowImages[1], NULL, &arrowsDraw, 255, 255, 255, transparency / blendFactor );
|
||||
if( SDL_GetKeyboardState(NULL)[SDL_KEY(RIGHT)] )
|
||||
drawCharTex( &arrowImages[2], NULL, &arrows, 255, 255, 255, transparency / blendFactor );
|
||||
drawCharTex( &arrowImages[2], NULL, &arrowsDraw, 255, 255, 255, transparency / blendFactor );
|
||||
if( SDL_GetKeyboardState(NULL)[SDL_KEY(UP)] )
|
||||
drawCharTex( &arrowImages[3], NULL, &arrows, 255, 255, 255, transparency / blendFactor );
|
||||
drawCharTex( &arrowImages[3], NULL, &arrowsDraw, 255, 255, 255, transparency / blendFactor );
|
||||
if( SDL_GetKeyboardState(NULL)[SDL_KEY(DOWN)] )
|
||||
drawCharTex( &arrowImages[4], NULL, &arrows, 255, 255, 255, transparency / blendFactor );
|
||||
drawCharTex( &arrowImages[4], NULL, &arrowsDraw, 255, 255, 255, transparency / blendFactor );
|
||||
}
|
||||
|
||||
for( i = 0; i < MAX_BUTTONS; i++ )
|
||||
@@ -234,12 +236,12 @@ int SDL_ANDROID_drawTouchscreenKeyboard()
|
||||
( ButtonAutoFireX[i*2] > 0 || ButtonAutoFireX[i*2+1] > 0 ) )
|
||||
{
|
||||
int pos1src = buttonImages[i*2+1].w / 2 - ButtonAutoFireX[i*2];
|
||||
int pos1dst = buttons[i].w * pos1src / buttonImages[i*2+1].w;
|
||||
int pos1dst = buttonsDraw[i].w * pos1src / buttonImages[i*2+1].w;
|
||||
int pos2src = buttonImages[i*2+1].w - ( buttonImages[i*2+1].w / 2 - ButtonAutoFireX[i*2+1] );
|
||||
int pos2dst = buttons[i].w * pos2src / buttonImages[i*2+1].w;
|
||||
int pos2dst = buttonsDraw[i].w * pos2src / buttonImages[i*2+1].w;
|
||||
|
||||
SDL_Rect autoFireCrop = { 0, 0, pos1src, buttonImages[i*2+1].h };
|
||||
SDL_Rect autoFireDest = buttons[i];
|
||||
SDL_Rect autoFireDest = buttonsDraw[i];
|
||||
autoFireDest.w = pos1dst;
|
||||
|
||||
drawCharTex( &buttonImages[i*2+1],
|
||||
@@ -247,15 +249,15 @@ int SDL_ANDROID_drawTouchscreenKeyboard()
|
||||
|
||||
autoFireCrop.x = pos2src;
|
||||
autoFireCrop.w = buttonImages[i*2+1].w - pos2src;
|
||||
autoFireDest.x = buttons[i].x + pos2dst;
|
||||
autoFireDest.w = buttons[i].w - pos2dst;
|
||||
autoFireDest.x = buttonsDraw[i].x + pos2dst;
|
||||
autoFireDest.w = buttonsDraw[i].w - pos2dst;
|
||||
|
||||
drawCharTex( &buttonImages[i*2+1],
|
||||
&autoFireCrop, &autoFireDest, 255, 255, 255, transparency );
|
||||
|
||||
autoFireCrop.x = pos1src;
|
||||
autoFireCrop.w = pos2src - pos1src;
|
||||
autoFireDest.x = buttons[i].x + pos1dst;
|
||||
autoFireDest.x = buttonsDraw[i].x + pos1dst;
|
||||
autoFireDest.w = pos2dst - pos1dst;
|
||||
|
||||
drawCharTex( &buttonAutoFireImages[i*2+1],
|
||||
@@ -265,7 +267,7 @@ int SDL_ANDROID_drawTouchscreenKeyboard()
|
||||
{
|
||||
drawCharTex( ( i < AutoFireButtonsNum && ButtonAutoFire[i] ) ? &buttonAutoFireImages[i*2] :
|
||||
&buttonImages[ SDL_GetKeyboardState(NULL)[buttonKeysyms[i]] ? (i * 2 + 1) : (i * 2) ],
|
||||
NULL, &buttons[i], 255, 255, 255, transparency );
|
||||
NULL, &buttonsDraw[i], 255, 255, 255, transparency );
|
||||
}
|
||||
}
|
||||
endDrawingTex();
|
||||
@@ -552,18 +554,36 @@ int SDL_ANDROID_processTouchscreenKeyboard(int x, int y, int action, int pointer
|
||||
return processed;
|
||||
};
|
||||
|
||||
void shrinkButtonRect(SDL_Rect s, SDL_Rect * d)
|
||||
{
|
||||
int i;
|
||||
|
||||
if( !buttonDrawSize )
|
||||
{
|
||||
memcpy(d, &s, sizeof(s));
|
||||
return;
|
||||
}
|
||||
|
||||
d->w = s.w * 2 / (buttonDrawSize+2);
|
||||
d->h = s.h * 2 / (buttonDrawSize+2);
|
||||
d->x = s.x + s.w / 2 - d->w / 2;
|
||||
d->y = s.y + s.h / 2 - d->h / 2;
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
JAVA_EXPORT_NAME(Settings_nativeSetupScreenKeyboard) ( JNIEnv* env, jobject thiz, jint size, jint theme, jint nbuttonsAutoFire, jint _transparency )
|
||||
JAVA_EXPORT_NAME(Settings_nativeSetupScreenKeyboard) ( JNIEnv* env, jobject thiz, jint size, jint drawsize, jint theme, jint nbuttonsAutoFire, jint _transparency )
|
||||
{
|
||||
int i, ii;
|
||||
int nbuttons1row, nbuttons2row;
|
||||
int _nbuttons = MAX_BUTTONS;
|
||||
SDL_Rect * r;
|
||||
touchscreenKeyboardTheme = theme;
|
||||
AutoFireButtonsNum = nbuttonsAutoFire;
|
||||
if( AutoFireButtonsNum > MAX_BUTTONS_AUTOFIRE )
|
||||
AutoFireButtonsNum = MAX_BUTTONS_AUTOFIRE;
|
||||
// TODO: works for horizontal screen orientation only!
|
||||
buttonsize = size;
|
||||
buttonDrawSize = drawsize;
|
||||
switch(_transparency)
|
||||
{
|
||||
case 0: transparency = 16; break;
|
||||
@@ -616,6 +636,11 @@ JAVA_EXPORT_NAME(Settings_nativeSetupScreenKeyboard) ( JNIEnv* env, jobject thi
|
||||
buttonsAutoFireRect[i].x = buttons[i].x - buttons[i].w / 2;
|
||||
buttonsAutoFireRect[i].y = buttons[i].y - buttons[i].h / 2;
|
||||
}
|
||||
shrinkButtonRect(arrows, &arrowsDraw);
|
||||
for(i = 0; i < MAX_BUTTONS; i++)
|
||||
{
|
||||
shrinkButtonRect(buttons[i], &buttonsDraw[i]);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -711,11 +736,13 @@ int SDL_ANDROID_SetScreenKeyboardButtonPos(int buttonId, SDL_Rect * pos)
|
||||
if( buttonId == SDL_ANDROID_SCREENKEYBOARD_BUTTON_DPAD )
|
||||
{
|
||||
arrows = *pos;
|
||||
shrinkButtonRect(arrows, &arrowsDraw);
|
||||
}
|
||||
else
|
||||
{
|
||||
int i = buttonId - SDL_ANDROID_SCREENKEYBOARD_BUTTON_0;
|
||||
buttons[i] = *pos;
|
||||
shrinkButtonRect(buttons[i], &buttonsDraw[i]);
|
||||
if( i < AutoFireButtonsNum )
|
||||
{
|
||||
buttonsAutoFireRect[i].w = buttons[i].w * 2;
|
||||
|
||||
Reference in New Issue
Block a user