If you have read the article on the 'Linux Arcade System' you may wonder how to get multiple people using keyboards on a single system. For multi-player games they can be more fun when you can have multiple players to play at once. A good example is the game Gauntlet where there can be up to four players playing at one time. Some games tend to be one player at a time. When one player dies the next one plays until they die and the switching continues. If you want to play with multiple people at once then read on. XINPUT Xinput is part of the X11 system. On Linux X11 is the X Window System which appears as a Graphical User Interface (GUI). To determine if you have X11 use the following command: 'dpkg -l|grep xserver'. The easiest way is to open a terminal and type 'xinput --version' to get an output showing the version of the Xinput application. Xinput can be used to control the keyboard and mouse on a Linux system with X11. Looking at the system on which you are working you need to first run the command 'xinput' or 'xinput --list'. The option '--list' specifies that a list of the Xinput devices should be shown. If no options are given then the default option is '--list'. To execute the Xinput command would give results similar to Figure 1. FIGURE 1 The two main items to note here are the Virtual Core Pointer and the Virtual Core Keyboard. The Virtual Core Pointer is the master device for the mouse while the Virtual Core Keyboard is for the keyboard device. Under each master device is a Virtual Core XTEST device for the pointer and keyboard. Under the Virtual Core Pointer there will be an entry for each pointing device which are considered slave devices. Usually there is only one, but in some cases there are more. In the case of a laptop with a touchpad with a mouse connected there will be two slave devices. One device for the touchpad and one for the mouse will be listed. For the Virtual Core Keyboard section there are two 'Power Button' entries which represent the PWRB and the PWRF. These will represent different things on various systems. The PWRB represents the hardware power button (PoWeR Button) while the PWRF is for software forced shutdown (PoWeR Forced reboot). A laptop may have a 'Power Buton' entry for the lid when it is closed and causes the laptop to hibernate. There may be other entries, but the main one to note is the one for the physical keyboard. In Figure 1 this is represented by the 'Logitech USB Receiver'. NOTE: For both the mouse and keyboard the devices are listed as a USB Receiver. The two entries are receivers since they are a Bluetooth keyboard and mouse. So, to get another keyboard and mouse on a system we need to create another Master Keyboard and Master Pointer to control the slave device. If you wish to only add one master device then you will have both a Master Pointer and Master Keyboard. The master devices are created as a pair, but you do not need to connect both devices. If a second keyboard is needed then only connect a keyboard and not a mouse. With USB devices you can quickly fill your USB Ports unless you add a USB Hub. Adding a Keyboard and/or Mouse To add the new master device you use the command: xinput create-master name The name is used to signify the new Master. In Figure 1 the primary Master is labeled 'Virtual core'. The name can be anything you want it to be. For example, I can type the command 'xinput create-master Secondary' and I would have an xinput listing as shown in Figure 2. FIGURE 2 There is now a secondary Master Device, but there isn't hardware associated with it. Now you will need to plug in a keyboard and/or mouse. Once I plug in a keyboard I run the command 'xinput' again. The results of the new keyboard are shown in Figure 3. FIGURE 3 The new keyboard is shown as 'SIGMACHIP USB Keyboard' with an id of 14. The keyboard will need to be moved to the new master 'Secondary Keyboard'. To move the keyboard from the Primary Master to the Secondary Master the command needed is 'xinput reattach a-id b-id'. The 'a-id' is the id number of the slave device we are moving. The 'b-id' is the Master device we are moving the slave to for control. In the instance of Figure 3, the command is 'xinput reattach 14 11'. (Log in to hide this advertisement) Notice something very interesting. The keyboard was added as a slave pointer as well. The pointer can be moved from 14 to 10 with the command 'xinput reattach 14 10'. Once these commands are done the results can be seen in Figure 4. FIGURE 4 If I add a USB mouse it shows up as ID 16 and I will need to move it to the Secondary Pointer with an ID of 10. The command is 'xinput reattach 16 10'. The results of reattching the mouse is shown in Figure 5. FIGURE 5 I now have my system set up with two keyboards and two mice which act independently of each other. You can add more keyboards and mice as you need for more players. Once you are done with extra keyboards and mice you will need to remove them. Removing a Keyboard and/or Mouse Once you are finished with the extra input hardware you can easily remove the Master Devices from xinput with the following command: xinput -remove-master [id] The '[id]' is the ID of the Master Device for either the keyboard or the pointer. Removing one master will remove the whole set. To use Figure 5 as an example I can use the ID of 11 or 10 to remove the whole Secondary Master Device. The possible commands to remove the Secondary Master Device are: xinput -remove-master 11 - or - xinput -remove-master 10 After the commands are executed you can run the command 'xinput' again to see that the Master Device was removed. If you do not want to remove the Master Device you can disable it so it will not function. Enable/Disable a Device If you leave two keyboards and two mice connected they can interfere with each other while you try to do other things on the Linux system. You could remove the devices as covered previously or simply disable them. To disable a device use the following command: xinput -disable [id] The '[id]' is the ID of the device which you want to disable/enable. Looking back at Figure 5 my keyboard has an ID of 14 and the mouse is 16. So to disable both devices I would execute the following commands: xinput -disable 14 xinput -disable 16 With the devices disabled they will not function when used. For the mouse the second mouse cursor will still appear on the screen as before. To enable the devices when needed again use the following commands: xinput -enable 14 xinput -enable 16 NOTE: Be aware to make sure you disable/enable the physical hardware devices. If you disable/enable the Master Devices then you can cause your GUI to restart. I hope this helps to play games with multiple keyboards and mice. Happy gaming!