- Как легко подключить контроллер от Xbox 360 в Ubuntu
- Настройка Ubuntu Xbox драйвера
- Ubuntu Documentation
- Introduction
- The (old) Xbox™ Controller
- Before you begin
- Updating the drivers
- Installing required packages
- Downloading and preparing the drivers
- Creating the Makefile
- Compiling and installing the drivers
- Testing and Troubleshooting
- Known issues with Wireless controllers
- General issues and solutions
- Controller doesn’t respond
- Incorrectly mapped buttons
- Xbox 360 controller linux
- About
- Xbox 360 controller linux
Как легко подключить контроллер от Xbox 360 в Ubuntu
С тех пор как Steam стал доступен на Linux, геймеры все чаще и чаще задаются вопросом, как подключить контроллеры от Xbox в Ubuntu.
Драйвер «xpad» доступен в Ubuntu 14.04 LTS по умолчанию. В большинстве случаев все работает гладко и стабильно, но владельцы новых беспроводных контроллеров отмечают существование проблем с некорректным реагированием на нажатие кнопок и беспричинным мерцанием лампочек на контроллере.
Для более гладкого управления игровым процессом, настройками, чувствительностью и назначением кнопок обычно рекомендуется альтернативный драйвер под названием «xboxdrv».
Xboxdrv считается отличным решением, засчет поддержки широкого спектра устройств и огромного количества доступных настроек, такик как:
- Имитация клавиатуры и мыши
- Переназначение кнопок
- Регулировка/настройка/калибровка
- Макросы для триггеров
- Настройка лампочек на геймпаде
Настройка Ubuntu Xbox драйвера
Выше мы упомянули драйвер xboxdrv: но его не так то просто установить. Постоянно возникают проблемы несовместимости драйвера с Панелью Управлению Unity, это очень сильно раздражает и мешает настройке.
Но репак драйверов от Rael GC решает большую часть этих проблем (и многие другие!). Его репак драйвера xboxdv — который он назвал «Ubuntu xboxdrv» — доступен для Ubuntu 12.04 LTS, 13.10 и 14.04 LTS с помощью соответствующего PPA, благодаря которому процесс установки (и удаления) значительно упрощается.
Чтобы установить, откройте окно Терминала и введите следующие команды:
sudo apt-add-repository ppa:rael-gc/ubuntu-xboxdrv
sudo apt-get update && sudo apt-get install ubuntu-xboxdrv
После завершения установки необходимо перезагрузить компьютер, чтобы убедиться, что новые драйверы заменили стандартные. Теперь, можно смело пробовать. Особые настройки можно производить в интерфейсе контроллера в Центре программного обеспечения.
За более детальной информацией воспользуйтесь страницей проекта на GitHub.
Источник
Ubuntu Documentation
Introduction
This HOWTO deals with the installation and configuration of Microsoft® Xbox 360™ controllers; both the USB and wireless. The Xbox 360™ controllers and the older Xbox™ controllers should be supported out of the box, but if you are experiencing problems you might want to check out the Testing and Troubleshooting section.
Ubuntu now includes the xpad kernel module with support for the Xbox™ controller and Xbox 360™ (wired/wireless) controller. The tools from the «joystick» package can be used to test and calibrate them from the terminal.
The rest of this HOWTO was originally written for Ubuntu 7.10, although it should apply, with a few modifications, to both older and newer versions which do not already have kernel support for these controllers. The HOWTO is an adaptation of a similar HOWTO for Gentoo Linux, with some general suggestions from various posts on the Ubuntu Forums.
It should be noted that this HOWTO only deals with the regular Xbox™ and Xbox 360™ controllers. Other controllers, peripherals and modules are not dealt with and may or may not work.
Although the steps taken in this HOWTO works for me, I make no guarantee as to the outcome and consequences from following this HOWTO. Use at your own risk.
The (old) Xbox™ Controller
When dealing with the older Xbox™ controllers, all you need to do is to make, or obtain, a USB adapter and plug it in; driver support for the older controllers should already be installed and active. If the controller doesn’t respond, see the Testing and Troubleshooting section.
Before you begin
Before you begin I would like to point out that the Xbox 360™ does not use Bluetooth® for its wireless communication. If you have a wireless controller, you need to get an Xbox 360™ Wireless Gaming Receiver for Windows®. Don’t worry, it works under Linux too, although there are a few quirks. All you need to do is to plug it in, as you would under Windows®, and it should behave similarly to the USB controller.
Updating the drivers
Experimental support for the Xbox 360™ controller does exist. The xpad kernel module included in kernels before 2.6.26 only supports the old Xbox™ controller though. If you want to use your Xbox 360™ controller with a kernel before 2.6.26, you will have to install an updated xpad module. Since there is no package for it, you will have to compile and install the module yourself.
Alternatively, with older kernels you can use the Userspace Xbox/Xbox360 USB Gamepad Driver.
Installing required packages
In order to compile and install the new drivers, you will need a few packages. The following command will install them for you:
Although it isn’t required, you may want additional packages in order to calibrate the controller
You may, of course, use any package manager you like. Just make sure you install the linux-headers version that corresponds to your current kernel.
Downloading and preparing the drivers
For kernels before 2.6.26, you will need to build an updated kernel module (xpad) or the Userspace Xbox/Xbox360 USB Gamepad Driver.
For the updated xpad module, you will need a directory for the files. The name of the directory doesn’t matter, as long as it’s empty and you have write permissions to it.
The above will change directory to your home directory and create the subdirectory «xpad».
Now, go to the newly created directory and download the files:
Creating the Makefile
In your working directory («xpad»), copy and paste the following to a file called «Makefile», using your favourite editor. Make sure the tabs under «all:» and «install:» remain intact.
This should find your current header files, build the new xpad drivers using the recently downloaded source code as a module, and install the module to the appropriate directory.
Compiling and installing the drivers
Assuming your current directory is your working directory («xpad»), all you need to do is to execute the following commands:
This will compile the module, install it, remove the old one, and load the new one. If the process return errors, you probably missed a step. Otherwise, check the Testing and Troubleshooting section.
Testing and Troubleshooting
By now your new module should be installed and ready for use. Connect the controller and type «dmesg» in a terminal. If you see something like «Microsoft Xbox 360 Wireless Controller (PC). «, then the new drivers are supposedly working.
If you installed jscalibrator, you can use it to test and calibrate your controller.
Known issues with Wireless controllers
Support for wireless controllers are still experimental. And although the controllers work, the following issues exist:
- The LED indicator on the controller continues to blink even after the controller has been connected.
- There is no way to turn the controller off, save removing the batteries.
- Some programs may require that you resync the controller after starting them in order for the controller to work.
General issues and solutions
Controller doesn’t respond
- Make sure that the controller is plugged in and that the drivers are installed properly. The install directory mentioned in the Makefile has changed before; if the old modules are loaded when you run «sudo modprobe xpad», then xpad.ko should probably be copied elsewhere. If so, locate the old xpad.ko, and overwrite it with the xpad.ko generated from the compiled sources.
- If the «make» process failed, you are probably missing a file, or the tabs in the Makefile got converted to spaces.
If you just installed the driver, you could try rebooting the system, as that should load all the needed modules. If that doesn’t fix it, try reconnecting the controller. You could also try to run the modprobe commands mentioned under Compiling and installing the drivers again.
Incorrectly mapped buttons
The Gentoo Linux HOWTO on the same subject mentions some fixes if you are having problems with incorrectly mapped buttons. Essentially, you need to figure out which button/axis is controlling what, and what they should be controlling. Then you need to move the corresponding variables around in the source code («xpad.c») to match your setup, save, and repeat this HOWTO from the «Compiling and installing the drivers» section.
Xbox360Controller (последним исправлял пользователь h-danielsson 2010-06-03 23:25:46)
The material on this wiki is available under a free license, see Copyright / License for details
You can contribute to this wiki, see Wiki Guide for details
Источник
Xbox 360 controller linux
A pythonic Xbox360 controller API built on top of the xpad Linux kernel driver.
This Python Package aims to provide a pythonic and complete API for your Xbox360 and similar game controllers. Currently it’s built on top of the Linux kernel driver xpad so you can use it on almost any Linux distribution including your Rasperry Pi projects etc.
The following features are supported:
- Registering callbacks for all Buttons, Axes, Triggers and Hat in a gpiozero -inspired way
- Setting the LED circle; all xpad provided options are possible: blinking, rotating, setting individual LEDs on and off, .
- Rumbling, both the left and right side can be controlled from 0 to 100 percent
You will need Python 3.4 or above.
Any Linux distribution:
You might also use a virtual environment or do a per-user install by providing the —user flag to above command. Global installations might require the usage of sudo or working directly from a root shell but are not recommended.
If the pip3 command cannot be found, try pip or make sure to have pip installed properly:
Of course you don’t need sudo when working from a root shell.
The above code will run until Ctrl+C is pressed. Each time on of the left or right axis is moved, the event will be processed. Additionally, the events of the A button are being processed.
See the API reference for a more detailed explanation of the Xbox360Controller class and how to use all available buttons, axes and the hat.
This will enable rumble on both sides of the controller with each 50% strength for one second (1000ms). Note that the method call is non-blocking, thus we need to manually wait one second for the rumble to finish. You won’t need this in a regular use case with signal.pause() .
This will let the LED circle rotate for one second and then turn it off.
See the API reference for all available LED modes.
The output may look like this:
This project is now in a somewhat stable state, and I really appreciate all kinds of contributions — may it be new or improved code, documentation or just a simple typo fix. Just provide me a PR and I’ll be happy to include your work!
For feature requests, general questions or problems you face regarding this package please open an issue.
Please see CHANGES.md for a complete release history.
Thanks to @VidyaPuri and @jennib3 for pointing out installation issues and providing a fix!
All the code and documentation are distributed under the MIT license. See LICENSE for more information.
About
🎮 A pythonic Xbox360 controller API built on top of the xpad Linux kernel driver
Источник
Xbox 360 controller linux
PS: if you intend to play only Steam games, check this other tutorial, it might be easier.
Dust is meant to be played using a XBOX controller. If you have one, excelent, but if you don’t, some controllers won’t work 100% out of the box. For example, PS2 controller + USB adapter missplaces some buttons: A is where Y should be, X is where A should be etc. There is a way to correct this and remap all your buttons/axis to the right place. On Windows you’ll use a program called x360ce and on Linux you’ll use xboxdrv. I’ll explaing how to set xboxdrv for your USB controller on Linux.
grumbel/xboxdrv/) and compile it. Since this step is distro specific, I won’t cover it. If you’re not sure how to do it, ask for help in your distro’s forum.
Check if your distro loads xpad module to handle XBOX controller events:
# lsmod | grep xpad
If it returns a blank line, you’re fine, go straight to the next section. If it returns something else, you must unload xpad module before loading xboxdrv by executing this command:
List all your available input events:
# ls /dev/input/ | grep event*
It will probably range from event0 to event20. You’ll have to test each one of them until you find out which one is the event associated with your USB controller. To do so, enter the following command and press your controller buttons (press CTRL+C to exit after checking):
If you got the wrong event, nothing will happen when you press buttons. When you get the right event, you’ll notice because as soon as you press a button there will be a corresponding terminal output. Keep testing your available events until you find out which one is correct. In my case, /dev/input/event11 is associated with my PS2 controller.
If you have a PS3 controller, you can skip this section and go stragith for section 5. If you have any other controller, you must map it. To do so, while using evtest with the event associated to your controller (for example, # evtest /dev/input/event11), each time you press a button you’ll receive a terminal output like this:
Event: time 1380985017.964843, type 4 (EV_MSC), code 4 (MSC_SCAN), value 90003
Event: time 1380985017.964843, type 1 (EV_KEY), code 290 (BTN_THUMB2), value 1
In this case, I pressed the button corresponding to where the A button is on the XBOX controller, and this button is mapped as BTN_THUMB2. Then I pressed the button corresponding to where the B button is on the XBOX controller, and the output was this:
Event: time 1380985018.460841, type 4 (EV_MSC), code 4 (MSC_SCAN), value 90002
Event: time 1380985018.460841, type 1 (EV_KEY), code 289 (BTN_THUMB), value 1
This output tells me that this button is mapped with the name BTN_THUMB. Take note of all these names. Do this for all your buttons and all your axis. You must take note of their names to be able to map them properly later. In the end, you’ll have a list with all names and the corresponding XBOX buttons. You must map these buttons to valid XBOX buttons symbols:
Buttons: A, B, X, Y, RB (frontal upper right), RT (posterior upper right), LB (frontal upper left), LT (posterior upper left), START, BACK
Directional: DPAD_X (horizontal D-pad), DPAD_Y (vertical D-pad), X1 (left analog horizontal), Y1 (left analog vertical), X2 (right analog horizontal), Y2 (right analog vertical)
Analog clicks: TL (left analog click), TR (right analog click)
I made an image to illustrate these valid XBOX buttons symbols [lh4.googleusercontent.com] you’ll use to map your controller events. For a PS2 + USB adapter, this is how the final mapping list will look:
Note that if you have a PS2 controller too, you won’t have to map all your buttons again, since I already did this (just copy this list for further use). To see what each XBOX button is named after, you can use the built in xboxsrv help to see the valid names:
$ xboxsrv —help-button
$ xboxsrv —help-axis
$ xboxsrv —help-abs
If you have a PS3 controller, you don’t have to map your controller nor nothing. Just initialize xboxdrv like this and everything will be working:
# xboxdrv —silent —detach-kernel-driver
If you have any other controller, now that you have all your buttons and axis mapped, you must initialize xboxdrv properly. To do so, you’ll have to initialize it like this:
# xboxdrv —evdev [EVENT] —evdev-absmap [ABS MAP] —axismap [AXIS MAP] —evdev-keymap [BUTTONS MAP] —mimic-xpad —silent &
[EVENT] is the event associated with your controller (section 3 of this post) and [ABS MAP], [AXIS MAP] and [BUTTONS MAP] are your controller mapping (section 4 of this post). In my case, my PS2 controller + USB adapter is associated with /dev/input/event11 and has the above mapping, so I initialize xboxdrv like this:
# xboxdrv —evdev /dev/input/event11 —evdev-absmap ABS_X=x1,ABS_Y=y1,ABS_RZ=x2,ABS_Z=y2,ABS_HAT0X=dpad_x,ABS_HAT0Y=dpad_y —axismap -Y1=Y1,-Y2=Y2 —evdev-keymap BTN_TOP=x,BTN_TRIGGER=y,BTN_THUMB2=a,BTN_THUMB=b,BTN_BASE3=back,BTN_BASE4=start,BTN_BASE=lb,BTN_BASE2=rb,BTN_TOP2=lt,BTN_PINKIE=rt,BTN_BASE5=tl,BTN_BASE6=tr —mimic-xpad —silent &
Note that if you have a PS2 controller too, you will initialize xboxdrv exactly the same way I do, except for the event, which might be another one.
Источник