我正在开发一个 android 应用程序(键盘驱动程序),首先我将蓝牙键盘与 android 设备连接,在我的 Inputmethod 服务中成功连接后,我正在接收按键并将其发送到当前打开的编辑器。问题是我无法弄清楚如何在 android 中打开/关闭大写锁定和 shift 键功能。
任何帮助!
这是从蓝牙键盘接收按键的广播接收器
private BroadcastReceiver key3Receiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
int key = Integer.parseInt(intent
.getStringExtra(BluezService.COLONY_KEYPRESS_KEY));
int action = intent.getIntExtra(BluezService.EVENT_KEYPRESS_ACTION,
KeyEvent.ACTION_DOWN);
Log.d("++++ key recieved ", Integer.toString(key));
InputConnection ic = getCurrentInputConnection();
long eventTime = SystemClock.uptimeMillis();
// ********* Hacks
if(key==8)
{
key=127;
}
if (key < 130) {
ic.sendKeyEvent(new KeyEvent(eventTime, eventTime, action,COLONYKEYCODE[key],
0, COLONYKEYCODE[key], 0, 0, KeyEvent.FLAG_SOFT_KEYBOARD));
}
}
};