Oolite Bulletins

For information and discussion about Oolite.
It is currently Wed Nov 22, 2017 1:42 am

All times are UTC




Post new topic  Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Wed May 28, 2014 1:35 pm 
Offline
Deadly
Deadly
User avatar

Joined: Tue Apr 29, 2014 5:57 pm
Posts: 169
Location: My God it's full of stars
Hello all

I've been ooliting for only a few weeks. Starting with Keyboard control, then, a brief flirtation with 'fly by mouse' and finally onto an original xbox controller. Which is where the Story really starts :mrgreen:

First up I am using the latest crunchbang linux and am also an ubuntu user. The following should work on all flavours YMMV though. If there are issues google is your friend.

First I added the PPA from grumble -
Code:
sudo add-apt-repository ppa:grumbel/ppa
sudo apt-get update
sudo apt-get install xboxdrv
You will need to do the following -

The original xbox one controller I modded by changing it's existing plug to a standard PC usb plug. -

http://www.instructables.com/id/X-Box-C ... -on-PCMac/

So with xboxdrv installed and the handset modded we are now good to go.

At it's most basic to have oolite flight/combat control under the eagis of xboxdrv you would do the following in terminal.

Please do not be afraid of this Command Line Interface. It is your friend -

First we need to ensure a module called xpad is blacklisted. This is another joystick interface software app. So type this -
Code:
echo "blacklist xpad" | sudo tee /etc/modprobe.d/blacklist-xpad.conf
Then type -
Code:
sudo rmmod xpad
This just saves you rebooting. On the next reboot xpad wont be loaded ever. Unless removes from the blacklist of course.

Plug your controller in now, then -

This line of code suits the HOME install of oolite. Basically everything is in the GNUstep folder
Code:
sudo xboxdrv --dpad-as-button --trigger-as-button -s ~/GNUstep/Applications/Oolite/oolite.app/oolite-wrapper/
If you did the SYSTEM WIDE install you would use the following code -
Code:
sudo xboxdrv --dpad-as-button --trigger-as-button -s /opt/Oolite/oolite.app/oolite-wrapper]
Oolite will pop up and then you can go into the Joystick Settings page and set up the axis controls and buttons to suit yourself.

Of course you can then go on with the 'game'.

The above codes ensure that the dpad and triggers work. also as you have to leave terminal open the -s on the end stops reams of key presses filling the terminal screen.

So all well and good at this point? You will have to run the above codes everytime you want to play, with the controller, of course.

But wait! There's more! :shock:

How would you like to automate the above to a menu entry. One click and everything fires up........Oh and how about expanding the remit of some of the controller buttons? Interested? Then read on...

First of all we need to create a xxxxx.xboxdrv config file. In my case it is called oolite.xboxdrv. This contains information on button settings, axis settings and 'other tweaks'. The following is what works for me. It is not exhaustive and may, in some part, not be best practice but it works thus far.
Code:
[xboxdrv]
ui-clear=false
silent=true
deadzone=1500
dpad-as-button=true
trigger-as-button=true

#The sticks. Left is x/y1 Right is x/y2
[ui-axismap]
X1^sen:-0.3^resp:-32768:-23014:-15417:-9709:-5618:-2876:-1213:-359:-44:0:44:359:1213:2876:5618:9708:15417:23013:32767=ABS_X
Y1^sen:-0.3^resp:-32768:-23014:-15417:-9709:-5618:-2876:-1213:-359:-44:0:44:359:1213:2876:5618:9708:15417:23013:32767=ABS_Y
X2^sen:-0.3^resp:-32768:-23014:-15417:-9709:-5618:-2876:-1213:-359:-44:0:44:359:1213:2876:5618:9708:15417:23013:32767=ABS_RX

#The coloured buttons
[ui-buttonmap]
a=KEY_T
lt+a=KEY_LEFTSHIFT+KEY_T
b=KEY_N
lt+b=KEY_LEFTSHIFT+KEY_N
x=KEY_E
lt+x=KEY_U
y=KEY_Y

#The white and black buttons. As per the original Xbox controller
[ui-buttonmap]
lb=KEY_S
lt+lb=KEY_J
rb=KEY_W
lt+rb=KEY_I

#The Triggers
[ui-buttonmap]
lt+rt=KEY_M
rt=KEY_A

#The Dpad
[ui-buttonmap]
dl=KEY_KPPLUS
lt+dl=XK_backslash
dr=KEY_KPMINUS
lt+dr=KEY_LEFTSHIFT+XK_backslash
du=KEY_R
dd=KEY_B

#The Back/Start buttons
[ui-buttonmap]
back=KEY_ESC
start=KEY_0
lt+start=KEY_TAB

#The thumbstick buttons
[ui-buttonmap]
tl=KEY_KPASTERISK
#tr set in oolite F2 game option joystick menu. For fine control of axis
tr=

# EOF #
This image has the controls anotated to cross reference with the above.
Image

If you look at the config file, particularly the 'buttonmap' headed areas you should see that to the left of the '=' is the controller notation as per the diagram. Everything to the right are the key codes which map to the keyboard letters/symbols.

Also notice there are pairs of code each side on some of the buttonmaps. Simply put I am using the left trigger (lt) as a 'shift' button. Basically it means I can make one button do two jobs. i.e. the right trigger fires the laser (rt=KEY_A) but if I do this - (lt+rt=KEY_M) It will launch a missile, if targeted.

For the 'shift N', keyboard command, the code used to prime equipment the xbox code is KEY_LEFTSHIFT+KEY_N. Simples!

You should be able to identify all the KEY_commands in the config file as they are simply the keyboard strokes used in the game.

OK look at the axismap further up. This still causes my nose to bleed :? Basically each axis, there are 4, can have a specific setup for sensitivity, responsecurve, deadzones etc... ooh there goes my nose again :o In this instance only sensitivity and a responsecurve are used. Sensitivity can go from -1.0 to 1.0 in increments of 0.1 if you will. negative value reduces sensitivity positive increases sensitivity. The string of numbers is the responsecurve. generated with a python script that is in the xboxdrv examples folder.

The setup I have seems to be OK....

At the very top are some general commands.

ui-clear=false - Usually set to true. This clears the actual games key map making way for the config files mapping.
silent=true - stops concurrent output of any key axis movement in terminal being 'printed'
deadzone=1500 - For joysticks where they may be a little slack at rest causing unwanted movement, at the slightest twitch, in game. 1500 seems to work for this setup up to 4000/6000 can be a useful range also.
dpad-as-button/trigger-as-button=true - without these lines niether would function.

The config file is saved in /home/yourname folder as oolite.xboxdrv . Now to try it out. Put the following in terminal. Ensure your controller is plugged in and in this instance in the config file change the 'ui-clear=false' to true. Remember to save the change
Code:
sudo xboxdrv --config ~/oolite.xboxdrv ~/GNUstep/Applications/Oolite/oolite.app/oolite-wrapper/
If you did the SYSTEM WIDE install you would use the following code -
Code:
sudo xboxdrv --config ~/oolite.xboxdrv /opt/Oolite/oolite.app/oolite-wrapper]
The game should pop up and when you launch everything should work on the controller.

I will go on to the automagic menu entry later. For now I hope this helps someone even if it's only me :mrgreen:

BBD

_________________
Do not press this button [O].....Oh Bugger!
Cobra MKIII Grendal's Dam


Last edited by Bangbangduck on Wed May 28, 2014 9:07 pm, edited 1 time in total.

Top
   
PostPosted: Wed May 28, 2014 7:52 pm 
Offline
---- E L I T E ----
---- E L I T E ----
User avatar

Joined: Mon Apr 06, 2009 12:20 pm
Posts: 6241
Location: Aboard the Pitviper S.E. "Blackwidow"
Very nice, and concise.. well done! 8)

_________________
Most games have some sort of paddling-pool-and-water-wings beginning to ease you in: Oolite takes the rather more Darwinian approach of heaving you straight into the ocean, often with a brick or two in your pockets for luck. ~ Disembodied


Top
   
PostPosted: Wed May 28, 2014 9:10 pm 
Offline
Deadly
Deadly
User avatar

Joined: Tue Apr 29, 2014 5:57 pm
Posts: 169
Location: My God it's full of stars
Thank you. I even nipped upstairs to assualt my PC Oolite install to make sure it all worked. It took 20 minutes mostly wondering why nothing worked...........Ah........Thats not the controller lead you've plugged in :oops: :mrgreen:

Of course where I was checking out the changes, Usle, I am now known by the name Yo-yo duck due to the nature of launch, test the flight configs, and dock (manually of course).

BBD

_________________
Do not press this button [O].....Oh Bugger!
Cobra MKIII Grendal's Dam


Top
   
PostPosted: Thu May 29, 2014 1:29 pm 
Offline
Deadly
Deadly
User avatar

Joined: Tue Apr 29, 2014 5:57 pm
Posts: 169
Location: My God it's full of stars
Hi Chaps

OK here we go with the final bit. Automagic launch with a menu entry.

Now as far as I can see this is a little bit 'hackish'. From the previous entry you will know that we have to 'sudo' the command line that fires up xboxdrv and then the game.

The sudo is primarily to run xboxdrv which needs root authorisation to work. I did find a script 'out there' that when run should have asked for you password and then it should have fired everything up. It didn't work and I am not a programmer so haven't a clue how to get it working. So I found another but it needs a couple of things done in terminal for it to do the job.

So heres the warning. This changes the root privelidges of xboxdrv. I've done it and the world hasn't come to an end BUT I know little of this so if your not happy with the idea then maybe hold off in the hope that a linux guru pops up and says -

"You didn't want to do that.. You should have done this"

Otherwise here we go. In a text editor (NOT NOTEPAD) type the following. The 'Start xboxdrvline' and 'launch your favourite game line' should reflect where your oolite.xboxdrv and the game is installed as in the previous post.
Code:
#!/bin/sh

# Start xboxdrv and remember its PID in the variable XBOXPID
xboxdrv --config ~/oolite.xboxdrv &
XBOXPID=$!

# Give xboxdrv a second to startup and create the device
sleep 1

# Launch your favorite game
/home/fenris/GNUstep/Applications/Oolite/oolite.app/oolite-wrapper

# Kill xboxdrv and wait for it to finish
kill $XBOXPID
wait $XBOXPID

# EOF #
save as 'oolite_xboxdrv.sh' without the quotes.

I created a folder in my home folder called 'xboxdrv_scripts' and put the new file in it.

now in terminal cd to this same folder and the type the following followed by enter -
Code:
chmod u+x oolite_xboxdrv.sh
This makes it executable (makes it work)

Now the hackish bit -

Type these one at a time followed by enter
Code:
sudo chown root /usr/bin/xboxdrv
sudo chmod +s /usr/bin/xboxdrv
This allows xboxdrv to be 'turned on' by the script without having to use 'sudo'

Now in your linux OS system there should be a menu editor. We need to make a menu entry. I use openbox GUI as this is what is in crunchbang. But the principle is the same.

You enter a name - Oolite because that what it is.
then enter command. This the path to the oolite_xboxdrv.sh file. You can often browse to this to automatically enter this string.
There may be a 'comments' entry. 'Oolite FTW' for instance.
You may even be able to pick an icon image for it.

Here's an image of my openbox menu. There are two entries one for the script version to run everything. The other just runs oolite without xboxdrv.

Image

Once this is done plug your controller in and click the menu entry. You should be good to go.

Now a couple of things that will/may be important. In my xboxdrv config I set ui-clear=false. This stops a minor problem where you can't select the 'roll/pitch precision toggle' . When the game opens go to the joystick config page and other than the 3 axis clear any entrys with the 'u' key if any. Otherwise there may be conflicts. The only other entry in this menu you will find usefull is the 'roll/pitch precision toggle' I set this with the (tr) of the game pad. That is the right stick push down button. It's useful for getting the enemy in your sights.

I had some issues with my yaw not working with the menu entry launch but working if launched via terminal. This is down to the 'sudo' difference. If you do the command line version all your button strokes/Axis are entered into the joystick config, at least as far as the single key controls go. Your shift+key will still work. With the menu entry version the configs are not passed to the joystick control page. The X1/Y1 axis is : pitch/roll I think because it is treated as a joystick. But the yaw :X2 may not be as it is a possible option of your hardware. No other buttons are though. If the Yaw isn't set just do it manually on the joystick config page. But all your button strokes will still work so don't worry.

Fingers crossed I have this down right. If anyone knows how to do a sudo driven menu entry to do the above please show us mere mortals.

BBD

_________________
Do not press this button [O].....Oh Bugger!
Cobra MKIII Grendal's Dam


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 4 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 6 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
cron
Powered by phpBB® Forum Software © phpBB Limited