Virtual Input manger uses uinput framework to create virtual/user-space input devices & virtio-input infrastructure from QEmu to map the devices on virtual machines
Prerequisite:
- Required minimum gcc version is 7.4.0 or Ubuntu 18.04 release of Ubuntu Host
Compile:
- $make clean
- $make
- Compilation generates vinput-manager & sendkey executables.
Step 1:
- Pre-built binaries are placed in ~/civ/scripts directory
- $cd ~/civ/scripts/
- $chmod +x vinput-manager sendkey
Step 2: Launch vinput-manager
- $sudo ./vinput-manager
Step 3: Launch Android
- Add below two lines under common_options variable in start_android_qcow2.sh script.
-device virtio-input-host-pci,evdev=/dev/input/by-id/Power-Button-vm0 \
-device virtio-input-host-pci,evdev=/dev/input/by-id/Volume-Button-vm0 \ - Launch CIV using start_android_qcow2.sh script.
Step 4:
Use sendkey application to verify volume and power key functionality in android
- Volume Functionality:
./sendkey --vm 0 --volume up => Increases volume in CIV
./sendkey --vm 0 --volume down => decreases volume in CIV - Power Functionality:
./sendkey --vm 0 --power 0 => Short press to trigger Suspend/Resume in CIV
./sendkey –vm 0 –power 5 => long press of power key for 5 seconds. Displays power options in Android.
Note:
- Use sendkey application only after launching CIV.
- To set device in to graphical mode.
$sudo systemctl set-default graphical.target
$sudo reboot
Step 1: Pre-built binaries are placed in ~/civ/scripts directory
- $cd ~/civ/scripts
- $chmod +x vinput-manager sendkey
Step 2: Set the device in multi-user target mode.
- $sudo systemctl set-default multi-user.target
Step 3: Update logind.conf file with "HandlePowerKey=ignore" and reboot device
- $sudo vim /etc/systemd/logind.conf
[Login]
HandlePowerKey=ignore - $sudo reboot
Step 4: Launch vinput-manager
- $sudo ./vinput-manager --gvtd
Step 5:
-
Add below 3 lines under cmd field in ini file
-device virtio-input-host-pci,evdev=/dev/input/by-id/Power-Button-vm0 \
-device virtio-input-host-pci,evdev=/dev/input/by-id/Volume-Button-vm0 \
-qmp unix:./qmp-vinput-sock,server,nowait \ -
eg [extra] #cmd=-monitor stdio cmd=-device virtio-input-host-pci,evdev=/dev/input/by-id/Power-Button-vm0 -device virtio-input-host-pci,evdev=/dev/input/by-id/Volume-Button-vm0 -qmp unix:./qmp-vinput-sock,server,nowait
-
Launch CIV: $sudo vm-manager -b civ-1
Step 6: Run sendkey application to verify volume and power key functionality in android
- Volume Functionality:
$./sendkey --vm 0 --volume up => Increases volume in CIV
$./sendkey --vm 0 --volume down => decreases volume in CIV - Power Functionality:
$./sendkey --vm 0 --power 0 => Suspend/Resume in CIV
$./sendkey –vm 0 –power 5 => long press of power key for 5 seconds. Displays power options in android.
-
By default g++ compiler version is 7.5.0 in Ubuntu 18.04 host OS.
-
In case g++ version < 7.4, install manually latest version using below mentioned commands.
-
$ sudo apt install software-properties-common
-
$ sudo apt install gcc-7 g++-7
-
$ sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-7 50
-
$ sudo update-alternatives --config g++
-
$ Select "g++-7"
-
command to check version
$g++ --version
Note:
1. Execute/Run vinput-manager before lunching CIV.
2. Use sendkey application to send commands after launching CIV.