开启/关闭大写锁定,并转变对机器人编程键机器人

2023-09-04 05:16:28 作者:填补距离

我开发一个Android应用程序(键盘驱动程序),其中第一个我连接蓝牙键盘与Android设备,我收到了关键presses并将其发送给当前打开的编辑器,在我的Inputmethod服务连接成功后。问题是,我无法弄清楚如何打开/关闭大写锁定,并在Android的shift键的功能。

任何帮助!

这是广播接收器,它是由蓝牙键盘

接收键

 私人的BroadcastReceiver key3Receiver =新的BroadcastReceiver(){

    @覆盖
    公共无效的onReceive(上下文的背景下,意图意图){
        INT键=的Integer.parseInt(意向
                .getStringExtra(BluezService.COLONY_KEY preSS_KEY));
        INT行动= intent.getIntExtra(BluezService.EVENT_KEY preSS_ACTION,
                KeyEvent.ACTION_DOWN);
        Log.d(++++键:收到,Integer.toString(键));

        InputConnection集成电路= getCurrentInputConnection();
        长eventTime = SystemClock.uptimeMillis();

        // *********黑客
        如果(关键== 8)
        {
            键= 127;
        }


        如果(钥匙< 130){
            ic.sendKeyEvent(新的KeyEvent(eventTime,eventTime,动作,COLONYKEY code [关键]
                    0,COLONYKEY code [关键],0,0,KeyEvent.FLAG_SOFT_KEYBOARD));
        }

    }
};
 

解决方案 QQ面板上登入密码 大写锁定已打开 怎么关掉

在您的EditText(或酌情)使用属性:

 安卓inputType =textCapCharacters
 

在默认情况下充分利用所有的字母。阅读 inputType 了解它的其他功能。

I am developing an android application (keyboard driver) in which first I am connecting Bluetooth keyboard with android device , after successful connection in my Inputmethod service I am receiving key presses and send it to currently open editor. The problem is that I am unable to figure out how to turn on/off caps lock and shift key functionality in android.

Any help !!

This is the broadcast receiver which is receiving keys from Bluetooth keyboard

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));
        }

    }
};

解决方案

In your EditText (or wherever appropriate) use the attribute:

android:inputType="textCapCharacters"

to capitalize all letters by default. Read inputType for its other features.