2015-07-30 20:14:55 +02:00
|
|
|
package juloo.keyboard2;
|
|
|
|
|
|
|
|
import android.content.Context;
|
|
|
|
import android.graphics.Canvas;
|
|
|
|
import android.graphics.Paint;
|
2015-09-30 22:47:18 +02:00
|
|
|
import android.graphics.RectF;
|
2015-08-05 01:30:56 +02:00
|
|
|
import android.os.Handler;
|
|
|
|
import android.os.Message;
|
2015-08-03 00:01:04 +02:00
|
|
|
import android.os.Vibrator;
|
2015-09-30 22:47:18 +02:00
|
|
|
import android.util.AttributeSet;
|
|
|
|
import android.util.DisplayMetrics;
|
2015-07-30 20:14:55 +02:00
|
|
|
import android.view.MotionEvent;
|
|
|
|
import android.view.View;
|
2015-10-28 00:39:20 +01:00
|
|
|
import android.widget.PopupWindow;
|
2015-10-03 00:19:17 +02:00
|
|
|
import java.util.ArrayList;
|
2015-07-30 20:14:55 +02:00
|
|
|
|
|
|
|
public class Keyboard2View extends View
|
2021-12-19 19:44:27 +01:00
|
|
|
implements View.OnTouchListener, Handler.Callback
|
2015-07-30 20:14:55 +02:00
|
|
|
{
|
2021-12-19 19:44:27 +01:00
|
|
|
private static final long VIBRATE_MIN_INTERVAL = 100;
|
2015-07-30 20:14:55 +02:00
|
|
|
|
2021-12-19 19:44:27 +01:00
|
|
|
private KeyboardData _keyboard;
|
2015-07-30 20:14:55 +02:00
|
|
|
|
2021-12-19 19:44:27 +01:00
|
|
|
private ArrayList<KeyDown> _downKeys = new ArrayList<KeyDown>();
|
2015-08-01 23:54:38 +02:00
|
|
|
|
2021-12-19 19:44:27 +01:00
|
|
|
private int _flags = 0;
|
2015-08-01 16:33:30 +02:00
|
|
|
|
2021-12-19 19:44:27 +01:00
|
|
|
private Vibrator _vibratorService;
|
|
|
|
private long _lastVibration = 0;
|
2015-08-03 00:01:04 +02:00
|
|
|
|
2021-12-19 19:44:27 +01:00
|
|
|
private Handler _handler;
|
|
|
|
private static int _currentWhat = 0;
|
2015-08-05 01:30:56 +02:00
|
|
|
|
2021-12-19 19:44:27 +01:00
|
|
|
private Config _config;
|
2015-10-29 12:49:40 +01:00
|
|
|
|
2021-12-19 19:44:27 +01:00
|
|
|
private float _keyWidth;
|
2015-10-29 12:49:40 +01:00
|
|
|
|
2021-12-26 23:55:18 +01:00
|
|
|
private Theme _theme;
|
2015-10-29 12:49:40 +01:00
|
|
|
|
2021-12-19 19:44:27 +01:00
|
|
|
private static RectF _tmpRect = new RectF();
|
2015-07-30 20:14:55 +02:00
|
|
|
|
2021-12-19 19:44:27 +01:00
|
|
|
public Keyboard2View(Context context, AttributeSet attrs)
|
|
|
|
{
|
|
|
|
super(context, attrs);
|
|
|
|
_vibratorService = (Vibrator)context.getSystemService(Context.VIBRATOR_SERVICE);
|
|
|
|
_handler = new Handler(this);
|
2021-12-26 23:55:18 +01:00
|
|
|
_theme = new Theme(getContext(), attrs);
|
2021-12-28 16:47:19 +01:00
|
|
|
_config = Config.globalConfig();
|
|
|
|
refreshConfig(null);
|
2021-12-19 19:44:27 +01:00
|
|
|
setOnTouchListener(this);
|
|
|
|
}
|
2015-07-30 20:14:55 +02:00
|
|
|
|
2021-04-28 00:23:52 +02:00
|
|
|
/* Internally calls [reset()]. */
|
2021-12-28 16:47:19 +01:00
|
|
|
public void refreshConfig(KeyboardData kw)
|
2021-04-24 23:18:16 +02:00
|
|
|
{
|
2021-04-28 00:23:52 +02:00
|
|
|
if (kw != null)
|
|
|
|
setKeyboard(kw); // handle layout options then calls reset().
|
2021-04-24 23:18:16 +02:00
|
|
|
}
|
|
|
|
|
2021-12-19 19:44:27 +01:00
|
|
|
public void setKeyboard(KeyboardData kw)
|
2021-05-09 00:09:10 +02:00
|
|
|
{
|
2021-04-18 00:55:31 +02:00
|
|
|
if (!_config.shouldOfferSwitchingToNextInputMethod)
|
|
|
|
kw = kw.removeKeys(new KeyboardData.RemoveKeysByEvent(KeyValue.EVENT_CHANGE_METHOD));
|
2021-05-09 00:09:10 +02:00
|
|
|
if (_config.accent_flags_to_remove != 0)
|
|
|
|
kw = kw.removeKeys(new KeyboardData.RemoveKeysByFlags(_config.accent_flags_to_remove));
|
2021-04-18 00:55:31 +02:00
|
|
|
_keyboard = kw;
|
2021-05-09 00:09:10 +02:00
|
|
|
reset();
|
|
|
|
}
|
2015-08-08 16:47:22 +02:00
|
|
|
|
2021-12-19 19:44:27 +01:00
|
|
|
public void reset()
|
|
|
|
{
|
|
|
|
_flags = 0;
|
|
|
|
_downKeys.clear();
|
|
|
|
requestLayout();
|
|
|
|
invalidate();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean onTouch(View v, MotionEvent event)
|
|
|
|
{
|
|
|
|
float x;
|
|
|
|
float y;
|
|
|
|
float keyW;
|
|
|
|
int p;
|
|
|
|
|
|
|
|
switch (event.getActionMasked())
|
|
|
|
{
|
|
|
|
case MotionEvent.ACTION_UP:
|
|
|
|
case MotionEvent.ACTION_POINTER_UP:
|
|
|
|
onTouchUp(event.getPointerId(event.getActionIndex()));
|
|
|
|
break ;
|
|
|
|
case MotionEvent.ACTION_DOWN:
|
|
|
|
case MotionEvent.ACTION_POINTER_DOWN:
|
|
|
|
p = event.getActionIndex();
|
|
|
|
onTouchDown(event.getX(p), event.getY(p), event.getPointerId(p));
|
|
|
|
break ;
|
|
|
|
case MotionEvent.ACTION_MOVE:
|
|
|
|
for (p = 0; p < event.getPointerCount(); p++)
|
|
|
|
onTouchMove(event.getX(p), event.getY(p), event.getPointerId(p));
|
|
|
|
break ;
|
|
|
|
default:
|
|
|
|
return (false);
|
|
|
|
}
|
|
|
|
return (true);
|
|
|
|
}
|
|
|
|
|
|
|
|
private KeyDown getKeyDown(int pointerId)
|
|
|
|
{
|
|
|
|
for (KeyDown k : _downKeys)
|
|
|
|
{
|
|
|
|
if (k.pointerId == pointerId)
|
|
|
|
return (k);
|
|
|
|
}
|
|
|
|
return (null);
|
|
|
|
}
|
|
|
|
|
|
|
|
private KeyDown getKeyDown(KeyboardData.Key key)
|
|
|
|
{
|
|
|
|
for (KeyDown k : _downKeys)
|
|
|
|
{
|
|
|
|
if (k.key == key)
|
|
|
|
return (k);
|
|
|
|
}
|
|
|
|
return (null);
|
|
|
|
}
|
|
|
|
|
|
|
|
private KeyDown getKeyDown(KeyValue kv)
|
|
|
|
{
|
|
|
|
for (KeyDown k : _downKeys)
|
|
|
|
{
|
|
|
|
if (k.value == kv)
|
|
|
|
return (k);
|
|
|
|
}
|
|
|
|
return (null);
|
|
|
|
}
|
|
|
|
|
|
|
|
private void onTouchMove(float moveX, float moveY, int pointerId)
|
|
|
|
{
|
|
|
|
KeyDown key = getKeyDown(pointerId);
|
|
|
|
KeyValue newValue;
|
|
|
|
|
|
|
|
if (key != null)
|
|
|
|
{
|
|
|
|
moveX -= key.downX;
|
|
|
|
moveY -= key.downY;
|
2021-04-20 00:10:45 +02:00
|
|
|
float absDist = Math.abs(moveX) + Math.abs(moveY);
|
|
|
|
key.ptrDist = absDist;
|
2021-12-19 19:44:27 +01:00
|
|
|
if (absDist < _config.subValueDist)
|
|
|
|
newValue = key.key.key0;
|
|
|
|
else if (moveX < 0)
|
|
|
|
newValue = (moveY < 0) ? key.key.key1 : key.key.key3;
|
|
|
|
else if (moveY < 0)
|
|
|
|
newValue = key.key.key2;
|
|
|
|
else
|
|
|
|
newValue = key.key.key4;
|
|
|
|
if (newValue != null && newValue != key.value)
|
|
|
|
{
|
|
|
|
if (key.timeoutWhat != -1)
|
|
|
|
{
|
|
|
|
_handler.removeMessages(key.timeoutWhat);
|
|
|
|
if ((newValue.flags & KeyValue.FLAG_NOREPEAT) == 0)
|
|
|
|
_handler.sendEmptyMessageDelayed(key.timeoutWhat, _config.longPressTimeout);
|
|
|
|
}
|
|
|
|
key.value = newValue;
|
|
|
|
key.flags = newValue.flags;
|
|
|
|
updateFlags();
|
|
|
|
invalidate();
|
|
|
|
handleKeyDown(newValue);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void onTouchDown(float touchX, float touchY, int pointerId)
|
|
|
|
{
|
|
|
|
float y = _config.marginTop - _config.keyHeight;
|
|
|
|
for (KeyboardData.Row row : _keyboard.rows)
|
|
|
|
{
|
|
|
|
y += _config.keyHeight;
|
|
|
|
if (touchY < y || touchY >= (y + _config.keyHeight))
|
|
|
|
continue ;
|
2021-04-17 23:56:51 +02:00
|
|
|
float x = _config.horizontalMargin;
|
2021-12-19 19:44:27 +01:00
|
|
|
for (KeyboardData.Key key : row.keys)
|
|
|
|
{
|
2021-04-17 23:56:51 +02:00
|
|
|
x += key.shift * _keyWidth;
|
2021-12-19 19:44:27 +01:00
|
|
|
float keyW = _keyWidth * key.width;
|
|
|
|
if (touchX >= x && touchX < (x + keyW))
|
|
|
|
{
|
2021-04-29 00:08:55 +02:00
|
|
|
int what = _currentWhat++;
|
|
|
|
if (key.key0 != null && (key.key0.flags & KeyValue.FLAG_NOREPEAT) == 0)
|
|
|
|
_handler.sendEmptyMessageDelayed(what, _config.longPressTimeout);
|
|
|
|
_downKeys.add(new KeyDown(pointerId, key, touchX, touchY, what));
|
2021-12-19 19:44:27 +01:00
|
|
|
handleKeyDown(key.key0);
|
|
|
|
updateFlags();
|
|
|
|
invalidate();
|
|
|
|
return ;
|
|
|
|
}
|
|
|
|
x += keyW;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-07-31 01:14:35 +02:00
|
|
|
|
2021-04-29 00:08:55 +02:00
|
|
|
// Whether a key is already activated (key down but pointer up)
|
|
|
|
private KeyDown getActivatedKey(KeyValue kv)
|
|
|
|
{
|
2021-12-19 19:44:27 +01:00
|
|
|
for (KeyDown k : _downKeys)
|
|
|
|
{
|
|
|
|
if (k.value == kv && k.pointerId == -1)
|
|
|
|
return (k);
|
|
|
|
}
|
|
|
|
return (null);
|
2021-04-29 00:08:55 +02:00
|
|
|
}
|
|
|
|
|
2021-12-19 19:44:27 +01:00
|
|
|
private void onTouchUp(int pointerId)
|
|
|
|
{
|
|
|
|
KeyDown k = getKeyDown(pointerId);
|
2015-08-01 16:33:30 +02:00
|
|
|
|
2021-12-19 19:44:27 +01:00
|
|
|
if (k != null)
|
|
|
|
{
|
2021-04-29 00:08:55 +02:00
|
|
|
// Stop key repeat
|
|
|
|
if (k.timeoutWhat != -1)
|
|
|
|
{
|
|
|
|
_handler.removeMessages(k.timeoutWhat);
|
|
|
|
k.timeoutWhat = -1;
|
|
|
|
}
|
|
|
|
KeyDown k_on = getActivatedKey(k.value);
|
|
|
|
if (k_on != null)
|
|
|
|
{
|
|
|
|
_downKeys.remove(k); // Remove dupplicate
|
|
|
|
// Same key with FLAG_LOCK is already on, do lock
|
|
|
|
if ((k_on.flags & KeyValue.FLAG_LOCK) != 0)
|
|
|
|
{
|
|
|
|
k_on.flags ^= KeyValue.FLAG_LOCK; // Next time, disable it
|
|
|
|
k_on.flags |= KeyValue.FLAG_LOCKED;
|
|
|
|
}
|
|
|
|
// Otherwise, toggle it
|
|
|
|
else
|
|
|
|
{
|
|
|
|
_downKeys.remove(k_on);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Key stay activated
|
|
|
|
else if ((k.flags & KeyValue.FLAG_KEEP_ON) != 0)
|
|
|
|
{
|
|
|
|
k.pointerId = -1; // Set pointer up
|
|
|
|
}
|
|
|
|
else // Regular key up
|
|
|
|
{
|
|
|
|
for (int i = 0; i < _downKeys.size(); i++)
|
|
|
|
{
|
|
|
|
KeyDown downKey = _downKeys.get(i);
|
|
|
|
// Disable other activated keys that aren't locked
|
|
|
|
if (downKey.pointerId == -1 && (downKey.flags & KeyValue.FLAG_LOCKED) == 0)
|
|
|
|
_downKeys.remove(i--);
|
|
|
|
// Other keys currently down won't stay activated
|
|
|
|
else if ((downKey.flags & KeyValue.FLAG_KEEP_ON) != 0)
|
|
|
|
downKey.flags ^= KeyValue.FLAG_KEEP_ON;
|
|
|
|
}
|
|
|
|
_downKeys.remove(k);
|
|
|
|
handleKeyUp(k);
|
|
|
|
}
|
|
|
|
updateFlags();
|
|
|
|
invalidate();
|
2021-12-19 19:44:27 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void handleKeyUp(KeyDown key)
|
|
|
|
{
|
|
|
|
if (key.value != null && (key.flags & (KeyValue.FLAG_LOCKED | KeyValue.FLAG_NOCHAR)) == 0)
|
2021-12-28 17:47:18 +01:00
|
|
|
_config.handler.handleKeyUp(key.value, _flags);
|
2021-12-19 19:44:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
private void handleKeyDown(KeyValue key)
|
|
|
|
{
|
|
|
|
if (key == null)
|
|
|
|
return ;
|
|
|
|
vibrate();
|
|
|
|
}
|
|
|
|
|
|
|
|
private void updateFlags()
|
|
|
|
{
|
|
|
|
_flags = 0;
|
|
|
|
for (KeyDown k : _downKeys)
|
|
|
|
_flags |= k.flags;
|
|
|
|
}
|
|
|
|
|
|
|
|
private void vibrate()
|
|
|
|
{
|
|
|
|
if (!_config.vibrateEnabled)
|
|
|
|
return ;
|
|
|
|
long now = System.currentTimeMillis();
|
|
|
|
if ((now - _lastVibration) > VIBRATE_MIN_INTERVAL)
|
|
|
|
{
|
|
|
|
_lastVibration = now;
|
|
|
|
try
|
|
|
|
{
|
|
|
|
_vibratorService.vibrate(_config.vibrateDuration);
|
|
|
|
}
|
|
|
|
catch (Exception e)
|
|
|
|
{
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean handleMessage(Message msg)
|
|
|
|
{
|
|
|
|
for (KeyDown key : _downKeys)
|
|
|
|
{
|
|
|
|
if (key.timeoutWhat == msg.what)
|
|
|
|
{
|
2021-04-20 00:10:45 +02:00
|
|
|
long nextInterval = _config.longPressInterval;
|
2021-04-20 00:34:21 +02:00
|
|
|
if (_config.preciseRepeat && (key.flags & KeyValue.FLAG_PRECISE_REPEAT) != 0)
|
2021-04-20 00:10:45 +02:00
|
|
|
{
|
|
|
|
// Modulate repeat interval depending on the distance of the pointer
|
|
|
|
float accel = Math.min(4.f, Math.max(0.3f, key.ptrDist / (_config.subValueDist * 15.f)));
|
|
|
|
nextInterval = (long)((float)nextInterval / accel);
|
|
|
|
}
|
2021-12-19 19:44:27 +01:00
|
|
|
_handler.sendEmptyMessageDelayed(msg.what, nextInterval);
|
2021-12-28 17:47:18 +01:00
|
|
|
_config.handler.handleKeyUp(key.value, _flags);
|
2021-12-19 19:44:27 +01:00
|
|
|
return (true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return (false);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onMeasure(int wSpec, int hSpec)
|
|
|
|
{
|
2021-04-29 00:59:19 +02:00
|
|
|
DisplayMetrics dm = getContext().getResources().getDisplayMetrics();
|
2021-12-05 19:36:54 +01:00
|
|
|
int width = dm.widthPixels;
|
|
|
|
int height =
|
|
|
|
(int)(_config.keyHeight * _keyboard.keysHeight
|
|
|
|
+ _keyboard.rows.size() * _config.keyVerticalInterval
|
|
|
|
+ _config.marginTop + _config.marginBottom);
|
|
|
|
setMeasuredDimension(width, height);
|
|
|
|
_keyWidth = (width - (_config.horizontalMargin * 2)) / _keyboard.keysWidth;
|
2021-12-19 19:44:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void onDraw(Canvas canvas)
|
|
|
|
{
|
|
|
|
float y = _config.marginTop;
|
|
|
|
for (KeyboardData.Row row : _keyboard.rows)
|
|
|
|
{
|
2021-04-29 00:59:19 +02:00
|
|
|
y += row.shift * _config.keyHeight;
|
2021-04-17 23:56:51 +02:00
|
|
|
float x = _config.horizontalMargin;
|
2021-04-29 00:59:19 +02:00
|
|
|
float keyH = row.height * _config.keyHeight;
|
2021-12-19 19:44:27 +01:00
|
|
|
for (KeyboardData.Key k : row.keys)
|
|
|
|
{
|
2021-04-25 00:12:16 +02:00
|
|
|
x += k.shift * _keyWidth + _config.keyHorizontalInterval;
|
2021-12-19 19:44:27 +01:00
|
|
|
float keyW = _keyWidth * k.width - _config.keyHorizontalInterval;
|
|
|
|
KeyDown keyDown = getKeyDown(k);
|
|
|
|
_tmpRect.set(x, y, x + keyW, y + keyH);
|
2021-12-30 00:52:50 +01:00
|
|
|
canvas.drawRoundRect(_tmpRect, _theme.keyBorderRadius, _theme.keyBorderRadius,
|
|
|
|
(keyDown != null) ? _theme.keyDownBgPaint : _theme.keyBgPaint);
|
2021-12-19 19:44:27 +01:00
|
|
|
if (k.key0 != null)
|
2021-12-26 23:55:18 +01:00
|
|
|
drawLabel(canvas, k.key0, keyW / 2f + x, (keyH + _theme.labelTextSize) / 2f + y, keyDown);
|
2021-12-19 19:44:27 +01:00
|
|
|
float subPadding = _config.keyPadding;
|
|
|
|
if (k.key1 != null)
|
|
|
|
drawSubLabel(canvas, k.key1, x + subPadding, y + subPadding, false, true, keyDown);
|
|
|
|
if (k.key3 != null)
|
|
|
|
drawSubLabel(canvas, k.key3, x + subPadding, y + keyH - subPadding, false, false, keyDown);
|
|
|
|
if (k.key2 != null)
|
|
|
|
drawSubLabel(canvas, k.key2, x + keyW - subPadding, y + subPadding, true, true, keyDown);
|
|
|
|
if (k.key4 != null)
|
|
|
|
drawSubLabel(canvas, k.key4, x + keyW - subPadding, y + keyH - subPadding, true, false, keyDown);
|
|
|
|
x += keyW;
|
|
|
|
}
|
|
|
|
y += keyH + _config.keyVerticalInterval;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onDetachedFromWindow()
|
|
|
|
{
|
|
|
|
super.onDetachedFromWindow();
|
|
|
|
}
|
2015-10-28 00:39:20 +01:00
|
|
|
|
2021-04-29 01:33:57 +02:00
|
|
|
private int labelColor(KeyValue k, KeyDown hasKeyDown, int defaultColor)
|
|
|
|
{
|
|
|
|
if (hasKeyDown != null)
|
|
|
|
{
|
|
|
|
KeyDown kd = getKeyDown(k);
|
|
|
|
if (kd != null)
|
|
|
|
{
|
|
|
|
if ((kd.flags & KeyValue.FLAG_LOCKED) != 0)
|
2021-12-26 23:55:18 +01:00
|
|
|
return _theme.lockedColor;
|
2021-04-29 01:33:57 +02:00
|
|
|
if (kd.pointerId == -1)
|
2021-12-26 23:55:18 +01:00
|
|
|
return _theme.activatedColor;
|
2021-04-29 01:33:57 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return defaultColor;
|
|
|
|
}
|
|
|
|
|
2021-12-19 19:44:27 +01:00
|
|
|
private void drawLabel(Canvas canvas, KeyValue k, float x, float y, KeyDown keyDown)
|
|
|
|
{
|
2021-05-01 22:49:05 +02:00
|
|
|
k = KeyModifier.handleFlags(k, _flags);
|
2021-12-26 23:55:18 +01:00
|
|
|
Paint p = _theme.labelPaint(((k.flags & KeyValue.FLAG_KEY_FONT) != 0));
|
|
|
|
p.setColor(labelColor(k, keyDown, _theme.labelColor));
|
|
|
|
p.setTextSize(_theme.labelTextSize * scaleTextSize(k));
|
2021-04-24 23:18:16 +02:00
|
|
|
canvas.drawText(k.symbol, x, y, p);
|
2021-12-19 19:44:27 +01:00
|
|
|
}
|
2015-10-13 00:02:34 +02:00
|
|
|
|
2021-12-19 19:44:27 +01:00
|
|
|
private void drawSubLabel(Canvas canvas, KeyValue k, float x, float y, boolean right, boolean up, KeyDown keyDown)
|
|
|
|
{
|
2021-05-01 22:49:05 +02:00
|
|
|
k = KeyModifier.handleFlags(k, _flags);
|
2021-12-26 23:55:18 +01:00
|
|
|
Paint p = _theme.subLabelPaint(((k.flags & KeyValue.FLAG_KEY_FONT) != 0), right);
|
|
|
|
p.setColor(labelColor(k, keyDown, _theme.subLabelColor));
|
|
|
|
p.setTextSize(_theme.sublabelTextSize * scaleTextSize(k));
|
2021-05-01 22:49:05 +02:00
|
|
|
y -= up ? p.ascent() : p.descent();
|
2021-04-24 23:18:16 +02:00
|
|
|
canvas.drawText(k.symbol, x, y, p);
|
2021-12-19 19:44:27 +01:00
|
|
|
}
|
2015-10-13 00:02:34 +02:00
|
|
|
|
2021-04-24 23:38:29 +02:00
|
|
|
private float scaleTextSize(KeyValue k)
|
|
|
|
{
|
2021-12-26 23:55:18 +01:00
|
|
|
return ((k.symbol.length() < 2) ? 1.f : 0.8f) * _config.characterSize;
|
2021-04-24 23:38:29 +02:00
|
|
|
}
|
|
|
|
|
2021-12-19 19:44:27 +01:00
|
|
|
private static class KeyDown
|
|
|
|
{
|
2021-04-29 00:08:55 +02:00
|
|
|
/* -1 if pointer is up. */
|
2021-12-19 19:44:27 +01:00
|
|
|
public int pointerId;
|
|
|
|
public KeyValue value;
|
|
|
|
public KeyboardData.Key key;
|
|
|
|
public float downX;
|
|
|
|
public float downY;
|
2021-04-20 00:10:45 +02:00
|
|
|
/* Manhattan distance of the pointer to the center of the key */
|
|
|
|
public float ptrDist;
|
2021-12-19 19:44:27 +01:00
|
|
|
public int flags;
|
|
|
|
public int timeoutWhat;
|
|
|
|
|
|
|
|
public KeyDown(int pointerId, KeyboardData.Key key, float x, float y, int what)
|
|
|
|
{
|
|
|
|
this.pointerId = pointerId;
|
|
|
|
value = key.key0;
|
|
|
|
this.key = key;
|
|
|
|
downX = x;
|
|
|
|
downY = y;
|
2021-04-20 00:10:45 +02:00
|
|
|
ptrDist = 0.f;
|
2021-12-19 19:44:27 +01:00
|
|
|
flags = (value == null) ? 0 : value.flags;
|
|
|
|
timeoutWhat = what;
|
|
|
|
}
|
|
|
|
}
|
2015-07-30 20:14:55 +02:00
|
|
|
}
|