Hi TD05Educat,
Please go to the xavier device tree(dts) and search for “gpio-keys”.
gpio-keys {
compatible = "gpio-keys";
gpio-keys,name = "gpio-keys";
forcerecovery {
label = "force-recovery";
gpios = <&tegra_main_gpio TEGRA194_MAIN_GPIO(G, 0) GPIO_ACTIVE_LOW>;
linux,code = <BTN_1>;
};
power_key {
label = "power-key";
gpios = <&tegra_aon_gpio TEGRA194_AON_GPIO(EE, 4) GPIO_ACTIVE_LOW>;
linux,code = <KEY_POWER>;
gpio-key,wakeup;
};
};
};
You could register a new key here.
And you could monitor the key event by some tools. For example, I am trying to monitor the key_volumedown and volumeup on my tx2 with below commands.
nvidia@nvidia-desktop:/dev/input$ sudo evtest /dev/input/event2
Input driver version is 1.0.1
Input device ID: bus 0x19 vendor 0x1 product 0x1 version 0x100
Input device name: "gpio-keys"
Supported events:
Event type 0 (EV_SYN)
Event type 1 (EV_KEY)
Event code 114 (KEY_VOLUMEDOWN)
Event code 115 (KEY_VOLUMEUP)
Event code 116 (KEY_POWER)
Properties:
Testing ... (interrupt to exit)
Event: time 1582269997.329261, type 1 (EV_KEY), code 114 (KEY_VOLUMEDOWN), value 1
Event: time 1582269997.329261, -------------- SYN_REPORT ------------
Event: time 1582269997.514287, type 1 (EV_KEY), code 114 (KEY_VOLUMEDOWN), value 0
Event: time 1582269997.514287, -------------- SYN_REPORT ------------
Event: time 1582269998.869235, type 1 (EV_KEY), code 114 (KEY_VOLUMEDOWN), value 1
Event: time 1582269998.869235, -------------- SYN_REPORT ------------
Event: time 1582269999.045246, type 1 (EV_KEY), code 114 (KEY_VOLUMEDOWN), value 0
Event: time 1582269999.045246, -------------- SYN_REPORT ------------
Event: time 1582270000.358204, type 1 (EV_KEY), code 115 (KEY_VOLUMEUP), value 1
Event: time 1582270000.358204, -------------- SYN_REPORT ------------
Event: time 1582270000.527246, type 1 (EV_KEY), code 115 (KEY_VOLUMEUP), value 0
Event: time 1582270000.527246, -------------- SYN_REPORT ------------
Event: time 1582270001.435317, type 1 (EV_KEY), code 115 (KEY_VOLUMEUP), value 1
Event: time 1582270001.435317, -------------- SYN_REPORT ------------
Event: time 1582270001.640221, type 1 (EV_KEY), code 115 (KEY_VOLUMEUP), value 0
Event: time 1582270001.640221, -------------- SYN_REPORT ------------
reference:
https://www.kernel.org/doc/Documentation/devicetree/bindings/input/gpio-keys.txt