Last active
December 21, 2015 22:09
-
-
Save yazgoo/6373271 to your computer and use it in GitHub Desktop.
A controller mapper for Outer Wilds http://www-scf.usc.edu/~abhinavr/OW/home.html.
You need to install ruby, put it in the same directory as OuterWilds_7-30-13_Data, then run
ruby owcontroll.rb .
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# License: GPLv2 | |
# author: yazgoo | |
# Description: patches OuterWilds to support more controllers | |
# Usage: put in the same directory as OuterWilds_7-30-13_Data | |
require 'fileutils' | |
Mapping = './mapping.rb' | |
MainData = "OuterWilds_7-30-13_Data/mainData" | |
MainDataOrig = MainData + ".orig" | |
if not File.exist? Mapping | |
print "You must create a #{Mapping} file in your working directory, | |
which describes what button of your gamepad does what. | |
Under linux, to identify your controller buttons/axes IDs | |
you can use the command 'jstest /dev/input/js0' | |
To install it: | |
- on ubuntu: sudo apt-get install joystick | |
- on archlinux: joyutils via AUR | |
- from source: http://atrey.karlin.mff.cuni.cz/~vojtech/joystick/ | |
Do you want to create a bootstrap #{Mapping} (y/n) ? " | |
File.open Mapping, "w" do |f| | |
f.write "# first column keys name, second their ID | |
# this config has been tested with a Logitech RumblePad 2 USB | |
{ | |
:Horizontal => 0, | |
:Vertical => 1, | |
:Y => 3, | |
:X => 0, | |
:B => 2, | |
:A => 1, | |
:DPadUp => 4, | |
:RightStickClick => 11, | |
:LookX => 2, | |
:LookY => 3, | |
:LeftBumper => 4, | |
:RightBumper => 5, | |
:Start => 9, | |
:RightTrigger => 8, | |
:LeftTrigger => 5, | |
} | |
" | |
puts "written #{Mapping}, modify it and launch #{$0} again to patch" | |
end if gets.chomp == "y" | |
exit 1 | |
end | |
mapping = eval File.open(Mapping) { |f| f.read } | |
items = { | |
:Horizontal => { :type => :axis, :address => 0x5249}, | |
:Vertical => { :type => :axis, :address => 0x5289}, | |
:Y => { :type => :button, :address => 0x52b0}, | |
:X => { :type => :button, :address => 0x5364}, | |
:B => { :type => :button, :address => 0x5418}, | |
:A => { :type => :button, :address => 0x54cc}, | |
:DPadUp => { :type => :axis, :address => 0x55ac}, | |
:RightStickClick => {:type => :button, :address => 0x5844}, | |
:LookX => { :type => :axis, :address => 0x59e4}, | |
:LookY => { :type => :axis, :address => 0x5a68}, | |
:LeftBumper => { :type => :button, :address => 0x5ad0}, | |
:RightBumper => { :type => :button, :address => 0x5b94}, | |
:Start => { :type => :button, :address => 0x5c54}, | |
:RightTrigger => { :type => :axis, :address => 0x5de8}, | |
:LeftTrigger => { :type => :axis, :address => 0x5e74}, | |
} | |
FileUtils.mv MainData, MainDataOrig if not File.exist? MainDataOrig | |
pos = 0 | |
File.open(MainDataOrig, "rb") do |src| | |
File.open(MainData, "wb") do |dst| | |
items.each_pair do |name, v| | |
value = mapping[name] | |
if not value.nil? | |
dst.write src.read(items[name][:address] - pos) | |
pos = items[name][:address] | |
if items[name][:type] == :axis | |
dst.write [value].pack "C" | |
src.read 1 | |
pos += 1 | |
else | |
str = "joystick button #{value}" | |
dst.write [str.size].pack "C" | |
size = (src.read(1).unpack "C")[0] | |
3.times { dst.write [0].pack "C"; src.read(1) } | |
dst.write str | |
src.read size | |
src.read str.size - size if size < str.size | |
pos += str.size + 4 | |
end | |
end | |
end | |
dst.write src.read | |
puts "#{MainData} was patched" | |
puts "Original available at #{MainDataOrig}" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment