summaryrefslogtreecommitdiffhomepage
path: root/lib
diff options
context:
space:
mode:
authorTom Black <[email protected]>2018-09-26 17:27:57 -0700
committerTom Black <[email protected]>2018-09-26 17:27:57 -0700
commitdf8d3ec40ba5be54d0fea2d74709e803a588f526 (patch)
treed6a4d76f9df9ea42c81827f6ae20f899e89a4333 /lib
parente2fb9c34d6f56ec833e0451b26a02c304afaf71b (diff)
downloadruby2d-df8d3ec40ba5be54d0fea2d74709e803a588f526.tar.gz
ruby2d-df8d3ec40ba5be54d0fea2d74709e803a588f526.zip
Handle adding controller mappings through Window class
Diffstat (limited to 'lib')
-rw-r--r--lib/ruby2d/window.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/ruby2d/window.rb b/lib/ruby2d/window.rb
index 385070b..fee0893 100644
--- a/lib/ruby2d/window.rb
+++ b/lib/ruby2d/window.rb
@@ -54,6 +54,9 @@ module Ruby2D
# Mouse X and Y position in the window
@mouse_x, @mouse_y = 0, 0
+ # Controller axis and button mappings file
+ @controller_mappings = File.expand_path('~') + "/.ruby2d/controllers.txt"
+
# Renderable objects currently in the window, like a linear scene graph
@objects = []
@@ -314,6 +317,15 @@ module Ruby2D
end
end
+ # Add controller mappings from file
+ def add_controller_mappings
+ unless RUBY_ENGINE == 'opal'
+ if File.exists? @controller_mappings
+ ext_add_controller_mappings(@controller_mappings)
+ end
+ end
+ end
+
# Controller callback method, called by the native and web extentions
def controller_callback(which, type, axis, value, button)
# All controller events