From df8d3ec40ba5be54d0fea2d74709e803a588f526 Mon Sep 17 00:00:00 2001 From: Tom Black Date: Wed, 26 Sep 2018 17:27:57 -0700 Subject: Handle adding controller mappings through Window class --- lib/ruby2d/window.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'lib') 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 -- cgit v1.2.3