updated InputStick plugin (and migrated to Android Studio)

cleaned up java directory
This commit is contained in:
Philipp Crocoll 2016-01-28 06:50:37 +01:00
parent 3d2f6db36d
commit a2be64d1cb
882 changed files with 36282 additions and 39201 deletions

View File

@ -0,0 +1 @@
#Wed Jan 27 05:35:46 CET 2016

View File

@ -0,0 +1,23 @@
apply plugin: 'com.android.library'
android {
compileSdkVersion 19
buildToolsVersion "23.0.0"
defaultConfig {
minSdkVersion 9
targetSdkVersion 19
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:support-v4:19.1.0'
compile 'com.android.support:appcompat-v7:19.1.0'
}

View File

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.inputstick.api"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="9"
android:targetSdkVersion="19" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
</application>
</manifest>

View File

@ -0,0 +1,57 @@
package com.inputstick.api;
import java.security.MessageDigest;
import javax.crypto.Cipher;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
public class AES {
private Cipher mCipherEncr;
private Cipher mCipherDecr;
private SecretKeySpec mKey;
private boolean ready;
public AES() {
ready = false;
}
public static byte[] getMD5(String s) {
try {
MessageDigest md = MessageDigest.getInstance("MD5");
return md.digest(s.getBytes("UTF-8"));
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
public byte[] init(byte[] key) {
byte[] iv = null;
try {
mKey = new SecretKeySpec(key, "AES");
mCipherEncr = Cipher.getInstance("AES/CBC/NoPadding");
mCipherEncr.init(Cipher.ENCRYPT_MODE, mKey);
iv = mCipherEncr.getIV();
Util.printHex(iv, "AES IV: ");
mCipherDecr = Cipher.getInstance("AES/CBC/NoPadding");
mCipherDecr.init(Cipher.DECRYPT_MODE, mKey, new IvParameterSpec(iv));
ready = true;
} catch (Exception e) {
e.printStackTrace();
}
return iv;
}
public byte[] encrypt(byte[] data) {
return mCipherEncr.update(data);
}
public byte[] decrypt(byte[] data) {
return mCipherDecr.update(data);
}
public boolean isReady() {
return ready;
}
}

View File

@ -0,0 +1,159 @@
package com.inputstick.api;
import java.lang.ref.WeakReference;
import android.app.Application;
import android.os.Handler;
import android.os.Message;
import com.inputstick.api.bluetooth.BTService;
import com.inputstick.api.init.InitManager;
import com.inputstick.api.init.InitManagerListener;
public class BTConnectionManager extends ConnectionManager implements InitManagerListener {
//private static final String mTag = "BTConnectionManager";
private String mMac;
private byte[] mKey;
private boolean mIsBT40;
private InitManager mInitManager;
private Application mApp;
protected BTService mBTService;
private PacketManager mPacketManager;
private final BTHandler mBTHandler = new BTHandler(this);
private static class BTHandler extends Handler {
private final WeakReference<BTConnectionManager> ref;
BTHandler(BTConnectionManager manager) {
ref = new WeakReference<BTConnectionManager>(manager);
}
@Override
public void handleMessage(Message msg) {
BTConnectionManager manager = ref.get();
switch (msg.what) {
case BTService.EVENT_DATA:
manager.onData((byte[])msg.obj);
break;
case BTService.EVENT_CONNECTED:
manager.onConnected();
break;
case BTService.EVENT_CANCELLED:
manager.onDisconnected();
break;
case BTService.EVENT_ERROR:
manager.onFailure(msg.arg1);
break;
default:
manager.onFailure(InputStickError.ERROR_BLUETOOTH);
}
}
}
private void onConnecting() {
stateNotify(ConnectionManager.STATE_CONNECTING);
}
private void onConnected() {
stateNotify(ConnectionManager.STATE_CONNECTED);
//mInitManager.startTimeoutCountdown(InitManager.DEFAULT_INIT_TIMEOUT);
mInitManager.onConnected();
}
private void onDisconnected() {
stateNotify(ConnectionManager.STATE_DISCONNECTED);
mInitManager.onDisconnected();
}
private void onFailure(int code) {
mErrorCode = code;
stateNotify(ConnectionManager.STATE_FAILURE);
disconnect();
}
@Override
protected void onData(byte[] rawData) {
byte[] data;
data = mPacketManager.bytesToPacket(rawData);
if (data == null) {
//TODO failure?
return;
}
mInitManager.onData(data);
super.onData(data);
}
public BTConnectionManager(InitManager initManager, Application app, String mac, byte[] key, boolean isBT40) {
mInitManager = initManager;
mMac = mac;
mKey = key;
mApp = app;
mIsBT40 = isBT40;
}
public BTConnectionManager(InitManager initManager, Application app, String mac, byte[] key) {
this(initManager, app, mac, key, false);
}
@Override
public void connect() {
connect(false, BTService.DEFAULT_CONNECT_TIMEOUT);
}
public void connect(boolean reflection, int timeout, boolean doNotAsk) {
mErrorCode = InputStickError.ERROR_NONE;
if (mBTService == null) {
mBTService = new BTService(mApp, mBTHandler);
mPacketManager = new PacketManager(mBTService, mKey);
mInitManager.init(this, mPacketManager);
}
mBTService.setConnectTimeout(timeout);
mBTService.enableReflection(reflection);
mBTService.connect(mMac, doNotAsk, mIsBT40);
onConnecting();
}
public void connect(boolean reflection, int timeout) {
connect(reflection, timeout, false);
}
@Override
public void disconnect() {
if (mBTService != null) {
mBTService.disconnect();
}
}
public void disconnect(int failureCode) {
onFailure(failureCode);
}
@Override
public void sendPacket(Packet p) {
mPacketManager.sendPacket(p);
}
@Override
public void onInitReady() {
stateNotify(ConnectionManager.STATE_READY);
}
@Override
public void onInitNotReady() {
stateNotify(ConnectionManager.STATE_CONNECTED);
}
@Override
public void onInitFailure(int code) {
onFailure(code);
}
}

View File

@ -0,0 +1,99 @@
package com.inputstick.api;
import java.util.Vector;
public abstract class ConnectionManager {
public static final int STATE_DISCONNECTED = 0;
public static final int STATE_FAILURE = 1;
public static final int STATE_CONNECTING = 2;
public static final int STATE_CONNECTED = 3;
public static final int STATE_READY = 4;
protected Vector<InputStickStateListener> mStateListeners = new Vector<InputStickStateListener>();
protected Vector<InputStickDataListener> mDataListeners = new Vector<InputStickDataListener>();
protected int mState;
protected int mErrorCode;
public abstract void connect();
public abstract void disconnect();
public abstract void sendPacket(Packet p);
protected void stateNotify(int state) {
stateNotify(state, false);
}
protected void stateNotify(int state, boolean forceNotification) {
if (( !forceNotification) && (mState == state )) {
//do nothing
} else {
//notify all listeners
mState = state;
for (InputStickStateListener listener : mStateListeners) {
listener.onStateChanged(state);
}
}
}
public int getState() {
return mState;
}
public boolean isReady() {
if (mState == STATE_READY) {
return true;
} else {
return false;
}
}
public boolean isConnected() {
if ((mState == STATE_READY) || (mState == STATE_CONNECTED)) {
return true;
} else {
return false;
}
}
public int getErrorCode() {
return mErrorCode;
}
protected void onData(byte[] data) {
for (InputStickDataListener listener : mDataListeners) {
listener.onInputStickData(data);
}
}
public void addStateListener(InputStickStateListener listener) {
if (listener != null) {
if ( !mStateListeners.contains(listener)) {
mStateListeners.add(listener);
}
}
}
public void removeStateListener(InputStickStateListener listener) {
if (listener != null) {
mStateListeners.remove(listener);
}
}
public void addDataListener(InputStickDataListener listener) {
if (listener != null) {
if ( !mDataListeners.contains(listener)) {
mDataListeners.add(listener);
}
}
}
public void removeDataListener(InputStickDataListener listener) {
if (listener != null) {
mDataListeners.remove(listener);
}
}
}

View File

@ -0,0 +1,53 @@
package com.inputstick.api;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.net.Uri;
public class DownloadDialog {
public static final int NOT_INSTALLED = 0;
public static final int NOT_UPDATED = 1;
public static AlertDialog getDialog(final Context ctx, final int messageCode) {
AlertDialog.Builder downloadDialog = new AlertDialog.Builder(ctx);
if (messageCode == NOT_UPDATED) {
downloadDialog.setTitle("InputStickUtility app must be updated");
downloadDialog.setMessage("It appears that you are using older version of InputStickUtility application. Update now (GoolePlay)?");
} else {
downloadDialog.setTitle("InputStickUtility app NOT installed");
downloadDialog.setMessage("InputStickUtility is required to complete this action. Download now (GoolePlay)?\nNote: InputStick USB receiver (HARDWARE!) is also required.");
}
downloadDialog.setPositiveButton("Yes",
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
final String appPackageName = "com.inputstick.apps.inputstickutility";
try {
ctx.startActivity(new Intent(Intent.ACTION_VIEW,
Uri.parse("market://details?id="
+ appPackageName)));
} catch (android.content.ActivityNotFoundException anfe) {
ctx.startActivity(new Intent(
Intent.ACTION_VIEW,
Uri.parse("http://play.google.com/store/apps/details?id="
+ appPackageName)));
}
}
});
downloadDialog.setNegativeButton("No",
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
}
});
return downloadDialog.show();
}
}

View File

@ -0,0 +1,149 @@
package com.inputstick.api;
public class HIDInfo {
private int state;
private boolean numLock;
private boolean capsLock;
private boolean scrollLock;
private boolean keyboardReportProtocol;
private boolean mouseReportProtocol;
private boolean keyboardReady;
private boolean mouseReady;
private boolean consumerReady;
// >= 0.93
private boolean sentToHostInfo;
private int keyboardReportsSentToHost;
private int mouseReportsSentToHost;
private int consumerReportsSentToHost;
public HIDInfo() {
keyboardReportProtocol = true;
mouseReportProtocol = true;
sentToHostInfo = false;
}
public void update(byte[] data) {
state = data[1];
int leds = data[2];
if ((leds & 0x01) != 0) {
numLock = true;
} else {
numLock = false;
}
if ((leds & 0x02) != 0) {
capsLock = true;
} else {
capsLock = false;
}
if ((leds & 0x04) != 0) {
scrollLock = true;
} else {
scrollLock = false;
}
if (data[3] == 0) {
keyboardReportProtocol = true;
} else {
keyboardReportProtocol = false;
}
if (data[4] == 0) {
keyboardReady = false;
} else {
keyboardReady = true;
}
if (data[5] == 0) {
mouseReportProtocol = true;
} else {
mouseReportProtocol = false;
}
if (data[6] == 0) {
mouseReady = false;
} else {
mouseReady = true;
}
if (data[7] == 0) {
consumerReady = false;
} else {
consumerReady = true;
}
if (data.length >= 12) {
if (data[11] == (byte)0xFF) {
sentToHostInfo = true;
keyboardReportsSentToHost = data[8] & 0xFF;
mouseReportsSentToHost = data[9] & 0xFF;
consumerReportsSentToHost = data[10] & 0xFF;
}
}
}
public void setKeyboardBusy() {
keyboardReady = false;
}
public int getState() {
return state;
}
public boolean getNumLock() {
return numLock;
}
public boolean getCapsLock() {
return capsLock;
}
public boolean getScrollLock() {
return scrollLock;
}
public boolean isKeyboardReportProtocol() {
return keyboardReportProtocol;
}
public boolean isMouseReportProtocol() {
return mouseReportProtocol;
}
public boolean isKeyboardReady() {
return keyboardReady;
}
public boolean isMouseReady() {
return mouseReady;
}
public boolean isConsumerReady() {
return consumerReady;
}
// > v0.93 firmware only
public boolean isSentToHostInfoAvailable() {
return sentToHostInfo;
}
public int getKeyboardReportsSentToHost() {
return keyboardReportsSentToHost;
}
public int getMouseReportsSentToHost() {
return mouseReportsSentToHost;
}
public int getConsumerReportsSentToHost() {
return consumerReportsSentToHost;
}
}

View File

@ -0,0 +1,180 @@
package com.inputstick.api;
import java.lang.ref.WeakReference;
import android.app.Application;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;
import android.os.Message;
import android.os.Messenger;
public class IPCConnectionManager extends ConnectionManager {
//private static final String mTag = "IPCConnectionManager";
public static final int SERVICE_CMD_CONNECT = 1;
public static final int SERVICE_CMD_DISCONNECT = 2;
public static final int SERVICE_CMD_DATA = 3;
public static final int SERVICE_CMD_STATE = 4;
Context mCtx;
Messenger mService = null;
boolean mBound;
boolean initSent;
final Messenger mMessenger = new Messenger(new IncomingHandler(this));
private static class IncomingHandler extends Handler {
private final WeakReference<IPCConnectionManager> ref;
IncomingHandler(IPCConnectionManager manager) {
ref = new WeakReference<IPCConnectionManager>(manager);
}
@Override
public void handleMessage(Message msg) {
if (ref == null) return;
IPCConnectionManager manager = ref.get();
if (manager != null) {
switch (msg.what) {
case SERVICE_CMD_DATA:
byte[] data = null;
Bundle b = msg.getData();
if (b != null) {
data = b.getByteArray("data");
manager.onData(data);
}
break;
case SERVICE_CMD_STATE:
manager.stateNotify(msg.arg1);
break;
}
}
}
}
private ServiceConnection mConnection = new ServiceConnection() {
public void onServiceConnected(ComponentName className, IBinder service) {
mService = new Messenger(service);
mBound = true;
sendConnectMessage();
}
public void onServiceDisconnected(ComponentName className) {
// unexpectedly disconnected from service
mService = null;
mBound = false;
mErrorCode = InputStickError.ERROR_ANDROID_SERVICE_DISCONNECTED;
stateNotify(STATE_FAILURE);
stateNotify(STATE_DISCONNECTED);
}
};
//SERVICE=========================================================
private void sendConnectMessage() {
Bundle b = new Bundle();
b.putLong("TIME", System.currentTimeMillis());
sendMessage(SERVICE_CMD_CONNECT, 0, 0, b);
}
private void sendMessage(int what, int arg1, int arg2, Bundle b) {
Message msg;
try {
msg = Message.obtain(null, what, arg1, 0, null);
msg.replyTo = mMessenger;
msg.setData(b);
mService.send(msg);
} catch (Exception e) {
e.printStackTrace();
}
}
private void sendMessage(int what, int arg1, int arg2, byte[] data) {
Bundle b;
b = new Bundle();
b.putByteArray("data", data);
sendMessage(what, arg1, arg2, b);
}
private void sendMessage(int what, int arg1, int arg2) {
sendMessage(what, arg1, arg2, (Bundle)null);
}
@Override
protected void onData(byte[] data) {
super.onData(data);
}
public IPCConnectionManager(Application app) {
mCtx = app.getApplicationContext();
}
@Override
public void connect() {
PackageManager pm = mCtx.getPackageManager();
boolean exists = true;
try {
pm.getPackageInfo("com.inputstick.apps.inputstickutility", PackageManager.GET_META_DATA);
} catch (NameNotFoundException e) {
exists = false;
}
if (exists) {
mErrorCode = InputStickError.ERROR_NONE;
Intent intent = new Intent();
intent.setComponent(new ComponentName("com.inputstick.apps.inputstickutility","com.inputstick.apps.inputstickutility.service.InputStickService"));
intent.putExtra("TIME", System.currentTimeMillis());
mCtx.startService(intent);
mCtx.bindService(intent, mConnection, Context.BIND_AUTO_CREATE);
if (mBound) {
//already bound
sendConnectMessage();
}
} else {
mErrorCode = InputStickError.ERROR_ANDROID_NO_UTILITY_APP;
stateNotify(STATE_FAILURE);
stateNotify(STATE_DISCONNECTED);
}
}
@Override
public void disconnect() {
if (mBound) {
sendMessage(SERVICE_CMD_DISCONNECT, 0, 0);
Intent intent = new Intent();
intent.setComponent(new ComponentName("com.inputstick.apps.inputstickutility","com.inputstick.apps.inputstickutility.service.InputStickService"));
mCtx.unbindService(mConnection);
mCtx.stopService(intent);
mBound = false;
//service will pass notification message (disconnected)
} else {
//just set state, there is nothing else to do
stateNotify(STATE_DISCONNECTED);
}
}
@Override
public void sendPacket(Packet p) {
if ((mState == ConnectionManager.STATE_READY) || (mState == ConnectionManager.STATE_CONNECTED)) {
if (p.getRespond()) {
sendMessage(IPCConnectionManager.SERVICE_CMD_DATA, 1, 0, p.getBytes());
} else {
sendMessage(IPCConnectionManager.SERVICE_CMD_DATA, 0, 0, p.getBytes());
}
}
}
}

View File

@ -0,0 +1,7 @@
package com.inputstick.api;
public interface InputStickDataListener {
public void onInputStickData(byte[] data);
}

View File

@ -0,0 +1,144 @@
package com.inputstick.api;
import android.util.SparseArray;
public class InputStickError {
public static String ERROR_UNKNOWN_MSG = "Unknown";
public static final int ERROR_NONE = 0;
public static final int ERROR_UNKNOWN = 1;
//Bluetooth comm errors:
public static final int ERROR_BLUETOOTH = 0x0100;
public static final int ERROR_BLUETOOTH_CONNECTION_FAILED = ERROR_BLUETOOTH | 0x01;
public static final int ERROR_BLUETOOTH_CONNECTION_LOST = ERROR_BLUETOOTH | 0x02;
public static final int ERROR_BLUETOOTH_NOT_SUPPORTED = ERROR_BLUETOOTH | 0x03;
public static final int ERROR_BLUETOOTH_INVALID_MAC = ERROR_BLUETOOTH | 0x04;
public static final int ERROR_BLUETOOTH_ECHO_TIMEDOUT = ERROR_BLUETOOTH | 0x05;
public static final int ERROR_BLUETOOTH_NO_REMOTE_DEVICE = ERROR_BLUETOOTH | 0x06;
public static final int ERROR_BLUETOOTH_BT40_NOT_SUPPRTED = ERROR_BLUETOOTH | 0x07;
public static final int ERROR_BLUETOOTH_BT40_NO_SPP_SERVICE = ERROR_BLUETOOTH | 0x08;
//Hardware-related errors:
public static final int ERROR_HARDWARE = 0x0200;
public static final int ERROR_HARDWARE_WDG_RESET = ERROR_HARDWARE | 0x01;
//Packet
public static final int ERROR_PACKET = 0x0300;
public static final int ERROR_PACKET_INVALID_CRC = ERROR_PACKET | 0x01;
public static final int ERROR_PACKET_INVALID_LENGTH = ERROR_PACKET | 0x02;
public static final int ERROR_PACKET_INVALID_HEADER = ERROR_PACKET | 0x03;
//Init
public static final int ERROR_INIT = 0x0400;
public static final int ERROR_INIT_UNSUPPORTED_CMD = ERROR_INIT | 0x01;
public static final int ERROR_INIT_TIMEDOUT = ERROR_INIT | 0x02;
public static final int ERROR_INIT_FW_TYPE_NOT_SUPPORTED = ERROR_INIT | 0x03;
public static final int ERROR_INIT_FW_VERSION_NOT_SUPPORTED = ERROR_INIT | 0x04;
//Security
public static final int ERROR_SECURITY = 0x0500;
public static final int ERROR_SECURITY_NOT_SUPPORTED = ERROR_SECURITY | 0x01;
public static final int ERROR_SECURITY_NO_KEY = ERROR_SECURITY | 0x02;
public static final int ERROR_SECURITY_INVALID_KEY = ERROR_SECURITY | 0x03;
public static final int ERROR_SECURITY_CHALLENGE = ERROR_SECURITY | 0x04;
public static final int ERROR_SECURITY_NOT_PROTECTED = ERROR_SECURITY | 0x05;
//Android
public static final int ERROR_ANDROID = 0x1000;
public static final int ERROR_ANDROID_NO_UTILITY_APP = ERROR_ANDROID | 0x01;
public static final int ERROR_ANDROID_SERVICE_DISCONNECTED = ERROR_ANDROID | 0x02;
public static final int ERROR_ANDROID_UTIL_FORCE_DISC = ERROR_ANDROID | 0x03;
public static final int ERROR_ANDROID_UTIL_IDLE_DISC = ERROR_ANDROID | 0x04;
// 0000 - ERROR_NONE
// xx00 - Category / Unknown
// xxyy - Category / Details
private static final SparseArray<String> errorCodeMap;
static
{
errorCodeMap = new SparseArray<String>();
errorCodeMap.put(ERROR_NONE, "None");
errorCodeMap.put(ERROR_UNKNOWN, "Unknown");
//Bluetooth
errorCodeMap.put(ERROR_BLUETOOTH, "Bluetooth");
errorCodeMap.put(ERROR_BLUETOOTH_CONNECTION_FAILED, "Failed to connect");
errorCodeMap.put(ERROR_BLUETOOTH_CONNECTION_LOST, "Connection lost");
errorCodeMap.put(ERROR_BLUETOOTH_NOT_SUPPORTED, "Not supported");
errorCodeMap.put(ERROR_BLUETOOTH_INVALID_MAC, "Invalid MAC");
errorCodeMap.put(ERROR_BLUETOOTH_ECHO_TIMEDOUT, "Echo timedout");
errorCodeMap.put(ERROR_BLUETOOTH_NO_REMOTE_DEVICE, "Can't find remote device");
errorCodeMap.put(ERROR_BLUETOOTH_BT40_NOT_SUPPRTED, "BT 4.0 is not supported");
errorCodeMap.put(ERROR_BLUETOOTH_BT40_NO_SPP_SERVICE, "BT 4.0 RXTX not found");
//Hardware
errorCodeMap.put(ERROR_HARDWARE, "Hardware");
errorCodeMap.put(ERROR_HARDWARE_WDG_RESET, "WDG reset");
//Packet
errorCodeMap.put(ERROR_PACKET, "Invalid packet");
errorCodeMap.put(ERROR_PACKET_INVALID_CRC, "Invalid CRC");
errorCodeMap.put(ERROR_PACKET_INVALID_LENGTH, "Invalid length");
errorCodeMap.put(ERROR_PACKET_INVALID_HEADER, "Invalid header");
//Init
errorCodeMap.put(ERROR_INIT, "Init");
errorCodeMap.put(ERROR_INIT_UNSUPPORTED_CMD, "Command not supported");
errorCodeMap.put(ERROR_INIT_TIMEDOUT, "Timedout");
errorCodeMap.put(ERROR_INIT_FW_TYPE_NOT_SUPPORTED, "FW type not supported");
errorCodeMap.put(ERROR_INIT_FW_VERSION_NOT_SUPPORTED, "FW version not supported");
//Security
errorCodeMap.put(ERROR_SECURITY, "Security");
errorCodeMap.put(ERROR_SECURITY_NOT_SUPPORTED, "Not supported");
errorCodeMap.put(ERROR_SECURITY_NO_KEY, "No key provided");
errorCodeMap.put(ERROR_SECURITY_INVALID_KEY, "Invalid key");
errorCodeMap.put(ERROR_SECURITY_CHALLENGE, "Challenge failed");
errorCodeMap.put(ERROR_SECURITY_NOT_PROTECTED, "Key was provided, but device is not password protected");
//Android
errorCodeMap.put(ERROR_ANDROID, "Android");
errorCodeMap.put(ERROR_ANDROID_NO_UTILITY_APP, "InputStickUtility app not installed");
errorCodeMap.put(ERROR_ANDROID_SERVICE_DISCONNECTED, "Service connection lost");
errorCodeMap.put(ERROR_ANDROID_UTIL_FORCE_DISC, "Connection closed by InputStickUtility");
errorCodeMap.put(ERROR_ANDROID_UTIL_IDLE_DISC, "Connection closed due to inactivity");
}
public static String getErrorType(int errorCode) {
String result;
errorCode &= 0xFF00;
result = errorCodeMap.get(errorCode);
if (result != null) {
return result;
} else {
return ERROR_UNKNOWN_MSG;
}
}
public static String getErrorMessage(int errorCode) {
String result;
if (errorCode == ERROR_NONE) {
return errorCodeMap.get(ERROR_NONE);
}
//handle case: "Bluetooth: Unknown" etc
if ((errorCode & 0x00FF) == 0) {
return ERROR_UNKNOWN_MSG;
}
result = errorCodeMap.get(errorCode);
if (result != null) {
return result;
} else {
return ERROR_UNKNOWN_MSG;
}
}
public static String getFullErrorMessage(int errorCode) {
return getErrorType(errorCode) + " - " + getErrorMessage(errorCode);
}
}

View File

@ -0,0 +1,7 @@
package com.inputstick.api;
public interface InputStickKeyboardListener {
public void onLEDsChanged(boolean numLock, boolean capsLock, boolean scrollLock);
}

View File

@ -0,0 +1,7 @@
package com.inputstick.api;
public interface InputStickStateListener {
public void onStateChanged(int state);
}

View File

@ -0,0 +1,8 @@
package com.inputstick.api;
public interface OnEmptyBufferListener {
public void onLocalBufferEmpty(int interfaceId);
public void onRemoteBufferEmpty(int interfaceId);
}

View File

@ -0,0 +1,144 @@
package com.inputstick.api;
public class Packet {
public static final byte NONE = 0x00;
public static final byte START_TAG = 0x55;
public static final byte FLAG_RESPOND = (byte)0x80;
public static final byte FLAG_ENCRYPTED = 0x40;
public static final int MAX_SUBPACKETS = 17;
public static final int MAX_LENGTH = MAX_SUBPACKETS * 16;
public static final byte CMD_IDENTIFY = 0x01;
public static final byte CMD_LED = 0x02;
public static final byte CMD_RUN_BL = 0x03;
public static final byte CMD_RUN_FW = 0x04;
public static final byte CMD_GET_INFO = 0x05;
public static final byte CMD_BL_ERASE = 0x06;
public static final byte CMD_ADD_DATA = 0x07;
public static final byte CMD_BL_WRITE = 0x08;
public static final byte CMD_FW_INFO = 0x10;
public static final byte CMD_INIT = 0x11;
public static final byte CMD_INIT_AUTH = 0x12;
public static final byte CMD_INIT_CON = 0x13;
public static final byte CMD_SET_VALUE = 0x14;
public static final byte CMD_RESTORE_DEFAULTS = 0x15;
public static final byte CMD_RESTORE_STATUS = 0x16;
public static final byte CMD_GET_VALUE = 0x17;
public static final byte CMD_SET_PIN = 0x18;
public static final byte CMD_USB_RESUME = 0x19;
public static final byte CMD_USB_POWER = 0x1A;
public static final byte CMD_SYSTEM_NOTIFICATION = 0x1F;
public static final byte CMD_HID_STATUS_REPORT = 0x20;
public static final byte CMD_HID_DATA_KEYB = 0x21;
public static final byte CMD_HID_DATA_CONSUMER = 0x22;
public static final byte CMD_HID_DATA_MOUSE = 0x23;
public static final byte CMD_HID_DATA_GAMEPAD = 0x24;
public static final byte CMD_HID_DATA_ENDP = 0x2B;
public static final byte CMD_HID_DATA_KEYB_FAST = 0x2C;
public static final byte CMD_HID_DATA_KEYB_FASTEST = 0x2D;
//out
public static final byte CMD_HID_STATUS = 0x2F;
public static final byte CMD_DUMMY = (byte)0xFF;
public static final byte RESP_OK = 0x01;
public static final byte RESP_UNKNOWN_CMD = (byte)0xFF;
public static final byte[] RAW_OLD_BOOTLOADER = new byte[] {START_TAG, (byte)0x00, (byte)0x02, (byte)0x83, (byte)0x00, (byte)0xDA};
public static final byte[] RAW_DELAY_1_MS = new byte[] {0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01};
private byte[] mData;
private int mPos;
private boolean mRespond;
//do not modify
public Packet(boolean respond, byte[] data) {
mRespond = respond;
mData = data;
mPos = data.length;
}
public Packet(boolean respond, byte cmd, byte param, byte[] data) {
mRespond = respond;
mData = new byte[MAX_LENGTH];
mData[0] = cmd;
mData[1] = param;
mPos = 2;
if (data != null) {
addBytes(data);
}
}
public Packet(boolean respond, byte cmd, byte param) {
this(respond, cmd, param, null);
}
public Packet(boolean respond, byte cmd) {
mRespond = respond;
mData = new byte[MAX_LENGTH];
mData[0] = cmd;
mPos = 1;
}
public void modifyByte(int pos, byte b) {
mData[pos] = b;
}
public void addBytes(byte[] data) {
//TODO check null pointer / available size (MAX_PAYLOAD - mPos)
System.arraycopy(data, 0, mData, mPos, data.length);
mPos += data.length;
}
public void addByte(byte b) {
mData[mPos++] = b;
}
public void addInt16(int val) {
mData[mPos + 0] = Util.getMSB(val);
mData[mPos + 1] = Util.getLSB(val);
mPos += 2;
}
public void addInt32(long val) {
mData[mPos + 3] = (byte)val;
val >>= 8;
mData[mPos + 2] = (byte)val;
val >>= 8;
mData[mPos + 1] = (byte)val;
val >>= 8;
mData[mPos + 0] = (byte)val;
val >>= 8;
mPos += 4;
}
public byte[] getBytes() {
byte[] result;
result = new byte[mPos];
System.arraycopy(mData, 0, result, 0, mPos);
return result;
}
public boolean getRespond() {
return mRespond;
}
public void print() {
Util.printHex(mData, "PACKET DATA:");
}
}

View File

@ -0,0 +1,185 @@
package com.inputstick.api;
import java.util.Arrays;
import java.util.Random;
import java.util.zip.CRC32;
import com.inputstick.api.bluetooth.BTService;
public class PacketManager {
public static final int MAX_PAYLAOD = 64;
public static final int HEADER_OFFSET = 2;
public static final int CRC_OFFSET = 4;
public static final int PACKET_SIZE = 16;
private final BTService mBTService;
private final AES mAes;
private final byte[] mKey;
private byte[] cmpData;
private final CRC32 mCrc;
private boolean mEncryption;
public PacketManager(BTService btService, byte[] key) {
mBTService = btService;
mCrc = new CRC32();
mAes = new AES();
mKey = key;
mEncryption = false;
}
public boolean setEncryption(byte[] cmp, boolean encryptOut) {
byte[] cmpDec = mAes.decrypt(cmp);
if (Arrays.equals(cmpDec, cmpData)) {
mEncryption = encryptOut;
return true;
} else {
mEncryption = false;
return false;
}
}
public boolean isEncrypted() {
return mEncryption;
}
public Packet encPacket(boolean enable) {
Random r = new Random();
Packet p = new Packet(true, Packet.CMD_INIT_AUTH);
if (enable) {
p.addByte((byte)1);
} else {
p.addByte((byte)0);
}
byte[] iv = mAes.init(mKey);
p.addBytes(iv);
//Util.printHex(mKey, "key: "); // TODO prnt
//Util.printHex(iv, "IV: ");
byte[] initData = new byte[16];
r.nextBytes(initData);
mCrc.reset();
mCrc.update(initData, 4, 12); //only 12 bytes!
long crcValue = mCrc.getValue();
initData[3] = (byte)crcValue;
crcValue >>= 8;
initData[2] = (byte)crcValue;
crcValue >>= 8;
initData[1] = (byte)crcValue;
crcValue >>= 8;
initData[0] = (byte)crcValue;
initData = mAes.encrypt(initData);
p.addBytes(initData);
//Util.printHex(initData, "InitData: ");
cmpData = new byte[16];
r.nextBytes(cmpData);
p.addBytes(cmpData);
//Util.printHex(cmpData, "CmpData: ");
return p;
}
public byte[] bytesToPacket(byte[] data) {
byte[] payload;
//boolean decrypt = false;
long crcValue, crcCompare;
//Util.printHex(data, "RX DATA: "); // TODO prnt
payload = Arrays.copyOfRange(data, 2, data.length); //remove TAG, info
if ((data[1] & Packet.FLAG_ENCRYPTED) != 0) {
//Util.log("DECRYPT");
if (mAes.isReady()) {
payload = mAes.decrypt(payload);
//Util.printHex(payload, "RX DECR: "); // TODO prnt
} else {
return null;
}
}
//Util.printHex(payload, "DATA IN: ");
//check CRC
crcCompare = Util.getLong(payload[0], payload[1], payload[2], payload[3]);
mCrc.reset();
mCrc.update(payload, CRC_OFFSET, payload.length - CRC_OFFSET);
crcValue = mCrc.getValue();
//System.out.println("CMP: " + crcCompare + " VAL: " + crcValue);
if (crcValue == crcCompare) {
payload = Arrays.copyOfRange(payload, 4, payload.length); //remove CRC
//Util.printHex(payload, "RX PAYLOAD FINAL: "); // TODO prnt
return payload;
} else {
return null; //TODO
}
}
public void sendRAW(byte[] data) {
mBTService.write(data);
}
public void sendPacket(Packet p) {
if (p != null) {
sendPacket(p, mEncryption);
}
}
public void sendPacket(Packet p, boolean encrypt) {
byte[] result, header, data;
int length;
int packets;
long crcValue;
//if data > MAX_PAYLAOD -> error
data = p.getBytes();
length = data.length + CRC_OFFSET; //include 4bytes for CRC32
packets = ((length - 1) >> 4) + 1; //how many 16 bytes data sub-packets are necessary
result = new byte[packets * PACKET_SIZE];
System.arraycopy(data, 0, result, CRC_OFFSET, data.length);
//add CRC32
mCrc.reset();
mCrc.update(result, CRC_OFFSET, result.length - CRC_OFFSET);
crcValue = mCrc.getValue();
//Util.log("CRC: "+crcValue);
result[3] = (byte)crcValue;
crcValue >>= 8;
result[2] = (byte)crcValue;
crcValue >>= 8;
result[1] = (byte)crcValue;
crcValue >>= 8;
result[0] = (byte)crcValue;
//Util.printHex(result, "TX DATA: "); // TODO prnt
if (encrypt) {
result = mAes.encrypt(result);
//Util.printHex(result, "ENC DATA: "); // TODO prnt
}
header = new byte[2];
header[0] = Packet.START_TAG;
header[1] = (byte)packets;
if (encrypt) {
header[1] |= Packet.FLAG_ENCRYPTED;
}
if (p.getRespond()) {
header[1] |= Packet.FLAG_RESPOND;
}
//Util.printHex(header, "TX HEADER: "); // TODO prnt
mBTService.write(header);
mBTService.write(result);
}
}

View File

@ -0,0 +1,121 @@
package com.inputstick.api;
import android.annotation.SuppressLint;
import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
public abstract class Util {
public static boolean debug = false;
public static boolean flashingToolMode = false;
public static void log(String msg) {
log(msg, false);
}
public static void log(String msg, boolean displayTime) {
if (debug) {
System.out.print("LOG: " + msg);
if (displayTime) {
System.out.print(" @ " + System.currentTimeMillis());
}
System.out.println();
}
}
public static void printHex(byte[] toPrint, String info) {
if (debug) {
System.out.println(info);
printHex(toPrint);
}
}
@SuppressLint("DefaultLocale")
public static String byteToHexString(byte b) {
String s;
//0x0..0xF = 0x00..0x0F
if ((b < 0x10) && (b >= 0)) {
s = Integer.toHexString((int)b);
s = "0" + s;
} else {
s = Integer.toHexString((int)b);
if (s.length() > 2) {
s = s.substring(s.length() - 2);
}
}
s = s.toUpperCase();
return s;
}
public static void printHex(byte[] toPrint) {
if (debug) {
if (toPrint != null) {
int cnt = 0;
byte b;
for (int i = 0; i < toPrint.length; i++) {
b = toPrint[i];
System.out.print("0x" + byteToHexString(b) + " ");
cnt++;
if (cnt == 8) {
System.out.println("");
cnt = 0;
}
}
} else {
System.out.println("null");
}
System.out.println("\n#####");
}
}
public static byte getLSB(int n) {
return (byte)(n & 0x00FF);
}
public static byte getMSB(int n) {
return (byte)((n & 0xFF00) >> 8);
}
public static int getInt(byte b) {
int bInt = b & 0xFF;
return bInt;
}
public static int getInt(byte msb, byte lsb) {
int msbInt = msb & 0xFF;
int lsbInt = lsb & 0xFF;
return (msbInt << 8) + lsbInt;
}
public static long getLong(byte b0, byte b1, byte b2, byte b3) {
long result;
result = (b0) & 0xFF;
result <<= 8;
result += (b1) & 0xFF;
result <<= 8;
result += (b2) & 0xFF;
result <<= 8;
result += (b3) & 0xFF;
return result;
}
public static byte[] getPasswordBytes(String plainText) {
try {
MessageDigest md = MessageDigest.getInstance("MD5");
return md.digest(plainText.getBytes("UTF-8"));
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
return null;
}
}

View File

@ -0,0 +1,89 @@
package com.inputstick.api.basic;
import com.inputstick.api.hid.ConsumerReport;
import com.inputstick.api.hid.HIDTransaction;
public class InputStickConsumer {
//CONSUMER PAGE (consumerAction)
public static final int VOL_UP = 0x00E9;
public static final int VOL_DOWN = 0x00EA;
public static final int VOL_MUTE = 0x00E2;
public static final int TRACK_NEXT = 0x00B5;
public static final int TRACK_PREV = 0x00B6;
public static final int STOP = 0x00B7;
public static final int PLAY_PAUSE = 0x00CD;
public static final int LAUNCH_BROWSER = 0x0196;
public static final int LAUNCH_EMAIL = 0x018A;
public static final int LAUNCH_CALC = 0x0192;
//Android OS (consumer):
public static final int HOME = 0x0223;
public static final int BACK = 0x0224;
public static final int SEARCH = 0x0221;
//SYSTEM PAGE (systemAction)
public static final byte SYSTEM_POWER_DOWN = 0x01;
public static final byte SYSTEM_SLEEP = 0x02;
public static final byte SYSTEM_WAKEUP = 0x03;
private InputStickConsumer() {
}
/*
* Use only for system actions SYSTEM_POWER_DOWN, SYSTEM_SLEEP and SYSTEM_WAKEUP
*
* @param action code of system action
*/
public static void systemAction(byte action) {
HIDTransaction t = new HIDTransaction();
t.addReport(new ConsumerReport(ConsumerReport.SYSTEM_REPORT_ID, action, (byte)0));
t.addReport(new ConsumerReport(ConsumerReport.SYSTEM_REPORT_ID, (byte)0, (byte)0));
InputStickHID.addConsumerTransaction(t);
}
/*
* Requests USB host to power down. Must be supported and enabled by USB host.
*/
public static void systemPowerDown() {
systemAction(SYSTEM_POWER_DOWN);
}
/*
* Requests USB host to go into sleep/standby mode. Must be supported and enabled by USB host.
*/
public static void systemSleep() {
systemAction(SYSTEM_SLEEP);
}
/*
* Requests USB host to resume from sleep/standby mode. Must be supported and enabled by USB host.
* Note: USB host must supply USB power when suspended. Otherwise InputStick will not work.
*/
public static void systemWakeUp() {
systemAction(SYSTEM_WAKEUP);
}
/*
* Consumer control action: media playback, volume etc.
* See http://www.usb.org/developers/hidpage/Hut1_12v2.pdf (consumer page).
* USB host may not support certain action codes
*
* @param action code of consumer control action
*/
public static void consumerAction(int action) {
HIDTransaction t = new HIDTransaction();
t.addReport(new ConsumerReport(action));
t.addReport(new ConsumerReport());
InputStickHID.addConsumerTransaction(t);
}
}

View File

@ -0,0 +1,38 @@
package com.inputstick.api.basic;
import com.inputstick.api.Packet;
public class InputStickGamepad {
private InputStickGamepad() {
}
/*
* Sends custom HID gamepad report
*
* @param buttons1 state (on/off) of buttons0..7
* @param buttons2 state (on/off) of buttons8..15
* @param x value of X axis
* @param y value of Y axis
* @param z value of Z axis
* @param rx value of rX axis
*/
public static void customReport(byte buttons1, byte buttons2, byte x, byte y, byte z, byte rX) {
if (InputStickHID.isReady()) {
Packet p = new Packet(false, (byte)0x2B, (byte)0x03); //write directly to endp3in, no buffering
p.addByte((byte)0x07); //report bytes cnt
p.addByte((byte)0x03); //report ID
p.addByte(buttons1);
p.addByte(buttons2);
p.addByte(x);
p.addByte(y);
p.addByte(z);
p.addByte(rX);
InputStickHID.sendPacket(p);
}
}
}

View File

@ -0,0 +1,602 @@
package com.inputstick.api.basic;
import java.util.Timer;
import java.util.TimerTask;
import java.util.Vector;
import android.app.AlertDialog;
import android.app.Application;
import android.content.Context;
import com.inputstick.api.BTConnectionManager;
import com.inputstick.api.ConnectionManager;
import com.inputstick.api.DownloadDialog;
import com.inputstick.api.HIDInfo;
import com.inputstick.api.IPCConnectionManager;
import com.inputstick.api.InputStickDataListener;
import com.inputstick.api.InputStickError;
import com.inputstick.api.InputStickStateListener;
import com.inputstick.api.OnEmptyBufferListener;
import com.inputstick.api.Packet;
import com.inputstick.api.hid.HIDReport;
import com.inputstick.api.hid.HIDTransaction;
import com.inputstick.api.hid.HIDTransactionQueue;
import com.inputstick.api.init.BasicInitManager;
import com.inputstick.api.init.DeviceInfo;
import com.inputstick.api.init.InitManager;
public class InputStickHID implements InputStickStateListener, InputStickDataListener {
public static final int INTERFACE_KEYBOARD = 0;
public static final int INTERFACE_CONSUMER = 1;
public static final int INTERFACE_MOUSE = 2;
private static ConnectionManager mConnectionManager;
private static Vector<InputStickStateListener> mStateListeners = new Vector<InputStickStateListener>();
protected static Vector<OnEmptyBufferListener> mBufferEmptyListeners = new Vector<OnEmptyBufferListener>();
private static InputStickHID instance = new InputStickHID();
private static HIDInfo mHIDInfo;
private static DeviceInfo mDeviceInfo;
private static HIDTransactionQueue keyboardQueue;
private static HIDTransactionQueue mouseQueue;
private static HIDTransactionQueue consumerQueue;
//FW 0.93 - 0.95
private static Timer updateQueueTimer;
private static int mKeyboardReportMultiplier; //enables "slow" typing by multiplying HID reports
private InputStickHID() {
}
public static InputStickHID getInstance() {
return instance;
}
private static void init() {
mHIDInfo = new HIDInfo();
keyboardQueue = new HIDTransactionQueue(INTERFACE_KEYBOARD, mConnectionManager);
mouseQueue = new HIDTransactionQueue(INTERFACE_MOUSE, mConnectionManager);
consumerQueue = new HIDTransactionQueue(INTERFACE_CONSUMER, mConnectionManager);
mConnectionManager.addStateListener(instance);
mConnectionManager.addDataListener(instance);
mConnectionManager.connect();
}
/*
* Returns download InputStickUtility AlertDialog if InputStickUtility is not installed. Returns null is InputStickUtility application is installed.
* Should be called when your application is started or before InputStick functionality is about to be used.
*
* @return download InputStickUtility AlertDialog or null
*/
public static AlertDialog getDownloadDialog(final Context ctx) {
if (mConnectionManager.getErrorCode() == InputStickError.ERROR_ANDROID_NO_UTILITY_APP) {
return DownloadDialog.getDialog(ctx, DownloadDialog.NOT_INSTALLED);
} else {
return null;
}
}
/*
* Connect using InputStickUtility application.
* IN MOST CASES THIS METHOD SHOULD BE USED TO INITIATE CONNECTION!
*
* @param app Application
*/
public static void connect(Application app) {
mConnectionManager = new IPCConnectionManager(app);
init();
}
/*
* Close connection
*/
public static void disconnect() {
if (mConnectionManager != null) {
mConnectionManager.disconnect();
}
}
/*
* Direct connection to InputStick (BT2.1 only!). InputStickUtility application is not required in this case.
* TIP: use Util.getPasswordBytes(plainText) to get key.
*
* @param app Application
* @param mac Bluetooth MAC address
* @param key MD5(password) - must be provided if InputStick is password protected. Use null otherwise
* @param initManager custom init manager
*/
public static void connect(Application app, String mac, byte[] key, InitManager initManager) {
connect(app, mac, key, initManager, false);
}
/*
* Direct connection to InputStick. InputStickUtility application is not required in this case.
* TIP: use Util.getPasswordBytes(plainText) to get key.
*
* @param app Application
* @param mac Bluetooth MAC address
* @param key MD5(password) - must be provided if InputStick is password protected. Use null otherwise
* @param initManager custom init manager
* @param isBT40 specify Bluetooth version. Must match your hardware (InputStick BT2.1 or BT4.0)!
*/
public static void connect(Application app, String mac, byte[] key, InitManager initManager, boolean isBT40) {
mConnectionManager = new BTConnectionManager(initManager, app, mac, key, isBT40);
init();
}
/*
* Direct connection to InputStick. InputStickUtility application is not required in this case.
* TIP: use Util.getPasswordBytes(plainText) to get key.
*
* @param app Application
* @param mac Bluetooth MAC address
* @param key MD5(password) - must be provided if InputStick is password protected. Use null otherwise
* @param initManager custom init manager
* @param isBT40 specify Bluetooth version. Must match your hardware (InputStick BT2.1 or BT4.0)!
*/
public static void connect(Application app, String mac, byte[] key, boolean isBT40) {
mConnectionManager = new BTConnectionManager(new BasicInitManager(key), app, mac, key, isBT40);
init();
}
/*
* Direct connection to InputStick (BT2.1 only!). InputStickUtility application is not required in this case.
* TIP: use Util.getPasswordBytes(plainText) to get key.
*
* @param app Application
* @param mac Bluetooth MAC address
* @param key MD5(password) - must be provided if InputStick is password protected. Use null otherwise
*/
public static void connect(Application app, String mac, byte[] key) {
connect(app, mac, key, false);
}
/*
* When keyboard transactions are queued, each individual HID keyboard report is duplicated by reportMultiplier.
* Allows to control typing speed. Can help with missing characters (for example in BIOS).
* Important! Value of multiplier should be manually restored back to 1, when slow typing is no longer needed!
*
* Example: press and release "a" key:
* 1) Multiplier = 1
* "a" key presses, all keys released
* 2 HID reports, fastest typing speed
* 2) Multiplier = 2
* "a" key presses, "a" key presses, all keys released, all keys released
* 4 HID reports, 50% slower typing speed
*
*
* @param reportMultiplier number by which each HID report will be duplicated
*/
public static void setKeyboardReportMultiplier(int reportMultiplier) {
mKeyboardReportMultiplier = reportMultiplier;
}
/*
* Returns value of keyboard report multiplier
*
* @return keyboard report multiplier
*/
public static int getKeyboardReportMultiplier(int reportMultiplier) {
return mKeyboardReportMultiplier;
}
/*
* Requests USB host to resume from sleep / suspended state. Feature must be supported and enabled by USB host.
* Note 1: when USB host is suspended, device state will be STATE_CONNECTED.
* Note 2: some USB hosts may cut off USB power when suspended.
*/
public static void wakeUpUSBHost() {
if (isConnected()) {
Packet p = new Packet(false, Packet.CMD_USB_RESUME);
InputStickHID.sendPacket(p);
mConnectionManager.sendPacket(p);
}
}
/*
* Get device info of connected device
*
* @return Device info of connected device. Null if info is not available
*/
public static DeviceInfo getDeviceInfo() {
if ((isReady()) && (mDeviceInfo != null)) {
return mDeviceInfo;
} else {
return null;
}
}
/*
* Get latest status update received from InputStick.
*
* @return latest status update
*/
public static HIDInfo getHIDInfo() {
return mHIDInfo;
}
/*
* Returns current state of the connection.
*
* @return state of the connection
*/
public static int getState() {
if (mConnectionManager != null) {
return mConnectionManager.getState();
} else {
return ConnectionManager.STATE_DISCONNECTED;
}
}
/*
* Returns last error code. See class InputStickError.
*
* @return last error code
*/
public static int getErrorCode() {
if (mConnectionManager != null) {
return mConnectionManager.getErrorCode();
} else {
return InputStickError.ERROR_UNKNOWN;
}
}
/*
* Checks if Bluetooth connection between Android device and InputStick is established.
* Note - InputStick may be not ready yet to accept keyboard/mouse data.
*
* @return true if Bluetooth connection is established
*/
public static boolean isConnected() {
if ((getState() == ConnectionManager.STATE_READY) || (getState() == ConnectionManager.STATE_CONNECTED)) {
return true;
} else {
return false;
}
}
/*
* Checks if InputStick is ready to accept keyboard/mouse/etc. data.
*
* @return true if InputStick is ready to accept data
*/
public static boolean isReady() {
if (getState() == ConnectionManager.STATE_READY) {
return true;
} else {
return false;
}
}
/*
* Adds InputStickStateListener. Listener will be notified when connection state changes.
*
* @param listener listener to add
*/
public static void addStateListener(InputStickStateListener listener) {
if (listener != null) {
if ( !mStateListeners.contains(listener)) {
mStateListeners.add(listener);
}
}
}
/*
* Removes InputStickStateListener. Listener will no longer be notified when connection state changes.
*
* @param listener listener to remove
*/
public static void removeStateListener(InputStickStateListener listener) {
if (listener != null) {
mStateListeners.remove(listener);
}
}
/*
* Adds OnEmptyBufferListener. Listeners will be notified when local (application) or remote (InputStick) HID report buffer is empty.
*
* @param listener listener to add
*/
public static void addBufferEmptyListener(OnEmptyBufferListener listener) {
if (listener != null) {
if ( !mBufferEmptyListeners.contains(listener)) {
mBufferEmptyListeners.add(listener);
}
}
}
/*
* Removes OnEmptyBufferListener.
*
* @param listener listener to remove
*/
public static void removeBufferEmptyListener(OnEmptyBufferListener listener) {
if (listener != null) {
mBufferEmptyListeners.remove(listener);
}
}
/*
* Returns vector with registered OnEmptyBuffer listeners.
*
* @return vector with OnEmptyBuffer listeners
*/
public static Vector<OnEmptyBufferListener> getBufferEmptyListeners() {
return mBufferEmptyListeners;
}
/*
* Adds transaction to keyboard queue.
* If possible, all reports form a single transactions will be sent in a single packet.
* This should prevent from key being stuck in pressed position when connection is suddenly lost.
*
* @param transaction transaction to be queued
*/
public static void addKeyboardTransaction(HIDTransaction transaction) {
if ((transaction != null) && (keyboardQueue != null)) {
//keyboardQueue.addTransaction(transaction);
if (mKeyboardReportMultiplier > 1) {
HIDTransaction multipliedTransaction = new HIDTransaction();
HIDReport r;
for (int i = 0; i < transaction.getReportsCount(); i++) {
r = transaction.getHIDReportAt(i);
for (int j = 0; j < mKeyboardReportMultiplier; j++) {
multipliedTransaction.addReport(r);
}
}
keyboardQueue.addTransaction(multipliedTransaction);
} else {
keyboardQueue.addTransaction(transaction);
}
}
}
/*
* Adds transaction to mouse queue.
* If possible, all reports form a single transactions will be sent in a single packet.
*
* @param transaction transaction to be queued
*/
public static void addMouseTransaction(HIDTransaction transaction) {
if ((transaction != null) && (mouseQueue != null)) {
mouseQueue.addTransaction(transaction);
}
}
/*
* Adds transaction to consumer control queue.
* If possible, all reports form a single transactions will be sent in a single packet.
*
* @param transaction transaction to be queued
*/
public static void addConsumerTransaction(HIDTransaction transaction) {
if ((transaction != null) && (consumerQueue != null)) {
consumerQueue.addTransaction(transaction);
}
}
/*
* Removes all reports from keyboard buffer.
*/
public static void clearKeyboardBuffer() {
if (keyboardQueue != null) {
keyboardQueue.clearBuffer();
}
}
/*
* Removes all reports from mouse buffer.
*/
public static void clearMouseBuffer() {
if (mouseQueue != null) {
mouseQueue.clearBuffer();
}
}
/*
* Removes all reports from consumer control buffer.
*/
public static void clearConsumerBuffer() {
if (consumerQueue != null) {
consumerQueue.clearBuffer();
}
}
/*
* Sends custom packet to InputStick.
*
* @param p packet to send.
*/
public static boolean sendPacket(Packet p) {
if (mConnectionManager != null) {
mConnectionManager.sendPacket(p);
return true;
} else {
return false;
}
}
/*
* Checks if local (Android device) keyboard report buffer is empty. It is possible that there are reports queued in InputStick's buffer.
*
* @return true if local keyboard buffer is empty, false otherwise
*/
public static boolean isKeyboardLocalBufferEmpty() {
if (keyboardQueue != null) {
return keyboardQueue.isLocalBufferEmpty();
} else {
return true;
}
}
/*
* Checks if local (Android device) mouse report buffer is empty. It is possible that there are reports queued in InputStick's buffer.
*
* @return true if local mouse buffer is empty, false otherwise
*/
public static boolean isMouseLocalBufferEmpty() {
if (mouseQueue != null) {
return mouseQueue.isLocalBufferEmpty();
} else {
return true;
}
}
/*
* Checks if local (Android device) consumer control report buffer is empty. It is possible that there are reports queued in InputStick's buffer.
*
* @return true if local consumer control buffer is empty, false otherwise
*/
public static boolean isConsumerLocalBufferEmpty() {
if (consumerQueue != null) {
return consumerQueue.isLocalBufferEmpty();
} else {
return true;
}
}
/*
* Checks if local (Android device) AND remote (InputStick) keyboard report buffers are empty.
*
* @return true if local and remote keyboard buffers are empty, false otherwise
*/
public static boolean isKeyboardRemoteBufferEmpty() {
if (keyboardQueue != null) {
return keyboardQueue.isRemoteBufferEmpty();
} else {
return true;
}
}
/*
* Checks if local (Android device) AND remote (InputStick) mouse report buffers are empty.
*
* @return true if local and remote mouse buffers are empty, false otherwise
*/
public static boolean isMouseRemoteBufferEmpty() {
if (mouseQueue != null) {
return mouseQueue.isRemoteBufferEmpty();
} else {
return true;
}
}
/*
* Checks if local (Android device) AND remote (InputStick) consumer control report buffers are empty.
*
* @return true if local and remote consumer control buffers are empty, false otherwise
*/
public static boolean isConsumerRemoteBufferEmpty() {
if (consumerQueue != null) {
return consumerQueue.isRemoteBufferEmpty();
} else {
return true;
}
}
@Override
public void onStateChanged(int state) {
if ((state == ConnectionManager.STATE_DISCONNECTED) && (updateQueueTimer != null)) {
updateQueueTimer.cancel();
updateQueueTimer = null;
}
for (InputStickStateListener listener : mStateListeners) {
listener.onStateChanged(state);
}
}
@Override
public void onInputStickData(byte[] data) {
byte cmd = data[0];
if (cmd == Packet.CMD_FW_INFO) {
mDeviceInfo = new DeviceInfo(data);
}
if (cmd == Packet.CMD_HID_STATUS) {
mHIDInfo.update(data);
if (mHIDInfo.isSentToHostInfoAvailable()) {
// >= FW 0.93
keyboardQueue.deviceReady(mHIDInfo, mHIDInfo.getKeyboardReportsSentToHost());
mouseQueue.deviceReady(mHIDInfo, mHIDInfo.getMouseReportsSentToHost());
consumerQueue.deviceReady(mHIDInfo, mHIDInfo.getConsumerReportsSentToHost());
if (mDeviceInfo != null) {
if ((updateQueueTimer == null) && (mDeviceInfo.getFirmwareVersion() < 97)) {
updateQueueTimer = new Timer();
updateQueueTimer.schedule(new TimerTask() {
@Override
public void run() {
keyboardQueue.sendToBuffer(false);
mouseQueue.sendToBuffer(false);
consumerQueue.sendToBuffer(false);
}
}, 5, 5);
}
}
} else {
//previous FW versions
if (mHIDInfo.isKeyboardReady()) {
keyboardQueue.deviceReady(null, 0);
}
if (mHIDInfo.isMouseReady()) {
mouseQueue.deviceReady(null, 0);
}
if (mHIDInfo.isConsumerReady()) {
consumerQueue.deviceReady(null, 0);
}
}
InputStickKeyboard.setLEDs(mHIDInfo.getNumLock(), mHIDInfo.getCapsLock(), mHIDInfo.getScrollLock());
}
}
}

View File

@ -0,0 +1,263 @@
package com.inputstick.api.basic;
import java.util.Vector;
import android.util.SparseArray;
import com.inputstick.api.InputStickKeyboardListener;
import com.inputstick.api.hid.HIDKeycodes;
import com.inputstick.api.hid.HIDTransaction;
import com.inputstick.api.hid.KeyboardReport;
import com.inputstick.api.layout.KeyboardLayout;
public class InputStickKeyboard {
private static final byte NONE = (byte)0;
private static final byte LED_NUM_LOCK = 1;
private static final byte LED_CAPS_LOCK = 2;
private static final byte LED_SCROLL_LOCK = 4;
private static boolean mReportProtocol;
private static boolean mNumLock;
private static boolean mCapsLock;
private static boolean mScrollLock;
private static Vector<InputStickKeyboardListener> mKeyboardListeners = new Vector<InputStickKeyboardListener>();
private static final SparseArray<String> ledsMap;
static
{
ledsMap = new SparseArray<String>();
ledsMap.put(LED_NUM_LOCK, "NumLock");
ledsMap.put(LED_CAPS_LOCK, "CapsLock");
ledsMap.put(LED_SCROLL_LOCK, "ScrollLock");
}
private InputStickKeyboard() {
}
/*
* Uses InputStick to press and then immediately release key combination specified by parameters.
*
* @param modifier state of modifier keys (CTRL_LEFT .. GUI_RIGHT, see HIDKeycodes)
* @param key non-modifier key (see HIDKeycodes)
*/
public static void pressAndRelease(byte modifier, byte key) {
HIDTransaction t = new HIDTransaction();
t.addReport(new KeyboardReport(modifier, NONE));
t.addReport(new KeyboardReport(modifier, key));
t.addReport(new KeyboardReport(NONE, NONE));
InputStickHID.addKeyboardTransaction(t);
}
/*
* Type text via InputStick, using selected keyboard layout. USB host must use matching keyboard layout.
* For available keyboard layouts see: com.inputstick.api.layout.
* If layout is null or not found, en-US will be used.
*
* @param toType text to type
* @param layoutCode code of keyboard layout ("en-US", "de-DE", etc.)
*/
public static void type(String toType, String layoutCode) {
KeyboardLayout layout = KeyboardLayout.getLayout(layoutCode);
layout.type(toType);
}
/*
* Type text via InputStick. ASCII characters only! It is assumed that USB host uses en-US keyboard layout.
*
* @param toType text to type
*/
public static void typeASCII(String toType) {
int keyCode;
int index;
for (int i = 0; i < toType.length(); i++) {
index = toType.charAt(i);
if (index == '\n') {
pressAndRelease(NONE, HIDKeycodes.KEY_ENTER);
} else if (index == '\t') {
pressAndRelease(NONE, HIDKeycodes.KEY_TAB);
} else {
if (index > 127) {
index = 127;
}
keyCode = HIDKeycodes.getKeyCode(index);
if (keyCode > 128) {
keyCode -= 128;
pressAndRelease(HIDKeycodes.SHIFT_LEFT, (byte)keyCode);
} else {
pressAndRelease(NONE, (byte)keyCode);
}
}
}
}
/*
* Sends custom keyboard HID report.
* Note: keys must be "manually" released by sending next custom HID report (with 0x00s as key0..key5).
*
* @param modifier state of modifier keys (CTRL_LEFT .. GUI_RIGHT, see HIDKeycodes)
* @param key0 non modifier keyboard key (see HIDKeycodes). Use 0x00 when no key is pressed.
* @param key1 non modifier keyboard key (see HIDKeycodes). Use 0x00 when no key is pressed.
* @param key2 non modifier keyboard key (see HIDKeycodes). Use 0x00 when no key is pressed.
* @param key3 non modifier keyboard key (see HIDKeycodes). Use 0x00 when no key is pressed.
* @param key4 non modifier keyboard key (see HIDKeycodes). Use 0x00 when no key is pressed.
* @param key5 non modifier keyboard key (see HIDKeycodes). Use 0x00 when no key is pressed.
*/
public static void customReport(byte modifier, byte key0, byte key1, byte key2, byte key3, byte key4, byte key5) {
HIDTransaction t = new HIDTransaction();
t.addReport(new KeyboardReport(modifier, key0, key1, key2, key3, key4, key5));
InputStickHID.addKeyboardTransaction(t);
}
/*
* Checks is report protocol is used.
* Report protocol is in most cases used by OS
* Boot protocol is used by BIOS, or when OS is booting
*
* @return true if USB host uses report protocol, false if USB host uses boot protocol
*/
public boolean isReportProtocol() {
return mReportProtocol;
}
/*
* Checks states of NumLock keyboard LED
*
* @return true if NumLock LED is on, false if off.
*/
public static boolean isNumLock() {
return mNumLock;
}
/*
* Checks states of CapsLock keyboard LED
*
* @return true if CapsLock LED is on, false if off.
*/
public static boolean isCapsLock() {
return mCapsLock;
}
/*
* Checks states of ScrollLock keyboard LED
*
* @return true if ScrollLock LED is on, false if off.
*/
public static boolean isScrollLock() {
return mScrollLock;
}
/*
* Toggle state of NumLock by press and release NumLock key.
*/
public static void toggleNumLock() {
pressAndRelease(NONE, HIDKeycodes.KEY_NUM_LOCK);
}
/*
* Toggle state of CapsLock by press and release CapsLock key.
*/
public static void toggleCapsLock() {
pressAndRelease(NONE, HIDKeycodes.KEY_CAPS_LOCK);
}
/*
* Toggle state of ScrollLock by press and release ScrollLock key.
*/
public static void toggleScrollLock() {
pressAndRelease(NONE, HIDKeycodes.KEY_SCROLL_LOCK);
}
/*
* Converts state of keyboard LEDs to String. Example: "CapsLock, ScrollLock".
*
* @return String description of keyboard LEDs.
*/
public static String ledsToString(byte leds) {
String result = "None";
boolean first = true;
byte mod;
for (int i = 0; i < 8; i++) {
mod = (byte)(LED_NUM_LOCK << i);
if ((leds & mod) != 0) {
if ( !first) {
result += ", ";
} else {
result = "";
}
first = false;
result += ledsMap.get(mod);
}
}
return result;
}
/*
* Adds InputStickKeyboardListener. Listener will be notified when state of keyboard LEDs changes (NumLock, CapsLock, ScrollLock).
*
* @param listener listener to add
*/
public static void addKeyboardListener(InputStickKeyboardListener listener) {
if (listener != null) {
if ( !mKeyboardListeners.contains(listener)) {
mKeyboardListeners.add(listener);
}
}
}
/*
* Removes InputStickKeyboardListener.
*
* @param listener listener to remove
*/
public static void removeKeyboardListener(InputStickKeyboardListener listener) {
if (listener != null) {
mKeyboardListeners.remove(listener);
}
}
protected void setReportProtocol(boolean reportProtocol) {
mReportProtocol = reportProtocol;
}
protected static void setLEDs(boolean numLock, boolean capsLock, boolean scrollLock) {
boolean mustUpdate = false;
if ((numLock != mNumLock) || (capsLock != mCapsLock) || (scrollLock != mScrollLock)) {
mustUpdate = true;
}
mNumLock = numLock;
mCapsLock = capsLock;
mScrollLock = scrollLock;
if (mustUpdate) {
for (InputStickKeyboardListener listener : mKeyboardListeners) {
listener.onLEDsChanged(mNumLock, mCapsLock, mScrollLock);
}
}
}
}

View File

@ -0,0 +1,131 @@
package com.inputstick.api.basic;
import android.util.SparseArray;
import com.inputstick.api.hid.HIDTransaction;
import com.inputstick.api.hid.MouseReport;
public class InputStickMouse {
private static final byte NONE = 0x00;
public static final byte BUTTON_NONE = 0x00;
public static final byte BUTTON_LEFT = 0x01;
public static final byte BUTTON_RIGHT = 0x02;
public static final byte BUTTON_MIDDLE = 0x04;
private static final SparseArray<String> buttonsMap;
static
{
buttonsMap = new SparseArray<String>();
buttonsMap.put(BUTTON_LEFT, "Left");
buttonsMap.put(BUTTON_RIGHT, "Right");
buttonsMap.put(BUTTON_MIDDLE, "Middle");
}
private static boolean mReportProtocol;
private InputStickMouse() {
}
/*
* Clicks selected mouse button (BUTTON_LEFT etc) N times
*
* @param button code of mouse button
* @param n number of button clicks (press and release events)
*/
public static void click(byte button, int n) {
HIDTransaction t = new HIDTransaction();
t.addReport(new MouseReport()); //release
for (int i = 0; i < n; i++) {
t.addReport(new MouseReport(button, NONE, NONE, NONE)); //press
t.addReport(new MouseReport()); //release
}
InputStickHID.addMouseTransaction(t);
}
/*
* Move mouse pointer
*
* @param x x displacement
* @param y y dispalcement
*/
public static void move(byte x, byte y) {
HIDTransaction t = new HIDTransaction();
t.addReport(new MouseReport(NONE, x, y, NONE));
InputStickHID.addMouseTransaction(t);
}
/*
* Moves mouse scroll wheel
*
* @param wheel scroll wheel displacement
*/
public static void scroll(byte wheel) {
HIDTransaction t = new HIDTransaction();
t.addReport(new MouseReport(NONE, NONE, NONE, wheel));
InputStickHID.addMouseTransaction(t);
}
//sends custom mouse report (buttons will remain in pressed state until released by next report)
/*
* Sends custom HID mouse report. Mouse buttons will remain in selected state until new report is received.
*
* @param buttons state of mouse buttons
* @param x x displacement
* @param y y dispalcement
* @param wheel scroll wheel displacement
*/
public static void customReport(byte buttons, byte x, byte y, byte wheel) {
HIDTransaction t = new HIDTransaction();
t.addReport(new MouseReport(buttons, x, y, wheel));
InputStickHID.addMouseTransaction(t);
}
/*
* Returns names of buttons in "pressed" state
*
* @param buttons state of mouse buttons
*/
public static String buttonsToString(byte buttons) {
String result = "None";
boolean first = true;
byte mod;
for (int i = 0; i < 8; i++) {
mod = (byte)(BUTTON_LEFT << i);
if ((buttons & mod) != 0) {
if ( !first) {
result += ", ";
} else {
result = "";
}
first = false;
result += buttonsMap.get(mod);
}
}
return result;
}
/*
* When report protocol is used, scroll wheel is enabled. Otherwise, simplified boot protocol is selected by USB host.
* Report protocol is in most cases used by OS.
* Boot protocol is used by BIOS, or when OS is booting.
*
* @return true if USB host uses report protocol, false if USB host uses boot protocol
*/
public boolean isReportProtocol() {
return mReportProtocol;
}
protected void setReportProtocol(boolean reportProtocol) {
mReportProtocol = reportProtocol;
}
}

View File

@ -0,0 +1,198 @@
package com.inputstick.api.bluetooth;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.lang.reflect.Method;
import java.util.UUID;
import android.app.Application;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothSocket;
import com.inputstick.api.InputStickError;
import com.inputstick.api.Util;
public class BT20Connection extends BTConnection {
private static final UUID MY_UUID = UUID.fromString("00001101-0000-1000-8000-00805F9B34FB"); //SPP
private final BluetoothAdapter mAdapter;
private ConnectThread mConnectThread;
private ConnectedThread mConnectedThread;
public BT20Connection(Application app, BTService btService, String mac, boolean reflections) {
super(app, btService, mac, reflections);
mAdapter = BluetoothAdapter.getDefaultAdapter();
}
@Override
public void connect() {
if (mConnectThread != null) {
mConnectThread.cancel();
mConnectThread = null;
}
if (mConnectedThread != null) {
mConnectedThread.cancel();
mConnectedThread = null;
}
final BluetoothDevice device = mAdapter.getRemoteDevice(mMac);
if (device != null) {
mConnectThread = new ConnectThread(device, mReflections);
mConnectThread.start();
} else {
mBTservice.connectionFailed(false, InputStickError.ERROR_BLUETOOTH_NO_REMOTE_DEVICE);
}
}
@Override
public void disconnect() {
cancelThreads();
}
@Override
public void write(byte[] out) {
mConnectedThread.write(out);
}
//################################
private synchronized void cancelThreads() {
if (mConnectThread != null) {
mConnectThread.cancel();
mConnectThread = null;
}
if (mConnectedThread != null) {
mConnectedThread.cancel();
mConnectedThread = null;
}
}
private class ConnectThread extends Thread {
private final BluetoothSocket mmSocket;
//private final BluetoothDevice mmDevice;
public ConnectThread(BluetoothDevice device, boolean useReflection) {
//mmDevice = device;
BluetoothSocket tmp = null;
try {
if (useReflection) {
Method m = device.getClass().getMethod("createRfcommSocket", new Class[] {int.class});
tmp = (BluetoothSocket) m.invoke(device, 1);
} else {
tmp = device.createRfcommSocketToServiceRecord(MY_UUID);
}
} catch (IOException e) {
Util.log("Socket create() failed");
} catch (Exception e) {
Util.log("Socket create() REFLECTION failed");
e.printStackTrace();
}
mmSocket = tmp;
}
public void run() {
Util.log("BEGIN mConnectThread");
mAdapter.cancelDiscovery(); //else it will slow down connection
try {
mmSocket.connect();
} catch (IOException e) {
try {
mmSocket.close();
} catch (IOException e2) {
Util.log("unable to close() socket during connection failure");
}
mBTservice.connectionFailed(true, 0);
return;
}
mConnectThread = null;
cancelThreads();
//now connected:
mConnectedThread = new ConnectedThread(mmSocket);
mConnectedThread.start();
mBTservice.connectedEstablished();
}
public void cancel() {
try {
mmSocket.close();
} catch (IOException e) {
Util.log("close() of connect socket failed");
}
}
}
private class ConnectedThread extends Thread {
private final BluetoothSocket mmSocket;
private final InputStream mmInStream;
private final OutputStream mmOutStream;
public ConnectedThread(BluetoothSocket socket) {
Util.log("create ConnectedThread");
mmSocket = socket;
InputStream tmpIn = null;
OutputStream tmpOut = null;
try {
tmpIn = socket.getInputStream();
tmpOut = socket.getOutputStream();
} catch (IOException e) {
Util.log("temp sockets not created");
}
mmInStream = tmpIn;
mmOutStream = tmpOut;
}
public void run() {
Util.log("BEGIN mConnectedThread");
int rxTmp;
while (true) {
try {
rxTmp = mmInStream.read();
mBTservice.onByteRx(rxTmp);
} catch (IOException e) {
mBTservice.connectionFailed(false, InputStickError.ERROR_BLUETOOTH_CONNECTION_LOST);
break;
}
}
}
public void write(byte[] buffer) {
try {
mmOutStream.write(buffer);
mmOutStream.flush();
} catch (IOException e) {
Util.log("write() exception");
}
}
public void cancel() {
try {
mmSocket.close();
} catch (IOException e) {
Util.log("socket close() exception");
}
}
}
}

View File

@ -0,0 +1,286 @@
package com.inputstick.api.bluetooth;
import java.util.LinkedList;
import java.util.List;
import java.util.UUID;
import android.annotation.SuppressLint;
import android.app.Application;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothGatt;
import android.bluetooth.BluetoothGattCallback;
import android.bluetooth.BluetoothGattCharacteristic;
import android.bluetooth.BluetoothGattDescriptor;
import android.bluetooth.BluetoothGattService;
import android.bluetooth.BluetoothManager;
import android.bluetooth.BluetoothProfile;
import android.content.Context;
import android.os.Handler;
import com.inputstick.api.InputStickError;
import com.inputstick.api.Util;
@SuppressLint("NewApi")
public class BT40Connection extends BTConnection {
private static final int CONNECTION_TIMEOUT = 10000;
private static final String MOD_CHARACTERISTIC_CONFIG = "00002902-0000-1000-8000-00805f9b34fb";
private static final String MOD_CONF = "0000ffe0-0000-1000-8000-00805f9b34fb";
private static final String MOD_RX_TX = "0000ffe1-0000-1000-8000-00805f9b34fb";
private static final UUID UUID_HM_RX_TX = UUID.fromString(MOD_RX_TX);
private BluetoothManager mBluetoothManager;
private BluetoothAdapter mBluetoothAdapter;
private BluetoothGatt mBluetoothGatt;
private BluetoothGattCharacteristic characteristicTX;
private BluetoothGattCharacteristic characteristicRX;
private LinkedList<byte[]> txBuffer;
private boolean canSend;
private boolean isConnecting;
private Handler handler;
public BT40Connection(Application app, BTService btService, String mac, boolean reflections) {
super(app, btService, mac, reflections);
mBluetoothManager = (BluetoothManager) (mCtx.getSystemService(Context.BLUETOOTH_SERVICE));
mBluetoothAdapter = mBluetoothManager.getAdapter();
}
@Override
public void connect() {
final BluetoothDevice device = mBluetoothAdapter.getRemoteDevice(mMac);
if (device != null) {
mBluetoothGatt = device.connectGatt(mCtx, false, mGattCallback);
isConnecting = true;
handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
if (isConnecting) {
disconnect();
mBTservice.connectionFailed(true, 0);
}
}
}, CONNECTION_TIMEOUT);
} else {
mBTservice.connectionFailed(false, InputStickError.ERROR_BLUETOOTH_NO_REMOTE_DEVICE);
}
}
@Override
public void disconnect() {
txBuffer = null;
try {
if (mBluetoothGatt != null) {
mBluetoothGatt.close();
mBluetoothGatt.disconnect();
mBluetoothGatt = null;
}
} catch (Exception e) {
}
}
@Override
public void write(byte[] out) {
byte[] tmp;
int offset = 0;
//SPECIAL CASES for flashing utility
if (Util.flashingToolMode) {
//txBuffer.add(out);
//return;
if (out.length == 1) {
txBuffer.add(out);
return;
}
if (out.length == 1026) {
tmp = new byte[2];
tmp[0] = out[0];
tmp[1] = out[1];
txBuffer.add(tmp);
offset = 2;
for (int i = 0; i < 64; i++) {
tmp = new byte[16];
System.arraycopy(out, offset, tmp, 0, 16);
offset += 16;
txBuffer.add(tmp);
}
return;
}
}
if (out.length == 2) {
addHeader(out);
} else {
Util.log("ADDING: " + out.length);
int loops = out.length / 16;
offset = 0;
for (int i = 0; i < loops; i++) {
tmp = new byte[16];
System.arraycopy(out, offset, tmp, 0, 16);
offset += 16;
addData16(tmp);
}
sendNext();
}
}
private byte h0;
private byte h1;
private boolean header;
private synchronized void addHeader(byte[] data) {
h0 = data[0];
h1 = data[1];
header = true;
}
private synchronized void addData16(byte[] data) {
byte[] tmp;
int offset = 0;
if (txBuffer != null) {
if (header) {
header = false;
tmp = new byte[18];
offset = 2;
tmp[0] = h0;
tmp[1] = h1;
} else {
tmp = new byte[16];
offset = 0;
}
System.arraycopy(data, 0, tmp, offset, 16);
txBuffer.add(tmp);
}
}
private synchronized byte[] getData() {
if (txBuffer != null) {
if (!txBuffer.isEmpty()) {
byte[] data = txBuffer.poll();
return data;
}
}
return null;
}
private synchronized void sendNext() {
if (canSend) {
byte[] data = getData();
if (data != null) {
canSend = false;
characteristicTX.setValue(data);
characteristicTX.setWriteType(BluetoothGattCharacteristic.WRITE_TYPE_NO_RESPONSE); //TODO
//characteristicTX.setWriteType(BluetoothGattCharacteristic.WRITE_TYPE_DEFAULT); //TODO
mBluetoothGatt.writeCharacteristic(characteristicTX);
}
}
}
private final BluetoothGattCallback mGattCallback = new BluetoothGattCallback() {
@Override
public void onConnectionStateChange(BluetoothGatt gatt, int status, int newState) {
if (newState == BluetoothProfile.STATE_CONNECTED) {
isConnecting = false;
Util.log("Connected to GATT server.");
Util.log("Attempting to start service discovery:" + mBluetoothGatt.discoverServices());
} else if (newState == BluetoothProfile.STATE_DISCONNECTED) {
isConnecting = false;
Util.log("Disconnected from GATT server.");
mBTservice.connectionFailed(false, InputStickError.ERROR_BLUETOOTH_CONNECTION_LOST);
}
}
@Override
public void onServicesDiscovered(BluetoothGatt gatt, int status) {
if (status == BluetoothGatt.GATT_SUCCESS) {
Util.log("GATT onServicesDiscovered");
List<BluetoothGattService> gattServices = null;
boolean serviceDiscovered = false;
if (mBluetoothGatt != null) {
gattServices = mBluetoothGatt.getServices();
}
if (gattServices != null) {
String uuid = null;
characteristicRX = null;
for (BluetoothGattService gattService : gattServices) {
uuid = gattService.getUuid().toString();
if (MOD_CONF.equals(uuid)) {
Util.log("BT LE - Serial Service Discovered");
characteristicTX = gattService.getCharacteristic(UUID_HM_RX_TX);
characteristicRX = gattService.getCharacteristic(UUID_HM_RX_TX);
if (characteristicRX == null) {
mBTservice.connectionFailed(false, InputStickError.ERROR_BLUETOOTH_BT40_NO_SPP_SERVICE);
} else {
serviceDiscovered = true;
}
}
}
}
if (serviceDiscovered) {
//enable notifications
mBluetoothGatt.setCharacteristicNotification(characteristicRX, true);
if (UUID_HM_RX_TX.equals(characteristicRX.getUuid())) {
Util.log("RXTX SERVICE DISCOVERED!");
BluetoothGattDescriptor descriptor = characteristicRX.getDescriptor(UUID.fromString(MOD_CHARACTERISTIC_CONFIG));
descriptor.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE);
mBluetoothGatt.writeDescriptor(descriptor);
txBuffer = new LinkedList<byte[]>();
canSend = true;
sendNext();
mBTservice.connectedEstablished();
} else {
mBTservice.connectionFailed(false, InputStickError.ERROR_BLUETOOTH_BT40_NO_SPP_SERVICE);
}
} else {
Util.log("BT LE - Serial Service NOT FOUND");
mBTservice.connectionFailed(false, InputStickError.ERROR_BLUETOOTH_BT40_NO_SPP_SERVICE);
}
} else {
Util.log("onServicesDiscovered received: " + status);
}
}
@Override
public void onCharacteristicRead(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, int status) {
if (status == BluetoothGatt.GATT_SUCCESS) {
}
}
@Override
public void onCharacteristicChanged(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic) {
byte b[] = characteristic.getValue();
if (b != null) {
mBTservice.onByteRx(b);
}
}
@Override
public void onCharacteristicWrite(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, int status) {
Util.log("GATT onCharacteristicWrite");
if (status == BluetoothGatt.GATT_SUCCESS) {
canSend = true;
sendNext();
} //TODO error code?
}
};
}

View File

@ -0,0 +1,26 @@
package com.inputstick.api.bluetooth;
import android.app.Application;
import android.content.Context;
public abstract class BTConnection {
protected final Application mApp;
protected final Context mCtx;
protected final String mMac;
protected boolean mReflections;
protected final BTService mBTservice;
public BTConnection(Application app, BTService btService, String mac, boolean reflections) {
mApp = app;
mCtx = app.getApplicationContext();
mMac = mac;
mReflections = reflections;
mBTservice = btService;
}
public abstract void connect();
public abstract void disconnect();
public abstract void write(byte[] out);
}

View File

@ -0,0 +1,231 @@
package com.inputstick.api.bluetooth;
import android.app.Application;
import android.bluetooth.BluetoothAdapter;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Handler;
import android.os.Message;
import com.inputstick.api.InputStickError;
import com.inputstick.api.Util;
public class BTService {
public static final int DEFAULT_CONNECT_TIMEOUT = 30000;
public static final int EVENT_NONE = 0;
public static final int EVENT_DATA = 1;
public static final int EVENT_CONNECTED = 2;
public static final int EVENT_CANCELLED = 3;
public static final int EVENT_ERROR = 4;
private final Handler mHandler;
private int mLastEvent;
private String mMac;
private final Application mApp;
private final Context mCtx;
private boolean mUseReflection;
private int mConnectTimeout;
private long timeout;
private int retryCnt;
private boolean disconnecting;
private boolean connected;
private PacketReader mPacketReader;
private BTConnection mBTConnection;
private boolean turnBluetoothOn;
private boolean receiverRegistered;
private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
final String action = intent.getAction();
if (action.equals(BluetoothAdapter.ACTION_STATE_CHANGED)) {
final int state = intent.getIntExtra(BluetoothAdapter.EXTRA_STATE, BluetoothAdapter.ERROR);
if ((state == BluetoothAdapter.STATE_ON) && (turnBluetoothOn)) {
turnBluetoothOn = false;
connect(false);
}
}
}
};
public BTService(Application app, Handler handler) {
mLastEvent = EVENT_NONE;
mHandler = handler;
mApp = app;
mCtx = app.getApplicationContext();
mConnectTimeout = DEFAULT_CONNECT_TIMEOUT;
}
public void setConnectTimeout(int timeout) {
mConnectTimeout = timeout;
}
public void enableReflection(boolean enabled) {
mUseReflection = enabled;
}
protected synchronized void event(int event, int arg1) {
Util.log("event() " + mLastEvent + " -> " + event);
mLastEvent = event;
Message msg = Message.obtain(null, mLastEvent, arg1, 0);
mHandler.sendMessage(msg);
}
public synchronized int getLastEvent() {
return mLastEvent;
}
private void connect(boolean reconnecting) {
if (reconnecting) {
retryCnt++;
} else {
retryCnt = 0;
timeout = System.currentTimeMillis() + mConnectTimeout;
}
mBTConnection.connect();
}
public synchronized void connect(String mac) {
connect(mac, false);
}
public synchronized void connect(String mac, boolean doNotAsk) {
connect(mac, doNotAsk, false);
}
public synchronized void connect(String mac, boolean doNotAsk, boolean bt40) {
try {
Util.log("connect to: " + mac + " REFLECTION: " + mUseReflection);
disconnecting = false;
connected = false;
mMac = mac;
if (BluetoothAdapter.checkBluetoothAddress(mac)) {
BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
if (mBluetoothAdapter == null) {
event(BTService.EVENT_ERROR, InputStickError.ERROR_BLUETOOTH_NOT_SUPPORTED);
} else {
if (bt40) {
mBTConnection = new BT40Connection(mApp, this, mMac, mUseReflection);
} else {
mBTConnection = new BT20Connection(mApp, this, mMac, mUseReflection);
}
if (mBluetoothAdapter.isEnabled()) {
connect(false);
} else {
//enableBluetooth(doNotAsk); :
if (mApp != null) {
turnBluetoothOn = true;
if ( !receiverRegistered) {
IntentFilter filter = new IntentFilter(BluetoothAdapter.ACTION_STATE_CHANGED);
mCtx.registerReceiver(mReceiver, filter);
receiverRegistered = true;
}
if (doNotAsk) {
BluetoothAdapter.getDefaultAdapter().enable();
} else {
Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
enableBtIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
mApp.startActivity(enableBtIntent);
}
}
}
}
} else {
event(BTService.EVENT_ERROR, InputStickError.ERROR_BLUETOOTH_INVALID_MAC);
}
} catch (NoClassDefFoundError e) {
event(BTService.EVENT_ERROR, InputStickError.ERROR_BLUETOOTH_BT40_NOT_SUPPRTED);
}
}
public synchronized void disconnect() {
Util.log("disconnect");
disconnecting = true;
if (mBTConnection != null) {
mBTConnection.disconnect();
}
event(EVENT_CANCELLED, 0);
}
public synchronized void write(byte[] out) {
if (connected) {
mBTConnection.write(out);
}
}
protected synchronized void connectedEstablished() {
removeReceiver(); //TODO
mPacketReader = new PacketReader(this, mHandler);
timeout = 0;
connected = true;
event(EVENT_CONNECTED, 0);
}
protected void connectionFailed(boolean canRetry, int errorCode) {
removeReceiver(); //TODO
connected = false;
if (disconnecting) {
disconnecting = false;
} else {
if (canRetry) {
if ((timeout > 0) && (System.currentTimeMillis() < timeout)) {
Util.log("RETRY: "+retryCnt + " time left: " + (timeout - System.currentTimeMillis()));
connect(true);
} else {
event(EVENT_ERROR, InputStickError.ERROR_BLUETOOTH_CONNECTION_FAILED);
}
} else {
event(EVENT_ERROR, errorCode);
}
}
}
protected synchronized void onByteRx(int rxByte) {
mPacketReader.rxByte((byte)rxByte);
}
protected synchronized void onByteRx(byte[] rxBytes) {
for (int i = 0; i < rxBytes.length; i++) {
mPacketReader.rxByte(rxBytes[i]);
}
}
private void removeReceiver() {
if (receiverRegistered) {
mCtx.unregisterReceiver(mReceiver);
receiverRegistered = false;
}
}
public static boolean isBT40Supported() {
return (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.JELLY_BEAN_MR2);
}
}

View File

@ -0,0 +1,88 @@
package com.inputstick.api.bluetooth;
import android.os.Handler;
import com.inputstick.api.InputStickError;
import com.inputstick.api.Packet;
import com.inputstick.api.Util;
public class PacketReader {
private static final int RX_TIMEOUT = 3000;
private static final int RX_TAG = 0;
private static final int RX_LENGTH = 1;
private static final int RX_DATA = 2;
private long lastRxTime;
private int rxState;
private int rxPos;
private int rxLength;
private byte[] rxData;
private int rxWdgCnt;
private final BTService mBTService;
private final Handler mHandler;
public PacketReader(BTService btService, Handler handler) {
mBTService = btService;
mHandler = handler;
}
public void rxByte(byte b) {
//byte b = (byte)rxByte;
long time = System.currentTimeMillis();
if (time > lastRxTime + RX_TIMEOUT) {
rxState = RX_TAG;
}
switch (rxState) {
case RX_TAG:
if (b == Packet.START_TAG) {
rxState = RX_LENGTH;
} else {
Util.log("Unexpected RX byte" + b);
if (b == 0xAF) {
rxWdgCnt++;
}
if (rxWdgCnt > 1024) {
rxWdgCnt = 0;
mBTService.event(BTService.EVENT_ERROR, InputStickError.ERROR_HARDWARE_WDG_RESET);
}
}
break;
case RX_LENGTH:
rxLength = b;
rxLength &= 0x3F;
rxLength *= 16;
rxLength += 2;
rxPos = 2;
rxData = new byte[rxLength];
rxData[0] = Packet.START_TAG;
rxData[1] = (byte)b;
rxState = RX_DATA;
break;
case RX_DATA:
if (rxPos < rxLength) {
rxData[rxPos] = b;
rxPos++;
if (rxPos == rxLength) {
//done!
mHandler.obtainMessage(BTService.EVENT_DATA, 0, 0, rxData).sendToTarget();
rxState = RX_TAG;
}
} else {
//buffer overrun!
rxState = RX_TAG;
}
break;
}
lastRxTime = time;
}
}

View File

@ -0,0 +1,430 @@
package com.inputstick.api.broadcast;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager.NameNotFoundException;
import com.inputstick.api.DownloadDialog;
/*
* IMPORTANT:
*
* Using InputStickBroadcast is the easiest and fastest way to use InputStick with your application.
* InputStickUility takes care of almost everything:
* -enabling Bluetooth if necessary,
* -selecting InputStick device (if more than one is available),
* -establishing connection,
* -deals with potential connection problems (connection failed, lost),
* -user preferences (keyboard layout, typing speed).
*
* as a result of that, your application has little to no control over:
* -connection,
* -buffers
* -timing,
*
*
* Using InputStickBroadcast is recommended only for simple use cases: typing strings.
* Example: barcode scanner app, assuming that user will use InputStick to type only some of scanned codes.
*
* Using InputStickBroadcast is NOT recommended if
* -timing is critical,
* -low latency is necessary,
* -many actions can be executed in a short period of time
*
* Example: remote control app.
*
* In such case use classes from com.inputstick.api.hid package and implement all necessary callbacks.
*
*/
public class InputStickBroadcast {
private static boolean AUTO_SUPPORT_CHECK;
public static final String PARAM_REQUEST = "REQUEST";
public static final String PARAM_RELEASE = "RELEASE";
public static final String PARAM_CLEAR = "CLEAR";
public static final String PARAM_TEXT = "TEXT";
public static final String PARAM_LAYOUT = "LAYOUT";
public static final String PARAM_MULTIPLIER = "MULTIPLIER";
public static final String PARAM_KEY = "KEY";
public static final String PARAM_MODIFIER = "MODIFIER";
public static final String PARAM_REPORT_KEYB = "REPORT_KEYB";
public static final String PARAM_REPORT_EMPTY = "REPORT_EMPTY";
public static final String PARAM_REPORT_MOUSE = "REPORT_MOUSE";
public static final String PARAM_MOUSE_BUTTONS ="MOUSE_BUTTONS";
public static final String PARAM_MOUSE_CLICKS = "MOUSE_CLICKS";
public static final String PARAM_CONSUMER = "CONSUMER";
/*
* Checks whether InputStickUtility is installed and supports intents (version code >= 11).
* Optionally download dialog can be displayed if InputStickUtility is not installed.
*
* @param ctx context
* @param allowMessages when true, download dialog will be displayed if necessary
*
*/
public static boolean isSupported(Context ctx, boolean allowMessages) {
PackageInfo pInfo;
try {
pInfo = ctx.getPackageManager().getPackageInfo("com.inputstick.apps.inputstickutility", 0);
//System.out.println("ver: " + pInfo.versionName + " code: " + pInfo.versionCode);
if (pInfo.versionCode < 11) {
if (allowMessages) {
DownloadDialog.getDialog(ctx, DownloadDialog.NOT_UPDATED).show();
}
return false;
} else {
return true;
}
} catch (NameNotFoundException e) {
//e.printStackTrace();
//InputStickUtility not installed
if (allowMessages) {
DownloadDialog.getDialog(ctx, DownloadDialog.NOT_INSTALLED).show();
}
return false;
}
}
/*
* When Auto Support Check is enabled, isSupported(ctx, true) will be called each time before sending broadcast.
* You do not have to check support manually. Download dialog will be displayed if InputStickUtility is not installed.
*
* WARNING: checking support each time after sending broadcast can be very time consuming!!!
*
* @param enabled true to enable Auto Support Check, false to disable
*/
public static void setAutoSupportCheck(boolean enabled) {
AUTO_SUPPORT_CHECK = enabled;
}
/*
* Indicates that it is very likely that this application will want to use InputStick within next few seconds.
* Depending on user preferences this action may be ignored! In such case InputStickUtility will wait until some data arrives (text etc.).
* In many cases this will allow to reduce delay between requesting some action and executing it (typing text etc).
*
* @param ctx context used to send broadcast.
*/
public static void requestConnection(Context ctx) {
Intent intent = new Intent();
intent.putExtra(PARAM_REQUEST, true);
send(ctx, intent);
}
/*
* Indicates that application will no longer need InputStick in nearest future.
* Allows to save power.
* Depending on user preferences this action may be ignored!
* Ignored if not connected.
*
* @param ctx context used to send broadcast.
*/
public static void releaseConnection(Context ctx) {
Intent intent = new Intent();
intent.putExtra(PARAM_RELEASE, true);
send(ctx, intent);
}
/*
* Removes all actions from queue. Clears all interface buffers.
* Use to immediately stop all actions
* Depending on user preferences this action may be ignored!
*
* @param ctx context used to send broadcast.
*/
public static void clearQueue(Context ctx) {
Intent intent = new Intent();
intent.putExtra(PARAM_CLEAR, true);
send(ctx, intent);
}
//#######################################################################################################
//##### KEYBOARD INTERFACE ##############################################################################
//#######################################################################################################
/*
* Puts "type text" action into queue. Fastest typing speed, use en-US layout.
*
* @param ctx context used to send broadcast.
* @param text text to be typed. \n and \t characters are allowed.
*/
public static void type(Context ctx, String text) {
type(ctx, text, null, 1);
}
/*
* Puts "type text" action into queue. Fastest typing speed.
*
* Keyboard layout must match layout used by USB host. en-US is used by default.
* Depending on user preferences value of layoutCode may be ignored!
*
* @param ctx context used to send broadcast
* @param text text to be typed. \n and \t characters are allowed.
* @param layoutCode keyboard layout to be used: en-US, de-DE, pl-PL etc.
*/
public static void type(Context ctx, String text, String layoutCode) {
type(ctx, text, layoutCode, 1);
}
/*
* Puts "type text" action into queue.
*
* Keyboard layout must match layout used by USB host. en-US is used by default.
* Depending on user preferences value of layoutCode may be ignored!
*
* When multiplier is set to 1, keys will be "pressed" at fastest possible speed. Increase value of this parameter to obtain slower typing speed, by multiplying number of HID keyboard reports.
* Depending on user preferences value of multiplier may be ignored!
*
* @param ctx context used to send broadcast
* @param text text to be typed. \n and \t characters are allowed.
* @param layoutCode keyboard layout to be used: en-US, de-DE, pl-PL etc.
* @param multiplier controls typing speed.
*/
public static void type(Context ctx, String text, String layoutCode, int multiplier) {
Intent intent = new Intent();
intent.putExtra(PARAM_TEXT, text);
if (layoutCode != null) {
intent.putExtra(PARAM_LAYOUT, layoutCode);
}
if (multiplier > 1) {
intent.putExtra(PARAM_MULTIPLIER, multiplier);
}
send(ctx, intent);
}
/*
* Puts "press and release key" action into queue.
*
* @param ctx context used to send broadcast.
* @param modifiers modifier keys: Shift, Alt, Ctrl, Gui/Win/Command keys, (see HIDKeycodes class.
* @param key any non-modifier key, see HIDKeycodes class.
*/
public static void pressAndRelease(Context ctx, byte modifiers, byte key) {
pressAndRelease(ctx, modifiers, key, 1);
}
/*
* Puts "press and release key" action into queue.
* When multiplier is set to 1, keys will be "pressed" at fastest possible speed. Increase value of this parameter to obtain slower typing speed, by multiplying number of HID reports.
*
* @param ctx context used to send broadcast.
* @param modifiers modifier keys: Shift, Alt, Ctrl, Gui/Win/Command keys, (see HIDKeycodes class).
* @param key any non-modifier key, see HIDKeycodes class.
* @param multiplier controls typing speed.
*/
public static void pressAndRelease(Context ctx, byte modifiers, byte key, int multiplier) {
Intent intent = new Intent();
intent.putExtra(PARAM_MODIFIER, modifiers);
intent.putExtra(PARAM_KEY, key);
if (multiplier > 1) {
intent.putExtra(PARAM_MULTIPLIER, multiplier);
}
send(ctx, intent);
}
/*
* Puts single HID keyboard report into queue.
* HID keyboard report represents state of keyboard (which keys are pressed) at a given moment.
* Must be 8 bytes long:
* report[0] = modifier keys
* report[1] = 0x00
* report[2] = key1
* report[3] = key2
* report[4] = key3
* report[5] = key4
* report[6] = key5
* report[7] = key6
* To avoid keys getting "stuck" they should be released (by adding empty report).
*
* @param ctx context used to send broadcast.
* @param report HID keyboard report.
* @param addEmptyReport empty keyboard report (all keys released) will be added if true.
*/
public static void keyboardReport(Context ctx, byte[] report, boolean addEmptyReport) {
Intent intent = new Intent();
intent.putExtra(PARAM_REPORT_KEYB, report);
if (addEmptyReport) {
intent.putExtra(PARAM_REPORT_EMPTY, true);
}
send(ctx, intent);
}
/*
* Puts single HID keyboard report into queue.
* HID keyboard report represents state of keyboard (which keys are pressed) at a given moment.
* To avoid keys getting "stuck" they should be released (by adding empty report).
*
* @param ctx context used to send broadcast.
* @param modifiers modifier keys: Shift, Alt, Ctrl, Gui/Win/Command keys, (see HIDKeycodes class).
* @param key1 any non-modifier key, see HIDKeycodes class.
* @param key2 any non-modifier key, see HIDKeycodes class.
* @param key3 any non-modifier key, see HIDKeycodes class.
* @param key4 any non-modifier key, see HIDKeycodes class.
* @param key5 any non-modifier key, see HIDKeycodes class.
* @param key6 any non-modifier key, see HIDKeycodes class.
* @param addEmptyReport empty keyboard report (all keys released) will be added if true.
*/
public static void keyboardReport(Context ctx, byte modifiers, byte key1, byte key2, byte key3, byte key4, byte key5, byte key6, boolean addEmptyReport) {
byte[] report = new byte[8];
report[0] = modifiers;
report[2] = key1;
report[3] = key2;
report[4] = key3;
report[5] = key4;
report[6] = key5;
report[7] = key6;
keyboardReport(ctx, report, addEmptyReport);
}
//#######################################################################################################
//##### MOUSE INTERFACE #################################################################################
//#######################################################################################################
/*
* Puts single HID mouse report into queue.
* HID mouse report represents change in state of a mouse.
* Must be 4 bytes long:
* report[0] = buttons
* report[1] = x axis displacement
* report[2] = y axis displacement
* report[3] = scroll wheel displacement
*
* @param ctx context used to send broadcast.
* @param report HID mouse report.
*/
public static void mouseReport(Context ctx, byte[] report) {
Intent intent = new Intent();
intent.putExtra(PARAM_REPORT_MOUSE, report);
send(ctx, intent);
}
/*
* Puts single HID mouse report into queue.
* Left mouse button = 0x01
* Right mouse button = 0x02
* Middle mouse button = 0x04
*
* @param ctx context used to send broadcast.
* @param buttons mouse buttons to click.
* @param dx x axis displacement.
* @param dy y axis displacement.
* @param scroll scroll wheel displacement.
*/
public static void mouseReport(Context ctx, byte buttons, byte dx, byte dy, byte scroll) {
byte[] report = new byte[4];
report[0] = buttons;
report[1] = dx;
report[2] = dy;
report[3] = scroll;
mouseReport(ctx, report);
}
/*
* Puts mouse click (button(s) press-release) action into queue.
* Left mouse button = 0x01
* Right mouse button = 0x02
* Middle mouse button = 0x04
*
* @param ctx context used to send broadcast.
* @param buttons mouse buttons to click.
* @param n number of clicks.
*/
public static void mouseClick(Context ctx, byte buttons, int n) {
Intent intent = new Intent();
intent.putExtra(PARAM_MOUSE_BUTTONS, buttons);
intent.putExtra(PARAM_MOUSE_CLICKS, n);
send(ctx, intent);
}
/*
* Puts mouse move action into queue.
*
* @param ctx context used to send broadcast.
* @param dx x axis displacement.
* @param dy y axis displacement.
*/
public static void mouseMove(Context ctx, byte dx, byte dy) {
mouseReport(ctx, (byte)0x00, dx, dy, (byte)0x00);
}
/*
* Puts mouse scroll action into queue.
* Positive values: scroll up; negative values: scroll down
*
* @param ctx context used to send broadcast.
* @param scroll scroll wheel displacement.
*/
public static void mouseScroll(Context ctx, byte scroll) {
mouseReport(ctx, (byte)0x00, (byte)0x00, (byte)0x00, scroll);
}
//#######################################################################################################
//##### CONSUMER CONTROL INTERFACE ######################################################################
//#######################################################################################################
/*
* Puts "consumer" action into queue. See InputStickConsumer class for list available actions.
*
* @param ctx context used to send broadcast.
* @param action code of consumer action.
*/
public static void consumerControlAction(Context ctx, int action) {
Intent intent = new Intent();
intent.putExtra(PARAM_CONSUMER, action);
send(ctx, intent);
}
private static void send(Context ctx, Intent intent) {
intent.setAction("com.inputstick.apps.inputstickutility.HID");
intent.setClassName("com.inputstick.apps.inputstickutility", "com.inputstick.apps.inputstickutility.service.HIDReceiver");
//if necessary, show download dialog message
if (AUTO_SUPPORT_CHECK) {
if (isSupported(ctx, true)) {
ctx.sendBroadcast(intent);
}
} else {
ctx.sendBroadcast(intent);
}
}
}

View File

@ -0,0 +1,43 @@
package com.inputstick.api.hid;
import com.inputstick.api.Util;
public class ConsumerReport extends HIDReport {
public static final byte CONSUMER_REPORT_ID = 1;
public static final byte SYSTEM_REPORT_ID = 2;
public static final byte GAMEPAD_REPORT_ID = 3;
public static final int SIZE = 3;
private byte[] data;
public ConsumerReport(byte id, byte b1, byte b2) {
data = new byte[SIZE];
data[0] = id;
data[1] = b1;
data[2] = b2;
}
public ConsumerReport(int usage) {
data = new byte[SIZE];
data[0] = CONSUMER_REPORT_ID;
data[1] = Util.getLSB(usage);
data[2] = Util.getMSB(usage);
}
public ConsumerReport() {
this(0);
}
public byte[] getBytes() {
return data;
}
public int getBytesCount() {
return SIZE;
}
}

View File

@ -0,0 +1,32 @@
package com.inputstick.api.hid;
public class GamepadReport extends HIDReport {
public static final int SIZE = 7;
private byte[] data;
public GamepadReport(byte b1, byte b2, byte x, byte y, byte z, byte rx) {
data = new byte[SIZE];
data[0] = 3;
data[1] = b1;
data[2] = b2;
data[3] = x;
data[4] = y;
data[5] = z;
data[6] = rx;
}
public GamepadReport() {
this((byte)0, (byte)0, (byte)0, (byte)0, (byte)0, (byte)0);
}
public byte[] getBytes() {
return data;
}
public int getBytesCount() {
return SIZE;
}
}

View File

@ -0,0 +1,436 @@
package com.inputstick.api.hid;
import android.util.SparseArray;
public class HIDKeycodes {
public static final byte NONE = 0x00;
public static final byte CTRL_LEFT = 0x01;
public static final byte SHIFT_LEFT = 0x02;
public static final byte ALT_LEFT = 0x04;
public static final byte GUI_LEFT = 0x08;
public static final byte CTRL_RIGHT = 0x10;
public static final byte SHIFT_RIGHT = 0x20;
public static final byte ALT_RIGHT = 0x40;
public static final byte GUI_RIGHT = (byte)0x80;
public static final byte KEY_ENTER = 0x28;
public static final byte KEY_ESCAPE = 0x29;
public static final byte KEY_BACKSPACE = 0x2A;
public static final byte KEY_TAB = 0x2B;
public static final byte KEY_SPACEBAR = 0x2C;
public static final byte KEY_CAPS_LOCK = 0x39;
public static final byte KEY_1 = 0x1E;
public static final byte KEY_2 = 0x1F;
public static final byte KEY_3 = 0x20;
public static final byte KEY_4 = 0x21;
public static final byte KEY_5 = 0x22;
public static final byte KEY_6 = 0x23;
public static final byte KEY_7 = 0x24;
public static final byte KEY_8 = 0x25;
public static final byte KEY_9 = 0x26;
public static final byte KEY_0 = 0x27;
public static final byte KEY_F1 = 0x3A;
public static final byte KEY_F2 = 0x3B;
public static final byte KEY_F3 = 0x3C;
public static final byte KEY_F4 = 0x3D;
public static final byte KEY_F5 = 0x3E;
public static final byte KEY_F6 = 0x3F;
public static final byte KEY_F7 = 0x40;
public static final byte KEY_F8 = 0x41;
public static final byte KEY_F9 = 0x42;
public static final byte KEY_F10 = 0x43;
public static final byte KEY_F11 = 0x44;
public static final byte KEY_F12 = 0x45;
public static final byte KEY_PRINT_SCREEN = 0x46;
public static final byte KEY_SCROLL_LOCK = 0x47;
public static final byte KEY_PASUE = 0x48;
public static final byte KEY_INSERT = 0x49;
public static final byte KEY_HOME = 0x4A;
public static final byte KEY_PAGE_UP = 0x4B;
public static final byte KEY_DELETE = 0x4C;
public static final byte KEY_END = 0x4D;
public static final byte KEY_PAGE_DOWN = 0x4E;
public static final byte KEY_ARROW_RIGHT = 0x4F;
public static final byte KEY_ARROW_LEFT = 0x50;
public static final byte KEY_ARROW_DOWN = 0x51;
public static final byte KEY_ARROW_UP = 0x52;
public static final byte KEY_NUM_LOCK = 0x53;
public static final byte KEY_NUM_SLASH = 0x54;
public static final byte KEY_NUM_STAR = 0x55;
public static final byte KEY_NUM_MINUS = 0x56;
public static final byte KEY_NUM_PLUS = 0x57;
public static final byte KEY_NUM_ENTER = 0x58;
public static final byte KEY_NUM_1 = 0x59;
public static final byte KEY_NUM_2 = 0x5A;
public static final byte KEY_NUM_3 = 0x5B;
public static final byte KEY_NUM_4 = 0x5C;
public static final byte KEY_NUM_5 = 0x5D;
public static final byte KEY_NUM_6 = 0x5E;
public static final byte KEY_NUM_7 = 0x5F;
public static final byte KEY_NUM_8 = 0x60;
public static final byte KEY_NUM_9 = 0x61;
public static final byte KEY_NUM_0 = 0x62;
public static final byte KEY_NUM_DOT = 0x63;
public static final byte KEY_BACKSLASH_NON_US = 0x64;
public static final byte KEY_A = 0x04;
public static final byte KEY_B = 0x05;
public static final byte KEY_C = 0x06;
public static final byte KEY_D = 0x07;
public static final byte KEY_E = 0x08;
public static final byte KEY_F = 0x09;
public static final byte KEY_G = 0x0A;
public static final byte KEY_H = 0x0B;
public static final byte KEY_I = 0x0C;
public static final byte KEY_J = 0x0D;
public static final byte KEY_K = 0x0E;
public static final byte KEY_L = 0x0F;
public static final byte KEY_M = 0x10;
public static final byte KEY_N = 0x11;
public static final byte KEY_O = 0x12;
public static final byte KEY_P = 0x13;
public static final byte KEY_Q = 0x14;
public static final byte KEY_R = 0x15;
public static final byte KEY_S = 0x16;
public static final byte KEY_T = 0x17;
public static final byte KEY_U = 0x18;
public static final byte KEY_V = 0x19;
public static final byte KEY_W = 0x1A;
public static final byte KEY_X = 0x1B;
public static final byte KEY_Y = 0x1C;
public static final byte KEY_Z = 0x1D;
public static final byte KEY_MINUS = 0x2D;
public static final byte KEY_EQUALS = 0x2E;
public static final byte KEY_LEFT_BRACKET = 0x2F;
public static final byte KEY_RIGHT_BRACKET = 0x30;
public static final byte KEY_BACKSLASH = 0x31;
//public static final byte KEY_GRAVE = 0x32;
public static final byte KEY_SEMICOLON = 0x33;
public static final byte KEY_APOSTROPHE = 0x34;
public static final byte KEY_GRAVE = 0x35;
public static final byte KEY_COMA = 0x36;
public static final byte KEY_DOT = 0x37;
public static final byte KEY_SLASH = 0x38;
public static final byte KEY_APPLICATION = 0x65;
public static final SparseArray<String> modifiersMap;
static
{
modifiersMap = new SparseArray<String>();
modifiersMap.put(CTRL_LEFT, "Left Ctrl");
modifiersMap.put(SHIFT_LEFT, "Left Shift");
modifiersMap.put(ALT_LEFT, "Left Alt");
modifiersMap.put(GUI_LEFT, "Left GUI");
modifiersMap.put(CTRL_RIGHT, "Right Ctrl");
modifiersMap.put(SHIFT_RIGHT, "Right Shift");
modifiersMap.put(ALT_RIGHT, "Right Alt");
modifiersMap.put(GUI_RIGHT, "Right GUI");
}
public static final SparseArray<String> keyMap;
static
{
keyMap = new SparseArray<String>();
keyMap.put(0, "None");
keyMap.put(KEY_ENTER, "Enter");
keyMap.put(KEY_ESCAPE , "Esc");
keyMap.put(KEY_BACKSPACE , "Backspace");
keyMap.put(KEY_TAB , "Tab");
keyMap.put(KEY_SPACEBAR , "Space");
keyMap.put(KEY_CAPS_LOCK , "CapsLock");
keyMap.put(KEY_1 , "1");
keyMap.put(KEY_2 , "2");
keyMap.put(KEY_3 , "3");
keyMap.put(KEY_4 , "4");
keyMap.put(KEY_5 , "5");
keyMap.put(KEY_6 , "6");
keyMap.put(KEY_7 , "7");
keyMap.put(KEY_8 , "8");
keyMap.put(KEY_9 , "9");
keyMap.put(KEY_0 , "0");
keyMap.put(KEY_F1 , "F1");
keyMap.put(KEY_F2 , "F2");
keyMap.put(KEY_F3 , "F3");
keyMap.put(KEY_F4 , "F4");
keyMap.put(KEY_F5 , "F5");
keyMap.put(KEY_F6 , "F6");
keyMap.put(KEY_F7 , "F7");
keyMap.put(KEY_F8 , "F8");
keyMap.put(KEY_F9 , "F9");
keyMap.put(KEY_F10 , "F10");
keyMap.put(KEY_F11 , "F11");
keyMap.put(KEY_F12 , "F12");
keyMap.put(KEY_PRINT_SCREEN , "Print Scrn");
keyMap.put(KEY_SCROLL_LOCK , "ScrollLock");
keyMap.put(KEY_PASUE , "Pause Break");
keyMap.put(KEY_INSERT , "Insert");
keyMap.put(KEY_HOME , "Home");
keyMap.put(KEY_PAGE_UP , "PageUp");
keyMap.put(KEY_DELETE , "Delete");
keyMap.put(KEY_END , "End");
keyMap.put(KEY_PAGE_DOWN , "PageDown");
keyMap.put(KEY_ARROW_RIGHT , "Right Arrow");
keyMap.put(KEY_ARROW_LEFT , "Left Arrow");
keyMap.put(KEY_ARROW_DOWN , "Down Arrow");
keyMap.put(KEY_ARROW_UP , "Up Arrow");
keyMap.put(KEY_NUM_LOCK , "NumLock");
keyMap.put(KEY_NUM_SLASH , "Num /");
keyMap.put(KEY_NUM_STAR , "Num *");
keyMap.put(KEY_NUM_MINUS , "Num -");
keyMap.put(KEY_NUM_PLUS , "Num +");
keyMap.put(KEY_NUM_ENTER , "Num Enter");
keyMap.put(KEY_NUM_1 , "Num 1");
keyMap.put(KEY_NUM_2 , "Num 2");
keyMap.put(KEY_NUM_3 , "Num 3");
keyMap.put(KEY_NUM_4 , "Num 4");
keyMap.put(KEY_NUM_5 , "Num 5");
keyMap.put(KEY_NUM_6 , "Num 6");
keyMap.put(KEY_NUM_7 , "Num 7");
keyMap.put(KEY_NUM_8 , "Num 8");
keyMap.put(KEY_NUM_9 , "Num 9");
keyMap.put(KEY_NUM_0 , "Num 0");
keyMap.put(KEY_NUM_DOT , "Num .");
keyMap.put(KEY_A , "A");
keyMap.put(KEY_B , "B");
keyMap.put(KEY_C , "C");
keyMap.put(KEY_D , "D");
keyMap.put(KEY_E , "E");
keyMap.put(KEY_F , "F");
keyMap.put(KEY_G , "G");
keyMap.put(KEY_H , "H");
keyMap.put(KEY_I , "I");
keyMap.put(KEY_J , "J");
keyMap.put(KEY_K , "K");
keyMap.put(KEY_L , "L");
keyMap.put(KEY_M , "M");
keyMap.put(KEY_N , "N");
keyMap.put(KEY_O , "O");
keyMap.put(KEY_P , "P");
keyMap.put(KEY_Q , "Q");
keyMap.put(KEY_R , "R");
keyMap.put(KEY_S , "S");
keyMap.put(KEY_T , "T");
keyMap.put(KEY_U , "U");
keyMap.put(KEY_V , "V");
keyMap.put(KEY_W , "W");
keyMap.put(KEY_X , "X");
keyMap.put(KEY_Y , "Y");
keyMap.put(KEY_Z , "Z");
keyMap.put(KEY_MINUS , "-");
keyMap.put(KEY_EQUALS , "=");
keyMap.put(KEY_LEFT_BRACKET , "[");
keyMap.put(KEY_RIGHT_BRACKET , "]");
keyMap.put(KEY_BACKSLASH , "\\");
//keyMap.put(KEY_GRAVE , "`");
keyMap.put(KEY_SEMICOLON , ";");
keyMap.put(KEY_APOSTROPHE , "'");
keyMap.put(KEY_GRAVE , "`");
keyMap.put(KEY_COMA , ",");
keyMap.put(KEY_DOT , ".");
keyMap.put(KEY_SLASH , "/");
keyMap.put(KEY_APPLICATION , "Application");
}
public static final int[] ASCIItoHID = {
0, //000
0, //001
0, //002
0, //003
0, //004
0, //005
0, //006
0, //007
0, //008
0, //009
0, //010
0, //011
0, //012
0, //013
0, //014
0, //015
0, //016
0, //017
0, //018
0, //019
0, //020
0, //021
0, //022
0, //023
0, //024
0, //025
0, //026
0, //027
0, //028
0, //029
0, //030
0, //031
44, //032 space
128 + 30, //033 ! [SHIFT]
128 + 52, //034 " [SHIFT]
128 + 32, //035 # [SHIFT]
128 + 33, //036 $ [SHIFT]
128 + 34, //037 % [SHIFT]
128 + 36, //038 & [SHIFT]
52, //039 '
128 + 38, //040 ( [SHIFT]
128 + 39, //041 ) [SHIFT]
128 + 37, //042 * [SHIFT]
128 + 46, //043 + [SHIFT]
54, //044 ,
45, //045 - (-)
55, //046 . (.)
56, //047 /
39, //048 0
30, //049 1
31, //050 2
32, //051 3
33, //052 4
34, //053 5
35, //054 6
36, //055 7
37, //056 8
38, //057 9
128 + 51, //058 : [SHIFT]
51, //059 ;
128 + 54, //060 < [SHIFT]
46, //061 =
128 + 55, //062 > [SHIFT]
128 + 56, //063 ? [SHIFT]
128 + 31, //064 @ [SHIFT]
128 + 4, //065 A [SHIFT]
128 + 5, //066 B [SHIFT]
128 + 6, //067 C [SHIFT]
128 + 7, //068 D [SHIFT]
128 + 8, //069 E [SHIFT]
128 + 9, //070 F [SHIFT]
128 + 10, //071 G [SHIFT]
128 + 11, //072 H [SHIFT]
128 + 12, //073 I [SHIFT]
128 + 13, //074 J [SHIFT]
128 + 14, //075 K [SHIFT]
128 + 15, //076 L [SHIFT]
128 + 16, //077 M [SHIFT]
128 + 17, //078 N [SHIFT]
128 + 18, //079 O [SHIFT]
128 + 19, //080 P [SHIFT]
128 + 20, //081 Q [SHIFT]
128 + 21, //082 R [SHIFT]
128 + 22, //083 S [SHIFT]
128 + 23, //084 T [SHIFT]
128 + 24, //085 U [SHIFT]
128 + 25, //086 V [SHIFT]
128 + 26, //087 W [SHIFT]
128 + 27, //088 X [SHIFT]
128 + 28, //089 Y [SHIFT]
128 + 29, //090 Z [SHIFT]
47, //091 [
49, /*092 \ */
48, //093 ]
128 + 35, //094 ^ [SHIFT]
128 + 45, //095 _ [SHIFT] (underscore)
128 + 53, //096 ` [SHIFT] (grave accent)
4, //097 a
5, //098 b
6, //099 c
7, //100 d
8, //101 e
9, //102 f
10, //103 g
11, //104 h
12, //105 i
13, //106 j
14, //107 k
15, //108 l
16, //109 m
17, //110 n
18, //111 o
19, //112 p
20, //113 q
21, //114 r
22, //115 s
23, //116 t
24, //117 u
25, //118 v
26, //119 w
27, //120 x
28, //121 y
29, //122 z
128 + 47, //123 { [SHIFT]
128 + 49, //124 | [SHIFT]
128 + 48, //125 } [SHIFT]
128 + 53, //126 ~ [SHIFT]
0 //127 just in case...
};
public static char getChar(byte keyCode) {
for (int i = 0; i < ASCIItoHID.length; i++) {
if (ASCIItoHID[i] == keyCode) {
return (char)i;
}
}
return 0;
}
public static byte getKeyCode(char c) {
return (byte)ASCIItoHID[c]; //TODO range
}
public static int getKeyCode(int c) {
return ASCIItoHID[c]; //TODO range
}
public static String modifiersToString(byte modifiers) {
String result = "None";
boolean first = true;
byte mod;
for (int i = 0; i < 8; i++) {
mod = (byte)(CTRL_LEFT << i);
if ((modifiers & mod) != 0) {
if ( !first) {
result += ", ";
} else {
result = "";
}
first = false;
result += modifiersMap.get(mod);
}
}
return result;
}
public static String keyToString(byte key) {
String result = keyMap.get(key);
if (result == null) {
result = "Unknown";
}
return result;
}
}

View File

@ -0,0 +1,8 @@
package com.inputstick.api.hid;
public abstract class HIDReport {
public abstract byte[] getBytes();
public abstract int getBytesCount();
}

View File

@ -0,0 +1,56 @@
package com.inputstick.api.hid;
import java.util.LinkedList;
public class HIDTransaction {
private int mID;
private LinkedList<HIDReport> reports;
public HIDTransaction() {
reports = new LinkedList<HIDReport>();
}
public void addReport(HIDReport report) {
reports.add(report);
}
public int getReportsCount() {
return reports.size();
}
public void setID(int id) {
mID = id;
}
public int getID() {
return mID;
}
public boolean hasNext() {
return !reports.isEmpty();
}
public byte[] getNextReport() {
return reports.poll().getBytes();
}
public HIDReport getHIDReportAt(int pos) {
return reports.get(pos);
}
public HIDTransaction split(int n) {
HIDTransaction result = new HIDTransaction();
HIDReport report;
if (n <= reports.size()) {
while(n > 0) {
report = reports.poll();
result.addReport(report);
n--;
}
}
return result;
}
}

View File

@ -0,0 +1,324 @@
package com.inputstick.api.hid;
import java.util.LinkedList;
import java.util.Timer;
import java.util.TimerTask;
import java.util.Vector;
import com.inputstick.api.ConnectionManager;
import com.inputstick.api.HIDInfo;
import com.inputstick.api.OnEmptyBufferListener;
import com.inputstick.api.Packet;
import com.inputstick.api.basic.InputStickHID;
public class HIDTransactionQueue {
private static final int BUFFER_SIZE = 32;
private static final int BT_DELAY = 50; //additional delay for BT overhead
private static final int MAX_PACKETS_PER_UPDATE = 10;
private static final int MAX_IMMEDIATE_PACKETS = 3;
private final LinkedList<HIDTransaction> queue;
private final ConnectionManager mConnectionManager;
private final byte cmd;
private boolean ready;
private int mInterfaceType;
private boolean mustNotify;
private Timer t;
private boolean timerCancelled;
private boolean sentAhead;
private long lastTime;
private long minNextTime;
private int lastReports;
// >= FW 0.93
private boolean bufferInitDone;
private boolean constantUpdateMode;
private int bufferFreeSpace;
private int immediatePacketsLeft;
private int packetsSentSinceLastUpdate;
private int interfaceReadyCnt; //fix BT4.0 lost packet problem
public HIDTransactionQueue(int interfaceType, ConnectionManager connectionManager) {
constantUpdateMode = false;
bufferFreeSpace = BUFFER_SIZE;
interfaceReadyCnt = 0;
queue = new LinkedList<HIDTransaction>();
mConnectionManager = connectionManager;
ready = false;
sentAhead = false;
minNextTime = 0;
mustNotify = false;
mInterfaceType = interfaceType;
switch (interfaceType) {
case InputStickHID.INTERFACE_KEYBOARD:
cmd = Packet.CMD_HID_DATA_KEYB;
//TODO mod
//cmd = Packet.CMD_HID_DATA_KEYB_FAST;
break;
case InputStickHID.INTERFACE_MOUSE:
cmd = Packet.CMD_HID_DATA_MOUSE;
break;
case InputStickHID.INTERFACE_CONSUMER:
cmd = Packet.CMD_HID_DATA_CONSUMER;
break;
default:
cmd = Packet.CMD_DUMMY;
}
}
private int sendNext(int maxReports) {
HIDTransaction transaction;
//assume there is at least 1 element in queue
transaction = queue.peek();
if (transaction.getReportsCount() > maxReports) {
// v0.92
if (maxReports < BUFFER_SIZE) {
//don't split transactions until there is no other way left!
return 0;
}
//transaction too big to fit single packet! split
transaction = transaction.split(BUFFER_SIZE);
} else {
queue.removeFirst();
}
byte reports = 0;
ready = false;
Packet p = new Packet(false, cmd, reports);
while (transaction.hasNext()) {
p.addBytes(transaction.getNextReport());
//TODO mod
//byte[] r = transaction.getNextReport();
//p.addByte(r[0]);
//p.addByte(r[2]);
reports++;
}
while(true) {
if (queue.isEmpty()) {
break;
}
transaction = queue.peek();
if (reports + transaction.getReportsCount() < maxReports) {
queue.removeFirst();
while (transaction.hasNext()) {
p.addBytes(transaction.getNextReport());
//TODO mod
//byte[] r = transaction.getNextReport();
//p.addByte(r[0]);
//p.addByte(r[2]);
reports++;
}
} else {
break;
}
}
//!! total number of reports must be < 32 ! (max packet limitation)
p.modifyByte(1, reports); //set reports count
mConnectionManager.sendPacket(p);
interfaceReadyCnt = 0;
lastReports = reports;
lastTime = System.currentTimeMillis();
minNextTime = lastTime + (lastReports * 4) + BT_DELAY;
if (queue.isEmpty()) {
notifyOnLocalBufferEmpty();
}
return reports;
}
private void notifyOnRemoteBufferEmpty() {
Vector<OnEmptyBufferListener> listeners = InputStickHID.getBufferEmptyListeners();
for (OnEmptyBufferListener listener : listeners) {
listener.onRemoteBufferEmpty(mInterfaceType);
}
}
private void notifyOnLocalBufferEmpty() {
Vector<OnEmptyBufferListener> listeners = InputStickHID.getBufferEmptyListeners();
for (OnEmptyBufferListener listener : listeners) {
listener.onLocalBufferEmpty(mInterfaceType);
}
}
public synchronized boolean isLocalBufferEmpty() {
return queue.isEmpty();
}
public synchronized boolean isRemoteBufferEmpty() {
if ((queue.isEmpty()) && (bufferFreeSpace == BUFFER_SIZE)) {
return true;
}
if (queue.isEmpty() && ( !mustNotify)) {
return true;
} else {
return false;
}
}
public synchronized void clearBuffer() {
queue.clear();
}
public synchronized void addTransaction(HIDTransaction transaction) {
if ( !bufferInitDone) {
queue.add(transaction);
return;
}
if (constantUpdateMode) {
queue.add(transaction);
sendToBuffer(true);
return;
}
mustNotify = true;
//using sentAhead will slow down mouse. FW0.92 will solve the problems
if ((queue.isEmpty()) && (System.currentTimeMillis() > minNextTime) /*&& ( !sentAhead)*/) {
sentAhead = true;
ready = true;
}
queue.add(transaction);
if (ready) {
sendNext(BUFFER_SIZE);
}
}
private synchronized void timerAction() {
if ( !timerCancelled) {
if (sentAhead) {
deviceReady(null, 0); //will set sentAhead to false;
sentAhead = true; //restore value
} else {
deviceReady(null, 0);
}
}
}
public synchronized void deviceReady(HIDInfo hidInfo, int reportsSentToHost) {
//it is possible that in the meantime some packets has been sent to IS!!!
bufferInitDone = true;
if (hidInfo != null) {
if (hidInfo.isSentToHostInfoAvailable()) {
//BT4.0 lost packets fix:
if (bufferFreeSpace < BUFFER_SIZE) {
boolean interfaceReady = false;
if (mInterfaceType == InputStickHID.INTERFACE_KEYBOARD) {
interfaceReady = hidInfo.isKeyboardReady();
}
if (mInterfaceType == InputStickHID.INTERFACE_MOUSE) {
interfaceReady = hidInfo.isMouseReady();
}
if (mInterfaceType == InputStickHID.INTERFACE_CONSUMER) {
interfaceReady = hidInfo.isConsumerReady();
}
if (interfaceReady) {
interfaceReadyCnt++;
if (interfaceReadyCnt == 10) {
bufferFreeSpace = BUFFER_SIZE;
}
} else {
interfaceReadyCnt = 0;
}
}
constantUpdateMode = true;
// >= FW 0.93
bufferFreeSpace += reportsSentToHost;
if ((bufferFreeSpace == BUFFER_SIZE) && (queue.isEmpty())) {
notifyOnRemoteBufferEmpty();
}
immediatePacketsLeft = MAX_IMMEDIATE_PACKETS;
//reportsSentSinceLastUpdate = 0;
packetsSentSinceLastUpdate = 0;
sendToBuffer(false);
return;
}
}
long now = System.currentTimeMillis();
//System.out.println("v90 HID update");
if (now < minNextTime) {
//set timer, just in case if deviceReady won't be called again
timerCancelled = false;
t = new Timer();
t.schedule(new TimerTask() {
@Override
public void run() {
timerAction();
}
}, (minNextTime - now + 1));
} else {
timerCancelled = true;
sentAhead = false;
if (!queue.isEmpty()) {
sendNext(BUFFER_SIZE);
} else {
ready = true;
//queue is empty, InputStick reported that buffer is empty, data was added since last notification
if (mustNotify) {
notifyOnRemoteBufferEmpty();
mustNotify = false;
}
}
}
}
public synchronized void sendToBuffer(boolean justAdded) {
if ((justAdded) && (immediatePacketsLeft <= 0)) {
return;
}
if ( !InputStickHID.isReady()) {
return;
}
if (queue.isEmpty()) {
return;
}
if (bufferFreeSpace <= 0) {
return;
}
if (packetsSentSinceLastUpdate >= MAX_PACKETS_PER_UPDATE) {
return;
}
int reportsSent = sendNext(bufferFreeSpace);
if (reportsSent > 0) {
if (justAdded) {
immediatePacketsLeft --;
}
bufferFreeSpace -= reportsSent;
packetsSentSinceLastUpdate ++;
}
}
}

View File

@ -0,0 +1,36 @@
package com.inputstick.api.hid;
public class KeyboardReport extends HIDReport {
public static final int SIZE = 8;
private byte[] data;
public KeyboardReport(byte modifier, byte key0, byte key1, byte key2, byte key3, byte key4, byte key5) {
data = new byte[SIZE];
data[0] = modifier;
data[2] = key0;
data[3] = key1;
data[4] = key2;
data[5] = key3;
data[6] = key4;
data[7] = key5;
}
public KeyboardReport() {
this((byte)0, (byte)0, (byte)0, (byte)0, (byte)0, (byte)0, (byte)0);
}
public KeyboardReport(byte modifier, byte key) {
this(modifier, key, (byte)0, (byte)0, (byte)0, (byte)0, (byte)0);
}
public byte[] getBytes() {
return data;
}
public int getBytesCount() {
return SIZE;
}
}

View File

@ -0,0 +1,29 @@
package com.inputstick.api.hid;
public class MouseReport extends HIDReport {
public static final int SIZE = 4;
private byte[] data;
public MouseReport(byte buttons, byte x, byte y, byte wheel) {
data = new byte[SIZE];
data[0] = buttons;
data[1] = x;
data[2] = y;
data[3] = wheel;
}
public MouseReport() {
this((byte)0, (byte)0, (byte)0, (byte)0);
}
public byte[] getBytes() {
return data;
}
public int getBytesCount() {
return SIZE;
}
}

View File

@ -0,0 +1,97 @@
package com.inputstick.api.init;
import android.os.Handler;
import com.inputstick.api.InputStickError;
import com.inputstick.api.Packet;
public class BasicInitManager extends InitManager {
private int lastStatusParam;
private Handler handler;
private boolean cancelled;
public BasicInitManager(byte[] key) {
super(key);
lastStatusParam = 0;
}
@Override
public void onConnected() {
lastStatusParam = 0;
cancelled = false;
initDone = false;
sendPacket(new Packet(true, Packet.CMD_RUN_FW));
handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
if ((!cancelled) && ( !initDone)) {
sendPacket(new Packet(true, Packet.CMD_RUN_FW));
}
}
}, 1000);
handler.postDelayed(new Runnable() {
@Override
public void run() {
if ((!cancelled) && ( !initDone)) {
mListener.onInitFailure(InputStickError.ERROR_INIT_TIMEDOUT);
}
}
}, 2000);
}
@Override
public void onDisconnected() {
cancelled = true;
}
@Override
public void onData(byte[] data) {
byte cmd = data[0];
byte respCode = data[1];
byte param = data[1];
switch (cmd) {
case Packet.CMD_RUN_FW:
sendPacket(new Packet(true, Packet.CMD_FW_INFO));
break;
case Packet.CMD_FW_INFO:
onFWInfo(data, true, true, new Packet(true, Packet.CMD_INIT)); //TODO next FW: params!
break;
case Packet.CMD_INIT:
if (respCode == Packet.RESP_OK) {
initDone = true;
sendPacket(new Packet(true, Packet.CMD_HID_STATUS_REPORT));
} else {
mListener.onInitFailure(respCode);
}
break;
case Packet.CMD_INIT_AUTH:
initDone = onAuth(data, true, new Packet(true, Packet.CMD_INIT)); //TODO next FW: params!
break;
case Packet.CMD_HID_STATUS:
if (mKey == null) {
initDone = true;
}
if (initDone) {
if (param != lastStatusParam) {
lastStatusParam = param;
if (param == 0x05) {
mListener.onInitReady();
} else {
mListener.onInitNotReady();
}
}
}
break;
}
}
}

View File

@ -0,0 +1,93 @@
package com.inputstick.api.init;
public class DeviceInfo {
private int firmwareType;
private int versionMajor;
private int versionMinor;
private int versionHardware;
private int securityStatus;
private boolean passwordProtected;
public DeviceInfo(byte[] data) {
//cmd, param
firmwareType = data[2];
versionMajor = data[3];
versionMinor = data[4];
versionHardware = data[5];
//6,7,8,9
//10,11,12,13
//14,15,16,17
//18,19
securityStatus = data[19];
if (data[20] == 0) {
passwordProtected = false;
} else {
passwordProtected = true;
}
}
public int getSecurityStatus() {
return securityStatus;
}
public boolean isAuthenticated() {
return ((securityStatus & 0x10) != 0);
}
public boolean isUnlocked() {
if (getFirmwareVersion() < 96) {
return true;
} else {
return ((securityStatus & 0x08) != 0);
}
}
public int getFirmwareType() {
return firmwareType;
}
public boolean isPasswordProtected() {
return passwordProtected;
}
public int getVersionMinor() {
return versionMinor;
}
public int getVersionMajor() {
return versionMajor;
}
public int getHardwareVersion() {
return versionHardware;
}
public int getFirmwareVersion() {
return (versionMajor) * 100 + versionMinor;
}
public boolean supportsEncryption() {
return (getFirmwareVersion() >= 91);
}
public boolean supportsPinChange() {
return (getFirmwareVersion() >= 97);
}
public boolean supportsGamepad() {
return (getFirmwareVersion() >= 97);
}
public boolean supportsRestoreOptions() {
return (getFirmwareVersion() >= 98);
}
}

View File

@ -0,0 +1,112 @@
package com.inputstick.api.init;
import com.inputstick.api.InputStickError;
import com.inputstick.api.Packet;
import com.inputstick.api.PacketManager;
public class InitManager {
public static final int DEFAULT_INIT_TIMEOUT = 60000; //60s init timeout
protected PacketManager mPacketManager;
protected InitManagerListener mListener;
protected byte[] mKey;
protected DeviceInfo mInfo;
protected boolean initDone;
public InitManager(byte[] key) {
mKey = key;
}
public DeviceInfo getDeviceInfo() {
return mInfo;
}
public boolean isEncrypted() {
return mPacketManager.isEncrypted();
}
public void init(InitManagerListener listener, PacketManager packetManager) {
mListener = listener;
mPacketManager = packetManager;
initDone = false;
}
public void onConnected() {
mListener.onInitReady();
}
public void onDisconnected() {
}
public void onData(byte[] data) {
//byte cmd = data[0];
//byte param = data[1];
}
public void sendPacket(Packet p) {
mPacketManager.sendPacket(p);
}
public void onFWInfo(byte[] data, boolean authenticate, boolean enableEncryption, Packet sendNext) {
mInfo = new DeviceInfo(data);
if (authenticate) {
if (mInfo.isPasswordProtected()) {
if (mKey != null) {
//authenticate
sendPacket(mPacketManager.encPacket(enableEncryption));
} else {
mListener.onInitFailure(InputStickError.ERROR_SECURITY_NO_KEY);
}
} else {
if (mKey != null) {
//possible scenarios: FW upgrade / password removed using other device/app / tampering!
mListener.onInitFailure(InputStickError.ERROR_SECURITY_NOT_PROTECTED);
}
sendPacket(sendNext);
}
} else {
sendPacket(sendNext);
}
}
public boolean onAuth(byte[] data, boolean enableOutEncryption, Packet sendNext) {
byte respCode = data[1];
switch (respCode) {
case Packet.RESP_OK:
byte[] cmp = new byte[16];
//TODO check length!
System.arraycopy(data, 2, cmp, 0, 16);
if (mPacketManager.setEncryption(cmp, enableOutEncryption)) {
sendPacket(sendNext);
return true;
} else {
mListener.onInitFailure(InputStickError.ERROR_SECURITY_CHALLENGE);
}
break;
case 0x20:
mListener.onInitFailure(InputStickError.ERROR_SECURITY_INVALID_KEY);
break;
case 0x21:
mListener.onInitFailure(InputStickError.ERROR_SECURITY_NOT_PROTECTED);
break;
case Packet.RESP_UNKNOWN_CMD:
mListener.onInitFailure(InputStickError.ERROR_SECURITY_NOT_SUPPORTED);
break;
default:
mListener.onInitFailure(InputStickError.ERROR_SECURITY);
}
return false;
}
}

View File

@ -0,0 +1,9 @@
package com.inputstick.api.init;
public interface InitManagerListener {
public void onInitReady();
public void onInitNotReady();
public void onInitFailure(int code);
}

View File

@ -0,0 +1,390 @@
package com.inputstick.api.layout;
public class DanishLayout extends KeyboardLayout {
public static final String LOCALE_NAME = "da-DK";
//{char (16b unicode), modifier, key, deadkey_modifier, deadkey}
//da-DK
private static final int[][] FAST_LUT = {
{ 0, 0, 0, 0, 0 }, // empty
{ 27, 1, 47, 0, 0 }, // 
{ 28, 1, 53, 0, 0 }, // 
{ 29, 1, 48, 0, 0 }, // 
{ 32, 0, 44, 0, 0 }, //
{ 33, 2, 30, 0, 0 }, // !
{ 34, 2, 31, 0, 0 }, // "
{ 35, 2, 32, 0, 0 }, // #
{ 36, 64, 33, 0, 0 }, // $
{ 37, 2, 34, 0, 0 }, // %
{ 38, 2, 35, 0, 0 }, // &
{ 39, 0, 49, 0, 0 }, // '
{ 40, 2, 37, 0, 0 }, // (
{ 41, 2, 38, 0, 0 }, // )
{ 42, 2, 49, 0, 0 }, // *
{ 43, 0, 45, 0, 0 }, // +
{ 44, 0, 54, 0, 0 }, // ,
{ 45, 0, 56, 0, 0 }, // -
{ 46, 0, 55, 0, 0 }, // .
{ 47, 2, 36, 0, 0 }, // /
{ 48, 0, 39, 0, 0 }, // 0
{ 49, 0, 30, 0, 0 }, // 1
{ 50, 0, 31, 0, 0 }, // 2
{ 51, 0, 32, 0, 0 }, // 3
{ 52, 0, 33, 0, 0 }, // 4
{ 53, 0, 34, 0, 0 }, // 5
{ 54, 0, 35, 0, 0 }, // 6
{ 55, 0, 36, 0, 0 }, // 7
{ 56, 0, 37, 0, 0 }, // 8
{ 57, 0, 38, 0, 0 }, // 9
{ 58, 2, 55, 0, 0 }, // :
{ 59, 2, 54, 0, 0 }, // ;
{ 60, 0, 100, 0, 0 }, // <
{ 61, 2, 39, 0, 0 }, // =
{ 62, 2, 100, 0, 0 }, // >
{ 63, 2, 45, 0, 0 }, // ?
{ 64, 64, 31, 0, 0 }, // @
{ 65, 2, 4, 0, 0 }, // A
{ 66, 2, 5, 0, 0 }, // B
{ 67, 2, 6, 0, 0 }, // C
{ 68, 2, 7, 0, 0 }, // D
{ 69, 2, 8, 0, 0 }, // E
{ 70, 2, 9, 0, 0 }, // F
{ 71, 2, 10, 0, 0 }, // G
{ 72, 2, 11, 0, 0 }, // H
{ 73, 2, 12, 0, 0 }, // I
{ 74, 2, 13, 0, 0 }, // J
{ 75, 2, 14, 0, 0 }, // K
{ 76, 2, 15, 0, 0 }, // L
{ 77, 2, 16, 0, 0 }, // M
{ 78, 2, 17, 0, 0 }, // N
{ 79, 2, 18, 0, 0 }, // O
{ 80, 2, 19, 0, 0 }, // P
{ 81, 2, 20, 0, 0 }, // Q
{ 82, 2, 21, 0, 0 }, // R
{ 83, 2, 22, 0, 0 }, // S
{ 84, 2, 23, 0, 0 }, // T
{ 85, 2, 24, 0, 0 }, // U
{ 86, 2, 25, 0, 0 }, // V
{ 87, 2, 26, 0, 0 }, // W
{ 88, 2, 27, 0, 0 }, // X
{ 89, 2, 28, 0, 0 }, // Y
{ 90, 2, 29, 0, 0 }, // Z
{ 91, 64, 37, 0, 0 }, // [
{ 92, 64, 100, 0, 0 }, // \
{ 93, 64, 38, 0, 0 }, // ]
{ 94, 0, 44, 2, 48 }, // ^
{ 95, 2, 56, 0, 0 }, // _
{ 96, 0, 44, 2, 46 }, // `
{ 97, 0, 4, 0, 0 }, // a
{ 98, 0, 5, 0, 0 }, // b
{ 99, 0, 6, 0, 0 }, // c
{ 100, 0, 7, 0, 0 }, // d
{ 101, 0, 8, 0, 0 }, // e
{ 102, 0, 9, 0, 0 }, // f
{ 103, 0, 10, 0, 0 }, // g
{ 104, 0, 11, 0, 0 }, // h
{ 105, 0, 12, 0, 0 }, // i
{ 106, 0, 13, 0, 0 }, // j
{ 107, 0, 14, 0, 0 }, // k
{ 108, 0, 15, 0, 0 }, // l
{ 109, 0, 16, 0, 0 }, // m
{ 110, 0, 17, 0, 0 }, // n
{ 111, 0, 18, 0, 0 }, // o
{ 112, 0, 19, 0, 0 }, // p
{ 113, 0, 20, 0, 0 }, // q
{ 114, 0, 21, 0, 0 }, // r
{ 115, 0, 22, 0, 0 }, // s
{ 116, 0, 23, 0, 0 }, // t
{ 117, 0, 24, 0, 0 }, // u
{ 118, 0, 25, 0, 0 }, // v
{ 119, 0, 26, 0, 0 }, // w
{ 120, 0, 27, 0, 0 }, // x
{ 121, 0, 28, 0, 0 }, // y
{ 122, 0, 29, 0, 0 }, // z
{ 123, 64, 36, 0, 0 }, // {
{ 124, 64, 46, 0, 0 }, // |
{ 125, 64, 39, 0, 0 }, // }
{ 126, 0, 44, 64, 48 }, // ~
{ 163, 64, 32, 0, 0 }, // ?
{ 164, 2, 33, 0, 0 }, // ¤
{ 167, 2, 53, 0, 0 }, // §
{ 168, 0, 44, 0, 48 }, // ¨
{ 180, 0, 44, 0, 46 }, // ´
{ 181, 64, 16, 0, 0 }, // µ
{ 189, 0, 53, 0, 0 }, // ?
{ 192, 2, 4, 2, 46 }, // ?
{ 193, 2, 4, 0, 46 }, // Á
{ 194, 2, 4, 2, 48 }, // Â
{ 195, 2, 4, 64, 48 }, // ?
{ 196, 2, 4, 0, 48 }, // Ä
{ 197, 2, 47, 0, 0 }, // ?
{ 198, 2, 51, 0, 0 }, // ?
{ 200, 2, 8, 2, 46 }, // ?
{ 201, 2, 8, 0, 46 }, // É
{ 202, 2, 8, 2, 48 }, // ?
{ 203, 2, 8, 0, 48 }, // Ë
{ 204, 2, 12, 2, 46 }, // ?
{ 205, 2, 12, 0, 46 }, // Í
{ 206, 2, 12, 2, 48 }, // Î
{ 207, 2, 12, 0, 48 }, // ?
{ 209, 2, 17, 64, 48 }, // ?
{ 210, 2, 18, 2, 46 }, // ?
{ 211, 2, 18, 0, 46 }, // Ó
{ 212, 2, 18, 2, 48 }, // Ô
{ 213, 2, 18, 64, 48 }, // ?
{ 214, 2, 18, 0, 48 }, // Ö
{ 216, 2, 52, 0, 0 }, // ?
{ 217, 2, 24, 2, 46 }, // ?
{ 218, 2, 24, 0, 46 }, // Ú
{ 219, 2, 24, 2, 48 }, // ?
{ 220, 2, 24, 0, 48 }, // Ü
{ 221, 2, 28, 0, 46 }, // Ý
{ 224, 0, 4, 2, 46 }, // ?
{ 225, 0, 4, 0, 46 }, // á
{ 226, 0, 4, 2, 48 }, // â
{ 227, 0, 4, 64, 48 }, // ?
{ 228, 0, 4, 0, 48 }, // ä
{ 229, 0, 47, 0, 0 }, // ?
{ 230, 0, 51, 0, 0 }, // ?
{ 232, 0, 8, 2, 46 }, // ?
{ 233, 0, 8, 0, 46 }, // é
{ 234, 0, 8, 2, 48 }, // ?
{ 235, 0, 8, 0, 48 }, // ë
{ 236, 0, 12, 2, 46 }, // ?
{ 237, 0, 12, 0, 46 }, // í
{ 238, 0, 12, 2, 48 }, // î
{ 239, 0, 12, 0, 48 }, // ?
{ 241, 0, 17, 64, 48 }, // ?
{ 242, 0, 18, 2, 46 }, // ?
{ 243, 0, 18, 0, 46 }, // ó
{ 244, 0, 18, 2, 48 }, // ô
{ 245, 0, 18, 64, 48 }, // ?
{ 246, 0, 18, 0, 48 }, // ö
{ 248, 0, 52, 0, 0 }, // ?
{ 249, 0, 24, 2, 46 }, // ?
{ 250, 0, 24, 0, 46 }, // ú
{ 251, 0, 24, 2, 48 }, // ?
{ 252, 0, 24, 0, 48 }, // ü
{ 253, 0, 28, 0, 46 }, // ý
{ 255, 0, 28, 0, 48 }, // ?
{ 8364, 64, 34, 0, 0 }, //
};
public static final int LUT[][] = {
/* 0 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 1 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 2 */ { 0 , (int)'1' , 0x0021 , -1 , -1 , -1 } ,
/* 3 */ { 0 , (int)'2' , 0x0022 , -1 , 0x0040 , -1 } ,
/* 4 */ { 0 , (int)'3' , 0x0023 , -1 , 0x00a3 , -1 } ,
/* 5 */ { 0 , (int)'4' , 0x00a4 , -1 , 0x0024 , -1 } ,
/* 6 */ { 0 , (int)'5' , 0x0025 , -1 , 0x20ac , -1 } ,
/* 7 */ { 0 , (int)'6' , 0x0026 , -1 , -1 , -1 } ,
/* 8 */ { 0 , (int)'7' , 0x002f , -1 , 0x007b , -1 } ,
/* 9 */ { 0 , (int)'8' , 0x0028 , -1 , 0x005b , -1 } ,
/* 0a */ { 0 , (int)'9' , 0x0029 , -1 , 0x005d , -1 } ,
/* 0b */ { 0 , (int)'0' , 0x003d , -1 , 0x007d , -1 } ,
/* 0c */ { 0 , 0x002b , 0x003f , -1 , -1 , -1 } ,
/* 0d */ { 0 , 0x00b4 , 0x0060 , -1 , 0x007c , -1 } ,
/* 0e */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 0f */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 10 */ { 1 , (int)'q' , (int)'Q' , -1 , -1 , -1 } ,
/* 11 */ { 1 , (int)'w' , (int)'W' , -1 , -1 , -1 } ,
/* 12 */ { 1 , (int)'e' , (int)'E' , -1 , 0x20ac , -1 } ,
/* 13 */ { 1 , (int)'r' , (int)'R' , -1 , -1 , -1 } ,
/* 14 */ { 1 , (int)'t' , (int)'T' , -1 , -1 , -1 } ,
/* 15 */ { 1 , (int)'y' , (int)'Y' , -1 , -1 , -1 } ,
/* 16 */ { 1 , (int)'u' , (int)'U' , -1 , -1 , -1 } ,
/* 17 */ { 1 , (int)'i' , (int)'I' , -1 , -1 , -1 } ,
/* 18 */ { 1 , (int)'o' , (int)'O' , -1 , -1 , -1 } ,
/* 19 */ { 1 , (int)'p' , (int)'P' , -1 , -1 , -1 } ,
/* 1a */ { 1 , 0x00e5 , 0x00c5 , 0x001b , -1 , -1 } ,
/* 1b */ { 0 , 0x00a8 , 0x005e , 0x001d , 0x007e , -1 } ,
/* 1c */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 1d */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 1e */ { 1 , (int)'a' , (int)'A' , -1 , -1 , -1 } ,
/* 1f */ { 1 , (int)'s' , (int)'S' , -1 , -1 , -1 } ,
/* 20 */ { 1 , (int)'d' , (int)'D' , -1 , -1 , -1 } ,
/* 21 */ { 1 , (int)'f' , (int)'F' , -1 , -1 , -1 } ,
/* 22 */ { 1 , (int)'g' , (int)'G' , -1 , -1 , -1 } ,
/* 23 */ { 1 , (int)'h' , (int)'H' , -1 , -1 , -1 } ,
/* 24 */ { 1 , (int)'j' , (int)'J' , -1 , -1 , -1 } ,
/* 25 */ { 1 , (int)'k' , (int)'K' , -1 , -1 , -1 } ,
/* 26 */ { 1 , (int)'l' , (int)'L' , -1 , -1 , -1 } ,
/* 27 */ { 1 , 0x00e6 , 0x00c6 , -1 , -1 , -1 } ,
/* 28 */ { 1 , 0x00f8 , 0x00d8 , -1 , -1 , -1 } ,
/* 29 */ { 0 , 0x00bd , 0x00a7 , 0x001c , -1 , -1 } ,
/* 2a */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 2b */ { 0 , 0x0027 , 0x002a , -1 , -1 , -1 } ,
/* 2c */ { 1 , (int)'z' , (int)'Z' , -1 , -1 , -1 } ,
/* 2d */ { 1 , (int)'x' , (int)'X' , -1 , -1 , -1 } ,
/* 2e */ { 1 , (int)'c' , (int)'C' , -1 , -1 , -1 } ,
/* 2f */ { 1 , (int)'v' , (int)'V' , -1 , -1 , -1 } ,
/* 30 */ { 1 , (int)'b' , (int)'B' , -1 , -1 , -1 } ,
/* 31 */ { 1 , (int)'n' , (int)'N' , -1 , -1 , -1 } ,
/* 32 */ { 1 , (int)'m' , (int)'M' , -1 , 0x00b5 , -1 } ,
/* 33 */ { 0 , 0x002c , 0x003b , -1 , -1 , -1 } ,
/* 34 */ { 0 , 0x002e , 0x003a , -1 , -1 , -1 } ,
/* 35 */ { 0 , 0x002d , 0x005f , -1 , -1 , -1 } ,
/* 36 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 37 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 38 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 39 */ { 0 , 0x0020 , 0x0020 , 0x0020 , -1 , -1 } ,
/* 3a */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 3b */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 3c */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 3d */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 3e */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 3f */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 40 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 41 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 42 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 43 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 44 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 45 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 46 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 47 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 48 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 49 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 4a */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 4b */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 4c */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 4d */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 4e */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 4f */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 50 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 51 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 52 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 53 */ { 0 , 0x002c , 0x002c , -1 , -1 , -1 } ,
/* 54 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 55 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 56 */ { 0 , 0x003c , 0x003e , 0x001c , 0x005c , -1 } ,
/* 57 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 58 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 59 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 5a */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 5b */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 5c */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 5d */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 5e */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 5f */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
};
public static final int DEADKEYS[] = {
0x00b4, 0x0060, 0x00a8, 0x005e, 0x007e
};
public static final int DEADKEY_LUT[][] = {
{ 0x00b4 , 0x0061 , 0x00e1 },
{ 0x00b4 , 0x0065 , 0x00e9 },
{ 0x00b4 , 0x0075 , 0x00fa },
{ 0x00b4 , 0x0069 , 0x00ed },
{ 0x00b4 , 0x0079 , 0x00fd },
{ 0x00b4 , 0x006f , 0x00f3 },
{ 0x00b4 , 0x0041 , 0x00c1 },
{ 0x00b4 , 0x0045 , 0x00c9 },
{ 0x00b4 , 0x0055 , 0x00da },
{ 0x00b4 , 0x0049 , 0x00cd },
{ 0x00b4 , 0x0059 , 0x00dd },
{ 0x00b4 , 0x004f , 0x00d3 },
{ 0x00b4 , 0x0020 , 0x00b4 },
{ 0x0060 , 0x0061 , 0x00e0 },
{ 0x0060 , 0x0065 , 0x00e8 },
{ 0x0060 , 0x0075 , 0x00f9 },
{ 0x0060 , 0x0069 , 0x00ec },
{ 0x0060 , 0x006f , 0x00f2 },
{ 0x0060 , 0x0041 , 0x00c0 },
{ 0x0060 , 0x0045 , 0x00c8 },
{ 0x0060 , 0x0055 , 0x00d9 },
{ 0x0060 , 0x0049 , 0x00cc },
{ 0x0060 , 0x004f , 0x00d2 },
{ 0x0060 , 0x0020 , 0x0060 },
{ 0x00a8 , 0x0061 , 0x00e4 },
{ 0x00a8 , 0x0065 , 0x00eb },
{ 0x00a8 , 0x0075 , 0x00fc },
{ 0x00a8 , 0x0069 , 0x00ef },
{ 0x00a8 , 0x0079 , 0x00ff },
{ 0x00a8 , 0x006f , 0x00f6 },
{ 0x00a8 , 0x0041 , 0x00c4 },
{ 0x00a8 , 0x0045 , 0x00cb },
{ 0x00a8 , 0x0055 , 0x00dc },
{ 0x00a8 , 0x0049 , 0x00cf },
{ 0x00a8 , 0x004f , 0x00d6 },
{ 0x00a8 , 0x0020 , 0x00a8 },
{ 0x005e , 0x0061 , 0x00e2 },
{ 0x005e , 0x0065 , 0x00ea },
{ 0x005e , 0x0075 , 0x00fb },
{ 0x005e , 0x0069 , 0x00ee },
{ 0x005e , 0x006f , 0x00f4 },
{ 0x005e , 0x0041 , 0x00c2 },
{ 0x005e , 0x0045 , 0x00ca },
{ 0x005e , 0x0055 , 0x00db },
{ 0x005e , 0x0049 , 0x00ce },
{ 0x005e , 0x004f , 0x00d4 },
{ 0x005e , 0x0020 , 0x005e },
{ 0x007e , 0x006e , 0x00f1 },
{ 0x007e , 0x0061 , 0x00e3 },
{ 0x007e , 0x006f , 0x00f5 },
{ 0x007e , 0x004e , 0x00d1 },
{ 0x007e , 0x0041 , 0x00c3 },
{ 0x007e , 0x004f , 0x00d5 },
{ 0x007e , 0x0020 , 0x007e },
};
private static DanishLayout instance = new DanishLayout();
private DanishLayout() {
}
public static DanishLayout getInstance() {
return instance;
}
@Override
public int[][] getLUT() {
return LUT;
}
@Override
public int[][] getFastLUT() {
return FAST_LUT;
}
@Override
public void type(String text) {
super.type(FAST_LUT, text, (byte)0);
}
@Override
public void type(String text, byte modifiers) {
super.type(FAST_LUT, text, modifiers);
}
@Override
public char getChar(int scanCode, boolean capsLock, boolean shift, boolean altGr) {
return super.getChar(LUT, scanCode, capsLock, shift, altGr);
}
@Override
public String getLocaleName() {
return LOCALE_NAME;
}
@Override
public int[][] getDeadkeyLUT() {
return DEADKEY_LUT;
}
@Override
public int[] getDeadkeys() {
return DEADKEYS;
}
}

View File

@ -0,0 +1,269 @@
package com.inputstick.api.layout;
public class DvorakLayout extends KeyboardLayout {
public static final String LOCALE_NAME = "en-DV";
//{char (16b unicode), modifier, key, deadkey_modifier, deadkey}
//en-DV
private static final int[][] FAST_LUT = {
{ 0, 0, 0, 0, 0 }, // empty
{ 27, 1, 45, 0, 0 }, // 
{ 28, 1, 49, 0, 0 }, // 
{ 29, 1, 46, 0, 0 }, // 
{ 32, 0, 44, 0, 0 }, //
{ 33, 2, 30, 0, 0 }, // !
{ 34, 2, 20, 0, 0 }, // "
{ 35, 2, 32, 0, 0 }, // #
{ 36, 2, 33, 0, 0 }, // $
{ 37, 2, 34, 0, 0 }, // %
{ 38, 2, 36, 0, 0 }, // &
{ 39, 0, 20, 0, 0 }, // '
{ 40, 2, 38, 0, 0 }, // (
{ 41, 2, 39, 0, 0 }, // )
{ 42, 2, 37, 0, 0 }, // *
{ 43, 2, 48, 0, 0 }, // +
{ 44, 0, 26, 0, 0 }, // ,
{ 45, 0, 52, 0, 0 }, // -
{ 46, 0, 8, 0, 0 }, // .
{ 47, 0, 47, 0, 0 }, // /
{ 48, 0, 39, 0, 0 }, // 0
{ 49, 0, 30, 0, 0 }, // 1
{ 50, 0, 31, 0, 0 }, // 2
{ 51, 0, 32, 0, 0 }, // 3
{ 52, 0, 33, 0, 0 }, // 4
{ 53, 0, 34, 0, 0 }, // 5
{ 54, 0, 35, 0, 0 }, // 6
{ 55, 0, 36, 0, 0 }, // 7
{ 56, 0, 37, 0, 0 }, // 8
{ 57, 0, 38, 0, 0 }, // 9
{ 58, 2, 29, 0, 0 }, // :
{ 59, 0, 29, 0, 0 }, // ;
{ 60, 2, 26, 0, 0 }, // <
{ 61, 0, 48, 0, 0 }, // =
{ 62, 2, 8, 0, 0 }, // >
{ 63, 2, 47, 0, 0 }, // ?
{ 64, 2, 31, 0, 0 }, // @
{ 65, 2, 4, 0, 0 }, // A
{ 66, 2, 17, 0, 0 }, // B
{ 67, 2, 12, 0, 0 }, // C
{ 68, 2, 11, 0, 0 }, // D
{ 69, 2, 7, 0, 0 }, // E
{ 70, 2, 28, 0, 0 }, // F
{ 71, 2, 24, 0, 0 }, // G
{ 72, 2, 13, 0, 0 }, // H
{ 73, 2, 10, 0, 0 }, // I
{ 74, 2, 6, 0, 0 }, // J
{ 75, 2, 25, 0, 0 }, // K
{ 76, 2, 19, 0, 0 }, // L
{ 77, 2, 16, 0, 0 }, // M
{ 78, 2, 15, 0, 0 }, // N
{ 79, 2, 22, 0, 0 }, // O
{ 80, 2, 21, 0, 0 }, // P
{ 81, 2, 27, 0, 0 }, // Q
{ 82, 2, 18, 0, 0 }, // R
{ 83, 2, 51, 0, 0 }, // S
{ 84, 2, 14, 0, 0 }, // T
{ 85, 2, 9, 0, 0 }, // U
{ 86, 2, 55, 0, 0 }, // V
{ 87, 2, 54, 0, 0 }, // W
{ 88, 2, 5, 0, 0 }, // X
{ 89, 2, 23, 0, 0 }, // Y
{ 90, 2, 56, 0, 0 }, // Z
{ 91, 0, 45, 0, 0 }, // [
{ 92, 0, 49, 0, 0 }, // \
{ 93, 0, 46, 0, 0 }, // ]
{ 94, 2, 35, 0, 0 }, // ^
{ 95, 2, 52, 0, 0 }, // _
{ 96, 0, 53, 0, 0 }, // `
{ 97, 0, 4, 0, 0 }, // a
{ 98, 0, 17, 0, 0 }, // b
{ 99, 0, 12, 0, 0 }, // c
{ 100, 0, 11, 0, 0 }, // d
{ 101, 0, 7, 0, 0 }, // e
{ 102, 0, 28, 0, 0 }, // f
{ 103, 0, 24, 0, 0 }, // g
{ 104, 0, 13, 0, 0 }, // h
{ 105, 0, 10, 0, 0 }, // i
{ 106, 0, 6, 0, 0 }, // j
{ 107, 0, 25, 0, 0 }, // k
{ 108, 0, 19, 0, 0 }, // l
{ 109, 0, 16, 0, 0 }, // m
{ 110, 0, 15, 0, 0 }, // n
{ 111, 0, 22, 0, 0 }, // o
{ 112, 0, 21, 0, 0 }, // p
{ 113, 0, 27, 0, 0 }, // q
{ 114, 0, 18, 0, 0 }, // r
{ 115, 0, 51, 0, 0 }, // s
{ 116, 0, 14, 0, 0 }, // t
{ 117, 0, 9, 0, 0 }, // u
{ 118, 0, 55, 0, 0 }, // v
{ 119, 0, 54, 0, 0 }, // w
{ 120, 0, 5, 0, 0 }, // x
{ 121, 0, 23, 0, 0 }, // y
{ 122, 0, 56, 0, 0 }, // z
{ 123, 2, 45, 0, 0 }, // {
{ 124, 2, 49, 0, 0 }, // |
{ 125, 2, 46, 0, 0 }, // }
{ 126, 2, 53, 0, 0 }, // ~
};
public static final int LUT[][] = {
/* 0 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 1 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 2 */ { 0 , (int)'1' , 0x021 , -1 , -1 , -1 } ,
/* 3 */ { 0 , (int)'2' , 0x040 , -1 , -1 , -1 } ,
/* 4 */ { 0 , (int)'3' , 0x023 , -1 , -1 , -1 } ,
/* 5 */ { 0 , (int)'4' , 0x024 , -1 , -1 , -1 } ,
/* 6 */ { 0 , (int)'5' , 0x025 , -1 , -1 , -1 } ,
/* 7 */ { 0 , (int)'6' , 0x05e , -1 , -1 , -1 } ,
/* 8 */ { 0 , (int)'7' , 0x026 , -1 , -1 , -1 } ,
/* 9 */ { 0 , (int)'8' , 0x02a , -1 , -1 , -1 } ,
/* 0a */ { 0 , (int)'9' , 0x028 , -1 , -1 , -1 } ,
/* 0b */ { 0 , (int)'0' , 0x029 , -1 , -1 , -1 } ,
/* 0c */ { 0 , 0x05b , 0x07b , 0x01b , -1 , -1 } ,
/* 0d */ { 0 , 0x05d , 0x07d , 0x01d , -1 , -1 } ,
/* 0e */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 0f */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 10 */ { 0 , 0x027 , 0x022 , -1 , -1 , -1 } ,
/* 11 */ { 0 , 0x02c , 0x03c , -1 , -1 , -1 } ,
/* 12 */ { 0 , 0x02e , 0x03e , -1 , -1 , -1 } ,
/* 13 */ { 1 , 'p' , 'P' , -1 , -1 , -1 } ,
/* 14 */ { 1 , 'y' , 'Y' , -1 , -1 , -1 } ,
/* 15 */ { 1 , 'f' , 'F' , -1 , -1 , -1 } ,
/* 16 */ { 1 , 'g' , 'G' , -1 , -1 , -1 } ,
/* 17 */ { 1 , 'c' , 'C' , -1 , -1 , -1 } ,
/* 18 */ { 1 , 'r' , 'R' , -1 , -1 , -1 } ,
/* 19 */ { 1 , 'l' , 'L' , -1 , -1 , -1 } ,
/* 1a */ { 0 , 0x02f , 0x03f , -1 , -1 , -1 } ,
/* 1b */ { 0 , 0x03d , 0x02b , -1 , -1 , -1 } ,
/* 1c */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 1d */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 1e */ { 1 , 'a' , 'A' , -1 , -1 , -1 } ,
/* 1f */ { 1 , 'o' , 'O' , -1 , -1 , -1 } ,
/* 20 */ { 1 , 'e' , 'E' , -1 , -1 , -1 } ,
/* 21 */ { 1 , 'u' , 'U' , -1 , -1 , -1 } ,
/* 22 */ { 1 , 'i' , 'I' , -1 , -1 , -1 } ,
/* 23 */ { 1 , 'd' , 'D' , -1 , -1 , -1 } ,
/* 24 */ { 1 , 'h' , 'H' , -1 , -1 , -1 } ,
/* 25 */ { 1 , 't' , 'T' , -1 , -1 , -1 } ,
/* 26 */ { 1 , 'n' , 'N' , -1 , -1 , -1 } ,
/* 27 */ { 1 , 's' , 'S' , -1 , -1 , -1 } ,
/* 28 */ { 0 , 0x02d , 0x05f , -1 , -1 , -1 } ,
/* 29 */ { 0 , 0x060 , 0x07e , -1 , -1 , -1 } ,
/* 2a */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 2b */ { 0 , 0x005c , 0x07c , 0x01c , -1 , -1 } ,
/* 2c */ { 0 , 0x003b , 0x03a , -1 , -1 , -1 } ,
/* 2d */ { 1 , 'q' , 'Q' , -1 , -1 , -1 } ,
/* 2e */ { 1 , 'j' , 'J' , -1 , -1 , -1 } ,
/* 2f */ { 1 , 'k' , 'K' , -1 , -1 , -1 } ,
/* 30 */ { 1 , 'x' , 'X' , -1 , -1 , -1 } ,
/* 31 */ { 1 , 'b' , 'B' , -1 , -1 , -1 } ,
/* 32 */ { 1 , 'm' , 'M' , -1 , -1 , -1 } ,
/* 33 */ { 1 , 'w' , 'W' , -1 , -1 , -1 } ,
/* 34 */ { 1 , 'v' , 'V' , -1 , -1 , -1 } ,
/* 35 */ { 1 , 'z' , 'Z' , -1 , -1 , -1 } ,
/* 36 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 37 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 38 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 39 */ { 0 , 0x020 , 0x020 , 0x020 , -1 , -1 } ,
/* 3a */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 3b */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 3c */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 3d */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 3e */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 3f */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 40 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 41 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 42 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 43 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 44 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 45 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 46 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 47 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 48 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 49 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 4a */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 4b */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 4c */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 4d */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 4e */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 4f */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 50 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 51 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 52 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 53 */ { 0 , 0x02e , 0x02e , -1 , -1 , -1 } ,
/* 54 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 55 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 56 */ { 0 , 0x05c , 0x07c , 0x01c , -1 , -1 } ,
/* 57 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 58 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 59 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 5a */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 5b */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 5c */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 5d */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 5e */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 5f */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
};
public static final int DEADKEYS[] = null;
public static final int DEADKEY_LUT[][] = null;
private static DvorakLayout instance = new DvorakLayout();
private DvorakLayout() {
}
public static DvorakLayout getInstance() {
return instance;
}
@Override
public int[][] getLUT() {
return LUT;
}
@Override
public int[][] getFastLUT() {
return FAST_LUT;
}
@Override
public void type(String text) {
super.type(FAST_LUT, text, (byte)0);
}
@Override
public void type(String text, byte modifiers) {
super.type(FAST_LUT, text, modifiers);
}
@Override
public char getChar(int scanCode, boolean capsLock, boolean shift, boolean altGr) {
return super.getChar(LUT, scanCode, capsLock, shift, altGr);
}
@Override
public String getLocaleName() {
return LOCALE_NAME;
}
@Override
public int[][] getDeadkeyLUT() {
return DEADKEY_LUT;
}
@Override
public int[] getDeadkeys() {
return DEADKEYS;
}
}

View File

@ -0,0 +1,388 @@
package com.inputstick.api.layout;
public class FinnishLayout extends KeyboardLayout {
public static final String LOCALE_NAME = "fi-FI";
//{char (16b unicode), modifier, key, deadkey_modifier, deadkey}
//fi-FI
private static final int[][] FAST_LUT = {
{ 0, 0, 0, 0, 0 }, // empty
{ 24, 64, 33, 0, 0 }, // 
{ 27, 1, 47, 0, 0 }, // 
{ 28, 1, 53, 0, 0 }, // 
{ 29, 1, 48, 0, 0 }, // 
{ 32, 0, 44, 0, 0 }, //
{ 33, 2, 30, 0, 0 }, // !
{ 34, 2, 31, 0, 0 }, // "
{ 35, 2, 32, 0, 0 }, // #
{ 37, 2, 34, 0, 0 }, // %
{ 38, 2, 35, 0, 0 }, // &
{ 39, 0, 49, 0, 0 }, // '
{ 40, 2, 37, 0, 0 }, // (
{ 41, 2, 38, 0, 0 }, // )
{ 42, 2, 49, 0, 0 }, // *
{ 43, 0, 45, 0, 0 }, // +
{ 44, 0, 54, 0, 0 }, // ,
{ 45, 0, 56, 0, 0 }, // -
{ 46, 0, 55, 0, 0 }, // .
{ 47, 2, 36, 0, 0 }, // /
{ 48, 0, 39, 0, 0 }, // 0
{ 49, 0, 30, 0, 0 }, // 1
{ 50, 0, 31, 0, 0 }, // 2
{ 51, 0, 32, 0, 0 }, // 3
{ 52, 0, 33, 0, 0 }, // 4
{ 53, 0, 34, 0, 0 }, // 5
{ 54, 0, 35, 0, 0 }, // 6
{ 55, 0, 36, 0, 0 }, // 7
{ 56, 0, 37, 0, 0 }, // 8
{ 57, 0, 38, 0, 0 }, // 9
{ 58, 2, 55, 0, 0 }, // :
{ 59, 2, 54, 0, 0 }, // ;
{ 60, 0, 100, 0, 0 }, // <
{ 61, 2, 39, 0, 0 }, // =
{ 62, 2, 100, 0, 0 }, // >
{ 63, 2, 45, 0, 0 }, // ?
{ 64, 64, 31, 0, 0 }, // @
{ 65, 2, 4, 0, 0 }, // A
{ 66, 2, 5, 0, 0 }, // B
{ 67, 2, 6, 0, 0 }, // C
{ 68, 2, 7, 0, 0 }, // D
{ 69, 2, 8, 0, 0 }, // E
{ 70, 2, 9, 0, 0 }, // F
{ 71, 2, 10, 0, 0 }, // G
{ 72, 2, 11, 0, 0 }, // H
{ 73, 2, 12, 0, 0 }, // I
{ 74, 2, 13, 0, 0 }, // J
{ 75, 2, 14, 0, 0 }, // K
{ 76, 2, 15, 0, 0 }, // L
{ 77, 2, 16, 0, 0 }, // M
{ 78, 2, 17, 0, 0 }, // N
{ 79, 2, 18, 0, 0 }, // O
{ 80, 2, 19, 0, 0 }, // P
{ 81, 2, 20, 0, 0 }, // Q
{ 82, 2, 21, 0, 0 }, // R
{ 83, 2, 22, 0, 0 }, // S
{ 84, 2, 23, 0, 0 }, // T
{ 85, 2, 24, 0, 0 }, // U
{ 86, 2, 25, 0, 0 }, // V
{ 87, 2, 26, 0, 0 }, // W
{ 88, 2, 27, 0, 0 }, // X
{ 89, 2, 28, 0, 0 }, // Y
{ 90, 2, 29, 0, 0 }, // Z
{ 91, 64, 37, 0, 0 }, // [
{ 92, 64, 45, 0, 0 }, // \
{ 93, 64, 38, 0, 0 }, // ]
{ 94, 0, 44, 2, 48 }, // ^
{ 95, 2, 56, 0, 0 }, // _
{ 96, 0, 44, 2, 46 }, // `
{ 97, 0, 4, 0, 0 }, // a
{ 98, 0, 5, 0, 0 }, // b
{ 99, 0, 6, 0, 0 }, // c
{ 100, 0, 7, 0, 0 }, // d
{ 101, 0, 8, 0, 0 }, // e
{ 102, 0, 9, 0, 0 }, // f
{ 103, 0, 10, 0, 0 }, // g
{ 104, 0, 11, 0, 0 }, // h
{ 105, 0, 12, 0, 0 }, // i
{ 106, 0, 13, 0, 0 }, // j
{ 107, 0, 14, 0, 0 }, // k
{ 108, 0, 15, 0, 0 }, // l
{ 109, 0, 16, 0, 0 }, // m
{ 110, 0, 17, 0, 0 }, // n
{ 111, 0, 18, 0, 0 }, // o
{ 112, 0, 19, 0, 0 }, // p
{ 113, 0, 20, 0, 0 }, // q
{ 114, 0, 21, 0, 0 }, // r
{ 115, 0, 22, 0, 0 }, // s
{ 116, 0, 23, 0, 0 }, // t
{ 117, 0, 24, 0, 0 }, // u
{ 118, 0, 25, 0, 0 }, // v
{ 119, 0, 26, 0, 0 }, // w
{ 120, 0, 27, 0, 0 }, // x
{ 121, 0, 28, 0, 0 }, // y
{ 122, 0, 29, 0, 0 }, // z
{ 123, 64, 36, 0, 0 }, // {
{ 124, 64, 100, 0, 0 }, // |
{ 125, 64, 39, 0, 0 }, // }
{ 126, 0, 44, 64, 48 }, // ~
{ 163, 64, 32, 0, 0 }, // ?
{ 164, 2, 33, 0, 0 }, // ¤
{ 167, 0, 53, 0, 0 }, // §
{ 168, 0, 44, 0, 48 }, // ¨
{ 180, 0, 44, 0, 46 }, // ´
{ 181, 64, 16, 0, 0 }, // µ
{ 189, 2, 53, 0, 0 }, // ?
{ 192, 2, 4, 2, 46 }, // ?
{ 193, 2, 4, 0, 46 }, // Á
{ 194, 2, 4, 2, 48 }, // Â
{ 195, 2, 4, 64, 48 }, // ?
{ 196, 2, 52, 0, 0 }, // Ä
{ 197, 2, 47, 0, 0 }, // ?
{ 200, 2, 8, 2, 46 }, // ?
{ 201, 2, 8, 0, 46 }, // É
{ 202, 2, 8, 2, 48 }, // ?
{ 203, 2, 8, 0, 48 }, // Ë
{ 204, 2, 12, 2, 46 }, // ?
{ 205, 2, 12, 0, 46 }, // Í
{ 206, 2, 12, 2, 48 }, // Î
{ 207, 2, 12, 0, 48 }, // ?
{ 209, 2, 17, 64, 48 }, // ?
{ 210, 2, 18, 2, 46 }, // ?
{ 211, 2, 18, 0, 46 }, // Ó
{ 212, 2, 18, 2, 48 }, // Ô
{ 213, 2, 18, 64, 48 }, // ?
{ 214, 2, 51, 0, 0 }, // Ö
{ 217, 2, 24, 2, 46 }, // ?
{ 218, 2, 24, 0, 46 }, // Ú
{ 219, 2, 24, 2, 48 }, // ?
{ 220, 2, 24, 0, 48 }, // Ü
{ 221, 2, 28, 0, 46 }, // Ý
{ 224, 0, 4, 2, 46 }, // ?
{ 225, 0, 4, 0, 46 }, // á
{ 226, 0, 4, 2, 48 }, // â
{ 227, 0, 4, 64, 48 }, // ?
{ 228, 0, 52, 0, 0 }, // ä
{ 229, 0, 47, 0, 0 }, // ?
{ 232, 0, 8, 2, 46 }, // ?
{ 233, 0, 8, 0, 46 }, // é
{ 234, 0, 8, 2, 48 }, // ?
{ 235, 0, 8, 0, 48 }, // ë
{ 236, 0, 12, 2, 46 }, // ?
{ 237, 0, 12, 0, 46 }, // í
{ 238, 0, 12, 2, 48 }, // î
{ 239, 0, 12, 0, 48 }, // ?
{ 241, 0, 17, 64, 48 }, // ?
{ 242, 0, 18, 2, 46 }, // ?
{ 243, 0, 18, 0, 46 }, // ó
{ 244, 0, 18, 2, 48 }, // ô
{ 245, 0, 18, 64, 48 }, // ?
{ 246, 0, 51, 0, 0 }, // ö
{ 249, 0, 24, 2, 46 }, // ?
{ 250, 0, 24, 0, 46 }, // ú
{ 251, 0, 24, 2, 48 }, // ?
{ 252, 0, 24, 0, 48 }, // ü
{ 253, 0, 28, 0, 46 }, // ý
{ 255, 0, 28, 0, 48 }, // ?
{ 8364, 64, 34, 0, 0 }, //
};
public static final int LUT[][] = {
/* 0 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 1 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 2 */ { 0 , (int)'1' , 0x0021 , -1 , -1 , -1 } ,
/* 3 */ { 0 , (int)'2' , 0x0022 , -1 , 0x0040 , -1 } ,
/* 4 */ { 0 , (int)'3' , 0x0023 , -1 , 0x00a3 , -1 } ,
/* 5 */ { 0 , (int)'4' , 0x00a4 , -1 , 24 , -1 } ,
/* 6 */ { 0 , (int)'5' , 0x0025 , -1 , 0x20ac , -1 } ,
/* 7 */ { 0 , (int)'6' , 0x0026 , -1 , -1 , -1 } ,
/* 8 */ { 0 , (int)'7' , 0x002f , -1 , 0x007b , -1 } ,
/* 9 */ { 0 , (int)'8' , 0x0028 , -1 , 0x005b , -1 } ,
/* 0a */ { 0 , (int)'9' , 0x0029 , -1 , 0x005d , -1 } ,
/* 0b */ { 0 , (int)'0' , 0x003d , -1 , 0x007d , -1 } ,
/* 0c */ { 0 , 0x002b , 0x003f , -1 , 0x005c , -1 } ,
/* 0d */ { 0 , 0x00b4 , 0x0060 , -1 , -1 , -1 } ,
/* 0e */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 0f */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 10 */ { 1 , (int)'q' , (int)'Q' , -1 , -1 , -1 } ,
/* 11 */ { 1 , (int)'w' , (int)'W' , -1 , -1 , -1 } ,
/* 12 */ { 1 , (int)'e' , (int)'E' , -1 , 0x020ac , -1 } ,
/* 13 */ { 1 , (int)'r' , (int)'R' , -1 , -1 , -1 } ,
/* 14 */ { 1 , (int)'t' , (int)'T' , -1 , -1 , -1 } ,
/* 15 */ { 1 , (int)'y' , (int)'Y' , -1 , -1 , -1 } ,
/* 16 */ { 1 , (int)'u' , (int)'U' , -1 , -1 , -1 } ,
/* 17 */ { 1 , (int)'i' , (int)'I' , -1 , -1 , -1 } ,
/* 18 */ { 1 , (int)'o' , (int)'O' , -1 , -1 , -1 } ,
/* 19 */ { 1 , (int)'p' , (int)'P' , -1 , -1 , -1 } ,
/* 1a */ { 1 , 0x00e5 , 0x00c5 , 0x001b , -1 , -1 } ,
/* 1b */ { 0 , 0x00a8 , 0x005e , 0x001d , 0x007e , -1 } ,
/* 1c */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 1d */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 1e */ { 1 , (int)'a' , (int)'A' , -1 , -1 , -1 } ,
/* 1f */ { 1 , (int)'s' , (int)'S' , -1 , -1 , -1 } ,
/* 20 */ { 1 , (int)'d' , (int)'D' , -1 , -1 , -1 } ,
/* 21 */ { 1 , (int)'f' , (int)'F' , -1 , -1 , -1 } ,
/* 22 */ { 1 , (int)'g' , (int)'G' , -1 , -1 , -1 } ,
/* 23 */ { 1 , (int)'h' , (int)'H' , -1 , -1 , -1 } ,
/* 24 */ { 1 , (int)'j' , (int)'J' , -1 , -1 , -1 } ,
/* 25 */ { 1 , (int)'k' , (int)'K' , -1 , -1 , -1 } ,
/* 26 */ { 1 , (int)'l' , (int)'L' , -1 , -1 , -1 } ,
/* 27 */ { 1 , 0x00f6 , 0x00d6 , -1 , -1 , -1 } ,
/* 28 */ { 1 , 0x00e4 , 0x00c4 , -1 , -1 , -1 } ,
/* 29 */ { 0 , 0x00a7 , 0x00bd , 0x001c , -1 , -1 } ,
/* 2a */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 2b */ { 0 , 0x0027 , 0x002a , -1 , -1 , -1 } ,
/* 2c */ { 1 , (int)'z' , (int)'Z' , -1 , -1 , -1 } ,
/* 2d */ { 1 , (int)'x' , (int)'X' , -1 , -1 , -1 } ,
/* 2e */ { 1 , (int)'c' , (int)'C' , -1 , -1 , -1 } ,
/* 2f */ { 1 , (int)'v' , (int)'V' , -1 , -1 , -1 } ,
/* 30 */ { 1 , (int)'b' , (int)'B' , -1 , -1 , -1 } ,
/* 31 */ { 1 , (int)'n' , (int)'N' , -1 , -1 , -1 } ,
/* 32 */ { 1 , (int)'m' , (int)'M' , -1 , 0x00b5 , -1 } ,
/* 33 */ { 0 , 0x002c , 0x003b , -1 , -1 , -1 } ,
/* 34 */ { 0 , 0x002e , 0x003a , -1 , -1 , -1 } ,
/* 35 */ { 0 , 0x002d , 0x005f , -1 , -1 , -1 } ,
/* 36 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 37 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 38 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 39 */ { 0 , 0x0020 , 0x0020 , 0x0020 , -1 , -1 } ,
/* 3a */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 3b */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 3c */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 3d */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 3e */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 3f */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 40 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 41 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 42 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 43 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 44 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 45 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 46 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 47 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 48 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 49 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 4a */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 4b */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 4c */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 4d */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 4e */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 4f */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 50 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 51 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 52 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 53 */ { 0 , 0x002c , 0x002c , -1 , -1 , -1 } ,
/* 54 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 55 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 56 */ { 0 , 0x003c , 0x003e , 0x001c , 0x007c , -1 } ,
/* 57 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 58 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 59 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 5a */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 5b */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 5c */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 5d */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 5e */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 5f */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
};
public static final int DEADKEYS[] = {
0x00b4, 0x0060, 0x00a8, 0x005e, 0x007e
};
public static final int DEADKEY_LUT[][] = {
{ 0x00b4 , 0x0061 , 0x00e1 } ,
{ 0x00b4 , 0x0065 , 0x00e9 } ,
{ 0x00b4 , 0x0075 , 0x00fa } ,
{ 0x00b4 , 0x0069 , 0x00ed } ,
{ 0x00b4 , 0x0079 , 0x00fd } ,
{ 0x00b4 , 0x006f , 0x00f3 } ,
{ 0x00b4 , 0x0041 , 0x00c1 } ,
{ 0x00b4 , 0x0045 , 0x00c9 } ,
{ 0x00b4 , 0x0055 , 0x00da } ,
{ 0x00b4 , 0x0049 , 0x00cd } ,
{ 0x00b4 , 0x0059 , 0x00dd } ,
{ 0x00b4 , 0x004f , 0x00d3 } ,
{ 0x00b4 , 0x0020 , 0x00b4 } ,
{ 0x0060 , 0x0061 , 0x00e0 } ,
{ 0x0060 , 0x0065 , 0x00e8 } ,
{ 0x0060 , 0x0075 , 0x00f9 } ,
{ 0x0060 , 0x0069 , 0x00ec } ,
{ 0x0060 , 0x006f , 0x00f2 } ,
{ 0x0060 , 0x0041 , 0x00c0 } ,
{ 0x0060 , 0x0045 , 0x00c8 } ,
{ 0x0060 , 0x0055 , 0x00d9 } ,
{ 0x0060 , 0x0049 , 0x00cc } ,
{ 0x0060 , 0x004f , 0x00d2 } ,
{ 0x0060 , 0x0020 , 0x0060 } ,
{ 0x00a8 , 0x0061 , 0x00e4 } ,
{ 0x00a8 , 0x0065 , 0x00eb } ,
{ 0x00a8 , 0x0075 , 0x00fc } ,
{ 0x00a8 , 0x0069 , 0x00ef } ,
{ 0x00a8 , 0x0079 , 0x00ff } ,
{ 0x00a8 , 0x006f , 0x00f6 } ,
{ 0x00a8 , 0x0041 , 0x00c4 } ,
{ 0x00a8 , 0x0045 , 0x00cb } ,
{ 0x00a8 , 0x0055 , 0x00dc } ,
{ 0x00a8 , 0x0049 , 0x00cf } ,
{ 0x00a8 , 0x004f , 0x00d6 } ,
{ 0x00a8 , 0x0020 , 0x00a8 } ,
{ 0x005e , 0x0061 , 0x00e2 } ,
{ 0x005e , 0x0065 , 0x00ea } ,
{ 0x005e , 0x0075 , 0x00fb } ,
{ 0x005e , 0x0069 , 0x00ee } ,
{ 0x005e , 0x006f , 0x00f4 } ,
{ 0x005e , 0x0041 , 0x00c2 } ,
{ 0x005e , 0x0045 , 0x00ca } ,
{ 0x005e , 0x0055 , 0x00db } ,
{ 0x005e , 0x0049 , 0x00ce } ,
{ 0x005e , 0x004f , 0x00d4 } ,
{ 0x005e , 0x0020 , 0x005e } ,
{ 0x007e , 0x006e , 0x00f1 } ,
{ 0x007e , 0x0061 , 0x00e3 } ,
{ 0x007e , 0x006f , 0x00f5 } ,
{ 0x007e , 0x004e , 0x00d1 } ,
{ 0x007e , 0x0041 , 0x00c3 } ,
{ 0x007e , 0x004f , 0x00d5 } ,
{ 0x007e , 0x0020 , 0x007e } ,
};
private static FinnishLayout instance = new FinnishLayout();
private FinnishLayout() {
}
public static FinnishLayout getInstance() {
return instance;
}
@Override
public int[][] getLUT() {
return LUT;
}
@Override
public int[][] getFastLUT() {
return FAST_LUT;
}
@Override
public void type(String text) {
super.type(FAST_LUT, text, (byte)0);
}
@Override
public void type(String text, byte modifiers) {
super.type(FAST_LUT, text, modifiers);
}
@Override
public char getChar(int scanCode, boolean capsLock, boolean shift, boolean altGr) {
return super.getChar(LUT, scanCode, capsLock, shift, altGr);
}
@Override
public String getLocaleName() {
return LOCALE_NAME;
}
@Override
public int[][] getDeadkeyLUT() {
return DEADKEY_LUT;
}
@Override
public int[] getDeadkeys() {
return DEADKEYS;
}
}

View File

@ -0,0 +1,362 @@
package com.inputstick.api.layout;
public class FrenchLayout extends KeyboardLayout {
public static final String LOCALE_NAME = "fr-FR";
//{char (16b unicode), modifier, key, deadkey_modifier, deadkey}
//fr-FR
private static final int[][] FAST_LUT = {
{ 0, 0, 0, 0, 0 }, // empty
{ 27, 1, 47, 0, 0 }, // 
{ 28, 1, 49, 0, 0 }, // 
{ 29, 1, 48, 0, 0 }, // 
{ 32, 0, 44, 0, 0 }, //
{ 33, 0, 56, 0, 0 }, // !
{ 34, 0, 32, 0, 0 }, // "
{ 35, 64, 32, 0, 0 }, // #
{ 36, 0, 48, 0, 0 }, // $
{ 37, 2, 52, 0, 0 }, // %
{ 38, 0, 30, 0, 0 }, // &
{ 39, 0, 33, 0, 0 }, // '
{ 40, 0, 34, 0, 0 }, // (
{ 41, 0, 45, 0, 0 }, // )
{ 42, 0, 49, 0, 0 }, // *
{ 43, 2, 46, 0, 0 }, // +
{ 44, 0, 16, 0, 0 }, // ,
{ 45, 0, 35, 0, 0 }, // -
{ 46, 2, 54, 0, 0 }, // .
{ 47, 2, 55, 0, 0 }, // /
{ 48, 2, 39, 0, 0 }, // 0
{ 49, 2, 30, 0, 0 }, // 1
{ 50, 2, 31, 0, 0 }, // 2
{ 51, 2, 32, 0, 0 }, // 3
{ 52, 2, 33, 0, 0 }, // 4
{ 53, 2, 34, 0, 0 }, // 5
{ 54, 2, 35, 0, 0 }, // 6
{ 55, 2, 36, 0, 0 }, // 7
{ 56, 2, 37, 0, 0 }, // 8
{ 57, 2, 38, 0, 0 }, // 9
{ 58, 0, 55, 0, 0 }, // :
{ 59, 0, 54, 0, 0 }, // ;
{ 60, 0, 100, 0, 0 }, // <
{ 61, 0, 46, 0, 0 }, // =
{ 62, 2, 100, 0, 0 }, // >
{ 63, 2, 16, 0, 0 }, // ?
{ 64, 64, 39, 0, 0 }, // @
{ 65, 2, 20, 0, 0 }, // A
{ 66, 2, 5, 0, 0 }, // B
{ 67, 2, 6, 0, 0 }, // C
{ 68, 2, 7, 0, 0 }, // D
{ 69, 2, 8, 0, 0 }, // E
{ 70, 2, 9, 0, 0 }, // F
{ 71, 2, 10, 0, 0 }, // G
{ 72, 2, 11, 0, 0 }, // H
{ 73, 2, 12, 0, 0 }, // I
{ 74, 2, 13, 0, 0 }, // J
{ 75, 2, 14, 0, 0 }, // K
{ 76, 2, 15, 0, 0 }, // L
{ 77, 2, 51, 0, 0 }, // M
{ 78, 2, 17, 0, 0 }, // N
{ 79, 2, 18, 0, 0 }, // O
{ 80, 2, 19, 0, 0 }, // P
{ 81, 2, 4, 0, 0 }, // Q
{ 82, 2, 21, 0, 0 }, // R
{ 83, 2, 22, 0, 0 }, // S
{ 84, 2, 23, 0, 0 }, // T
{ 85, 2, 24, 0, 0 }, // U
{ 86, 2, 25, 0, 0 }, // V
{ 87, 2, 29, 0, 0 }, // W
{ 88, 2, 27, 0, 0 }, // X
{ 89, 2, 28, 0, 0 }, // Y
{ 90, 2, 26, 0, 0 }, // Z
{ 91, 64, 34, 0, 0 }, // [
{ 92, 64, 37, 0, 0 }, // \
{ 93, 64, 45, 0, 0 }, // ]
{ 94, 0, 44, 64, 38 }, // ^
{ 95, 0, 37, 0, 0 }, // _
{ 96, 0, 44, 64, 36 }, // `
{ 97, 0, 20, 0, 0 }, // a
{ 98, 0, 5, 0, 0 }, // b
{ 99, 0, 6, 0, 0 }, // c
{ 100, 0, 7, 0, 0 }, // d
{ 101, 0, 8, 0, 0 }, // e
{ 102, 0, 9, 0, 0 }, // f
{ 103, 0, 10, 0, 0 }, // g
{ 104, 0, 11, 0, 0 }, // h
{ 105, 0, 12, 0, 0 }, // i
{ 106, 0, 13, 0, 0 }, // j
{ 107, 0, 14, 0, 0 }, // k
{ 108, 0, 15, 0, 0 }, // l
{ 109, 0, 51, 0, 0 }, // m
{ 110, 0, 17, 0, 0 }, // n
{ 111, 0, 18, 0, 0 }, // o
{ 112, 0, 19, 0, 0 }, // p
{ 113, 0, 4, 0, 0 }, // q
{ 114, 0, 21, 0, 0 }, // r
{ 115, 0, 22, 0, 0 }, // s
{ 116, 0, 23, 0, 0 }, // t
{ 117, 0, 24, 0, 0 }, // u
{ 118, 0, 25, 0, 0 }, // v
{ 119, 0, 29, 0, 0 }, // w
{ 120, 0, 27, 0, 0 }, // x
{ 121, 0, 28, 0, 0 }, // y
{ 122, 0, 26, 0, 0 }, // z
{ 123, 64, 33, 0, 0 }, // {
{ 124, 64, 35, 0, 0 }, // |
{ 125, 64, 46, 0, 0 }, // }
{ 126, 0, 44, 64, 31 }, // ~
{ 163, 2, 48, 0, 0 }, // ?
{ 164, 64, 48, 0, 0 }, // ¤
{ 167, 2, 56, 0, 0 }, // §
{ 168, 0, 44, 2, 47 }, // ¨
{ 176, 2, 45, 0, 0 }, // °
{ 178, 0, 53, 0, 0 }, // ?
{ 181, 2, 49, 0, 0 }, // µ
{ 192, 2, 20, 64, 36 }, // ?
{ 194, 2, 20, 64, 38 }, // Â
{ 195, 2, 20, 64, 31 }, // ?
{ 196, 2, 20, 2, 47 }, // Ä
{ 200, 2, 8, 64, 36 }, // ?
{ 202, 2, 8, 64, 38 }, // ?
{ 203, 2, 8, 2, 47 }, // Ë
{ 204, 2, 12, 64, 36 }, // ?
{ 206, 2, 12, 64, 38 }, // Î
{ 207, 2, 12, 2, 47 }, // ?
{ 209, 2, 17, 64, 31 }, // ?
{ 210, 2, 18, 64, 36 }, // ?
{ 212, 2, 18, 64, 38 }, // Ô
{ 213, 2, 18, 64, 31 }, // ?
{ 214, 2, 18, 2, 47 }, // Ö
{ 217, 2, 24, 64, 36 }, // ?
{ 219, 2, 24, 64, 38 }, // ?
{ 220, 2, 24, 2, 47 }, // Ü
{ 224, 0, 39, 0, 0 }, // ?
{ 226, 0, 20, 64, 38 }, // â
{ 227, 0, 20, 64, 31 }, // ?
{ 228, 0, 20, 2, 47 }, // ä
{ 231, 0, 38, 0, 0 }, // ç
{ 232, 0, 36, 0, 0 }, // ?
{ 233, 0, 31, 0, 0 }, // é
{ 234, 0, 8, 64, 38 }, // ?
{ 235, 0, 8, 2, 47 }, // ë
{ 236, 0, 12, 64, 36 }, // ?
{ 238, 0, 12, 64, 38 }, // î
{ 239, 0, 12, 2, 47 }, // ?
{ 241, 0, 17, 64, 31 }, // ?
{ 242, 0, 18, 64, 36 }, // ?
{ 244, 0, 18, 64, 38 }, // ô
{ 245, 0, 18, 64, 31 }, // ?
{ 246, 0, 18, 2, 47 }, // ö
{ 249, 0, 52, 0, 0 }, // ?
{ 251, 0, 24, 64, 38 }, // ?
{ 252, 0, 24, 2, 47 }, // ü
{ 255, 0, 28, 2, 47 }, // ?
{ 8364, 64, 8, 0, 0 }, //
};
public static final int LUT[][] = {
/* 0 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 1 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 2 */ { 1 , 0x26 , (int)'1' , -1 , -1 , -1 } ,
/* 3 */ { 1 , 0x00e9 , (int)'2' , -1 , 0x007e , -1 } ,
/* 4 */ { 1 , 0x22 , (int)'3' , -1 , 0x23 , -1 } ,
/* 5 */ { 1 , 0x27 , (int)'4' , -1 , 0x007b , -1 } ,
/* 6 */ { 1 , 0x28 , (int)'5' , -1 , 0x005b , -1 } ,
/* 7 */ { 1 , 0x002d , (int)'6' , -1 , 0x007c , -1 } ,
/* 8 */ { 1 , 0x00e8 , (int)'7' , -1 , 0x0060 , -1 } ,
/* 9 */ { 1 , 0x005f , (int)'8' , -1 , 0x005c , -1 } ,
/* 0a */ { 1 , 0x00e7 , (int)'9' , -1 , 0x005e , -1 } ,
/* 0b */ { 1 , 0x00e0 , (int)'0' , -1 , 0x40 , -1 } ,
/* 0c */ { 1 , 0x29 , 0x00b0 , -1 , 0x005d , -1 } ,
/* 0d */ { 1 , 0x003d , 0x002b , -1 , 0x007d , -1 } ,
/* 1e */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 1f */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 10 */ { 1 , (int)'a' , (int)'A' , -1 , -1 , -1 } ,
/* 11 */ { 1 , (int)'z' , (int)'Z' , -1 , -1 , -1 } ,
/* 12 */ { 1 , (int)'e' , (int)'E' , -1 , 0x20ac , -1 } ,
/* 13 */ { 1 , (int)'r' , (int)'R' , -1 , -1 , -1 } ,
/* 14 */ { 1 , (int)'t' , (int)'T' , -1 , -1 , -1 } ,
/* 15 */ { 1 , (int)'y' , (int)'Y' , -1 , -1 , -1 } ,
/* 16 */ { 1 , (int)'u' , (int)'U' , -1 , -1 , -1 } ,
/* 17 */ { 1 , (int)'i' , (int)'I' , -1 , -1 , -1 } ,
/* 18 */ { 1 , (int)'o' , (int)'O' , -1 , -1 , -1 } ,
/* 19 */ { 1 , (int)'p' , (int)'P' , -1 , -1 , -1 } ,
/* 1a */ { 1 , 0x005e , 0x00a8 , 0x001b , -1 , -1 } ,
/* 1b */ { 1 , 0x24 , 0x00a3 , 0x001d , 0x00a4 , -1 } ,
/* 1c */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 1d */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 1e */ { 1 , (int)'q' , (int)'Q' , -1 , -1 , -1 } ,
/* 1f */ { 1 , (int)'s' , (int)'S' , -1 , -1 , -1 } ,
/* 20 */ { 1 , (int)'d' , (int)'D' , -1 , -1 , -1 } ,
/* 21 */ { 1 , (int)'f' , (int)'F' , -1 , -1 , -1 } ,
/* 22 */ { 1 , (int)'g' , (int)'G' , -1 , -1 , -1 } ,
/* 23 */ { 1 , (int)'h' , (int)'H' , -1 , -1 , -1 } ,
/* 24 */ { 1 , (int)'j' , (int)'J' , -1 , -1 , -1 } ,
/* 25 */ { 1 , (int)'k' , (int)'K' , -1 , -1 , -1 } ,
/* 26 */ { 1 , (int)'l' , (int)'L' , -1 , -1 , -1 } ,
/* 27 */ { 1 , (int)'m' , (int)'M' , -1 , -1 , -1 } ,
/* 28 */ { 1 , 0x00f9 , 0x25 , -1 , -1 , -1 } ,
/* 29 */ { 0 , 0x00b2 , -1 , -1 , -1 , -1 } ,
/* 2a */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 2b */ { 1 , 0x002a , 0x00b5 , 0x001c , -1 , -1 } ,
/* 2c */ { 1 , (int)'w' , (int)'W' , -1 , -1 , -1 } ,
/* 2d */ { 1 , (int)'x' , (int)'X' , -1 , -1 , -1 } ,
/* 2e */ { 1 , (int)'c' , (int)'C' , -1 , -1 , -1 } ,
/* 2f */ { 1 , (int)'v' , (int)'V' , -1 , -1 , -1 } ,
/* 30 */ { 1 , (int)'b' , (int)'B' , -1 , -1 , -1 } ,
/* 31 */ { 1 , (int)'n' , (int)'N' , -1 , -1 , -1 } ,
/* 32 */ { 1 , 0x002c , 0x003f , -1 , -1 , -1 } ,
/* 33 */ { 1 , 0x003b , 0x002e , -1 , -1 , -1 } ,
/* 34 */ { 1 , 0x003a , 0x002f , -1 , -1 , -1 } ,
/* 35 */ { 1 , 0x21 , 0x00a7 , -1 , -1 , -1 } ,
/* 36 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 37 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 38 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 39 */ { 0 , 0x20 , 0x20 , 0x20 , -1 , -1 } ,
/* 3a */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 3b */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 3c */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 3d */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 3e */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 3f */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 40 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 41 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 42 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 43 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 44 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 45 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 46 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 47 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 48 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 49 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 4a */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 4b */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 4c */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 4d */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 4e */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 4f */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 50 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 51 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 52 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 53 */ { 0 , 0x002e , 0x002e , -1 , -1 , -1 } ,
/* 54 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 55 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 56 */ { 0 , 0x003c , 0x003e , 0x001c , -1 , -1 } ,
/* 57 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 58 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 59 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 5a */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 5b */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 5c */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 5d */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 5e */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 5f */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
};
public static final int DEADKEYS[] = {
0x007e, 0x0060, 0x005e, 0x00a8, 0x007e
};
public static final int DEADKEY_LUT[][] = {
{ 0x007e , 0x006e , 0x00f1 } ,
{ 0x007e , 0x006f , 0x00f5 } ,
{ 0x007e , 0x0061 , 0x00e3 } ,
{ 0x007e , 0x004e , 0x00d1 } ,
{ 0x007e , 0x004f , 0x00d5 } ,
{ 0x007e , 0x0041 , 0x00c3 } ,
{ 0x007e , 0x0020 , 0x007e } ,
{ 0x0060 , 0x0065 , 0x00e8 } ,
{ 0x0060 , 0x0075 , 0x00f9 } ,
{ 0x0060 , 0x0069 , 0x00ec } ,
{ 0x0060 , 0x006f , 0x00f2 } ,
{ 0x0060 , 0x0061 , 0x00e0 } ,
{ 0x0060 , 0x0045 , 0x00c8 } ,
{ 0x0060 , 0x0055 , 0x00d9 } ,
{ 0x0060 , 0x0049 , 0x00cc } ,
{ 0x0060 , 0x004f , 0x00d2 } ,
{ 0x0060 , 0x0041 , 0x00c0 } ,
{ 0x0060 , 0x0020 , 0x0060 } ,
{ 0x005e , 0x0065 , 0x00ea } ,
{ 0x005e , 0x0075 , 0x00fb } ,
{ 0x005e , 0x0069 , 0x00ee } ,
{ 0x005e , 0x006f , 0x00f4 } ,
{ 0x005e , 0x0061 , 0x00e2 } ,
{ 0x005e , 0x0045 , 0x00ca } ,
{ 0x005e , 0x0055 , 0x00db } ,
{ 0x005e , 0x0049 , 0x00ce } ,
{ 0x005e , 0x004f , 0x00d4 } ,
{ 0x005e , 0x0041 , 0x00c2 } ,
{ 0x005e , 0x0020 , 0x005e } ,
{ 0x00a8 , 0x0065 , 0x00eb } ,
{ 0x00a8 , 0x0075 , 0x00fc } ,
{ 0x00a8 , 0x0069 , 0x00ef } ,
{ 0x00a8 , 0x0079 , 0x00ff } ,
{ 0x00a8 , 0x006f , 0x00f6 } ,
{ 0x00a8 , 0x0061 , 0x00e4 } ,
{ 0x00a8 , 0x0045 , 0x00cb } ,
{ 0x00a8 , 0x0055 , 0x00dc } ,
{ 0x00a8 , 0x0049 , 0x00cf } ,
{ 0x00a8 , 0x004f , 0x00d6 } ,
{ 0x00a8 , 0x0041 , 0x00c4 } ,
{ 0x00a8 , 0x0020 , 0x00a8 } ,
};
private static FrenchLayout instance = new FrenchLayout();
private FrenchLayout() {
}
public static FrenchLayout getInstance() {
return instance;
}
@Override
public int[][] getLUT() {
return LUT;
}
@Override
public int[][] getFastLUT() {
return FAST_LUT;
}
@Override
public void type(String text) {
super.type(FAST_LUT, text, (byte)0);
}
@Override
public void type(String text, byte modifiers) {
super.type(FAST_LUT, text, modifiers);
}
@Override
public char getChar(int scanCode, boolean capsLock, boolean shift, boolean altGr) {
return super.getChar(LUT, scanCode, capsLock, shift, altGr);
}
@Override
public String getLocaleName() {
return LOCALE_NAME;
}
@Override
public int[][] getDeadkeyLUT() {
return DEADKEY_LUT;
}
@Override
public int[] getDeadkeys() {
return DEADKEYS;
}
}

View File

@ -0,0 +1,355 @@
package com.inputstick.api.layout;
public class GermanLayout extends KeyboardLayout {
public static final String LOCALE_NAME = "de-DE";
//{char (16b unicode), modifier, key, deadkey_modifier, deadkey}
//de-DE
private static final int[][] FAST_LUT = {
{ 0, 0, 0, 0, 0 }, // empty
{ 27, 1, 47, 0, 0 }, // 
{ 28, 1, 49, 0, 0 }, // 
{ 29, 1, 48, 0, 0 }, // 
{ 32, 0, 44, 0, 0 }, //
{ 33, 2, 30, 0, 0 }, // !
{ 34, 2, 31, 0, 0 }, // "
{ 35, 0, 49, 0, 0 }, // #
{ 36, 2, 33, 0, 0 }, // $
{ 37, 2, 34, 0, 0 }, // %
{ 38, 2, 35, 0, 0 }, // &
{ 39, 2, 49, 0, 0 }, // '
{ 40, 2, 37, 0, 0 }, // (
{ 41, 2, 38, 0, 0 }, // )
{ 42, 2, 48, 0, 0 }, // *
{ 43, 0, 48, 0, 0 }, // +
{ 44, 0, 54, 0, 0 }, // ,
{ 45, 0, 56, 0, 0 }, // -
{ 46, 0, 55, 0, 0 }, // .
{ 47, 2, 36, 0, 0 }, // /
{ 48, 0, 39, 0, 0 }, // 0
{ 49, 0, 30, 0, 0 }, // 1
{ 50, 0, 31, 0, 0 }, // 2
{ 51, 0, 32, 0, 0 }, // 3
{ 52, 0, 33, 0, 0 }, // 4
{ 53, 0, 34, 0, 0 }, // 5
{ 54, 0, 35, 0, 0 }, // 6
{ 55, 0, 36, 0, 0 }, // 7
{ 56, 0, 37, 0, 0 }, // 8
{ 57, 0, 38, 0, 0 }, // 9
{ 58, 2, 55, 0, 0 }, // :
{ 59, 2, 54, 0, 0 }, // ;
{ 60, 0, 100, 0, 0 }, // <
{ 61, 2, 39, 0, 0 }, // =
{ 62, 2, 100, 0, 0 }, // >
{ 63, 2, 45, 0, 0 }, // ?
{ 64, 64, 20, 0, 0 }, // @
{ 65, 2, 4, 0, 0 }, // A
{ 66, 2, 5, 0, 0 }, // B
{ 67, 2, 6, 0, 0 }, // C
{ 68, 2, 7, 0, 0 }, // D
{ 69, 2, 8, 0, 0 }, // E
{ 70, 2, 9, 0, 0 }, // F
{ 71, 2, 10, 0, 0 }, // G
{ 72, 2, 11, 0, 0 }, // H
{ 73, 2, 12, 0, 0 }, // I
{ 74, 2, 13, 0, 0 }, // J
{ 75, 2, 14, 0, 0 }, // K
{ 76, 2, 15, 0, 0 }, // L
{ 77, 2, 16, 0, 0 }, // M
{ 78, 2, 17, 0, 0 }, // N
{ 79, 2, 18, 0, 0 }, // O
{ 80, 2, 19, 0, 0 }, // P
{ 81, 2, 20, 0, 0 }, // Q
{ 82, 2, 21, 0, 0 }, // R
{ 83, 2, 22, 0, 0 }, // S
{ 84, 2, 23, 0, 0 }, // T
{ 85, 2, 24, 0, 0 }, // U
{ 86, 2, 25, 0, 0 }, // V
{ 87, 2, 26, 0, 0 }, // W
{ 88, 2, 27, 0, 0 }, // X
{ 89, 2, 29, 0, 0 }, // Y
{ 90, 2, 28, 0, 0 }, // Z
{ 91, 64, 37, 0, 0 }, // [
{ 92, 64, 45, 0, 0 }, // \
{ 93, 64, 38, 0, 0 }, // ]
{ 94, 0, 44, 0, 53 }, // ^
{ 95, 2, 56, 0, 0 }, // _
{ 96, 0, 44, 2, 46 }, // `
{ 97, 0, 4, 0, 0 }, // a
{ 98, 0, 5, 0, 0 }, // b
{ 99, 0, 6, 0, 0 }, // c
{ 100, 0, 7, 0, 0 }, // d
{ 101, 0, 8, 0, 0 }, // e
{ 102, 0, 9, 0, 0 }, // f
{ 103, 0, 10, 0, 0 }, // g
{ 104, 0, 11, 0, 0 }, // h
{ 105, 0, 12, 0, 0 }, // i
{ 106, 0, 13, 0, 0 }, // j
{ 107, 0, 14, 0, 0 }, // k
{ 108, 0, 15, 0, 0 }, // l
{ 109, 0, 16, 0, 0 }, // m
{ 110, 0, 17, 0, 0 }, // n
{ 111, 0, 18, 0, 0 }, // o
{ 112, 0, 19, 0, 0 }, // p
{ 113, 0, 20, 0, 0 }, // q
{ 114, 0, 21, 0, 0 }, // r
{ 115, 0, 22, 0, 0 }, // s
{ 116, 0, 23, 0, 0 }, // t
{ 117, 0, 24, 0, 0 }, // u
{ 118, 0, 25, 0, 0 }, // v
{ 119, 0, 26, 0, 0 }, // w
{ 120, 0, 27, 0, 0 }, // x
{ 121, 0, 29, 0, 0 }, // y
{ 122, 0, 28, 0, 0 }, // z
{ 123, 64, 36, 0, 0 }, // {
{ 124, 64, 100, 0, 0 }, // |
{ 125, 64, 39, 0, 0 }, // }
{ 126, 64, 48, 0, 0 }, // ~
{ 167, 2, 32, 0, 0 }, // §
{ 176, 2, 53, 0, 0 }, // °
{ 178, 64, 31, 0, 0 }, // ?
{ 179, 64, 32, 0, 0 }, // ?
{ 180, 0, 44, 0, 46 }, // ´
{ 181, 64, 16, 0, 0 }, // µ
{ 192, 2, 4, 2, 46 }, // ?
{ 193, 2, 4, 0, 46 }, // Á
{ 194, 2, 4, 0, 53 }, // Â
{ 196, 2, 52, 0, 0 }, // Ä
{ 200, 2, 8, 2, 46 }, // ?
{ 201, 2, 8, 0, 46 }, // É
{ 202, 2, 8, 0, 53 }, // ?
{ 204, 2, 12, 2, 46 }, // ?
{ 205, 2, 12, 0, 46 }, // Í
{ 206, 2, 12, 0, 53 }, // Î
{ 210, 2, 18, 2, 46 }, // ?
{ 211, 2, 18, 0, 46 }, // Ó
{ 212, 2, 18, 0, 53 }, // Ô
{ 214, 2, 51, 0, 0 }, // Ö
{ 217, 2, 24, 2, 46 }, // ?
{ 218, 2, 24, 0, 46 }, // Ú
{ 219, 2, 24, 0, 53 }, // ?
{ 220, 2, 47, 0, 0 }, // Ü
{ 221, 2, 29, 0, 46 }, // Ý
{ 223, 0, 45, 0, 0 }, // ß
{ 224, 0, 4, 2, 46 }, // ?
{ 225, 0, 4, 0, 46 }, // á
{ 226, 0, 4, 0, 53 }, // â
{ 228, 0, 52, 0, 0 }, // ä
{ 232, 0, 8, 2, 46 }, // ?
{ 233, 0, 8, 0, 46 }, // é
{ 234, 0, 8, 0, 53 }, // ?
{ 236, 0, 12, 2, 46 }, // ?
{ 237, 0, 12, 0, 46 }, // í
{ 238, 0, 12, 0, 53 }, // î
{ 242, 0, 18, 2, 46 }, // ?
{ 243, 0, 18, 0, 46 }, // ó
{ 244, 0, 18, 0, 53 }, // ô
{ 246, 0, 51, 0, 0 }, // ö
{ 249, 0, 24, 2, 46 }, // ?
{ 250, 0, 24, 0, 46 }, // ú
{ 251, 0, 24, 0, 53 }, // ?
{ 252, 0, 47, 0, 0 }, // ü
{ 253, 0, 29, 0, 46 }, // ý
{ 8364, 64, 8, 0, 0 }, //
};
public static final int LUT[][] = {
/* 0 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 1 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 2 */ { 0 , (int)'1' , 0x21 , -1 , -1 , -1 } ,
/* 3 */ { 0 , (int)'2' , 0x22 , -1 , 0x00b2 , 0x00b2 } ,
/* 4 */ { 0 , (int)'3' , 0x00a7 , -1 , 0x00b3 , 0x00b3 } ,
/* 5 */ { 0 , (int)'4' , 0x24 , -1 , -1 , -1 } ,
/* 6 */ { 0 , (int)'5' , 0x25 , -1 , -1 , -1 } ,
/* 7 */ { 0 , (int)'6' , 0x26 , -1 , -1 , -1 } ,
/* 8 */ { 0 , (int)'7' , 0x002f , -1 , 0x007b , 0x007b } ,
/* 9 */ { 0 , (int)'8' , 0x28 , -1 , 0x005b , 0x005b } ,
/* 0a */ { 0 , (int)'9' , 0x29 , -1 , 0x005d , 0x005d } ,
/* 0b */ { 0 , (int)'0' , 0x003d , -1 , 0x007d , 0x007d } ,
/* 0c */ { 0 , 0x00df , 0x003f , -1 , 0x005c , 0x005c } ,
/* 0d */ { 0 , 0x00b4 , 0x0060 , -1 , -1 , -1 } ,
/* 0e */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 0f */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 10 */ { 1 , (int)'q' , (int)'Q' , -1 , 0x40 , 0x40 } ,
/* 11 */ { 1 , (int)'w' , (int)'W' , -1 , -1 , -1 } ,
/* 12 */ { 1 , (int)'e' , (int)'E' , -1 , 0x20ac , -1 } ,
/* 13 */ { 1 , (int)'r' , (int)'R' , -1 , -1 , -1 } ,
/* 14 */ { 1 , (int)'t' , (int)'T' , -1 , -1 , -1 } ,
/* 15 */ { 1 , (int)'z' , (int)'Z' , -1 , -1 , -1 } ,
/* 16 */ { 1 , (int)'u' , (int)'U' , -1 , -1 , -1 } ,
/* 17 */ { 1 , (int)'i' , (int)'I' , -1 , -1 , -1 } ,
/* 18 */ { 1 , (int)'o' , (int)'O' , -1 , -1 , -1 } ,
/* 19 */ { 1 , (int)'p' , (int)'P' , -1 , -1 , -1 } ,
/* 1a */ { 1 , 0x00fc , 0x00dc , 0x001b , -1 , -1 } ,
/* 1b */ { 0 , 0x002b , 0x002a , 0x001d , 0x007e , 0x007e } ,
/* 1c */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 1d */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 1e */ { 1 , (int)'a' , (int)'A' , -1 , -1 , -1 } ,
/* 1f */ { 1 , (int)'s' , (int)'S' , -1 , -1 , -1 } ,
/* 20 */ { 1 , (int)'d' , (int)'D' , -1 , -1 , -1 } ,
/* 21 */ { 1 , (int)'f' , (int)'F' , -1 , -1 , -1 } ,
/* 22 */ { 1 , (int)'g' , (int)'G' , -1 , -1 , -1 } ,
/* 23 */ { 1 , (int)'h' , (int)'H' , -1 , -1 , -1 } ,
/* 24 */ { 1 , (int)'j' , (int)'J' , -1 , -1 , -1 } ,
/* 25 */ { 1 , (int)'k' , (int)'K' , -1 , -1 , -1 } ,
/* 26 */ { 1 , (int)'l' , (int)'L' , -1 , -1 , -1 } ,
/* 27 */ { 1 , 0x00f6 , 0x00d6 , -1 , -1 , -1 } ,
/* 28 */ { 1 , 0x00e4 , 0x00c4 , -1 , -1 , -1 } ,
/* 29 */ { 0 , 0x005e , 0x00b0 , -1 , -1 , -1 } ,
/* 2a */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 2b */ { 0 , 0x23 , 0x27 , 0x001c , -1 , -1 } ,
/* 2c */ { 1 , (int)'y' , (int)'Y' , -1 , -1 , -1 } ,
/* 2d */ { 1 , (int)'x' , (int)'X' , -1 , -1 , -1 } ,
/* 2e */ { 1 , (int)'c' , (int)'C' , -1 , -1 , -1 } ,
/* 2f */ { 1 , (int)'v' , (int)'V' , -1 , -1 , -1 } ,
/* 30 */ { 1 , (int)'b' , (int)'B' , -1 , -1 , -1 } ,
/* 31 */ { 1 , (int)'n' , (int)'N' , -1 , -1 , -1 } ,
/* 32 */ { 1 , (int)'m' , (int)'M' , -1 , 0x00b5 , 0x00b5 } ,
/* 33 */ { 0 , 0x002c , 0x003b , -1 , -1 , -1 } ,
/* 34 */ { 0 , 0x002e , 0x003a , -1 , -1 , -1 } ,
/* 35 */ { 0 , 0x002d , 0x005f , -1 , -1 , -1 } ,
/* 36 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 37 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 38 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 39 */ { 0 , 0x20 , 0x20 , 0x20 , -1 , -1 } ,
/* 3a */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 3b */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 3c */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 3d */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 3e */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 3f */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 40 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 41 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 42 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 43 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 44 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 45 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 46 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 47 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 48 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 49 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 4a */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 4b */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 4c */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 4d */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 4e */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 4f */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 50 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 51 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 52 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 53 */ { 0 , 0x002c , 0x002c , -1 , -1 , -1 } ,
/* 54 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 55 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 56 */ { 0 , 0x003c , 0x003e , -1 , 0x007c , 0x007c } ,
/* 57 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 58 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 59 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 5a */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 5b */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 5c */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 5d */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 5e */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 5f */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
};
public static final int DEADKEYS[] = {
0x0060, 0x00b4, 0x005e
};
public static final int DEADKEY_LUT[][] = {
{ 0x00b4 , 0x0079 , 0x00fd } ,
{ 0x00b4 , 0x0061 , 0x00e1 } ,
{ 0x00b4 , 0x0065 , 0x00e9 } ,
{ 0x00b4 , 0x0075 , 0x00fa } ,
{ 0x00b4 , 0x0069 , 0x00ed } ,
{ 0x00b4 , 0x006f , 0x00f3 } ,
{ 0x00b4 , 0x0059 , 0x00dd } ,
{ 0x00b4 , 0x0041 , 0x00c1 } ,
{ 0x00b4 , 0x0045 , 0x00c9 } ,
{ 0x00b4 , 0x0055 , 0x00da } ,
{ 0x00b4 , 0x0049 , 0x00cd } ,
{ 0x00b4 , 0x004f , 0x00d3 } ,
{ 0x00b4 , 0x0020 , 0x00b4 } ,
{ 0x0060 , 0x0061 , 0x00e0 } ,
{ 0x0060 , 0x0065 , 0x00e8 } ,
{ 0x0060 , 0x0075 , 0x00f9 } ,
{ 0x0060 , 0x0069 , 0x00ec } ,
{ 0x0060 , 0x006f , 0x00f2 } ,
{ 0x0060 , 0x0041 , 0x00c0 } ,
{ 0x0060 , 0x0045 , 0x00c8 } ,
{ 0x0060 , 0x0055 , 0x00d9 } ,
{ 0x0060 , 0x0049 , 0x00cc } ,
{ 0x0060 , 0x004f , 0x00d2 } ,
{ 0x0060 , 0x0020 , 0x0060 } ,
{ 0x005e , 0x0061 , 0x00e2 } ,
{ 0x005e , 0x0065 , 0x00ea } ,
{ 0x005e , 0x0075 , 0x00fb } ,
{ 0x005e , 0x0069 , 0x00ee } ,
{ 0x005e , 0x006f , 0x00f4 } ,
{ 0x005e , 0x0041 , 0x00c2 } ,
{ 0x005e , 0x0045 , 0x00ca } ,
{ 0x005e , 0x0055 , 0x00db } ,
{ 0x005e , 0x0049 , 0x00ce } ,
{ 0x005e , 0x004f , 0x00d4 } ,
{ 0x005e , 0x0020 , 0x005e } ,
};
private static GermanLayout instance = new GermanLayout();
private GermanLayout() {
}
public static GermanLayout getInstance() {
return instance;
}
@Override
public int[][] getLUT() {
return LUT;
}
@Override
public int[][] getFastLUT() {
return FAST_LUT;
}
@Override
public void type(String text) {
super.type(FAST_LUT, text, (byte)0);
}
@Override
public void type(String text, byte modifiers) {
super.type(FAST_LUT, text, modifiers);
}
@Override
public char getChar(int scanCode, boolean capsLock, boolean shift, boolean altGr) {
return super.getChar(LUT, scanCode, capsLock, shift, altGr);
}
@Override
public String getLocaleName() {
return LOCALE_NAME;
}
@Override
public int[][] getDeadkeyLUT() {
return DEADKEY_LUT;
}
@Override
public int[] getDeadkeys() {
return DEADKEYS;
}
}

View File

@ -0,0 +1,353 @@
package com.inputstick.api.layout;
public class GermanMacLayout extends KeyboardLayout {
public static final String LOCALE_NAME = "de-DE-mac";
//{char (16b unicode), modifier, key, deadkey_modifier, deadkey}
//de-DE-mac
private static final int[][] FAST_LUT = {
{ 0, 0, 0, 0, 0 }, // empty
{ 27, 1, 47, 0, 0 }, // 
{ 28, 1, 49, 0, 0 }, // 
{ 29, 1, 48, 0, 0 }, // 
{ 32, 0, 44, 0, 0 }, //
{ 33, 2, 30, 0, 0 }, // !
{ 34, 2, 31, 0, 0 }, // "
{ 35, 0, 49, 0, 0 }, // #
{ 36, 2, 33, 0, 0 }, // $
{ 37, 2, 34, 0, 0 }, // %
{ 38, 2, 35, 0, 0 }, // &
{ 39, 2, 49, 0, 0 }, // '
{ 40, 2, 37, 0, 0 }, // (
{ 41, 2, 38, 0, 0 }, // )
{ 42, 2, 48, 0, 0 }, // *
{ 43, 0, 48, 0, 0 }, // +
{ 44, 0, 54, 0, 0 }, // ,
{ 45, 0, 56, 0, 0 }, // -
{ 46, 0, 55, 0, 0 }, // .
{ 47, 2, 36, 0, 0 }, // /
{ 48, 0, 39, 0, 0 }, // 0
{ 49, 0, 30, 0, 0 }, // 1
{ 50, 0, 31, 0, 0 }, // 2
{ 51, 0, 32, 0, 0 }, // 3
{ 52, 0, 33, 0, 0 }, // 4
{ 53, 0, 34, 0, 0 }, // 5
{ 54, 0, 35, 0, 0 }, // 6
{ 55, 0, 36, 0, 0 }, // 7
{ 56, 0, 37, 0, 0 }, // 8
{ 57, 0, 38, 0, 0 }, // 9
{ 58, 2, 55, 0, 0 }, // :
{ 59, 2, 54, 0, 0 }, // ;
{ 60, 0, 100, 0, 0 }, // <
{ 61, 2, 39, 0, 0 }, // =
{ 62, 2, 100, 0, 0 }, // >
{ 63, 2, 45, 0, 0 }, // ?
{ 64, 64, 15, 0, 0 }, // @
{ 65, 2, 4, 0, 0 }, // A
{ 66, 2, 5, 0, 0 }, // B
{ 67, 2, 6, 0, 0 }, // C
{ 68, 2, 7, 0, 0 }, // D
{ 69, 2, 8, 0, 0 }, // E
{ 70, 2, 9, 0, 0 }, // F
{ 71, 2, 10, 0, 0 }, // G
{ 72, 2, 11, 0, 0 }, // H
{ 73, 2, 12, 0, 0 }, // I
{ 74, 2, 13, 0, 0 }, // J
{ 75, 2, 14, 0, 0 }, // K
{ 76, 2, 15, 0, 0 }, // L
{ 77, 2, 16, 0, 0 }, // M
{ 78, 2, 17, 0, 0 }, // N
{ 79, 2, 18, 0, 0 }, // O
{ 80, 2, 19, 0, 0 }, // P
{ 81, 2, 20, 0, 0 }, // Q
{ 82, 2, 21, 0, 0 }, // R
{ 83, 2, 22, 0, 0 }, // S
{ 84, 2, 23, 0, 0 }, // T
{ 85, 2, 24, 0, 0 }, // U
{ 86, 2, 25, 0, 0 }, // V
{ 87, 2, 26, 0, 0 }, // W
{ 88, 2, 27, 0, 0 }, // X
{ 89, 2, 29, 0, 0 }, // Y
{ 90, 2, 28, 0, 0 }, // Z
{ 91, 64, 34, 0, 0 }, // [
{ 93, 64, 35, 0, 0 }, // ]
{ 94, 0, 44, 0, 53 }, // ^
{ 95, 2, 56, 0, 0 }, // _
{ 96, 0, 44, 2, 46 }, // `
{ 97, 0, 4, 0, 0 }, // a
{ 98, 0, 5, 0, 0 }, // b
{ 99, 0, 6, 0, 0 }, // c
{ 100, 0, 7, 0, 0 }, // d
{ 101, 0, 8, 0, 0 }, // e
{ 102, 0, 9, 0, 0 }, // f
{ 103, 0, 10, 0, 0 }, // g
{ 104, 0, 11, 0, 0 }, // h
{ 105, 0, 12, 0, 0 }, // i
{ 106, 0, 13, 0, 0 }, // j
{ 107, 0, 14, 0, 0 }, // k
{ 108, 0, 15, 0, 0 }, // l
{ 109, 0, 16, 0, 0 }, // m
{ 110, 0, 17, 0, 0 }, // n
{ 111, 0, 18, 0, 0 }, // o
{ 112, 0, 19, 0, 0 }, // p
{ 113, 0, 20, 0, 0 }, // q
{ 114, 0, 21, 0, 0 }, // r
{ 115, 0, 22, 0, 0 }, // s
{ 116, 0, 23, 0, 0 }, // t
{ 117, 0, 24, 0, 0 }, // u
{ 118, 0, 25, 0, 0 }, // v
{ 119, 0, 26, 0, 0 }, // w
{ 120, 0, 27, 0, 0 }, // x
{ 121, 0, 29, 0, 0 }, // y
{ 122, 0, 28, 0, 0 }, // z
{ 123, 64, 37, 0, 0 }, // {
{ 124, 64, 36, 0, 0 }, // |
{ 125, 64, 38, 0, 0 }, // }
{ 126, 64, 17, 0, 0 }, // ~
{ 167, 2, 32, 0, 0 }, // §
{ 176, 2, 53, 0, 0 }, // °
{ 180, 0, 44, 0, 46 }, // ´
{ 181, 64, 16, 0, 0 }, // µ
{ 192, 2, 4, 2, 46 }, // ?
{ 193, 2, 4, 0, 46 }, // Á
{ 194, 2, 4, 0, 53 }, // Â
{ 196, 2, 52, 0, 0 }, // Ä
{ 200, 2, 8, 2, 46 }, // ?
{ 201, 2, 8, 0, 46 }, // É
{ 202, 2, 8, 0, 53 }, // ?
{ 204, 2, 12, 2, 46 }, // ?
{ 205, 2, 12, 0, 46 }, // Í
{ 206, 2, 12, 0, 53 }, // Î
{ 210, 2, 18, 2, 46 }, // ?
{ 211, 2, 18, 0, 46 }, // Ó
{ 212, 2, 18, 0, 53 }, // Ô
{ 214, 2, 51, 0, 0 }, // Ö
{ 217, 2, 24, 2, 46 }, // ?
{ 218, 2, 24, 0, 46 }, // Ú
{ 219, 2, 24, 0, 53 }, // ?
{ 220, 2, 47, 0, 0 }, // Ü
{ 221, 2, 29, 0, 46 }, // Ý
{ 223, 0, 45, 0, 0 }, // ß
{ 224, 0, 4, 2, 46 }, // ?
{ 225, 0, 4, 0, 46 }, // á
{ 226, 0, 4, 0, 53 }, // â
{ 228, 0, 52, 0, 0 }, // ä
{ 232, 0, 8, 2, 46 }, // ?
{ 233, 0, 8, 0, 46 }, // é
{ 234, 0, 8, 0, 53 }, // ?
{ 236, 0, 12, 2, 46 }, // ?
{ 237, 0, 12, 0, 46 }, // í
{ 238, 0, 12, 0, 53 }, // î
{ 242, 0, 18, 2, 46 }, // ?
{ 243, 0, 18, 0, 46 }, // ó
{ 244, 0, 18, 0, 53 }, // ô
{ 246, 0, 51, 0, 0 }, // ö
{ 249, 0, 24, 2, 46 }, // ?
{ 250, 0, 24, 0, 46 }, // ú
{ 251, 0, 24, 0, 53 }, // ?
{ 252, 0, 47, 0, 0 }, // ü
{ 253, 0, 29, 0, 46 }, // ý
{ 8364, 64, 8, 0, 0 }, //
};
public static final int LUT[][] = {
// CAPSLOCK, NORMAL , SHIFT , CTRL , ALTGR , SHIFT + ALTGR
/* 0 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 1 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 2 */ { 0 , (int)'1' , 0x21 , -1 , -1 , -1 } ,
/* 3 */ { 0 , (int)'2' , 0x22 , -1 , -1 , -1 } ,
/* 4 */ { 0 , (int)'3' , 0x00a7 , -1 , -1 , -1 } ,
/* 5 */ { 0 , (int)'4' , 0x24 , -1 , -1 , -1 } ,
/* 6 */ { 0 , (int)'5' , 0x25 , -1 , 0x005b , 0x005b } ,
/* 7 */ { 0 , (int)'6' , 0x26 , -1 , 0x005d , 0x005d } ,
/* 8 */ { 0 , (int)'7' , 0x002f , -1 , 0x007c , 0x007c } ,
/* 9 */ { 0 , (int)'8' , 0x28 , -1 , 0x007b , 0x007b } ,
/* 0a */ { 0 , (int)'9' , 0x29 , -1 , 0x007d , 0x007d } ,
/* 0b */ { 0 , (int)'0' , 0x003d , -1 , -1 , -1 } ,
/* 0c */ { 0 , 0x00df , 0x003f , -1 , -1 , -1 } ,
/* 0d */ { 0 , 0x00b4 , 0x0060 , -1 , -1 , -1 } ,
/* 0e */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 0f */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 10 */ { 1 , (int)'q' , (int)'Q' , -1 , -1 , -1 } ,
/* 11 */ { 1 , (int)'w' , (int)'W' , -1 , -1 , -1 } ,
/* 12 */ { 1 , (int)'e' , (int)'E' , -1 , 0x20ac , -1 } , //euro, same as Windows layout
/* 13 */ { 1 , (int)'r' , (int)'R' , -1 , -1 , -1 } ,
/* 14 */ { 1 , (int)'t' , (int)'T' , -1 , -1 , -1 } ,
/* 15 */ { 1 , (int)'z' , (int)'Z' , -1 , -1 , -1 } ,
/* 16 */ { 1 , (int)'u' , (int)'U' , -1 , -1 , -1 } ,
/* 17 */ { 1 , (int)'i' , (int)'I' , -1 , -1 , -1 } ,
/* 18 */ { 1 , (int)'o' , (int)'O' , -1 , -1 , -1 } ,
/* 19 */ { 1 , (int)'p' , (int)'P' , -1 , -1 , -1 } ,
/* 1a */ { 1 , 0x00fc , 0x00dc , 0x001b , -1 , -1 } ,
/* 1b */ { 0 , 0x002b , 0x002a , 0x001d , -1 , -1 } ,
/* 1c */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 1d */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 1e */ { 1 , (int)'a' , (int)'A' , -1 , -1 , -1 } ,
/* 1f */ { 1 , (int)'s' , (int)'S' , -1 , -1 , -1 } ,
/* 20 */ { 1 , (int)'d' , (int)'D' , -1 , -1 , -1 } ,
/* 21 */ { 1 , (int)'f' , (int)'F' , -1 , -1 , -1 } ,
/* 22 */ { 1 , (int)'g' , (int)'G' , -1 , -1 , -1 } ,
/* 23 */ { 1 , (int)'h' , (int)'H' , -1 , -1 , -1 } ,
/* 24 */ { 1 , (int)'j' , (int)'J' , -1 , -1 , -1 } ,
/* 25 */ { 1 , (int)'k' , (int)'K' , -1 , -1 , -1 } ,
/* 26 */ { 1 , (int)'l' , (int)'L' , -1 , 0x0040 , -1 } ,
/* 27 */ { 1 , 0x00f6 , 0x00d6 , -1 , -1 , -1 } ,
/* 28 */ { 1 , 0x00e4 , 0x00c4 , -1 , -1 , -1 } ,
/* 29 */ { 0 , 0x005e , 0x00b0 , -1 , -1 , -1 } ,
/* 2a */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 2b */ { 0 , 0x23 , 0x27 , 0x001c , -1 , -1 } ,
/* 2c */ { 1 , (int)'y' , (int)'Y' , -1 , -1 , -1 } ,
/* 2d */ { 1 , (int)'x' , (int)'X' , -1 , -1 , -1 } ,
/* 2e */ { 1 , (int)'c' , (int)'C' , -1 , -1 , -1 } ,
/* 2f */ { 1 , (int)'v' , (int)'V' , -1 , -1 , -1 } ,
/* 30 */ { 1 , (int)'b' , (int)'B' , -1 , -1 , -1 } ,
/* 31 */ { 1 , (int)'n' , (int)'N' , -1 , 0x007e , 0x007e } , //MAC ~
/* 32 */ { 1 , (int)'m' , (int)'M' , -1 , 0x00b5 , 0x00b5 } , //"micro" - same as Windwos
/* 33 */ { 0 , 0x002c , 0x003b , -1 , -1 , -1 } ,
/* 34 */ { 0 , 0x002e , 0x003a , -1 , -1 , -1 } ,
/* 35 */ { 0 , 0x002d , 0x005f , -1 , -1 , -1 } ,
/* 36 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 37 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 38 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 39 */ { 0 , 0x20 , 0x20 , 0x20 , -1 , -1 } ,
/* 3a */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 3b */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 3c */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 3d */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 3e */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 3f */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 40 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 41 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 42 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 43 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 44 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 45 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 46 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 47 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 48 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 49 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 4a */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 4b */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 4c */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 4d */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 4e */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 4f */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 50 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 51 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 52 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 53 */ { 0 , 0x002c , 0x002c , -1 , -1 , -1 } ,
/* 54 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 55 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 56 */ { 0 , 0x003c , 0x003e , -1 , -1 , -1 } ,
/* 57 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 58 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 59 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 5a */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 5b */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 5c */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 5d */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 5e */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 5f */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
};
public static final int DEADKEYS[] = {
0x0060, 0x00b4, 0x005e
};
public static final int DEADKEY_LUT[][] = {
{ 0x00b4 , 0x0079 , 0x00fd } ,
{ 0x00b4 , 0x0061 , 0x00e1 } ,
{ 0x00b4 , 0x0065 , 0x00e9 } ,
{ 0x00b4 , 0x0075 , 0x00fa } ,
{ 0x00b4 , 0x0069 , 0x00ed } ,
{ 0x00b4 , 0x006f , 0x00f3 } ,
{ 0x00b4 , 0x0059 , 0x00dd } ,
{ 0x00b4 , 0x0041 , 0x00c1 } ,
{ 0x00b4 , 0x0045 , 0x00c9 } ,
{ 0x00b4 , 0x0055 , 0x00da } ,
{ 0x00b4 , 0x0049 , 0x00cd } ,
{ 0x00b4 , 0x004f , 0x00d3 } ,
{ 0x00b4 , 0x0020 , 0x00b4 } ,
{ 0x0060 , 0x0061 , 0x00e0 } ,
{ 0x0060 , 0x0065 , 0x00e8 } ,
{ 0x0060 , 0x0075 , 0x00f9 } ,
{ 0x0060 , 0x0069 , 0x00ec } ,
{ 0x0060 , 0x006f , 0x00f2 } ,
{ 0x0060 , 0x0041 , 0x00c0 } ,
{ 0x0060 , 0x0045 , 0x00c8 } ,
{ 0x0060 , 0x0055 , 0x00d9 } ,
{ 0x0060 , 0x0049 , 0x00cc } ,
{ 0x0060 , 0x004f , 0x00d2 } ,
{ 0x0060 , 0x0020 , 0x0060 } ,
{ 0x005e , 0x0061 , 0x00e2 } ,
{ 0x005e , 0x0065 , 0x00ea } ,
{ 0x005e , 0x0075 , 0x00fb } ,
{ 0x005e , 0x0069 , 0x00ee } ,
{ 0x005e , 0x006f , 0x00f4 } ,
{ 0x005e , 0x0041 , 0x00c2 } ,
{ 0x005e , 0x0045 , 0x00ca } ,
{ 0x005e , 0x0055 , 0x00db } ,
{ 0x005e , 0x0049 , 0x00ce } ,
{ 0x005e , 0x004f , 0x00d4 } ,
{ 0x005e , 0x0020 , 0x005e } ,
};
private static GermanMacLayout instance = new GermanMacLayout();
private GermanMacLayout() {
}
public static GermanMacLayout getInstance() {
return instance;
}
@Override
public int[][] getLUT() {
return LUT;
}
@Override
public int[][] getFastLUT() {
return FAST_LUT;
}
@Override
public void type(String text) {
super.type(FAST_LUT, text, (byte)0);
}
@Override
public void type(String text, byte modifiers) {
super.type(FAST_LUT, text, modifiers);
}
@Override
public char getChar(int scanCode, boolean capsLock, boolean shift, boolean altGr) {
return super.getChar(LUT, scanCode, capsLock, shift, altGr);
}
@Override
public String getLocaleName() {
return LOCALE_NAME;
}
@Override
public int[][] getDeadkeyLUT() {
return DEADKEY_LUT;
}
@Override
public int[] getDeadkeys() {
return DEADKEYS;
}
}

View File

@ -0,0 +1,275 @@
package com.inputstick.api.layout;
public class HebrewLayout extends KeyboardLayout {
public static final String LOCALE_NAME = "he-IL";
//{char (16b unicode), modifier, key, deadkey_modifier, deadkey}
//he-IL
private static final int[][] FAST_LUT = {
{ 0, 0, 0, 0, 0 }, // empty
{ 28, 1, 49, 0, 0 }, // 
{ 32, 0, 44, 0, 0 }, //
{ 33, 2, 30, 0, 0 }, // !
{ 34, 2, 52, 0, 0 }, // "
{ 35, 2, 32, 0, 0 }, // #
{ 36, 2, 33, 0, 0 }, // $
{ 37, 2, 34, 0, 0 }, // %
{ 38, 2, 36, 0, 0 }, // &
{ 39, 0, 26, 0, 0 }, // '
{ 40, 2, 39, 0, 0 }, // (
{ 41, 2, 38, 0, 0 }, // )
{ 42, 2, 37, 0, 0 }, // *
{ 43, 2, 46, 0, 0 }, // +
{ 44, 0, 52, 0, 0 }, // ,
{ 45, 0, 45, 0, 0 }, // -
{ 46, 0, 56, 0, 0 }, // .
{ 47, 0, 20, 0, 0 }, // /
{ 48, 0, 39, 0, 0 }, // 0
{ 49, 0, 30, 0, 0 }, // 1
{ 50, 0, 31, 0, 0 }, // 2
{ 51, 0, 32, 0, 0 }, // 3
{ 52, 0, 33, 0, 0 }, // 4
{ 53, 0, 34, 0, 0 }, // 5
{ 54, 0, 35, 0, 0 }, // 6
{ 55, 0, 36, 0, 0 }, // 7
{ 56, 0, 37, 0, 0 }, // 8
{ 57, 0, 38, 0, 0 }, // 9
{ 58, 2, 51, 0, 0 }, // :
{ 59, 0, 53, 0, 0 }, // ;
{ 60, 2, 55, 0, 0 }, // <
{ 61, 0, 46, 0, 0 }, // =
{ 62, 2, 54, 0, 0 }, // >
{ 63, 2, 56, 0, 0 }, // ?
{ 64, 2, 31, 0, 0 }, // @
{ 65, 2, 4, 0, 0 }, // A
{ 66, 2, 5, 0, 0 }, // B
{ 67, 2, 6, 0, 0 }, // C
{ 68, 2, 7, 0, 0 }, // D
{ 69, 2, 8, 0, 0 }, // E
{ 70, 2, 9, 0, 0 }, // F
{ 71, 2, 10, 0, 0 }, // G
{ 72, 2, 11, 0, 0 }, // H
{ 73, 2, 12, 0, 0 }, // I
{ 74, 2, 13, 0, 0 }, // J
{ 75, 2, 14, 0, 0 }, // K
{ 76, 2, 15, 0, 0 }, // L
{ 77, 2, 16, 0, 0 }, // M
{ 78, 2, 17, 0, 0 }, // N
{ 79, 2, 18, 0, 0 }, // O
{ 80, 2, 19, 0, 0 }, // P
{ 81, 2, 20, 0, 0 }, // Q
{ 82, 2, 21, 0, 0 }, // R
{ 83, 2, 22, 0, 0 }, // S
{ 84, 2, 23, 0, 0 }, // T
{ 85, 2, 24, 0, 0 }, // U
{ 86, 2, 25, 0, 0 }, // V
{ 87, 2, 26, 0, 0 }, // W
{ 88, 2, 27, 0, 0 }, // X
{ 89, 2, 28, 0, 0 }, // Y
{ 90, 2, 29, 0, 0 }, // Z
{ 91, 0, 48, 0, 0 }, // [
{ 92, 0, 49, 0, 0 }, // \
{ 93, 0, 47, 0, 0 }, // ]
{ 94, 2, 35, 0, 0 }, // ^
{ 95, 2, 45, 0, 0 }, // _
{ 123, 2, 48, 0, 0 }, // {
{ 124, 2, 49, 0, 0 }, // |
{ 125, 2, 47, 0, 0 }, // }
{ 126, 2, 53, 0, 0 }, // ~
{ 1471, 66, 45, 0, 0 }, // ?
{ 1488, 0, 23, 0, 0 }, // ?
{ 1489, 0, 6, 0, 0 }, // ?
{ 1490, 0, 7, 0, 0 }, // ?
{ 1491, 0, 22, 0, 0 }, // ?
{ 1492, 0, 25, 0, 0 }, // ?
{ 1493, 0, 24, 0, 0 }, // ?
{ 1494, 0, 29, 0, 0 }, // ?
{ 1495, 0, 13, 0, 0 }, // ?
{ 1496, 0, 28, 0, 0 }, // ?
{ 1497, 0, 11, 0, 0 }, // ?
{ 1498, 0, 15, 0, 0 }, // ?
{ 1499, 0, 9, 0, 0 }, // ?
{ 1500, 0, 14, 0, 0 }, // ?
{ 1501, 0, 18, 0, 0 }, // ?
{ 1502, 0, 17, 0, 0 }, // ?
{ 1503, 0, 12, 0, 0 }, // ?
{ 1504, 0, 5, 0, 0 }, // ?
{ 1505, 0, 27, 0, 0 }, // ?
{ 1506, 0, 10, 0, 0 }, // ?
{ 1507, 0, 51, 0, 0 }, // ?
{ 1508, 0, 19, 0, 0 }, // ?
{ 1509, 0, 55, 0, 0 }, // ?
{ 1510, 0, 16, 0, 0 }, // ?
{ 1511, 0, 8, 0, 0 }, // ?
{ 1512, 0, 21, 0, 0 }, // ?
{ 1513, 0, 4, 0, 0 }, // ?
{ 1514, 0, 54, 0, 0 }, // ?
{ 1520, 66, 24, 0, 0 }, // ?
{ 1521, 66, 13, 0, 0 }, // ?
{ 1522, 66, 11, 0, 0 }, // ?
{ 8206, 64, 32, 0, 0 }, // ?
{ 8207, 64, 33, 0, 0 }, // ?
{ 8362, 66, 33, 0, 0 }, // ?
{ 8364, 66, 8, 0, 0 }, //
};
public static final int LUT[][] = {
/* 0 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 1 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 2 */ { 0 , (int)'1' , 0x0021 , -1 , -1 , -1 } , // TODO SGCap
/* 3 */ { 0 , (int)'2' , 0x0040 , -1 , -1 , -1 } , // TODO SGCap
/* 4 */ { 0 , (int)'3' , 0x0023 , -1 , 0x200e , -1 } , // TODO SGCap
/* 5 */ { 0 , (int)'4' , 0x0024 , -1 , 0x200f , 0x20aa } , // TODO SGCap
/* 6 */ { 0 , (int)'5' , 0x0025 , -1 , -1 , -1 } , // TODO SGCap
/* 7 */ { 0 , (int)'6' , 0x005e , -1 , -1 , -1 } , // TODO SGCap
/* 8 */ { 0 , (int)'7' , 0x0026 , -1 , -1 , -1 } , // TODO SGCap
/* 9 */ { 0 , (int)'8' , 0x002a , -1 , -1 , -1 } , // TODO SGCap
/* 0a */ { 0 , (int)'9' , 0x0029 , -1 , -1 , -1 } , // TODO SGCap
/* 0b */ { 0 , (int)'0' , 0x0028 , -1 , -1 , -1 } , // TODO SGCap
/* 0c */ { 0 , 0x002d , 0x005f , -1 , -1 , 0x05bf } , // TODO SGCap
/* 0d */ { 0 , 0x003d , 0x002b , -1 , -1 , -1 } , // TODO SGCap
/* 0e */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 0f */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 10 */ { 1 , 0x002f , (int)'Q' , -1 , -1 , -1 } ,
/* 11 */ { 1 , 0x0027 , (int)'W' , -1 , -1 , -1 } ,
/* 12 */ { 1 , 0x05e7 , (int)'E' , -1 , -1 , 0x20ac } ,
/* 13 */ { 1 , 0x05e8 , (int)'R' , -1 , -1 , -1 } ,
/* 14 */ { 1 , 0x05d0 , (int)'T' , -1 , -1 , -1 } ,
/* 15 */ { 1 , 0x05d8 , (int)'Y' , -1 , -1 , -1 } ,
/* 16 */ { 1 , 0x05d5 , (int)'U' , -1 , -1 , 0x05f0 } ,
/* 17 */ { 1 , 0x05df , (int)'I' , -1 , -1 , -1 } ,
/* 18 */ { 1 , 0x05dd , (int)'O' , -1 , -1 , -1 } ,
/* 19 */ { 1 , 0x05e4 , (int)'P' , -1 , -1 , -1 } ,
/* 1a */ { 0 , 0x005d , 0x007d , 0x200e , -1 , -1 } , // TODO SGCap
/* 1b */ { 0 , 0x005b , 0x007b , 0x200f , -1 , -1 } , // TODO SGCap
/* 1c */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 1d */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 1e */ { 1 , 0x05e9 , (int)'A' , -1 , -1 , -1 } ,
/* 1f */ { 1 , 0x05d3 , (int)'S' , -1 , -1 , -1 } ,
/* 20 */ { 1 , 0x05d2 , (int)'D' , -1 , -1 , -1 } ,
/* 21 */ { 1 , 0x05db , (int)'F' , -1 , -1 , -1 } ,
/* 22 */ { 1 , 0x05e2 , (int)'G' , -1 , -1 , -1 } ,
/* 23 */ { 1 , 0x05d9 , (int)'H' , -1 , -1 , 0x05f2 } ,
/* 24 */ { 1 , 0x05d7 , (int)'J' , -1 , -1 , 0x05f1 } ,
/* 25 */ { 1 , 0x05dc , (int)'K' , -1 , -1 , -1 } ,
/* 26 */ { 1 , 0x05da , (int)'L' , -1 , -1 , -1 } ,
/* 27 */ { 0 , 0x05e3 , 0x003a , -1 , -1 , -1 } , // TODO SGCap
/* 28 */ { 0 , 0x002c , 0x0022 , -1 , -1 , -1 } , // TODO SGCap
/* 29 */ { 0 , 0x003b , 0x007e , -1 , -1 , -1 } , // TODO SGCap
/* 2a */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 2b */ { 0 , 0x005c , 0x007c , 0x001c , -1 , -1 } , // TODO SGCap
/* 2c */ { 1 , 0x05d6 , (int)'Z' , -1 , -1 , -1 } ,
/* 2d */ { 1 , 0x05e1 , (int)'X' , -1 , -1 , -1 } ,
/* 2e */ { 1 , 0x05d1 , (int)'C' , -1 , -1 , -1 } ,
/* 2f */ { 1 , 0x05d4 , (int)'V' , -1 , -1 , -1 } ,
/* 30 */ { 1 , 0x05e0 , (int)'B' , -1 , -1 , -1 } ,
/* 31 */ { 1 , 0x05de , (int)'N' , -1 , -1 , -1 } ,
/* 32 */ { 1 , 0x05e6 , (int)'M' , -1 , -1 , -1 } ,
/* 33 */ { 0 , 0x05ea , 0x003e , -1 , -1 , -1 } , // TODO SGCap
/* 34 */ { 0 , 0x05e5 , 0x003c , -1 , -1 , -1 } , // TODO SGCap
/* 35 */ { 0 , 0x002e , 0x003f , -1 , -1 , -1 } , // TODO SGCap
/* 36 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 37 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 38 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 39 */ { 0 , 0x0020 , 0x0020 , 0x0020 , -1 , -1 } ,
/* 3a */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 3b */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 3c */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 3d */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 3e */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 3f */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 40 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 41 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 42 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 43 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 44 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 45 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 46 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 47 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 48 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 49 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 4a */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 4b */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 4c */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 4d */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 4e */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 4f */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 50 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 51 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 52 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 53 */ { 0 , 0x002e , 0x002e , -1 , -1 , -1 } ,
/* 54 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 55 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 56 */ { 0 , 0x005c , 0x007c , 0x001c , -1 , -1 } ,
/* 57 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 58 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 59 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 5a */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 5b */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 5c */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 5d */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 5e */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 5f */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
};
public static final int DEADKEYS[] = null;
public static final int DEADKEY_LUT[][] = null;
private static HebrewLayout instance = new HebrewLayout();
private HebrewLayout() {
}
public static HebrewLayout getInstance() {
return instance;
}
@Override
public int[][] getLUT() {
return LUT;
}
@Override
public int[][] getFastLUT() {
return FAST_LUT;
}
@Override
public void type(String text) {
super.type(FAST_LUT, text, (byte)0);
}
@Override
public void type(String text, byte modifiers) {
super.type(FAST_LUT, text, modifiers);
}
@Override
public char getChar(int scanCode, boolean capsLock, boolean shift, boolean altGr) {
return super.getChar(LUT, scanCode, capsLock, shift, altGr);
}
@Override
public String getLocaleName() {
return LOCALE_NAME;
}
@Override
public int[][] getDeadkeyLUT() {
return DEADKEY_LUT;
}
@Override
public int[] getDeadkeys() {
return DEADKEYS;
}
}

View File

@ -0,0 +1,279 @@
package com.inputstick.api.layout;
public class ItalianLayout extends KeyboardLayout {
public static final String LOCALE_NAME = "it-IT";
//{char (16b unicode), modifier, key, deadkey_modifier, deadkey}
//it-IT
private static final int[][] FAST_LUT = {
{ 0, 0, 0, 0, 0 }, // empty
{ 27, 1, 47, 0, 0 }, // 
{ 28, 1, 49, 0, 0 }, // 
{ 29, 1, 48, 0, 0 }, // 
{ 32, 0, 44, 0, 0 }, //
{ 33, 2, 30, 0, 0 }, // !
{ 34, 2, 31, 0, 0 }, // "
{ 35, 64, 52, 0, 0 }, // #
{ 36, 2, 33, 0, 0 }, // $
{ 37, 2, 34, 0, 0 }, // %
{ 38, 2, 35, 0, 0 }, // &
{ 39, 0, 45, 0, 0 }, // '
{ 40, 2, 37, 0, 0 }, // (
{ 41, 2, 38, 0, 0 }, // )
{ 42, 2, 48, 0, 0 }, // *
{ 43, 0, 48, 0, 0 }, // +
{ 44, 0, 54, 0, 0 }, // ,
{ 45, 0, 56, 0, 0 }, // -
{ 46, 0, 55, 0, 0 }, // .
{ 47, 2, 36, 0, 0 }, // /
{ 48, 0, 39, 0, 0 }, // 0
{ 49, 0, 30, 0, 0 }, // 1
{ 50, 0, 31, 0, 0 }, // 2
{ 51, 0, 32, 0, 0 }, // 3
{ 52, 0, 33, 0, 0 }, // 4
{ 53, 0, 34, 0, 0 }, // 5
{ 54, 0, 35, 0, 0 }, // 6
{ 55, 0, 36, 0, 0 }, // 7
{ 56, 0, 37, 0, 0 }, // 8
{ 57, 0, 38, 0, 0 }, // 9
{ 58, 2, 55, 0, 0 }, // :
{ 59, 2, 54, 0, 0 }, // ;
{ 60, 0, 100, 0, 0 }, // <
{ 61, 2, 39, 0, 0 }, // =
{ 62, 2, 100, 0, 0 }, // >
{ 63, 2, 45, 0, 0 }, // ?
{ 64, 64, 51, 0, 0 }, // @
{ 65, 2, 4, 0, 0 }, // A
{ 66, 2, 5, 0, 0 }, // B
{ 67, 2, 6, 0, 0 }, // C
{ 68, 2, 7, 0, 0 }, // D
{ 69, 2, 8, 0, 0 }, // E
{ 70, 2, 9, 0, 0 }, // F
{ 71, 2, 10, 0, 0 }, // G
{ 72, 2, 11, 0, 0 }, // H
{ 73, 2, 12, 0, 0 }, // I
{ 74, 2, 13, 0, 0 }, // J
{ 75, 2, 14, 0, 0 }, // K
{ 76, 2, 15, 0, 0 }, // L
{ 77, 2, 16, 0, 0 }, // M
{ 78, 2, 17, 0, 0 }, // N
{ 79, 2, 18, 0, 0 }, // O
{ 80, 2, 19, 0, 0 }, // P
{ 81, 2, 20, 0, 0 }, // Q
{ 82, 2, 21, 0, 0 }, // R
{ 83, 2, 22, 0, 0 }, // S
{ 84, 2, 23, 0, 0 }, // T
{ 85, 2, 24, 0, 0 }, // U
{ 86, 2, 25, 0, 0 }, // V
{ 87, 2, 26, 0, 0 }, // W
{ 88, 2, 27, 0, 0 }, // X
{ 89, 2, 28, 0, 0 }, // Y
{ 90, 2, 29, 0, 0 }, // Z
{ 91, 64, 47, 0, 0 }, // [
{ 92, 0, 53, 0, 0 }, // \
{ 93, 64, 48, 0, 0 }, // ]
{ 94, 2, 46, 0, 0 }, // ^
{ 95, 2, 56, 0, 0 }, // _
{ 97, 0, 4, 0, 0 }, // a
{ 98, 0, 5, 0, 0 }, // b
{ 99, 0, 6, 0, 0 }, // c
{ 100, 0, 7, 0, 0 }, // d
{ 101, 0, 8, 0, 0 }, // e
{ 102, 0, 9, 0, 0 }, // f
{ 103, 0, 10, 0, 0 }, // g
{ 104, 0, 11, 0, 0 }, // h
{ 105, 0, 12, 0, 0 }, // i
{ 106, 0, 13, 0, 0 }, // j
{ 107, 0, 14, 0, 0 }, // k
{ 108, 0, 15, 0, 0 }, // l
{ 109, 0, 16, 0, 0 }, // m
{ 110, 0, 17, 0, 0 }, // n
{ 111, 0, 18, 0, 0 }, // o
{ 112, 0, 19, 0, 0 }, // p
{ 113, 0, 20, 0, 0 }, // q
{ 114, 0, 21, 0, 0 }, // r
{ 115, 0, 22, 0, 0 }, // s
{ 116, 0, 23, 0, 0 }, // t
{ 117, 0, 24, 0, 0 }, // u
{ 118, 0, 25, 0, 0 }, // v
{ 119, 0, 26, 0, 0 }, // w
{ 120, 0, 27, 0, 0 }, // x
{ 121, 0, 28, 0, 0 }, // y
{ 122, 0, 29, 0, 0 }, // z
{ 123, 66, 47, 0, 0 }, // {
{ 124, 2, 53, 0, 0 }, // |
{ 125, 66, 48, 0, 0 }, // }
{ 163, 2, 32, 0, 0 }, // ?
{ 167, 2, 49, 0, 0 }, // §
{ 176, 2, 52, 0, 0 }, // °
{ 224, 0, 52, 0, 0 }, // ?
{ 231, 2, 51, 0, 0 }, // ç
{ 232, 0, 47, 0, 0 }, // ?
{ 233, 2, 47, 0, 0 }, // é
{ 236, 0, 46, 0, 0 }, // ?
{ 242, 0, 51, 0, 0 }, // ?
{ 249, 0, 49, 0, 0 }, // ?
{ 8364, 64, 34, 0, 0 }, //
};
public static final int LUT[][] = {
/* 0 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 1 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 2 */ { 0 , (int)'1' , 0x0021 , -1 , -1 , -1 } ,
/* 3 */ { 0 , (int)'2' , 0x0022 , -1 , -1 , -1 } ,
/* 4 */ { 0 , (int)'3' , 0x00a3 , -1 , -1 , -1 } ,
/* 5 */ { 0 , (int)'4' , 0x0024 , -1 , -1 , -1 } ,
/* 6 */ { 0 , (int)'5' , 0x0025 , -1 , 0x20ac , -1 } ,
/* 7 */ { 0 , (int)'6' , 0x0026 , -1 , -1 , -1 } ,
/* 8 */ { 0 , (int)'7' , 0x002f , -1 , -1 , -1 } ,
/* 9 */ { 0 , (int)'8' , 0x0028 , -1 , -1 , -1 } ,
/* 0a */ { 0 , (int)'9' , 0x0029 , -1 , -1 , -1 } ,
/* 0b */ { 0 , (int)'0' , 0x003d , -1 , -1 , -1 } ,
/* 0c */ { 0 , 0x0027 , 0x003f , -1 , -1 , -1 } ,
/* 0d */ { 0 , 0x00ec , 0x005e , -1 , -1 , -1 } ,
/* 0e */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 0f */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 10 */ { 1 , (int)'q' , (int)'Q' , -1 , -1 , -1 } ,
/* 11 */ { 1 , (int)'w' , (int)'W' , -1 , -1 , -1 } ,
/* 12 */ { 1 , (int)'e' , (int)'E' , -1 , 0x20ac , -1 } ,
/* 13 */ { 1 , (int)'r' , (int)'R' , -1 , -1 , -1 } ,
/* 14 */ { 1 , (int)'t' , (int)'T' , -1 , -1 , -1 } ,
/* 15 */ { 1 , (int)'y' , (int)'Y' , -1 , -1 , -1 } ,
/* 16 */ { 1 , (int)'u' , (int)'U' , -1 , -1 , -1 } ,
/* 17 */ { 1 , (int)'i' , (int)'I' , -1 , -1 , -1 } ,
/* 18 */ { 1 , (int)'o' , (int)'O' , -1 , -1 , -1 } ,
/* 19 */ { 1 , (int)'p' , (int)'P' , -1 , -1 , -1 } ,
/* 1a */ { 0 , 0x00e8 , 0x00e9 , 0x001b , 0x005b , 0x007b } ,
/* 1b */ { 0 , 0x002b , 0x002a , 0x001d , 0x005d , 0x007d } ,
/* 1c */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 1d */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 1e */ { 1 , (int)'a' , (int)'A' , -1 , -1 , -1 } ,
/* 1f */ { 1 , (int)'s' , (int)'S' , -1 , -1 , -1 } ,
/* 20 */ { 1 , (int)'d' , (int)'D' , -1 , -1 , -1 } ,
/* 21 */ { 1 , (int)'f' , (int)'F' , -1 , -1 , -1 } ,
/* 22 */ { 1 , (int)'g' , (int)'G' , -1 , -1 , -1 } ,
/* 23 */ { 1 , (int)'h' , (int)'H' , -1 , -1 , -1 } ,
/* 24 */ { 1 , (int)'j' , (int)'J' , -1 , -1 , -1 } ,
/* 25 */ { 1 , (int)'k' , (int)'K' , -1 , -1 , -1 } ,
/* 26 */ { 1 , (int)'l' , (int)'L' , -1 , -1 , -1 } ,
/* 27 */ { 0 , 0x00f2 , 0x00e7 , -1 , 0x0040 , -1 } ,
/* 28 */ { 0 , 0x00e0 , 0x00b0 , -1 , 0x0023 , -1 } ,
/* 29 */ { 0 , 0x005c , 0x007c , -1 , -1 , -1 } ,
/* 2a */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 2b */ { 0 , 0x00f9 , 0x00a7 , 0x001c , -1 , -1 } ,
/* 2c */ { 1 , (int)'z' , (int)'Z' , -1 , -1 , -1 } ,
/* 2d */ { 1 , (int)'x' , (int)'X' , -1 , -1 , -1 } ,
/* 2e */ { 1 , (int)'c' , (int)'C' , -1 , -1 , -1 } ,
/* 2f */ { 1 , (int)'v' , (int)'V' , -1 , -1 , -1 } ,
/* 30 */ { 1 , (int)'b' , (int)'B' , -1 , -1 , -1 } ,
/* 31 */ { 1 , (int)'n' , (int)'N' , -1 , -1 , -1 } ,
/* 32 */ { 1 , (int)'m' , (int)'M' , -1 , -1 , -1 } ,
/* 33 */ { 0 , 0x002c , 0x003b , -1 , -1 , -1 } ,
/* 34 */ { 0 , 0x002e , 0x003a , -1 , -1 , -1 } ,
/* 35 */ { 0 , 0x002d , 0x005f , -1 , -1 , -1 } ,
/* 36 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 37 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 38 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 39 */ { 0 , 0x0020 , 0x0020 , 0x0020 , -1 , -1 } ,
/* 3a */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 3b */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 3c */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 3d */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 3e */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 3f */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 40 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 41 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 42 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 43 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 44 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 45 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 46 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 47 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 48 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 49 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 4a */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 4b */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 4c */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 4d */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 4e */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 4f */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 50 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 51 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 52 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 53 */ { 0 , 0x002e , 0x002e , -1 , -1 , -1 } ,
/* 54 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 55 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 56 */ { 0 , 0x003c , 0x003e , 0x001c , -1 , -1 } ,
/* 57 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 58 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 59 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 5a */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 5b */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 5c */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 5d */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 5e */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 5f */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
};
public static final int DEADKEYS[] = null;
public static final int DEADKEY_LUT[][] = null;
private static ItalianLayout instance = new ItalianLayout();
private ItalianLayout() {
}
public static ItalianLayout getInstance() {
return instance;
}
@Override
public int[][] getLUT() {
return LUT;
}
@Override
public int[][] getFastLUT() {
return FAST_LUT;
}
@Override
public void type(String text) {
super.type(FAST_LUT, text, (byte)0);
}
@Override
public void type(String text, byte modifiers) {
super.type(FAST_LUT, text, modifiers);
}
@Override
public char getChar(int scanCode, boolean capsLock, boolean shift, boolean altGr) {
return super.getChar(LUT, scanCode, capsLock, shift, altGr);
}
@Override
public String getLocaleName() {
return LOCALE_NAME;
}
@Override
public int[][] getDeadkeyLUT() {
return DEADKEY_LUT;
}
@Override
public int[] getDeadkeys() {
return DEADKEYS;
}
}

View File

@ -0,0 +1,432 @@
package com.inputstick.api.layout;
import com.inputstick.api.ConnectionManager;
import com.inputstick.api.basic.InputStickHID;
import com.inputstick.api.basic.InputStickKeyboard;
import com.inputstick.api.hid.HIDKeycodes;
import com.inputstick.api.hid.HIDTransaction;
import com.inputstick.api.hid.KeyboardReport;
public abstract class KeyboardLayout {
public static final int MAX_SCANCODE = 0x60;
public static final byte[] scanCodeToHID = {
/* 0x00 */ 0,
/* 0x01 */ HIDKeycodes.KEY_ESCAPE,
/* 0x02 */ HIDKeycodes.KEY_1,
/* 0x03 */ HIDKeycodes.KEY_2,
/* 0x04 */ HIDKeycodes.KEY_3,
/* 0x05 */ HIDKeycodes.KEY_4,
/* 0x06 */ HIDKeycodes.KEY_5,
/* 0x07 */ HIDKeycodes.KEY_6,
/* 0x08 */ HIDKeycodes.KEY_7,
/* 0x09 */ HIDKeycodes.KEY_8,
/* 0x0a */ HIDKeycodes.KEY_9,
/* 0x0b */ HIDKeycodes.KEY_0,
/* 0x0c */ HIDKeycodes.KEY_MINUS,
/* 0x0d */ HIDKeycodes.KEY_EQUALS,
/* 0x0e */ HIDKeycodes.KEY_BACKSPACE,
/* 0x0f */ HIDKeycodes.KEY_TAB,
/* 0x10 */ HIDKeycodes.KEY_Q,
/* 0x11 */ HIDKeycodes.KEY_W,
/* 0x12 */ HIDKeycodes.KEY_E,
/* 0x13 */ HIDKeycodes.KEY_R,
/* 0x14 */ HIDKeycodes.KEY_T,
/* 0x15 */ HIDKeycodes.KEY_Y,
/* 0x16 */ HIDKeycodes.KEY_U,
/* 0x17 */ HIDKeycodes.KEY_I,
/* 0x18 */ HIDKeycodes.KEY_O,
/* 0x19 */ HIDKeycodes.KEY_P,
/* 0x1a */ HIDKeycodes.KEY_LEFT_BRACKET,
/* 0x1b */ HIDKeycodes.KEY_RIGHT_BRACKET,
/* 0x1c */ HIDKeycodes.KEY_ENTER,
/* 0x1d */ 0, //RL CTRL
/* 0x1e */ HIDKeycodes.KEY_A,
/* 0x1f */ HIDKeycodes.KEY_S,
/* 0x20 */ HIDKeycodes.KEY_D,
/* 0x21 */ HIDKeycodes.KEY_F,
/* 0x22 */ HIDKeycodes.KEY_G,
/* 0x23 */ HIDKeycodes.KEY_H,
/* 0x24 */ HIDKeycodes.KEY_J,
/* 0x25 */ HIDKeycodes.KEY_K,
/* 0x26 */ HIDKeycodes.KEY_L,
/* 0x27 */ HIDKeycodes.KEY_SEMICOLON,
/* 0x28 */ HIDKeycodes.KEY_APOSTROPHE,
/* 0x29 */ HIDKeycodes.KEY_GRAVE,
/* 0x2a */ 0, //L SHIFT
/* 0x2b */ HIDKeycodes.KEY_BACKSLASH,
/* 0x2c */ HIDKeycodes.KEY_Z,
/* 0x2d */ HIDKeycodes.KEY_X,
/* 0x2e */ HIDKeycodes.KEY_C,
/* 0x2f */ HIDKeycodes.KEY_V,
/* 0x30 */ HIDKeycodes.KEY_B,
/* 0x31 */ HIDKeycodes.KEY_N,
/* 0x32 */ HIDKeycodes.KEY_M,
/* 0x33 */ HIDKeycodes.KEY_COMA,
/* 0x34 */ HIDKeycodes.KEY_DOT,
/* 0x35 */ HIDKeycodes.KEY_SLASH,
/* 0x36 */ 0, //R SHIFT
/* 0x37 */ HIDKeycodes.KEY_PRINT_SCREEN,
/* 0x38 */ 0, //RL ALT
/* 0x39 */ HIDKeycodes.KEY_SPACEBAR,
/* 0x3a */ HIDKeycodes.KEY_CAPS_LOCK,
/* 0x3b */ HIDKeycodes.KEY_F1,
/* 0x3c */ HIDKeycodes.KEY_F2,
/* 0x3d */ HIDKeycodes.KEY_F3,
/* 0x3e */ HIDKeycodes.KEY_F4,
/* 0x3f */ HIDKeycodes.KEY_F5,
/* 0x40 */ HIDKeycodes.KEY_F6,
/* 0x41 */ HIDKeycodes.KEY_F7,
/* 0x42 */ HIDKeycodes.KEY_F8,
/* 0x43 */ HIDKeycodes.KEY_F9,
/* 0x44 */ HIDKeycodes.KEY_F10,
/* 0x45 */ HIDKeycodes.KEY_NUM_LOCK,
/* 0x46 */ HIDKeycodes.KEY_SCROLL_LOCK,
/* 0x47 */ HIDKeycodes.KEY_HOME,
/* 0x48 */ HIDKeycodes.KEY_ARROW_UP,
/* 0x49 */ HIDKeycodes.KEY_PAGE_UP,
/* 0x4a */ 0, //-
/* 0x4b */ HIDKeycodes.KEY_ARROW_LEFT,
/* 0x4c */ 0, //CENTER
/* 0x4d */ HIDKeycodes.KEY_ARROW_RIGHT,
/* 0x4e */ 0, //+
/* 0x4f */ HIDKeycodes.KEY_END,
/* 0x50 */ HIDKeycodes.KEY_ARROW_DOWN,
/* 0x51 */ HIDKeycodes.KEY_PAGE_DOWN,
/* 0x52 */ HIDKeycodes.KEY_INSERT,
/* 0x53 */ HIDKeycodes.KEY_DELETE,
/* 0x54 */ 0,
/* 0x55 */ 0,
/* 0x56 */ HIDKeycodes.KEY_BACKSLASH_NON_US, //GERMAN LAYOUT!
/* 0x57 */ HIDKeycodes.KEY_F11,
/* 0x58 */ HIDKeycodes.KEY_F12,
/* 0x59 */ 0,
/* 0x5a */ 0,
/* 0x5b */ 0,
/* 0x5c */ 0,
/* 0x5d */ 0,
/* 0x5e */ 0,
/* 0x5f */ 0,
};
public static final int LAYOUT_CODE = 0;
public abstract int[][] getLUT();
public abstract int[][] getFastLUT();
public abstract int[][] getDeadkeyLUT();
public abstract int[] getDeadkeys();
public abstract String getLocaleName();
/*
* Type text using InputStick. Assumes that USB host uses matching keyboard layout.
*
* @param text text to type
*/
public abstract void type(String text);
/*
* Type text using InputStick. Assumes that USB host uses matching keyboard layout.
* Note: use only if you are certain that specified modifier keys will not cause any side effects during typing.
*
* @param text text to type
* @param modifiers state of keyboard modifier keys (CTRL_LEFT .. GUI_RIGHT, see HIDKeycodes)
*/
public abstract void type(String text, byte modifiers);
public abstract char getChar(int scanCode, boolean capsLock, boolean shift, boolean altGr);
public void type(int[][] fastLUT, String text, byte modifiers) {
if (InputStickHID.getState() == ConnectionManager.STATE_READY) {
char[] chars = text.toCharArray();
HIDTransaction t;
for (char c : chars) {
if (c == '\n') {
InputStickKeyboard.pressAndRelease(HIDKeycodes.NONE, HIDKeycodes.KEY_ENTER);
} else if (c == '\t') {
InputStickKeyboard.pressAndRelease(HIDKeycodes.NONE, HIDKeycodes.KEY_TAB);
} else {
t = getHIDTransaction(fastLUT, c, modifiers);
if (t != null) {
InputStickHID.addKeyboardTransaction(t);
}
}
}
}
}
/*public void type(int[][] lut, int[][] deadkeyLUT, int[] deadkeys, String text, byte modifiers) {
if (InputStickHID.getState() == ConnectionManager.STATE_READY) {
char[] chars = text.toCharArray();
HIDTransaction t;
for (char c : chars) {
if (c == '\n') {
InputStickKeyboard.pressAndRelease(HIDKeycodes.NONE, HIDKeycodes.KEY_ENTER);
} else if (c == '\t') {
InputStickKeyboard.pressAndRelease(HIDKeycodes.NONE, HIDKeycodes.KEY_TAB);
} else {
t = getHIDTransaction(lut, deadkeyLUT, deadkeys, c, modifiers);
if (t != null) {
InputStickHID.addKeyboardTransaction(t);
}
}
}
}
} */
public static int hidToScanCode(byte key) {
for (int scanCode = 0; scanCode < MAX_SCANCODE; scanCode++) {
if (scanCodeToHID[scanCode] == key) {
return scanCode;
}
}
return -1;
}
public static char getChar(int[][] lut, int scanCode, boolean capsLock, boolean shift, boolean altGr) {
if ((scanCode >= MAX_SCANCODE) || (scanCode < 0)) {
return (char)0;
}
int index = 1;
if ((capsLock) && (lut[scanCode][0] > 0)) {
//capslock is on and it affects current key
if (lut[scanCode][0] == 1) {
if (shift) {
index = 1; //caps + shift = default
} else {
index = 2; //shift
}
} else {
// >1
if (shift) {
if (altGr) {
index = 4; //caps + shift + alt = alt
} else {
index = 1; //caps + shift = default
}
} else {
if (altGr) {
index = 5; //caps + alt = shift + alt
} else {
index = 2; //caps = shift
}
}
}
} else {
if (shift) {
index = 2;
}
if (altGr) {
if (shift) {
index = 5;
} else {
index = 4;
}
}
}
if (lut[scanCode][index] == -1) {
index = 1;
}
return (char)lut[scanCode][index];
}
public static int getScanCode(int[][] lut, char c) {
for (int scanCode = 0; scanCode < MAX_SCANCODE; scanCode++) {
if (lut[scanCode][0] == -1) {
continue;
} else {
for (int i = 1; i < 6; i++) {
if (lut[scanCode][i] == (int)c) {
return scanCode;
}
}
}
}
return -1;
}
public static byte getKey(int scanCode) {
return scanCodeToHID[scanCode];
}
public static byte getModifiers(int[][] lut, int scanCode, char c) {
if (lut[scanCode][1] == (int)c) {
return 0;
}
if (lut[scanCode][2] == (int)c) {
return HIDKeycodes.SHIFT_LEFT;
}
if (lut[scanCode][3] == (int)c) {
return HIDKeycodes.CTRL_LEFT;
}
if (lut[scanCode][4] == (int)c) {
return HIDKeycodes.ALT_RIGHT;
}
if (lut[scanCode][5] == (int)c) {
return HIDKeycodes.SHIFT_LEFT | HIDKeycodes.ALT_RIGHT;
}
return 0;
}
public static boolean isDeadkey(int[] deadkeys, char c) {
if (deadkeys != null) {
for (int key : deadkeys) {
if (key == (int)c) {
return true;
}
}
}
return false;
}
public static int searchLUT(int[][] deadkeyLUT, char c, int returnIndex) {
if (deadkeyLUT != null) {
for (int i = 0; i < deadkeyLUT.length; i++) {
if (deadkeyLUT[i][2] == (int)c) {
return deadkeyLUT[i][returnIndex];
}
}
}
return -1;
}
public static int findDeadKey(int[][] deadkeyLUT, char c) {
return searchLUT(deadkeyLUT, c, 0);
}
public static int findFollowingKey(int[][] deadkeyLUT, char c) {
return searchLUT(deadkeyLUT, c, 1);
}
public static HIDTransaction getHIDTransaction(int[][] fastLUT, char c, byte additionalModifierKeys) {
byte modifiers, key, deadKey, deadKeyModifiers;
HIDTransaction t = new HIDTransaction();
for (int i = 0; i < fastLUT.length; i++) {
if (fastLUT[i][0] == c) {
modifiers = (byte)fastLUT[i][1];
key = (byte)fastLUT[i][2];
deadKeyModifiers = (byte)fastLUT[i][3];
deadKey = (byte)fastLUT[i][4];
if (deadKey > 0) {
t.addReport(new KeyboardReport(deadKeyModifiers, (byte)0));
t.addReport(new KeyboardReport(deadKeyModifiers, deadKey));
t.addReport(new KeyboardReport());
}
t.addReport(new KeyboardReport(modifiers, (byte)0));
t.addReport(new KeyboardReport(modifiers, key));
t.addReport(new KeyboardReport());
}
}
return t;
}
public static HIDTransaction getHIDTransaction(int[][] lut, int[][] deadkeyLUT, int[] deadkeys, char c, byte additionalModifierKeys) {
byte modifiers, key;
int scanCode;
HIDTransaction t = new HIDTransaction();
scanCode = getScanCode(lut, c);
if (scanCode > 0) {
key = getKey(scanCode);
modifiers = getModifiers(lut, scanCode, c);
modifiers |= additionalModifierKeys;
t.addReport(new KeyboardReport(modifiers, (byte)0));
t.addReport(new KeyboardReport(modifiers, key));
t.addReport(new KeyboardReport());
//add space after deadkey!
if (isDeadkey(deadkeys, c)) {
t.addReport(new KeyboardReport((byte)0, HIDKeycodes.KEY_SPACEBAR)); //this won't work if modifiers are present!
t.addReport(new KeyboardReport());
}
} else {
//check if character can be obtained using deadkey:
int deadkey = findDeadKey(deadkeyLUT, c);
if (deadkey > 0) {
//yes it can
int following = findFollowingKey(deadkeyLUT, c);
scanCode = getScanCode(lut, (char)deadkey);
key = getKey(scanCode);
modifiers = getModifiers(lut, scanCode, (char)deadkey);
t.addReport(new KeyboardReport(modifiers, (byte)0));
t.addReport(new KeyboardReport(modifiers, key));
t.addReport(new KeyboardReport());
scanCode = getScanCode(lut, (char)following);
key = getKey(scanCode);
modifiers = getModifiers(lut, scanCode, (char)following);
t.addReport(new KeyboardReport(modifiers, (byte)0));
t.addReport(new KeyboardReport(modifiers, key));
t.addReport(new KeyboardReport());
}
}
return t;
}
//returns layout sepcified by locale (example: "de-DE"). If specified layout is not available, en=US will be returned.
public static KeyboardLayout getLayout(String locale) {
if (locale != null) {
if (locale.equalsIgnoreCase(UnitedStatesLayout.LOCALE_NAME)) {
return UnitedStatesLayout.getInstance();
} else if (locale.equalsIgnoreCase(PolishLayout.LOCALE_NAME)) {
return PolishLayout.getInstance();
} else if (locale.equalsIgnoreCase(RussianLayout.LOCALE_NAME)) {
return RussianLayout.getInstance();
} else if (locale.equalsIgnoreCase(GermanLayout.LOCALE_NAME)) {
return GermanLayout.getInstance();
} else if (locale.equalsIgnoreCase(SlovakLayout.LOCALE_NAME)) {
return SlovakLayout.getInstance();
} else if (locale.equalsIgnoreCase(PortugueseBrazilianLayout.LOCALE_NAME)) {
return PortugueseBrazilianLayout.getInstance();
} else if (locale.equalsIgnoreCase(DvorakLayout.LOCALE_NAME)) {
return DvorakLayout.getInstance();
} else if (locale.equalsIgnoreCase(NorwegianLayout.LOCALE_NAME)) {
return NorwegianLayout.getInstance();
} else if (locale.equalsIgnoreCase(SwedishLayout.LOCALE_NAME)) {
return SwedishLayout.getInstance();
} else if (locale.equalsIgnoreCase(FrenchLayout.LOCALE_NAME)) {
return FrenchLayout.getInstance();
} else if (locale.equalsIgnoreCase(SpanishLayout.LOCALE_NAME)) {
return SpanishLayout.getInstance();
} else if (locale.equalsIgnoreCase(UnitedKingdomLayout.LOCALE_NAME)) {
return UnitedKingdomLayout.getInstance();
} else if (locale.equalsIgnoreCase(GermanMacLayout.LOCALE_NAME)) {
return GermanMacLayout.getInstance(); // TODO
} else if (locale.equalsIgnoreCase(ItalianLayout.LOCALE_NAME)) {
return ItalianLayout.getInstance();
} else if (locale.equalsIgnoreCase(FinnishLayout.LOCALE_NAME)) {
return FinnishLayout.getInstance();
} else if (locale.equalsIgnoreCase(SwissFrenchLayout.LOCALE_NAME)) {
return SwissFrenchLayout.getInstance();
} else if (locale.equalsIgnoreCase(SwissGermanLayout.LOCALE_NAME)) {
return SwissGermanLayout.getInstance();
} else if (locale.equalsIgnoreCase(HebrewLayout.LOCALE_NAME)) {
return HebrewLayout.getInstance();
} else if (locale.equalsIgnoreCase(DanishLayout.LOCALE_NAME)) {
return DanishLayout.getInstance();
}
}
return UnitedStatesLayout.getInstance();
}
}

View File

@ -0,0 +1,392 @@
package com.inputstick.api.layout;
public class NorwegianLayout extends KeyboardLayout {
public static final String LOCALE_NAME = "nb-NO";
//{char (16b unicode), modifier, key, deadkey_modifier, deadkey}
//nb-NO
private static final int[][] FAST_LUT = {
{ 0, 0, 0, 0, 0 }, // empty
{ 27, 1, 47, 0, 0 }, // 
{ 28, 1, 53, 0, 0 }, // 
{ 29, 1, 48, 0, 0 }, // 
{ 32, 0, 44, 0, 0 }, //
{ 33, 2, 30, 0, 0 }, // !
{ 34, 2, 31, 0, 0 }, // "
{ 35, 2, 32, 0, 0 }, // #
{ 36, 64, 33, 0, 0 }, // $
{ 37, 2, 34, 0, 0 }, // %
{ 38, 2, 35, 0, 0 }, // &
{ 39, 0, 49, 0, 0 }, // '
{ 40, 2, 37, 0, 0 }, // (
{ 41, 2, 38, 0, 0 }, // )
{ 42, 2, 49, 0, 0 }, // *
{ 43, 0, 45, 0, 0 }, // +
{ 44, 0, 54, 0, 0 }, // ,
{ 45, 0, 56, 0, 0 }, // -
{ 46, 0, 55, 0, 0 }, // .
{ 47, 2, 36, 0, 0 }, // /
{ 48, 0, 39, 0, 0 }, // 0
{ 49, 0, 30, 0, 0 }, // 1
{ 50, 0, 31, 0, 0 }, // 2
{ 51, 0, 32, 0, 0 }, // 3
{ 52, 0, 33, 0, 0 }, // 4
{ 53, 0, 34, 0, 0 }, // 5
{ 54, 0, 35, 0, 0 }, // 6
{ 55, 0, 36, 0, 0 }, // 7
{ 56, 0, 37, 0, 0 }, // 8
{ 57, 0, 38, 0, 0 }, // 9
{ 58, 2, 55, 0, 0 }, // :
{ 59, 2, 54, 0, 0 }, // ;
{ 60, 0, 100, 0, 0 }, // <
{ 61, 2, 39, 0, 0 }, // =
{ 62, 2, 100, 0, 0 }, // >
{ 63, 2, 45, 0, 0 }, // ?
{ 64, 64, 31, 0, 0 }, // @
{ 65, 2, 4, 0, 0 }, // A
{ 66, 2, 5, 0, 0 }, // B
{ 67, 2, 6, 0, 0 }, // C
{ 68, 2, 7, 0, 0 }, // D
{ 69, 2, 8, 0, 0 }, // E
{ 70, 2, 9, 0, 0 }, // F
{ 71, 2, 10, 0, 0 }, // G
{ 72, 2, 11, 0, 0 }, // H
{ 73, 2, 12, 0, 0 }, // I
{ 74, 2, 13, 0, 0 }, // J
{ 75, 2, 14, 0, 0 }, // K
{ 76, 2, 15, 0, 0 }, // L
{ 77, 2, 16, 0, 0 }, // M
{ 78, 2, 17, 0, 0 }, // N
{ 79, 2, 18, 0, 0 }, // O
{ 80, 2, 19, 0, 0 }, // P
{ 81, 2, 20, 0, 0 }, // Q
{ 82, 2, 21, 0, 0 }, // R
{ 83, 2, 22, 0, 0 }, // S
{ 84, 2, 23, 0, 0 }, // T
{ 85, 2, 24, 0, 0 }, // U
{ 86, 2, 25, 0, 0 }, // V
{ 87, 2, 26, 0, 0 }, // W
{ 88, 2, 27, 0, 0 }, // X
{ 89, 2, 28, 0, 0 }, // Y
{ 90, 2, 29, 0, 0 }, // Z
{ 91, 64, 37, 0, 0 }, // [
{ 92, 0, 46, 0, 0 }, // \
{ 93, 64, 38, 0, 0 }, // ]
{ 94, 0, 44, 2, 48 }, // ^
{ 95, 2, 56, 0, 0 }, // _
{ 96, 0, 44, 2, 46 }, // `
{ 97, 0, 4, 0, 0 }, // a
{ 98, 0, 5, 0, 0 }, // b
{ 99, 0, 6, 0, 0 }, // c
{ 100, 0, 7, 0, 0 }, // d
{ 101, 0, 8, 0, 0 }, // e
{ 102, 0, 9, 0, 0 }, // f
{ 103, 0, 10, 0, 0 }, // g
{ 104, 0, 11, 0, 0 }, // h
{ 105, 0, 12, 0, 0 }, // i
{ 106, 0, 13, 0, 0 }, // j
{ 107, 0, 14, 0, 0 }, // k
{ 108, 0, 15, 0, 0 }, // l
{ 109, 0, 16, 0, 0 }, // m
{ 110, 0, 17, 0, 0 }, // n
{ 111, 0, 18, 0, 0 }, // o
{ 112, 0, 19, 0, 0 }, // p
{ 113, 0, 20, 0, 0 }, // q
{ 114, 0, 21, 0, 0 }, // r
{ 115, 0, 22, 0, 0 }, // s
{ 116, 0, 23, 0, 0 }, // t
{ 117, 0, 24, 0, 0 }, // u
{ 118, 0, 25, 0, 0 }, // v
{ 119, 0, 26, 0, 0 }, // w
{ 120, 0, 27, 0, 0 }, // x
{ 121, 0, 28, 0, 0 }, // y
{ 122, 0, 29, 0, 0 }, // z
{ 123, 64, 36, 0, 0 }, // {
{ 124, 0, 53, 0, 0 }, // |
{ 125, 64, 39, 0, 0 }, // }
{ 126, 0, 44, 64, 48 }, // ~
{ 163, 64, 32, 0, 0 }, // ?
{ 164, 2, 33, 0, 0 }, // ¤
{ 167, 2, 53, 0, 0 }, // §
{ 168, 0, 44, 0, 48 }, // ¨
{ 180, 0, 44, 64, 46 }, // ´
{ 181, 64, 16, 0, 0 }, // µ
{ 192, 2, 4, 2, 46 }, // ?
{ 193, 2, 4, 64, 46 }, // Á
{ 194, 2, 4, 2, 48 }, // Â
{ 195, 2, 4, 64, 48 }, // ?
{ 196, 2, 4, 0, 48 }, // Ä
{ 197, 2, 47, 0, 0 }, // ?
{ 198, 2, 52, 0, 0 }, // ?
{ 200, 2, 8, 2, 46 }, // ?
{ 201, 2, 8, 64, 46 }, // É
{ 202, 2, 8, 2, 48 }, // ?
{ 203, 2, 8, 0, 48 }, // Ë
{ 204, 2, 12, 2, 46 }, // ?
{ 205, 2, 12, 64, 46 }, // Í
{ 206, 2, 12, 2, 48 }, // Î
{ 207, 2, 12, 0, 48 }, // ?
{ 209, 2, 17, 64, 48 }, // ?
{ 210, 2, 18, 2, 46 }, // ?
{ 211, 2, 18, 64, 46 }, // Ó
{ 212, 2, 18, 2, 48 }, // Ô
{ 213, 2, 18, 64, 48 }, // ?
{ 214, 2, 18, 0, 48 }, // Ö
{ 216, 2, 51, 0, 0 }, // ?
{ 217, 2, 24, 2, 46 }, // ?
{ 218, 2, 24, 64, 46 }, // Ú
{ 219, 2, 24, 2, 48 }, // ?
{ 220, 2, 24, 0, 48 }, // Ü
{ 221, 2, 28, 64, 46 }, // Ý
{ 224, 0, 4, 2, 46 }, // ?
{ 225, 0, 4, 64, 46 }, // á
{ 226, 0, 4, 2, 48 }, // â
{ 227, 0, 4, 64, 48 }, // ?
{ 228, 0, 4, 0, 48 }, // ä
{ 229, 0, 47, 0, 0 }, // ?
{ 230, 0, 52, 0, 0 }, // ?
{ 232, 0, 8, 2, 46 }, // ?
{ 233, 0, 8, 64, 46 }, // é
{ 234, 0, 8, 2, 48 }, // ?
{ 235, 0, 8, 0, 48 }, // ë
{ 236, 0, 12, 2, 46 }, // ?
{ 237, 0, 12, 64, 46 }, // í
{ 238, 0, 12, 2, 48 }, // î
{ 239, 0, 12, 0, 48 }, // ?
{ 241, 0, 17, 64, 48 }, // ?
{ 242, 0, 18, 2, 46 }, // ?
{ 243, 0, 18, 64, 46 }, // ó
{ 244, 0, 18, 2, 48 }, // ô
{ 245, 0, 18, 64, 48 }, // ?
{ 246, 0, 18, 0, 48 }, // ö
{ 248, 0, 51, 0, 0 }, // ?
{ 249, 0, 24, 2, 46 }, // ?
{ 250, 0, 24, 64, 46 }, // ú
{ 251, 0, 24, 2, 48 }, // ?
{ 252, 0, 24, 0, 48 }, // ü
{ 253, 0, 28, 64, 46 }, // ý
{ 255, 0, 28, 0, 48 }, // ?
{ 8364, 64, 34, 0, 0 }, //
};
public static final int LUT[][] = {
/* 0 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 1 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 2 */ { 0 , (int)'1' , 0x21 , -1 , -1 , -1 } ,
/* 3 */ { 0 , (int)'2' , 0x22 , -1 , 0x40 , -1 } ,
/* 4 */ { 0 , (int)'3' , 0x23 , -1 , 0x00a3 , -1 } ,
/* 5 */ { 0 , (int)'4' , 0x00a4 , -1 , 0x24 , -1 } ,
/* 6 */ { 0 , (int)'5' , 0x25 , -1 , 0x20ac , -1 } ,
/* 7 */ { 0 , (int)'6' , 0x26 , -1 , -1 , -1 } ,
/* 8 */ { 0 , (int)'7' , 0x002f , -1 , 0x007b , -1 } ,
/* 9 */ { 0 , (int)'8' , 0x28 , -1 , 0x005b , -1 } ,
/* 0a */ { 0 , (int)'9' , 0x29 , -1 , 0x005d , -1 } ,
/* 0b */ { 0 , (int)'0' , 0x003d , -1 , 0x007d , -1 } ,
/* 0c */ { 0 , 0x002b , 0x003f , -1 , -1 , -1 } ,
/* 0d */ { 0 , 0x005c , 0x0060 , -1 , 0x00b4 , -1 } ,
/* 0e */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 0f */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 10 */ { 1 , (int)'q' , (int)'Q' , -1 , -1 , -1 } ,
/* 11 */ { 1 , (int)'w' , (int)'W' , -1 , -1 , -1 } ,
/* 12 */ { 1 , (int)'e' , (int)'E' , -1 , 0x20ac , -1 } ,
/* 13 */ { 1 , (int)'r' , (int)'R' , -1 , -1 , -1 } ,
/* 14 */ { 1 , (int)'t' , (int)'T' , -1 , -1 , -1 } ,
/* 15 */ { 1 , (int)'y' , (int)'Y' , -1 , -1 , -1 } ,
/* 16 */ { 1 , (int)'u' , (int)'U' , -1 , -1 , -1 } ,
/* 17 */ { 1 , (int)'i' , (int)'I' , -1 , -1 , -1 } ,
/* 18 */ { 1 , (int)'o' , (int)'O' , -1 , -1 , -1 } ,
/* 19 */ { 1 , (int)'p' , (int)'P' , -1 , -1 , -1 } ,
/* 1a */ { 1 , 0x00e5 , 0x00c5 , 0x001b , -1 , -1 } ,
/* 1b */ { 0 , 0x00a8 , 0x005e , 0x001d , 0x007e , -1 } ,
/* 1c */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 1d */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 1e */ { 1 , (int)'a' , (int)'A' , -1 , -1 , -1 } ,
/* 1f */ { 1 , (int)'s' , (int)'S' , -1 , -1 , -1 } ,
/* 20 */ { 1 , (int)'d' , (int)'D' , -1 , -1 , -1 } ,
/* 21 */ { 1 , (int)'f' , (int)'F' , -1 , -1 , -1 } ,
/* 22 */ { 1 , (int)'g' , (int)'G' , -1 , -1 , -1 } ,
/* 23 */ { 1 , (int)'h' , (int)'H' , -1 , -1 , -1 } ,
/* 24 */ { 1 , (int)'j' , (int)'J' , -1 , -1 , -1 } ,
/* 25 */ { 1 , (int)'k' , (int)'K' , -1 , -1 , -1 } ,
/* 26 */ { 1 , (int)'l' , (int)'L' , -1 , -1 , -1 } ,
/* 27 */ { 1 , 0x00f8 , 0x00d8 , -1 , -1 , -1 } ,
/* 28 */ { 1 , 0x00e6 , 0x00c6 , -1 , -1 , -1 } ,
/* 29 */ { 0 , 0x007c , 0x00a7 , 0x001c , -1 , -1 } ,
/* 2a */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 2b */ { 0 , 0x27 , 0x002a , -1 , -1 , -1 } ,
/* 2c */ { 1 , (int)'z' , (int)'Z' , -1 , -1 , -1 } ,
/* 2d */ { 1 , (int)'x' , (int)'X' , -1 , -1 , -1 } ,
/* 2e */ { 1 , (int)'c' , (int)'C' , -1 , -1 , -1 } ,
/* 2f */ { 1 , (int)'v' , (int)'V' , -1 , -1 , -1 } ,
/* 30 */ { 1 , (int)'b' , (int)'B' , -1 , -1 , -1 } ,
/* 31 */ { 1 , (int)'n' , (int)'N' , -1 , -1 , -1 } ,
/* 32 */ { 1 , (int)'m' , (int)'M' , -1 , 0x00b5 , -1 } ,
/* 33 */ { 0 , 0x002c , 0x003b , -1 , -1 , -1 } ,
/* 34 */ { 0 , 0x002e , 0x003a , -1 , -1 , -1 } ,
/* 35 */ { 0 , 0x002d , 0x005f , -1 , -1 , -1 } ,
/* 36 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 37 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 38 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 39 */ { 0 , 0x20 , 0x20 , 0x20 , -1 , -1 } ,
/* 3a */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 3b */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 3c */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 3d */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 3e */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 3f */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 40 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 41 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 42 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 43 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 44 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 45 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 46 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 47 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 48 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 49 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 4a */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 4b */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 4c */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 4d */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 4e */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 4f */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 50 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 51 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 52 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 53 */ { 0 , 0x002c , 0x002c , -1 , -1 , -1 } ,
/* 54 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 55 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 56 */ { 0 , 0x003c , 0x003e , 0x001c , -1 , -1 } ,
/* 57 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 58 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 59 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 5a */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 5b */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 5c */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 5d */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 5e */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 5f */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
};
public static final int DEADKEYS[] = {
0x0060, 0x00b4, 0x00a8, 0x005e, 0x007e
};
//0x0060 => 0061 00e0 // a -> à
public static final int DEADKEY_LUT[][] = {
{ 0x0060 , 0x0061 , 0x00e0 } ,
{ 0x0060 , 0x0065 , 0x00e8 } ,
{ 0x0060 , 0x0075 , 0x00f9 } ,
{ 0x0060 , 0x0069 , 0x00ec } ,
{ 0x0060 , 0x006f , 0x00f2 } ,
{ 0x0060 , 0x0041 , 0x00c0 } ,
{ 0x0060 , 0x0045 , 0x00c8 } ,
{ 0x0060 , 0x0055 , 0x00d9 } ,
{ 0x0060 , 0x0049 , 0x00cc } ,
{ 0x0060 , 0x004f , 0x00d2 } ,
{ 0x0060 , 0x0020 , 0x0060 } ,
{ 0x00b4 , 0x0061 , 0x00e1 } ,
{ 0x00b4 , 0x0065 , 0x00e9 } ,
{ 0x00b4 , 0x0075 , 0x00fa } ,
{ 0x00b4 , 0x0069 , 0x00ed } ,
{ 0x00b4 , 0x0079 , 0x00fd } ,
{ 0x00b4 , 0x006f , 0x00f3 } ,
{ 0x00b4 , 0x0041 , 0x00c1 } ,
{ 0x00b4 , 0x0045 , 0x00c9 } ,
{ 0x00b4 , 0x0055 , 0x00da } ,
{ 0x00b4 , 0x0049 , 0x00cd } ,
{ 0x00b4 , 0x0059 , 0x00dd } ,
{ 0x00b4 , 0x004f , 0x00d3 } ,
{ 0x00b4 , 0x0020 , 0x00b4 } ,
{ 0x00a8 , 0x0061 , 0x00e4 } ,
{ 0x00a8 , 0x0065 , 0x00eb } ,
{ 0x00a8 , 0x0075 , 0x00fc } ,
{ 0x00a8 , 0x0069 , 0x00ef } ,
{ 0x00a8 , 0x0079 , 0x00ff } ,
{ 0x00a8 , 0x006f , 0x00f6 } ,
{ 0x00a8 , 0x0041 , 0x00c4 } ,
{ 0x00a8 , 0x0045 , 0x00cb } ,
{ 0x00a8 , 0x0055 , 0x00dc } ,
{ 0x00a8 , 0x0049 , 0x00cf } ,
{ 0x00a8 , 0x004f , 0x00d6 } ,
{ 0x00a8 , 0x0020 , 0x00a8 } ,
{ 0x005e , 0x0061 , 0x00e2 } ,
{ 0x005e , 0x0065 , 0x00ea } ,
{ 0x005e , 0x0075 , 0x00fb } ,
{ 0x005e , 0x0069 , 0x00ee } ,
{ 0x005e , 0x006f , 0x00f4 } ,
{ 0x005e , 0x0041 , 0x00c2 } ,
{ 0x005e , 0x0045 , 0x00ca } ,
{ 0x005e , 0x0055 , 0x00db } ,
{ 0x005e , 0x0049 , 0x00ce } ,
{ 0x005e , 0x004f , 0x00d4 } ,
{ 0x005e , 0x0020 , 0x005e } ,
{ 0x007e , 0x006e , 0x00f1 } ,
{ 0x007e , 0x0061 , 0x00e3 } ,
{ 0x007e , 0x006f , 0x00f5 } ,
{ 0x007e , 0x004e , 0x00d1 } ,
{ 0x007e , 0x0041 , 0x00c3 } ,
{ 0x007e , 0x004f , 0x00d5 } ,
{ 0x007e , 0x0020 , 0x007e } ,
};
private static NorwegianLayout instance = new NorwegianLayout();
private NorwegianLayout() {
}
public static NorwegianLayout getInstance() {
return instance;
}
@Override
public int[][] getLUT() {
return LUT;
}
@Override
public int[][] getFastLUT() {
return FAST_LUT;
}
@Override
public void type(String text) {
super.type(FAST_LUT, text, (byte)0);
}
@Override
public void type(String text, byte modifiers) {
super.type(FAST_LUT, text, modifiers);
}
@Override
public char getChar(int scanCode, boolean capsLock, boolean shift, boolean altGr) {
return super.getChar(LUT, scanCode, capsLock, shift, altGr);
}
@Override
public String getLocaleName() {
return LOCALE_NAME;
}
@Override
public int[][] getDeadkeyLUT() {
return DEADKEY_LUT;
}
@Override
public int[] getDeadkeys() {
return DEADKEYS;
}
}

View File

@ -0,0 +1,312 @@
package com.inputstick.api.layout;
public class PolishLayout extends KeyboardLayout {
public static final String LOCALE_NAME = "pl-PL";
//{char (16b unicode), modifier, key, deadkey_modifier, deadkey}
//pl-PL
private static final int[][] FAST_LUT = {
{ 0, 0, 0, 0, 0 }, // empty
{ 27, 1, 47, 0, 0 }, // 
{ 28, 1, 49, 0, 0 }, // 
{ 29, 1, 48, 0, 0 }, // 
{ 32, 0, 44, 0, 0 }, //
{ 33, 2, 30, 0, 0 }, // !
{ 34, 2, 52, 0, 0 }, // "
{ 35, 2, 32, 0, 0 }, // #
{ 36, 2, 33, 0, 0 }, // $
{ 37, 2, 34, 0, 0 }, // %
{ 38, 2, 36, 0, 0 }, // &
{ 39, 0, 52, 0, 0 }, // '
{ 40, 2, 38, 0, 0 }, // (
{ 41, 2, 39, 0, 0 }, // )
{ 42, 2, 37, 0, 0 }, // *
{ 43, 2, 46, 0, 0 }, // +
{ 44, 0, 54, 0, 0 }, // ,
{ 45, 0, 45, 0, 0 }, // -
{ 46, 0, 55, 0, 0 }, // .
{ 47, 0, 56, 0, 0 }, // /
{ 48, 0, 39, 0, 0 }, // 0
{ 49, 0, 30, 0, 0 }, // 1
{ 50, 0, 31, 0, 0 }, // 2
{ 51, 0, 32, 0, 0 }, // 3
{ 52, 0, 33, 0, 0 }, // 4
{ 53, 0, 34, 0, 0 }, // 5
{ 54, 0, 35, 0, 0 }, // 6
{ 55, 0, 36, 0, 0 }, // 7
{ 56, 0, 37, 0, 0 }, // 8
{ 57, 0, 38, 0, 0 }, // 9
{ 58, 2, 51, 0, 0 }, // :
{ 59, 0, 51, 0, 0 }, // ;
{ 60, 2, 54, 0, 0 }, // <
{ 61, 0, 46, 0, 0 }, // =
{ 62, 2, 55, 0, 0 }, // >
{ 63, 2, 56, 0, 0 }, // ?
{ 64, 2, 31, 0, 0 }, // @
{ 65, 2, 4, 0, 0 }, // A
{ 66, 2, 5, 0, 0 }, // B
{ 67, 2, 6, 0, 0 }, // C
{ 68, 2, 7, 0, 0 }, // D
{ 69, 2, 8, 0, 0 }, // E
{ 70, 2, 9, 0, 0 }, // F
{ 71, 2, 10, 0, 0 }, // G
{ 72, 2, 11, 0, 0 }, // H
{ 73, 2, 12, 0, 0 }, // I
{ 74, 2, 13, 0, 0 }, // J
{ 75, 2, 14, 0, 0 }, // K
{ 76, 2, 15, 0, 0 }, // L
{ 77, 2, 16, 0, 0 }, // M
{ 78, 2, 17, 0, 0 }, // N
{ 79, 2, 18, 0, 0 }, // O
{ 80, 2, 19, 0, 0 }, // P
{ 81, 2, 20, 0, 0 }, // Q
{ 82, 2, 21, 0, 0 }, // R
{ 83, 2, 22, 0, 0 }, // S
{ 84, 2, 23, 0, 0 }, // T
{ 85, 2, 24, 0, 0 }, // U
{ 86, 2, 25, 0, 0 }, // V
{ 87, 2, 26, 0, 0 }, // W
{ 88, 2, 27, 0, 0 }, // X
{ 89, 2, 28, 0, 0 }, // Y
{ 90, 2, 29, 0, 0 }, // Z
{ 91, 0, 47, 0, 0 }, // [
{ 92, 0, 49, 0, 0 }, // \
{ 93, 0, 48, 0, 0 }, // ]
{ 94, 2, 35, 0, 0 }, // ^
{ 95, 2, 45, 0, 0 }, // _
{ 96, 0, 53, 0, 0 }, // `
{ 97, 0, 4, 0, 0 }, // a
{ 98, 0, 5, 0, 0 }, // b
{ 99, 0, 6, 0, 0 }, // c
{ 100, 0, 7, 0, 0 }, // d
{ 101, 0, 8, 0, 0 }, // e
{ 102, 0, 9, 0, 0 }, // f
{ 103, 0, 10, 0, 0 }, // g
{ 104, 0, 11, 0, 0 }, // h
{ 105, 0, 12, 0, 0 }, // i
{ 106, 0, 13, 0, 0 }, // j
{ 107, 0, 14, 0, 0 }, // k
{ 108, 0, 15, 0, 0 }, // l
{ 109, 0, 16, 0, 0 }, // m
{ 110, 0, 17, 0, 0 }, // n
{ 111, 0, 18, 0, 0 }, // o
{ 112, 0, 19, 0, 0 }, // p
{ 113, 0, 20, 0, 0 }, // q
{ 114, 0, 21, 0, 0 }, // r
{ 115, 0, 22, 0, 0 }, // s
{ 116, 0, 23, 0, 0 }, // t
{ 117, 0, 24, 0, 0 }, // u
{ 118, 0, 25, 0, 0 }, // v
{ 119, 0, 26, 0, 0 }, // w
{ 120, 0, 27, 0, 0 }, // x
{ 121, 0, 28, 0, 0 }, // y
{ 122, 0, 29, 0, 0 }, // z
{ 123, 2, 47, 0, 0 }, // {
{ 124, 2, 49, 0, 0 }, // |
{ 125, 2, 48, 0, 0 }, // }
{ 126, 0, 44, 2, 53 }, // ~
{ 211, 66, 18, 0, 0 }, // Ó
{ 243, 64, 18, 0, 0 }, // ó
{ 260, 66, 4, 0, 0 }, // ¥
{ 261, 64, 4, 0, 0 }, // ¹
{ 262, 66, 6, 0, 0 }, // Æ
{ 263, 64, 6, 0, 0 }, // æ
{ 280, 66, 8, 0, 0 }, // Ê
{ 281, 64, 8, 0, 0 }, // ê
{ 321, 66, 15, 0, 0 }, // £
{ 322, 64, 15, 0, 0 }, // ³
{ 323, 66, 17, 0, 0 }, // Ñ
{ 324, 64, 17, 0, 0 }, // ñ
{ 346, 66, 22, 0, 0 }, // Œ
{ 347, 64, 22, 0, 0 }, // œ
{ 377, 66, 27, 0, 0 }, // <EFBFBD>
{ 378, 64, 27, 0, 0 }, // Ÿ
{ 379, 66, 29, 0, 0 }, // ¯
{ 380, 64, 29, 0, 0 }, // ¿
{ 8364, 64, 24, 0, 0 }, //
};
public static final int LUT[][] = {
/* 0 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 1 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 2 */ { 0 , (int)'1' , 0x21 , -1 , -1 , -1 } ,
/* 3 */ { 0 , (int)'2' , 0x40 , -1 , -1 , -1 } ,
/* 4 */ { 0 , (int)'3' , 0x23 , -1 , -1 , -1 } ,
/* 5 */ { 0 , (int)'4' , 0x24 , -1 , -1 , -1 } ,
/* 6 */ { 0 , (int)'5' , 0x25 , -1 , -1 , -1 } ,
/* 7 */ { 0 , (int)'6' , 0x005e , -1 , -1 , -1 } ,
/* 8 */ { 0 , (int)'7' , 0x26 , -1 , -1 , -1 } ,
/* 9 */ { 0 , (int)'8' , 0x002a , -1 , -1 , -1 } ,
/* 0a */ { 0 , (int)'9' , 0x28 , -1 , -1 , -1 } ,
/* 0b */ { 0 , (int)'0' , 0x29 , -1 , -1 , -1 } ,
/* 0c */ { 0 , 0x002d , 0x005f , -1 , -1 , -1 } ,
/* 0d */ { 0 , 0x003d , 0x002b , -1 , -1 , -1 } ,
/* 0e */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 0f */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 10 */ { 1 , (int)'q' , (int)'Q' , -1 , -1 , -1 } ,
/* 11 */ { 1 , (int)'w' , (int)'W' , -1 , -1 , -1 } ,
/* 12 */ { 5 , (int)'e' , (int)'E' , -1 , 0x119 , 0x118 } ,
/* 13 */ { 1 , (int)'r' , (int)'R' , -1 , -1 , -1 } ,
/* 14 */ { 1 , (int)'t' , (int)'T' , -1 , -1 , -1 } ,
/* 15 */ { 1 , (int)'y' , (int)'Y' , -1 , -1 , -1 } ,
/* 16 */ { 1 , (int)'u' , (int)'U' , -1 , 0x20ac , -1 } ,
/* 17 */ { 1 , (int)'i' , (int)'I' , -1 , -1 , -1 } ,
/* 18 */ { 5 , (int)'o' , (int)'O' , -1 , 0x00f3 , 0x00d3 } ,
/* 19 */ { 1 , (int)'p' , (int)'P' , -1 , -1 , -1 } ,
/* 1a */ { 0 , 0x005b , 0x007b , 0x001b , -1 , -1 } ,
/* 1b */ { 0 , 0x005d , 0x007d , 0x001d , -1 , -1 } ,
/* 1c */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 1d */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 1e */ { 5 , (int)'a' , (int)'A' , -1 , 0x105 , 0x104 } ,
/* 1f */ { 5 , (int)'s' , (int)'S' , -1 , 0x015b , 0x015a } ,
/* 20 */ { 1 , (int)'d' , (int)'D' , -1 , -1 , -1 } ,
/* 21 */ { 1 , (int)'f' , (int)'F' , -1 , -1 , -1 } ,
/* 22 */ { 1 , (int)'g' , (int)'G' , -1 , -1 , -1 } ,
/* 23 */ { 1 , (int)'h' , (int)'H' , -1 , -1 , -1 } ,
/* 24 */ { 1 , (int)'j' , (int)'J' , -1 , -1 , -1 } ,
/* 25 */ { 1 , (int)'k' , (int)'K' , -1 , -1 , -1 } ,
/* 26 */ { 5 , (int)'l' , (int)'L' , -1 , 0x142 , 0x141 } ,
/* 27 */ { 0 , 0x003b , 0x003a , 0x001d , -1 , -1 } ,
/* 28 */ { 0 , 0x27 , 0x22 , -1 , -1 , -1 } ,
/* 29 */ { 0 , 0x60 , 0x007e , -1 , -1 , -1 } , //@
/* 2a */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 2b */ { 0 , 0x005c , 0x007c , 0x001c , -1 , -1 } ,
/* 2c */ { 5 , (int)'z' , (int)'Z' , -1 , 0x017c , 0x017b } ,
/* 2d */ { 5 , (int)'x' , (int)'X' , -1 , 0x017a , 0x179 } ,
/* 2e */ { 5 , (int)'c' , (int)'C' , -1 , 0x107 , 0x106 } ,
/* 2f */ { 1 , (int)'v' , (int)'V' , -1 , -1 , -1 } ,
/* 30 */ { 1 , (int)'b' , (int)'B' , -1 , -1 , -1 } ,
/* 31 */ { 5 , (int)'n' , (int)'N' , -1 , 0x144 , 0x143 } ,
/* 32 */ { 1 , (int)'m' , (int)'M' , -1 , -1 , -1 } ,
/* 33 */ { 0 , 0x002c , 0x003c , -1 , -1 , -1 } ,
/* 34 */ { 0 , 0x002e , 0x003e , -1 , -1 , -1 } ,
/* 35 */ { 0 , 0x002f , 0x003f , -1 , -1 , -1 } ,
/* 36 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 37 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 38 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 39 */ { 0 , 0x20 , 0x20 , 0x20 , -1 , -1 } ,
/* 3a */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 3b */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 3c */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 3d */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 3e */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 3f */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 40 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 41 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 42 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 43 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 44 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 45 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 46 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 47 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 48 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 49 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 4a */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 4b */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 4c */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 4d */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 4e */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 4f */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 50 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 51 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 52 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 53 */ { 0 , 0x002c , 0x002c , -1 , -1 , -1 } ,
/* 54 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 55 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 56 */ { 0 , 0x005c , 0x007c , 0x001c , -1 , -1 } ,
/* 57 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 58 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 59 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 5a */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 5b */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 5c */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 5d */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 5e */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 5f */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
};
public static final int DEADKEYS[] = {
0x007e
};
public static final int DEADKEY_LUT[][] = {
{ 0x007e , 0x006e , 0x0144 } ,
{ 0x007e , 0x0063 , 0x0107 } ,
{ 0x007e , 0x0078 , 0x017a } ,
{ 0x007e , 0x007a , 0x017c } ,
{ 0x007e , 0x0061 , 0x0105 } ,
{ 0x007e , 0x0073 , 0x015b } ,
{ 0x007e , 0x006c , 0x0142 } ,
{ 0x007e , 0x0065 , 0x0119 } ,
{ 0x007e , 0x006f , 0x00f3 } ,
{ 0x007e , 0x004e , 0x0143 } ,
{ 0x007e , 0x0043 , 0x0106 } ,
{ 0x007e , 0x0058 , 0x0179 } ,
{ 0x007e , 0x005a , 0x017b } ,
{ 0x007e , 0x0041 , 0x0104 } ,
{ 0x007e , 0x0053 , 0x015a } ,
{ 0x007e , 0x004c , 0x0141 } ,
{ 0x007e , 0x0045 , 0x0118 } ,
{ 0x007e , 0x004f , 0x00d3 } ,
{ 0x007e , 0x0020 , 0x007e } ,
};
private static PolishLayout instance = new PolishLayout();
private PolishLayout() {
}
public static PolishLayout getInstance() {
return instance;
}
@Override
public int[][] getLUT() {
return LUT;
}
@Override
public int[][] getFastLUT() {
return FAST_LUT;
}
@Override
public void type(String text) {
super.type(FAST_LUT, text, (byte)0);
}
@Override
public void type(String text, byte modifiers) {
super.type(FAST_LUT, text, modifiers);
}
@Override
public char getChar(int scanCode, boolean capsLock, boolean shift, boolean altGr) {
return super.getChar(LUT, scanCode, capsLock, shift, altGr);
}
@Override
public String getLocaleName() {
return LOCALE_NAME;
}
@Override
public int[][] getDeadkeyLUT() {
return DEADKEY_LUT;
}
@Override
public int[] getDeadkeys() {
return DEADKEYS;
}
}

View File

@ -0,0 +1,399 @@
package com.inputstick.api.layout;
public class PortugueseBrazilianLayout extends KeyboardLayout {
public static final String LOCALE_NAME = "pt-BR";
//{char (16b unicode), modifier, key, deadkey_modifier, deadkey}
//pt-BR
private static final int[][] FAST_LUT = {
{ 0, 0, 0, 0, 0 }, // empty
{ 27, 1, 48, 0, 0 }, // 
{ 28, 1, 49, 0, 0 }, // 
{ 29, 1, 51, 0, 0 }, // 
{ 32, 0, 44, 0, 0 }, //
{ 33, 2, 30, 0, 0 }, // !
{ 34, 2, 53, 0, 0 }, // "
{ 35, 2, 32, 0, 0 }, // #
{ 36, 2, 33, 0, 0 }, // $
{ 37, 2, 34, 0, 0 }, // %
{ 38, 2, 36, 0, 0 }, // &
{ 39, 0, 53, 0, 0 }, // '
{ 40, 2, 38, 0, 0 }, // (
{ 41, 2, 39, 0, 0 }, // )
{ 42, 2, 37, 0, 0 }, // *
{ 43, 2, 46, 0, 0 }, // +
{ 44, 0, 54, 0, 0 }, // ,
{ 45, 0, 45, 0, 0 }, // -
{ 46, 0, 55, 0, 0 }, // .
{ 47, 64, 20, 0, 0 }, // /
{ 48, 0, 39, 0, 0 }, // 0
{ 49, 0, 30, 0, 0 }, // 1
{ 50, 0, 31, 0, 0 }, // 2
{ 51, 0, 32, 0, 0 }, // 3
{ 52, 0, 33, 0, 0 }, // 4
{ 53, 0, 34, 0, 0 }, // 5
{ 54, 0, 35, 0, 0 }, // 6
{ 55, 0, 36, 0, 0 }, // 7
{ 56, 0, 37, 0, 0 }, // 8
{ 57, 0, 38, 0, 0 }, // 9
{ 58, 2, 56, 0, 0 }, // :
{ 59, 0, 56, 0, 0 }, // ;
{ 60, 2, 54, 0, 0 }, // <
{ 61, 0, 46, 0, 0 }, // =
{ 62, 2, 55, 0, 0 }, // >
{ 63, 64, 26, 0, 0 }, // ?
{ 64, 2, 31, 0, 0 }, // @
{ 65, 2, 4, 0, 0 }, // A
{ 66, 2, 5, 0, 0 }, // B
{ 67, 2, 6, 0, 0 }, // C
{ 68, 2, 7, 0, 0 }, // D
{ 69, 2, 8, 0, 0 }, // E
{ 70, 2, 9, 0, 0 }, // F
{ 71, 2, 10, 0, 0 }, // G
{ 72, 2, 11, 0, 0 }, // H
{ 73, 2, 12, 0, 0 }, // I
{ 74, 2, 13, 0, 0 }, // J
{ 75, 2, 14, 0, 0 }, // K
{ 76, 2, 15, 0, 0 }, // L
{ 77, 2, 16, 0, 0 }, // M
{ 78, 2, 17, 0, 0 }, // N
{ 79, 2, 18, 0, 0 }, // O
{ 80, 2, 19, 0, 0 }, // P
{ 81, 2, 20, 0, 0 }, // Q
{ 82, 2, 21, 0, 0 }, // R
{ 83, 2, 22, 0, 0 }, // S
{ 84, 2, 23, 0, 0 }, // T
{ 85, 2, 24, 0, 0 }, // U
{ 86, 2, 25, 0, 0 }, // V
{ 87, 2, 26, 0, 0 }, // W
{ 88, 2, 27, 0, 0 }, // X
{ 89, 2, 28, 0, 0 }, // Y
{ 90, 2, 29, 0, 0 }, // Z
{ 91, 0, 48, 0, 0 }, // [
{ 92, 0, 100, 0, 0 }, // \
{ 93, 0, 49, 0, 0 }, // ]
{ 94, 0, 44, 2, 52 }, // ^
{ 95, 2, 45, 0, 0 }, // _
{ 96, 0, 44, 2, 47 }, // `
{ 97, 0, 4, 0, 0 }, // a
{ 98, 0, 5, 0, 0 }, // b
{ 99, 0, 6, 0, 0 }, // c
{ 100, 0, 7, 0, 0 }, // d
{ 101, 0, 8, 0, 0 }, // e
{ 102, 0, 9, 0, 0 }, // f
{ 103, 0, 10, 0, 0 }, // g
{ 104, 0, 11, 0, 0 }, // h
{ 105, 0, 12, 0, 0 }, // i
{ 106, 0, 13, 0, 0 }, // j
{ 107, 0, 14, 0, 0 }, // k
{ 108, 0, 15, 0, 0 }, // l
{ 109, 0, 16, 0, 0 }, // m
{ 110, 0, 17, 0, 0 }, // n
{ 111, 0, 18, 0, 0 }, // o
{ 112, 0, 19, 0, 0 }, // p
{ 113, 0, 20, 0, 0 }, // q
{ 114, 0, 21, 0, 0 }, // r
{ 115, 0, 22, 0, 0 }, // s
{ 116, 0, 23, 0, 0 }, // t
{ 117, 0, 24, 0, 0 }, // u
{ 118, 0, 25, 0, 0 }, // v
{ 119, 0, 26, 0, 0 }, // w
{ 120, 0, 27, 0, 0 }, // x
{ 121, 0, 28, 0, 0 }, // y
{ 122, 0, 29, 0, 0 }, // z
{ 123, 2, 48, 0, 0 }, // {
{ 124, 2, 100, 0, 0 }, // |
{ 125, 2, 49, 0, 0 }, // }
{ 126, 0, 44, 0, 52 }, // ~
{ 162, 64, 34, 0, 0 }, // ?
{ 163, 64, 33, 0, 0 }, // ?
{ 167, 64, 46, 0, 0 }, // §
{ 168, 0, 44, 2, 35 }, // ¨
{ 170, 64, 48, 0, 0 }, // ?
{ 172, 64, 35, 0, 0 }, // ¬
{ 176, 64, 8, 0, 0 }, // °
{ 178, 64, 31, 0, 0 }, // ?
{ 179, 64, 32, 0, 0 }, // ?
{ 180, 0, 44, 0, 47 }, // ´
{ 185, 64, 30, 0, 0 }, // ?
{ 186, 64, 49, 0, 0 }, // ?
{ 192, 2, 4, 2, 47 }, // ?
{ 193, 2, 4, 0, 47 }, // Á
{ 194, 2, 4, 2, 52 }, // Â
{ 195, 2, 4, 0, 52 }, // ?
{ 196, 2, 4, 2, 35 }, // Ä
{ 199, 2, 51, 0, 0 }, // Ç
{ 200, 2, 8, 2, 47 }, // ?
{ 201, 2, 8, 0, 47 }, // É
{ 202, 2, 8, 2, 52 }, // ?
{ 203, 2, 8, 2, 35 }, // Ë
{ 204, 2, 12, 2, 47 }, // ?
{ 205, 2, 12, 0, 47 }, // Í
{ 206, 2, 12, 2, 52 }, // Î
{ 207, 2, 12, 2, 35 }, // ?
{ 209, 2, 17, 0, 52 }, // ?
{ 210, 2, 18, 2, 47 }, // ?
{ 211, 2, 18, 0, 47 }, // Ó
{ 212, 2, 18, 2, 52 }, // Ô
{ 213, 2, 18, 0, 52 }, // ?
{ 214, 2, 18, 2, 35 }, // Ö
{ 217, 2, 24, 2, 47 }, // ?
{ 218, 2, 24, 0, 47 }, // Ú
{ 219, 2, 24, 2, 52 }, // ?
{ 220, 2, 24, 2, 35 }, // Ü
{ 221, 2, 28, 0, 47 }, // Ý
{ 224, 0, 4, 2, 47 }, // ?
{ 225, 0, 4, 0, 47 }, // á
{ 226, 0, 4, 2, 52 }, // â
{ 227, 0, 4, 0, 52 }, // ?
{ 228, 0, 4, 2, 35 }, // ä
{ 231, 0, 51, 0, 0 }, // ç
{ 232, 0, 8, 2, 47 }, // ?
{ 233, 0, 8, 0, 47 }, // é
{ 234, 0, 8, 2, 52 }, // ?
{ 235, 0, 8, 2, 35 }, // ë
{ 236, 0, 12, 2, 47 }, // ?
{ 237, 0, 12, 0, 47 }, // í
{ 238, 0, 12, 2, 52 }, // î
{ 239, 0, 12, 2, 35 }, // ?
{ 241, 0, 17, 0, 52 }, // ?
{ 242, 0, 18, 2, 47 }, // ?
{ 243, 0, 18, 0, 47 }, // ó
{ 244, 0, 18, 2, 52 }, // ô
{ 245, 0, 18, 0, 52 }, // ?
{ 246, 0, 18, 2, 35 }, // ö
{ 249, 0, 24, 2, 47 }, // ?
{ 250, 0, 24, 0, 47 }, // ú
{ 251, 0, 24, 2, 52 }, // ?
{ 252, 0, 24, 2, 35 }, // ü
{ 253, 0, 28, 0, 47 }, // ý
{ 255, 0, 28, 2, 35 }, // ?
{ 8354, 64, 6, 0, 0 }, // ?
};
public static final int LUT[][] = {
/* 0 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 1 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 2 */ { 0 , (int)'1' , 0x21 , -1 , 0x00b9 , -1 } ,
/* 3 */ { 0 , (int)'2' , 0x40 , -1 , 0x00b2 , -1 } ,
/* 4 */ { 0 , (int)'3' , 0x23 , -1 , 0x00b3 , -1 } ,
/* 5 */ { 0 , (int)'4' , 0x24 , -1 , 0x00a3 , -1 } ,
/* 6 */ { 0 , (int)'5' , 0x25 , -1 , 0x00a2 , -1 } ,
/* 7 */ { 0 , (int)'6' , 0x00a8 , -1 , 0x00ac , -1 } ,
/* 8 */ { 0 , (int)'7' , 0x26 , -1 , -1 , -1 } ,
/* 9 */ { 0 , (int)'8' , 0x002a , -1 , -1 , -1 } ,
/* 0a */ { 0 , (int)'9' , 0x28 , -1 , -1 , -1 } ,
/* 0b */ { 0 , (int)'0' , 0x29 , -1 , -1 , -1 } ,
/* 0c */ { 0 , 0x002d , 0x005f , -1 , -1 , -1 } ,
/* 0d */ { 0 , 0x003d , 0x002b , -1 , 0x00a7 , -1 } ,
/* 0e */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 1f */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 10 */ { 1 , (int)'q' , (int)'Q' , -1 , 0x002f , -1 } ,
/* 11 */ { 1 , (int)'w' , (int)'W' , -1 , 0x003f , -1 } ,
/* 12 */ { 1 , (int)'e' , (int)'E' , -1 , 0x00b0 , -1 } ,
/* 13 */ { 1 , (int)'r' , (int)'R' , -1 , -1 , -1 } ,
/* 14 */ { 1 , (int)'t' , (int)'T' , -1 , -1 , -1 } ,
/* 15 */ { 1 , (int)'y' , (int)'Y' , -1 , -1 , -1 } ,
/* 16 */ { 1 , (int)'u' , (int)'U' , -1 , -1 , -1 } ,
/* 17 */ { 1 , (int)'i' , (int)'I' , -1 , -1 , -1 } ,
/* 18 */ { 1 , (int)'o' , (int)'O' , -1 , -1 , -1 } ,
/* 19 */ { 1 , (int)'p' , (int)'P' , -1 , -1 , -1 } ,
/* 1a */ { 0 , 0x00b4 , 0x0060 , -1 , -1 , -1 } ,
/* 1b */ { 0 , 0x005b , 0x007b , 0x001b , 0x00aa , -1 } ,
/* 1c */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 1d */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 1e */ { 1 , (int)'a' , (int)'A' , -1 , -1 , -1 } ,
/* 1f */ { 1 , (int)'s' , (int)'S' , -1 , -1 , -1 } ,
/* 20 */ { 1 , (int)'d' , (int)'D' , -1 , -1 , -1 } ,
/* 21 */ { 1 , (int)'f' , (int)'F' , -1 , -1 , -1 } ,
/* 22 */ { 1 , (int)'g' , (int)'G' , -1 , -1 , -1 } ,
/* 23 */ { 1 , (int)'h' , (int)'H' , -1 , -1 , -1 } ,
/* 24 */ { 1 , (int)'j' , (int)'J' , -1 , -1 , -1 } ,
/* 25 */ { 1 , (int)'k' , (int)'K' , -1 , -1 , -1 } ,
/* 26 */ { 1 , (int)'l' , (int)'L' , -1 , -1 , -1 } ,
/* 27 */ { 1 , 0x00e7 , 0x00c7 , 0x001d , -1 , -1 } ,
/* 28 */ { 0 , 0x007e , 0x005e , -1 , -1 , -1 } ,
/* 29 */ { 0 , 0x27 , 0x22 , -1 , -1 , -1 } ,
/* 2a */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 2b */ { 0 , 0x005d , 0x007d , 0x001c , 0x00ba , -1 } ,
/* 2c */ { 1 , (int)'z' , (int)'Z' , -1 , -1 , -1 } ,
/* 2d */ { 1 , (int)'x' , (int)'X' , -1 , -1 , -1 } ,
/* 2e */ { 1 , (int)'c' , (int)'C' , -1 , 0x20a2 , -1 } ,
/* 2f */ { 1 , (int)'v' , (int)'V' , -1 , -1 , -1 } ,
/* 30 */ { 1 , (int)'b' , (int)'B' , -1 , -1 , -1 } ,
/* 31 */ { 1 , (int)'n' , (int)'N' , -1 , -1 , -1 } ,
/* 32 */ { 1 , (int)'m' , (int)'M' , -1 , -1 , -1 } ,
/* 33 */ { 0 , 0x002c , 0x003c , -1 , -1 , -1 } ,
/* 34 */ { 0 , 0x002e , 0x003e , -1 , -1 , -1 } ,
/* 35 */ { 0 , 0x003b , 0x003a , -1 , -1 , -1 } ,
/* 36 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 37 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 38 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 39 */ { 0 , 0x20 , 0x20 , 0x20 , -1 , -1 } ,
/* 3a */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 3b */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 3c */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 3d */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 3e */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 3f */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 40 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 41 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 42 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 43 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 44 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 45 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 46 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 47 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 48 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 49 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 4a */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 4b */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 4c */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 4d */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 4e */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 4f */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 50 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 51 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 52 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 53 */ { 0 , 0x002c , 0x002c , -1 , -1 , -1 } ,
/* 54 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 55 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 56 */ { 0 , 0x005c , 0x007c , 0x001c , -1 , -1 } ,
/* 57 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 58 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 59 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 5a */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 5b */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 5c */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 5d */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 5e */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 5f */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 73 */ /*{ 0 , 002f , 003f , -1 , 00b0 , -1 } ,*/
/* 7e */ /*{ 0 , 002e , 002e , -1 , -1 , -1 } ,*/
};
public static final int DEADKEYS[] = {
0x00a8, 0x00b4, 0x0060, 0x007e, 0x005e
};
public static final int DEADKEY_LUT[][] = {
{ 0x00a8 , 0x0061 , 0x00e4 } ,
{ 0x00a8 , 0x0065 , 0x00eb } ,
{ 0x00a8 , 0x0075 , 0x00fc } ,
{ 0x00a8 , 0x0069 , 0x00ef } ,
{ 0x00a8 , 0x0079 , 0x00ff } ,
{ 0x00a8 , 0x006f , 0x00f6 } ,
{ 0x00a8 , 0x0041 , 0x00c4 } ,
{ 0x00a8 , 0x0045 , 0x00cb } ,
{ 0x00a8 , 0x0055 , 0x00dc } ,
{ 0x00a8 , 0x0049 , 0x00cf } ,
{ 0x00a8 , 0x004f , 0x00d6 } ,
{ 0x00a8 , 0x0020 , 0x00a8 } ,
{ 0x00b4 , 0x0061 , 0x00e1 } ,
{ 0x00b4 , 0x0065 , 0x00e9 } ,
{ 0x00b4 , 0x0075 , 0x00fa } ,
{ 0x00b4 , 0x0069 , 0x00ed } ,
{ 0x00b4 , 0x0079 , 0x00fd } ,
{ 0x00b4 , 0x006f , 0x00f3 } ,
{ 0x00b4 , 0x0041 , 0x00c1 } ,
{ 0x00b4 , 0x0045 , 0x00c9 } ,
{ 0x00b4 , 0x0055 , 0x00da } ,
{ 0x00b4 , 0x0049 , 0x00cd } ,
{ 0x00b4 , 0x0059 , 0x00dd } ,
{ 0x00b4 , 0x004f , 0x00d3 } ,
{ 0x00b4 , 0x0020 , 0x00b4 } ,
{ 0x0060 , 0x0061 , 0x00e0 } ,
{ 0x0060 , 0x0065 , 0x00e8 } ,
{ 0x0060 , 0x0075 , 0x00f9 } ,
{ 0x0060 , 0x0069 , 0x00ec } ,
{ 0x0060 , 0x006f , 0x00f2 } ,
{ 0x0060 , 0x0041 , 0x00c0 } ,
{ 0x0060 , 0x0045 , 0x00c8 } ,
{ 0x0060 , 0x0055 , 0x00d9 } ,
{ 0x0060 , 0x0049 , 0x00cc } ,
{ 0x0060 , 0x004f , 0x00d2 } ,
{ 0x0060 , 0x0020 , 0x0060 } ,
{ 0x007e , 0x006e , 0x00f1 } ,
{ 0x007e , 0x0061 , 0x00e3 } ,
{ 0x007e , 0x006f , 0x00f5 } ,
{ 0x007e , 0x004e , 0x00d1 } ,
{ 0x007e , 0x0041 , 0x00c3 } ,
{ 0x007e , 0x004f , 0x00d5 } ,
{ 0x007e , 0x0020 , 0x007e } ,
{ 0x005e , 0x0061 , 0x00e2 } ,
{ 0x005e , 0x0065 , 0x00ea } ,
{ 0x005e , 0x0075 , 0x00fb } ,
{ 0x005e , 0x0069 , 0x00ee } ,
{ 0x005e , 0x006f , 0x00f4 } ,
{ 0x005e , 0x0041 , 0x00c2 } ,
{ 0x005e , 0x0045 , 0x00ca } ,
{ 0x005e , 0x0055 , 0x00db } ,
{ 0x005e , 0x0049 , 0x00ce } ,
{ 0x005e , 0x004f , 0x00d4 } ,
{ 0x005e , 0x0020 , 0x005e } ,
};
private static PortugueseBrazilianLayout instance = new PortugueseBrazilianLayout();
private PortugueseBrazilianLayout() {
}
public static PortugueseBrazilianLayout getInstance() {
return instance;
}
@Override
public int[][] getLUT() {
return LUT;
}
@Override
public int[][] getFastLUT() {
return FAST_LUT;
}
@Override
public void type(String text) {
super.type(FAST_LUT, text, (byte)0);
}
@Override
public void type(String text, byte modifiers) {
super.type(FAST_LUT, text, modifiers);
}
@Override
public char getChar(int scanCode, boolean capsLock, boolean shift, boolean altGr) {
return super.getChar(LUT, scanCode, capsLock, shift, altGr);
}
@Override
public String getLocaleName() {
return LOCALE_NAME;
}
@Override
public int[][] getDeadkeyLUT() {
return DEADKEY_LUT;
}
@Override
public int[] getDeadkeys() {
return DEADKEYS;
}
}

View File

@ -0,0 +1,269 @@
package com.inputstick.api.layout;
public class RussianLayout extends KeyboardLayout {
public static final String LOCALE_NAME = "ru-RU";
//{char (16b unicode), modifier, key, deadkey_modifier, deadkey}
//ru-RU
private static final int[][] FAST_LUT = {
{ 0, 0, 0, 0, 0 }, // empty
{ 28, 1, 49, 0, 0 }, // 
{ 32, 0, 44, 0, 0 }, //
{ 33, 2, 30, 0, 0 }, // !
{ 34, 2, 31, 0, 0 }, // "
{ 37, 2, 34, 0, 0 }, // %
{ 40, 2, 38, 0, 0 }, // (
{ 41, 2, 39, 0, 0 }, // )
{ 42, 2, 37, 0, 0 }, // *
{ 43, 2, 46, 0, 0 }, // +
{ 44, 2, 56, 0, 0 }, // ,
{ 45, 0, 45, 0, 0 }, // -
{ 46, 0, 56, 0, 0 }, // .
{ 47, 2, 49, 0, 0 }, // /
{ 48, 0, 39, 0, 0 }, // 0
{ 49, 0, 30, 0, 0 }, // 1
{ 50, 0, 31, 0, 0 }, // 2
{ 51, 0, 32, 0, 0 }, // 3
{ 52, 0, 33, 0, 0 }, // 4
{ 53, 0, 34, 0, 0 }, // 5
{ 54, 0, 35, 0, 0 }, // 6
{ 55, 0, 36, 0, 0 }, // 7
{ 56, 0, 37, 0, 0 }, // 8
{ 57, 0, 38, 0, 0 }, // 9
{ 58, 2, 35, 0, 0 }, // :
{ 59, 2, 33, 0, 0 }, // ;
{ 61, 0, 46, 0, 0 }, // =
{ 63, 2, 36, 0, 0 }, // ?
{ 92, 0, 49, 0, 0 }, // \
{ 95, 2, 45, 0, 0 }, // _
{ 1025, 2, 53, 0, 0 }, // ?
{ 1040, 2, 9, 0, 0 }, // ?
{ 1041, 2, 54, 0, 0 }, // ?
{ 1042, 2, 7, 0, 0 }, // ?
{ 1043, 2, 24, 0, 0 }, // ?
{ 1044, 2, 15, 0, 0 }, // ?
{ 1045, 2, 23, 0, 0 }, // ?
{ 1046, 2, 51, 0, 0 }, // ?
{ 1047, 2, 19, 0, 0 }, // ?
{ 1048, 2, 5, 0, 0 }, // ?
{ 1049, 2, 20, 0, 0 }, // ?
{ 1050, 2, 21, 0, 0 }, // ?
{ 1051, 2, 14, 0, 0 }, // ?
{ 1052, 2, 25, 0, 0 }, // ?
{ 1053, 2, 28, 0, 0 }, // ?
{ 1054, 2, 13, 0, 0 }, // ?
{ 1055, 2, 10, 0, 0 }, // ?
{ 1056, 2, 11, 0, 0 }, // ?
{ 1057, 2, 6, 0, 0 }, // ?
{ 1058, 2, 17, 0, 0 }, // ?
{ 1059, 2, 8, 0, 0 }, // ?
{ 1060, 2, 4, 0, 0 }, // ?
{ 1061, 2, 47, 0, 0 }, // ?
{ 1062, 2, 26, 0, 0 }, // ?
{ 1063, 2, 27, 0, 0 }, // ?
{ 1064, 2, 12, 0, 0 }, // ?
{ 1065, 2, 18, 0, 0 }, // ?
{ 1066, 2, 48, 0, 0 }, // ?
{ 1067, 2, 22, 0, 0 }, // ?
{ 1068, 2, 16, 0, 0 }, // ?
{ 1069, 2, 52, 0, 0 }, // ?
{ 1070, 2, 55, 0, 0 }, // ?
{ 1071, 2, 29, 0, 0 }, // ?
{ 1072, 0, 9, 0, 0 }, // ?
{ 1073, 0, 54, 0, 0 }, // ?
{ 1074, 0, 7, 0, 0 }, // ?
{ 1075, 0, 24, 0, 0 }, // ?
{ 1076, 0, 15, 0, 0 }, // ?
{ 1077, 0, 23, 0, 0 }, // ?
{ 1078, 0, 51, 0, 0 }, // ?
{ 1079, 0, 19, 0, 0 }, // ?
{ 1080, 0, 5, 0, 0 }, // ?
{ 1081, 0, 20, 0, 0 }, // ?
{ 1082, 0, 21, 0, 0 }, // ?
{ 1083, 0, 14, 0, 0 }, // ?
{ 1084, 0, 25, 0, 0 }, // ?
{ 1085, 0, 28, 0, 0 }, // ?
{ 1086, 0, 13, 0, 0 }, // ?
{ 1087, 0, 10, 0, 0 }, // ?
{ 1088, 0, 11, 0, 0 }, // ?
{ 1089, 0, 6, 0, 0 }, // ?
{ 1090, 0, 17, 0, 0 }, // ?
{ 1091, 0, 8, 0, 0 }, // ?
{ 1092, 0, 4, 0, 0 }, // ?
{ 1093, 0, 47, 0, 0 }, // ?
{ 1094, 0, 26, 0, 0 }, // ?
{ 1095, 0, 27, 0, 0 }, // ?
{ 1096, 0, 12, 0, 0 }, // ?
{ 1097, 0, 18, 0, 0 }, // ?
{ 1098, 0, 48, 0, 0 }, // ?
{ 1099, 0, 22, 0, 0 }, // ?
{ 1100, 0, 16, 0, 0 }, // ?
{ 1101, 0, 52, 0, 0 }, // ?
{ 1102, 0, 55, 0, 0 }, // ?
{ 1103, 0, 29, 0, 0 }, // ?
{ 1105, 0, 53, 0, 0 }, // ?
{ 8470, 2, 32, 0, 0 }, // ?
};
public static final int LUT[][] = {
/* 0 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 1 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 2 */ { 0 , (int)'1' , 0x21 , -1 , -1 , -1 } ,
/* 3 */ { 0 , (int)'2' , 0x22 , -1 , -1 , -1 } ,
/* 4 */ { 0 , (int)'3' , 0x2116 , -1 , -1 , -1 } ,
/* 5 */ { 0 , (int)'4' , 0x003b , -1 , -1 , -1 } ,
/* 6 */ { 0 , (int)'5' , 0x25 , -1 , -1 , -1 } ,
/* 7 */ { 0 , (int)'6' , 0x003a , -1 , -1 , -1 } ,
/* 8 */ { 0 , (int)'7' , 0x003f , -1 , -1 , -1 } ,
/* 9 */ { 0 , (int)'8' , 0x002a , -1 , -1 , -1 } ,
/* 0a */ { 0 , (int)'9' , 0x28 , -1 , -1 , -1 } ,
/* 0b */ { 0 , (int)'0' , 0x29 , -1 , -1 , -1 } ,
/* 0c */ { 0 , 0x002d , 0x005f , -1 , -1 , -1 } ,
/* 0d */ { 0 , 0x003d , 0x002b , -1 , -1 , -1 } ,
/* 0e */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 0f */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 10 */ { 1 , 0x439 , 0x419 , -1 , -1 , -1 } ,
/* 11 */ { 1 , 0x446 , 0x426 , -1 , -1 , -1 } ,
/* 12 */ { 1 , 0x443 , 0x423 , -1 , -1 , -1 } ,
/* 13 */ { 1 , 0x043a , 0x041a , -1 , -1 , -1 } ,
/* 14 */ { 1 , 0x435 , 0x415 , -1 , -1 , -1 } ,
/* 15 */ { 1 , 0x043d , 0x041d , -1 , -1 , -1 } ,
/* 16 */ { 1 , 0x433 , 0x413 , -1 , -1 , -1 } ,
/* 17 */ { 1 , 0x448 , 0x428 , -1 , -1 , -1 } ,
/* 18 */ { 1 , 0x449 , 0x429 , -1 , -1 , -1 } ,
/* 19 */ { 1 , 0x437 , 0x417 , -1 , -1 , -1 } ,
/* 1a */ { 1 , 0x445 , 0x425 , -1 , -1 , -1 } ,
/* 1b */ { 1 , 0x044a , 0x042a , -1 , -1 , -1 } ,
/* 1c */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 1d */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 1e */ { 1 , 0x444 , 0x424 , -1 , -1 , -1 } ,
/* 1f */ { 1 , 0x044b , 0x042b , -1 , -1 , -1 } ,
/* 20 */ { 1 , 0x432 , 0x412 , -1 , -1 , -1 } ,
/* 21 */ { 1 , 0x430 , 0x410 , -1 , -1 , -1 } ,
/* 22 */ { 1 , 0x043f , 0x041f , -1 , -1 , -1 } ,
/* 23 */ { 1 , 0x440 , 0x420 , -1 , -1 , -1 } ,
/* 24 */ { 1 , 0x043e , 0x041e , -1 , -1 , -1 } ,
/* 25 */ { 1 , 0x043b , 0x041b , -1 , -1 , -1 } ,
/* 26 */ { 1 , 0x434 , 0x414 , -1 , -1 , -1 } ,
/* 27 */ { 1 , 0x436 , 0x416 , -1 , -1 , -1 } ,
/* 28 */ { 1 , 0x044d , 0x042d , -1 , -1 , -1 } ,
/* 29 */ { 1 , 0x451 , 0x401 , -1 , -1 , -1 } ,
/* 2a */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 2b */ { 0 , 0x005c , 0x002f , 0x001c , -1 , -1 } ,
/* 2c */ { 1 , 0x044f , 0x042f , -1 , -1 , -1 } ,
/* 2d */ { 1 , 0x447 , 0x427 , -1 , -1 , -1 } ,
/* 2e */ { 1 , 0x441 , 0x421 , -1 , -1 , -1 } ,
/* 2f */ { 1 , 0x043c , 0x041c , -1 , -1 , -1 } ,
/* 30 */ { 1 , 0x438 , 0x418 , -1 , -1 , -1 } ,
/* 31 */ { 1 , 0x442 , 0x422 , -1 , -1 , -1 } ,
/* 32 */ { 1 , 0x044c , 0x042c , -1 , -1 , -1 } ,
/* 33 */ { 1 , 0x431 , 0x411 , -1 , -1 , -1 } ,
/* 34 */ { 1 , 0x044e , 0x042e , -1 , -1 , -1 } ,
/* 35 */ { 0 , 0x002e , 0x002c , -1 , -1 , -1 } ,
/* 36 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 37 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 38 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 39 */ { 0 , 0x20 , 0x20 , 0x20 , -1 , -1 } ,
/* 3a */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 3b */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 3c */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 3d */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 3e */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 3f */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 40 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 41 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 42 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 43 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 44 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 45 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 46 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 47 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 48 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 49 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 4a */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 4b */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 4c */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 4d */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 4e */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 4f */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 50 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 51 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 52 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 53 */ { 0 , 0x002c , 0x002c , -1 , -1 , -1 } ,
/* 54 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 55 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 56 */ { 0 , 0x005c , 0x002f , 0x001c , -1 , -1 } ,
/* 57 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 58 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 59 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 5a */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 5b */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 5c */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 5d */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 5e */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 5f */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
};
public static final int DEADKEYS[] = null;
public static final int DEADKEY_LUT[][] = null;
private static RussianLayout instance = new RussianLayout();
private RussianLayout() {
}
public static RussianLayout getInstance() {
return instance;
}
@Override
public int[][] getLUT() {
return LUT;
}
@Override
public int[][] getFastLUT() {
return FAST_LUT;
}
@Override
public void type(String text) {
super.type(FAST_LUT, text, (byte)0);
}
@Override
public void type(String text, byte modifiers) {
super.type(FAST_LUT, text, modifiers);
}
@Override
public char getChar(int scanCode, boolean capsLock, boolean shift, boolean altGr) {
return super.getChar(LUT, scanCode, capsLock, shift, altGr);
}
@Override
public String getLocaleName() {
return LOCALE_NAME;
}
@Override
public int[][] getDeadkeyLUT() {
return DEADKEY_LUT;
}
@Override
public int[] getDeadkeys() {
return DEADKEYS;
}
}

View File

@ -0,0 +1,505 @@
package com.inputstick.api.layout;
public class SlovakLayout extends KeyboardLayout {
public static final String LOCALE_NAME = "sk-SK";
//{char (16b unicode), modifier, key, deadkey_modifier, deadkey}
//sk-SK
private static final int[][] FAST_LUT = {
{ 0, 0, 0, 0, 0 }, // empty
{ 0, 66, 30, 0, 0 }, //
{ 7, 64, 30, 0, 0 }, // 
{ 27, 1, 48, 0, 0 }, // 
{ 28, 1, 49, 0, 0 }, // 
{ 29, 1, 51, 0, 0 }, // 
{ 32, 0, 44, 0, 0 }, //
{ 33, 2, 52, 0, 0 }, // !
{ 34, 2, 51, 0, 0 }, // "
{ 35, 64, 27, 0, 0 }, // #
{ 36, 64, 51, 0, 0 }, // $
{ 37, 2, 45, 0, 0 }, // %
{ 38, 64, 6, 0, 0 }, // &
{ 39, 64, 19, 0, 0 }, // '
{ 40, 2, 48, 0, 0 }, // (
{ 41, 2, 49, 0, 0 }, // )
{ 42, 64, 56, 0, 0 }, // *
{ 43, 0, 30, 0, 0 }, // +
{ 44, 0, 54, 0, 0 }, // ,
{ 45, 0, 56, 0, 0 }, // -
{ 46, 0, 55, 0, 0 }, // .
{ 47, 2, 47, 0, 0 }, // /
{ 48, 2, 39, 0, 0 }, // 0
{ 49, 2, 30, 0, 0 }, // 1
{ 50, 2, 31, 0, 0 }, // 2
{ 51, 2, 32, 0, 0 }, // 3
{ 52, 2, 33, 0, 0 }, // 4
{ 53, 2, 34, 0, 0 }, // 5
{ 54, 2, 35, 0, 0 }, // 6
{ 55, 2, 36, 0, 0 }, // 7
{ 56, 2, 37, 0, 0 }, // 8
{ 57, 2, 38, 0, 0 }, // 9
{ 58, 2, 55, 0, 0 }, // :
{ 59, 0, 53, 0, 0 }, // ;
{ 60, 64, 54, 0, 0 }, // <
{ 61, 0, 45, 0, 0 }, // =
{ 62, 64, 29, 0, 0 }, // >
{ 63, 2, 54, 0, 0 }, // ?
{ 64, 64, 25, 0, 0 }, // @
{ 65, 2, 4, 0, 0 }, // A
{ 66, 2, 5, 0, 0 }, // B
{ 67, 2, 6, 0, 0 }, // C
{ 68, 2, 7, 0, 0 }, // D
{ 69, 2, 8, 0, 0 }, // E
{ 70, 2, 9, 0, 0 }, // F
{ 71, 2, 10, 0, 0 }, // G
{ 72, 2, 11, 0, 0 }, // H
{ 73, 2, 12, 0, 0 }, // I
{ 74, 2, 13, 0, 0 }, // J
{ 75, 2, 14, 0, 0 }, // K
{ 76, 2, 15, 0, 0 }, // L
{ 77, 2, 16, 0, 0 }, // M
{ 78, 2, 17, 0, 0 }, // N
{ 79, 2, 18, 0, 0 }, // O
{ 80, 2, 19, 0, 0 }, // P
{ 81, 2, 20, 0, 0 }, // Q
{ 82, 2, 21, 0, 0 }, // R
{ 83, 2, 22, 0, 0 }, // S
{ 84, 2, 23, 0, 0 }, // T
{ 85, 2, 24, 0, 0 }, // U
{ 86, 2, 25, 0, 0 }, // V
{ 87, 2, 26, 0, 0 }, // W
{ 88, 2, 27, 0, 0 }, // X
{ 89, 2, 28, 0, 0 }, // Y
{ 90, 2, 29, 0, 0 }, // Z
{ 91, 64, 9, 0, 0 }, // [
{ 92, 64, 20, 0, 0 }, // \
{ 93, 64, 10, 0, 0 }, // ]
{ 94, 0, 44, 64, 32 }, // ^
{ 95, 2, 56, 0, 0 }, // _
{ 96, 64, 36, 0, 0 }, // `
{ 97, 0, 4, 0, 0 }, // a
{ 98, 0, 5, 0, 0 }, // b
{ 99, 0, 6, 0, 0 }, // c
{ 100, 0, 7, 0, 0 }, // d
{ 101, 0, 8, 0, 0 }, // e
{ 102, 0, 9, 0, 0 }, // f
{ 103, 0, 10, 0, 0 }, // g
{ 104, 0, 11, 0, 0 }, // h
{ 105, 0, 12, 0, 0 }, // i
{ 106, 0, 13, 0, 0 }, // j
{ 107, 0, 14, 0, 0 }, // k
{ 108, 0, 15, 0, 0 }, // l
{ 109, 0, 16, 0, 0 }, // m
{ 110, 0, 17, 0, 0 }, // n
{ 111, 0, 18, 0, 0 }, // o
{ 112, 0, 19, 0, 0 }, // p
{ 113, 0, 20, 0, 0 }, // q
{ 114, 0, 21, 0, 0 }, // r
{ 115, 0, 22, 0, 0 }, // s
{ 116, 0, 23, 0, 0 }, // t
{ 117, 0, 24, 0, 0 }, // u
{ 118, 0, 25, 0, 0 }, // v
{ 119, 0, 26, 0, 0 }, // w
{ 120, 0, 27, 0, 0 }, // x
{ 121, 0, 28, 0, 0 }, // y
{ 122, 0, 29, 0, 0 }, // z
{ 123, 64, 5, 0, 0 }, // {
{ 124, 64, 26, 0, 0 }, // |
{ 125, 64, 17, 0, 0 }, // }
{ 164, 64, 49, 0, 0 }, // ¤
{ 167, 0, 52, 0, 0 }, // §
{ 168, 0, 44, 64, 45 }, // ¨
{ 176, 0, 44, 64, 34 }, // °
{ 180, 0, 44, 64, 38 }, // ´
{ 184, 0, 44, 64, 46 }, // ¸
{ 193, 2, 4, 64, 38 }, // Á
{ 194, 2, 4, 64, 32 }, // Â
{ 196, 2, 4, 64, 45 }, // Ä
{ 199, 2, 6, 64, 46 }, // Ç
{ 201, 2, 8, 64, 38 }, // É
{ 203, 2, 8, 64, 45 }, // Ë
{ 205, 2, 12, 64, 38 }, // Í
{ 206, 2, 12, 64, 32 }, // Î
{ 211, 2, 18, 64, 38 }, // Ó
{ 212, 2, 18, 64, 32 }, // Ô
{ 214, 2, 18, 64, 45 }, // Ö
{ 215, 64, 48, 0, 0 }, // ×
{ 218, 2, 24, 64, 38 }, // Ú
{ 220, 2, 24, 64, 45 }, // Ü
{ 221, 2, 28, 64, 38 }, // Ý
{ 223, 64, 52, 0, 0 }, // ß
{ 225, 0, 37, 0, 0 }, // á
{ 226, 0, 4, 64, 32 }, // â
{ 228, 0, 48, 0, 0 }, // ä
{ 231, 0, 6, 64, 46 }, // ç
{ 233, 0, 39, 0, 0 }, // é
{ 235, 0, 8, 64, 45 }, // ë
{ 237, 0, 38, 0, 0 }, // í
{ 238, 0, 12, 64, 32 }, // î
{ 243, 0, 18, 64, 38 }, // ó
{ 244, 0, 51, 0, 0 }, // ô
{ 246, 0, 18, 64, 45 }, // ö
{ 247, 64, 47, 0, 0 }, // ÷
{ 250, 0, 47, 0, 0 }, // ú
{ 252, 0, 24, 64, 45 }, // ü
{ 253, 0, 36, 0, 0 }, // ý
{ 258, 2, 4, 64, 32 }, // Ã
{ 259, 0, 4, 64, 32 }, // ã
{ 260, 2, 4, 64, 35 }, // ¥
{ 261, 0, 4, 64, 35 }, // ¹
{ 262, 2, 6, 64, 38 }, // Æ
{ 263, 0, 6, 64, 38 }, // æ
{ 268, 2, 6, 64, 31 }, // È
{ 269, 0, 33, 0, 0 }, // è
{ 270, 2, 7, 64, 31 }, // Ï
{ 271, 0, 7, 64, 31 }, // ï
{ 272, 64, 7, 0, 0 }, // Ð
{ 273, 64, 22, 0, 0 }, // ð
{ 280, 2, 8, 64, 35 }, // Ê
{ 281, 0, 8, 64, 35 }, // ê
{ 282, 2, 8, 64, 31 }, // Ì
{ 283, 0, 8, 64, 31 }, // ì
{ 313, 2, 15, 64, 38 }, // Å
{ 314, 0, 15, 64, 38 }, // å
{ 317, 2, 15, 64, 31 }, // ¼
{ 318, 0, 31, 0, 0 }, // ¾
{ 321, 64, 15, 0, 0 }, // £
{ 322, 64, 14, 0, 0 }, // ³
{ 323, 2, 17, 64, 38 }, // Ñ
{ 324, 0, 17, 64, 38 }, // ñ
{ 327, 2, 17, 64, 31 }, // Ò
{ 328, 0, 49, 0, 0 }, // ò
{ 336, 2, 18, 64, 39 }, // Õ
{ 337, 0, 18, 64, 39 }, // õ
{ 340, 2, 21, 64, 38 }, // À
{ 341, 0, 21, 64, 38 }, // à
{ 344, 2, 21, 64, 31 }, // Ø
{ 345, 0, 21, 64, 31 }, // ø
{ 346, 2, 22, 64, 38 }, // Œ
{ 347, 0, 22, 64, 38 }, // œ
{ 350, 2, 22, 64, 46 }, // ª
{ 351, 0, 22, 64, 46 }, // º
{ 352, 2, 22, 64, 31 }, // Š
{ 353, 0, 32, 0, 0 }, // š
{ 354, 2, 23, 64, 46 }, // Þ
{ 355, 0, 23, 64, 46 }, // þ
{ 356, 2, 23, 64, 31 }, // <EFBFBD>
{ 357, 0, 34, 0, 0 }, // <EFBFBD>
{ 366, 2, 24, 64, 34 }, // Ù
{ 367, 0, 24, 64, 34 }, // ù
{ 368, 2, 24, 64, 39 }, // Û
{ 369, 0, 24, 64, 39 }, // û
{ 377, 2, 29, 64, 38 }, // <EFBFBD>
{ 378, 0, 29, 64, 38 }, // Ÿ
{ 379, 2, 29, 64, 37 }, // ¯
{ 380, 0, 29, 64, 37 }, // ¿
{ 381, 2, 29, 64, 31 }, // Ž
{ 382, 0, 35, 0, 0 }, // ž
{ 711, 0, 44, 64, 31 }, // ¡
{ 728, 0, 44, 64, 33 }, // ¢
{ 729, 0, 44, 64, 37 }, // ÿ
{ 731, 0, 44, 64, 35 }, // ²
{ 733, 0, 44, 64, 39 }, // ½
{ 8364, 64, 8, 0, 0 }, //
};
public static final int LUT[][] = {
/* 0 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 1 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 2 */ { 0 , 0x02b , (int)'1' , -1 , 0x007 , 0 } ,
/* 3 */ { 0 , 0x13e , (int)'2' , -1 , 0x2c7 , 0 } ,
/* 4 */ { 0 , 0x161 , (int)'3' , -1 , 0x05e , 0 } ,
/* 5 */ { 0 , 0x10d , (int)'4' , -1 , 0x2d8 , 0 } ,
/* 6 */ { 0 , 0x165 , (int)'5' , -1 , 0x0b0 , 0 } ,
/* 7 */ { 0 , 0x17e , (int)'6' , -1 , 0x2db , 0 } ,
/* 8 */ { 0 , 0x0fd , (int)'7' , -1 , 0x060 , 0 } ,
/* 9 */ { 0 , 0x0e1 , (int)'8' , -1 , 0x2d9 , 0 } ,
/* 0a */ { 0 , 0x0ed , (int)'9' , -1 , 0x0b4 , 0 } ,
/* 0b */ { 0 , 0x0e9 , (int)'0' , -1 , 0x2dd , 0 } ,
/* 0c */ { 0 , 0x03d , 0x025 , -1 , 0x0a8 , 0 } ,
/* 0d */ { 0 , 0x0b4 , 0x2c7 , -1 , 0x0b8 , 0 } ,
/* 0e */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 0f */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 10 */ { 1 , 'q' , 'Q' , -1 , 0x05c , 0 } ,
/* 11 */ { 1 , 'w' , 'W' , -1 , 0x07c , 0 } ,
/* 12 */ { 1 , 'e' , 'E' , -1 , 0x20ac , 0 } ,
/* 13 */ { 1 , 'r' , 'R' , -1 , -1 , 0 } ,
/* 14 */ { 1 , 't' , 'T' , -1 , -1 , 0 } ,
/* 15 */ { 1 , 'y' , 'Y' , -1 , -1 , 0 } ,
/* 16 */ { 1 , 'u' , 'U' , -1 , -1 , 0 } ,
/* 17 */ { 1 , 'i' , 'I' , -1 , -1 , 0 } ,
/* 18 */ { 1 , 'o' , 'O' , -1 , -1 , 0 } ,
/* 19 */ { 1 , 'p' , 'P' , -1 , 0x027 , 0 } ,
/* 1a */ { 0 , 0x0fa , 0x02f , -1 , 0x0f7 , 0 } ,
/* 1b */ { 0 , 0x0e4 , 0x028 , 0x01b , 0x0d7 , 0 } ,
/* 1c */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 1d */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 1e */ { 1 , 'a' , 'A' , -1 , -1 , 0 } ,
/* 1f */ { 1 , 's' , 'S' , -1 , 0x111 , 0 } ,
/* 20 */ { 1 , 'd' , 'D' , -1 , 0x110 , 0 } ,
/* 21 */ { 1 , 'f' , 'F' , -1 , 0x05b , 0 } ,
/* 22 */ { 1 , 'g' , 'G' , -1 , 0x05d , 0 } ,
/* 23 */ { 1 , 'h' , 'H' , -1 , -1 , 0 } ,
/* 24 */ { 1 , 'j' , 'J' , -1 , -1 , 0 } ,
/* 25 */ { 1 , 'k' , 'K' , -1 , 0x142 , 0 } ,
/* 26 */ { 1 , 'l' , 'L' , -1 , 0x141 , 0 } ,
/* 27 */ { 0 , 0x0f4 , 0x022 , 0x01d , 0x024 , 0 } ,
/* 28 */ { 0 , 0x0a7 , 0x021 , -1 , 0x0df , 0 } ,
/* 29 */ { 0 , 0x03b , 0x0b0 , -1 , -1 , 0 } ,
/* 2a */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 2b */ { 0 , 0x148 , 0x029 , 0x01c , 0x0a4 , 0 } ,
/* 2c */ { 1 , 'z' , 'Z' , -1 , 0x03e , 0 } ,
/* 2d */ { 1 , 'x' , 'X' , -1 , 0x023 , 0 } ,
/* 2e */ { 1 , 'c' , 'C' , -1 , 0x026 , 0 } ,
/* 2f */ { 1 , 'v' , 'V' , -1 , 0x040 , 0 } ,
/* 30 */ { 1 , 'b' , 'B' , -1 , 0x07b , 0 } ,
/* 31 */ { 1 , 'n' , 'N' , -1 , 0x07d , 0 } ,
/* 32 */ { 1 , 'm' , 'M' , -1 , -1 , 0 } ,
/* 33 */ { 0 , 0x02c , 0x03f , -1 , 0x03c , 0 } ,
/* 34 */ { 0 , 0x02e , 0x03a , -1 , 0x03e , 0 } ,
/* 35 */ { 0 , 0x02d , 0x05f , -1 , 0x02a , 0 } ,
/* 36 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 37 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 38 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 39 */ { 0 , 0x020 , 0x020 , 0x020 , -1 , 0 } ,
/* 3a */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 3b */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 3c */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 3d */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 3e */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 3f */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 40 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 41 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 42 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 43 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 44 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 45 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 46 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 47 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 48 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 49 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 4a */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 4b */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 4c */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 4d */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 4e */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 4f */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 50 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 51 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 52 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 53 */ { 0 , 0x02c , 0x02c , -1 , -1 , 0 } ,
/* 54 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 55 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 56 */ { 0 , 0x026 , 0x02a , 0x01c , 0x03c , 0 } ,
/* 57 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 58 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 59 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 5a */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 5b */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 5c */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 5d */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 5e */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 5f */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
};
public static final int DEADKEYS[] = {
0x02c7, 0x005e, 0x02d8, 0x00b0, 0x02db, 0x02d9, 0x00b4, 0x02dd, 0x00a8, 0x00b4, 0x02c7, 0x00b8, 0x00b0
};
public static final int DEADKEY_LUT[][] = {
{ 0x02c7 , 0x006e , 0x0148 } ,
{ 0x02c7 , 0x0063 , 0x010d } ,
{ 0x02c7 , 0x007a , 0x017e } ,
{ 0x02c7 , 0x0064 , 0x010f } ,
{ 0x02c7 , 0x0073 , 0x0161 } ,
{ 0x02c7 , 0x006c , 0x013e } ,
{ 0x02c7 , 0x0065 , 0x011b } ,
{ 0x02c7 , 0x0072 , 0x0159 } ,
{ 0x02c7 , 0x0074 , 0x0165 } ,
{ 0x02c7 , 0x004e , 0x0147 } ,
{ 0x02c7 , 0x0043 , 0x010c } ,
{ 0x02c7 , 0x005a , 0x017d } ,
{ 0x02c7 , 0x0044 , 0x010e } ,
{ 0x02c7 , 0x0053 , 0x0160 } ,
{ 0x02c7 , 0x004c , 0x013d } ,
{ 0x02c7 , 0x0045 , 0x011a } ,
{ 0x02c7 , 0x0052 , 0x0158 } ,
{ 0x02c7 , 0x0054 , 0x0164 } ,
{ 0x02c7 , 0x0020 , 0x02c7 } ,
{ 0x005e , 0x0061 , 0x00e2 } ,
{ 0x005e , 0x0069 , 0x00ee } ,
{ 0x005e , 0x006f , 0x00f4 } ,
{ 0x005e , 0x0041 , 0x00c2 } ,
{ 0x005e , 0x0049 , 0x00ce } ,
{ 0x005e , 0x004f , 0x00d4 } ,
{ 0x005e , 0x0020 , 0x005e } ,
{ 0x005e , 0x0061 , 0x0103 } ,
{ 0x005e , 0x0041 , 0x0102 } ,
{ 0x005e , 0x0020 , 0x02d8 } ,
{ 0x00b0 , 0x0075 , 0x016f } ,
{ 0x00b0 , 0x0055 , 0x016e } ,
{ 0x00b0 , 0x0020 , 0x00b0 } ,
{ 0x02db , 0x0061 , 0x0105 } ,
{ 0x02db , 0x0065 , 0x0119 } ,
{ 0x02db , 0x0041 , 0x0104 } ,
{ 0x02db , 0x0045 , 0x0118 } ,
{ 0x02db , 0x0020 , 0x02db } ,
{ 0x02d9 , 0x007a , 0x017c } ,
{ 0x02d9 , 0x005a , 0x017b } ,
{ 0x02d9 , 0x0020 , 0x02d9 } ,
{ 0x00b4 , 0x006e , 0x0144 } ,
{ 0x00b4 , 0x0063 , 0x0107 } ,
{ 0x00b4 , 0x007a , 0x017a } ,
{ 0x00b4 , 0x0061 , 0x00e1 } ,
{ 0x00b4 , 0x0073 , 0x015b } ,
{ 0x00b4 , 0x006c , 0x013a } ,
{ 0x00b4 , 0x0065 , 0x00e9 } ,
{ 0x00b4 , 0x0072 , 0x0155 } ,
{ 0x00b4 , 0x0075 , 0x00fa } ,
{ 0x00b4 , 0x0069 , 0x00ed } ,
{ 0x00b4 , 0x0079 , 0x00fd } ,
{ 0x00b4 , 0x006f , 0x00f3 } ,
{ 0x00b4 , 0x004e , 0x0143 } ,
{ 0x00b4 , 0x0043 , 0x0106 } ,
{ 0x00b4 , 0x005a , 0x0179 } ,
{ 0x00b4 , 0x0041 , 0x00c1 } ,
{ 0x00b4 , 0x0053 , 0x015a } ,
{ 0x00b4 , 0x004c , 0x0139 } ,
{ 0x00b4 , 0x0045 , 0x00c9 } ,
{ 0x00b4 , 0x0052 , 0x0154 } ,
{ 0x00b4 , 0x0055 , 0x00da } ,
{ 0x00b4 , 0x0049 , 0x00cd } ,
{ 0x00b4 , 0x0059 , 0x00dd } ,
{ 0x00b4 , 0x004f , 0x00d3 } ,
{ 0x00b4 , 0x0020 , 0x00b4 } ,
{ 0x02dd , 0x0075 , 0x0171 } ,
{ 0x02dd , 0x006f , 0x0151 } ,
{ 0x02dd , 0x0055 , 0x0170 } ,
{ 0x02dd , 0x004f , 0x0150 } ,
{ 0x02dd , 0x0020 , 0x02dd } ,
{ 0x00a8 , 0x0061 , 0x00e4 } ,
{ 0x00a8 , 0x0065 , 0x00eb } ,
{ 0x00a8 , 0x0075 , 0x00fc } ,
{ 0x00a8 , 0x006f , 0x00f6 } ,
{ 0x00a8 , 0x0041 , 0x00c4 } ,
{ 0x00a8 , 0x0045 , 0x00cb } ,
{ 0x00a8 , 0x0055 , 0x00dc } ,
{ 0x00a8 , 0x004f , 0x00d6 } ,
{ 0x00a8 , 0x0020 , 0x00a8 } ,
{ 0x00b4 , 0x006e , 0x0144 } ,
{ 0x00b4 , 0x0063 , 0x0107 } ,
{ 0x00b4 , 0x007a , 0x017a } ,
{ 0x00b4 , 0x0061 , 0x00e1 } ,
{ 0x00b4 , 0x0073 , 0x015b } ,
{ 0x00b4 , 0x006c , 0x013a } ,
{ 0x00b4 , 0x0065 , 0x00e9 } ,
{ 0x00b4 , 0x0072 , 0x0155 } ,
{ 0x00b4 , 0x0075 , 0x00fa } ,
{ 0x00b4 , 0x0069 , 0x00ed } ,
{ 0x00b4 , 0x0079 , 0x00fd } ,
{ 0x00b4 , 0x006f , 0x00f3 } ,
{ 0x00b4 , 0x004e , 0x0143 } ,
{ 0x00b4 , 0x0043 , 0x0106 } ,
{ 0x00b4 , 0x005a , 0x0179 } ,
{ 0x00b4 , 0x0041 , 0x00c1 } ,
{ 0x00b4 , 0x0053 , 0x015a } ,
{ 0x00b4 , 0x004c , 0x0139 } ,
{ 0x00b4 , 0x0045 , 0x00c9 } ,
{ 0x00b4 , 0x0052 , 0x0154 } ,
{ 0x00b4 , 0x0055 , 0x00da } ,
{ 0x00b4 , 0x0049 , 0x00cd } ,
{ 0x00b4 , 0x0059 , 0x00dd } ,
{ 0x00b4 , 0x004f , 0x00d3 } ,
{ 0x00b4 , 0x0020 , 0x00b4 } ,
{ 0x02c7 , 0x006e , 0x0148 } ,
{ 0x02c7 , 0x0063 , 0x010d } ,
{ 0x02c7 , 0x007a , 0x017e } ,
{ 0x02c7 , 0x0064 , 0x010f } ,
{ 0x02c7 , 0x0073 , 0x0161 } ,
{ 0x02c7 , 0x006c , 0x013e } ,
{ 0x02c7 , 0x0065 , 0x011b } ,
{ 0x02c7 , 0x0072 , 0x0159 } ,
{ 0x02c7 , 0x0074 , 0x0165 } ,
{ 0x02c7 , 0x004e , 0x0147 } ,
{ 0x02c7 , 0x0043 , 0x010c } ,
{ 0x02c7 , 0x005a , 0x017d } ,
{ 0x02c7 , 0x0044 , 0x010e } ,
{ 0x02c7 , 0x0053 , 0x0160 } ,
{ 0x02c7 , 0x004c , 0x013d } ,
{ 0x02c7 , 0x0045 , 0x011a } ,
{ 0x02c7 , 0x0052 , 0x0158 } ,
{ 0x02c7 , 0x0054 , 0x0164 } ,
{ 0x02c7 , 0x0020 , 0x02c7 } ,
{ 0x00b8 , 0x0063 , 0x00e7 } ,
{ 0x00b8 , 0x0073 , 0x015f } ,
{ 0x00b8 , 0x0074 , 0x0163 } ,
{ 0x00b8 , 0x0043 , 0x00c7 } ,
{ 0x00b8 , 0x0053 , 0x015e } ,
{ 0x00b8 , 0x0054 , 0x0162 } ,
{ 0x00b8 , 0x0020 , 0x00b8 } ,
{ 0x00b0 , 0x0075 , 0x016f } ,
{ 0x00b0 , 0x0055 , 0x016e } ,
{ 0x00b0 , 0x0020 , 0x00b0 } ,
};
private static SlovakLayout instance = new SlovakLayout();
private SlovakLayout() {
}
public static SlovakLayout getInstance() {
return instance;
}
@Override
public int[][] getLUT() {
return LUT;
}
@Override
public int[][] getFastLUT() {
return FAST_LUT;
}
@Override
public void type(String text) {
super.type(FAST_LUT, text, (byte)0);
}
@Override
public void type(String text, byte modifiers) {
super.type(FAST_LUT, text, modifiers);
}
@Override
public char getChar(int scanCode, boolean capsLock, boolean shift, boolean altGr) {
return super.getChar(LUT, scanCode, capsLock, shift, altGr);
}
@Override
public String getLocaleName() {
return LOCALE_NAME;
}
@Override
public int[][] getDeadkeyLUT() {
return DEADKEY_LUT;
}
@Override
public int[] getDeadkeys() {
return DEADKEYS;
}
}

View File

@ -0,0 +1,392 @@
package com.inputstick.api.layout;
public class SpanishLayout extends KeyboardLayout {
public static final String LOCALE_NAME = "es-ES";
//{char (16b unicode), modifier, key, deadkey_modifier, deadkey}
//es-ES
private static final int[][] FAST_LUT = {
{ 0, 0, 0, 0, 0 }, // empty
{ 20, 1, 44, 0, 0 }, // 
{ 27, 1, 47, 0, 0 }, // 
{ 28, 1, 49, 0, 0 }, // 
{ 29, 1, 48, 0, 0 }, // 
{ 32, 0, 44, 0, 0 }, //
{ 33, 2, 30, 0, 0 }, // !
{ 34, 2, 31, 0, 0 }, // "
{ 35, 64, 32, 0, 0 }, // #
{ 36, 2, 33, 0, 0 }, // $
{ 37, 2, 34, 0, 0 }, // %
{ 38, 2, 35, 0, 0 }, // &
{ 39, 0, 45, 0, 0 }, // '
{ 40, 2, 37, 0, 0 }, // (
{ 41, 2, 38, 0, 0 }, // )
{ 42, 2, 48, 0, 0 }, // *
{ 43, 0, 48, 0, 0 }, // +
{ 44, 0, 54, 0, 0 }, // ,
{ 45, 0, 56, 0, 0 }, // -
{ 46, 0, 55, 0, 0 }, // .
{ 47, 2, 36, 0, 0 }, // /
{ 48, 0, 39, 0, 0 }, // 0
{ 49, 0, 30, 0, 0 }, // 1
{ 50, 0, 31, 0, 0 }, // 2
{ 51, 0, 32, 0, 0 }, // 3
{ 52, 0, 33, 0, 0 }, // 4
{ 53, 0, 34, 0, 0 }, // 5
{ 54, 0, 35, 0, 0 }, // 6
{ 55, 0, 36, 0, 0 }, // 7
{ 56, 0, 37, 0, 0 }, // 8
{ 57, 0, 38, 0, 0 }, // 9
{ 58, 2, 55, 0, 0 }, // :
{ 59, 2, 54, 0, 0 }, // ;
{ 60, 0, 100, 0, 0 }, // <
{ 61, 2, 39, 0, 0 }, // =
{ 62, 2, 100, 0, 0 }, // >
{ 63, 2, 45, 0, 0 }, // ?
{ 64, 64, 31, 0, 0 }, // @
{ 65, 2, 4, 0, 0 }, // A
{ 66, 2, 5, 0, 0 }, // B
{ 67, 2, 6, 0, 0 }, // C
{ 68, 2, 7, 0, 0 }, // D
{ 69, 2, 8, 0, 0 }, // E
{ 70, 2, 9, 0, 0 }, // F
{ 71, 2, 10, 0, 0 }, // G
{ 72, 2, 11, 0, 0 }, // H
{ 73, 2, 12, 0, 0 }, // I
{ 74, 2, 13, 0, 0 }, // J
{ 75, 2, 14, 0, 0 }, // K
{ 76, 2, 15, 0, 0 }, // L
{ 77, 2, 16, 0, 0 }, // M
{ 78, 2, 17, 0, 0 }, // N
{ 79, 2, 18, 0, 0 }, // O
{ 80, 2, 19, 0, 0 }, // P
{ 81, 2, 20, 0, 0 }, // Q
{ 82, 2, 21, 0, 0 }, // R
{ 83, 2, 22, 0, 0 }, // S
{ 84, 2, 23, 0, 0 }, // T
{ 85, 2, 24, 0, 0 }, // U
{ 86, 2, 25, 0, 0 }, // V
{ 87, 2, 26, 0, 0 }, // W
{ 88, 2, 27, 0, 0 }, // X
{ 89, 2, 28, 0, 0 }, // Y
{ 90, 2, 29, 0, 0 }, // Z
{ 91, 64, 47, 0, 0 }, // [
{ 92, 64, 53, 0, 0 }, // \
{ 93, 64, 48, 0, 0 }, // ]
{ 94, 0, 44, 2, 47 }, // ^
{ 95, 2, 56, 0, 0 }, // _
{ 96, 0, 44, 0, 47 }, // `
{ 97, 0, 4, 0, 0 }, // a
{ 98, 0, 5, 0, 0 }, // b
{ 99, 0, 6, 0, 0 }, // c
{ 100, 0, 7, 0, 0 }, // d
{ 101, 0, 8, 0, 0 }, // e
{ 102, 0, 9, 0, 0 }, // f
{ 103, 0, 10, 0, 0 }, // g
{ 104, 0, 11, 0, 0 }, // h
{ 105, 0, 12, 0, 0 }, // i
{ 106, 0, 13, 0, 0 }, // j
{ 107, 0, 14, 0, 0 }, // k
{ 108, 0, 15, 0, 0 }, // l
{ 109, 0, 16, 0, 0 }, // m
{ 110, 0, 17, 0, 0 }, // n
{ 111, 0, 18, 0, 0 }, // o
{ 112, 0, 19, 0, 0 }, // p
{ 113, 0, 20, 0, 0 }, // q
{ 114, 0, 21, 0, 0 }, // r
{ 115, 0, 22, 0, 0 }, // s
{ 116, 0, 23, 0, 0 }, // t
{ 117, 0, 24, 0, 0 }, // u
{ 118, 0, 25, 0, 0 }, // v
{ 119, 0, 26, 0, 0 }, // w
{ 120, 0, 27, 0, 0 }, // x
{ 121, 0, 28, 0, 0 }, // y
{ 122, 0, 29, 0, 0 }, // z
{ 123, 64, 52, 0, 0 }, // {
{ 124, 64, 30, 0, 0 }, // |
{ 125, 64, 49, 0, 0 }, // }
{ 126, 0, 44, 64, 33 }, // ~
{ 161, 0, 46, 0, 0 }, // ?
{ 168, 0, 44, 2, 52 }, // ¨
{ 170, 2, 53, 0, 0 }, // ?
{ 172, 64, 35, 0, 0 }, // ¬
{ 180, 0, 44, 0, 52 }, // ´
{ 183, 2, 32, 0, 0 }, // ·
{ 186, 0, 53, 0, 0 }, // ?
{ 191, 2, 46, 0, 0 }, // ?
{ 192, 2, 4, 0, 47 }, // ?
{ 193, 2, 4, 0, 52 }, // Á
{ 194, 2, 4, 2, 47 }, // Â
{ 195, 2, 4, 64, 33 }, // ?
{ 196, 2, 4, 2, 52 }, // Ä
{ 199, 2, 49, 0, 0 }, // Ç
{ 200, 2, 8, 0, 47 }, // ?
{ 201, 2, 8, 0, 52 }, // É
{ 202, 2, 8, 2, 47 }, // ?
{ 203, 2, 8, 2, 52 }, // Ë
{ 204, 2, 12, 0, 47 }, // ?
{ 205, 2, 12, 0, 52 }, // Í
{ 206, 2, 12, 2, 47 }, // Î
{ 207, 2, 12, 2, 52 }, // ?
{ 209, 2, 51, 0, 0 }, // ?
{ 210, 2, 18, 0, 47 }, // ?
{ 211, 2, 18, 0, 52 }, // Ó
{ 212, 2, 18, 2, 47 }, // Ô
{ 213, 2, 18, 64, 33 }, // ?
{ 214, 2, 18, 2, 52 }, // Ö
{ 217, 2, 24, 0, 47 }, // ?
{ 218, 2, 24, 0, 52 }, // Ú
{ 219, 2, 24, 2, 47 }, // ?
{ 220, 2, 24, 2, 52 }, // Ü
{ 221, 2, 28, 0, 52 }, // Ý
{ 224, 0, 4, 0, 47 }, // ?
{ 225, 0, 4, 0, 52 }, // á
{ 226, 0, 4, 2, 47 }, // â
{ 227, 0, 4, 64, 33 }, // ?
{ 228, 0, 4, 2, 52 }, // ä
{ 231, 0, 49, 0, 0 }, // ç
{ 232, 0, 8, 0, 47 }, // ?
{ 233, 0, 8, 0, 52 }, // é
{ 234, 0, 8, 2, 47 }, // ?
{ 235, 0, 8, 2, 52 }, // ë
{ 236, 0, 12, 0, 47 }, // ?
{ 237, 0, 12, 0, 52 }, // í
{ 238, 0, 12, 2, 47 }, // î
{ 239, 0, 12, 2, 52 }, // ?
{ 241, 0, 51, 0, 0 }, // ?
{ 242, 0, 18, 0, 47 }, // ?
{ 243, 0, 18, 0, 52 }, // ó
{ 244, 0, 18, 2, 47 }, // ô
{ 245, 0, 18, 64, 33 }, // ?
{ 246, 0, 18, 2, 52 }, // ö
{ 249, 0, 24, 0, 47 }, // ?
{ 250, 0, 24, 0, 52 }, // ú
{ 251, 0, 24, 2, 47 }, // ?
{ 252, 0, 24, 2, 52 }, // ü
{ 253, 0, 28, 0, 52 }, // ý
{ 255, 0, 28, 2, 52 }, // ?
{ 8364, 64, 34, 0, 0 }, //
};
public static final int LUT[][] = {
/* 0 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 1 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 2 */ { 0 , (int)'1' , 0x21 , -1 , 0x007c , -1 } ,
/* 3 */ { 0 , (int)'2' , 0x22 , -1 , 0x40 , -1 } ,
/* 4 */ { 0 , (int)'3' , 0x00b7 , -1 , 0x23 , -1 } ,
/* 5 */ { 0 , (int)'4' , 0x24 , -1 , 0x007e , -1 } ,
/* 6 */ { 0 , (int)'5' , 0x25 , -1 , 0x20ac , -1 } ,
/* 7 */ { 0 , (int)'6' , 0x26 , -1 , 0x00ac , -1 } ,
/* 8 */ { 0 , (int)'7' , 0x002f , -1 , -1 , -1 } ,
/* 9 */ { 0 , (int)'8' , 0x28 , -1 , -1 , -1 } ,
/* 0a */ { 0 , (int)'9' , 0x29 , -1 , -1 , -1 } ,
/* 0b */ { 0 , (int)'0' , 0x003d , -1 , -1 , -1 } ,
/* 0c */ { 0 , 0x27 , 0x003f , -1 , -1 , -1 } ,
/* 0d */ { 0 , 0x00a1 , 0x00bf , -1 , -1 , -1 } ,
/* 1e */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 1f */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 10 */ { 1 , (int)'q' , (int)'Q' , -1 , -1 , -1 } ,
/* 11 */ { 1 , (int)'w' , (int)'W' , -1 , -1 , -1 } ,
/* 12 */ { 1 , (int)'e' , (int)'E' , -1 , 0x20ac , -1 } ,
/* 13 */ { 1 , (int)'r' , (int)'R' , -1 , -1 , -1 } ,
/* 14 */ { 1 , (int)'t' , (int)'T' , -1 , -1 , -1 } ,
/* 15 */ { 1 , (int)'y' , (int)'Y' , -1 , -1 , -1 } ,
/* 16 */ { 1 , (int)'u' , (int)'U' , -1 , -1 , -1 } ,
/* 17 */ { 1 , (int)'i' , (int)'I' , -1 , -1 , -1 } ,
/* 18 */ { 1 , (int)'o' , (int)'O' , -1 , -1 , -1 } ,
/* 19 */ { 1 , (int)'p' , (int)'P' , -1 , -1 , -1 } ,
/* 1a */ { 0 , 0x0060 , 0x005e , 0x001b , 0x005b , -1 } ,
/* 1b */ { 0 , 0x002b , 0x002a , 0x001d , 0x005d , -1 } ,
/* 1c */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 1d */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 1e */ { 1 , (int)'a' , (int)'A' , -1 , -1 , -1 } ,
/* 1f */ { 1 , (int)'s' , (int)'S' , -1 , -1 , -1 } ,
/* 20 */ { 1 , (int)'d' , (int)'D' , -1 , -1 , -1 } ,
/* 21 */ { 1 , (int)'f' , (int)'F' , -1 , -1 , -1 } ,
/* 22 */ { 1 , (int)'g' , (int)'G' , -1 , -1 , -1 } ,
/* 23 */ { 1 , (int)'h' , (int)'H' , -1 , -1 , -1 } ,
/* 24 */ { 1 , (int)'j' , (int)'J' , -1 , -1 , -1 } ,
/* 25 */ { 1 , (int)'k' , (int)'K' , -1 , -1 , -1 } ,
/* 26 */ { 1 , (int)'l' , (int)'L' , -1 , -1 , -1 } ,
/* 27 */ { 1 , 0x00f1 , 0x00d1 , -1 , -1 , -1 } ,
/* 28 */ { 0 , 0x00b4 , 0x00a8 , -1 , 0x007b , -1 } ,
/* 29 */ { 0 , 0x00ba , 0x00aa , -1 , 0x005c , -1 } ,
/* 2a */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 2b */ { 1 , 0x00e7 , 0x00c7 , 0x001c , 0x007d , -1 } ,
/* 2c */ { 1 , (int)'z' , (int)'Z' , -1 , -1 , -1 } ,
/* 2d */ { 1 , (int)'x' , (int)'X' , -1 , -1 , -1 } ,
/* 2e */ { 1 , (int)'c' , (int)'C' , -1 , -1 , -1 } ,
/* 2f */ { 1 , (int)'v' , (int)'V' , -1 , -1 , -1 } ,
/* 30 */ { 1 , (int)'b' , (int)'B' , -1 , -1 , -1 } ,
/* 31 */ { 1 , (int)'n' , (int)'N' , -1 , -1 , -1 } ,
/* 32 */ { 1 , (int)'m' , (int)'M' , -1 , -1 , -1 } ,
/* 33 */ { 0 , 0x002c , 0x003b , -1 , -1 , -1 } ,
/* 34 */ { 0 , 0x002e , 0x003a , -1 , -1 , -1 } ,
/* 35 */ { 0 , 0x002d , 0x005f , -1 , -1 , -1 } ,
/* 36 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 37 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 38 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 39 */ { 0 , 0x20 , 0x20 , 20 , -1 , -1 } ,
/* 3a */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 3b */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 3c */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 3d */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 3e */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 3f */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 40 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 41 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 42 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 43 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 44 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 45 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 46 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 47 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 48 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 49 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 4a */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 4b */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 4c */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 4d */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 4e */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 4f */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 50 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 51 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 52 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 53 */ { 0 , 0x002e , 0x002e , -1 , -1 , -1 } ,
/* 54 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 55 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 56 */ { 0 , 0x003c , 0x003e , 0x001c , -1 , -1 } ,
/* 57 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 58 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 59 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 5a */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 5b */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 5c */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 5d */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 5e */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 5f */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
};
public static final int DEADKEYS[] = {
0x007e, 0x0060, 0x005e, 0x00b4,0x00a8
};
public static final int DEADKEY_LUT[][] = {
{ 0x007e , 0x006e , 0x00f1 } ,
{ 0x007e , 0x0061 , 0x00e3 } ,
{ 0x007e , 0x006f , 0x00f5 } ,
{ 0x007e , 0x004e , 0x00d1 } ,
{ 0x007e , 0x0041 , 0x00c3 } ,
{ 0x007e , 0x004f , 0x00d5 } ,
{ 0x007e , 0x0020 , 0x007e } ,
{ 0x0060 , 0x0061 , 0x00e0 } ,
{ 0x0060 , 0x0065 , 0x00e8 } ,
{ 0x0060 , 0x0075 , 0x00f9 } ,
{ 0x0060 , 0x0069 , 0x00ec } ,
{ 0x0060 , 0x006f , 0x00f2 } ,
{ 0x0060 , 0x0041 , 0x00c0 } ,
{ 0x0060 , 0x0045 , 0x00c8 } ,
{ 0x0060 , 0x0055 , 0x00d9 } ,
{ 0x0060 , 0x0049 , 0x00cc } ,
{ 0x0060 , 0x004f , 0x00d2 } ,
{ 0x0060 , 0x0020 , 0x0060 } ,
{ 0x005e , 0x0061 , 0x00e2 } ,
{ 0x005e , 0x0065 , 0x00ea } ,
{ 0x005e , 0x0075 , 0x00fb } ,
{ 0x005e , 0x0069 , 0x00ee } ,
{ 0x005e , 0x006f , 0x00f4 } ,
{ 0x005e , 0x0041 , 0x00c2 } ,
{ 0x005e , 0x0045 , 0x00ca } ,
{ 0x005e , 0x0055 , 0x00db } ,
{ 0x005e , 0x0049 , 0x00ce } ,
{ 0x005e , 0x004f , 0x00d4 } ,
{ 0x005e , 0x0020 , 0x005e } ,
{ 0x00b4 , 0x0061 , 0x00e1 } ,
{ 0x00b4 , 0x0065 , 0x00e9 } ,
{ 0x00b4 , 0x0075 , 0x00fa } ,
{ 0x00b4 , 0x0069 , 0x00ed } ,
{ 0x00b4 , 0x0079 , 0x00fd } ,
{ 0x00b4 , 0x006f , 0x00f3 } ,
{ 0x00b4 , 0x0041 , 0x00c1 } ,
{ 0x00b4 , 0x0045 , 0x00c9 } ,
{ 0x00b4 , 0x0055 , 0x00da } ,
{ 0x00b4 , 0x0049 , 0x00cd } ,
{ 0x00b4 , 0x0059 , 0x00dd } ,
{ 0x00b4 , 0x004f , 0x00d3 } ,
{ 0x00b4 , 0x0020 , 0x00b4 } ,
{ 0x00a8 , 0x0061 , 0x00e4 } ,
{ 0x00a8 , 0x0065 , 0x00eb } ,
{ 0x00a8 , 0x0075 , 0x00fc } ,
{ 0x00a8 , 0x0069 , 0x00ef } ,
{ 0x00a8 , 0x0079 , 0x00ff } ,
{ 0x00a8 , 0x006f , 0x00f6 } ,
{ 0x00a8 , 0x0041 , 0x00c4 } ,
{ 0x00a8 , 0x0045 , 0x00cb } ,
{ 0x00a8 , 0x0055 , 0x00dc } ,
{ 0x00a8 , 0x0049 , 0x00cf } ,
{ 0x00a8 , 0x004f , 0x00d6 } ,
{ 0x00a8 , 0x0020 , 0x00a8 } ,
};
private static SpanishLayout instance = new SpanishLayout();
private SpanishLayout() {
}
public static SpanishLayout getInstance() {
return instance;
}
@Override
public int[][] getLUT() {
return LUT;
}
@Override
public int[][] getFastLUT() {
return FAST_LUT;
}
@Override
public void type(String text) {
super.type(FAST_LUT, text, (byte)0);
}
@Override
public void type(String text, byte modifiers) {
super.type(FAST_LUT, text, modifiers);
}
@Override
public char getChar(int scanCode, boolean capsLock, boolean shift, boolean altGr) {
return super.getChar(LUT, scanCode, capsLock, shift, altGr);
}
@Override
public String getLocaleName() {
return LOCALE_NAME;
}
@Override
public int[][] getDeadkeyLUT() {
return DEADKEY_LUT;
}
@Override
public int[] getDeadkeys() {
return DEADKEYS;
}
}

View File

@ -0,0 +1,386 @@
package com.inputstick.api.layout;
public class SwedishLayout extends KeyboardLayout {
public static final String LOCALE_NAME = "sv-SE";
//{char (16b unicode), modifier, key, deadkey_modifier, deadkey}
//sv-SE
private static final int[][] FAST_LUT = {
{ 0, 0, 0, 0, 0 }, // empty
{ 27, 1, 47, 0, 0 }, // 
{ 28, 1, 53, 0, 0 }, // 
{ 29, 1, 48, 0, 0 }, // 
{ 32, 0, 44, 0, 0 }, //
{ 33, 2, 30, 0, 0 }, // !
{ 34, 2, 31, 0, 0 }, // "
{ 35, 2, 32, 0, 0 }, // #
{ 36, 64, 33, 0, 0 }, // $
{ 37, 2, 34, 0, 0 }, // %
{ 38, 2, 35, 0, 0 }, // &
{ 39, 0, 49, 0, 0 }, // '
{ 40, 2, 37, 0, 0 }, // (
{ 41, 2, 38, 0, 0 }, // )
{ 42, 2, 49, 0, 0 }, // *
{ 43, 0, 45, 0, 0 }, // +
{ 44, 0, 54, 0, 0 }, // ,
{ 45, 0, 56, 0, 0 }, // -
{ 46, 0, 55, 0, 0 }, // .
{ 47, 2, 36, 0, 0 }, // /
{ 48, 0, 39, 0, 0 }, // 0
{ 49, 0, 30, 0, 0 }, // 1
{ 50, 0, 31, 0, 0 }, // 2
{ 51, 0, 32, 0, 0 }, // 3
{ 52, 0, 33, 0, 0 }, // 4
{ 53, 0, 34, 0, 0 }, // 5
{ 54, 0, 35, 0, 0 }, // 6
{ 55, 0, 36, 0, 0 }, // 7
{ 56, 0, 37, 0, 0 }, // 8
{ 57, 0, 38, 0, 0 }, // 9
{ 58, 2, 55, 0, 0 }, // :
{ 59, 2, 54, 0, 0 }, // ;
{ 60, 0, 100, 0, 0 }, // <
{ 61, 2, 39, 0, 0 }, // =
{ 62, 2, 100, 0, 0 }, // >
{ 63, 2, 45, 0, 0 }, // ?
{ 64, 64, 31, 0, 0 }, // @
{ 65, 2, 4, 0, 0 }, // A
{ 66, 2, 5, 0, 0 }, // B
{ 67, 2, 6, 0, 0 }, // C
{ 68, 2, 7, 0, 0 }, // D
{ 69, 2, 8, 0, 0 }, // E
{ 70, 2, 9, 0, 0 }, // F
{ 71, 2, 10, 0, 0 }, // G
{ 72, 2, 11, 0, 0 }, // H
{ 73, 2, 12, 0, 0 }, // I
{ 74, 2, 13, 0, 0 }, // J
{ 75, 2, 14, 0, 0 }, // K
{ 76, 2, 15, 0, 0 }, // L
{ 77, 2, 16, 0, 0 }, // M
{ 78, 2, 17, 0, 0 }, // N
{ 79, 2, 18, 0, 0 }, // O
{ 80, 2, 19, 0, 0 }, // P
{ 81, 2, 20, 0, 0 }, // Q
{ 82, 2, 21, 0, 0 }, // R
{ 83, 2, 22, 0, 0 }, // S
{ 84, 2, 23, 0, 0 }, // T
{ 85, 2, 24, 0, 0 }, // U
{ 86, 2, 25, 0, 0 }, // V
{ 87, 2, 26, 0, 0 }, // W
{ 88, 2, 27, 0, 0 }, // X
{ 89, 2, 28, 0, 0 }, // Y
{ 90, 2, 29, 0, 0 }, // Z
{ 91, 64, 37, 0, 0 }, // [
{ 92, 64, 45, 0, 0 }, // \
{ 93, 64, 38, 0, 0 }, // ]
{ 94, 0, 44, 2, 48 }, // ^
{ 95, 2, 56, 0, 0 }, // _
{ 96, 0, 44, 2, 46 }, // `
{ 97, 0, 4, 0, 0 }, // a
{ 98, 0, 5, 0, 0 }, // b
{ 99, 0, 6, 0, 0 }, // c
{ 100, 0, 7, 0, 0 }, // d
{ 101, 0, 8, 0, 0 }, // e
{ 102, 0, 9, 0, 0 }, // f
{ 103, 0, 10, 0, 0 }, // g
{ 104, 0, 11, 0, 0 }, // h
{ 105, 0, 12, 0, 0 }, // i
{ 106, 0, 13, 0, 0 }, // j
{ 107, 0, 14, 0, 0 }, // k
{ 108, 0, 15, 0, 0 }, // l
{ 109, 0, 16, 0, 0 }, // m
{ 110, 0, 17, 0, 0 }, // n
{ 111, 0, 18, 0, 0 }, // o
{ 112, 0, 19, 0, 0 }, // p
{ 113, 0, 20, 0, 0 }, // q
{ 114, 0, 21, 0, 0 }, // r
{ 115, 0, 22, 0, 0 }, // s
{ 116, 0, 23, 0, 0 }, // t
{ 117, 0, 24, 0, 0 }, // u
{ 118, 0, 25, 0, 0 }, // v
{ 119, 0, 26, 0, 0 }, // w
{ 120, 0, 27, 0, 0 }, // x
{ 121, 0, 28, 0, 0 }, // y
{ 122, 0, 29, 0, 0 }, // z
{ 123, 64, 36, 0, 0 }, // {
{ 124, 64, 100, 0, 0 }, // |
{ 125, 64, 39, 0, 0 }, // }
{ 126, 0, 44, 64, 48 }, // ~
{ 163, 64, 32, 0, 0 }, // ?
{ 164, 2, 33, 0, 0 }, // ¤
{ 167, 0, 53, 0, 0 }, // §
{ 168, 0, 44, 0, 48 }, // ¨
{ 180, 0, 44, 0, 46 }, // ´
{ 181, 64, 16, 0, 0 }, // µ
{ 189, 2, 53, 0, 0 }, // ?
{ 192, 2, 4, 2, 46 }, // ?
{ 193, 2, 4, 0, 46 }, // Á
{ 194, 2, 4, 2, 48 }, // Â
{ 195, 2, 4, 64, 48 }, // ?
{ 196, 2, 52, 0, 0 }, // Ä
{ 197, 2, 47, 0, 0 }, // ?
{ 200, 2, 8, 2, 46 }, // ?
{ 201, 2, 8, 0, 46 }, // É
{ 202, 2, 8, 2, 48 }, // ?
{ 203, 2, 8, 0, 48 }, // Ë
{ 204, 2, 12, 2, 46 }, // ?
{ 205, 2, 12, 0, 46 }, // Í
{ 206, 2, 12, 2, 48 }, // Î
{ 207, 2, 12, 0, 48 }, // ?
{ 209, 2, 17, 64, 48 }, // ?
{ 210, 2, 18, 2, 46 }, // ?
{ 211, 2, 18, 0, 46 }, // Ó
{ 212, 2, 18, 2, 48 }, // Ô
{ 213, 2, 18, 64, 48 }, // ?
{ 214, 2, 51, 0, 0 }, // Ö
{ 217, 2, 24, 2, 46 }, // ?
{ 218, 2, 24, 0, 46 }, // Ú
{ 219, 2, 24, 2, 48 }, // ?
{ 220, 2, 24, 0, 48 }, // Ü
{ 221, 2, 28, 0, 46 }, // Ý
{ 224, 0, 4, 2, 46 }, // ?
{ 225, 0, 4, 0, 46 }, // á
{ 226, 0, 4, 2, 48 }, // â
{ 227, 0, 4, 64, 48 }, // ?
{ 228, 0, 52, 0, 0 }, // ä
{ 229, 0, 47, 0, 0 }, // ?
{ 232, 0, 8, 2, 46 }, // ?
{ 233, 0, 8, 0, 46 }, // é
{ 234, 0, 8, 2, 48 }, // ?
{ 235, 0, 8, 0, 48 }, // ë
{ 236, 0, 12, 2, 46 }, // ?
{ 237, 0, 12, 0, 46 }, // í
{ 238, 0, 12, 2, 48 }, // î
{ 239, 0, 12, 0, 48 }, // ?
{ 241, 0, 17, 64, 48 }, // ?
{ 242, 0, 18, 2, 46 }, // ?
{ 243, 0, 18, 0, 46 }, // ó
{ 244, 0, 18, 2, 48 }, // ô
{ 245, 0, 18, 64, 48 }, // ?
{ 246, 0, 51, 0, 0 }, // ö
{ 249, 0, 24, 2, 46 }, // ?
{ 250, 0, 24, 0, 46 }, // ú
{ 251, 0, 24, 2, 48 }, // ?
{ 252, 0, 24, 0, 48 }, // ü
{ 253, 0, 28, 0, 46 }, // ý
{ 255, 0, 28, 0, 48 }, // ?
{ 8364, 64, 34, 0, 0 }, //
};
public static final int LUT[][] = {
/* 0 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 1 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 2 */ { 0 , (int)'1' , 0x21 , -1 , -1 , -1 } ,
/* 3 */ { 0 , (int)'2' , 0x22 , -1 , 0x40 , -1 } ,
/* 4 */ { 0 , (int)'3' , 0x23 , -1 , 0x00a3 , -1 } ,
/* 5 */ { 0 , (int)'4' , 0x00a4 , -1 , 0x24 , -1 } ,
/* 6 */ { 0 , (int)'5' , 0x25 , -1 , 0x20ac , -1 } ,
/* 7 */ { 0 , (int)'6' , 0x26 , -1 , -1 , -1 } ,
/* 8 */ { 0 , (int)'7' , 0x002f , -1 , 0x007b , -1 } ,
/* 9 */ { 0 , (int)'8' , 0x28 , -1 , 0x005b , -1 } ,
/* 0a */ { 0 , (int)'9' , 0x29 , -1 , 0x005d , -1 } ,
/* 0b */ { 0 , (int)'0' , 0x003d , -1 , 0x007d , -1 } ,
/* 0c */ { 0 , 0x002b , 0x003f , -1 , 0x005c , -1 } ,
/* 0d */ { 0 , 0x00b4 , 0x0060 , -1 , -1 , -1 } ,
/* 0e */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 0f */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 10 */ { 1 , (int)'q' , (int)'Q' , -1 , -1 , -1 } ,
/* 11 */ { 1 , (int)'w' , (int)'W' , -1 , -1 , -1 } ,
/* 12 */ { 1 , (int)'e' , (int)'E' , -1 , 0x20ac , -1 } ,
/* 13 */ { 1 , (int)'r' , (int)'R' , -1 , -1 , -1 } ,
/* 14 */ { 1 , (int)'t' , (int)'T' , -1 , -1 , -1 } ,
/* 15 */ { 1 , (int)'y' , (int)'Y' , -1 , -1 , -1 } ,
/* 16 */ { 1 , (int)'u' , (int)'U' , -1 , -1 , -1 } ,
/* 17 */ { 1 , (int)'i' , (int)'I' , -1 , -1 , -1 } ,
/* 18 */ { 1 , (int)'o' , (int)'O' , -1 , -1 , -1 } ,
/* 19 */ { 1 , (int)'p' , (int)'P' , -1 , -1 , -1 } ,
/* 1a */ { 1 , 0x00e5 , 0x00c5 , 0x001b , -1 , -1 } ,
/* 1b */ { 0 , 0x00a8 , 0x005e , 0x001d , 0x007e , -1 } ,
/* 1c */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 1d */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 1e */ { 1 , (int)'a' , (int)'A' , -1 , -1 , -1 } ,
/* 1f */ { 1 , (int)'s' , (int)'S' , -1 , -1 , -1 } ,
/* 20 */ { 1 , (int)'d' , (int)'D' , -1 , -1 , -1 } ,
/* 21 */ { 1 , (int)'f' , (int)'F' , -1 , -1 , -1 } ,
/* 22 */ { 1 , (int)'g' , (int)'G' , -1 , -1 , -1 } ,
/* 23 */ { 1 , (int)'h' , (int)'H' , -1 , -1 , -1 } ,
/* 24 */ { 1 , (int)'j' , (int)'J' , -1 , -1 , -1 } ,
/* 25 */ { 1 , (int)'k' , (int)'K' , -1 , -1 , -1 } ,
/* 26 */ { 1 , (int)'l' , (int)'L' , -1 , -1 , -1 } ,
/* 27 */ { 1 , 0x00f6 , 0x00d6 , -1 , -1 , -1 } ,
/* 28 */ { 1 , 0x00e4 , 0x00c4 , -1 , -1 , -1 } ,
/* 29 */ { 0 , 0x00a7 , 0x00bd , 0x001c , -1 , -1 } ,
/* 2a */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 2b */ { 0 , 0x27 , 0x002a , -1 , -1 , -1 } ,
/* 2c */ { 1 , (int)'z' , (int)'Z' , -1 , -1 , -1 } ,
/* 2d */ { 1 , (int)'x' , (int)'X' , -1 , -1 , -1 } ,
/* 2e */ { 1 , (int)'c' , (int)'C' , -1 , -1 , -1 } ,
/* 2f */ { 1 , (int)'v' , (int)'V' , -1 , -1 , -1 } ,
/* 30 */ { 1 , (int)'b' , (int)'B' , -1 , -1 , -1 } ,
/* 31 */ { 1 , (int)'n' , (int)'N' , -1 , -1 , -1 } ,
/* 32 */ { 1 , (int)'m' , (int)'M' , -1 , 0x00b5 , -1 } ,
/* 33 */ { 0 , 0x002c , 0x003b , -1 , -1 , -1 } ,
/* 34 */ { 0 , 0x002e , 0x003a , -1 , -1 , -1 } ,
/* 35 */ { 0 , 0x002d , 0x005f , -1 , -1 , -1 } ,
/* 36 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 37 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 38 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 39 */ { 0 , 0x20 , 0x20 , 0x20 , -1 , -1 } ,
/* 3a */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 3b */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 3c */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 3d */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 3e */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 3f */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 40 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 41 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 42 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 43 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 44 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 45 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 46 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 47 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 48 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 49 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 4a */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 4b */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 4c */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 4d */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 4e */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 4f */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 50 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 51 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 52 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 53 */ { 0 , 0x002c , 0x002c , -1 , -1 , -1 } ,
/* 54 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 55 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 56 */ { 0 , 0x003c , 0x003e , 0x001c , 0x007c , -1 } ,
/* 57 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 58 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 59 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 5a */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 5b */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 5c */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 5d */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 5e */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 5f */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
};
public static final int DEADKEYS[] = {
0x0060, 0x00b4, 0x005e, 0x00a8, 0x007e
};
public static final int DEADKEY_LUT[][] = {
{ 0x00b4 , 0x0061 , 0x00e1 } ,
{ 0x00b4 , 0x0065 , 0x00e9 } ,
{ 0x00b4 , 0x0075 , 0x00fa } ,
{ 0x00b4 , 0x0069 , 0x00ed } ,
{ 0x00b4 , 0x0079 , 0x00fd } ,
{ 0x00b4 , 0x006f , 0x00f3 } ,
{ 0x00b4 , 0x0041 , 0x00c1 } ,
{ 0x00b4 , 0x0045 , 0x00c9 } ,
{ 0x00b4 , 0x0055 , 0x00da } ,
{ 0x00b4 , 0x0049 , 0x00cd } ,
{ 0x00b4 , 0x0059 , 0x00dd } ,
{ 0x00b4 , 0x004f , 0x00d3 } ,
{ 0x00b4 , 0x0020 , 0x00b4 } ,
{ 0x0060 , 0x0061 , 0x00e0 } ,
{ 0x0060 , 0x0065 , 0x00e8 } ,
{ 0x0060 , 0x0075 , 0x00f9 } ,
{ 0x0060 , 0x0069 , 0x00ec } ,
{ 0x0060 , 0x006f , 0x00f2 } ,
{ 0x0060 , 0x0041 , 0x00c0 } ,
{ 0x0060 , 0x0045 , 0x00c8 } ,
{ 0x0060 , 0x0055 , 0x00d9 } ,
{ 0x0060 , 0x0049 , 0x00cc } ,
{ 0x0060 , 0x004f , 0x00d2 } ,
{ 0x0060 , 0x0020 , 0x0060 } ,
{ 0x00a8 , 0x0061 , 0x00e4 } ,
{ 0x00a8 , 0x0065 , 0x00eb } ,
{ 0x00a8 , 0x0075 , 0x00fc } ,
{ 0x00a8 , 0x0069 , 0x00ef } ,
{ 0x00a8 , 0x0079 , 0x00ff } ,
{ 0x00a8 , 0x006f , 0x00f6 } ,
{ 0x00a8 , 0x0041 , 0x00c4 } ,
{ 0x00a8 , 0x0045 , 0x00cb } ,
{ 0x00a8 , 0x0055 , 0x00dc } ,
{ 0x00a8 , 0x0049 , 0x00cf } ,
{ 0x00a8 , 0x004f , 0x00d6 } ,
{ 0x00a8 , 0x0020 , 0x00a8 } ,
{ 0x005e , 0x0061 , 0x00e2 } ,
{ 0x005e , 0x0065 , 0x00ea } ,
{ 0x005e , 0x0075 , 0x00fb } ,
{ 0x005e , 0x0069 , 0x00ee } ,
{ 0x005e , 0x006f , 0x00f4 } ,
{ 0x005e , 0x0041 , 0x00c2 } ,
{ 0x005e , 0x0045 , 0x00ca } ,
{ 0x005e , 0x0055 , 0x00db } ,
{ 0x005e , 0x0049 , 0x00ce } ,
{ 0x005e , 0x004f , 0x00d4 } ,
{ 0x005e , 0x0020 , 0x005e } ,
{ 0x007e , 0x006e , 0x00f1 } ,
{ 0x007e , 0x0061 , 0x00e3 } ,
{ 0x007e , 0x006f , 0x00f5 } ,
{ 0x007e , 0x004e , 0x00d1 } ,
{ 0x007e , 0x0041 , 0x00c3 } ,
{ 0x007e , 0x004f , 0x00d5 } ,
{ 0x007e , 0x0020 , 0x007e } ,
};
private static SwedishLayout instance = new SwedishLayout();
private SwedishLayout() {
}
public static SwedishLayout getInstance() {
return instance;
}
@Override
public int[][] getLUT() {
return LUT;
}
@Override
public int[][] getFastLUT() {
return FAST_LUT;
}
@Override
public void type(String text) {
super.type(FAST_LUT, text, (byte)0);
}
@Override
public void type(String text, byte modifiers) {
super.type(FAST_LUT, text, modifiers);
}
@Override
public char getChar(int scanCode, boolean capsLock, boolean shift, boolean altGr) {
return super.getChar(LUT, scanCode, capsLock, shift, altGr);
}
@Override
public String getLocaleName() {
return LOCALE_NAME;
}
@Override
public int[][] getDeadkeyLUT() {
return DEADKEY_LUT;
}
@Override
public int[] getDeadkeys() {
return DEADKEYS;
}
}

View File

@ -0,0 +1,353 @@
package com.inputstick.api.layout;
public class SwissFrenchLayout extends KeyboardLayout {
public static final String LOCALE_NAME = "fr-CH";
//{char (16b unicode), modifier, key, deadkey_modifier, deadkey}
//fr-CH
private static final int[][] FAST_LUT = {
{ 0, 0, 0, 0, 0 }, // empty
{ 8, 2, 37, 0, 0 }, // 
{ 27, 1, 47, 0, 0 }, // 
{ 28, 1, 49, 0, 0 }, // 
{ 29, 1, 48, 0, 0 }, // 
{ 32, 0, 44, 0, 0 }, //
{ 33, 2, 48, 0, 0 }, // !
{ 34, 2, 31, 0, 0 }, // "
{ 35, 64, 32, 0, 0 }, // #
{ 36, 0, 49, 0, 0 }, // $
{ 37, 2, 34, 0, 0 }, // %
{ 38, 2, 35, 0, 0 }, // &
{ 39, 0, 45, 0, 0 }, // '
{ 41, 2, 38, 0, 0 }, // )
{ 42, 2, 32, 0, 0 }, // *
{ 43, 2, 30, 0, 0 }, // +
{ 44, 0, 54, 0, 0 }, // ,
{ 45, 0, 56, 0, 0 }, // -
{ 46, 0, 55, 0, 0 }, // .
{ 47, 2, 36, 0, 0 }, // /
{ 48, 0, 39, 0, 0 }, // 0
{ 49, 0, 30, 0, 0 }, // 1
{ 50, 0, 31, 0, 0 }, // 2
{ 51, 0, 32, 0, 0 }, // 3
{ 52, 0, 33, 0, 0 }, // 4
{ 53, 0, 34, 0, 0 }, // 5
{ 54, 0, 35, 0, 0 }, // 6
{ 55, 0, 36, 0, 0 }, // 7
{ 56, 0, 37, 0, 0 }, // 8
{ 57, 0, 38, 0, 0 }, // 9
{ 58, 2, 55, 0, 0 }, // :
{ 59, 2, 54, 0, 0 }, // ;
{ 60, 0, 100, 0, 0 }, // <
{ 61, 2, 39, 0, 0 }, // =
{ 62, 2, 100, 0, 0 }, // >
{ 63, 2, 45, 0, 0 }, // ?
{ 64, 64, 31, 0, 0 }, // @
{ 65, 2, 4, 0, 0 }, // A
{ 66, 2, 5, 0, 0 }, // B
{ 67, 2, 6, 0, 0 }, // C
{ 68, 2, 7, 0, 0 }, // D
{ 69, 2, 8, 0, 0 }, // E
{ 70, 2, 9, 0, 0 }, // F
{ 71, 2, 10, 0, 0 }, // G
{ 72, 2, 11, 0, 0 }, // H
{ 73, 2, 12, 0, 0 }, // I
{ 74, 2, 13, 0, 0 }, // J
{ 75, 2, 14, 0, 0 }, // K
{ 76, 2, 15, 0, 0 }, // L
{ 77, 2, 16, 0, 0 }, // M
{ 78, 2, 17, 0, 0 }, // N
{ 79, 2, 18, 0, 0 }, // O
{ 80, 2, 19, 0, 0 }, // P
{ 81, 2, 20, 0, 0 }, // Q
{ 82, 2, 21, 0, 0 }, // R
{ 83, 2, 22, 0, 0 }, // S
{ 84, 2, 23, 0, 0 }, // T
{ 85, 2, 24, 0, 0 }, // U
{ 86, 2, 25, 0, 0 }, // V
{ 87, 2, 26, 0, 0 }, // W
{ 88, 2, 27, 0, 0 }, // X
{ 89, 2, 29, 0, 0 }, // Y
{ 90, 2, 28, 0, 0 }, // Z
{ 91, 64, 47, 0, 0 }, // [
{ 92, 64, 100, 0, 0 }, // \
{ 93, 64, 48, 0, 0 }, // ]
{ 94, 0, 44, 0, 46 }, // ^
{ 95, 2, 56, 0, 0 }, // _
{ 96, 0, 44, 2, 46 }, // `
{ 97, 0, 4, 0, 0 }, // a
{ 98, 0, 5, 0, 0 }, // b
{ 99, 0, 6, 0, 0 }, // c
{ 100, 0, 7, 0, 0 }, // d
{ 101, 0, 8, 0, 0 }, // e
{ 102, 0, 9, 0, 0 }, // f
{ 103, 0, 10, 0, 0 }, // g
{ 104, 0, 11, 0, 0 }, // h
{ 105, 0, 12, 0, 0 }, // i
{ 106, 0, 13, 0, 0 }, // j
{ 107, 0, 14, 0, 0 }, // k
{ 108, 0, 15, 0, 0 }, // l
{ 109, 0, 16, 0, 0 }, // m
{ 110, 0, 17, 0, 0 }, // n
{ 111, 0, 18, 0, 0 }, // o
{ 112, 0, 19, 0, 0 }, // p
{ 113, 0, 20, 0, 0 }, // q
{ 114, 0, 21, 0, 0 }, // r
{ 115, 0, 22, 0, 0 }, // s
{ 116, 0, 23, 0, 0 }, // t
{ 117, 0, 24, 0, 0 }, // u
{ 118, 0, 25, 0, 0 }, // v
{ 119, 0, 26, 0, 0 }, // w
{ 120, 0, 27, 0, 0 }, // x
{ 121, 0, 29, 0, 0 }, // y
{ 122, 0, 28, 0, 0 }, // z
{ 123, 64, 52, 0, 0 }, // {
{ 124, 64, 36, 0, 0 }, // |
{ 125, 64, 49, 0, 0 }, // }
{ 126, 64, 46, 0, 0 }, // ~
{ 162, 64, 37, 0, 0 }, // ?
{ 163, 2, 49, 0, 0 }, // ?
{ 166, 64, 30, 0, 0 }, // ¦
{ 167, 64, 34, 0, 0 }, // §
{ 168, 0, 48, 0, 0 }, // ¨
{ 172, 64, 35, 0, 0 }, // ¬
{ 176, 64, 33, 0, 0 }, // °
{ 180, 0, 44, 64, 45 }, // ´
{ 192, 2, 4, 2, 46 }, // ?
{ 193, 2, 4, 64, 45 }, // Á
{ 194, 2, 4, 0, 46 }, // Â
{ 200, 2, 8, 2, 46 }, // ?
{ 201, 2, 8, 64, 45 }, // É
{ 202, 2, 8, 0, 46 }, // ?
{ 204, 2, 12, 2, 46 }, // ?
{ 205, 2, 12, 64, 45 }, // Í
{ 206, 2, 12, 0, 46 }, // Î
{ 210, 2, 18, 2, 46 }, // ?
{ 211, 2, 18, 64, 45 }, // Ó
{ 212, 2, 18, 0, 46 }, // Ô
{ 217, 2, 24, 2, 46 }, // ?
{ 218, 2, 24, 64, 45 }, // Ú
{ 219, 2, 24, 0, 46 }, // ?
{ 221, 2, 29, 64, 45 }, // Ý
{ 224, 0, 52, 0, 0 }, // ?
{ 225, 0, 4, 64, 45 }, // á
{ 226, 0, 4, 0, 46 }, // â
{ 228, 2, 52, 0, 0 }, // ä
{ 231, 2, 33, 0, 0 }, // ç
{ 232, 0, 47, 0, 0 }, // ?
{ 233, 0, 51, 0, 0 }, // é
{ 234, 0, 8, 0, 46 }, // ?
{ 236, 0, 12, 2, 46 }, // ?
{ 237, 0, 12, 64, 45 }, // í
{ 238, 0, 12, 0, 46 }, // î
{ 242, 0, 18, 2, 46 }, // ?
{ 243, 0, 18, 64, 45 }, // ó
{ 244, 0, 18, 0, 46 }, // ô
{ 246, 2, 51, 0, 0 }, // ö
{ 249, 0, 24, 2, 46 }, // ?
{ 250, 0, 24, 64, 45 }, // ú
{ 251, 0, 24, 0, 46 }, // ?
{ 252, 2, 47, 0, 0 }, // ü
{ 253, 0, 29, 64, 45 }, // ý
{ 8364, 64, 8, 0, 0 }, //
};
public static final int LUT[][] = {
/* 0 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 1 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 2 */ { 0 , (int)'1' , 0x002b , -1 , 0x00a6 , -1 } ,
/* 3 */ { 0 , (int)'2' , 0x0022 , -1 , 0x0040 , -1 } ,
/* 4 */ { 0 , (int)'3' , 0x002a , -1 , 0x0023 , -1 } ,
/* 5 */ { 0 , (int)'4' , 0x00e7 , -1 , 0x00b0 , -1 } ,
/* 6 */ { 0 , (int)'5' , 0x0025 , -1 , 0x00a7 , -1 } ,
/* 7 */ { 0 , (int)'6' , 0x0026 , -1 , 0x00ac , -1 } ,
/* 8 */ { 0 , (int)'7' , 0x002f , -1 , 0x007c , -1 } ,
/* 9 */ { 0 , (int)'8' , 0x008 , -1 , 0x00a2 , -1 } ,
/* 0a */ { 0 , (int)'9' , 0x0029 , -1 , -1 , -1 } ,
/* 0b */ { 0 , (int)'0' , 0x003d , -1 , -1 , -1 } ,
/* 0c */ { 0 , 0x0027 , 0x003f , -1 , 0x00b4 , -1 } ,
/* 0d */ { 0 , 0x005e , 0x0060 , -1 , 0x007e , -1 } ,
/* 0e */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 0f */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 10 */ { 1 , (int)'q' , (int)'Q' , -1 , -1 , -1 } ,
/* 11 */ { 1 , (int)'w' , (int)'W' , -1 , -1 , -1 } ,
/* 12 */ { 1 , (int)'e' , (int)'E' , -1 , 0x20ac , -1 } ,
/* 13 */ { 1 , (int)'r' , (int)'R' , -1 , -1 , -1 } ,
/* 14 */ { 1 , (int)'t' , (int)'T' , -1 , -1 , -1 } ,
/* 15 */ { 1 , (int)'z' , (int)'Z' , -1 , -1 , -1 } ,
/* 16 */ { 1 , (int)'u' , (int)'U' , -1 , -1 , -1 } ,
/* 17 */ { 1 , (int)'i' , (int)'I' , -1 , -1 , -1 } ,
/* 18 */ { 1 , (int)'o' , (int)'O' , -1 , -1 , -1 } ,
/* 19 */ { 1 , (int)'p' , (int)'P' , -1 , -1 , -1 } ,
/* 1a */ { 0 , 0x00e8 , 0x00fc , 0x001b , 0x005b , -1 } ,
/* 1b */ { 0 , 0x00a8 , 0x0021 , 0x001d , 0x005d , -1 } ,
/* 1c */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 1d */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 1e */ { 1 , (int)'a' , (int)'A' , -1 , -1 , -1 } ,
/* 1f */ { 1 , (int)'s' , (int)'S' , -1 , -1 , -1 } ,
/* 20 */ { 1 , (int)'d' , (int)'D' , -1 , -1 , -1 } ,
/* 21 */ { 1 , (int)'f' , (int)'F' , -1 , -1 , -1 } ,
/* 22 */ { 1 , (int)'g' , (int)'G' , -1 , -1 , -1 } ,
/* 23 */ { 1 , (int)'h' , (int)'H' , -1 , -1 , -1 } ,
/* 24 */ { 1 , (int)'j' , (int)'J' , -1 , -1 , -1 } ,
/* 25 */ { 1 , (int)'k' , (int)'K' , -1 , -1 , -1 } ,
/* 26 */ { 1 , (int)'l' , (int)'L' , -1 , -1 , -1 } ,
/* 27 */ { 0 , 0x00e9 , 0x00f6 , -1 , -1 , -1 } ,
/* 28 */ { 0 , 0x00e0 , 0x00e4 , -1 , 0x007b , -1 } ,
/* 29 */ { 0 , 0x00a7 , 0x00b0 , -1 , -1 , -1 } ,
/* 2a */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 2b */ { 0 , 0x0024 , 0x00a3 , 0x001c , 0x007d , -1 } ,
/* 2c */ { 1 , (int)'y' , (int)'Y' , -1 , -1 , -1 } ,
/* 2d */ { 1 , (int)'x' , (int)'X' , -1 , -1 , -1 } ,
/* 2e */ { 1 , (int)'c' , (int)'C' , -1 , -1 , -1 } ,
/* 2f */ { 1 , (int)'v' , (int)'V' , -1 , -1 , -1 } ,
/* 30 */ { 1 , (int)'b' , (int)'B' , -1 , -1 , -1 } ,
/* 31 */ { 1 , (int)'n' , (int)'N' , -1 , -1 , -1 } ,
/* 32 */ { 1 , (int)'m' , (int)'M' , -1 , -1 , -1 } ,
/* 33 */ { 0 , 0x002c , 0x003b , -1 , -1 , -1 } ,
/* 34 */ { 0 , 0x002e , 0x003a , -1 , -1 , -1 } ,
/* 35 */ { 0 , 0x002d , 0x005f , -1 , -1 , -1 } ,
/* 36 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 37 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 38 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 39 */ { 0 , 0x0020 , 0x0020 , 0x0020 , -1 , -1 } ,
/* 3a */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 3b */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 3c */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 3d */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 3e */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 3f */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 40 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 41 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 42 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 43 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 44 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 45 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 46 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 47 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 48 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 49 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 4a */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 4b */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 4c */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 4d */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 4e */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 4f */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 50 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 51 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 52 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 53 */ { 0 , 0x002e , 0x002e , -1 , -1 , -1 } ,
/* 54 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 55 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 56 */ { 0 , 0x003c , 0x003e , 0x001c , 0x005c , -1 } ,
/* 57 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 58 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 59 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 5a */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 5b */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 5c */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 5d */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 5e */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 5f */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
};
public static final int DEADKEYS[] = {
0x0060, 0x00b4, 0x005e
};
public static final int DEADKEY_LUT[][] = {
{ 0x00b4 , 0x0079 , 0x00fd } ,
{ 0x00b4 , 0x0061 , 0x00e1 } ,
{ 0x00b4 , 0x0065 , 0x00e9 } ,
{ 0x00b4 , 0x0075 , 0x00fa } ,
{ 0x00b4 , 0x0069 , 0x00ed } ,
{ 0x00b4 , 0x006f , 0x00f3 } ,
{ 0x00b4 , 0x0059 , 0x00dd } ,
{ 0x00b4 , 0x0041 , 0x00c1 } ,
{ 0x00b4 , 0x0045 , 0x00c9 } ,
{ 0x00b4 , 0x0055 , 0x00da } ,
{ 0x00b4 , 0x0049 , 0x00cd } ,
{ 0x00b4 , 0x004f , 0x00d3 } ,
{ 0x00b4 , 0x0020 , 0x00b4 } ,
{ 0x0060 , 0x0061 , 0x00e0 } ,
{ 0x0060 , 0x0065 , 0x00e8 } ,
{ 0x0060 , 0x0075 , 0x00f9 } ,
{ 0x0060 , 0x0069 , 0x00ec } ,
{ 0x0060 , 0x006f , 0x00f2 } ,
{ 0x0060 , 0x0041 , 0x00c0 } ,
{ 0x0060 , 0x0045 , 0x00c8 } ,
{ 0x0060 , 0x0055 , 0x00d9 } ,
{ 0x0060 , 0x0049 , 0x00cc } ,
{ 0x0060 , 0x004f , 0x00d2 } ,
{ 0x0060 , 0x0020 , 0x0060 } ,
{ 0x005e , 0x0061 , 0x00e2 } ,
{ 0x005e , 0x0065 , 0x00ea } ,
{ 0x005e , 0x0075 , 0x00fb } ,
{ 0x005e , 0x0069 , 0x00ee } ,
{ 0x005e , 0x006f , 0x00f4 } ,
{ 0x005e , 0x0041 , 0x00c2 } ,
{ 0x005e , 0x0045 , 0x00ca } ,
{ 0x005e , 0x0055 , 0x00db } ,
{ 0x005e , 0x0049 , 0x00ce } ,
{ 0x005e , 0x004f , 0x00d4 } ,
{ 0x005e , 0x0020 , 0x005e } ,
};
private static SwissFrenchLayout instance = new SwissFrenchLayout();
private SwissFrenchLayout() {
}
public static SwissFrenchLayout getInstance() {
return instance;
}
@Override
public int[][] getLUT() {
return LUT;
}
@Override
public int[][] getFastLUT() {
return FAST_LUT;
}
@Override
public void type(String text) {
super.type(FAST_LUT, text, (byte)0);
}
@Override
public void type(String text, byte modifiers) {
super.type(FAST_LUT, text, modifiers);
}
@Override
public char getChar(int scanCode, boolean capsLock, boolean shift, boolean altGr) {
return super.getChar(LUT, scanCode, capsLock, shift, altGr);
}
@Override
public String getLocaleName() {
return LOCALE_NAME;
}
@Override
public int[][] getDeadkeyLUT() {
return DEADKEY_LUT;
}
@Override
public int[] getDeadkeys() {
return DEADKEYS;
}
}

View File

@ -0,0 +1,388 @@
package com.inputstick.api.layout;
public class SwissGermanLayout extends KeyboardLayout {
public static final String LOCALE_NAME = "de-CH";
//{char (16b unicode), modifier, key, deadkey_modifier, deadkey}
//de-CH
private static final int[][] FAST_LUT = {
{ 0, 0, 0, 0, 0 }, // empty
{ 27, 1, 47, 0, 0 }, // 
{ 28, 1, 49, 0, 0 }, // 
{ 29, 1, 48, 0, 0 }, // 
{ 32, 0, 44, 0, 0 }, //
{ 33, 2, 48, 0, 0 }, // !
{ 34, 2, 31, 0, 0 }, // "
{ 35, 64, 32, 0, 0 }, // #
{ 36, 0, 49, 0, 0 }, // $
{ 37, 2, 34, 0, 0 }, // %
{ 38, 2, 35, 0, 0 }, // &
{ 39, 0, 45, 0, 0 }, // '
{ 40, 2, 37, 0, 0 }, // (
{ 41, 2, 38, 0, 0 }, // )
{ 42, 2, 32, 0, 0 }, // *
{ 43, 2, 30, 0, 0 }, // +
{ 44, 0, 54, 0, 0 }, // ,
{ 45, 0, 56, 0, 0 }, // -
{ 46, 0, 55, 0, 0 }, // .
{ 47, 2, 36, 0, 0 }, // /
{ 48, 0, 39, 0, 0 }, // 0
{ 49, 0, 30, 0, 0 }, // 1
{ 50, 0, 31, 0, 0 }, // 2
{ 51, 0, 32, 0, 0 }, // 3
{ 52, 0, 33, 0, 0 }, // 4
{ 53, 0, 34, 0, 0 }, // 5
{ 54, 0, 35, 0, 0 }, // 6
{ 55, 0, 36, 0, 0 }, // 7
{ 56, 0, 37, 0, 0 }, // 8
{ 57, 0, 38, 0, 0 }, // 9
{ 58, 2, 55, 0, 0 }, // :
{ 59, 2, 54, 0, 0 }, // ;
{ 60, 0, 100, 0, 0 }, // <
{ 61, 2, 39, 0, 0 }, // =
{ 62, 2, 100, 0, 0 }, // >
{ 63, 2, 45, 0, 0 }, // ?
{ 64, 64, 31, 0, 0 }, // @
{ 65, 2, 4, 0, 0 }, // A
{ 66, 2, 5, 0, 0 }, // B
{ 67, 2, 6, 0, 0 }, // C
{ 68, 2, 7, 0, 0 }, // D
{ 69, 2, 8, 0, 0 }, // E
{ 70, 2, 9, 0, 0 }, // F
{ 71, 2, 10, 0, 0 }, // G
{ 72, 2, 11, 0, 0 }, // H
{ 73, 2, 12, 0, 0 }, // I
{ 74, 2, 13, 0, 0 }, // J
{ 75, 2, 14, 0, 0 }, // K
{ 76, 2, 15, 0, 0 }, // L
{ 77, 2, 16, 0, 0 }, // M
{ 78, 2, 17, 0, 0 }, // N
{ 79, 2, 18, 0, 0 }, // O
{ 80, 2, 19, 0, 0 }, // P
{ 81, 2, 20, 0, 0 }, // Q
{ 82, 2, 21, 0, 0 }, // R
{ 83, 2, 22, 0, 0 }, // S
{ 84, 2, 23, 0, 0 }, // T
{ 85, 2, 24, 0, 0 }, // U
{ 86, 2, 25, 0, 0 }, // V
{ 87, 2, 26, 0, 0 }, // W
{ 88, 2, 27, 0, 0 }, // X
{ 89, 2, 29, 0, 0 }, // Y
{ 90, 2, 28, 0, 0 }, // Z
{ 91, 64, 47, 0, 0 }, // [
{ 92, 64, 100, 0, 0 }, // \
{ 93, 64, 48, 0, 0 }, // ]
{ 94, 0, 44, 0, 46 }, // ^
{ 95, 2, 56, 0, 0 }, // _
{ 96, 0, 44, 2, 46 }, // `
{ 97, 0, 4, 0, 0 }, // a
{ 98, 0, 5, 0, 0 }, // b
{ 99, 0, 6, 0, 0 }, // c
{ 100, 0, 7, 0, 0 }, // d
{ 101, 0, 8, 0, 0 }, // e
{ 102, 0, 9, 0, 0 }, // f
{ 103, 0, 10, 0, 0 }, // g
{ 104, 0, 11, 0, 0 }, // h
{ 105, 0, 12, 0, 0 }, // i
{ 106, 0, 13, 0, 0 }, // j
{ 107, 0, 14, 0, 0 }, // k
{ 108, 0, 15, 0, 0 }, // l
{ 109, 0, 16, 0, 0 }, // m
{ 110, 0, 17, 0, 0 }, // n
{ 111, 0, 18, 0, 0 }, // o
{ 112, 0, 19, 0, 0 }, // p
{ 113, 0, 20, 0, 0 }, // q
{ 114, 0, 21, 0, 0 }, // r
{ 115, 0, 22, 0, 0 }, // s
{ 116, 0, 23, 0, 0 }, // t
{ 117, 0, 24, 0, 0 }, // u
{ 118, 0, 25, 0, 0 }, // v
{ 119, 0, 26, 0, 0 }, // w
{ 120, 0, 27, 0, 0 }, // x
{ 121, 0, 29, 0, 0 }, // y
{ 122, 0, 28, 0, 0 }, // z
{ 123, 64, 52, 0, 0 }, // {
{ 124, 64, 36, 0, 0 }, // |
{ 125, 64, 49, 0, 0 }, // }
{ 126, 0, 44, 64, 46 }, // ~
{ 162, 64, 37, 0, 0 }, // ?
{ 163, 2, 49, 0, 0 }, // ?
{ 166, 64, 30, 0, 0 }, // ¦
{ 167, 64, 34, 0, 0 }, // §
{ 168, 0, 44, 0, 48 }, // ¨
{ 172, 64, 35, 0, 0 }, // ¬
{ 176, 64, 33, 0, 0 }, // °
{ 180, 0, 44, 64, 45 }, // ´
{ 192, 2, 4, 2, 46 }, // ?
{ 193, 2, 4, 64, 45 }, // Á
{ 194, 2, 4, 0, 46 }, // Â
{ 195, 2, 4, 64, 46 }, // ?
{ 196, 2, 4, 0, 48 }, // Ä
{ 200, 2, 8, 2, 46 }, // ?
{ 201, 2, 8, 64, 45 }, // É
{ 202, 2, 8, 0, 46 }, // ?
{ 203, 2, 8, 0, 48 }, // Ë
{ 204, 2, 12, 2, 46 }, // ?
{ 205, 2, 12, 64, 45 }, // Í
{ 206, 2, 12, 0, 46 }, // Î
{ 207, 2, 12, 0, 48 }, // ?
{ 209, 2, 17, 64, 46 }, // ?
{ 210, 2, 18, 2, 46 }, // ?
{ 211, 2, 18, 64, 45 }, // Ó
{ 212, 2, 18, 0, 46 }, // Ô
{ 213, 2, 18, 64, 46 }, // ?
{ 214, 2, 18, 0, 48 }, // Ö
{ 217, 2, 24, 2, 46 }, // ?
{ 218, 2, 24, 64, 45 }, // Ú
{ 219, 2, 24, 0, 46 }, // ?
{ 220, 2, 24, 0, 48 }, // Ü
{ 221, 2, 29, 64, 45 }, // Ý
{ 224, 2, 52, 0, 0 }, // ?
{ 225, 0, 4, 64, 45 }, // á
{ 226, 0, 4, 0, 46 }, // â
{ 227, 0, 4, 64, 46 }, // ?
{ 228, 0, 52, 0, 0 }, // ä
{ 231, 2, 33, 0, 0 }, // ç
{ 232, 2, 47, 0, 0 }, // ?
{ 233, 2, 51, 0, 0 }, // é
{ 234, 0, 8, 0, 46 }, // ?
{ 235, 0, 8, 0, 48 }, // ë
{ 236, 0, 12, 2, 46 }, // ?
{ 237, 0, 12, 64, 45 }, // í
{ 238, 0, 12, 0, 46 }, // î
{ 239, 0, 12, 0, 48 }, // ?
{ 241, 0, 17, 64, 46 }, // ?
{ 242, 0, 18, 2, 46 }, // ?
{ 243, 0, 18, 64, 45 }, // ó
{ 244, 0, 18, 0, 46 }, // ô
{ 245, 0, 18, 64, 46 }, // ?
{ 246, 0, 51, 0, 0 }, // ö
{ 249, 0, 24, 2, 46 }, // ?
{ 250, 0, 24, 64, 45 }, // ú
{ 251, 0, 24, 0, 46 }, // ?
{ 252, 0, 47, 0, 0 }, // ü
{ 253, 0, 29, 64, 45 }, // ý
{ 255, 0, 29, 0, 48 }, // ?
{ 8364, 64, 8, 0, 0 }, //
};
public static final int LUT[][] = {
/* 0 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 1 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 2 */ { 0 , (int)'1' , 0x002b , -1 , 0x00a6 , -1 } ,
/* 3 */ { 0 , (int)'2' , 0x0022 , -1 , 0x0040 , -1 } ,
/* 4 */ { 0 , (int)'3' , 0x002a , -1 , 0x0023 , -1 } ,
/* 5 */ { 0 , (int)'4' , 0x00e7 , -1 , 0x00b0 , -1 } ,
/* 6 */ { 0 , (int)'5' , 0x0025 , -1 , 0x00a7 , -1 } ,
/* 7 */ { 0 , (int)'6' , 0x0026 , -1 , 0x00ac , -1 } ,
/* 8 */ { 0 , (int)'7' , 0x002f , -1 , 0x007c , -1 } ,
/* 9 */ { 0 , (int)'8' , 0x0028 , -1 , 0x00a2 , -1 } ,
/* 0a */ { 0 , (int)'9' , 0x0029 , -1 , -1 , -1 } ,
/* 0b */ { 0 , (int)'0' , 0x003d , -1 , -1 , -1 } ,
/* 0c */ { 0 , 0x0027 , 0x003f , -1 , 0x00b4 , -1 } ,
/* 0d */ { 0 , 0x005e , 0x0060 , -1 , 0x007e , -1 } ,
/* 0e */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 0f */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 10 */ { 1 , (int)'q' , (int)'Q' , -1 , -1 , -1 } ,
/* 11 */ { 1 , (int)'w' , (int)'W' , -1 , -1 , -1 } ,
/* 12 */ { 1 , (int)'e' , (int)'E' , -1 , 0x20ac , -1 } ,
/* 13 */ { 1 , (int)'r' , (int)'R' , -1 , -1 , -1 } ,
/* 14 */ { 1 , (int)'t' , (int)'T' , -1 , -1 , -1 } ,
/* 15 */ { 1 , (int)'z' , (int)'Z' , -1 , -1 , -1 } ,
/* 16 */ { 1 , (int)'u' , (int)'U' , -1 , -1 , -1 } ,
/* 17 */ { 1 , (int)'i' , (int)'I' , -1 , -1 , -1 } ,
/* 18 */ { 1 , (int)'o' , (int)'O' , -1 , -1 , -1 } ,
/* 19 */ { 1 , (int)'p' , (int)'P' , -1 , -1 , -1 } ,
/* 1a */ { 0 , 0x00fc , 0x00e8 , 0x001b , 0x005b , -1 } , // TODO SGCap
/* 1b */ { 0 , 0x00a8 , 0x0021 , 0x001d , 0x005d , -1 } ,
/* 1c */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 1d */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 1e */ { 1 , (int)'a' , (int)'A' , -1 , -1 , -1 } ,
/* 1f */ { 1 , (int)'s' , (int)'S' , -1 , -1 , -1 } ,
/* 20 */ { 1 , (int)'d' , (int)'D' , -1 , -1 , -1 } ,
/* 21 */ { 1 , (int)'f' , (int)'F' , -1 , -1 , -1 } ,
/* 22 */ { 1 , (int)'g' , (int)'G' , -1 , -1 , -1 } ,
/* 23 */ { 1 , (int)'h' , (int)'H' , -1 , -1 , -1 } ,
/* 24 */ { 1 , (int)'j' , (int)'J' , -1 , -1 , -1 } ,
/* 25 */ { 1 , (int)'k' , (int)'K' , -1 , -1 , -1 } ,
/* 26 */ { 1 , (int)'l' , (int)'L' , -1 , -1 , -1 } ,
/* 27 */ { 0 , 0x00f6 , 0x00e9 , -1 , -1 , -1 } , // TODO SGCap
/* 28 */ { 0 , 0x00e4 , 0x00e0 , -1 , 0x007b , -1 } , // TODO SGCap
/* 29 */ { 0 , 0x00a7 , 0x00b0 , -1 , -1 , -1 } ,
/* 2a */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 2b */ { 0 , 0x0024 , 0x00a3 , 0x001c , 0x007d , -1 } ,
/* 2c */ { 1 , (int)'y' , (int)'Y' , -1 , -1 , -1 } ,
/* 2d */ { 1 , (int)'x' , (int)'X' , -1 , -1 , -1 } ,
/* 2e */ { 1 , (int)'c' , (int)'C' , -1 , -1 , -1 } ,
/* 2f */ { 1 , (int)'v' , (int)'V' , -1 , -1 , -1 } ,
/* 30 */ { 1 , (int)'b' , (int)'B' , -1 , -1 , -1 } ,
/* 31 */ { 1 , (int)'n' , (int)'N' , -1 , -1 , -1 } ,
/* 32 */ { 1 , (int)'m' , (int)'M' , -1 , -1 , -1 } ,
/* 33 */ { 0 , 0x002c , 0x003b , -1 , -1 , -1 } ,
/* 34 */ { 0 , 0x002e , 0x003a , -1 , -1 , -1 } ,
/* 35 */ { 0 , 0x002d , 0x005f , -1 , -1 , -1 } ,
/* 36 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 37 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 38 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 39 */ { 0 , 0x0020 , 0x0020 , 0x0020 , -1 , -1 } ,
/* 3a */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 3b */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 3c */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 3d */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 3e */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 3f */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 40 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 41 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 42 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 43 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 44 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 45 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 46 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 47 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 48 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 49 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 4a */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 4b */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 4c */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 4d */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 4e */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 4f */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 50 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 51 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 52 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 53 */ { 0 , 0x002e , 0x002e , -1 , -1 , -1 } ,
/* 54 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 55 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 56 */ { 0 , 0x003c , 0x003e , 0x001c , 0x005c , -1 } ,
/* 57 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 58 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 59 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 5a */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 5b */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 5c */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 5d */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 5e */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 5f */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
};
public static final int DEADKEYS[] = {
0x00b4, 0x005e, 0x0060, 0x007e, 0x00a8
};
public static final int DEADKEY_LUT[][] = {
{ 0x00b4 , 0x0079 , 0x00fd } ,
{ 0x00b4 , 0x0061 , 0x00e1 } ,
{ 0x00b4 , 0x0065 , 0x00e9 } ,
{ 0x00b4 , 0x0075 , 0x00fa } ,
{ 0x00b4 , 0x0069 , 0x00ed } ,
{ 0x00b4 , 0x006f , 0x00f3 } ,
{ 0x00b4 , 0x0059 , 0x00dd } ,
{ 0x00b4 , 0x0041 , 0x00c1 } ,
{ 0x00b4 , 0x0045 , 0x00c9 } ,
{ 0x00b4 , 0x0055 , 0x00da } ,
{ 0x00b4 , 0x0049 , 0x00cd } ,
{ 0x00b4 , 0x004f , 0x00d3 } ,
{ 0x00b4 , 0x0020 , 0x00b4 } ,
{ 0x005e , 0x0061 , 0x00e2 } ,
{ 0x005e , 0x0065 , 0x00ea } ,
{ 0x005e , 0x0075 , 0x00fb } ,
{ 0x005e , 0x0069 , 0x00ee } ,
{ 0x005e , 0x006f , 0x00f4 } ,
{ 0x005e , 0x0041 , 0x00c2 } ,
{ 0x005e , 0x0045 , 0x00ca } ,
{ 0x005e , 0x0055 , 0x00db } ,
{ 0x005e , 0x0049 , 0x00ce } ,
{ 0x005e , 0x004f , 0x00d4 } ,
{ 0x005e , 0x0020 , 0x005e } ,
{ 0x0060 , 0x0061 , 0x00e0 } ,
{ 0x0060 , 0x0065 , 0x00e8 } ,
{ 0x0060 , 0x0075 , 0x00f9 } ,
{ 0x0060 , 0x0069 , 0x00ec } ,
{ 0x0060 , 0x006f , 0x00f2 } ,
{ 0x0060 , 0x0041 , 0x00c0 } ,
{ 0x0060 , 0x0045 , 0x00c8 } ,
{ 0x0060 , 0x0055 , 0x00d9 } ,
{ 0x0060 , 0x0049 , 0x00cc } ,
{ 0x0060 , 0x004f , 0x00d2 } ,
{ 0x0060 , 0x0020 , 0x0060 } ,
{ 0x007e , 0x006e , 0x00f1 } ,
{ 0x007e , 0x0061 , 0x00e3 } ,
{ 0x007e , 0x006f , 0x00f5 } ,
{ 0x007e , 0x004e , 0x00d1 } ,
{ 0x007e , 0x0041 , 0x00c3 } ,
{ 0x007e , 0x004f , 0x00d5 } ,
{ 0x007e , 0x0020 , 0x007e } ,
{ 0x00a8 , 0x0079 , 0x00ff } ,
{ 0x00a8 , 0x0061 , 0x00e4 } ,
{ 0x00a8 , 0x0065 , 0x00eb } ,
{ 0x00a8 , 0x0075 , 0x00fc } ,
{ 0x00a8 , 0x0069 , 0x00ef } ,
{ 0x00a8 , 0x006f , 0x00f6 } ,
{ 0x00a8 , 0x0041 , 0x00c4 } ,
{ 0x00a8 , 0x0045 , 0x00cb } ,
{ 0x00a8 , 0x0055 , 0x00dc } ,
{ 0x00a8 , 0x0049 , 0x00cf } ,
{ 0x00a8 , 0x004f , 0x00d6 } ,
{ 0x00a8 , 0x0020 , 0x00a8 } ,
};
private static SwissGermanLayout instance = new SwissGermanLayout();
private SwissGermanLayout() {
}
public static SwissGermanLayout getInstance() {
return instance;
}
@Override
public int[][] getLUT() {
return LUT;
}
@Override
public int[][] getFastLUT() {
return FAST_LUT;
}
@Override
public void type(String text) {
super.type(FAST_LUT, text, (byte)0);
}
@Override
public void type(String text, byte modifiers) {
super.type(FAST_LUT, text, modifiers);
}
@Override
public char getChar(int scanCode, boolean capsLock, boolean shift, boolean altGr) {
return super.getChar(LUT, scanCode, capsLock, shift, altGr);
}
@Override
public String getLocaleName() {
return LOCALE_NAME;
}
@Override
public int[][] getDeadkeyLUT() {
return DEADKEY_LUT;
}
@Override
public int[] getDeadkeys() {
return DEADKEYS;
}
}

View File

@ -0,0 +1,283 @@
package com.inputstick.api.layout;
public class UnitedKingdomLayout extends KeyboardLayout {
public static final String LOCALE_NAME = "en-GB";
//{char (16b unicode), modifier, key, deadkey_modifier, deadkey}
//en-GB
private static final int[][] FAST_LUT = {
{ 0, 0, 0, 0, 0 }, // empty
{ 27, 1, 47, 0, 0 }, // 
{ 28, 1, 49, 0, 0 }, // 
{ 29, 1, 48, 0, 0 }, // 
{ 32, 0, 44, 0, 0 }, //
{ 33, 2, 30, 0, 0 }, // !
{ 34, 2, 31, 0, 0 }, // "
{ 35, 0, 49, 0, 0 }, // #
{ 36, 2, 33, 0, 0 }, // $
{ 37, 2, 34, 0, 0 }, // %
{ 38, 2, 36, 0, 0 }, // &
{ 39, 0, 52, 0, 0 }, // '
{ 40, 2, 38, 0, 0 }, // (
{ 41, 2, 39, 0, 0 }, // )
{ 42, 2, 37, 0, 0 }, // *
{ 43, 2, 46, 0, 0 }, // +
{ 44, 0, 54, 0, 0 }, // ,
{ 45, 0, 45, 0, 0 }, // -
{ 46, 0, 55, 0, 0 }, // .
{ 47, 0, 56, 0, 0 }, // /
{ 48, 0, 39, 0, 0 }, // 0
{ 49, 0, 30, 0, 0 }, // 1
{ 50, 0, 31, 0, 0 }, // 2
{ 51, 0, 32, 0, 0 }, // 3
{ 52, 0, 33, 0, 0 }, // 4
{ 53, 0, 34, 0, 0 }, // 5
{ 54, 0, 35, 0, 0 }, // 6
{ 55, 0, 36, 0, 0 }, // 7
{ 56, 0, 37, 0, 0 }, // 8
{ 57, 0, 38, 0, 0 }, // 9
{ 58, 2, 51, 0, 0 }, // :
{ 59, 0, 51, 0, 0 }, // ;
{ 60, 2, 54, 0, 0 }, // <
{ 61, 0, 46, 0, 0 }, // =
{ 62, 2, 55, 0, 0 }, // >
{ 63, 2, 56, 0, 0 }, // ?
{ 64, 2, 52, 0, 0 }, // @
{ 65, 2, 4, 0, 0 }, // A
{ 66, 2, 5, 0, 0 }, // B
{ 67, 2, 6, 0, 0 }, // C
{ 68, 2, 7, 0, 0 }, // D
{ 69, 2, 8, 0, 0 }, // E
{ 70, 2, 9, 0, 0 }, // F
{ 71, 2, 10, 0, 0 }, // G
{ 72, 2, 11, 0, 0 }, // H
{ 73, 2, 12, 0, 0 }, // I
{ 74, 2, 13, 0, 0 }, // J
{ 75, 2, 14, 0, 0 }, // K
{ 76, 2, 15, 0, 0 }, // L
{ 77, 2, 16, 0, 0 }, // M
{ 78, 2, 17, 0, 0 }, // N
{ 79, 2, 18, 0, 0 }, // O
{ 80, 2, 19, 0, 0 }, // P
{ 81, 2, 20, 0, 0 }, // Q
{ 82, 2, 21, 0, 0 }, // R
{ 83, 2, 22, 0, 0 }, // S
{ 84, 2, 23, 0, 0 }, // T
{ 85, 2, 24, 0, 0 }, // U
{ 86, 2, 25, 0, 0 }, // V
{ 87, 2, 26, 0, 0 }, // W
{ 88, 2, 27, 0, 0 }, // X
{ 89, 2, 28, 0, 0 }, // Y
{ 90, 2, 29, 0, 0 }, // Z
{ 91, 0, 47, 0, 0 }, // [
{ 92, 0, 100, 0, 0 }, // \
{ 93, 0, 48, 0, 0 }, // ]
{ 94, 2, 35, 0, 0 }, // ^
{ 95, 2, 45, 0, 0 }, // _
{ 96, 0, 53, 0, 0 }, // `
{ 97, 0, 4, 0, 0 }, // a
{ 98, 0, 5, 0, 0 }, // b
{ 99, 0, 6, 0, 0 }, // c
{ 100, 0, 7, 0, 0 }, // d
{ 101, 0, 8, 0, 0 }, // e
{ 102, 0, 9, 0, 0 }, // f
{ 103, 0, 10, 0, 0 }, // g
{ 104, 0, 11, 0, 0 }, // h
{ 105, 0, 12, 0, 0 }, // i
{ 106, 0, 13, 0, 0 }, // j
{ 107, 0, 14, 0, 0 }, // k
{ 108, 0, 15, 0, 0 }, // l
{ 109, 0, 16, 0, 0 }, // m
{ 110, 0, 17, 0, 0 }, // n
{ 111, 0, 18, 0, 0 }, // o
{ 112, 0, 19, 0, 0 }, // p
{ 113, 0, 20, 0, 0 }, // q
{ 114, 0, 21, 0, 0 }, // r
{ 115, 0, 22, 0, 0 }, // s
{ 116, 0, 23, 0, 0 }, // t
{ 117, 0, 24, 0, 0 }, // u
{ 118, 0, 25, 0, 0 }, // v
{ 119, 0, 26, 0, 0 }, // w
{ 120, 0, 27, 0, 0 }, // x
{ 121, 0, 28, 0, 0 }, // y
{ 122, 0, 29, 0, 0 }, // z
{ 123, 2, 47, 0, 0 }, // {
{ 124, 2, 100, 0, 0 }, // |
{ 125, 2, 48, 0, 0 }, // }
{ 126, 2, 49, 0, 0 }, // ~
{ 163, 2, 32, 0, 0 }, // ?
{ 166, 64, 53, 0, 0 }, // ¦
{ 172, 2, 53, 0, 0 }, // ¬
{ 193, 66, 4, 0, 0 }, // Á
{ 201, 66, 8, 0, 0 }, // É
{ 205, 66, 12, 0, 0 }, // Í
{ 211, 66, 18, 0, 0 }, // Ó
{ 218, 66, 24, 0, 0 }, // Ú
{ 225, 64, 4, 0, 0 }, // á
{ 233, 64, 8, 0, 0 }, // é
{ 237, 64, 12, 0, 0 }, // í
{ 243, 64, 18, 0, 0 }, // ó
{ 250, 64, 24, 0, 0 }, // ú
{ 8364, 64, 33, 0, 0 }, //
};
public static final int LUT[][] = {
/* 0 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 1 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 2 */ { 0 , (int)'1' , 0x21 , -1 , -1 , -1 } ,
/* 3 */ { 0 , (int)'2' , 0x22 , -1 , -1 , -1 } ,
/* 4 */ { 0 , (int)'3' , 0x00a3 , -1 , -1 , -1 } ,
/* 5 */ { 0 , (int)'4' , 0x24 , -1 , 0x20ac , -1 } ,
/* 6 */ { 0 , (int)'5' , 0x25 , -1 , -1 , -1 } ,
/* 7 */ { 0 , (int)'6' , 0x005e , -1 , -1 , -1 } ,
/* 8 */ { 0 , (int)'7' , 0x26 , -1 , -1 , -1 } ,
/* 9 */ { 0 , (int)'8' , 0x002a , -1 , -1 , -1 } ,
/* 0a */ { 0 , (int)'9' , 0x28 , -1 , -1 , -1 } ,
/* 0b */ { 0 , (int)'0' , 0x29 , -1 , -1 , -1 } ,
/* 0c */ { 0 , 0x002d , 0x005f , -1 , -1 , -1 } ,
/* 0d */ { 0 , 0x003d , 0x002b , -1 , -1 , -1 } ,
/* 0e */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 0f */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 10 */ { 1 , (int)'q' , (int)'Q' , -1 , -1 , -1 } ,
/* 11 */ { 1 , (int)'w' , (int)'W' , -1 , -1 , -1 } ,
/* 12 */ { 5 , (int)'e' , (int)'E' , -1 , 0x00e9 , 0x00c9 } ,
/* 13 */ { 1 , (int)'r' , (int)'R' , -1 , -1 , -1 } ,
/* 14 */ { 1 , (int)'t' , (int)'T' , -1 , -1 , -1 } ,
/* 15 */ { 1 , (int)'y' , (int)'Y' , -1 , -1 , -1 } ,
/* 16 */ { 5 , (int)'u' , (int)'U' , -1 , 0x00fa , 0x00da } ,
/* 17 */ { 5 , (int)'i' , (int)'I' , -1 , 0x00ed , 0x00cd } ,
/* 18 */ { 5 , (int)'o' , (int)'O' , -1 , 0x00f3 , 0x00d3 } ,
/* 19 */ { 1 , (int)'p' , (int)'P' , -1 , -1 , -1 } ,
/* 1a */ { 0 , 0x005b , 0x007b , 0x001b , -1 , -1 } ,
/* 1b */ { 0 , 0x005d , 0x007d , 0x001d , -1 , -1 } ,
/* 1c */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 1d */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 1e */ { 5 , (int)'a' , (int)'A' , -1 , 0x00e1 , 0x00c1 } ,
/* 1f */ { 1 , (int)'s' , (int)'S' , -1 , -1 , -1 } ,
/* 20 */ { 1 , (int)'d' , (int)'D' , -1 , -1 , -1 } ,
/* 21 */ { 1 , (int)'f' , (int)'F' , -1 , -1 , -1 } ,
/* 22 */ { 1 , (int)'g' , (int)'G' , -1 , -1 , -1 } ,
/* 23 */ { 1 , (int)'h' , (int)'H' , -1 , -1 , -1 } ,
/* 24 */ { 1 , (int)'j' , (int)'J' , -1 , -1 , -1 } ,
/* 25 */ { 1 , (int)'k' , (int)'K' , -1 , -1 , -1 } ,
/* 26 */ { 1 , (int)'l' , (int)'L' , -1 , -1 , -1 } ,
/* 27 */ { 0 , 0x003b , 0x003a , -1 , -1 , -1 } ,
/* 28 */ { 0 , 0x27 , 0x40 , -1 , -1 , -1 } ,
/* 29 */ { 0 , 0x60 , 0x00ac , -1 , 0x00a6 , -1 } ,
/* 2a */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 2b */ { 0 , 0x23 , 0x007e , 0x001c , -1 , -1 } ,
/* 2c */ { 1 , (int)'z' , (int)'Z' , -1 , -1 , -1 } ,
/* 2d */ { 1 , (int)'x' , (int)'X' , -1 , -1 , -1 } ,
/* 2e */ { 1 , (int)'c' , (int)'C' , -1 , -1 , -1 } ,
/* 2f */ { 1 , (int)'v' , (int)'V' , -1 , -1 , -1 } ,
/* 30 */ { 1 , (int)'b' , (int)'B' , -1 , -1 , -1 } ,
/* 31 */ { 1 , (int)'n' , (int)'N' , -1 , -1 , -1 } ,
/* 32 */ { 1 , (int)'m' , (int)'M' , -1 , -1 , -1 } ,
/* 33 */ { 0 , 0x002c , 0x003c , -1 , -1 , -1 } ,
/* 34 */ { 0 , 0x002e , 0x003e , -1 , -1 , -1 } ,
/* 35 */ { 0 , 0x002f , 0x003f , -1 , -1 , -1 } ,
/* 36 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 37 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 38 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 39 */ { 0 , 0x20 , 0x20 , 0x20 , -1 , -1 } ,
/* 3a */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 3b */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 3c */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 3d */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 3e */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 3f */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 40 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 41 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 42 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 43 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 44 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 45 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 46 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 47 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 48 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 49 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 4a */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 4b */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 4c */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 4d */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 4e */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 4f */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 50 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 51 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 52 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 53 */ { 0 , 0x002e , 0x002e , -1 , -1 , -1 } ,
/* 54 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 55 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 56 */ { 0 , 0x005c , 0x007c , 0x001c , -1 , -1 } ,
/* 57 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 58 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 59 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 5a */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 5b */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 5c */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 5d */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 5e */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 5f */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
};
public static final int DEADKEYS[] = null;
public static final int DEADKEY_LUT[][] = null;
private static UnitedKingdomLayout instance = new UnitedKingdomLayout();
private UnitedKingdomLayout() {
}
public static UnitedKingdomLayout getInstance() {
return instance;
}
@Override
public int[][] getLUT() {
return LUT;
}
@Override
public int[][] getFastLUT() {
return FAST_LUT;
}
@Override
public void type(String text) {
super.type(FAST_LUT, text, (byte)0);
}
@Override
public void type(String text, byte modifiers) {
super.type(FAST_LUT, text, modifiers);
}
@Override
public char getChar(int scanCode, boolean capsLock, boolean shift, boolean altGr) {
return super.getChar(LUT, scanCode, capsLock, shift, altGr);
}
@Override
public String getLocaleName() {
return LOCALE_NAME;
}
@Override
public int[][] getDeadkeyLUT() {
return DEADKEY_LUT;
}
@Override
public int[] getDeadkeys() {
return DEADKEYS;
}
}

View File

@ -0,0 +1,268 @@
package com.inputstick.api.layout;
public class UnitedStatesLayout extends KeyboardLayout {
public static final String LOCALE_NAME = "en-US";
//{char (16b unicode), modifier, key, deadkey_modifier, deadkey}
//en-US
private static final int[][] FAST_LUT = {
{ 0, 0, 0, 0, 0 }, // empty
{ 27, 1, 47, 0, 0 }, // 
{ 28, 1, 49, 0, 0 }, // 
{ 29, 1, 48, 0, 0 }, // 
{ 32, 0, 44, 0, 0 }, //
{ 33, 2, 30, 0, 0 }, // !
{ 34, 2, 52, 0, 0 }, // "
{ 35, 2, 32, 0, 0 }, // #
{ 36, 2, 33, 0, 0 }, // $
{ 37, 2, 34, 0, 0 }, // %
{ 38, 2, 36, 0, 0 }, // &
{ 39, 0, 52, 0, 0 }, // '
{ 40, 2, 38, 0, 0 }, // (
{ 41, 2, 39, 0, 0 }, // )
{ 42, 2, 37, 0, 0 }, // *
{ 43, 2, 46, 0, 0 }, // +
{ 44, 0, 54, 0, 0 }, // ,
{ 45, 0, 45, 0, 0 }, // -
{ 46, 0, 55, 0, 0 }, // .
{ 47, 0, 56, 0, 0 }, // /
{ 48, 0, 39, 0, 0 }, // 0
{ 49, 0, 30, 0, 0 }, // 1
{ 50, 0, 31, 0, 0 }, // 2
{ 51, 0, 32, 0, 0 }, // 3
{ 52, 0, 33, 0, 0 }, // 4
{ 53, 0, 34, 0, 0 }, // 5
{ 54, 0, 35, 0, 0 }, // 6
{ 55, 0, 36, 0, 0 }, // 7
{ 56, 0, 37, 0, 0 }, // 8
{ 57, 0, 38, 0, 0 }, // 9
{ 58, 2, 51, 0, 0 }, // :
{ 59, 0, 51, 0, 0 }, // ;
{ 60, 2, 54, 0, 0 }, // <
{ 61, 0, 46, 0, 0 }, // =
{ 62, 2, 55, 0, 0 }, // >
{ 63, 2, 56, 0, 0 }, // ?
{ 64, 2, 31, 0, 0 }, // @
{ 65, 2, 4, 0, 0 }, // A
{ 66, 2, 5, 0, 0 }, // B
{ 67, 2, 6, 0, 0 }, // C
{ 68, 2, 7, 0, 0 }, // D
{ 69, 2, 8, 0, 0 }, // E
{ 70, 2, 9, 0, 0 }, // F
{ 71, 2, 10, 0, 0 }, // G
{ 72, 2, 11, 0, 0 }, // H
{ 73, 2, 12, 0, 0 }, // I
{ 74, 2, 13, 0, 0 }, // J
{ 75, 2, 14, 0, 0 }, // K
{ 76, 2, 15, 0, 0 }, // L
{ 77, 2, 16, 0, 0 }, // M
{ 78, 2, 17, 0, 0 }, // N
{ 79, 2, 18, 0, 0 }, // O
{ 80, 2, 19, 0, 0 }, // P
{ 81, 2, 20, 0, 0 }, // Q
{ 82, 2, 21, 0, 0 }, // R
{ 83, 2, 22, 0, 0 }, // S
{ 84, 2, 23, 0, 0 }, // T
{ 85, 2, 24, 0, 0 }, // U
{ 86, 2, 25, 0, 0 }, // V
{ 87, 2, 26, 0, 0 }, // W
{ 88, 2, 27, 0, 0 }, // X
{ 89, 2, 28, 0, 0 }, // Y
{ 90, 2, 29, 0, 0 }, // Z
{ 91, 0, 47, 0, 0 }, // [
{ 92, 0, 49, 0, 0 }, // \
{ 93, 0, 48, 0, 0 }, // ]
{ 94, 2, 35, 0, 0 }, // ^
{ 95, 2, 45, 0, 0 }, // _
{ 96, 0, 53, 0, 0 }, // `
{ 97, 0, 4, 0, 0 }, // a
{ 98, 0, 5, 0, 0 }, // b
{ 99, 0, 6, 0, 0 }, // c
{ 100, 0, 7, 0, 0 }, // d
{ 101, 0, 8, 0, 0 }, // e
{ 102, 0, 9, 0, 0 }, // f
{ 103, 0, 10, 0, 0 }, // g
{ 104, 0, 11, 0, 0 }, // h
{ 105, 0, 12, 0, 0 }, // i
{ 106, 0, 13, 0, 0 }, // j
{ 107, 0, 14, 0, 0 }, // k
{ 108, 0, 15, 0, 0 }, // l
{ 109, 0, 16, 0, 0 }, // m
{ 110, 0, 17, 0, 0 }, // n
{ 111, 0, 18, 0, 0 }, // o
{ 112, 0, 19, 0, 0 }, // p
{ 113, 0, 20, 0, 0 }, // q
{ 114, 0, 21, 0, 0 }, // r
{ 115, 0, 22, 0, 0 }, // s
{ 116, 0, 23, 0, 0 }, // t
{ 117, 0, 24, 0, 0 }, // u
{ 118, 0, 25, 0, 0 }, // v
{ 119, 0, 26, 0, 0 }, // w
{ 120, 0, 27, 0, 0 }, // x
{ 121, 0, 28, 0, 0 }, // y
{ 122, 0, 29, 0, 0 }, // z
{ 123, 2, 47, 0, 0 }, // {
{ 124, 2, 49, 0, 0 }, // |
{ 125, 2, 48, 0, 0 }, // }
{ 126, 2, 53, 0, 0 }, // ~
};
public static final int LUT[][] = {
/* 0 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 1 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 2 */ { 0 , (int)'1' , 0x21 , -1 , -1 , -1 } ,
/* 3 */ { 0 , (int)'2' , 0x40 , -1 , -1 , -1 } ,
/* 4 */ { 0 , (int)'3' , 0x23 , -1 , -1 , -1 } ,
/* 5 */ { 0 , (int)'4' , 0x24 , -1 , -1 , -1 } ,
/* 6 */ { 0 , (int)'5' , 0x25 , -1 , -1 , -1 } ,
/* 7 */ { 0 , (int)'6' , 0x005e , -1 , -1 , -1 } ,
/* 8 */ { 0 , (int)'7' , 0x26 , -1 , -1 , -1 } ,
/* 9 */ { 0 , (int)'8' , 0x002a , -1 , -1 , -1 } ,
/* 0a */ { 0 , (int)'9' , 0x28 , -1 , -1 , -1 } ,
/* 0b */ { 0 , (int)'0' , 0x29 , -1 , -1 , -1 } ,
/* 0c */ { 0 , 0x002d , 0x005f , -1 , -1 , -1 } ,
/* 0d */ { 0 , 0x003d , 0x002b , -1 , -1 , -1 } ,
/* 0e */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 0f */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 10 */ { 1 , (int)'q' , (int)'Q' , -1 , -1 , -1 } ,
/* 11 */ { 1 , (int)'w' , (int)'W' , -1 , -1 , -1 } ,
/* 12 */ { 1 , (int)'e' , (int)'E' , -1 , -1 , -1 } ,
/* 13 */ { 1 , (int)'r' , (int)'R' , -1 , -1 , -1 } ,
/* 14 */ { 1 , (int)'t' , (int)'T' , -1 , -1 , -1 } ,
/* 15 */ { 1 , (int)'y' , (int)'Y' , -1 , -1 , -1 } ,
/* 16 */ { 1 , (int)'u' , (int)'U' , -1 , -1 , -1 } ,
/* 17 */ { 1 , (int)'i' , (int)'I' , -1 , -1 , -1 } ,
/* 18 */ { 1 , (int)'o' , (int)'O' , -1 , -1 , -1 } ,
/* 19 */ { 1 , (int)'p' , (int)'P' , -1 , -1 , -1 } ,
/* 1a */ { 0 , 0x005b , 0x007b , 0x001b , -1 , -1 } ,
/* 1b */ { 0 , 0x005d , 0x007d , 0x001d , -1 , -1 } ,
/* 1c */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 1d */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 1e */ { 1 , (int)'a' , (int)'A' , -1 , -1 , -1 } ,
/* 1f */ { 1 , (int)'s' , (int)'S' , -1 , -1 , -1 } ,
/* 20 */ { 1 , (int)'d' , (int)'D' , -1 , -1 , -1 } ,
/* 21 */ { 1 , (int)'f' , (int)'F' , -1 , -1 , -1 } ,
/* 22 */ { 1 , (int)'g' , (int)'G' , -1 , -1 , -1 } ,
/* 23 */ { 1 , (int)'h' , (int)'H' , -1 , -1 , -1 } ,
/* 24 */ { 1 , (int)'j' , (int)'J' , -1 , -1 , -1 } ,
/* 25 */ { 1 , (int)'k' , (int)'K' , -1 , -1 , -1 } ,
/* 26 */ { 1 , (int)'l' , (int)'L' , -1 , -1 , -1 } ,
/* 27 */ { 0 , 0x003b , 0x003a , -1 , -1 , -1 } ,
/* 28 */ { 0 , 0x27 , 0x22 , -1 , -1 , -1 } ,
/* 29 */ { 0 , 0x60 , 0x007e , -1 , -1 , -1 } ,
/* 2a */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 2b */ { 0 , 0x005c , 0x007c , 0x001c , -1 , -1 } ,
/* 2c */ { 1 , (int)'z' , (int)'Z' , -1 , -1 , -1 } ,
/* 2d */ { 1 , (int)'x' , (int)'X' , -1 , -1 , -1 } ,
/* 2e */ { 1 , (int)'c' , (int)'C' , -1 , -1 , -1 } ,
/* 2f */ { 1 , (int)'v' , (int)'V' , -1 , -1 , -1 } ,
/* 30 */ { 1 , (int)'b' , (int)'B' , -1 , -1 , -1 } ,
/* 31 */ { 1 , (int)'n' , (int)'N' , -1 , -1 , -1 } ,
/* 32 */ { 1 , (int)'m' , (int)'M' , -1 , -1 , -1 } ,
/* 33 */ { 0 , 0x002c , 0x003c , -1 , -1 , -1 } ,
/* 34 */ { 0 , 0x002e , 0x003e , -1 , -1 , -1 } ,
/* 35 */ { 0 , 0x002f , 0x003f , -1 , -1 , -1 } ,
/* 36 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 37 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 38 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 39 */ { 0 , 0x20 , 0x20 , 0x20 , -1 , -1 } ,
/* 3a */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 3b */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 3c */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 3d */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 3e */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 3f */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 40 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 41 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 42 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 43 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 44 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 45 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 46 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 47 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 48 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 49 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 4a */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 4b */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 4c */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 4d */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 4e */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 4f */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 50 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 51 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 52 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 53 */ { 0 , 0x002e , 0x002e , -1 , -1 , -1 } ,
/* 54 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 55 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 56 */ { 0 , 0x005c , 0x007c , 0x001c , -1 , -1 } ,
/* 57 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 58 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 59 */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 5a */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 5b */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 5c */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 5d */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 5e */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
/* 5f */ { -1 , 0 , 0 , 0 , 0 , 0 } ,
};
public static final int DEADKEYS[] = null;
public static final int DEADKEY_LUT[][] = null;
private static UnitedStatesLayout instance = new UnitedStatesLayout();
private UnitedStatesLayout() {
}
public static UnitedStatesLayout getInstance() {
return instance;
}
@Override
public int[][] getLUT() {
return LUT;
}
@Override
public int[][] getFastLUT() {
return FAST_LUT;
}
@Override
public void type(String text) {
super.type(FAST_LUT, text, (byte)0);
}
@Override
public void type(String text, byte modifiers) {
super.type(FAST_LUT, text, modifiers);
}
@Override
public char getChar(int scanCode, boolean capsLock, boolean shift, boolean altGr) {
return super.getChar(LUT, scanCode, capsLock, shift, altGr);
}
@Override
public String getLocaleName() {
return LOCALE_NAME;
}
@Override
public int[][] getDeadkeyLUT() {
return DEADKEY_LUT;
}
@Override
public int[] getDeadkeys() {
return DEADKEYS;
}
}

View File

@ -0,0 +1,78 @@
package com.inputstick.init;
import com.inputstick.api.Packet;
public class BasicInitManager extends InitManager {
private static final int UPDATES_LIMIT = 50;
private static final int RETRY_LIMIT = 3;
private int lastStatusParam;
private int noInitUpdatesCnt;
private int noInitRetryCnt;
public BasicInitManager(byte[] key) {
super(key);
lastStatusParam = 0;
}
@Override
public void onConnected() {
sendPacket(new Packet(true, Packet.CMD_RUN_FW));
}
@Override
public void onData(byte[] data) {
byte cmd = data[0];
byte respCode = data[1];
byte param = data[1];
switch (cmd) {
case Packet.CMD_RUN_FW:
sendPacket(new Packet(true, Packet.CMD_FW_INFO));
break;
case Packet.CMD_FW_INFO:
onFWInfo(data, true, true, new Packet(true, Packet.CMD_INIT)); //TODO next FW: params!
break;
case Packet.CMD_INIT:
if (respCode == Packet.RESP_OK) {
initDone = true;
noInitUpdatesCnt = 0;
noInitRetryCnt = 0;
sendPacket(new Packet(true, Packet.CMD_HID_STATUS_REPORT));
} else {
mListener.onInitFailure(respCode);
}
break;
case Packet.CMD_INIT_AUTH:
onAuth(data, true, new Packet(true, Packet.CMD_INIT)); //TODO next FW: params!
break;
case Packet.CMD_HID_STATUS:
if (initDone) {
if (param != lastStatusParam) {
lastStatusParam = param;
if (param == 0x05) {
mListener.onInitReady();
} else {
mListener.onInitNotReady();
}
}
} else {
noInitUpdatesCnt++;
if (noInitUpdatesCnt == UPDATES_LIMIT) {
noInitUpdatesCnt = 0;
if (noInitRetryCnt < RETRY_LIMIT) {
sendPacket(new Packet(true, Packet.CMD_RUN_FW));
noInitRetryCnt++;
}
}
}
break;
}
}
}

View File

@ -0,0 +1,28 @@
package com.inputstick.init;
import com.inputstick.api.Packet;
public class BootloaderInitManager extends InitManager {
public BootloaderInitManager(byte[] key) {
super(key);
}
@Override
public void onConnected() {
//TODO key
sendPacket(new Packet(true, Packet.CMD_RUN_BL));
}
@Override
public void onData(byte[] data) {
byte cmd = data[0];
//byte respCode = data[1];
//byte param = data[1];
if (cmd == Packet.CMD_RUN_BL) {
mListener.onInitReady();
}
}
}

View File

@ -0,0 +1,89 @@
package com.inputstick.init;
public class DeviceInfo {
private int firmwareType;
private int versionMajor;
private int versionMinor;
private int versionHardware;
private int securityStatus;
private boolean passwordProtected;
public DeviceInfo(byte[] data) {
//cmd, param
firmwareType = data[2];
versionMajor = data[3];
versionMinor = data[4];
versionHardware = data[5];
//6,7,8,9
//10,11,12,13
//14,15,16,17
//18,19
securityStatus = data[19];
if (data[20] == 0) {
passwordProtected = false;
} else {
passwordProtected = true;
}
}
public int getSecurityStatus() {
return securityStatus;
}
public boolean isAuthenticated() {
return ((securityStatus & 0x10) != 0);
}
public boolean isUnlocked() {
if (getFirmwareVersion() < 96) {
return true;
} else {
return ((securityStatus & 0x08) != 0);
}
}
public int getFirmwareType() {
return firmwareType;
}
public boolean isPasswordProtected() {
return passwordProtected;
}
public int getVersionMinor() {
return versionMinor;
}
public int getVersionMajor() {
return versionMajor;
}
public int getHardwareVersion() {
return versionHardware;
}
public int getFirmwareVersion() {
return (versionMajor) * 100 + versionMinor;
}
public boolean supportsEncryption() {
return (getFirmwareVersion() >= 91);
}
public boolean supportsPinChange() {
return (getFirmwareVersion() >= 97);
}
public boolean supportsGamepad() {
return (getFirmwareVersion() >= 97);
}
}

View File

@ -0,0 +1,107 @@
package com.inputstick.init;
import com.inputstick.api.InputStickError;
import com.inputstick.api.Packet;
import com.inputstick.api.PacketManager;
public class InitManager {
public static final int DEFAULT_INIT_TIMEOUT = 60000; //60s init timeout
protected PacketManager mPacketManager;
protected InitManagerListener mListener;
protected byte[] mKey;
protected DeviceInfo mInfo;
protected boolean initDone;
public InitManager(byte[] key) {
mKey = key;
}
public DeviceInfo getDeviceInfo() {
return mInfo;
}
public boolean isEncrypted() {
return mPacketManager.isEncrypted();
}
public void init(InitManagerListener listener, PacketManager packetManager) {
mListener = listener;
mPacketManager = packetManager;
initDone = false;
}
public void onConnected() {
mListener.onInitReady();
}
public void onData(byte[] data) {
//byte cmd = data[0];
//byte param = data[1];
}
public void sendPacket(Packet p) {
mPacketManager.sendPacket(p);
}
public void onFWInfo(byte[] data, boolean authenticate, boolean enableEncryption, Packet sendNext) {
mInfo = new DeviceInfo(data);
if (authenticate) {
if (mInfo.isPasswordProtected()) {
if (mKey != null) {
//authenticate
sendPacket(mPacketManager.encPacket(enableEncryption));
} else {
mListener.onInitFailure(InputStickError.ERROR_SECURITY_NO_KEY);
}
} else {
if (mKey != null) {
//possible scenarios: FW upgrade / password removed using other device/app / tampering!
mListener.onInitFailure(InputStickError.ERROR_SECURITY_NOT_PROTECTED);
}
sendPacket(sendNext);
}
} else {
sendPacket(sendNext);
}
}
public void onAuth(byte[] data, boolean enableOutEncryption, Packet sendNext) {
byte respCode = data[1];
switch (respCode) {
case Packet.RESP_OK:
byte[] cmp = new byte[16];
//TODO check length!
System.arraycopy(data, 2, cmp, 0, 16);
if (mPacketManager.setEncryption(cmp, enableOutEncryption)) {
sendPacket(sendNext);
} else {
mListener.onInitFailure(InputStickError.ERROR_SECURITY_CHALLENGE);
}
break;
case 0x20:
mListener.onInitFailure(InputStickError.ERROR_SECURITY_INVALID_KEY);
break;
case 0x21:
mListener.onInitFailure(InputStickError.ERROR_SECURITY_NOT_PROTECTED);
break;
case Packet.RESP_UNKNOWN_CMD:
mListener.onInitFailure(InputStickError.ERROR_SECURITY_NOT_SUPPORTED);
break;
default:
mListener.onInitFailure(InputStickError.ERROR_SECURITY);
}
}
}

View File

@ -0,0 +1,9 @@
package com.inputstick.init;
public interface InitManagerListener {
public void onInitReady();
public void onInitNotReady();
public void onInitFailure(int code);
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

View File

@ -0,0 +1,9 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="@+id/action_settings"
android:orderInCategory="100"
android:showAsAction="never"
android:title="@string/action_settings"/>
</menu>

View File

@ -0,0 +1,8 @@
<resources>
<!--
Customize dimensions originally defined in res/values/dimens.xml (such as
screen margins) for sw600dp devices (e.g. 7" tablets) here.
-->
</resources>

View File

@ -0,0 +1,9 @@
<resources>
<!--
Customize dimensions originally defined in res/values/dimens.xml (such as
screen margins) for sw720dp devices (e.g. 10" tablets) in landscape here.
-->
<dimen name="activity_horizontal_margin">128dp</dimen>
</resources>

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">InputStickAPI</string>
<string name="title_activity_install_utility">Download InputStickUtility</string>
<string name="action_settings">Settings</string>
<string name="hello_world">Hello world!</string>
</resources>

View File

@ -0,0 +1,15 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.2.3'
}
}
allprojects {
repositories {
jcenter()
}
}

Binary file not shown.

View File

@ -0,0 +1,6 @@
#Wed Apr 10 15:27:10 PDT 2013
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip

164
src/java/InputStickAPI/gradlew vendored Normal file
View File

@ -0,0 +1,164 @@
#!/usr/bin/env bash
##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn ( ) {
echo "$*"
}
die ( ) {
echo
echo "$*"
echo
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
esac
# For Cygwin, ensure paths are in UNIX format before anything is touched.
if $cygwin ; then
[ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
fi
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >&-
APP_HOME="`pwd -P`"
cd "$SAVED" >&-
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
function splitJvmOpts() {
JVM_OPTS=("$@")
}
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"

90
src/java/InputStickAPI/gradlew.bat vendored Normal file
View File

@ -0,0 +1,90 @@
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windowz variants
if not "%OS%" == "Windows_NT" goto win9xME_args
if "%@eval[2+2]" == "4" goto 4NT_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
goto execute
:4NT_args
@rem Get arguments from the 4NT Shell from JP Software
set CMD_LINE_ARGS=%$
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega

View File

@ -0,0 +1,60 @@
ECLIPSE ANDROID PROJECT IMPORT SUMMARY
======================================
Ignored Files:
--------------
The following files were *not* copied into the new Gradle project; you
should evaluate whether these are still needed in your project and if
so manually move them:
* .gitignore
* .idea\
* .idea\.name
* .idea\InputStickAPI.iml
* .idea\compiler.xml
* .idea\copyright\
* .idea\copyright\profiles_settings.xml
* .idea\misc.xml
* .idea\modules.xml
* .idea\vcs.xml
* .idea\workspace.xml
* LICENSE
* README.md
* proguard-project.txt
Replaced Jars with Dependencies:
--------------------------------
The importer recognized the following .jar files as third party
libraries and replaced them with Gradle dependencies instead. This has
the advantage that more explicit version information is known, and the
libraries can be updated automatically. However, it is possible that
the .jar file in your project was of an older version than the
dependency we picked, which could render the project not compileable.
You can disable the jar replacement in the import wizard and try again:
android-support-v4.jar => com.android.support:support-v4:19.1.0
android-support-v7-appcompat.jar => com.android.support:appcompat-v7:19.1.0
Moved Files:
------------
Android Gradle projects use a different directory structure than ADT
Eclipse projects. Here's how the projects were restructured:
* AndroidManifest.xml => app\src\main\AndroidManifest.xml
* res\ => app\src\main\res\
* src\ => app\src\main\java\
Next Steps:
-----------
You can now build the project. The Gradle project needs network
connectivity to download dependencies.
Bugs:
-----
If for some reason your project does not build, and you determine that
it is due to a bug or limitation of the Eclipse to Gradle importer,
please file a bug at http://b.android.com with category
Component-Tools.
(This import summary is for your information only, and can be deleted
after import once you are satisfied with the results.)

View File

@ -0,0 +1 @@
include ':app'

View File

@ -1,9 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="gen"/>
<classpathentry kind="output" path="bin/classes"/>
</classpath>

View File

@ -1,33 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>KP2ASoftKeyboard</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.android.ide.eclipse.adt.ApkBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>com.android.ide.eclipse.adt.AndroidNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

View File

@ -1,2 +0,0 @@
eclipse.preferences.version=1
encoding//src/keepass2android/softkeyboard/KP2AKeyboard.java=UTF-8

View File

@ -1,21 +0,0 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="keepass2android.softkeyboard" android:versionCode="1">
<uses-sdk android:targetSdkVersion="14" android:minSdkVersion="8"/>
<supports-screens
android:anyDensity="true"
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true" />
<application android:label="@string/ime_name">
<service android:name="KP2AKeyboard"
android:permission="android.permission.BIND_INPUT_METHOD">
<intent-filter>
<action android:name="android.view.InputMethod" />
</intent-filter>
<meta-data android:name="android.view.im" android:resource="@xml/method" />
</service>
</application>
</manifest>

View File

@ -1,4 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<lint>
<issue id="WrongCall" severity="ignore" />
</lint>

View File

@ -1,15 +0,0 @@
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system edit
# "ant.properties", and override values to adapt the script to your
# project structure.
#
# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
# Project target.
target=android-17
android.library=true

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 885 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 536 B

Some files were not shown because too many files have changed in this diff Show More