02 Key detection case
Case Introduction
This case detects key events by monitoring the state of the user input key UBOOT. The case will obtain the key event, match the key value, and then process the event. If you need to test other keys, please modify the corresponding device node and source code.
The UBOOT button used in this case is the button in the red box in the figure below.

Operation process
Open the terminal and use the evtest command to view the event device node corresponding to the UBOOT button. The UBOOT button corresponds to "adc-keys". This command can be executed in any path.
evtest

From the query results, the event device node corresponding to the UBOOT button is event2 .
Copy the executable program smdt_key_demo in the bin directory of this case (05-Development Materials\Software Development Materials\linux_demo\smdt_key_demo\bin) to the development board file system (the source code can be viewed in the src path.
Execute the following command in the terminal to switch to the directory where the smdt_key_demo executable program is located.
cd ‘the file's directory’
After switching, you can run the command "ls" to check whether the smdt_key_demo executable program is in the current directory.
ls
If the executable file smdt_key_demo exists in the current directory, continue to perform the following operations: Enter the following command to modify the file permissions.
chmod 777 smdt_key_demo
After modifying the permissions, you can enter the following command to check whether the modification is successful.
ls -ld smdt_key_demo
The execution result is: -rwxrwxrwx 1 root root 13824 Mar 4 01:22 smdt_key_demo
-rwxrwxrwx means the permissions have been modified successfully, the file can be executed, and you can continue with the following operations.
Enter the command to view the program parameter information. Note that event2 in the following command needs to be changed according to the result of the previous evtest command query.
./smdt_key_demo -help
./smdt_key_demo -d /dev/input/event2
Press the UBOOT button on the development board again , the program will detect the key event and print the key status information.
The test results are as follows
Press "Ctrl+C" to exit the test.