Showing with 1,183 additions and 289 deletions.
  1. +70 −1 main/SCsub
  2. +39 −0 main/default_controller_mappings.h
  3. +423 −0 main/gamecontrollerdb.txt
  4. +269 −0 main/gamecontrollerdb_204.txt
  5. +337 −0 main/gamecontrollerdb_205.txt
  6. +38 −0 main/godotcontrollerdb.txt
  7. +7 −288 main/input_default.cpp
@@ -2,7 +2,7 @@

Import('env')
from compat import byte_to_str

from collections import OrderedDict

def make_splash(target, source, env):

@@ -62,10 +62,79 @@ def make_app_icon(target, source, env):
g.write("};\n")
g.write("#endif")

def make_default_controller_mappings(target, source, env):
dst = target[0].srcnode().abspath
g = open(dst, "w")

g.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n")
g.write("#include \"default_controller_mappings.h\"\n")
g.write("#include \"typedefs.h\"\n")

# ensure mappings have a consistent order
platform_mappings = OrderedDict()
for src in source:
src_path = src.srcnode().abspath
f = open(src_path, "rb")

# read mapping file and skip header
mapping_file_lines = f.readlines()[2:]

current_platform = None
for line in mapping_file_lines:
if not line:
continue
line = line.strip()
if len(line) == 0:
continue
if line[0] == "#":
current_platform = line[1:].strip()
if current_platform not in platform_mappings:
platform_mappings[current_platform] = {}
elif current_platform:
line_parts = line.split(",")
guid = line_parts[0]
if guid in platform_mappings[current_platform]:
g.write("// WARNING - DATABASE {} OVERWROTE PRIOR MAPPING: {} {}\n".format(src_path, current_platform, platform_mappings[current_platform][guid]))
valid_mapping = True
for input_map in line_parts[2:]:
if "+" in input_map or "-" in input_map or "~" in input_map:
g.write("// WARNING - DISCARDED UNSUPPORTED MAPPING TYPE FROM DATABASE {}: {} {}\n".format(src_path, current_platform, line))
valid_mapping = False
break
if valid_mapping:
platform_mappings[current_platform][guid] = line

platform_variables = {
"Linux": "#if X11_ENABLED",
"Windows": "#ifdef WINDOWS_ENABLED",
"Mac OS X": "#ifdef OSX_ENABLED",
"Android": "#if defined(__ANDROID__)",
"iOS": "#ifdef IPHONE_ENABLED",
"Javascript": "#ifdef JAVASCRIPT_ENABLED",
"UWP": "#ifdef UWP_ENABLED",
}

g.write("const char* DefaultControllerMappings::mappings[] = {\n")
for platform, mappings in platform_mappings.items():
variable = platform_variables[platform]
g.write("{}\n".format(variable))
for mapping in mappings.values():
g.write("\t\"{}\",\n".format(mapping))
g.write("#endif\n")

g.write("};\n")

env.main_sources = []
env.add_source_files(env.main_sources, "*.cpp")

# order matters here. higher index controller database files write on top of lower index database files
controller_databases = ["#main/gamecontrollerdb.txt", "#main/gamecontrollerdb_205.txt", "#main/gamecontrollerdb_204.txt", "#main/godotcontrollerdb.txt"]

env.Depends("#main/default_controller_mappings.gen.cpp", controller_databases)
env.Command("#main/default_controller_mappings.gen.cpp", controller_databases, make_default_controller_mappings)

env.main_sources.append("#main/default_controller_mappings.gen.cpp")

Export('env')

env.Depends("#main/splash.gen.h", "#main/splash.png")
@@ -0,0 +1,39 @@
/*************************************************************************/
/* input_default.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/

#ifndef DEFAULT_CONTROLLER_MAPPINGS_H
#define DEFAULT_CONTROLLER_MAPPINGS_H

class DefaultControllerMappings {
public:
static const char *mappings[];
};

#endif // DEFAULT_CONTROLLER_MAPPINGS_H