• RK3399 gpio 做系统按键



    一.kernelarcharm64ootdts ockchip k3399-android.dtsi

    	rk_key: rockchip-key {
    		compatible = "rockchip,key";
    		status = "okay";
    
    		//io-channels = <&saradc 0>;
    
    		vol-up-key {
    			linux,code = <115>;
    			label = "volume up";
    			rockchip,adc_value = <1>;
    		};
    
    		vol-down-key {
    			linux,code = <114>;
    			label = "volume down";
    			rockchip,adc_value = <170>;
    		};
    
    		power-key {
    			gpios = <&gpio0 5 GPIO_ACTIVE_LOW>;
    			linux,code = <116>;
    			label = "power";
    			gpio-key,wakeup;
    		};
    		
    		gpio1-key {
    			gpios = <&gpio2 4 GPIO_ACTIVE_LOW>;
    			linux,code = <131>;
    			label = "gpio1 key";
    			gpio-key,wakeup;
    		};				
    	};

    二.frameworks ativeincludeandroidkeycodes.h

        /** F1 key. */
        AKEYCODE_F1              = 131,
        /** F2 key. */
        AKEYCODE_F2              = 132,
        /** F3 key. */
        AKEYCODE_F3              = 133,

    三.rk29-keypad.kl  加按键值

    系统 优先加载  systemusrkeylayout k29-keypad.kl   

    device ockchipcommon k29-keypad.kl

    key 59    MENU
    key 102   HOME
    key 114   VOLUME_DOWN
    key 115   VOLUME_UP
    key 116   POWER
    key 143   NOTIFICATION
    key 158   BACK
    key 212   CAMERA
    key 217   SEARCH
    key 131   F1
    key 132   F2
    key 133   F3  

    四.frameworksaseservicescorejavacomandroidserverpolicyPhoneWindowManager.java  

      public long interceptKeyBeforeDispatching(WindowState win, KeyEvent event, int policyFlags) {

                    else if(keyCode == 131){	
    				if (!down) {
    				  //Log.d("gatsby", "gpio1_key xh_flag-> " + xh_flag +" gpio1_key  num->"+gpio1_key);
    				  if(xh_flag){
    					 if(gpio1_key %2 !=0){
    					 	  RootCommand("settings put system screen_brightness 255");
    					 	  toastTest("Highlight mode!");				   		
    					 }else {
    					 	  RootCommand("settings put system screen_brightness 110");
    					 	  toastTest("Normal brightness!");
    					 }
    				  }
    					gpio1_key++;						
    				}	
    				return -1;
    		}
    

      

  • 相关阅读:
    yarn 完美替代 npm
    Vue调试神器vue-devtools安装
    PHPStorm 忽略 node_modules 目录
    npm 更改为淘宝镜像的方法
    php快速获取所有的自定义常量用户常量
    我们为什么要在 PHPStorm 中标记目录
    PhpStorm 合理标注目录让索引和扫描更加地高效
    Linux sleep命令
    Shell命令行中特殊字符与其转义详解(去除特殊含义)
    shell编程—— EOF
  • 原文地址:https://www.cnblogs.com/crushgirl/p/15093250.html
Copyright © 2020-2023  润新知