commit 28e24736f38fe64bb756fa15e46a51abaa3537b4 Author: a327ex Date: Thu Feb 18 01:11:25 2021 -0300 Day 1 diff --git a/.ctrlp b/.ctrlp new file mode 100644 index 0000000..e69de29 diff --git a/arena.lua b/arena.lua new file mode 100644 index 0000000..142561a --- /dev/null +++ b/arena.lua @@ -0,0 +1,42 @@ +Arena = Object:extend() +Arena:implement(State) +Arena:implement(GameObject) +function Arena:init(name) + self:init_state(name) + self:init_game_object() + self.main = Group():set_as_physics_world(32, 0, 0, {'player', 'enemy', 'projectile', 'enemy_projectile'}) + self.effects = Group() + self.ui = Group():no_camera() + self.main:disable_collision_between('player', 'player') + + self.x1, self.y1 = gw/2 - 0.8*gw/2, gh/2 - 0.8*gh/2 + self.x2, self.y2 = gw/2 + 0.8*gw/2, gh/2 + 0.8*gh/2 + + Wall{group = self.main, vertices = math.to_rectangle_vertices(-40, -40, self.x1, gh + 40), color = bg[-1]} + Wall{group = self.main, vertices = math.to_rectangle_vertices(self.x2, -40, gw + 40, gh + 40), color = bg[-1]} + Wall{group = self.main, vertices = math.to_rectangle_vertices(self.x1, -40, self.x2, self.y1), color = bg[-1]} + Wall{group = self.main, vertices = math.to_rectangle_vertices(self.x1, self.y2, self.x2, gh + 40), color = bg[-1]} + + self.player = Unit{group = self.main, x = gw/2, y = gh/2, player = true, leader = true, character = 'vagrant'} + -- self.player:add_follower(Unit{group = self.main, player = true, color = red[0]}) +end + + +function Arena:on_enter(from) + +end + + +function Arena:update(dt) + self:update_game_object(dt*slow_amount) + self.main:update(dt*slow_amount) + self.effects:update(dt*slow_amount) + self.ui:update(dt*slow_amount) +end + + +function Arena:draw() + self.main:draw() + self.effects:draw() + self.ui:draw() +end diff --git a/assets/fonts/FatPixelFont.ttf b/assets/fonts/FatPixelFont.ttf new file mode 100644 index 0000000..feaf675 Binary files /dev/null and b/assets/fonts/FatPixelFont.ttf differ diff --git a/assets/fonts/PixulBrush-Mono.ttf b/assets/fonts/PixulBrush-Mono.ttf new file mode 100644 index 0000000..4856510 Binary files /dev/null and b/assets/fonts/PixulBrush-Mono.ttf differ diff --git a/assets/fonts/PixulBrush.ttf b/assets/fonts/PixulBrush.ttf new file mode 100644 index 0000000..70316fd Binary files /dev/null and b/assets/fonts/PixulBrush.ttf differ diff --git a/assets/fonts/fonts_go_here.txt b/assets/fonts/fonts_go_here.txt new file mode 100644 index 0000000..e69de29 diff --git a/assets/images/images_go_here.txt b/assets/images/images_go_here.txt new file mode 100644 index 0000000..e69de29 diff --git a/assets/maps/maps_go_here.txt b/assets/maps/maps_go_here.txt new file mode 100644 index 0000000..e69de29 diff --git a/assets/shaders/combine.frag b/assets/shaders/combine.frag new file mode 100644 index 0000000..1815c3e --- /dev/null +++ b/assets/shaders/combine.frag @@ -0,0 +1,4 @@ +vec4 effect(vec4 vcolor, Image texture, vec2 tc, vec2 pc) { + vec4 tex_color = Texel(texture, tc); + return vec4(vcolor.rgb*tex_color.rgb, tex_color.a); +} diff --git a/assets/shaders/default.vert b/assets/shaders/default.vert new file mode 100644 index 0000000..9627a38 --- /dev/null +++ b/assets/shaders/default.vert @@ -0,0 +1,3 @@ +vec4 position(mat4 transform_projection, vec4 vertex_position) { + return transform_projection * vertex_position; +} diff --git a/assets/shaders/displacement.frag b/assets/shaders/displacement.frag new file mode 100644 index 0000000..ce4d024 --- /dev/null +++ b/assets/shaders/displacement.frag @@ -0,0 +1,8 @@ +extern Image displacement_map; + vec4 effect(vec4 color, Image texture, vec2 tc, vec2 pc) { + vec4 dp = Texel(displacement_map, tc); + vec2 p = tc; + p.x += (dp.r*2.0 - 1.0)*0.025*dp.a; + p.y += (dp.g*2.0 - 1.0)*0.025*dp.a; + return color*Texel(texture, p); +} diff --git a/assets/shaders/full_combine.frag b/assets/shaders/full_combine.frag new file mode 100644 index 0000000..c8dc2a7 --- /dev/null +++ b/assets/shaders/full_combine.frag @@ -0,0 +1,4 @@ +vec4 effect(vec4 vcolor, Image texture, vec2 tc, vec2 pc) { + vec4 tex_color = Texel(texture, tc); + return vec4(vcolor.rgb + tex_color.rgb, tex_color.a); +} diff --git a/assets/shaders/replace.frag b/assets/shaders/replace.frag new file mode 100644 index 0000000..16934c7 --- /dev/null +++ b/assets/shaders/replace.frag @@ -0,0 +1,4 @@ +vec4 effect(vec4 vcolor, Image texture, vec2 tc, vec2 pc) { + vec4 tex_color = Texel(texture, tc); + return vec4(vcolor.rgb, tex_color.a); +} diff --git a/assets/shaders/shadow.frag b/assets/shaders/shadow.frag new file mode 100644 index 0000000..8c7547c --- /dev/null +++ b/assets/shaders/shadow.frag @@ -0,0 +1,3 @@ +vec4 effect(vec4 vcolor, Image texture, vec2 tc, vec2 pc) { + return vec4(0.1, 0.1, 0.1, Texel(texture, tc).a*0.5); +} diff --git a/assets/sounds/sounds_go_here.txt b/assets/sounds/sounds_go_here.txt new file mode 100644 index 0000000..e69de29 diff --git a/builds/web/web_build_goes_here.txt b/builds/web/web_build_goes_here.txt new file mode 100644 index 0000000..e69de29 diff --git a/builds/windows/windows_build_goes_here.txt b/builds/windows/windows_build_goes_here.txt new file mode 100644 index 0000000..e69de29 diff --git a/conf.lua b/conf.lua new file mode 100644 index 0000000..a456323 --- /dev/null +++ b/conf.lua @@ -0,0 +1,7 @@ +function love.conf(t) + t.version = "11.3" + t.window.width = 960 + t.window.height = 540 + t.window.vsync = 1 + t.window.msaa = 0 +end diff --git a/devlog.md b/devlog.md new file mode 100644 index 0000000..d13a1c1 --- /dev/null +++ b/devlog.md @@ -0,0 +1,30 @@ +# Day 1 - 17/02/21 + +Ideaguyed the basics of the game's classes and mechanics, and implemented basic movement and setting of all the stats it will have. Here are the initial characters, synergies and stats I want to have: + +### Characters + +* Vagrant: shoots a projectile at any nearby enemy, medium range +* Scout: throws a knife at any nearby enemy that chains, small range +* Cleric: heals every unit when any one drops below 50% HP +* Swordsman: deals damage in an area around the unit, small range +* Archer: shoots an arrow at any nearby enemy in front of the unit, long range +* Wizard: shoots a projectile at any nearby enemy and deals AoE damage on contact, small range + +### Synergies + +* Ranger: yellow, buff attack speed +* Warrior: orange, buff attack damage +* Healer: green, buff healing effectiveness +* Mage: blue, debuff enemy defense +* Cycler: purple, buff cycle speed + +### Stats + +* HP +* Damage +* Attack speed: stacks additively, starts at 1 and capped at minimum 0.125s or +300% +* Defense: if defense >= 0 then dmg_m = 100/(100+defense) else dmg_m = 2-100/(100-defense) +* Cycle speed: stacks additively, starts at 2 and capped at minimum 0.5s or +300% + +Perhaps I'm overengineering it already with the stats but I wanna see where this goes. From SHOOTRX it seems like figuring out stats earlier is better than later, and these seem like they have enough flexibility. diff --git a/engine/datastructures/graph.lua b/engine/datastructures/graph.lua new file mode 100644 index 0000000..8643045 --- /dev/null +++ b/engine/datastructures/graph.lua @@ -0,0 +1,283 @@ +Graph = Object:extend() +function Graph:init() + self.adjacency_list = {} + self.nodes = {} + self.edges = {} + self.floyd_dists = {} +end + + +-- Nodes can be of any type but must be unique +-- graph = Graph() +-- graph:add_node(1) +-- graph:add_node('node_2') +function Graph:add_node(node) + self.adjacency_list[node] = {} + self:_set_nodes() +end + + +-- Returns a node after searching for it by property, the property value must be unique among all nodes +-- graph = Graph() +-- graph:add_node({id = 1}) +-- graph:add_node({id = 2}) +-- graph:get_node_by_property('id', 1) -> original {id = 1} table +function Graph:get_node_by_property(key, value) + for node, _ in pairs(self.adjacency_list) do + if node[key] == value then + return node + end + end +end + + +-- Runs function f for all nodes in the graph +-- graph = Graph() +-- graph:add_node(1) +-- graph:add_node('node_2') +-- graph:for_all_nodes(function(node) print(node) end) -> prints 1, 'node_2' +function Graph:for_all_nodes(f) + for _, node in ipairs(self.nodes) do + f(node) + end +end + + +-- Runs function f for all edges in the graph +-- graph = Graph() +-- graph:add_node(1) +-- graph:add_node('node_2') +-- graph:add_node(3) +-- graph:add_edge(1, 'node_2') +-- graph:add_edge('node_2', 3) +-- graph:for_all_edges(function(node1, node2) print(node1, node2) end) -> prints 1, 'node_2'; prints 'node_2', 3 +function Graph:for_all_edges(f) + for _, edge in ipairs(self.edges) do + f(edge[1], edge[2]) + end +end + + +-- Returns a table containing all neighbors of the given node. +-- graph = Graph() +-- graph:add_node(1) +-- graph:add_node('node_2') +-- graph:add_node(3) +-- graph:add_edge(1, 'node_2') +-- graph:add_edge('node_2', 3) +-- graph:get_node_neighbors('node_2') -> {1, 3} +function Graph:get_node_neighbors(node) + return self.adjacency_list[node] +end + + +-- graph = Graph() +-- graph:add_node(1) +-- graph:remove_node(1) +function Graph:remove_node(node) + for _node, list in pairs(self.adjacency_list) do + self:remove_edge(node, _node) + end + self.adjacency_list[node] = nil + self:_set_nodes() +end + + +local function contains_edge(table, edge) + for _, v in ipairs(table) do + if (v[1] == edge[1] and v[2] == edge[2]) or (v[1] == edge[2] and v[2] == edge[1]) then + return true + end + end + return false +end + + +-- graph = Graph() +-- graph:add_node(1) +-- graph:add_node('node_2') +-- graph:add_edge(1, 'node_2') +function Graph:add_edge(node1, node2) + if table.any(self.adjacency_list[node1], function(v) return v == node2 end) then return end + table.insert(self.adjacency_list[node1], node2) + table.insert(self.adjacency_list[node2], node1) + self:_set_edges() +end + + +-- graph = Graph() +-- graph:add_node(1) +-- graph:add_node('node_2') +-- graph:add_edge(1, 'node_2') +-- graph:remove_edge(1, 'node_2') +function Graph:remove_edge(node1, node2) + for i, node in ipairs(self.adjacency_list[node1]) do + if node == node2 then + table.remove(self.adjacency_list[node1], i) + break + end + end + for i, node in ipairs(self.adjacency_list[node2]) do + if node == node1 then + table.remove(self.adjacency_list[node2], i) + break + end + end + self:_set_edges() +end + + +-- graph = Graph() +-- graph:add_node(1) +-- graph:add_node('node_2') +-- graph:add_node('node_3') +-- graph:add_edge(1, 'node_2') +-- graph:add_edge('node_2', 'node_3') +-- path = graph:shortest_path_bfs(1, 'node_3') +-- print(path) -> {1, 'node_2', 'node_3'} +function Graph:shortest_path_bfs(node1, node2) + local path = {} + local visited = {} + local queue = {} + table.insert(queue, node1) + visited[node1] = true + + while #queue > 0 do + local node = table.remove(queue, 1) + if node == node2 then + local linear_path = {} + local current_node = node2 + table.insert(linear_path, 1, current_node) + while current_node ~= node1 do + current_node = path[current_node] + table.insert(linear_path, 1, current_node) + end + return linear_path + end + + for _, neighbor in ipairs(self.adjacency_list[node]) do + if not visited[neighbor] then + path[neighbor] = node + visited[neighbor] = true + table.insert(queue, neighbor) + end + end + end +end + + +function Graph:get_distance_between_nodes(node1, node2) + return self.floyd_dists[node1][node2] +end + + +-- Comments follow pseudocode from http://en.wikipedia.org/wiki/Floyd%E2%80%93Warshall_algorithm. +-- graph = Graph() +-- graph:add_node(1) +-- graph:add_node('node_2') +-- graph:add_edge(1, 'node_2') +-- graph:floyd_warshall() +-- print(graph.floyd_dists[1]['node_2']) -> 1 +function Graph:floyd_warshall() + self:_set_nodes() + self:_set_edges() + + -- initialize multidimensional to be array + for _, node in ipairs(self.nodes) do + self.floyd_dists[node] = {} + end + + -- let floyd_dist be a |V|x|V| array of minimun distance initialized to infinity + for _, node in ipairs(self.nodes) do + for _, _node in ipairs(self.nodes) do + self.floyd_dists[node][_node] = 10000 -- 10000 is big enough for an unweighted graph + self.floyd_dists[_node][node] = 10000 + end + end + + -- set dist[v][v] to 0 + for _, node in ipairs(self.nodes) do + self.floyd_dists[node][node] = 0 + end + + -- set dist[u][v] to w(u, v) which is always 1 in the case of an unweighted graph + for _, edge in ipairs(self.edges) do + self.floyd_dists[edge[1]][edge[2]] = 1 + self.floyd_dists[edge[2]][edge[1]] = 1 + end + + -- main triple loop + for _, nodek in ipairs(self.nodes) do + for _, nodei in ipairs(self.nodes) do + for _, nodej in ipairs(self.nodes) do + if self.floyd_dists[nodei][nodek] + self.floyd_dists[nodek][nodej] < self.floyd_dists[nodei][nodej] then + self.floyd_dists[nodei][nodej] = self.floyd_dists[nodei][nodek] + self.floyd_dists[nodek][nodej] + end + end + end + end +end + + +function Graph:_get_edge(node1, node2) + for _, node in ipairs(self.adjacency_list[node1]) do + if node == node2 then + return true + end + end + return false +end + + +function Graph:_set_nodes() + self.nodes = {} + for node, _ in pairs(self.adjacency_list) do + table.insert(self.nodes, node) + end +end + + +function Graph:_set_edges() + self.edges = {} + for node, list in pairs(self.adjacency_list) do + for _, _node in ipairs(list) do + if not contains_edge(self.edges, {node, _node}) then + table.insert(self.edges, {node, _node}) + end + end + end +end + + +function Graph:__tostring() + local str = "----\nAdjacency List: \n" + for node, list in pairs(self.adjacency_list) do + str = str .. node .. " -> " + for _, adj in ipairs(list) do + str = str .. adj .. ", " + end + str = string.sub(str, 0, -3) + str = str .. "\n" + end + str = str .. "\n" + str = str .. "Nodes: \n" + for _, node in ipairs(self.nodes) do + str = str .. node .. "\n" + end + str = str .. "\n" + str = str .. "Edges: \n" + for _, edge in ipairs(self.edges) do + str = str .. edge[1] .. ", " .. edge[2] + str = str .. "\n" + end + str = str .. "\n" + str = str .. "Floyd Warshall Distances: \n" + for node, _ in pairs(self.floyd_dists) do + for _node, _ in pairs(self.floyd_dists[node]) do + str = str .. "(" .. node .. ", " .. _node .. ") = " .. self.floyd_dists[node][_node] + str = str .. "\n" + end + end + str = str .. "----\n" + return str +end diff --git a/engine/datastructures/grid.lua b/engine/datastructures/grid.lua new file mode 100644 index 0000000..f290bf2 --- /dev/null +++ b/engine/datastructures/grid.lua @@ -0,0 +1,260 @@ +-- Starts a new grid with 10 width, 5 height and all values 0ed +-- grid = Grid(10, 5, 0) +-- Starts a new grid with 3 width, 2 height and values 1, 2, 3 in the first row and 3, 4, 5 in the second row. +-- grid = Grid(3, 2, {1, 2, 3, 4, 5, 6}) +Grid = Object:extend() +function Grid:init(w, h, v) + self.grid = {} + self.w, self.h = w, h + if type(v) ~= 'table' then + for j = 1, h do + for i = 1, w do + self.grid[w*(j-1) + i] = v or 0 + end + end + else + for j = 1, h do + for i = 1, w do + self.grid[w*(j-1) + i] = v[w*(j-1) + i] + end + end + end +end + + +-- Creates a copy of a grid instance +-- grid = Grid(10, 5, 0) +-- grid_clone = grid:clone() +function Grid:clone() + local new_grid = Grid(self.w, self.h, 0) + new_grid.grid = table.deep_copy(self.grid) + return new_grid +end + + +-- grid = Grid(10, 5, 0) +-- grid:get(2, 2) -> 0 +-- grid:set(2, 2, 1) +-- grid:get(2, 2) -> 1 +-- grid:set(11, 1, 1) -> doesn't actually set because out of bounds, fails silently +function Grid:set(x, y, v) + if not self:_is_outside_bounds(x, y) then + self.grid[self.w*(y-1) + x] = v + end +end + + +-- Applies function f to all grid elements +-- If i1,j1 and i2,j2 are passed then it applies only to the subgrid defined by those values. +-- grid:apply(function(grid, i, j) grid:set(i, j, 0) end) -> sets all elements in the grid to 0 +-- grid:apply(function(grid, i, j) grid:set(i, j, 0) end, 2, 2, 4, 4) -> sets all elements in the subgrid 2,2x4,4 to 0 +function Grid:apply(f, i1, j1, i2, j2) + if i1 and j1 and i2 and j2 then + for i = i1, i2 do + for j = j1, j2 do + f(self, i, j) + end + end + else + for i = 1, self.w do + for j = 1, self.h do + f(self, i, j) + end + end + end +end + + +-- grid = Grid(10, 5, 0) +-- print(grid:get(2, 2)) -> 0 +-- grid:set(2, 2, 1) +-- grid:get(2, 2) -> 1 +-- grid:get(11, 1) -> nil, out of bounds, fails silently +function Grid:get(x, y) + if not self:_is_outside_bounds(x, y) then + return self.grid[self.w*(y-1) + x] + end +end + + +-- Converts the 2D grid to a 1D array +-- If i1,j1 and i2,j2 are passed then it applies only to the subgrid defined by those values. +-- grid = Grid(3, 2, 1) +-- grid:to_table() -> {1, 1, 1, 1, 1, 1} +-- grid:to_table(1, 1, 2, 2) -> {1, 1, 1, 1} +function Grid:to_table(i1, j1, i2, j2) + local t = {} + if i1 and j1 and i2 and j2 then + for j = j1, j2 do + for i = i1, i2 do + if self:get(i, j) then + table.insert(t, self:get(i, j)) + end + end + end + else + for j = 1, self.h do + for i = 1, self.w do + table.insert(t, self:get(i, j)) + end + end + end + return t, self.w +end + + +-- Rotates the grid in an anti-clockwise direction +-- grid = Grid(3, 2, {1, 2, 3, 4, 5, 6}) -> the grid looks like this: +-- [1, 2, 3] +-- [4, 5, 6] +-- grid:rotate_anticlockwise() -> now the grid looks like this: +-- [3, 6] +-- [2, 5] +-- [1, 4] +-- grid:rotate_anticlockwise() -> now the grid looks like this: +-- [6, 5, 4] +-- [3, 2, 1] +function Grid:rotate_anticlockwise() + local new_grid = Grid(self.h, self.w, 0) + for i = 1, self.w do + for j = 1, self.h do + new_grid:set(j, i, self:get(i, j)) + end + end + + for i = 1, new_grid.w do + for k = 0, math.floor(new_grid.h/2) do + local v1, v2 = new_grid:get(i, 1+k), new_grid:get(i, new_grid.h-k) + new_grid:set(i, 1+k, v2) + new_grid:set(i, new_grid.h-k, v1) + end + end + + return new_grid +end + + +-- Rotates the grid in a clockwise direction +-- grid = Grid(3, 2, {1, 2, 3, 4, 5, 6}) -> the grid looks like this: +-- [1, 2, 3] +-- [4, 5, 6] +-- grid:rotate_clockwise() -> now the grid looks like this: +-- [4, 1] +-- [5, 2] +-- [6, 3] +-- grid:rotate_clockwise() -> now the grid looks like this: +-- [6, 5, 4] +-- [3, 2, 1] +function Grid:rotate_clockwise() + local new_grid = Grid(self.h, self.w, 0) + for i = 1, self.w do + for j = 1, self.h do + new_grid:set(j, i, self:get(i, j)) + end + end + + for j = 1, new_grid.h do + for k = 0, math.floor(new_grid.w/2) do + local v1, v2 = new_grid:get(1+k, j), new_grid:get(new_grid.w-k, j) + new_grid:set(1+k, j, v2) + new_grid:set(new_grid.w-k, j, v1) + end + end + + return new_grid +end + + +-- Assume the following grid: +-- grid = Grid(10, 10, { +-- 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, +-- 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, +-- 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, +-- 0, 0, 0, 1, 1, 1, 0, 0, 1, 0, +-- 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, +-- 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, +-- 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, +-- 1, 1, 0, 1, 1, 0, 0, 1, 1, 1, +-- 1, 1, 0, 1, 1, 0, 0, 0, 0, 1, +-- 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, +-- }) +-- In this grid you can see that there are multiple islands of solid positions formed. +-- This function will go over the entire grid and find all the islands of solid values, mark them with different numbers, and return them. +-- Essentially, it would do this: { +-- 1, 1, 1, 0, 0, 0, 0, 2, 2, 0, +-- 1, 1, 0, 0, 0, 0, 2, 2, 2, 2, +-- 1, 0, 0, 0, 3, 0, 2, 0, 2, 0, +-- 0, 0, 0, 3, 3, 3, 0, 0, 2, 0, +-- 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, +-- 4, 0, 0, 0, 0, 0, 0, 5, 0, 0, +-- 4, 4, 0, 0, 0, 0, 5, 5, 0, 0, +-- 4, 4, 0, 6, 6, 0, 0, 5, 5, 5, +-- 4, 4, 0, 6, 6, 0, 0, 0, 0, 5, +-- 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, +-- } +-- All values form islands that are connected, and each of those islands is identified by a different number. +-- The function returns this information in two formats: an array of positions per island number, and the marked grid as shown above. +-- islands, marked_grid = grid:flood_fill(1) -> (the value passed in is what the solid value should be, in the case of the array we're using as an example 1 is the proper value) +-- islands is an array that looks like this: { +-- [1] = {{1, 1}, {2, 1}, {3, 1}, {1, 2}, {2, 2}, {1, 3}}, +-- [2] = {{8, 1}, {9, 1}, {7, 2}, {8, 2}, {9, 2}, {10, 2}, {7, 3}, {9, 3}, {9, 4}}, +-- ... +-- [7] = {{3, 10}} +-- } +-- It contains all the positions in each island, indexed by island number. +-- And marked_grid is simply a Grid instance that looks exactly like the one shown above right after I said "Essentially, it would do this:" +function Grid:flood_fill(v) + local islands = {} + local marked_grid = Grid(self.w, self.h, 0) + + local flood_fill = function(i, j, color) + local queue = {} + table.insert(queue, {i, j}) + while #queue > 0 do + local x, y = unpack(table.remove(queue, 1)) + marked_grid:set(x, y, color) + table.insert(islands[color], {x, y}) + + if self:get(x, y-1) == v and marked_grid:get(x, y-1) == 0 then table.insert(queue, {x, y-1}) end + if self:get(x, y+1) == v and marked_grid:get(x, y+1) == 0 then table.insert(queue, {x, y+1}) end + if self:get(x-1, y) == v and marked_grid:get(x-1, y) == 0 then table.insert(queue, {x-1, y}) end + if self:get(x+1, y) == v and marked_grid:get(x+1, y) == 0 then table.insert(queue, {x+1, y}) end + end + end + + local color = 1 + islands[color] = {} + for i = 1, self.w do + for j = 1, self.h do + if self:get(i, j) == v and marked_grid:get(i, j) == 0 then + flood_fill(i, j, color) + color = color + 1 + islands[color] = {} + end + end + end + + islands[color] = nil + return islands, marked_grid +end + + +function Grid:_is_outside_bounds(x, y) + if x > self.w then return true end + if x < 1 then return true end + if y > self.h then return true end + if y < 1 then return true end +end + + +function Grid:__tostring() + local str = '' + for j = 1, self.h do + str = str .. '[' + for i = 1, self.w do + str = str .. self:get(i, j) .. ', ' + end + str = str:sub(1, -3) .. ']\n' + end + return str +end diff --git a/engine/datastructures/string.lua b/engine/datastructures/string.lua new file mode 100644 index 0000000..ef09a92 --- /dev/null +++ b/engine/datastructures/string.lua @@ -0,0 +1,45 @@ +-- Returns the substring to the left of the first instance of the pattern passed in +-- a = 'assets/images/player_32.png' +-- a:left('/') -> 'assets' +function string:left(p) + local i = self:find(p) + if i then + local out = self:sub(1, i-1) + return out ~= "" and out + end +end + + +-- Returns the substring to the right of the first instance of the pattern passed in +-- a = 'assets/images/player_32.png' +-- a:right('/') -> 'images/player_32.png' +function string:right(p) + local _, j = self:find(p) + if j then + local out = self:sub(j+1) + return out ~= "" and out + end +end + + +-- Splits the string into words in a table according to the separator pattern passed in +-- paid_comment = 'This engine is really great!' +-- paid_comment:split('%s') -> {'This', 'engine', 'is', 'really', 'great!'} +function string:split(s) + if not s then s = "%s" end + local out = {} + for str in self:gmatch("([^" .. s .. "]+)") do + table.insert(out, str) + end + return out +end + + +-- Returns the character at a particular index +-- a = 'engine' +-- a:index(2) -> 'n' +-- a:index(3) -> 'g' +-- a:index(-1) -> 'e' +function string:index(i) + return self:sub(i, i) +end diff --git a/engine/datastructures/table.lua b/engine/datastructures/table.lua new file mode 100644 index 0000000..4aef79e --- /dev/null +++ b/engine/datastructures/table.lua @@ -0,0 +1,480 @@ +-- Copies the table deeply, including metatables +function table.copy(t) + local t_type = type(t) + local copy + if t_type == "table" then + copy = {} + for k, v in next, t, nil do + copy[table.copy(k)] = table.copy(v) + end + setmetatable(copy, table.copy(getmetatable(t))) + else + copy = t + end + return copy +end + + +-- Copies the table shallowly, meaning that tables inside the table will not be created anew, and only be referenced in the copy +function table.shallow_copy(t) + local copy = {} + for k, v in pairs(t) do + copy[k] = v + end + return copy +end + + +-- t = {} +-- table.array(t, 5) -> {1, 2, 3, 4, 5} +function table.array(t, n) + for i = 1, n do + table.push(t, i) + end + return t +end + +-- t = {"a", "b", "c", "d"} +-- table.get(t, 1) -> "a" +-- table.get(t, 1, 3) -> {"a", "b", "c"} +-- table.get(t, 2, -1) -> {"b", "c", "d"} +function table.get(t, i, j) + if i < 0 then i = #t + i + 1 end + if not j then return t[i] end + if j < 0 then j = #t + j + 1 end + if i == j then return t[i] end + local out = {} + for k = i, j, math.sign(j-i) do + table.push(out, t[k]) + end + return out +end + + +-- t = {"a", "b", "c", "d"} +-- table.set(t, 1, 1) -> {1, "b", "c", "d"} +-- table.set(t, 1, 3, 2) -> {2, 2, 2, "d"} +-- table.set(t, 2, -1, 3) -> {"a", 3, 3, 3} +function table.set(t, i, j, v) + if i < 0 then i = #t + i + 1 end + if not v then t[i] = j; return t end + if j < 0 then j = #t + j + 1 end + if i == j then t[i] = v; return t end + for k = i, j, math.sign(j-i) do + t[k] = v + end + return t +end + + +-- Returns the index of the first instance of value v +-- t = {4, 3, 2, 4, "a", 1, "a"} +-- table.index(t, 4) -> 1 +-- table.index(t, "a") -> 5 +function table.index(t, v) + for i, u in ipairs(t) do + if u == v then + return i + end + end +end + + +-- Returns the last value of the table +-- t = {1, 2, 3, 4} +-- table.back(t) -> 4 +function table.back(t) + return t[#t] +end + + +-- Returns the first n values +-- t = {4, 3, 2, 1} +-- table.head(t) -> 4 +-- table.head(t, 2) -> {4, 3} +function table.head(t, n) + local out = {} + for i = 1, (n or 1) do + table.push(out, t[i]) + end + if #out == 1 then return out[1] + else return out end +end + + +-- Returns the last n values +-- t = {5, 4, 3, 2, 1} +-- table.tail(t) -> 1 +-- table.tail(t, 2) -> {2, 1} +function table.tail(t, n) + local out = {} + for i = #t-(n or #t-1)+1, #t do + table.push(out, t[i]) + end + if #out == 1 then return out[1] + else return out end +end + + +-- Inserts value at the end of the table +-- t = {1, 2} +-- table.push(t, "a") -> {1, 2, "a"} +function table.push(t, v) + table.insert(t, v) + return t +end + + +-- Removes the first n values and returns them as well as the modified table +-- t = {4, 3, 2, 1} +-- table.shift(t) -> 4, {3, 2, 1} +-- table.shift(t, 3) -> {4, 3, 2}, {1} +function table.shift(t, n) + local out = {} + for i = 1, (n or 1) do + table.insert(out, table.remove(t, 1)) + end + if #out == 1 then return out[1], t + else return out, t end +end + + +-- Inserts values at the start of the table +-- t = {3, 4} +-- table.unshift(t, 1, 2) -> {1, 2, 3, 4} +function table.unshift(t, ...) + for j, v in ipairs({...}) do + table.insert(t, 1+j-1, v) + end + return t +end + + +-- Removes the last value and returns it as well as the modified table +-- t = {1, 2, 3, 4} +-- table.pop(t) -> 4, {1, 2, 3} +function table.pop(t) + return table.remove(t, #t), t +end + + +-- Deletes all instances of value v +-- t = {1, 1, 2, 3, 2, 3, 4, 4} +-- table.delete(t, 1) -> {2, 3, 2, 3, 4, 4} +-- t = {{id = 1}, {id = 1}, {id = 2}} +-- table.delete(t, function(v) return v.id == 1 end) -> {{id = 2}} +function table.delete(t, v) + if type(v) == 'function' then + for i = #t, 1, -1 do + if v(t[i]) then + table.remove(t, i) + end + end + else + for i = #t, 1, -1 do + if v == t[i] then + table.remove(t, i) + end + end + end + return t +end + + +-- Deletes the elements in the given range and returns them as well as the modified table +-- t = {1, 2, 3} +-- table.slice(t, 1) -> 1, {2, 3} +-- table.slice(t, 2, -1) -> {2, 3}, 1 +function table.slice(t, i, j) + if i < 0 then i = #t + i + 1 end + if not j then return t[i] end + if j < 0 then j = #t + j + 1 end + if i == j then return t[i] end + local out = {} + for k = j, i, -math.sign(j-i) do + table.insert(out, table.remove(t, k)) + end + if #out == 1 then return out[1], t + else return table.reverse(out), t end +end + + +-- Removes duplicates +-- t = {1, 1, 2, 2, 3, 3} +-- table.unify(t) -> {1, 2, 3} +-- t = {{id = 1}, {id = 1}, {id = 2}} +-- table.unify(t, function(v) return v.id end) -> {{id = 1}, {id = 2}} +function table.unify(t, f) + if not f then f = function(v) return v end end + local seen = {} + for i = #t, 1, -1 do + if not seen[f(t[i])] then + seen[f(t[i])] = true + else + table.remove(t, i) + end + end + return t +end + + +-- Counts the number of elements in the table +-- t = {1, 1, 5, 5, 4, 1, 3, 2, 0, 9, 8, 5, 1, 5, 5, 4, 6} +-- table.count(t, 1) -> 4 +-- table.count(t, 5) -> 5 +-- table.count(t, 6) -> 1 +-- table.count(t, 4) -> 2 +function table.count(t, v) + local n = 0 + for i = 1, #t do + if t[i] == v then + n = n + 1 + end + end + return n +end + + +-- Applies function f to all table elements and replaces each element for the value returned by f +function table.map(t, f, ...) + for k, v in ipairs(t) do + t[k] = f(v, k, ...) + end + return t +end + + +-- Applies function f to all table elements resulting in a single output value +-- t = {1, 2, 3} +-- table.reduce(t, function(memo, v) return memo + v end) -> 6 +-- t = {'a', 'b', 'c'} +-- table.reduce(t, function(memo, v) return memo .. v end) -> 'abc' +-- t = {{id = 1}, {id = 2}, {id = 3}} +-- table.reduce(t, function(memo, v) return memo + v.id end, 0) -> 6 +-- The memo variable starts as the first argument in the array, but sometimes, as in the last example, that's not the desired functionality. +-- For those cases the third argument comes in handy and can be used to set the initial value of memo directly. +function table.reduce(t, f, dv, ...) + local memo = t[1] or dv + for i = 2, #t do + memo = f(memo, t[i], i, ...) + end + return memo +end + + +-- Applies function f to all array elements without changing the array +function table.foreach(t, f, ...) + for k, v in ipairs(t) do + f(v, k, ...) + end + return t +end + + +-- Applies function f to all array elements and adds the results to a new array +function table.foreachn(t, f, ...) + local out = {} + for k, v in ipairs(t) do + table.insert(out, f(v, k, ...)) + end + return out +end + + +-- Applies filter function f which removes all elements that pass the filter and returns them as well as the modified table +-- t = {1, 2, 3, 4} +-- table.reject(t, function(v) return v >= 3 end) -> {3, 4}, {1, 2} +-- table.reject(t, function(v) return v == 1 end) -> 1, {2, 3, 4} +function table.reject(t, f, ...) + local out = {} + for i = #t, 1, -1 do + if f(t[i], i, ...) then + table.insert(out, table.remove(t, i)) + end + end + if #out == 1 then return out[1], t + else return table.reverse(out), t end +end + + +-- Applies filter function f which collects all elements that pass the filter and returns them; the original table is not modified +-- t = {1, 2, 3, 4} +-- table.select(t, function(v) return v >= 3 end) -> {3, 4} +-- table.select(t, function(v) return v == 1 end) -> 1 +function table.select(t, f, ...) + local out = {} + for i = 1, #t do + if f(t[i], i, ...) then + table.insert(out, t[i]) + end + end + return out +end + + +-- Returns true if any values in the table pass the test +function table.any(t, f, ...) + for i, v in ipairs(t) do + if f(v, i, ...) then + return true + end + end +end + + +-- Returns true if all values in the table pass the test +function table.all(t, f, ...) + for i, v in ipairs(t) do + if not f(v, i, ...) then + return false + end + end + return true +end + + +-- Check if table contains value v and return its index +-- If value v is a function instead then it checks according to the check performed by that function +-- t = {4, 3, 2, 1} +-- table.contains(t, 4) -> 1 +-- t = {{id = 4}, {id = 3}, {id = 2}, {id = 1}} +-- table.contains(t, function(v) return v.id == 3 end) -> 2 +function table.contains(t, v) + if type(v) == "function" then + for i, u in ipairs(t) do + if v(u) then return i end + end + else + for i, u in ipairs(t) do + if u == v then return i end + end + end +end + + +-- t = {{1, 2}, {3, {4, 5}}, {6, 7}, 8} +-- table.flatten(t) -> {1, 2, 3, 4, 5, 6, 7, 8} +-- table.flatten(t, true) -> {1, 2, 3, {4, 5}, 6, 7, 8} +function table.flatten(t, shallow) + local out = {} + local u + for k, v in ipairs(t) do + if type(v) == "table" and getmetatable(t) == nil then + u = shallow and v or table.flatten(v) + for _, x in ipairs(u) do + table.insert(out, x) + end + else + table.insert(out, v) + end + end + return out +end + + +-- t = {1, 2, 3, 4} +-- table.tostring(t) -> '{[1] = 1, [2] = 2, [3] = 3, [4] = 4}' +function table.tostring(t) + if type(t) == "table" then + local str = "{" + for k, v in ipairs(t) do + if type(k) ~= "number" then k = '"' .. k .. '"' end + str = str .. "[" .. k .. "] = " .. table.tostring(v) .. ", " + end + return str:sub(1, -3) .. "}" + else return tostring(t) end +end + + +-- Returns the first n values, same as head +-- t = {4, 3, 2, 1} +-- table.first(t) -> 4 +-- table.first(t, 2) -> {4, 3} +function table.first(t, n) + if n == 1 then return t[1] end + local out = {} + for i = 1, (n or 1) do + table.push(out, t[i]) + end + if #out == 1 then return out[1] + else return out end +end + + +-- Returns the last n values, same as tail +-- t = {4, 3, 2, 1} +-- table.last(t) -> 1 +-- table.last(t, 2) -> {2, 1} +function table.last(t, n) + if n == 1 then return t[#t] end + local out = {} + for i = #t-n+1, #t do + table.push(out, t[i]) + end + if #out == 1 then return out[1] + else return out end +end + + +-- t = {"a", "b", "c", "d"} +-- table.reverse(t) -> {"d", "c", "b", "a"} +-- table.reverse(t, 2, 3) -> {"a", "c", "b", "d"} +-- table.reverse(t, 2, -1) -> {"a", "d", "c", "b"} +function table.reverse(t, i, j) + if not i then i = 1 end + if i < 0 then i = #t + i + 1 end + if not j then j = #t end + if j < 0 then j = #t + j + 1 end + if i == j then return t end + for k = 0, (j-i+1)/2-1, math.sign(j-i) do + t[i+k], t[j-k] = t[j-k], t[i+k] + end + return t +end + + +-- Shifts the table to the right n times, the last value is warped over to become the first value +-- t = {1, 2, 3, 4} +-- table.rotate(t) -> {4, 1, 2, 3} +-- table.rotate(t, 2) -> {3, 4, 1, 2} +function table.rotate(t, n) + if not n then n = 1 end + if n < 0 then n = #t + n end + t = table.reverse(t, 1, #t) + t = table.reverse(t, 1, #t-n) + t = table.reverse(t, #t-n+1, #t) + return t +end + + +-- Returns a random value from the table +-- t = {1, 2, 3} +-- table.random(t) -> 1 or 2 or 3 randomly +function table.random(t) + return t[love.math.random(1, #t)] +end + + +-- t = {1, 2, 3, 4, 5} +-- table.shuffle(t) -> {3, 4, 1, 2, 5} +-- table.shuttle(t) -> {2, 5, 1, 4, 3} +-- table.shuffle(t) -> {5, 4, 1, 3, 2} +function table.shuffle(t) + for i = #t, 2, -1 do + local j = love.math.random(i) + t[i], t[j] = t[j], t[i] + end + return t +end + + +-- Merges both tables based on their indexes, if the second table has values in the same indexes as the first table then those will overwrite the first values. +-- t1 = {1, 2, ['a'] = 3, ['b'] = function() end} +-- t2 = {nil, 8, 4, 5, ['a'] = 8} +-- table.merge(t1, t2) -> {1, 2, 8, 4, 5, ['a'] = 8, ['b'] = function() end} +function table.merge(t1, t2) + local out = {} + for k, v in pairs(t1) do out[k] = v end + for k, v in pairs(t2) do out[k] = v end + return out +end diff --git a/engine/external/binser.lua b/engine/external/binser.lua new file mode 100644 index 0000000..731200d --- /dev/null +++ b/engine/external/binser.lua @@ -0,0 +1,747 @@ +-- binser.lua + +--[[ +Copyright (c) 2016-2019 Calvin Rose +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. +]] + +local assert = assert +local error = error +local select = select +local pairs = pairs +local getmetatable = getmetatable +local setmetatable = setmetatable +local type = type +local loadstring = loadstring or load +local concat = table.concat +local char = string.char +local byte = string.byte +local format = string.format +local sub = string.sub +local dump = string.dump +local floor = math.floor +local frexp = math.frexp +local unpack = unpack or table.unpack + +-- Lua 5.3 frexp polyfill +-- From https://github.com/excessive/cpml/blob/master/modules/utils.lua +if not frexp then + local log, abs, floor = math.log, math.abs, math.floor + local log2 = log(2) + frexp = function(x) + if x == 0 then return 0, 0 end + local e = floor(log(abs(x)) / log2 + 1) + return x / 2 ^ e, e + end +end + +local function pack(...) + return {...}, select("#", ...) +end + +local function not_array_index(x, len) + return type(x) ~= "number" or x < 1 or x > len or x ~= floor(x) +end + +local function type_check(x, tp, name) + assert(type(x) == tp, + format("Expected parameter %q to be of type %q.", name, tp)) +end + +local bigIntSupport = false +local isInteger +if math.type then -- Detect Lua 5.3 + local mtype = math.type + bigIntSupport = loadstring[[ + local char = string.char + return function(n) + local nn = n < 0 and -(n + 1) or n + local b1 = nn // 0x100000000000000 + local b2 = nn // 0x1000000000000 % 0x100 + local b3 = nn // 0x10000000000 % 0x100 + local b4 = nn // 0x100000000 % 0x100 + local b5 = nn // 0x1000000 % 0x100 + local b6 = nn // 0x10000 % 0x100 + local b7 = nn // 0x100 % 0x100 + local b8 = nn % 0x100 + if n < 0 then + b1, b2, b3, b4 = 0xFF - b1, 0xFF - b2, 0xFF - b3, 0xFF - b4 + b5, b6, b7, b8 = 0xFF - b5, 0xFF - b6, 0xFF - b7, 0xFF - b8 + end + return char(212, b1, b2, b3, b4, b5, b6, b7, b8) + end]]() + isInteger = function(x) + return mtype(x) == 'integer' + end +else + isInteger = function(x) + return floor(x) == x + end +end + +-- Copyright (C) 2012-2015 Francois Perrad. +-- number serialization code modified from https://github.com/fperrad/lua-MessagePack +-- Encode a number as a big-endian ieee-754 double, big-endian signed 64 bit integer, or a small integer +local function number_to_str(n) + if isInteger(n) then -- int + if n <= 100 and n >= -27 then -- 1 byte, 7 bits of data + return char(n + 27) + elseif n <= 8191 and n >= -8192 then -- 2 bytes, 14 bits of data + n = n + 8192 + return char(128 + (floor(n / 0x100) % 0x100), n % 0x100) + elseif bigIntSupport then + return bigIntSupport(n) + end + end + local sign = 0 + if n < 0.0 then + sign = 0x80 + n = -n + end + local m, e = frexp(n) -- mantissa, exponent + if m ~= m then + return char(203, 0xFF, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00) + elseif m == 1/0 then + if sign == 0 then + return char(203, 0x7F, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00) + else + return char(203, 0xFF, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00) + end + end + e = e + 0x3FE + if e < 1 then -- denormalized numbers + m = m * 2 ^ (52 + e) + e = 0 + else + m = (m * 2 - 1) * 2 ^ 52 + end + return char(203, + sign + floor(e / 0x10), + (e % 0x10) * 0x10 + floor(m / 0x1000000000000), + floor(m / 0x10000000000) % 0x100, + floor(m / 0x100000000) % 0x100, + floor(m / 0x1000000) % 0x100, + floor(m / 0x10000) % 0x100, + floor(m / 0x100) % 0x100, + m % 0x100) +end + +-- Copyright (C) 2012-2015 Francois Perrad. +-- number deserialization code also modified from https://github.com/fperrad/lua-MessagePack +local function number_from_str(str, index) + local b = byte(str, index) + if not b then error("Expected more bytes of input.") end + if b < 128 then + return b - 27, index + 1 + elseif b < 192 then + local b2 = byte(str, index + 1) + if not b2 then error("Expected more bytes of input.") end + return b2 + 0x100 * (b - 128) - 8192, index + 2 + end + local b1, b2, b3, b4, b5, b6, b7, b8 = byte(str, index + 1, index + 8) + if (not b1) or (not b2) or (not b3) or (not b4) or + (not b5) or (not b6) or (not b7) or (not b8) then + error("Expected more bytes of input.") + end + if b == 212 then + local flip = b1 >= 128 + if flip then -- negative + b1, b2, b3, b4 = 0xFF - b1, 0xFF - b2, 0xFF - b3, 0xFF - b4 + b5, b6, b7, b8 = 0xFF - b5, 0xFF - b6, 0xFF - b7, 0xFF - b8 + end + local n = ((((((b1 * 0x100 + b2) * 0x100 + b3) * 0x100 + b4) * + 0x100 + b5) * 0x100 + b6) * 0x100 + b7) * 0x100 + b8 + if flip then + return (-n) - 1, index + 9 + else + return n, index + 9 + end + end + if b ~= 203 then + error("Expected number") + end + local sign = b1 > 0x7F and -1 or 1 + local e = (b1 % 0x80) * 0x10 + floor(b2 / 0x10) + local m = ((((((b2 % 0x10) * 0x100 + b3) * 0x100 + b4) * 0x100 + b5) * 0x100 + b6) * 0x100 + b7) * 0x100 + b8 + local n + if e == 0 then + if m == 0 then + n = sign * 0.0 + else + n = sign * (m / 2 ^ 52) * 2 ^ -1022 + end + elseif e == 0x7FF then + if m == 0 then + n = sign * (1/0) + else + n = 0.0/0.0 + end + else + n = sign * (1.0 + m / 2 ^ 52) * 2 ^ (e - 0x3FF) + end + return n, index + 9 +end + + +local function newbinser() + + -- unique table key for getting next value + local NEXT = {} + local CTORSTACK = {} + + -- NIL = 202 + -- FLOAT = 203 + -- TRUE = 204 + -- FALSE = 205 + -- STRING = 206 + -- TABLE = 207 + -- REFERENCE = 208 + -- CONSTRUCTOR = 209 + -- FUNCTION = 210 + -- RESOURCE = 211 + -- INT64 = 212 + -- TABLE WITH META = 213 + + local mts = {} + local ids = {} + local serializers = {} + local deserializers = {} + local resources = {} + local resources_by_name = {} + local types = {} + + types["nil"] = function(x, visited, accum) + accum[#accum + 1] = "\202" + end + + function types.number(x, visited, accum) + accum[#accum + 1] = number_to_str(x) + end + + function types.boolean(x, visited, accum) + accum[#accum + 1] = x and "\204" or "\205" + end + + function types.string(x, visited, accum) + local alen = #accum + if visited[x] then + accum[alen + 1] = "\208" + accum[alen + 2] = number_to_str(visited[x]) + else + visited[x] = visited[NEXT] + visited[NEXT] = visited[NEXT] + 1 + accum[alen + 1] = "\206" + accum[alen + 2] = number_to_str(#x) + accum[alen + 3] = x + end + end + + local function check_custom_type(x, visited, accum) + local res = resources[x] + if res then + accum[#accum + 1] = "\211" + types[type(res)](res, visited, accum) + return true + end + local mt = getmetatable(x) + local id = mt and ids[mt] + if id then + local constructing = visited[CTORSTACK] + if constructing[x] then + error("Infinite loop in constructor.") + end + constructing[x] = true + accum[#accum + 1] = "\209" + types[type(id)](id, visited, accum) + local args, len = pack(serializers[id](x)) + accum[#accum + 1] = number_to_str(len) + for i = 1, len do + local arg = args[i] + types[type(arg)](arg, visited, accum) + end + visited[x] = visited[NEXT] + visited[NEXT] = visited[NEXT] + 1 + -- We finished constructing + constructing[x] = nil + return true + end + end + + function types.userdata(x, visited, accum) + if visited[x] then + accum[#accum + 1] = "\208" + accum[#accum + 1] = number_to_str(visited[x]) + else + if check_custom_type(x, visited, accum) then return end + error("Cannot serialize this userdata.") + end + end + + function types.table(x, visited, accum) + if visited[x] then + accum[#accum + 1] = "\208" + accum[#accum + 1] = number_to_str(visited[x]) + else + if check_custom_type(x, visited, accum) then return end + visited[x] = visited[NEXT] + visited[NEXT] = visited[NEXT] + 1 + local xlen = #x + local mt = getmetatable(x) + if mt then + accum[#accum + 1] = "\213" + types.table(mt, visited, accum) + else + accum[#accum + 1] = "\207" + end + accum[#accum + 1] = number_to_str(xlen) + for i = 1, xlen do + local v = x[i] + types[type(v)](v, visited, accum) + end + local key_count = 0 + for k in pairs(x) do + if not_array_index(k, xlen) then + key_count = key_count + 1 + end + end + accum[#accum + 1] = number_to_str(key_count) + for k, v in pairs(x) do + if not_array_index(k, xlen) then + types[type(k)](k, visited, accum) + types[type(v)](v, visited, accum) + end + end + end + end + + types["function"] = function(x, visited, accum) + if visited[x] then + accum[#accum + 1] = "\208" + accum[#accum + 1] = number_to_str(visited[x]) + else + if check_custom_type(x, visited, accum) then return end + visited[x] = visited[NEXT] + visited[NEXT] = visited[NEXT] + 1 + local str = dump(x) + accum[#accum + 1] = "\210" + accum[#accum + 1] = number_to_str(#str) + accum[#accum + 1] = str + end + end + + types.cdata = function(x, visited, accum) + if visited[x] then + accum[#accum + 1] = "\208" + accum[#accum + 1] = number_to_str(visited[x]) + else + if check_custom_type(x, visited, #accum) then return end + error("Cannot serialize this cdata.") + end + end + + types.thread = function() error("Cannot serialize threads.") end + + local function deserialize_value(str, index, visited) + local t = byte(str, index) + if not t then return nil, index end + if t < 128 then + return t - 27, index + 1 + elseif t < 192 then + local b2 = byte(str, index + 1) + if not b2 then error("Expected more bytes of input.") end + return b2 + 0x100 * (t - 128) - 8192, index + 2 + elseif t == 202 then + return nil, index + 1 + elseif t == 203 or t == 212 then + return number_from_str(str, index) + elseif t == 204 then + return true, index + 1 + elseif t == 205 then + return false, index + 1 + elseif t == 206 then + local length, dataindex = number_from_str(str, index + 1) + local nextindex = dataindex + length + if not (length >= 0) then error("Bad string length") end + if #str < nextindex - 1 then error("Expected more bytes of string") end + local substr = sub(str, dataindex, nextindex - 1) + visited[#visited + 1] = substr + return substr, nextindex + elseif t == 207 or t == 213 then + local mt, count, nextindex + local ret = {} + visited[#visited + 1] = ret + nextindex = index + 1 + if t == 213 then + mt, nextindex = deserialize_value(str, nextindex, visited) + if type(mt) ~= "table" then error("Expected table metatable") end + end + count, nextindex = number_from_str(str, nextindex) + for i = 1, count do + local oldindex = nextindex + ret[i], nextindex = deserialize_value(str, nextindex, visited) + if nextindex == oldindex then error("Expected more bytes of input.") end + end + count, nextindex = number_from_str(str, nextindex) + for i = 1, count do + local k, v + local oldindex = nextindex + k, nextindex = deserialize_value(str, nextindex, visited) + if nextindex == oldindex then error("Expected more bytes of input.") end + oldindex = nextindex + v, nextindex = deserialize_value(str, nextindex, visited) + if nextindex == oldindex then error("Expected more bytes of input.") end + if k == nil then error("Can't have nil table keys") end + ret[k] = v + end + if mt then setmetatable(ret, mt) end + return ret, nextindex + elseif t == 208 then + local ref, nextindex = number_from_str(str, index + 1) + return visited[ref], nextindex + elseif t == 209 then + local count + local name, nextindex = deserialize_value(str, index + 1, visited) + count, nextindex = number_from_str(str, nextindex) + local args = {} + for i = 1, count do + local oldindex = nextindex + args[i], nextindex = deserialize_value(str, nextindex, visited) + if nextindex == oldindex then error("Expected more bytes of input.") end + end + if not name or not deserializers[name] then + error(("Cannot deserialize class '%s'"):format(tostring(name))) + end + local ret = deserializers[name](unpack(args)) + visited[#visited + 1] = ret + return ret, nextindex + elseif t == 210 then + local length, dataindex = number_from_str(str, index + 1) + local nextindex = dataindex + length + if not (length >= 0) then error("Bad string length") end + if #str < nextindex - 1 then error("Expected more bytes of string") end + local ret = loadstring(sub(str, dataindex, nextindex - 1)) + visited[#visited + 1] = ret + return ret, nextindex + elseif t == 211 then + local resname, nextindex = deserialize_value(str, index + 1, visited) + if resname == nil then error("Got nil resource name") end + local res = resources_by_name[resname] + if res == nil then + error(("No resources found for name '%s'"):format(tostring(resname))) + end + return res, nextindex + else + error("Could not deserialize type byte " .. t .. ".") + end + end + + local function serialize(...) + local visited = {[NEXT] = 1, [CTORSTACK] = {}} + local accum = {} + for i = 1, select("#", ...) do + local x = select(i, ...) + types[type(x)](x, visited, accum) + end + return concat(accum) + end + + local function make_file_writer(file) + return setmetatable({}, { + __newindex = function(_, _, v) + file:write(v) + end + }) + end + + local function serialize_to_file(path, mode, ...) + local file, err = io.open(path, mode) + assert(file, err) + local visited = {[NEXT] = 1, [CTORSTACK] = {}} + local accum = make_file_writer(file) + for i = 1, select("#", ...) do + local x = select(i, ...) + types[type(x)](x, visited, accum) + end + -- flush the writer + file:flush() + file:close() + end + + local function writeFile(path, ...) + return serialize_to_file(path, "wb", ...) + end + + local function appendFile(path, ...) + return serialize_to_file(path, "ab", ...) + end + + local function deserialize(str, index) + assert(type(str) == "string", "Expected string to deserialize.") + local vals = {} + index = index or 1 + local visited = {} + local len = 0 + local val + while true do + local nextindex + val, nextindex = deserialize_value(str, index, visited) + if nextindex > index then + len = len + 1 + vals[len] = val + index = nextindex + else + break + end + end + return vals, len + end + + local function deserializeN(str, n, index) + assert(type(str) == "string", "Expected string to deserialize.") + n = n or 1 + assert(type(n) == "number", "Expected a number for parameter n.") + assert(n > 0 and floor(n) == n, "N must be a poitive integer.") + local vals = {} + index = index or 1 + local visited = {} + local len = 0 + local val + while len < n do + local nextindex + val, nextindex = deserialize_value(str, index, visited) + if nextindex > index then + len = len + 1 + vals[len] = val + index = nextindex + else + break + end + end + vals[len + 1] = index + return unpack(vals, 1, n + 1) + end + + local function readFile(path) + local file, err = io.open(path, "rb") + assert(file, err) + local str = file:read("*all") + file:close() + return deserialize(str) + end + + -- Resources + + local function registerResource(resource, name) + type_check(name, "string", "name") + assert(not resources[resource], + "Resource already registered.") + assert(not resources_by_name[name], + format("Resource %q already exists.", name)) + resources_by_name[name] = resource + resources[resource] = name + return resource + end + + local function unregisterResource(name) + type_check(name, "string", "name") + assert(resources_by_name[name], format("Resource %q does not exist.", name)) + local resource = resources_by_name[name] + resources_by_name[name] = nil + resources[resource] = nil + return resource + end + + -- Templating + + local function normalize_template(template) + local ret = {} + for i = 1, #template do + ret[i] = template[i] + end + local non_array_part = {} + -- The non-array part of the template (nested templates) have to be deterministic, so they are sorted. + -- This means that inherently non deterministicly sortable keys (tables, functions) should NOT be used + -- in templates. Looking for way around this. + for k in pairs(template) do + if not_array_index(k, #template) then + non_array_part[#non_array_part + 1] = k + end + end + table.sort(non_array_part) + for i = 1, #non_array_part do + local name = non_array_part[i] + ret[#ret + 1] = {name, normalize_template(template[name])} + end + return ret + end + + local function templatepart_serialize(part, argaccum, x, len) + local extras = {} + local extracount = 0 + for k, v in pairs(x) do + extras[k] = v + extracount = extracount + 1 + end + for i = 1, #part do + local name + if type(part[i]) == "table" then + name = part[i][1] + len = templatepart_serialize(part[i][2], argaccum, x[name], len) + else + name = part[i] + len = len + 1 + argaccum[len] = x[part[i]] + end + if extras[name] ~= nil then + extracount = extracount - 1 + extras[name] = nil + end + end + if extracount > 0 then + argaccum[len + 1] = extras + else + argaccum[len + 1] = nil + end + return len + 1 + end + + local function templatepart_deserialize(ret, part, values, vindex) + for i = 1, #part do + local name = part[i] + if type(name) == "table" then + local newret = {} + ret[name[1]] = newret + vindex = templatepart_deserialize(newret, name[2], values, vindex) + else + ret[name] = values[vindex] + vindex = vindex + 1 + end + end + local extras = values[vindex] + if extras then + for k, v in pairs(extras) do + ret[k] = v + end + end + return vindex + 1 + end + + local function template_serializer_and_deserializer(metatable, template) + return function(x) + local argaccum = {} + local len = templatepart_serialize(template, argaccum, x, 0) + return unpack(argaccum, 1, len) + end, function(...) + local ret = {} + local args = {...} + templatepart_deserialize(ret, template, args, 1) + return setmetatable(ret, metatable) + end + end + + -- Used to serialize classes withh custom serializers and deserializers. + -- If no _serialize or _deserialize (or no _template) value is found in the + -- metatable, then the metatable is registered as a resources. + local function register(metatable, name, serialize, deserialize) + if type(metatable) == "table" then + name = name or metatable.name + serialize = serialize or metatable._serialize + deserialize = deserialize or metatable._deserialize + if (not serialize) or (not deserialize) then + if metatable._template then + -- Register as template + local t = normalize_template(metatable._template) + serialize, deserialize = template_serializer_and_deserializer(metatable, t) + else + -- Register the metatable as a resource. This is semantically + -- similar and more flexible (handles cycles). + registerResource(metatable, name) + return + end + end + elseif type(metatable) == "string" then + name = name or metatable + end + type_check(name, "string", "name") + type_check(serialize, "function", "serialize") + type_check(deserialize, "function", "deserialize") + assert((not ids[metatable]) and (not resources[metatable]), + "Metatable already registered.") + assert((not mts[name]) and (not resources_by_name[name]), + ("Name %q already registered."):format(name)) + mts[name] = metatable + ids[metatable] = name + serializers[name] = serialize + deserializers[name] = deserialize + return metatable + end + + local function unregister(item) + local name, metatable + if type(item) == "string" then -- assume name + name, metatable = item, mts[item] + else -- assume metatable + name, metatable = ids[item], item + end + type_check(name, "string", "name") + mts[name] = nil + if (metatable) then + resources[metatable] = nil + ids[metatable] = nil + end + serializers[name] = nil + deserializers[name] = nil + resources_by_name[name] = nil; + return metatable + end + + local function registerClass(class, name) + name = name or class.name + if class.__instanceDict then -- middleclass + register(class.__instanceDict, name) + else -- assume 30log or similar library + register(class, name) + end + return class + end + + return { + VERSION = "0.0-8", + -- aliases + s = serialize, + d = deserialize, + dn = deserializeN, + r = readFile, + w = writeFile, + a = appendFile, + + serialize = serialize, + deserialize = deserialize, + deserializeN = deserializeN, + readFile = readFile, + writeFile = writeFile, + appendFile = appendFile, + register = register, + unregister = unregister, + registerResource = registerResource, + unregisterResource = unregisterResource, + registerClass = registerClass, + + newbinser = newbinser + } +end + +return newbinser() diff --git a/engine/external/clipper.lua b/engine/external/clipper.lua new file mode 100644 index 0000000..2d22225 --- /dev/null +++ b/engine/external/clipper.lua @@ -0,0 +1,274 @@ +-- Copyright (c) 2017 Laurent Zubiaur +-- +-- 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. + +local ffi = require 'ffi' +-- NOTE ffi.load doesn't use package.cpath to search for libraries but rather the +-- default OS default search path (e.g. LD_LIBRARY_PATH). + +-- Load Clipper from a shared library... +local C = ffi.load 'polyclipping' +-- or use the default namespace if Clipper's been compiled within the executable +-- local C = ffi.C + +ffi.cdef[[ + +// Replace `int64_t` with `int32_t` if Clipper has been compiled with `use_int32` +typedef struct __cl_int_point { int64_t x, y; } cl_int_point; +typedef struct __cl_int_rect { int64_t left; int64_t top; int64_t right; int64_t bottom; } cl_int_rect; +// Replace `long long` with `int` if compiled with `use_int32` +typedef signed long long cInt; + +typedef struct __cl_path cl_path; +typedef struct __cl_paths cl_paths; +typedef struct __cl_offset cl_offset; +typedef struct __cl_clipper cl_clipper; + +const char* cl_err_msg(); + +// Path +cl_path* cl_path_new(); +void cl_path_free(cl_path *self); +cl_int_point* cl_path_get(cl_path *self, int i); +bool cl_path_add(cl_path *self, cInt x, cInt y); +int cl_path_size(cl_path *self); +double cl_path_area(const cl_path *self); +bool cl_path_orientation(const cl_path *self); +void cl_path_reverse(cl_path *self); +int cl_path_point_in_polygon(cl_path *self,cInt x, cInt y); +cl_paths* cl_path_simplify(cl_path *self,int fillType); +cl_path* cl_path_clean_polygon(const cl_path *in, double distance); + +// Paths +cl_paths* cl_paths_new(); +void cl_paths_free(cl_paths *self); +cl_path* cl_paths_get(cl_paths *self, int i); +bool cl_paths_add(cl_paths *self, cl_path *path); +int cl_paths_size(cl_paths *self); + +// ClipperOffset +cl_offset* cl_offset_new(double miterLimit,double roundPrecision); +void cl_offset_free(cl_offset *self); +cl_paths* cl_offset_path(cl_offset *self, cl_path *subj, double delta, int jointType, int endType); +cl_paths* cl_offset_paths(cl_offset *self, cl_paths *subj, double delta, int jointType, int endType); +void cl_offset_clear(cl_offset *self); + +// Clipper +cl_clipper* cl_clipper_new(); +void cl_clipper_free(cl_clipper *cl); +void cl_clipper_clear(cl_clipper *cl); +bool cl_clipper_add_path(cl_clipper *cl,cl_path *path, int pt, bool closed,const char *err); +bool cl_clipper_add_paths(cl_clipper *cl,cl_paths *paths, int pt, bool closed,const char *err); +void cl_clipper_reverse_solution(cl_clipper *cl, bool value); +void cl_clipper_preserve_collinear(cl_clipper *cl, bool value); +void cl_clipper_strictly_simple(cl_clipper *cl, bool value); +cl_paths* cl_clipper_execute(cl_clipper *cl,int clipType,int subjFillType,int clipFillType); +cl_int_rect cl_clipper_get_bounds(cl_clipper *cl); +]] + +local ClipType = { + intersection = 0, union = 1, difference = 2, xor = 3 +} + +local JoinType = { + square = 0, round = 1, miter = 2 +} + +local EndType = { + closedPolygon = 0, closedLine = 1, openButt = 2, openSquare = 3, openRound = 4 +} + +-- Clipper constructor options +local InitOptions = { + reverseSolution = 1, strictlySimple = 2, preserveCollinear = 4 +} + +local PolyType = { + subject = 0, clip = 1 +} + +local PolyFillType = { + evenOdd = 1, nonZero = 2, positive = 2, negative = 3 +} + +local Path = {} + +function Path.new() + return ffi.gc(C.cl_path_new(), C.cl_path_free) +end + +function Path:add(x,y) + return C.cl_path_add(self,x,y) +end + +function Path:get(i) + return C.cl_path_get(self,i-1) +end + +function Path:size() + return C.cl_path_size(self) +end + +function Path:area() + return C.cl_path_area(self) +end + +function Path:reverse() + return C.cl_path_reverse(self) +end + +function Path:orientation() + return C.cl_path_orientation(self) +end + +function Path:contains(x,y) + return C.cl_path_point_in_polygon(self,x,y) +end + +function Path:simplify(fillType) + fillType = fillType or 'evenOdd' + fillType = assert(PolyFillType[fillType],'unknown fill type') + return C.cl_path_simplify(self,fillType) +end + +function Path:cleanPolygon(distance) + distance = distance or 1.415 + return C.cl_path_clean_polygon(self,distance) +end + +local Paths = {} + +function Paths.new() + return ffi.gc(C.cl_paths_new(), C.cl_paths_free) +end + +function Paths:add(path) + return C.cl_paths_add(self,path) +end + +function Paths:get(i) + return C.cl_paths_get(self,i-1) +end + +function Paths:size() + return C.cl_paths_size(self) +end + +local ClipperOffset = {} + +function ClipperOffset.new(miterLimit,roundPrecision) + local co = C.cl_offset_new(miterLimit or 2,roundPrecision or 0.25) + return ffi.gc(co, C.cl_offset_free) +end + +function ClipperOffset:offsetPath(path,delta,jt,et) + jt,et = jt or 'square', et or 'openButt' + assert(JoinType[jt]) + assert(EndType[et]) + local out = C.cl_offset_path(self,path,delta,JoinType[jt],EndType[et]) + if out == nil then + error(ffi.string(C.cl_err_msg())) + end + return out +end + +function ClipperOffset:offsetPaths(paths,delta,jt,et) + jt,et = jt or 'square', et or 'openButt' + assert(JoinType[jt]) + assert(EndType[et]) + local out = C.cl_offset_paths(self,paths,delta,JoinType[jt],EndType[et]) + if out == nil then + error(ffi.string(C.cl_err_msg())) + end + return out +end + +function ClipperOffset:clear() + C.cl_offset_clear(self) +end + +-- Clipper + +local Clipper = {} + +function Clipper.new(...) + local cl = C.cl_clipper_new() + for _,opt in ipairs {...} do + assert(InitOptions[opt]) + if opt == 'strictlySimple' then + C.cl_clipper_strictly_simple(true) + elseif opt == 'reverseSolution' then + C.cl_clipper_reverse_solution(true) + else + C.cl_clipper_preserve_collinear(true) + end + end + return ffi.gc(cl, C.cl_clipper_free) +end + +function Clipper:clear() + C.cl_clipper_clear(self) +end + +function Clipper:addPath(path,pt,closed) + assert(path,'path is nil') + assert(PolyType[pt],'unknown polygon type') + if closed == nil then closed = true end + C.cl_clipper_add_path(self,path,PolyType[pt],closed,err); +end + +function Clipper:addPaths(paths,pt,closed) + assert(paths,'paths is nil') + assert(PolyType[pt],'unknown polygon type') + if closed == nil then closed = true end + if not C.cl_clipper_add_paths(self,paths,PolyType[pt],closed,err) then + error(ffi.string(C.cl_err_msg())) + end +end + +function Clipper:execute(clipType,subjFillType,clipFillType) + subjFillType = subjFillType or 'evenOdd' + clipFillType = clipFillType or 'evenOdd' + clipType = assert(ClipType[clipType],'unknown clip type') + subjFillType = assert(PolyFillType[subjFillType],'unknown fill type') + clipFillType = assert(PolyFillType[clipFillType],'unknown fill type') + local out = C.cl_clipper_execute(self,clipType,subjFillType,clipFillType) + -- XXX test `not nil` return false ?! + if out == nil then + error(ffi.string(C.cl_err_msg())) + end + return out +end + +function Clipper:getBounds() + local r = C.cl_clipper_get_bounds(self) + return tonumber(r.left),tonumber(r.top),tonumber(r.right),tonumber(r.bottom) +end + +ffi.metatype('cl_path', {__index = Path}) +ffi.metatype('cl_paths', {__index = Paths}) +ffi.metatype('cl_offset', {__index = ClipperOffset}) +ffi.metatype('cl_clipper', {__index = Clipper}) + +return { + Path = Path.new, + Paths = Paths.new, + ClipperOffset = ClipperOffset.new, + Clipper = Clipper.new, +} diff --git a/engine/external/init.lua b/engine/external/init.lua new file mode 100644 index 0000000..69ffafe --- /dev/null +++ b/engine/external/init.lua @@ -0,0 +1,7 @@ +local path = ... +if not path:find("init") then + binser = require(path .. ".binser") + mlib = require(path .. ".mlib") + if not web then clipper = require(path .. ".clipper") end + ripple = require(path .. ".ripple") +end diff --git a/engine/external/mlib.lua b/engine/external/mlib.lua new file mode 100644 index 0000000..da8b4e6 --- /dev/null +++ b/engine/external/mlib.lua @@ -0,0 +1,1411 @@ +--[[ License + A math library made in Lua + + Copyright (c) 2015 Davis Claiborne + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgement in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +]] + +-- Local Utility Functions ---------------------- {{{ +local unpack = table.unpack or unpack + +-- Used to handle variable-argument functions and whether they are passed as func{ table } or func( unpack( table ) ) +local function checkInput( ... ) + local input = {} + if type( ... ) ~= 'table' then input = { ... } else input = ... end + return input +end + +-- Deals with floats / verify false false values. This can happen because of significant figures. +local function checkFuzzy( number1, number2 ) + return ( number1 - .00001 <= number2 and number2 <= number1 + .00001 ) +end + +-- Remove multiple occurrences from a table. +local function removeDuplicatePairs( tab ) + for index1 = #tab, 1, -1 do + local first = tab[index1] + for index2 = #tab, 1, -1 do + local second = tab[index2] + if index1 ~= index2 then + if type( first[1] ) == 'number' and type( second[1] ) == 'number' and type( first[2] ) == 'number' and type( second[2] ) == 'number' then + if checkFuzzy( first[1], second[1] ) and checkFuzzy( first[2], second[2] ) then + table.remove( tab, index1 ) + end + elseif first[1] == second[1] and first[2] == second[2] then + table.remove( tab, index1 ) + end + end + end + end + return tab +end + + +local function removeDuplicates4Points( tab ) + for index1 = #tab, 1, -1 do + local first = tab[index1] + for index2 = #tab, 1, -1 do + local second = tab[index2] + if index1 ~= index2 then + if type( first[1] ) ~= type( second[1] ) then return false end + if type( first[2] ) == 'number' and type( second[2] ) == 'number' and type( first[3] ) == 'number' and type( second[3] ) == 'number' then + if checkFuzzy( first[2], second[2] ) and checkFuzzy( first[3], second[3] ) then + table.remove( tab, index1 ) + end + elseif checkFuzzy( first[1], second[1] ) and checkFuzzy( first[2], second[2] ) and checkFuzzy( first[3], second[3] ) then + table.remove( tab, index1 ) + end + end + end + end + return tab +end + + +-- Add points to the table. +local function addPoints( tab, x, y ) + tab[#tab + 1] = x + tab[#tab + 1] = y +end + +-- Like removeDuplicatePairs but specifically for numbers in a flat table +local function removeDuplicatePointsFlat( tab ) + for i = #tab, 1 -2 do + for ii = #tab - 2, 3, -2 do + if i ~= ii then + local x1, y1 = tab[i], tab[i + 1] + local x2, y2 = tab[ii], tab[ii + 1] + if checkFuzzy( x1, x2 ) and checkFuzzy( y1, y2 ) then + table.remove( tab, ii ); table.remove( tab, ii + 1 ) + end + end + end + end + return tab +end + + +-- Check if input is actually a number +local function validateNumber( n ) + if type( n ) ~= 'number' then return false + elseif n ~= n then return false -- nan + elseif math.abs( n ) == math.huge then return false + else return true end +end + +local function cycle( tab, index ) return tab[( index - 1 ) % #tab + 1] end + +local function getGreatestPoint( points, offset ) + offset = offset or 1 + local start = 2 - offset + local greatest = points[start] + local least = points[start] + for i = 2, #points / 2 do + i = i * 2 - offset + if points[i] > greatest then + greatest = points[i] + end + if points[i] < least then + least = points[i] + end + end + return greatest, least +end + +local function isWithinBounds( min, num, max ) + return num >= min and num <= max +end + +local function distance2( x1, y1, x2, y2 ) -- Faster since it does not use math.sqrt + local dx, dy = x1 - x2, y1 - y2 + return dx * dx + dy * dy +end -- }}} + +-- Points -------------------------------------- {{{ +local function rotatePoint( x, y, rotation, ox, oy ) + ox, oy = ox or 0, oy or 0 + return ( x - ox ) * math.cos( rotation ) + ox - ( y - oy ) * math.sin( rotation ), ( x - ox ) * math.sin( rotation ) + ( y - oy ) * math.cos( rotation ) + oy +end + +local function scalePoint( x, y, scale, ox, oy ) + ox, oy = ox or 0, oy or 0 + return ( x - ox ) * scale + ox, ( y - oy ) * scale + oy +end + +local function polarToCartesian( radius, theta, offsetRadius, offsetTheta ) + local ox, oy = 0, 0 + if offsetRadius and offsetTheta then + ox, oy = polarToCartesian( offsetRadius, offsetTheta ) + end + local x = radius * math.cos( theta ) + local y = radius * math.sin( theta ) + return x + ox, y + oy +end + +local function cartesianToPolar( x, y, ox, oy ) + x, y = x - ( ox or 0 ), y - ( oy or 0 ) + local theta = math.atan2( y, x ) + -- Convert to absolute angle + theta = theta > 0 and theta or theta + 2 * math.pi + local radius = math.sqrt( x ^ 2 + y ^ 2 ) + return radius, theta +end +-- }}} + +-- Lines --------------------------------------- {{{ +-- Returns the length of a line. +local function getLength( x1, y1, x2, y2 ) + local dx, dy = x1 - x2, y1 - y2 + return math.sqrt( dx * dx + dy * dy ) +end + +-- Gives the midpoint of a line. +local function getMidpoint( x1, y1, x2, y2 ) + return ( x1 + x2 ) / 2, ( y1 + y2 ) / 2 +end + +-- Gives the slope of a line. +local function getSlope( x1, y1, x2, y2 ) + if checkFuzzy( x1, x2 ) then return false end -- Technically it's undefined, but this is easier to program. + return ( y1 - y2 ) / ( x1 - x2 ) +end + +-- Gives the perpendicular slope of a line. +-- x1, y1, x2, y2 +-- slope +local function getPerpendicularSlope( ... ) + local input = checkInput( ... ) + local slope + + if #input ~= 1 then + slope = getSlope( unpack( input ) ) + else + slope = unpack( input ) + end + + if not slope then return 0 -- Vertical lines become horizontal. + elseif checkFuzzy( slope, 0 ) then return false -- Horizontal lines become vertical. + else return -1 / slope end +end + +-- Gives the y-intercept of a line. +-- x1, y1, x2, y2 +-- x1, y1, slope +local function getYIntercept( x, y, ... ) + local input = checkInput( ... ) + local slope + + if #input == 1 then + slope = input[1] + else + slope = getSlope( x, y, unpack( input ) ) + end + + if not slope then return x, true end -- This way we have some information on the line. + return y - slope * x, false +end + +-- Gives the intersection of two lines. +-- slope1, slope2, x1, y1, x2, y2 +-- slope1, intercept1, slope2, intercept2 +-- x1, y1, x2, y2, x3, y3, x4, y4 +local function getLineLineIntersection( ... ) + local input = checkInput( ... ) + local x1, y1, x2, y2, x3, y3, x4, y4 + local slope1, intercept1 + local slope2, intercept2 + local x, y + + if #input == 4 then -- Given slope1, intercept1, slope2, intercept2. + slope1, intercept1, slope2, intercept2 = unpack( input ) + + -- Since these are lines, not segments, we can use arbitrary points, such as ( 1, y ), ( 2, y ) + y1 = slope1 and slope1 * 1 + intercept1 or 1 + y2 = slope1 and slope1 * 2 + intercept1 or 2 + y3 = slope2 and slope2 * 1 + intercept2 or 1 + y4 = slope2 and slope2 * 2 + intercept2 or 2 + x1 = slope1 and ( y1 - intercept1 ) / slope1 or intercept1 + x2 = slope1 and ( y2 - intercept1 ) / slope1 or intercept1 + x3 = slope2 and ( y3 - intercept2 ) / slope2 or intercept2 + x4 = slope2 and ( y4 - intercept2 ) / slope2 or intercept2 + elseif #input == 6 then -- Given slope1, intercept1, and 2 points on the other line. + slope1, intercept1 = input[1], input[2] + slope2 = getSlope( input[3], input[4], input[5], input[6] ) + intercept2 = getYIntercept( input[3], input[4], input[5], input[6] ) + + y1 = slope1 and slope1 * 1 + intercept1 or 1 + y2 = slope1 and slope1 * 2 + intercept1 or 2 + y3 = input[4] + y4 = input[6] + x1 = slope1 and ( y1 - intercept1 ) / slope1 or intercept1 + x2 = slope1 and ( y2 - intercept1 ) / slope1 or intercept1 + x3 = input[3] + x4 = input[5] + elseif #input == 8 then -- Given 2 points on line 1 and 2 points on line 2. + slope1 = getSlope( input[1], input[2], input[3], input[4] ) + intercept1 = getYIntercept( input[1], input[2], input[3], input[4] ) + slope2 = getSlope( input[5], input[6], input[7], input[8] ) + intercept2 = getYIntercept( input[5], input[6], input[7], input[8] ) + + x1, y1, x2, y2, x3, y3, x4, y4 = unpack( input ) + end + + if not slope1 and not slope2 then -- Both are vertical lines + if x1 == x3 then -- Have to have the same x positions to intersect + return true + else + return false + end + elseif not slope1 then -- First is vertical + x = x1 -- They have to meet at this x, since it is this line's only x + y = slope2 and slope2 * x + intercept2 or 1 + elseif not slope2 then -- Second is vertical + x = x3 -- Vice-Versa + y = slope1 * x + intercept1 + elseif checkFuzzy( slope1, slope2 ) then -- Parallel (not vertical) + if checkFuzzy( intercept1, intercept2 ) then -- Same intercept + return true + else + return false + end + else -- Regular lines + x = ( -intercept1 + intercept2 ) / ( slope1 - slope2 ) + y = slope1 * x + intercept1 + end + + return x, y +end + +-- Gives the closest point on a line to a point. +-- perpendicularX, perpendicularY, x1, y1, x2, y2 +-- perpendicularX, perpendicularY, slope, intercept +local function getClosestPoint( perpendicularX, perpendicularY, ... ) + local input = checkInput( ... ) + local x, y, x1, y1, x2, y2, slope, intercept + + if #input == 4 then -- Given perpendicularX, perpendicularY, x1, y1, x2, y2 + x1, y1, x2, y2 = unpack( input ) + slope = getSlope( x1, y1, x2, y2 ) + intercept = getYIntercept( x1, y1, x2, y2 ) + elseif #input == 2 then -- Given perpendicularX, perpendicularY, slope, intercept + slope, intercept = unpack( input ) + x1, y1 = 1, slope and slope * 1 + intercept or 1 -- Need x1 and y1 in case of vertical/horizontal lines. + end + + if not slope then -- Vertical line + x, y = x1, perpendicularY -- Closest point is always perpendicular. + elseif checkFuzzy( slope, 0 ) then -- Horizontal line + x, y = perpendicularX, y1 + else + local perpendicularSlope = getPerpendicularSlope( slope ) + local perpendicularIntercept = getYIntercept( perpendicularX, perpendicularY, perpendicularSlope ) + x, y = getLineLineIntersection( slope, intercept, perpendicularSlope, perpendicularIntercept ) + end + + return x, y +end + +-- Gives the intersection of a line and a line segment. +-- x1, y1, x2, y2, x3, y3, x4, y4 +-- x1, y1, x2, y2, slope, intercept +local function getLineSegmentIntersection( x1, y1, x2, y2, ... ) + local input = checkInput( ... ) + + local slope1, intercept1, x, y, lineX1, lineY1, lineX2, lineY2 + local slope2, intercept2 = getSlope( x1, y1, x2, y2 ), getYIntercept( x1, y1, x2, y2 ) + + if #input == 2 then -- Given slope, intercept + slope1, intercept1 = input[1], input[2] + lineX1, lineY1 = 1, slope1 and slope1 + intercept1 + lineX2, lineY2 = 2, slope1 and slope1 * 2 + intercept1 + else -- Given x3, y3, x4, y4 + lineX1, lineY1, lineX2, lineY2 = unpack( input ) + slope1 = getSlope( unpack( input ) ) + intercept1 = getYIntercept( unpack( input ) ) + end + + if not slope1 and not slope2 then -- Vertical lines + if checkFuzzy( x1, lineX1 ) then + return x1, y1, x2, y2 + else + return false + end + elseif not slope1 then -- slope1 is vertical + x, y = input[1], slope2 * input[1] + intercept2 + elseif not slope2 then -- slope2 is vertical + x, y = x1, slope1 * x1 + intercept1 + else + x, y = getLineLineIntersection( slope1, intercept1, slope2, intercept2 ) + end + + local length1, length2, distance + if x == true then -- Lines are collinear. + return x1, y1, x2, y2 + elseif x then -- There is an intersection + length1, length2 = getLength( x1, y1, x, y ), getLength( x2, y2, x, y ) + distance = getLength( x1, y1, x2, y2 ) + else -- Lines are parallel but not collinear. + if checkFuzzy( intercept1, intercept2 ) then + return x1, y1, x2, y2 + else + return false + end + end + + if length1 <= distance and length2 <= distance then return x, y else return false end +end + +-- Checks if a point is on a line. +-- Does not support the format using slope because vertical lines would be impossible to check. +local function checkLinePoint( x, y, x1, y1, x2, y2 ) + local m = getSlope( x1, y1, x2, y2 ) + local b = getYIntercept( x1, y1, m ) + + if not m then -- Vertical + return checkFuzzy( x, x1 ) + end + return checkFuzzy( y, m * x + b ) +end -- }}} + +-- Segment -------------------------------------- {{{ +-- Gives the perpendicular bisector of a line. +local function getPerpendicularBisector( x1, y1, x2, y2 ) + local slope = getSlope( x1, y1, x2, y2 ) + local midpointX, midpointY = getMidpoint( x1, y1, x2, y2 ) + return midpointX, midpointY, getPerpendicularSlope( slope ) +end + +-- Gives whether or not a point lies on a line segment. +local function checkSegmentPoint( px, py, x1, y1, x2, y2 ) + -- Explanation around 5:20: https://www.youtube.com/watch?v=A86COO8KC58 + local x = checkLinePoint( px, py, x1, y1, x2, y2 ) + if not x then return false end + + local lengthX = x2 - x1 + local lengthY = y2 - y1 + + if checkFuzzy( lengthX, 0 ) then -- Vertical line + if checkFuzzy( px, x1 ) then + local low, high + if y1 > y2 then low = y2; high = y1 + else low = y1; high = y2 end + + if py >= low and py <= high then return true + else return false end + else + return false + end + elseif checkFuzzy( lengthY, 0 ) then -- Horizontal line + if checkFuzzy( py, y1 ) then + local low, high + if x1 > x2 then low = x2; high = x1 + else low = x1; high = x2 end + + if px >= low and px <= high then return true + else return false end + else + return false + end + end + + local distanceToPointX = ( px - x1 ) + local distanceToPointY = ( py - y1 ) + local scaleX = distanceToPointX / lengthX + local scaleY = distanceToPointY / lengthY + + if ( scaleX >= 0 and scaleX <= 1 ) and ( scaleY >= 0 and scaleY <= 1 ) then -- Intersection + return true + end + return false +end + +-- Gives the point of intersection between two line segments. +local function getSegmentSegmentIntersection( x1, y1, x2, y2, x3, y3, x4, y4 ) + local slope1, intercept1 = getSlope( x1, y1, x2, y2 ), getYIntercept( x1, y1, x2, y2 ) + local slope2, intercept2 = getSlope( x3, y3, x4, y4 ), getYIntercept( x3, y3, x4, y4 ) + + if ( ( slope1 and slope2 ) and checkFuzzy( slope1, slope2 ) ) or ( not slope1 and not slope2 ) then -- Parallel lines + if checkFuzzy( intercept1, intercept2 ) then -- The same lines, possibly in different points. + local points = {} + if checkSegmentPoint( x1, y1, x3, y3, x4, y4 ) then addPoints( points, x1, y1 ) end + if checkSegmentPoint( x2, y2, x3, y3, x4, y4 ) then addPoints( points, x2, y2 ) end + if checkSegmentPoint( x3, y3, x1, y1, x2, y2 ) then addPoints( points, x3, y3 ) end + if checkSegmentPoint( x4, y4, x1, y1, x2, y2 ) then addPoints( points, x4, y4 ) end + + points = removeDuplicatePointsFlat( points ) + if #points == 0 then return false end + return unpack( points ) + else + return false + end + end + + local x, y = getLineLineIntersection( x1, y1, x2, y2, x3, y3, x4, y4 ) + if x and checkSegmentPoint( x, y, x1, y1, x2, y2 ) and checkSegmentPoint( x, y, x3, y3, x4, y4 ) then + return x, y + end + return false +end -- }}} + +-- Math ----------------------------------------- {{{ +-- Get the root of a number (i.e. the 2nd (square) root of 4 is 2) +local function getRoot( number, root ) + return number ^ ( 1 / root ) +end + +-- Checks if a number is prime. +local function isPrime( number ) + if number < 2 then return false end + + for i = 2, math.sqrt( number ) do + if number % i == 0 then + return false + end + end + return true +end + +-- Rounds a number to the xth decimal place (round( 3.14159265359, 4 ) --> 3.1416) +local function round( number, place ) + local pow = 10 ^ ( place or 0 ) + return math.floor( number * pow + .5 ) / pow +end + +-- Gives the summation given a local function +local function getSummation( start, stop, func ) + local returnValues = {} + local sum = 0 + for i = start, stop do + local value = func( i, returnValues ) + returnValues[i] = value + sum = sum + value + end + return sum +end + +-- Gives the percent of change. +local function getPercentOfChange( old, new ) + if old == 0 and new == 0 then + return 0 + else + return ( new - old ) / math.abs( old ) + end +end + +-- Gives the percentage of a number. +local function getPercentage( percent, number ) + return percent * number +end + +-- Returns the quadratic roots of an equation. +local function getQuadraticRoots( a, b, c ) + local discriminant = b ^ 2 - ( 4 * a * c ) + if discriminant < 0 then return false end + discriminant = math.sqrt( discriminant ) + local denominator = ( 2 * a ) + return ( -b - discriminant ) / denominator, ( -b + discriminant ) / denominator +end + +-- Gives the angle between three points. +local function getAngle( x1, y1, x2, y2, x3, y3 ) + local a = getLength( x3, y3, x2, y2 ) + local b = getLength( x1, y1, x2, y2 ) + local c = getLength( x1, y1, x3, y3 ) + + return math.acos( ( a * a + b * b - c * c ) / ( 2 * a * b ) ) +end -- }}} + +-- Circle --------------------------------------- {{{ +-- Gives the area of the circle. +local function getCircleArea( radius ) + return math.pi * ( radius * radius ) +end + +-- Checks if a point is within the radius of a circle. +local function checkCirclePoint( x, y, circleX, circleY, radius ) + return getLength( circleX, circleY, x, y ) <= radius +end + +-- Checks if a point is on a circle. +local function isPointOnCircle( x, y, circleX, circleY, radius ) + return checkFuzzy( getLength( circleX, circleY, x, y ), radius ) +end + +-- Gives the circumference of a circle. +local function getCircumference( radius ) + return 2 * math.pi * radius +end + +-- Gives the intersection of a line and a circle. +local function getCircleLineIntersection( circleX, circleY, radius, x1, y1, x2, y2 ) + slope = getSlope( x1, y1, x2, y2 ) + intercept = getYIntercept( x1, y1, slope ) + + if slope then + local a = ( 1 + slope ^ 2 ) + local b = ( -2 * ( circleX ) + ( 2 * slope * intercept ) - ( 2 * circleY * slope ) ) + local c = ( circleX ^ 2 + intercept ^ 2 - 2 * ( circleY ) * ( intercept ) + circleY ^ 2 - radius ^ 2 ) + + x1, x2 = getQuadraticRoots( a, b, c ) + + if not x1 then return false end + + y1 = slope * x1 + intercept + y2 = slope * x2 + intercept + + if checkFuzzy( x1, x2 ) and checkFuzzy( y1, y2 ) then + return 'tangent', x1, y1 + else + return 'secant', x1, y1, x2, y2 + end + else -- Vertical Lines + local lengthToPoint1 = circleX - x1 + local remainingDistance = lengthToPoint1 - radius + local intercept = math.sqrt( -( lengthToPoint1 ^ 2 - radius ^ 2 ) ) + + if -( lengthToPoint1 ^ 2 - radius ^ 2 ) < 0 then return false end + + local bottomX, bottomY = x1, circleY - intercept + local topX, topY = x1, circleY + intercept + + if topY ~= bottomY then + return 'secant', topX, topY, bottomX, bottomY + else + return 'tangent', topX, topY + end + end +end + +-- Gives the type of intersection of a line segment. +local function getCircleSegmentIntersection( circleX, circleY, radius, x1, y1, x2, y2 ) + local Type, x3, y3, x4, y4 = getCircleLineIntersection( circleX, circleY, radius, x1, y1, x2, y2 ) + if not Type then return false end + + local slope, intercept = getSlope( x1, y1, x2, y2 ), getYIntercept( x1, y1, x2, y2 ) + + if isPointOnCircle( x1, y1, circleX, circleY, radius ) and isPointOnCircle( x2, y2, circleX, circleY, radius ) then -- Both points are on line-segment. + return 'chord', x1, y1, x2, y2 + end + + if slope then + if checkCirclePoint( x1, y1, circleX, circleY, radius ) and checkCirclePoint( x2, y2, circleX, circleY, radius ) then -- Line-segment is fully in circle. + return 'enclosed', x1, y1, x2, y2 + elseif x3 and x4 then + if checkSegmentPoint( x3, y3, x1, y1, x2, y2 ) and not checkSegmentPoint( x4, y4, x1, y1, x2, y2 ) then -- Only the first of the points is on the line-segment. + return 'tangent', x3, y3 + elseif checkSegmentPoint( x4, y4, x1, y1, x2, y2 ) and not checkSegmentPoint( x3, y3, x1, y1, x2, y2 ) then -- Only the second of the points is on the line-segment. + return 'tangent', x4, y4 + else -- Neither of the points are on the circle (means that the segment is not on the circle, but "encasing" the circle) + if checkSegmentPoint( x3, y3, x1, y1, x2, y2 ) and checkSegmentPoint( x4, y4, x1, y1, x2, y2 ) then + return 'secant', x3, y3, x4, y4 + else + return false + end + end + elseif not x4 then -- Is a tangent. + if checkSegmentPoint( x3, y3, x1, y1, x2, y2 ) then + return 'tangent', x3, y3 + else -- Neither of the points are on the line-segment (means that the segment is not on the circle or "encasing" the circle). + local length = getLength( x1, y1, x2, y2 ) + local distance1 = getLength( x1, y1, x3, y3 ) + local distance2 = getLength( x2, y2, x3, y3 ) + + if length > distance1 or length > distance2 then + return false + elseif length < distance1 and length < distance2 then + return false + else + return 'tangent', x3, y3 + end + end + end + else + local lengthToPoint1 = circleX - x1 + local remainingDistance = lengthToPoint1 - radius + local intercept = math.sqrt( -( lengthToPoint1 ^ 2 - radius ^ 2 ) ) + + if -( lengthToPoint1 ^ 2 - radius ^ 2 ) < 0 then return false end + + local topX, topY = x1, circleY - intercept + local bottomX, bottomY = x1, circleY + intercept + + local length = getLength( x1, y1, x2, y2 ) + local distance1 = getLength( x1, y1, topX, topY ) + local distance2 = getLength( x2, y2, topX, topY ) + + if bottomY ~= topY then -- Not a tangent + if checkSegmentPoint( topX, topY, x1, y1, x2, y2 ) and checkSegmentPoint( bottomX, bottomY, x1, y1, x2, y2 ) then + return 'chord', topX, topY, bottomX, bottomY + elseif checkSegmentPoint( topX, topY, x1, y1, x2, y2 ) then + return 'tangent', topX, topY + elseif checkSegmentPoint( bottomX, bottomY, x1, y1, x2, y2 ) then + return 'tangent', bottomX, bottomY + else + return false + end + else -- Tangent + if checkSegmentPoint( topX, topY, x1, y1, x2, y2 ) then + return 'tangent', topX, topY + else + return false + end + end + end +end + +-- Checks if one circle intersects another circle. +local function getCircleCircleIntersection( circle1x, circle1y, radius1, circle2x, circle2y, radius2 ) + local length = getLength( circle1x, circle1y, circle2x, circle2y ) + if length > radius1 + radius2 then return false end -- If the distance is greater than the two radii, they can't intersect. + if checkFuzzy( length, 0 ) and checkFuzzy( radius1, radius2 ) then return 'equal' end + if checkFuzzy( circle1x, circle2x ) and checkFuzzy( circle1y, circle2y ) then return 'collinear' end + + local a = ( radius1 * radius1 - radius2 * radius2 + length * length ) / ( 2 * length ) + local h = math.sqrt( radius1 * radius1 - a * a ) + + local p2x = circle1x + a * ( circle2x - circle1x ) / length + local p2y = circle1y + a * ( circle2y - circle1y ) / length + local p3x = p2x + h * ( circle2y - circle1y ) / length + local p3y = p2y - h * ( circle2x - circle1x ) / length + local p4x = p2x - h * ( circle2y - circle1y ) / length + local p4y = p2y + h * ( circle2x - circle1x ) / length + + if not validateNumber( p3x ) or not validateNumber( p3y ) or not validateNumber( p4x ) or not validateNumber( p4y ) then + return 'inside' + end + + if checkFuzzy( length, radius1 + radius2 ) or checkFuzzy( length, math.abs( radius1 - radius2 ) ) then return 'tangent', p3x, p3y end + return 'intersection', p3x, p3y, p4x, p4y +end + +-- Checks if circle1 is entirely inside of circle2. +local function isCircleCompletelyInsideCircle( circle1x, circle1y, circle1radius, circle2x, circle2y, circle2radius ) + if not checkCirclePoint( circle1x, circle1y, circle2x, circle2y, circle2radius ) then return false end + local Type = getCircleCircleIntersection( circle2x, circle2y, circle2radius, circle1x, circle1y, circle1radius ) + if ( Type ~= 'tangent' and Type ~= 'collinear' and Type ~= 'inside' ) then return false end + return true +end + +-- Checks if a line-segment is entirely within a circle. +local function isSegmentCompletelyInsideCircle( circleX, circleY, circleRadius, x1, y1, x2, y2 ) + local Type = getCircleSegmentIntersection( circleX, circleY, circleRadius, x1, y1, x2, y2 ) + return Type == 'enclosed' +end -- }}} + +-- Polygon -------------------------------------- {{{ +-- Gives the signed area. +-- If the points are clockwise the number is negative, otherwise, it's positive. +local function getSignedPolygonArea( ... ) + local points = checkInput( ... ) + + -- Shoelace formula (https://en.wikipedia.org/wiki/Shoelace_formula). + points[#points + 1] = points[1] + points[#points + 1] = points[2] + + return ( .5 * getSummation( 1, #points / 2, + function( index ) + index = index * 2 - 1 -- Convert it to work properly. + return ( ( points[index] * cycle( points, index + 3 ) ) - ( cycle( points, index + 2 ) * points[index + 1] ) ) + end + ) ) +end + +-- Simply returns the area of the polygon. +local function getPolygonArea( ... ) + return math.abs( getSignedPolygonArea( ... ) ) +end + +-- Gives the height of a triangle, given the base. +-- base, x1, y1, x2, y2, x3, y3, x4, y4 +-- base, area +local function getTriangleHeight( base, ... ) + local input = checkInput( ... ) + local area + + if #input == 1 then area = input[1] -- Given area. + else area = getPolygonArea( input ) end -- Given coordinates. + + return ( 2 * area ) / base, area +end + +-- Gives the centroid of the polygon. +local function getCentroid( ... ) + local points = checkInput( ... ) + + points[#points + 1] = points[1] + points[#points + 1] = points[2] + + local area = getSignedPolygonArea( points ) -- Needs to be signed here in case points are counter-clockwise. + + -- This formula: https://en.wikipedia.org/wiki/Centroid#Centroid_of_polygon + local centroidX = ( 1 / ( 6 * area ) ) * ( getSummation( 1, #points / 2, + function( index ) + index = index * 2 - 1 -- Convert it to work properly. + return ( ( points[index] + cycle( points, index + 2 ) ) * ( ( points[index] * cycle( points, index + 3 ) ) - ( cycle( points, index + 2 ) * points[index + 1] ) ) ) + end + ) ) + + local centroidY = ( 1 / ( 6 * area ) ) * ( getSummation( 1, #points / 2, + function( index ) + index = index * 2 - 1 -- Convert it to work properly. + return ( ( points[index + 1] + cycle( points, index + 3 ) ) * ( ( points[index] * cycle( points, index + 3 ) ) - ( cycle( points, index + 2 ) * points[index + 1] ) ) ) + end + ) ) + + return centroidX, centroidY +end + +-- Returns whether or not a line intersects a polygon. +-- x1, y1, x2, y2, polygonPoints +local function getPolygonLineIntersection( x1, y1, x2, y2, ... ) + local input = checkInput( ... ) + local choices = {} + + local slope = getSlope( x1, y1, x2, y2 ) + local intercept = getYIntercept( x1, y1, slope ) + + local x3, y3, x4, y4 + if slope then + x3, x4 = 1, 2 + y3, y4 = slope * x3 + intercept, slope * x4 + intercept + else + x3, x4 = x1, x1 + y3, y4 = y1, y2 + end + + for i = 1, #input, 2 do + local x1, y1, x2, y2 = getLineSegmentIntersection( input[i], input[i + 1], cycle( input, i + 2 ), cycle( input, i + 3 ), x3, y3, x4, y4 ) + if x1 and not x2 then choices[#choices + 1] = { x1, y1 } + elseif x1 and x2 then choices[#choices + 1] = { x1, y1, x2, y2 } end + -- No need to check 2-point sets since they only intersect each poly line once. + end + + local final = removeDuplicatePairs( choices ) + return #final > 0 and final or false +end + +-- Returns if the line segment intersects the polygon. +-- x1, y1, x2, y2, polygonPoints +local function getPolygonSegmentIntersection( x1, y1, x2, y2, ... ) + local input = checkInput( ... ) + local choices = {} + + for i = 1, #input, 2 do + local x1, y1, x2, y2 = getSegmentSegmentIntersection( input[i], input[i + 1], cycle( input, i + 2 ), cycle( input, i + 3 ), x1, y1, x2, y2 ) + if x1 and not x2 then choices[#choices + 1] = { x1, y1 } + elseif x2 then choices[#choices + 1] = { x1, y1, x2, y2 } end + end + + local final = removeDuplicatePairs( choices ) + return #final > 0 and final or false +end + +-- Checks if the point lies INSIDE the polygon not on the polygon. +local function checkPolygonPoint( px, py, ... ) + local points = { unpack( checkInput( ... ) ) } -- Make a new table, as to not edit values of previous. + + local greatest, least = getGreatestPoint( points, 0 ) + if not isWithinBounds( least, py, greatest ) then return false end + greatest, least = getGreatestPoint( points ) + if not isWithinBounds( least, px, greatest ) then return false end + + local count = 0 + for i = 1, #points, 2 do + if checkFuzzy( points[i + 1], py ) then + points[i + 1] = py + .001 -- Handles vertices that lie on the point. + -- Not exactly mathematically correct, but a lot easier. + end + if points[i + 3] and checkFuzzy( points[i + 3], py ) then + points[i + 3] = py + .001 -- Do not need to worry about alternate case, since points[2] has already been done. + end + local x1, y1 = points[i], points[i + 1] + local x2, y2 = points[i + 2] or points[1], points[i + 3] or points[2] + + if getSegmentSegmentIntersection( px, py, greatest, py, x1, y1, x2, y2 ) then + count = count + 1 + end + end + + return count and count % 2 ~= 0 +end + +-- Returns if the line segment is fully or partially inside. +-- x1, y1, x2, y2, polygonPoints +local function isSegmentInsidePolygon( x1, y1, x2, y2, ... ) + local input = checkInput( ... ) + + local choices = getPolygonSegmentIntersection( x1, y1, x2, y2, input ) -- If it's partially enclosed that's all we need. + if choices then return true end + + if checkPolygonPoint( x1, y1, input ) or checkPolygonPoint( x2, y2, input ) then return true end + return false +end + +-- Returns whether two polygons intersect. +local function getPolygonPolygonIntersection( polygon1, polygon2 ) + local choices = {} + + for index1 = 1, #polygon1, 2 do + local intersections = getPolygonSegmentIntersection( polygon1[index1], polygon1[index1 + 1], cycle( polygon1, index1 + 2 ), cycle( polygon1, index1 + 3 ), polygon2 ) + if intersections then + for index2 = 1, #intersections do + choices[#choices + 1] = intersections[index2] + end + end + end + + for index1 = 1, #polygon2, 2 do + local intersections = getPolygonSegmentIntersection( polygon2[index1], polygon2[index1 + 1], cycle( polygon2, index1 + 2 ), cycle( polygon2, index1 + 3 ), polygon1 ) + if intersections then + for index2 = 1, #intersections do + choices[#choices + 1] = intersections[index2] + end + end + end + + choices = removeDuplicatePairs( choices ) + for i = #choices, 1, -1 do + if type( choices[i][1] ) == 'table' then -- Remove co-linear pairs. + table.remove( choices, i ) + end + end + + return #choices > 0 and choices +end + +-- Returns whether the circle intersects the polygon. +-- x, y, radius, polygonPoints +local function getPolygonCircleIntersection( x, y, radius, ... ) + local input = checkInput( ... ) + local choices = {} + + for i = 1, #input, 2 do + local Type, x1, y1, x2, y2 = getCircleSegmentIntersection( x, y, radius, input[i], input[i + 1], cycle( input, i + 2 ), cycle( input, i + 3 ) ) + if x2 then + choices[#choices + 1] = { Type, x1, y1, x2, y2 } + elseif x1 then choices[#choices + 1] = { Type, x1, y1 } end + end + + local final = removeDuplicates4Points( choices ) + + return #final > 0 and final +end + +-- Returns whether the circle is inside the polygon. +-- x, y, radius, polygonPoints +local function isCircleInsidePolygon( x, y, radius, ... ) + local input = checkInput( ... ) + return checkPolygonPoint( x, y, input ) +end + +-- Returns whether the polygon is inside the polygon. +local function isPolygonInsidePolygon( polygon1, polygon2 ) + local bool = false + for i = 1, #polygon2, 2 do + local result = false + result = isSegmentInsidePolygon( polygon2[i], polygon2[i + 1], cycle( polygon2, i + 2 ), cycle( polygon2, i + 3 ), polygon1 ) + if result then bool = true; break end + end + return bool +end + +-- Checks if a segment is completely inside a polygon +local function isSegmentCompletelyInsidePolygon( x1, y1, x2, y2, ... ) + local polygon = checkInput( ... ) + if not checkPolygonPoint( x1, y1, polygon ) + or not checkPolygonPoint( x2, y2, polygon ) + or getPolygonSegmentIntersection( x1, y1, x2, y2, polygon ) then + return false + end + return true +end + +-- Checks if a polygon is completely inside another polygon +local function isPolygonCompletelyInsidePolygon( polygon1, polygon2 ) + for i = 1, #polygon1, 2 do + local x1, y1 = polygon1[i], polygon1[i + 1] + local x2, y2 = polygon1[i + 2] or polygon1[1], polygon1[i + 3] or polygon1[2] + if not isSegmentCompletelyInsidePolygon( x1, y1, x2, y2, polygon2 ) then + return false + end + end + return true +end + +-------------- Circle w/ Polygons -------------- +-- Gets if a polygon is completely within a circle +-- circleX, circleY, circleRadius, polygonPoints +local function isPolygonCompletelyInsideCircle( circleX, circleY, circleRadius, ... ) + local input = checkInput( ... ) + local function isDistanceLess( px, py, x, y, circleRadius ) -- Faster, does not use math.sqrt + local distanceX, distanceY = px - x, py - y + return distanceX * distanceX + distanceY * distanceY < circleRadius * circleRadius -- Faster. For comparing distances only. + end + + for i = 1, #input, 2 do + if not checkCirclePoint( input[i], input[i + 1], circleX, circleY, circleRadius ) then return false end + end + return true +end + +-- Checks if a circle is completely within a polygon +-- circleX, circleY, circleRadius, polygonPoints +local function isCircleCompletelyInsidePolygon( circleX, circleY, circleRadius, ... ) + local input = checkInput( ... ) + if not checkPolygonPoint( circleX, circleY, ... ) then return false end + + local rad2 = circleRadius * circleRadius + + for i = 1, #input, 2 do + local x1, y1 = input[i], input[i + 1] + local x2, y2 = input[i + 2] or input[1], input[i + 3] or input[2] + if distance2( x1, y1, circleX, circleY ) <= rad2 then return false end + if getCircleSegmentIntersection( circleX, circleY, circleRadius, x1, y1, x2, y2 ) then return false end + end + return true +end -- }}} + +-- Statistics ----------------------------------- {{{ +-- Gets the average of a list of points +-- points +local function getMean( ... ) + local input = checkInput( ... ) + + mean = getSummation( 1, #input, + function( i, t ) + return input[i] + end + ) / #input + + return mean +end + +local function getMedian( ... ) + local input = checkInput( ... ) + + table.sort( input ) + + local median + if #input % 2 == 0 then -- If you have an even number of terms, you need to get the average of the middle 2. + median = getMean( input[#input / 2], input[#input / 2 + 1] ) + else + median = input[#input / 2 + .5] + end + + return median +end + +-- Gets the mode of a number. +local function getMode( ... ) + local input = checkInput( ... ) + + table.sort( input ) + local sorted = {} + for i = 1, #input do + local value = input[i] + sorted[value] = sorted[value] and sorted[value] + 1 or 1 + end + + local occurrences, least = 0, {} + for i, value in pairs( sorted ) do + if value > occurrences then + least = { i } + occurrences = value + elseif value == occurrences then + least[#least + 1] = i + end + end + + if #least >= 1 then return least, occurrences + else return false end +end + +-- Gets the range of the numbers. +local function getRange( ... ) + local input = checkInput( ... ) + local high, low = math.max( unpack( input ) ), math.min( unpack( input ) ) + return high - low +end + +-- Gets the variance of a set of numbers. +local function getVariance( ... ) + local input = checkInput( ... ) + local mean = getMean( ... ) + local sum = 0 + for i = 1, #input do + sum = sum + ( mean - input[i] ) * ( mean - input[i] ) + end + return sum / #input +end + +-- Gets the standard deviation of a set of numbers. +local function getStandardDeviation( ... ) + return math.sqrt( getVariance( ... ) ) +end + +-- Gets the central tendency of a set of numbers. +local function getCentralTendency( ... ) + local mode, occurrences = getMode( ... ) + return mode, occurrences, getMedian( ... ), getMean( ... ) +end + +-- Gets the variation ratio of a data set. +local function getVariationRatio( ... ) + local input = checkInput( ... ) + local numbers, times = getMode( ... ) + times = times * #numbers -- Account for bimodal data + return 1 - ( times / #input ) +end + +-- Gets the measures of dispersion of a data set. +local function getDispersion( ... ) + return getVariationRatio( ... ), getRange( ... ), getStandardDeviation( ... ) +end -- }}} + +-- Vector 2 ------------------------------------- {{{ +--[[ +Vector2 Copyright (c) 2010-2013 Matthias Richter + +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. + +Except as contained in this notice, the name(s) of the above copyright holders +shall not be used in advertising or otherwise to promote the sale, use or +other dealings in this Software without prior written authorization. + +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. +]]-- + +local sqrt, cos, sin, atan2 = math.sqrt, math.cos, math.sin, math.atan2 + +local function newVector(x, y) + return {x = x or 0, y = y or 0} +end + +local function isVector(a) + return type(a.x) == "number" and type(a.y) == "number" +end + +local function cloneVector(a) + return newVector(a.x, a.y) +end + +local function unpackVector(a) + return a.x, a.y +end + +local function toStringVector(a) + return string.format("(%f,%f)", a.x, a.y) +end + +local function invertVector(a) + return newVector(-a.x, -a.y) +end + +local function addVector(a, b) + if type(a) == "table" and type(b) == "table" then + return newVector(a.x+b.x, a.y+b.y) + elseif type(a) == "table" and type(b) == "number" then + return newVector(a.x+b, a.y+b) + elseif type(a) == "number" and type(b) == "table" then + return newVector(a+b.x, a+b.y) + end +end + +local function subVector(a, b) + if type(a) == "table" and type(b) == "table" then + return newVector(a.x-b.x, a.y-b.y) + elseif type(a) == "table" and type(b) == "number" then + return newVector(a.x-b, a.y-b) + elseif type(a) == "number" and type(b) == "table" then + return newVector(a-b.x, a-b.y) + end +end + +local function mulVector(a, b) + if type(a) == "table" and type(b) == "table" then + return newVector(a.x*b.x, a.y*b.y) + elseif type(a) == "table" and type(b) == "number" then + return newVector(a.x*b, a.y*b) + elseif type(a) == "number" and type(b) == "table" then + return newVector(a*b.x, a*b.y) + end +end + +local function divVector(a, b) + if type(a) == "table" and type(b) == "table" then + return newVector(a.x/b.x, a.y/b.y) + elseif type(a) == "table" and type(b) == "number" then + return newVector(a.x/b, a.y/b) + elseif type(a) == "number" and type(b) == "table" then + return newVector(a/b.x, a/b.y) + end +end + +local function eqVector(a, b) + return a.x == b.x and a.y == b.y +end + +local function ltVector(a, b) + return a.x < b.x or (a.x == b.x and a.y < b.y) +end + +local function leVector(a, b) + return a.x <= b.x and a.y <= b.y +end + +local function gtVector(a, b) + return ltVector(b, a) +end + +local function geVector(a, b) + return leVector(b, a) +end + +local function dotVector(a, b) + return a.x*b.x + a.y*b.y +end + +local function len2Vector(a) + return a.x * a.x + a.y * a.y +end + +local function lenVector(a) + return sqrt(len2Vector(a)) +end + +local function dist2Vector(a, b) + local dx = a.x - b.x + local dy = a.y - b.y + return (dx * dx + dy * dy) +end + +local function distVector(a, b) + return sqrt(dis2Vector(a, b)) +end + +local function normalizeVector(a) + local l = lenVector(a) + + if l > 0 then + return newVector(a.x / l, a.y / l) + else + return newVector(a.x, a.y) + end +end + +local function rotateVector(a, phi) + local c, s = cos(phi), sin(phi) + return newVector(c * a.x - s * a.y, s * a.x + c * a.y) +end + +local function perpendicularVector(a) + return newVector(-a.y, a.x) +end + +local function projectOnVector(a, b) + local s = (a.x * b.x + a.y * b.y) / (b.x * b.x + b.y * b.y) + return newVector(s * b.x, s * b.y) +end + +local function mirrorOnVector(a, b) + local s = 2 * (a.x * b.x + a.y * b.y) / (b.x * b.x + b.y * b.y) + return newVector(s * b.x - a.x, s * b.y - a.y) +end + +local function crossVector(a, b) + return a.x * v.y - a.y * v.x +end + +-- ref.: http://blog.signalsondisplay.com/?p=336 +local function trimVector(a, maxLen) + local s = maxLen * maxLen / len2Vector(a) + s = (s > 1 and 1) or sqrt(s) + return newVector(a.x * s, a.y * s) +end + +local function angleToVector(a, b) + if b then + return atan2(a.y-b.y, a.x-b.x) + end + + return atan2(a.y, a.x) +end + +local function lerpVector(a, b, s) + return a + s * (b - a) +end -- }}} + +return { + _VERSION = 'MLib 0.11.0', + _DESCRIPTION = 'A math and shape-intersection detection library for Lua', + _URL = 'https://github.com/davisdude/mlib', + point = { + rotate = rotatePoint, + scale = scalePoint, + polarToCartesian = polarToCartesian, + cartesianToPolar = cartesianToPolar, + }, + line = { + getLength = getLength, + getMidpoint = getMidpoint, + getSlope = getSlope, + getPerpendicularSlope = getPerpendicularSlope, + getYIntercept = getYIntercept, + getIntersection = getLineLineIntersection, + getClosestPoint = getClosestPoint, + getSegmentIntersection = getLineSegmentIntersection, + checkPoint = checkLinePoint, + + -- Aliases + getDistance = getLength, + getCircleIntersection = getCircleLineIntersection, + getPolygonIntersection = getPolygonLineIntersection, + getLineIntersection = getLineLineIntersection, + }, + segment = { + checkPoint = checkSegmentPoint, + getPerpendicularBisector = getPerpendicularBisector, + getIntersection = getSegmentSegmentIntersection, + + -- Aliases + getCircleIntersection = getCircleSegmentIntersection, + getPolygonIntersection = getPolygonSegmentIntersection, + getLineIntersection = getLineSegmentIntersection, + getSegmentIntersection = getSegmentSegmentIntersection, + isSegmentCompletelyInsideCircle = isSegmentCompletelyInsideCircle, + isSegmentCompletelyInsidePolygon = isSegmentCompletelyInsidePolygon, + }, + math = { + getRoot = getRoot, + isPrime = isPrime, + round = round, + getSummation = getSummation, + getPercentOfChange = getPercentOfChange, + getPercentage = getPercentage, + getQuadraticRoots = getQuadraticRoots, + getAngle = getAngle, + }, + circle = { + getArea = getCircleArea, + checkPoint = checkCirclePoint, + isPointOnCircle = isPointOnCircle, + getCircumference = getCircumference, + getLineIntersection = getCircleLineIntersection, + getSegmentIntersection = getCircleSegmentIntersection, + getCircleIntersection = getCircleCircleIntersection, + isCircleCompletelyInside = isCircleCompletelyInsideCircle, + isPolygonCompletelyInside = isPolygonCompletelyInsideCircle, + isSegmentCompletelyInside = isSegmentCompletelyInsideCircle, + + -- Aliases + getPolygonIntersection = getPolygonCircleIntersection, + isCircleInsidePolygon = isCircleInsidePolygon, + isCircleCompletelyInsidePolygon = isCircleCompletelyInsidePolygon, + }, + polygon = { + getSignedArea = getSignedPolygonArea, + getArea = getPolygonArea, + getTriangleHeight = getTriangleHeight, + getCentroid = getCentroid, + getLineIntersection = getPolygonLineIntersection, + getSegmentIntersection = getPolygonSegmentIntersection, + checkPoint = checkPolygonPoint, + isSegmentInside = isSegmentInsidePolygon, + getPolygonIntersection = getPolygonPolygonIntersection, + getCircleIntersection = getPolygonCircleIntersection, + isCircleInside = isCircleInsidePolygon, + isPolygonInside = isPolygonInsidePolygon, + isCircleCompletelyInside = isCircleCompletelyInsidePolygon, + isSegmentCompletelyInside = isSegmentCompletelyInsidePolygon, + isPolygonCompletelyInside = isPolygonCompletelyInsidePolygon, + + -- Aliases + isCircleCompletelyOver = isPolygonCompletelyInsideCircle, + }, + statistics = { + getMean = getMean, + getMedian = getMedian, + getMode = getMode, + getRange = getRange, + getVariance = getVariance, + getStandardDeviation = getStandardDeviation, + getCentralTendency = getCentralTendency, + getVariationRatio = getVariationRatio, + getDispersion = getDispersion, + }, + vec2 = { + new = newVector, + isVector = isVector, + clone = cloneVector, + toString = toStringVector, + invert = invertVector, + add = addVector, + sub = subVector, + mul = mulVector, + div = divVector, + eq = eqVector, + lt = ltVector, + le = leVector, + gt = gtVector, + ge = geVector, + dot = dotVector, + len = lenVector, + len2 = len2Vector, + dist = distVector, + dist2 = dist2Vector, + normalize = normalizeVector, + rotate = rotateVector, + perpendicular = perpendicularVector, + projectOn = projectOnVector, + mirrorOn = mirrorOnVector, + cross = crossVector, + trim = trimVector, + angleTo = angleToVector, + lerp = lerpVector, + + -- Aliases + copy = cloneVector, + subtract = subtractVector, + multiply = mulVector, + divide = divVector, + equal = eqVector, + lessThan = ltVector, + lessThanOrEqualTo = leVector, + greaterThan = gtVector, + greaterThanOrEqualTo = geVector, + dotProduct = dotVector, + length = lenVector, + length2 = len2Vector, + distance = distVector, + distance2 = dist2Vector, + }, +} diff --git a/engine/external/ripple.lua b/engine/external/ripple.lua new file mode 100644 index 0000000..a9372c4 --- /dev/null +++ b/engine/external/ripple.lua @@ -0,0 +1,518 @@ +local ripple = { + _VERSION = 'Ripple', + _DESCRIPTION = 'Audio helpers for LÖVE.', + _URL = 'https://github.com/tesselode/ripple', + _LICENSE = [[ + MIT License + + Copyright (c) 2019 Andrew Minnich + + 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. + ]] +} + +local unpack = unpack or table.unpack -- luacheck: ignore + +--[[ + Represents an object that: + - can have tags applied + - has a volume + - can have effects applied + + Tags, instances, and sounds are all taggable. + + Note that not all taggable objects have children - tags and sounds + do, but instances do not. +]] +local Taggable = {} + +--[[ + Gets the total volume of this object given its own volume + and the volume of each of its tags. +]] +function Taggable:_getTotalVolume() + local volume = self.volume + for tag, _ in pairs(self._tags) do + volume = volume * tag:_getTotalVolume() + end + return volume +end + +--[[ + Gets all the effects that should be applied to this object given + its own effects and the effects of each of its tags. The object's + own effects will override tag effects. + + Note: currently, if multiple tags define settings for the same effect, + the final result is undefined, as taggable objects use pairs to iterate + through the tags, which iterates in an undefined order. +]] +function Taggable:_getAllEffects() + local effects = {} + for tag, _ in pairs(self._tags) do + for name, filterSettings in pairs(tag:_getAllEffects()) do + effects[name] = filterSettings + end + end + for name, filterSettings in pairs(self._effects) do + effects[name] = filterSettings + end + return effects +end + +--[[ + A callback that is called when anything happens that could + lead to a change in the object's total volume. +]] +function Taggable:_onChangeVolume() end + +--[[ + A callback that is called when anything happens that could + change which effects are applied to the object. +]] +function Taggable:_onChangeEffects() end + +function Taggable:_setVolume(volume) + self._volume = volume + self:_onChangeVolume() +end + +--[[ + _tag, _untag, and _setEffect are analogous to the + similarly named public API functions (see below), but + they don't call the _onChangeVolume and _onChangeEffects + callbacks. This allows me to have finer control over when + to call those callbacks, so I can set multiple tags and + effects without needlessly calling the callbacks for each + one. +]] + +function Taggable:_tag(tag) + self._tags[tag] = true + tag._children[self] = true +end + +function Taggable:_untag(tag) + self._tags[tag] = nil + tag._children[self] = nil +end + +function Taggable:_setEffect(name, filterSettings) + if filterSettings == nil then filterSettings = true end + self._effects[name] = filterSettings +end + +--[[ + Given an options table, initializes the object's volume, + tags, and effects. +]] +function Taggable:_setOptions(options) + self.volume = options and options.volume or 1 + -- reset tags + for tag in pairs(self._tags) do + self:_untag(tag) + end + -- apply new tags + if options and options.tags then + for _, tag in ipairs(options.tags) do + self:_tag(tag) + end + end + -- reset effects + for name in pairs(self._effects) do + self._effects[name] = nil + end + -- apply new effects + if options and options.effects then + for name, filterSettings in pairs(options.effects) do + self:_setEffect(name, filterSettings) + end + end + -- update final volume and effects + self:_onChangeVolume() + self:_onChangeEffects() +end + +function Taggable:tag(...) + for i = 1, select('#', ...) do + local tag = select(i, ...) + self:_tag(tag) + end + self:_onChangeVolume() + self:_onChangeEffects() +end + +function Taggable:untag(...) + for i = 1, select('#', ...) do + local tag = select(i, ...) + self:_untag(tag) + end + self:_onChangeVolume() + self:_onChangeEffects() +end + +--[[ + Sets an effect for this object. filterSettings can be the following types: + - table - the effect will be enabled with the filter settings given in the table + - true/nil - the effect will be enabled with no filter + - false - the effect will be explicitly disabled, overriding effect settings + from a parent sound or tag +]] +function Taggable:setEffect(name, filterSettings) + self:_setEffect(name, filterSettings) + self:_onChangeEffects() +end + +function Taggable:removeEffect(name) + self._effects[name] = nil + self:_onChangeEffects() +end + +function Taggable:getEffect(name) + return self._effects[name] +end + +function Taggable:__index(key) + if key == 'volume' then + return self._volume + end + return Taggable[key] +end + +function Taggable:__newindex(key, value) + if key == 'volume' then + self:_setVolume(value) + else + rawset(self, key, value) + end +end + +--[[ + Represents a tag that can be applied to sounds, + instances of sounds, or other tags. +]] +local Tag = {__newindex = Taggable.__newindex} + +function Tag:__index(key) + if Tag[key] then return Tag[key] end + return Taggable.__index(self, key) +end + +function Tag:_onChangeVolume() + -- tell objects using this tag about a potential + -- volume change + for child, _ in pairs(self._children) do + child:_onChangeVolume() + end +end + +function Tag:_onChangeEffect() + -- tell objects using this tag about a potential + -- effect change + for child, _ in pairs(self._children) do + child:_onChangeEffect() + end +end + +-- Pauses all the sounds and instances tagged with this tag. +function Tag:pause(fadeDuration) + for child, _ in pairs(self._children) do + child:pause(fadeDuration) + end +end + +-- Resumes all the sounds and instances tagged with this tag. +function Tag:resume(fadeDuration) + for child, _ in pairs(self._children) do + child:resume(fadeDuration) + end +end + +-- Stops all the sounds and instances tagged with this tag. +function Tag:stop(fadeDuration) + for child, _ in pairs(self._children) do + child:stop(fadeDuration) + end +end + +function ripple.newTag(options) + local tag = setmetatable({ + _effects = {}, + _tags = {}, + _children = {}, + }, Tag) + tag:_setOptions(options) + return tag +end + +-- Represents a specific occurrence of a sound. +local Instance = {} + +function Instance:__index(key) + if key == 'pitch' then + return self._source:getPitch() + elseif key == 'loop' then + return self._source:isLooping() + elseif Instance[key] then + return Instance[key] + end + return Taggable.__index(self, key) +end + +function Instance:__newindex(key, value) + if key == 'pitch' then + self._source:setPitch(value) + elseif key == 'loop' then + self._source:setLooping(value) + else + Taggable.__newindex(self, key, value) + end +end + +function Instance:_getTotalVolume() + local volume = Taggable._getTotalVolume(self) + -- apply sound volume as well as tag/self volumes + volume = volume * self._sound:_getTotalVolume() + -- apply fade volume + volume = volume * self._fadeVolume + return volume +end + +function Instance:_getAllEffects() + local effects = {} + for tag, _ in pairs(self._tags) do + for name, filterSettings in pairs(tag:_getAllEffects()) do + effects[name] = filterSettings + end + end + -- apply sound effects as well as tag/self effects + for name, filterSettings in pairs(self._sound:_getAllEffects()) do + effects[name] = filterSettings + end + for name, filterSettings in pairs(self._effects) do + effects[name] = filterSettings + end + return effects +end + +function Instance:_onChangeVolume() + -- update the source's volume + self._source:setVolume(self:_getTotalVolume()) +end + +function Instance:_onChangeEffects() + -- get the list of effects that should be applied + local effects = self:_getAllEffects() + for name, filterSettings in pairs(effects) do + -- remember which effects are currently applied to the source + if filterSettings == false then + self._appliedEffects[name] = nil + else + self._appliedEffects[name] = true + end + if filterSettings == true then + self._source:setEffect(name) + else + self._source:setEffect(name, filterSettings) + end + end + -- remove effects that are currently applied but shouldn't be anymore + for name in pairs(self._appliedEffects) do + if not effects[name] then + self._source:setEffect(name, false) + self._appliedEffects[name] = nil + end + end +end + +function Instance:_play(options) + if options and options.fadeDuration then + self._fadeVolume = 0 + self._fadeSpeed = 1 / options.fadeDuration + else + self._fadeVolume = 1 + end + self._fadeDirection = 1 + self._afterFadingOut = false + self._paused = false + self:_setOptions(options) + self.pitch = options and options.pitch or 1 + if options and options.loop ~= nil then + self.loop = options.loop + end + if not web then self._source:seek(options and options.seek or 0) end + self._source:play() +end + +function Instance:_update(dt) + -- fade in + if self._fadeDirection == 1 and self._fadeVolume < 1 then + self._fadeVolume = self._fadeVolume + self._fadeSpeed * dt + if self._fadeVolume > 1 then self._fadeVolume = 1 end + self:_onChangeVolume() + -- fade out + elseif self._fadeDirection == -1 and self._fadeVolume > 0 then + self._fadeVolume = self._fadeVolume - self._fadeSpeed * dt + if self._fadeVolume < 0 then + self._fadeVolume = 0 + -- pause or stop after fading out + if self._afterFadingOut == 'pause' then + self:pause() + elseif self._afterFadingOut == 'stop' then + self:stop() + end + end + self:_onChangeVolume() + end +end + +function Instance:isStopped() + return (not self._source:isPlaying()) and (not self._paused) +end + +function Instance:pause(fadeDuration) + if fadeDuration and not self._paused then + self._fadeDirection = -1 + self._fadeSpeed = 1 / fadeDuration + self._afterFadingOut = 'pause' + else + self._source:pause() + self._paused = true + end +end + +function Instance:resume(fadeDuration) + if fadeDuration then + if self._paused then + self._fadeVolume = 0 + self:_onChangeVolume() + end + self._fadeDirection = 1 + self._fadeSpeed = 1 / fadeDuration + end + self._source:play() + self._paused = false +end + +function Instance:stop(fadeDuration) + if fadeDuration and not self._paused then + self._fadeDirection = -1 + self._fadeSpeed = 1 / fadeDuration + self._afterFadingOut = 'stop' + else + self._source:stop() + self._paused = false + end +end + +-- Represents a sound that can be played. +local Sound = {} + +function Sound:__index(key) + if key == 'loop' then + return self._source:isLooping() + elseif Sound[key] then + return Sound[key] + end + return Taggable.__index(self, key) +end + +function Sound:__newindex(key, value) + if key == 'loop' then + self._source:setLooping(value) + for _, instance in ipairs(self._instances) do + instance.loop = value + end + else + Taggable.__newindex(self, key, value) + end +end + +function Sound:_onChangeVolume() + -- tell instances about potential volume changes + for _, instance in ipairs(self._instances) do + instance:_onChangeVolume() + end +end + +function Sound:_onChangeEffects() + -- tell instances about potential effect changes + for _, instance in ipairs(self._instances) do + instance:_onChangeEffects() + end +end + +function Sound:play(options) + -- reuse a stopped instance if one is available + for _, instance in ipairs(self._instances) do + if instance:isStopped() then + instance:_play(options) + return instance + end + end + -- otherwise, create a brand new one + local instance = setmetatable({ + _sound = self, + _source = self._source:clone(), + _effects = {}, + _tags = {}, + _appliedEffects = {}, + }, Instance) + table.insert(self._instances, instance) + instance:_play(options) + return instance +end + +function Sound:pause(fadeDuration) + for _, instance in ipairs(self._instances) do + instance:pause(fadeDuration) + end +end + +function Sound:resume(fadeDuration) + for _, instance in ipairs(self._instances) do + instance:resume(fadeDuration) + end +end + +function Sound:stop(fadeDuration) + for _, instance in ipairs(self._instances) do + instance:stop(fadeDuration) + end +end + +function Sound:update(dt) + for _, instance in ipairs(self._instances) do + instance:_update(dt) + end +end + +function ripple.newSound(source, options) + local sound = setmetatable({ + _source = source, + _effects = {}, + _tags = {}, + _instances = {}, + }, Sound) + sound:_setOptions(options) + if options and options.loop then sound.loop = true end + return sound +end + +return ripple diff --git a/engine/game/flashes.lua b/engine/game/flashes.lua new file mode 100644 index 0000000..1e4cf8c --- /dev/null +++ b/engine/game/flashes.lua @@ -0,0 +1,30 @@ +-- The base Flashes class. +-- This class is used to manage all flashes in an object. +-- Add a new flash: +-- self.flashes:add('hit', 0.15) +-- Use it: +-- self.flashes.hit:flash(0.1) +-- self.flashes.hit.f -- a boolean that says if it's currently flashing or not +-- Every GameObject has a .flashes attribute with a Flashes instance attached to it. +Flashes = Object:extend() +function Flashes:init() + self.trigger = Trigger() +end + + +function Flashes:update(dt) + self.trigger:update(dt) +end + + +-- Adds a new flash to the object. The name must be unique and the second argument is the default duration for the flash. +-- self.flashes:add('hit', 0.15) +function Flashes:add(name, default_duration) + if name == 'parent' or name == 'names' or name == 'trigger' or name == 'add' or name == 'use' or name == 'update' or name == 'init' or name == 'pull' or name == 'flash' then + error("Invalid name to be added to the Flashes object. 'add', 'flash', 'init', 'names', 'parent', 'pull', 'trigger', 'update' and 'use' are reserved names, choose another.") + end + self[name] = {f = false, default_duration = default_duration or 0.15, flash = function(_, duration) + self[name].f = true + self.trigger:after(duration or self[name].default_duration, function() self[name].f = false end, name) + end} +end diff --git a/engine/game/gameobject.lua b/engine/game/gameobject.lua new file mode 100644 index 0000000..5c6ae79 --- /dev/null +++ b/engine/game/gameobject.lua @@ -0,0 +1,78 @@ +-- The base GameObject class. +-- The general way of creating an object that implements these functions goes like this: +--[[ +MyGameObject = Object:extend() +MyGameObject:implement(GameObject) +function MyGameObject:init(args) + self:init_game_object(args) +end + +function MyGameObject:update(dt) + self:update_game_object(dt) +end +]]-- + +-- This simply implements the GameObject class as a mixin into your own class, giving it the functions defined in this file as well as the attributes set from init_game_object. +-- In general you'd create your own game object like this, for instance: +-- group = Group() +-- MyGameObject{group = group, x = 100, y = 100, v = 100, r = math.pi/4} +-- And then this object would be automatically updated and drawn by the group. +-- Alternatively you could add the object to the group manually: +-- my_object = MyGameObject{x = 100, y = 100, v = 100, r = math.pi/4} +-- group:add(my_object) +-- One of the nice patterns I've found was a passing arguments as a key + value table. +-- So in the case above, the object would automatically have its .x, .y and .v attributes set to 100 and its .r attribute set to math.pi/4. +GameObject = Object:extend() +function GameObject:init_game_object(args) + for k, v in pairs(args or {}) do self[k] = v end + if self.group then self.group:add(self) end + self.x, self.y = self.x or 0, self.y or 0 + self.r = self.r or 0 + self.sx, self.sy = self.sx or 1, self.sy or 1 + self.id = self.id or random:uid() + self.t = Trigger() + self.springs = Springs() + self.flashes = Flashes() + self.hfx = HitFX(self) + self.spring = Spring(1) + return self +end + + +function GameObject:update_game_object(dt) + self.t:update(dt) + self.springs:update(dt) + self.flashes:update(dt) + self.hfx:update(dt) + self.spring:update(dt) + if self.body then self:update_physics(dt) end + + if self.shape then + if self.shape.vertices and self.body then + self.shape.vertices = {self.body:getWorldPoints(self.fixture:getShape():getPoints())} + self.shape:get_centroid() + end + if self.body then + self.shape:move_to(self:get_position()) + end + + if self.interact_with_mouse then + local colliding_with_mouse = self.shape:is_colliding_with_point(self.group:get_mouse_position()) + if colliding_with_mouse and not self.colliding_with_mouse then + self.colliding_with_mouse = true + if self.on_mouse_enter then self:on_mouse_enter() end + elseif not colliding_with_mouse and self.colliding_with_mouse then + self.colliding_with_mouse = false + if self.on_mouse_exit then self:on_mouse_exit() end + end + if self.colliding_with_mouse then + if self.on_mouse_stay then self:on_mouse_stay() end + end + end + end +end + + +function GameObject:draw_game_object() + if self.body then self:draw_physics() end +end diff --git a/engine/game/group.lua b/engine/game/group.lua new file mode 100644 index 0000000..48ca53f --- /dev/null +++ b/engine/game/group.lua @@ -0,0 +1,410 @@ +-- The Group class is responsible for object management. +-- A common usage is to create different groups for different "layers" of behavior in the game: +--[[ +Game = Object:extend() +Game:implement(State) +function Game:on_enter() + self.main = Group():set_as_physics_world(192) + self.effects = Group() + self.floor = Group() + self.ui = Group():no_camera() +end + + +function Game:update(dt) + self.main:update(dt) + self.floor:update(dt) + self.effects:update(dt) + self.ui:update(dt) +end + + +function Game:draw() + self.floor:draw() + self.main:sort_by_y() + self.main:draw() + self.effects:draw() + self.ui:draw() +end +]]-- + +-- This is a simple example where you have four groups, each for a different purpose. +-- The main group is where all gameplay objects are and thus the only one that's using the physics world (box2d). +-- If you need an object to collide with another physically then they have to use the same physics world, and thus also the same group. +-- The effects and floor groups are purely visual, one for drawing things on the floor (it's a top-down-ish 2.5D game), like shadows, and the other for drawing visual effects on top of everything else. +-- As you can see in the draw function, floor is drawn first and effects is drawn after all gameplay objects. +-- These three groups above also all use the game's main camera instance as their targets since we want gameplay objects, floor and visual effects to be drawn according to the camera's transform. +-- Finally, the UI group is the one that doesn't have a camera attached to it because we want its objects to be drawn in fixed locations on the screen. +-- And this group is also drawn last because generally UI elements go on top of literally everything else. +Group = Object:extend() +function Group:init() + self.t = Trigger() + self.camera = camera + self.objects = {} + self.objects.by_id = {} + self.objects.by_class = {} + self.cells = {} + self.cell_size = 128 + return self +end + + +function Group:update(dt) + self.t:update(dt) + for _, object in ipairs(self.objects) do object:update(dt) end + if self.world then self.world:update(dt) end + + self.cells = {} + for _, object in ipairs(self.objects) do + local cx, cy = math.floor(object.x/self.cell_size), math.floor(object.y/self.cell_size) + if not self.cells[cx] then self.cells[cx] = {} end + if not self.cells[cx][cy] then self.cells[cx][cy] = {} end + table.insert(self.cells[cx][cy], object) + end + + for i = #self.objects, 1, -1 do + if self.objects[i].dead then + if self.objects[i].destroy then self.objects[i]:destroy() end + self.objects.by_id[self.objects[i].id] = nil + table.delete(self.objects.by_class[getmetatable(self.objects[i])], function(v) return v.id == self.objects[i].id end) + table.remove(self.objects, i) + end + end +end + + +-- scroll_factor_x and scroll_factor_y can be used for parallaxing, they should be values between 0 and 1 +-- The closer to 0, the more of a parallaxing effect there will be. +function Group:draw(scroll_factor_x, scroll_factor_y) + if self.camera then self.camera:attach(scroll_factor_x, scroll_factor_y) end + for _, object in ipairs(self.objects) do object:draw() end + if self.camera then self.camera:detach() end +end + + +-- Draws only objects within the indexed range +-- group:draw_range(1, 3) -> draws only 1st, 2nd and 3rd objects in this group +function Group:draw_range(i, j, scroll_factor_x, scroll_factor_y) + if self.camera then self.camera:attach(scroll_factor_x, scroll_factor_y) end + for k = i, j do self.objects[k]:draw() end + if self.camera then self.camera:detach() end +end + + +-- Draws only objects of a certain class +-- group:draw_class(Solid) -> draws only objects of the Solid class +function Group:draw_class(class, scroll_factor_x, scroll_factor_y) + if self.camera then self.camera:attach(scroll_factor_x, scroll_factor_y) end + for _, object in ipairs(self.objects) do + if object:is(class) then + object:draw() + end + end + if self.camera then self.camera:detach() end +end + + +-- Draws all objects except those of specified classes +-- group:draw_all_except({Solid, SolidGeometry}) -> draws all objects except those of the Solid and SolidGeometry classes +function Group:draw_all_except(classes, scroll_factor_x, scroll_factor_y) + if self.camera then self.camera:attach(scroll_factor_x, scroll_factor_y) end + for _, object in ipairs(self.objects) do + if not table.any(classes, function(v) return object:is(v) end) then + object:draw() + end + end + if self.camera then self.camera:detach() end +end + + +-- Sets this group as one without a camera, useful for things like UIs +function Group:no_camera() + self.camera = nil + return self +end + + +-- Sorts all objects in this group by their y position +-- This is useful for top-down 2.5D games so that objects further up on the screen are drawn first and look like they're further away from the camera +-- Objects can additionally have a .y_sort_offset attribute which gets added to this function's calculations +-- This attribute is useful for objects that are longer vertically and need some adjusting otherwise the point at which they get drawn behind looks off +function Group:sort_by_y() + table.sort(self.objects, function(a, b) return (a.y + (a.y_sort_offset or 0)) < (b.y + (b.y_sort_offset or 0)) end) +end + + +-- Returns the mouse position based on the camera used by this group +-- mx, my = group:get_mouse_position() +function Group:get_mouse_position() + if self.camera then + return self.camera.mouse.x, self.camera.mouse.y + else + local mx, my = love.mouse.getPosition() + return mx/sx, my/sy + end +end + + +function Group:destroy() + for _, object in ipairs(self.objects) do object:destroy() end + self.objects = {} + self.objects.by_id = {} + self.objects.by_class = {} + if self.world then + self.world:destroy() + self.world = nil + end + return self +end + + +-- Adds an existing object to the group +-- player = Player{x = 160, y = 80} +-- group:add(player) +-- Creates an object and automatically add it to the group +-- player = Player{group = group, x = 160, y = 80} +-- The object has its .group attribute set to this group, and has a random .id set if it doesn't already have one +function Group:add(object) + local class = getmetatable(object) + object.group = self + if not object.id then object.id = random:uid() end + self.objects.by_id[object.id] = object + if not self.objects.by_class[class] then self.objects.by_class[class] = {} end + table.insert(self.objects.by_class[class], object) + table.insert(self.objects, object) + return object +end + + +-- Returns an object by its unique id +-- group:get_object_by_id(id) -> the object +function Group:get_object_by_id(id) + return self.objects.by_id[id] +end + + +-- Returns the first object found after searching for it by property, the property value must be unique among all objects +-- group:get_object_by_property('special_id', 347762) -> the object +function Group:get_object_by_property(key, value) + for _, object in ipairs(self.objects) do + if object[key] == value then + return object + end + end +end + + +-- Returns an object after searching for it by properties with all of them matching, the property value match must be unique among all objects +-- group:get_object_by_properties({'special_id_1', 'special_id_2'}, {347762, 32452}) -> the object +function Group:get_object_by_properties(keys, values) + for _, object in ipairs(self.objects) do + local this_is_the_object = true + for i = 1, #keys do + if object[keys[i]] ~= values[i] then + this_is_the_object = false + end + end + if this_is_the_object then + return object + end + end +end + + +-- Returns all objects of a specific class +-- group:get_objects_by_class(Star) -> all objects of class Star in a table +function Group:get_objects_by_class(class) + if not self.objects.by_class[class] then return {} + else return table.shallow_copy(self.objects.by_class[class]) end +end + + +-- Returns all objects of the specified classes +-- group:get_objects_by_classes({Star, Enemy, Projectile}) -> all objects of class Star, Enemy or Projectile in a table +function Group:get_objects_by_classes(class_list) + local objects = {} + for _, class in ipairs(class_list) do table.insert(objects, self:get_objects_by_class(class)) end + return table.flatten(objects, true) +end + + +-- Returns all objects inside the shape, using its .x, .y attributes as the center and its .w, .h attributes as its bounding size. +-- If object_types is passed in then it only returns object of those classes. +-- The bounding size is used to select objects quickly and roughly, and then more specific and expensive collision methods are run on the objects returned from that selection. +-- group:get_objects_in_shape(Rectangle(player.x, player.y, 100, 100, player.r), {Enemy1, Enemy2}) -> all Enemy1 and Enemy2 instances in a 100x100 rotated rectangle around the player +-- group:get_objects_in_shape(Rectangle(player.x, player.y, 100, 100, player.r), {Enemy1, Enemy2}, {object_1, object_2}) -> same as above except excluding object instances object_1 and object_2 +function Group:get_objects_in_shape(shape, object_types, exclude_list) + local out = {} + local exclude_list = exclude_list or {} + local cx1, cy1 = math.floor((shape.x-shape.w)/self.cell_size), math.floor((shape.y-shape.h)/self.cell_size) + local cx2, cy2 = math.floor((shape.x+shape.w)/self.cell_size), math.floor((shape.y+shape.h)/self.cell_size) + for i = cx1, cx2 do + for j = cy1, cy2 do + local cx, cy = i, j + if self.cells[cx] then + local cell_objects = self.cells[cx][cy] + if cell_objects then + for _, object in ipairs(cell_objects) do + if object_types then + if not table.any(exclude_list, function(v) return v.id == object.id end) then + if table.any(object_types, function(v) return object:is(v) end) and object.shape and object.shape:is_colliding_with_shape(shape) then + table.insert(out, object) + end + end + else + if object.shape and object:is_colliding_with_shape(shape) then + table.insert(out, object) + end + end + end + end + end + end + end + return out +end + + +-- Returns the closest object in this group to the object passed in +-- Optionally also pass in a function which will only allow objects that pass its test to be considered in the calculations +-- group:get_closest_object(player) -> closest object to the player, if the player is in this group then this object will be the player itself +-- group:get_closest_object(player, function(o) return o.id ~= player.id end) -> closest object to the player that isn't the player +function Group:get_closest_object(object, select_function) + if not select_function then select_function = function(o) return true end end + local min_distance, min_index = 100000, 0 + for i, o in ipairs(self.objects) do + if select_function(o) then + local d = math.distance(o.x, o.y, object.x, object.y) + if d < min_distance then + min_distance = d + min_index = i + end + end + end + return self.objects[min_index] +end + + +-- Sets this group as a physics box2d world +-- This means that objects inserted here can also be initialized as physics objects (see the gameobject file for more on this) +-- group:set_as_physics_world(192, 0, 400) -> a common platformer setup with vertical downward gravity +-- group:set_as_physics_world(192) -> a common setup for most non-platformer games +-- If your game takes place in smaller world coordinates (i.e. you set game_width and game_height to 320x240 or something) then you'll want smaller meter values, like 32 instead of 192 +-- Read more on meter values for box2d worlds here: https://love2d.org/wiki/love.physics.setMeter +-- The last argument, tags, is a list of strings corresponding to collision tags that will be assigned to different objects, for instance: +-- group:set_as_physics_world(192, 0, 0, {'player', 'enemy', 'projectile', 'ghost'}) +-- As different physics objects have different collision behaviors in regards to one another, the tags created here will facilitate the delineation of those differences. +function Group:set_as_physics_world(meter, xg, yg, tags) + love.physics.setMeter(meter or 192) + self.tags = table.unify(table.push(tags, 'solid')) + self.collision_tags = {} + self.trigger_tags = {} + for i, tag in ipairs(self.tags) do + self.collision_tags[tag] = {category = i, masks = {}} + self.trigger_tags[tag] = {category = i, triggers = {}} + end + + self.world = love.physics.newWorld(xg or 0, yg or 0) + self.world:setCallbacks( + function(fa, fb, c) + local oa, ob = self:get_object_by_id(fa:getUserData()), self:get_object_by_id(fb:getUserData()) + if fa:isSensor() or fb:isSensor() then + if fa:isSensor() then if oa.on_trigger_enter then oa:on_trigger_enter(ob, c) end end + if fb:isSensor() then if ob.on_trigger_enter then ob:on_trigger_enter(oa, c) end end + else + if oa.on_collision_enter then oa:on_collision_enter(ob, c) end + if ob.on_collision_enter then ob:on_collision_enter(oa, c) end + end + end, + function(fa, fb, c) + local oa, ob = self:get_object_by_id(fa:getUserData()), self:get_object_by_id(fb:getUserData()) + if fa:isSensor() or fb:isSensor() then + if fa:isSensor() then if oa.on_trigger_exit then oa:on_trigger_exit(ob, c) end end + if fb:isSensor() then if ob.on_trigger_exit then ob:on_trigger_exit(oa, c) end end + else + if oa.on_collision_exit then oa:on_collision_exit(ob, c) end + if ob.on_collision_exit then ob:on_collision_exit(oa, c) end + end + end + ) + return self +end + + +-- Enables physical collision between objects of two tags +-- on_collision_enter and on_collision_exit callbacks will be called when objects of these two tags physically collide +-- By default, every object physically collides with every other object +-- group:set_as_physics_world(192, 0, 0, {'player', 'enemy', 'projectile', 'ghost', 'solid'}) +-- group:enable_collision_between('player', 'enemy') +function Group:enable_collision_between(tag1, tag2) + table.delete(self.collision_tags[tag1].masks, self.collision_tags[tag2].category) +end + + +-- Disables physical collision between objects of two tags +-- on_collision_enter and on_collision_exit callbacks will NOT be called when objects of these two tags pass through each other +-- group:set_as_physics_world(192, 0, 0, {'player', 'enemy', 'projectile', 'ghost', 'solid'}) +-- group:disable_collision_between('ghost', 'solid') +-- group:disable_collision_between('player', 'projectile') +function Group:disable_collision_between(tag1, tag2) + table.insert(self.collision_tags[tag1].masks, self.collision_tags[tag2].category) +end + + +-- Enables trigger collision between objects of two tags +-- When objects have physical collision disabled between one another, you might still want to have the engine generate enter and exit events when they start/stop overlapping +-- This is the function that makes that happen +-- group:set_as_physics_world(192, 0, 0, {'player', 'enemy', 'projectile', 'ghost', 'solid'}) +-- group:disable_collision_between('ghost', 'solid') +-- group:enable_trigger_between('ghost', 'solid') -> now when a ghost passes through a solid, on_trigger_enter and on_trigger_exit will be called +function Group:enable_trigger_between(tag1, tag2) + table.insert(self.trigger_tags[tag1].triggers, self.trigger_tags[tag2].category) +end + + +-- Disables trigger collision between objects of two tags +-- This will only work if enable_trigger_between has been called for a pair of tags +-- In general you shouldn't use this, as trigger collisions are disabled by default for all objects +function Group:disable_trigger_between(tag1, tag2) + table.delete(self.trigger_tags[tag1].triggers, self.trigger_tags[tag2].category) +end + + +-- Returns a table of all physics objects that collide with the segment passed in +-- This requires that the group is set as a physics world first and only works on objects initialized as physics objects (see gameobject file) +-- This function returns a table of hits, each hit is of the following format: { +-- x = hit's x position, y = hit's y position, +-- nx = hit's x normal, ny = hit's y normal, +-- fraction = a number from 0 to 1 representing the fraction of the segment where the hit happened, +-- other = the object hit by the segment +-- } +-- So if the following call group:raycast(100, 100, 800 800) hits 3 objects, it will return something like this: { +-- [1] = {x = ..., y = ..., nx = ..., ny = ..., fraction = ..., other = the 1st object hit}, +-- [2] = {x = ..., y = ..., nx = ..., ny = ..., fraction = ..., other = the 2nd object hit}, +-- [3] = {x = ..., y = ..., nx = ..., ny = ..., fraction = ..., other = the 3rd object hit}, +-- } +-- Where ... just stands for some number. +function Group:raycast(x1, y1, x2, y2) + if not self.world then return end + + self.raycast_hitlist = {} + self.world:rayCast(x1, y1, x2, y2, function(fixture, x, y, nx, ny, fraction) + local hit = {} + hit.fixture = fixture + hit.x, hit.y = x, y + hit.nx, hit.ny = nx, ny + hit.fraction = fraction + table.insert(self.raycast_hitlist, hit) + return 1 + end) + + local hits = {} + for _, hit in ipairs(self.raycast_hitlist) do + local obj = self:get_object_by_id(hit.fixture:getUserData()) + hit.fixture = nil + hit.other = obj + table.insert(hits, hit) + end + + return hits +end diff --git a/engine/game/hitfx.lua b/engine/game/hitfx.lua new file mode 100644 index 0000000..b4e4201 --- /dev/null +++ b/engine/game/hitfx.lua @@ -0,0 +1,58 @@ +-- The base HitFX class. +-- Whenever an object is interacted with it's a good idea to either pull on a spring attached to its scale, or to flash it to signal that the interaction went through. +-- This is a combination of both Springs and Flashes put together to create that effect. +-- An instance of this called .hfx is added automatically to every game object. +-- Add a new effect: +-- self.hfx:add('hit') +-- Subsequent arguments are defaults for flashes and springs respectively, so: +-- self.hfx:add('hit', 0.15, 1, 200, 20) +-- Will add a flash with default duration of 0.15 and a spring with parameters 1, 200, 20. +-- Use the effect: +-- self.hfx:use('hit') +-- Subsequent arguments are the same as for the add function. This will call flash on the flash and pull on the spring. +-- Access its values: +-- self.hfx.hit.x -- the spring value +-- self.hfx.hit.f -- the flash boolean +HitFX = Object:extend() +function HitFX:init(parent) + self.parent = parent + self.names = {} +end + + +function HitFX:update(dt) + if not self.parent then return end + if self.parent and self.parent.dead then self.parent = nil; return end + + for _, name in ipairs(self.names) do + self[name].x = self.parent.springs[name].x + self[name].f = self.parent.flashes[name].f + end +end + + +function HitFX:add(name, x, k, d, default_flash_duration) + if name == 'parent' or name == 'names' or name == 'trigger' or name == 'add' or name == 'use' or name == 'update' or name == 'init' or name == 'pull' or name == 'flash' then + error("Invalid name to be added to the HitFX object. 'add', 'flash', 'init', 'names', 'parent', 'pull', 'trigger', 'update' and 'use' are reserved names, choose another.") + end + self.parent.flashes:add(name, default_flash_duration) + self.parent.springs:add(name, x, k, d) + table.insert(self.names, name) + self[name] = {x = self.parent.springs[name].x, f = self.parent.flashes[name].f} +end + + +function HitFX:use(name, x, k, d, flash_duration) + self.parent.flashes[name]:flash(flash_duration) + self.parent.springs[name]:pull(x, k, d) +end + + +function HitFX:pull(name, ...) + self.parent.springs[name]:pull(...) +end + + +function HitFX:flash(name, ...) + self.parent.flashes[name]:flash(...) +end diff --git a/engine/game/input.lua b/engine/game/input.lua new file mode 100644 index 0000000..527c916 --- /dev/null +++ b/engine/game/input.lua @@ -0,0 +1,109 @@ +Input = Object:extend() +function Input:init(joystick_index) + self.mouse_buttons = {"m1", "m2", "m3", "m4", "m5", "wheel_up", "wheel_down"} + self.gamepad_buttons = {"fdown", "fup", "fleft", "fright", "dpdown", "dpup", "dpleft", "dpright", "start", "back", "guide", "leftstick", "rightstick", "rb", "lb"} + self.index_to_gamepad_button = {["a"] = "fdown", ["b"] = "fright", ["x"] = "fleft", ["y"] = "fup", ["back"] = "back", ["start"] = "start", ["guide"] = "guide", ["leftstick"] = "leftstick", + ["rightstick"] = "rightstick", ["leftshoulder"] = "lb", ["rightshoulder"] = "rb", ["dpdown"] = "dpdown", ["dpup"] = "dpup", ["dpleft"] = "dpleft", ["dpright"] = "dpright", + } + self.index_to_gamepad_axis = {["leftx"] = "leftx", ["rightx"] = "rightx", ["lefty"] = "lefty", ["righty"] = "righty", ["triggerleft"] = "lt", ["triggerright"] = "rt"} + self.gamepad_axis = {} + self.joystick_index = joystick_index or 1 + self.joystick = love.joystick.getJoysticks()[self.joystick_index] + self.keyboard_state = {} + self.previous_keyboard_state = {} + self.mouse_state = {} + self.previous_mouse_state = {} + self.gamepad_state = {} + self.previous_gamepad_state = {} + self.actions = {} + self.textinput_buffer = '' +end + + +function Input:update(dt) + for _, action in ipairs(self.actions) do + self[action].pressed = false + self[action].down = false + self[action].released = false + end + + for _, action in ipairs(self.actions) do + for _, key in ipairs(self[action].keys) do + if table.contains(self.mouse_buttons, key) then + self[action].pressed = self[action].pressed or (self.mouse_state[key] and not self.previous_mouse_state[key]) + self[action].down = self[action].down or self.mouse_state[key] + self[action].released = self[action].released or (not self.mouse_state[key] and self.previous_mouse_state[key]) + elseif table.contains(self.gamepad_buttons, key) then + self[action].pressed = self[action].pressed or (self.gamepad_state[key] and not self.previous_gamepad_state[key]) + self[action].down = self[action].down or self.gamepad_state[key] + self[action].released = self[action].released or (not self.gamepad_state[key] and self.previous_gamepad_state[key]) + else + self[action].pressed = self[action].pressed or (self.keyboard_state[key] and not self.previous_keyboard_state[key]) + self[action].down = self[action].down or self.keyboard_state[key] + self[action].released = self[action].released or (not self.keyboard_state[key] and self.previous_keyboard_state[key]) + end + end + end + + self.previous_mouse_state = table.copy(self.mouse_state) + self.previous_gamepad_state = table.copy(self.gamepad_state) + self.previous_keyboard_state = table.copy(self.keyboard_state) + self.mouse_state.wheel_up = false + self.mouse_state.wheel_down = false +end + + +function Input:set_mouse_grabbed(v) + love.mouse.setGrabbed(v) +end + + +function Input:set_mouse_visible(v) + love.mouse.setVisible(v) +end + + +function Input:bind(action, keys) + if not self[action] then self[action] = {} end + if type(keys) == "string" then self[action].keys = {keys} + elseif type(keys) == "table" then self[action].keys = keys end + table.insert(self.actions, action) +end + + +function Input:unbind(action) + self[action] = nil +end + + +function Input:axis(key) + return self.gamepad_axis[key] +end + + +function Input:textinput(text) + self.textinput_buffer = self.textinput_buffer .. text + return self.textinput_buffer +end + + +function Input:get_and_clear_textinput_buffer() + local buffer = self.textinput_buffer + self.textinput_buffer = "" + return buffer +end + + +function Input:bind_all() + -- Set direct input binds for every keyboard and mouse key + -- Mostly to be used if you want to skip the action system and refer to keys directly (i.e. for internal tools or menus that don't need their keys changed ever) + local keyboard_binds = {['a'] = {'a'}, ['b'] = {'b'}, ['c'] = {'c'}, ['d'] = {'d'}, ['e'] = {'e'}, ['f'] = {'f'}, ['g'] = {'g'}, ['h'] = {'h'}, ['i'] = {'i'}, ['j'] = {'j'}, ['k'] = {'k'}, ['l'] = {'l'}, ['m'] = {'m'}, ['n'] = {'n'}, ['o'] = {'o'}, ['p'] = {'p'}, ['q'] = {'q'}, ['r'] = {'r'}, ['s'] = {'s'}, ['t'] = {'t'}, ['u'] = {'u'}, ['v'] = {'v'}, ['w'] = {'w'}, ['x'] = {'x'}, ['y'] = {'y'}, ['z'] = {'z'}, ['0'] = {'0'}, ['1'] = {'1'}, ['2'] = {'2'}, ['3'] = {'3'}, ['4'] = {'4'}, ['5'] = {'5'}, ['6'] = {'6'}, ['7'] = {'7'}, ['8'] = {'8'}, ['9'] = {'9'}, ['space'] = {'space'}, ['!'] = {'!'}, ['"'] = {'"'}, ['#'] = {'#'}, ['$'] = {'$'}, ['&'] = {'&'}, ["'"] = {"'"}, ['('] = {'('}, [')'] = {')'}, ['*'] = {'*'}, ['+'] = {'+'}, [','] = {','}, ['-'] = {'-'}, ['.'] = {'.'}, ['/'] = {'/'}, [':'] = {':'}, [';'] = {';'}, ['kp0'] = {'kp0'}, ['kp1'] = {'kp1'}, ['kp2'] = {'kp2'}, ['kp3'] = {'kp3'}, ['kp4'] = {'kp4'}, ['kp5'] = {'kp5'}, ['kp6'] = {'kp6'}, ['kp7'] = {'kp7'}, ['kp8'] = {'kp8'}, ['kp9'] = {'kp9'}, ['kp.'] = {'kp.'}, ['kp,'] = {'kp,'}, ['kp/'] = {'kp/'}, ['kp*'] = {'kp*'}, ['kp-'] = {'kp-'}, ['kp+'] = {'kp+'}, ['kpenter'] = {'kpenter'}, ['kp='] = {'kp='}, ['up'] = {'up'}, ['down'] = {'down'}, ['right'] = {'right'}, ['left'] = {'left'}, ['home'] = {'home'}, ['pageup'] = {'pageup'}, ['pagedown'] = {'pagedown'}, ['insert'] = {'insert'}, ['backspace'] = {'backspace'}, ['tab'] = {'tab'}, ['clear'] = {'clear'}, ['return'] = {'return'}, ['delete'] = {'delete'}, ['f1'] = {'f1'}, ['f2'] = {'f2'}, ['f3'] = {'f3'}, ['f4'] = {'f4'}, ['f5'] = {'f5'}, ['f6'] = {'f6'}, ['f7'] = {'f7'}, ['f8'] = {'f8'}, ['f9'] = {'f9'}, ['f10'] = {'f10'}, ['f11'] = {'f11'}, ['f12'] = {'f12'}, ['f13'] = {'f13'}, ['f14'] = {'f14'}, ['f15'] = {'f15'}, ['f16'] = {'f16'}, ['f17'] = {'f17'}, ['f18'] = {'f18'}, ['numlock'] = {'numlock'}, ['capslock'] = {'capslock'}, ['scrolllock'] = {'scrolllock'}, ['rshift'] = {'rshift'}, ['lshift'] = {'lshift'}, ['rctrl'] = {'rctrl'}, ['lctrl'] = {'lctrl'}, ['ralt'] = {'ralt'}, ['lalt'] = {'lalt'}, ['rgui'] = {'rgui'}, ['lgui'] = {'lgui'}, ['mode'] = {'mode'}, ['escape'] = {'escape'}} + for k, v in pairs(keyboard_binds) do self:bind(k, v) end + self:bind('m1', {'m1'}) + self:bind('m2', {'m2'}) + self:bind('m3', {'m3'}) + self:bind('m4', {'m4'}) + self:bind('m5', {'m5'}) + self:bind('wheel_up', {'wheel_up'}) + self:bind('wheel_down', {'wheel_down'}) +end diff --git a/engine/game/object.lua b/engine/game/object.lua new file mode 100644 index 0000000..8d63eb3 --- /dev/null +++ b/engine/game/object.lua @@ -0,0 +1,53 @@ +Object = {} +Object.__index = Object +function Object:init() +end + + +function Object:extend() + local cls = {} + for k, v in pairs(self) do + if k:find("__") == 1 then + cls[k] = v + end + end + cls.__index = cls + cls.super = self + setmetatable(cls, self) + return cls +end + + +function Object:implement(...) + for _, cls in pairs({...}) do + for k, v in pairs(cls) do + if self[k] == nil and type(v) == "function" then + self[k] = v + end + end + end +end + + +function Object:is(T) + local mt = getmetatable(self) + while mt do + if mt == T then + return true + end + mt = getmetatable(mt) + end + return false +end + + +function Object:__tostring() + return "Object" +end + + +function Object:__call(...) + local obj = setmetatable({}, self) + obj:init(...) + return obj +end diff --git a/engine/game/parent.lua b/engine/game/parent.lua new file mode 100644 index 0000000..5deb0be --- /dev/null +++ b/engine/game/parent.lua @@ -0,0 +1,19 @@ +-- This useful to add to objects that need to have some kind of relationship with their parents. +-- Call the appropriate function in the object's update function every frame. +-- The game object must have a .parent attribute defined and pointing to another game object. +Parent = Object:extend() + + +-- Follows the parent's transform exclusively. +-- This means that if the parent dies the entity also dies. +-- The .parent attribute is niled on death. +function Parent:follow_parent_exclusively() + if self.parent and self.parent.dead then + self.parent = nil + self.dead = true + return + end + self.x, self.y = self.parent.x, self.parent.y + self.r = self.parent.r + self.sx, self.sy = self.parent.sx, self.parent.sy +end diff --git a/engine/game/physics.lua b/engine/game/physics.lua new file mode 100644 index 0000000..e0bc546 --- /dev/null +++ b/engine/game/physics.lua @@ -0,0 +1,662 @@ +-- A physics mixin. Responsible for turning the game object it's attached to into a full fledged physics object. +-- Currently the only default way to add collision to objects is via this mixin. +-- In the future I want to create a way that doesn't make use of box2d for simpler games, but that also uses roughly the same API so that gameplay code doesn't have to be different regardless of which one you're using. +-- Using any of the "set_as" init functions requires the game object to have a group attached to it. +Physics = Object:extend() + + +-- Sets this object as a physics rectangle. +-- Its body_type can be either 'static', 'dynamic' or 'kinematic' (see box2d for more info) and its tag has to have been created in group:set_as_physics_world. +-- Its .shape variable is set to a Rectangle instance and this instance is updated to be in sync with the physics body every frame. +function Physics:set_as_rectangle(w, h, body_type, tag) + if not self.group then error("The GameObject must have a group defined for the Physics mixin to function") end + self.tag = tag + self.shape = Rectangle(self.x, self.y, w, h) + self.body = love.physics.newBody(self.group.world, self.x, self.y, body_type or "dynamic") + local shape = love.physics.newRectangleShape(self.shape.w, self.shape.h) + self.fixture = love.physics.newFixture(self.body, shape) + self.fixture:setUserData(self.id) + self.fixture:setCategory(self.group.collision_tags[tag].category) + self.fixture:setMask(unpack(self.group.collision_tags[tag].masks)) + if #self.group.trigger_tags[tag].triggers > 0 then + self.sensor = love.physics.newFixture(self.body, shape) + self.sensor:setUserData(self.id) + self.sensor:setSensor(true) + end + return self +end + + +-- Sets this object as a physics line. +-- Its body_type can be either 'static', 'dynamic' or 'kinematic' (see box2d for more info) and its tag has to have been created in group:set_as_physics_world. +-- Its .shape variable is set to a Line instance and this instance is updated to be in sync with the physics body every frame. +function Physics:set_as_line(x1, y1, x2, y2, body_type, tag) + if not self.group then error("The GameObject must have a group defined for the Physics mixin to function") end + self.tag = tag + self.shape = Line(x1, y1, x2, y2) + self.body = love.physics.newBody(self.group.world, 0, 0, body_type or "dynamic") + local shape = love.physics.newEdgeShape(self.shape.x1, self.shape.y1, self.shape.x2, self.shape.y2) + self.fixture = love.physics.newFixture(self.body, shape) + self.fixture:setUserData(self.id) + self.fixture:setCategory(self.group.collision_tags[tag].category) + self.fixture:setMask(unpack(self.group.collision_tags[tag].masks)) + if #self.group.trigger_tags[tag].triggers > 0 then + self.sensor = love.physics.newFixture(self.body, shape) + self.sensor:setUserData(self.id) + self.sensor:setSensor(true) + end + return self +end + + +-- Sets this object as a physics chain (a collection of edges) +-- Its body_type can be either 'static', 'dynamic' or 'kinematic' (see box2d for more info) and its tag has to have been created in group:set_as_physics_world. +-- If loop is set to true, then the collection of edges will be closed, forming a polygon. Otherwise it will be open. +-- Its .shape variable is set to a Chain instance and this instance is updated to be in sync with the physics body every frame. +function Physics:set_as_chain(loop, vertices, body_type, tag) + if not self.group then error("The GameObject must have a group defined for the Physics mixin to function") end + self.tag = tag + self.shape = Chain(loop, vertices) + self.body = love.physics.newBody(self.group.world, 0, 0, body_type or "dynamic") + local shape = love.physics.newChainShape(self.shape.loop, self.shape.vertices) + self.fixture = love.physics.newFixture(self.body, shape) + self.fixture:setUserData(self.id) + self.fixture:setCategory(self.group.collision_tags[tag].category) + self.fixture:setMask(unpack(self.group.collision_tags[tag].masks)) + if #self.group.trigger_tags[tag].triggers > 0 then + self.sensor = love.physics.newFixture(self.body, shape) + self.sensor:setUserData(self.id) + self.sensor:setSensor(true) + end + return self +end + + +-- Sets this object as a physics polygon. +-- Its body_type can be either 'static', 'dynamic' or 'kinematic' (see box2d for more info) and its tag has to have been created in group:set_as_physics_world. +-- Its .shape variable is set to a Polygon instance and this instance is updated to be in sync with the physics body every frame. +function Physics:set_as_polygon(vertices, body_type, tag) + if not self.group then error("The GameObject must have a group defined for the Physics mixin to function") end + self.tag = tag + self.shape = Polygon(vertices) + self.body = love.physics.newBody(self.group.world, 0, 0, body_type or "dynamic") + self.body:setPosition(self.x, self.y) + local shape = love.physics.newPolygonShape(self.shape.vertices) + self.fixture = love.physics.newFixture(self.body, shape) + self.fixture:setUserData(self.id) + self.fixture:setCategory(self.group.collision_tags[tag].category) + self.fixture:setMask(unpack(self.group.collision_tags[tag].masks)) + if #self.group.trigger_tags[tag].triggers > 0 then + self.sensor = love.physics.newFixture(self.body, shape) + self.sensor:setUserData(self.id) + self.sensor:setSensor(true) + end + return self +end + + +-- Sets this object as a physics circle. +-- Its body_type can be either 'static', 'dynamic' or 'kinematic' (see box2d for more info) and its tag has to have been created in group:set_as_physics_world. +-- Its .shape variable is set to a Circle instance and this instance is updated to be in sync with the physics body every frame. +function Physics:set_as_circle(rs, body_type, tag) + if not self.group then error("The GameObject must have a group defined for the Physics mixin to function") end + self.tag = tag + self.shape = Circle(self.x, self.y, rs) + self.body = love.physics.newBody(self.group.world, self.x, self.y, body_type or "dynamic") + local shape = love.physics.newCircleShape(self.shape.rs) + self.fixture = love.physics.newFixture(self.body, shape) + self.fixture:setUserData(self.id) + self.fixture:setCategory(self.group.collision_tags[tag].category) + self.fixture:setMask(unpack(self.group.collision_tags[tag].masks)) + if #self.group.trigger_tags[tag].triggers > 0 then + self.sensor = love.physics.newFixture(self.body, shape) + self.sensor:setUserData(self.id) + self.sensor:setSensor(true) + end + return self +end + + +-- Sets this object as a physics triangle. +-- Its body_type can be either 'static', 'dynamic' or 'kinematic' (see box2d for more info) and its tag has to have been created in group:set_as_physics_world. +-- Its .shape variable is set to a Triangle instance and this instance is updated to be in sync with the physics body every frame. +function Physics:set_as_triangle(w, h, body_type, tag) + if not self.group then error("The GameObject must have a group defined for the Physics mixin to function") end + self.tag = tag + self.shape = Triangle(self.x, self.y, w, h) + self.body = love.physics.newBody(self.group.world, 0, 0, body_type or "dynamic") + self.body:setPosition(self.x, self.y) + local x1, y1 = h/2, 0 + local x2, y2 = -h/2, -w/2 + local x3, y3 = -h/2, w/2 + local shape = love.physics.newPolygonShape({x1, y1, x2, y2, x3, y3}) + self.fixture = love.physics.newFixture(self.body, shape) + self.fixture:setUserData(self.id) + self.fixture:setCategory(self.group.collision_tags[tag].category) + self.fixture:setMask(unpack(self.group.collision_tags[tag].masks)) + if #self.group.trigger_tags[tag].triggers > 0 then + self.sensor = love.physics.newFixture(self.body, shape) + self.sensor:setUserData(self.id) + self.sensor:setSensor(true) + end + return self +end + + +-- Automatically called by the group instance this game object belongs to whenever it dies. +function Physics:destroy() + if self.body then + if self.fixtures then for _, fixture in ipairs(self.fixtures) do fixture:destroy() end end + if self.sensors then for _, sensor in ipairs(self.sensors) do sensor:destroy() end end + if self.sensor and (self.sensor.type and self.sensor:type() == 'Fixture') then + self.sensor:destroy() + self.sensor = nil + end + self.fixture:destroy() + self.body:destroy() + self.fixture, self.body = nil, nil + if self.fixtures then self.fixtures = nil end + if self.sensors then self.sensors = nil end + end +end + + +function Physics:draw_physics(color, line_width) + if self.shape then self.shape:draw(color, line_width or 4) end +end + + +-- Returns the angle from a point to this object +-- r = self:angle_from_point(player.x, player.y) -> angle from the player to this object +function Physics:angle_from_point(x, y) + return math.atan2(self.y - y, self.x - x) +end + + +-- Returns the angle from this object to another object +-- r = self:angle_to_object(player) -> angle from this object to the player +function Physics:angle_to_object(object) + return self:angle_to_point(object.x, object.y) +end + + +-- Returns the angle from an object to this object +-- r = self:angle_from_object(player) -> angle from the player to this object +function Physics:angle_from_object(object) + return self:angle_from_point(object.x, object.y) +end + + +-- Returns the angle from this object to the mouse +-- r = self:angle_to_mouse() +function Physics:angle_to_mouse() + local mx, my = self.group.camera:get_mouse_position() + return math.atan2(my - self.y, mx - self.x) +end + + +-- Returns the distance from this object to a point +-- d = self:distance_to_point(player.x, player.y) +function Physics:distance_to_point(x, y) + return math.distance(self.x, self.y, x, y) +end + + +-- Returns the distance from an object to this object +-- d = self:distance_to_object(player) +function Physics:distance_to_object(object) + return math.distance(self.x, self.y, object.x, object.y) +end + + +-- Returns the distance from this object to the mouse +-- d = self:angle_to_mouse() +function Physics:distance_to_mouse() + local mx, my = self.group.camera:get_mouse_position() + return math.distance(self.x, self.y, mx, my) +end + + +-- Returns true if this GameObject is colliding with the given point. +-- colliding = self:is_colliding_with_point(x, y) +function Physics:is_colliding_with_point(x, y) + return self:is_colliding_with_point(x, y) +end + + +-- Returns true if this GameObject is colliding with the mouse. +-- colliding = self:is_colliding_with_mouse() +function Physics:is_colliding_with_mouse() + return self:is_colliding_with_point(self.group.camera:get_mouse_position()) +end + + +-- Returns true if this GameObject is colliding with another GameObject. +-- Both must be physics objects set with one of the set_as_shape functions. +-- colliding = self:is_colliding_with_object(other) +function Physics:is_colliding_with_object(object) + return self:is_colliding_with_shape(object.shape) +end + + +-- Returns true if this GameObject is colliding with the given shape. +-- colliding = self:is_colliding_with_shape(shape) +function Physics:is_colliding_with_shape(shape) + return self.shape:is_colliding_with_shape(shape) +end + + +-- Exactly the same as group:get_objects_in_shape, except additionally it automatically removes this object from the results. +-- self:get_objects_in_shape(Circle(self.x, self.y, 100), {Enemy1, Enemy2, Enemy3}) -> all objects of class Enemy1, Enemy2 and Enemy3 in a circle of radius 100 around this object +function Physics:get_objects_in_shape(shape, object_types) + return table.select(self.group:get_objects_in_shape(shape, object_types), function(v) return v.id ~= self.id end) +end + + +-- Returns the closest object to this object in the given shape, optionally excluding objects in the exclude list passed in. +-- self:get_closest_object_in_shape(Circle(self.x, self.y, 100), {Enemy1, Enemy2, Enemy3}) -> closest object of class Enemy1, Enemy2 or Enemy3 in a circle of radius 100 around this object +-- self:get_closest_object_in_shape(Circle(self.x, self.y, 100), {Enemy1, Enemy2, Enemy3}, {object_1, object_2}) -> same as above except excluding object instances object_1 and object_2 +function Physics:get_closest_object_in_shape(shape, object_types, exclude_list) + local objects = self:get_objects_in_shape(shape, object_types) + local min_d, min_i = 1000000, 0 + local exclude_list = exclude_list or {} + for i, object in ipairs(objects) do + if not table.any(exclude_list, function(v) return v.id == object.id end) then + local d = math.distance(self.x, self.y, object.x, object.y) + if d < min_d then + min_d = d + min_i = i + end + end + end + if i ~= 0 then return objects[min_i] end +end + + +-- Returns a random object in the given shape, excluding this object and also optionally excluding objects in the exclude list passed in. +-- self:get_random_object_in_shape(Circle(self.x, self.y, 100), {Enemy1, Enemy2, Enemy3}) -> random object of class Enemy1, Enemy2 or Enemy3 in a circle of radius 100 around this object +-- self:get_random_object_in_shape(Circle(self.x, self.y, 100), {Enemy1, Enemy2, Enemy3}, {object_1, object_2}) -> same as above except excluding object instances object_1 and object_2 +function Physics:get_random_object_in_shape(shape, object_types, exclude_list) + local objects = self:get_objects_in_shape(shape, object_types) + local exclude_list = exclude_list or {} + local random_object = random:table(objects) + local tries = 0 + if random_object then + while table.any(exclude_list, function(v) return v.id == random_object.id end) and tries < 20 do + random_object = random:table(objects) + tries = tries + 1 + end + end + return random_object +end + + +function Physics:update_physics(dt) + self:update_position() + self:steering_update(dt) +end + + +-- Updates the .x, .y attributes of this object, useful to call before drawing something if you need its position as recent as position +-- self:update_position() +function Physics:update_position() + if self.body then self.x, self.y = self.body:getPosition() end + return self +end + + +-- Sets the object's position directly, avoid using if you need velocity/acceleration calculations to make sense and be accurate, as teleporting the object around messes up its physics +-- self:set_position(100, 100) +function Physics:set_position(x, y) + if self.body then self.body:setPosition(x, y) end + return self:update_position() +end + + +-- Returns the object's position as two values +-- x, y = self:get_position() +function Physics:get_position() + self:update_position() + if self.body then return self.body:getPosition() end +end + + +-- Sets the object as a bullet +-- Bullets will collide and generate proper collision responses regardless of their velocity, despite being more expensive to calculate +-- self:set_bullet(true) +function Physics:set_bullet(v) + if self.body then self.body:setBullet(v) end + return self +end + + +-- Sets the object to have fixed rotation +-- When box2d objects don't have fixed rotation, whenever they collide with other objects they will rotate around depending on where the collision happened +-- Setting this to true prevents that from happening, useful for every type of game where you don't need accurate physics responses in terms of the characters rotation +-- self:set_fixed_rotation(true) +function Physics:set_fixed_rotation(v) + self.fixed_rotation = v + if self.body then self.body:setFixedRotation(v) end + return self +end + + +-- Sets the object's velocity +-- self:set_velocity(100, 100) +function Physics:set_velocity(vx, vy) + if self.body then self.body:setLinearVelocity(vx, vy) end + return self +end + + +-- Returns the object's velocity as two values +-- vx, vy = self:get_velocity() +function Physics:get_velocity() + if self.body then return self.body:getLinearVelocity() end +end + + +-- Sets the object's damping +-- The higher this value, the more the object will resist movement and the faster it will stop moving after forces are applied to it +-- self:set_damping(10) +function Physics:set_damping(v) + if self.body then self.body:setLinearDamping(v) end + return self +end + + +-- Sets the object's angular velocity +-- If set_fixed_rotation is set to true then this will do nothing +-- self:set_angular_velocity(math.pi/4) +function Physics:set_angular_velocity(v) + if self.body then self.body:setAngularVelocity(v) end + return self +end + + +-- Sets the object's angular damping +-- The higher this value, the more the object will resist rotation and the faster it will stop rotating after angular forces are applied to it +-- self:set_angular_damping(10) +function Physics:set_angular_damping(v) + if self.body then self.body:setAngularDamping(v) end + return self +end + + +-- Returns the object's angle +-- r = self:get_angle() +function Physics:get_angle() + if self.body then return self.body:getAngle() end +end + + +-- Sets the object's angle +-- If set_fixed_rotation is set to true then this will do nothing +-- self:set_angle(math.pi/8) +function Physics:set_angle(v) + if self.body then self.body:setAngle(v) end + return self +end + + +-- Sets the object's restitution +-- This is a value from 0 to 1 and the higher it is the more energy the object will conserve when bouncing off other objects +-- At 1, it will bounce perfectly and not lose any velocity +-- At 0, it will not bounce at all +-- self:set_restitution(0.75) +function Physics:set_restitution(v) + if self.fixture then + self.fixture:setRestitution(v) + elseif self.fixtures then + for _, fixture in ipairs(self.fixtures) do + fixture:setRestitution(v) + end + end + return self +end + + +-- Sets the object's friction +-- This is a value from 0 to infinity, but generally between 0 and 1, the higher it is the more friction there will be when this object slides with another +-- At 0 friction is turned off and the object will slide with no resistance +-- The friction calculation takes into account the friction of both objects sliding on one another, so if one object has friction set to 0 then it will treat the interaction as if there's no friction +-- self:set_friction(1) +function Physics:set_friction(v) + if self.fixture then + self.fixture:setFriction(v) + elseif self.fixtures then + for _, fixture in ipairs(self.fixtures) do + fixture:setFriction(v) + end + end + return self +end + + +-- Applies an instantaneous amount of force to the object +-- self:apply_impulse(100*math.cos(angle), 100*math.sin(angle)) +function Physics:apply_impulse(fx, fy) + if self.body then self.body:applyLinearImpulse(fx, fy) end + return self +end + + +-- Applies an instantaneous amount of angular force to the object +-- self:apply_angular_impulse(8*math.pi) +function Physics:apply_angular_impulse(f) + if self.body then self.body:applyAngularImpulse(f) end + return self +end + + +-- Applies a continuous amount of force to the object +-- self:apply_force(100*math.cos(angle), 100*math.sin(angle)) +function Physics:apply_force(fx, fy, x, y) + if self.body then self.body:applyForce(fx, fy, x, y) end + return self +end + + +-- Applies torque to the object +-- self:apply_torque(math.pi) +function Physics:apply_torque(t) + if self.body then self.body:applyTorque(t) end + return self +end + + +-- Sets the object's mass +-- self:set_mass(1000) +function Physics:set_mass(mass) + if self.body then self.body:setMass(mass) end + return self +end + + +-- Sets the object's gravity scale +-- This is a simple multiplier on the world's gravity, but applied only to this object +function Physics:set_gravity_scale(v) + if self.body then self.body:setGravityScale(v) end + return self +end + + +-- Locks the object horizontally, meaning it can never move up or down. +-- self:lock_horizontally() +function Physics:lock_horizontally() + local vx, vy = self:get_velocity() + self:set_velocity(vx, 0) +end + + +-- Locks the object vertically, meaning it can never move left or right. +-- self:lock_vertically() +function Physics:lock_vertically() + local vx, vy = self:get_velocity() + self:set_velocity(0, vy) +end + + +-- Moves this object towards another object +-- You can either do this by using the speed argument directly, or by using the max_time argument +-- max_time will override speed since it will make it so that the object reaches the target in a given time +-- self:move_towards_object(player, 40) -> moves towards the player with 40 speed +-- self:move_towards_object(player, nil, 2) -> moves towards the player with speed such that it would reach him in 2 seconds if he never moved +function Physics:move_towards_object(object, speed, max_time) + if max_time then speed = self:distance_to_point(object.x, object.y)/max_time end + local r = self:angle_to_point(object.x, object.y) + self:set_velocity(speed*math.cos(r), speed*math.sin(r)) + return self +end + + +-- Same as move_towards_object except towards a point +-- self:move_towards_point(player.x, player.y, 40) +function Physics:move_towards_point(x, y, speed, max_time) + if max_time then speed = self:distance_to_point(x, y)/max_time end + local r = self:angle_to_point(x, y) + self:set_velocity(speed*math.cos(r), speed*math.sin(r)) + return self +end + + +-- Same as move_towards_object and move_towards_point except towards the mouse +-- self:move_towards_mouse(nil, 1) +function Physics:move_towards_mouse(speed, max_time) + if max_time then speed = self:distance_to_mouse()/max_time end + local r = self:angle_to_mouse() + self:set_velocity(speed*math.cos(r), speed*math.sin(r)) + return self +end + + +-- Same as move_towards_mouse but does so only on the x axis +-- self:move_towards_mouse_horizontally(nil, 1) +function Physics:move_towards_mouse_horizontally(speed, max_time) + if max_time then speed = self:distance_to_mouse()/max_time end + local r = self:angle_to_mouse() + local vx, vy = self:get_velocity() + self:set_velocity(speed*math.cos(r), vy) + return self +end + + +-- Same as move_towards_mouse but does so only on the y axis +-- self:move_towards_mouse_vertically(nil, 1) +function Physics:move_towards_mouse_vertically(speed, max_time) + if max_time then speed = self:distance_to_mouse()/max_time end + local r = self:angle_to_mouse() + local vx, vy = self:get_velocity() + self:set_velocity(vx, speed*math.sin(r)) + return self +end + + +-- Moves the object along an angle, most useful for simple projectiles that don't need any complex movements +-- self:move_along_angle(100, math.pi/4) +function Physics:move_along_angle(speed, r) + self:set_velocity(speed*math.cos(r), speed*math.sin(r)) + return self +end + + +-- Rotates the object towards another object using a rotational lerp, which is a value from 0 to 1 +-- Higher values will rotate the object faster, lower values will make the turn have a smooth delay to it +-- self:rotate_towards_object(player, 0.2) +function Physics:rotate_towards_object(object, lerp_value) + self:set_angle(math.lerp_angle(lerp_value, self:get_angle(), self:angle_to_point(object.x, object.y))) + return self +end + + +-- Same as rotate_towards_object except towards a point +-- self:rotate_towards_point(player.x, player.y, 0.2) +function Physics:rotate_towards_point(x, y, lerp_value) + self:set_angle(math.lerp_angle(lerp_value, self:get_angle(), self:angle_to_point(x, y))) + return self +end + + +-- Same as rotate_towards_object and rotate_towards_point except towards the mouse +-- self:rotate_towards_mouse(0.2) +function Physics:rotate_towards_mouse(lerp_value) + self:set_angle(math.lerp_angle(lerp_value, self:get_angle(), self:angle_to_mouse())) + return self +end + + +-- Rotates the object towards its own velocity vector using a rotational lerp, which is a value from 0 to 1 +-- Higher values will rotate the object faster, lower values will make the turn have a smooth delay to it +-- self:rotate_towards_velocity(0.2) +function Physics:rotate_towards_velocity(lerp_value) + local vx, vy = self:get_velocity() + self:set_angle(math.lerp_angle(lerp_value, self:get_angle(), self:angle_to_point(self.x + vx, self.y + vy))) + return self +end + + +-- Same as accelerate_towards_object except towards a point +-- self:accelerate_towards_object(player.x, player.y, 100, 10, 2) +function Physics:accelerate_towards_point(x, y, max_speed, deceleration, turn_coefficient) + local tx, ty = x - self.x, y - self.y + local d = math.length(tx, ty) + if d > 0 then + local speed = d/((deceleration or 1)*0.08) + speed = math.min(speed, max_speed) + local current_vx, current_vy = speed*tx/d, speed*ty/d + local vx, vy = self:get_velocity() + self:apply_force((current_vx - vx)*(turn_coefficient or 1), (current_vy - vy)*(turn_coefficient or 1)) + end + return self +end + + +-- Accelerates the object towards another object +-- Other than the object, the 3 arguments available are: +-- max_speed - the maximum speed the object can have in this acceleration +-- deceleration - how fast the object will decelerate once it gets closer to the target, higher values will make the deceleration more abrupt, do not make this value 0 +-- turn_coefficient - how strong is the turning force for this object, higher values will make it turn faster +-- self:accelerate_towards_object(player, 100, 10, 2) +function Physics:accelerate_towards_object(object, max_speed, deceleration, turn_coefficient) + return self:accelerate_towards_point(object.x, object.y, max_speed, deceleration, turn_coefficient) +end + + +-- Same as accelerate_towards_object and accelerate_towards_point but towards the mouse +-- self:accelerate_towards_mouse(100, 10, 2) +function Physics:accelerate_towards_mouse(max_speed, deceleration, turn_coefficient) + local mx, my = self.group.camera:get_mouse_position() + return self:accelerate_towards_point(mx, my, max_speed, deceleration, turn_coefficient) +end + + +-- Keeps this object separated from other objects of specific classes according to the radius passed in +-- What this function does is simply look at all nearby objects and apply forces to this object such that it remains separated from them +-- self:separate(40, {Enemy}) -> when this is called every frame, this applies forces to this object to keep it separated from other Enemy instances by 40 units at all times +function Physics:separate(rs, class_avoid_list) + local fx, fy = 0, 0 + local objects = table.flatten(table.foreachn(class_avoid_list, function(v) return self.group:get_objects_by_class(v) end), true) + for _, object in ipairs(objects) do + if object.id ~= self.id and math.distance(object.x, object.y, self.x, self.y) < 2*rs then + local tx, ty = self.x - object.x, self.y - object.y + local n = Vector(tx, ty):normalize() + local l = n:length() + fx = fx + rs*(n.x/l) + fy = fy + rs*(n.y/l) + end + end + self:apply_force(fx, fy) + return self +end + + +-- Returns the angle from this object to a point +-- r = self:angle_to_point(player.x, player.y) -> angle from this object to the player +function Physics:angle_to_point(x, y) + return math.atan2(y - self.y, x - self.x) +end + + +-- Sets the object as a steerable object. +-- The implementation of steering behaviors here mostly follows the one from chapter 3 of the book "Programming Game AI by Example" +-- https://github.com/wangchen/Programming-Game-AI-by-Example-src diff --git a/engine/game/springs.lua b/engine/game/springs.lua new file mode 100644 index 0000000..3ed5c55 --- /dev/null +++ b/engine/game/springs.lua @@ -0,0 +1,32 @@ +-- The base Springs class. +-- This class is used to manage all springs in an object. +-- Add a new spring: +-- self.springs:add('hit', 1) +-- Use it: +-- self.springs.hit:pull(0.2) +-- self.springs.hit.x +-- Every GameObject has a .springs attribute with a Springs instance attached to it. +-- See engine/game/hit +Springs = Object:extend() +function Springs:init() + self.names = {} +end + + +function Springs:update(dt) + for _, name in ipairs(self.names) do + self[name]:update(dt) + end +end + + +-- Adds a new spring to the object. The name must be unique and the next arguments are the same +-- as the arguments for creating a spring, see engine/math/spring.lua. +-- self.springs:add('hit', 1) +function Springs:add(name, x, k, d) + if name == 'parent' or name == 'names' or name == 'trigger' or name == 'add' or name == 'use' or name == 'update' or name == 'init' or name == 'pull' or name == 'flash' then + error("Invalid name to be added to the Springs object. 'add', 'flash', 'init', 'names', 'parent', 'pull', 'trigger', 'update' and 'use' are reserved names, choose another.") + end + self[name] = Spring(x, k, d) + table.insert(self.names, name) +end diff --git a/engine/game/state.lua b/engine/game/state.lua new file mode 100644 index 0000000..2ba45f6 --- /dev/null +++ b/engine/game/state.lua @@ -0,0 +1,114 @@ +-- The base State class. +-- The general way of creating an object that implements these functions goes like this: +--[[ +MyState = Object:extend() +MyState:implement(State) +function MyState:init(name) + self:init_state(name) +end + +function MyState:on_enter(from) + +end + +function MyState:update(dt) + +end + + +function MyState:draw() + +end +]]-- + +-- This creates a new MyState class which you can then use to start writing your code. +-- Use the init function for things you need to do when the state object is created. +-- Use the on_enter function for things you need to do whenever the state gets activated. +-- By default, whenever a state gets deactivated it's not deleted from memory, so if you want to restart a level, for instance, whenever you switch states, +-- then you need to destroy everything that needs to be destroyed in an on_exit function and then recreate it again in the on_enter function. +-- +-- You'd add a state to the game like this: +-- state.add(MyState'level_1') +-- You'd move to that state like so: +-- state.go_to'level_1' +-- state.go_to automatically calls on_exit for the currently active state and on_enter for the new one. +-- You can access the currently active state with state.current. +State = Object:extend() +function State:init_state(name) + self.name = name or random:uid() + self.active = false +end + + +function State:enter(from) + self.active = true + if self.on_enter then self:on_enter(from) end +end + + +function State:exit(to) + self.active = false + if self.on_exit then self:on_exit(to) end +end + + + +-- The main state. This is a global state that is always active and contains all other states. +Main = Object:extend() +Main:implement(State) +function Main:init(name) + self:init_state(name) + self.states = {} + self.transitions = Group():no_camera() +end + + +function Main:update(dt) + for _, state in pairs(self.states) do + if state.active or state.persistent_update then + state:update(dt) + end + end + self.transitions:update(dt) +end + + +function Main:draw() + for _, state in pairs(self.states) do + if state.active or state.persistent_draw then + state:draw() + end + end + self.transitions:draw() +end + + +function Main:add(state) + self.states[state.name] = state +end + + +function Main:get(state_name) + return self.states[state_name] +end + + +-- Deactivates the current active state and activates the target one. +-- Calls on_exit for the deactivated state and on_enter for the activated one. +-- If on_exit returns true then the deactivated state will be removed from memory. +-- You must handle the destruction of it yourself in its on_exit function. +function Main:go_to(state, ...) + if type(state) == 'string' then state = self:get(state) end + + if self.current then + if self.current.active then + if self.current:exit(state) then + self.states[state.name] = nil + end + end + end + + local last_state = self.current + self.current = state + state:enter(last_state, ...) +end diff --git a/engine/game/steering.lua b/engine/game/steering.lua new file mode 100644 index 0000000..9ad2d1a --- /dev/null +++ b/engine/game/steering.lua @@ -0,0 +1,260 @@ +-- Sets the object as a steerable object. +-- This is implemented in the Physics mixin because it plays well with the rest of it, thus, to make a game object steerable it needs to implement the Physics mixin. +-- The implementation of steering behaviors here mostly follows the one from chapter 3 of the book "Programming Game AI by Example" +-- https://github.com/wangchen/Programming-Game-AI-by-Example-src +-- self:set_as_steerable(100, 1000) +function Physics:set_as_steerable(max_v, max_f, max_turn_rate, turn_multiplier) + self.steerable = true + self.heading = Vector() + self.side = Vector() + self.mass = 1 + self.max_v = max_v or 100 + self.max_f = max_f or 2000 + self.max_turn_rate = max_turn_rate or 2*math.pi + self.turn_multiplier = turn_multiplier or 2 + self.seek_f = Vector() + self.flee_f = Vector() + self.pursuit_f = Vector() + self.evade_f = Vector() + self.wander_f = Vector() + local r = random:float(0, 2*math.pi) + self.wander_target = Vector(40*math.cos(r), 40*math.sin(r)) + self.path_follow_f = Vector() + self.separation_f = Vector() + self.alignment_f = Vector() + self.cohesion_f = Vector() + self.apply_force_f = Vector() + self.apply_impulse_f = Vector() +end + + +function Physics:steering_update(dt) + if self.steerable then + local steering_force = self:calculate_steering_force(dt):div(self.mass) + self:apply_force(steering_force.x, steering_force.y) + local vx, vy = self:get_velocity() + local v = Vector(vx, vy):truncate(self.max_v) + self:set_velocity(v.x, v.y) + if v:length_squared() > 0.00001 then + self.heading = self.v:clone():normalize() + self.side = self.heading:perpendicular() + end + end +end + + +function Physics:calculate_steering_force(dt) + local steering_force = Vector(0, 0) + if self.seeking then steering_force:add(self.seek_f) end + if self.fleeing then steering_force:add(self.flee_f) end + if self.pursuing then steering_force:add(self.pursuit_f) end + if self.evading then steering_force:add(self.evade_f) end + if self.wandering then steering_force:add(self.wander_f) end + if self.path_following then steering_force:add(self.path_follow_f) end + if self.separating then steering_force:add(self.separation_f) end + if self.aligning then steering_force:add(self.alignment_f) end + if self.cohesing then steering_force:add(self.cohesion_f) end + self.seeking = false + self.fleeing = false + self.pursuing = false + self.evading = false + self.wandering = false + self.path_following = false + self.separating = false + self.aligning = false + self.cohesing = false + return steering_force:truncate(self.max_f) +end + + +-- Arrive steering behavior +-- Makes this object accelerate towards a destination, slowing down the closer it gets to it +-- deceleration - how fast the object will decelerate once it gets closer to the target, higher values will make the deceleration more abrupt, do not make this value 0 +-- weight - how much the force of this behavior affects this object compared to others +-- self:seek_point(player.x, player.y) +function Physics:seek_point(x, y, deceleration, weight) + self.seeking = true + local tx, ty = x - self.x, y - self.y + local d = math.length(tx, ty) + if d > 0 then + local v = d/((deceleration or 1)*0.08) + v = math.min(v, self.max_v) + local dvx, dvy = v*tx/d, v*ty/d + self.seek_f:set((dvx - self.v.x)*self.turn_multiplier*(weight or 1), (dvy - self.v.y)*self.turn_multiplier*(weight or 1)) + else self.seek_f:set(0, 0) end +end + + +-- Same as self:seek_point but for objects instead. +-- self:seek_object(player) +function Physics:seek_object(object, deceleration, weight) + return self:seek_point(object.x, object.y, deceleration, weight) +end + + +-- Same as self:seek_point and self:seek_object but for the mouse instead. +-- self:seek_mouse() +function Physics:seek_mouse(deceleration, weight) + local mx, my = self.group.camera:get_mouse_position() + return self:seek_point(mx, my, deceleration, weight) +end + + +-- Separation steering behavior +-- Keeps this object separated from other objects of specific classes according to the radius passed in +-- What this function does is simply look at all nearby objects and apply forces to this object such that it remains separated from them +-- self:separate(40, {Enemy}) -> when this is called every frame, this applies forces to this object to keep it separated from other Enemy instances by 40 units at all times +function Physics:steering_separate(rs, class_avoid_list, weight) + self.separating = true + local fx, fy = 0, 0 + local objects = table.flatten(table.foreachn(class_avoid_list, function(v) return self.group:get_objects_by_class(v) end), true) + for _, object in ipairs(objects) do + if object.id ~= self.id and math.distance(object.x, object.y, self.x, self.y) < 2*rs then + local tx, ty = self.x - object.x, self.y - object.y + local nx, ny = math.normalize(tx, ty) + local l = math.length(nx, ny) + fx = fx + rs*(nx/l) + fy = fy + rs*(ny/l) + end + end + self.separation_f:set(fx*(weight or 1), fy*(weight or 1)) +end + + +-- Wander steering behavior +-- Makes the object move in a jittery manner, adding some randomness to its movement while keeping the overall direction +-- What this function does is project a circle in front of the entity and then choose a point randomly inside that circle for the entity to move towards and it does that every frame +-- rs - the radius of the circle +-- distance - the distance of the circle from this object, the further away the smoother the changes to movement will be +-- jitter - the amount of jitter to the movement, the higher it is the more abrupt the changes will be +-- self:wander(50, 100, 20) +function Physics:wander(rs, distance, jitter, weight) + self.wandering = true + self.wander_target:add(random:float(-1, 1)*(jitter or 20), random:float(-1, 1)*(jitter or 20)) + self.wander_target:normalize() + self.wander_target:mul(rs or 40) + local target_local = self.wander_target:clone():add(distance or 40, 0) + local target_world = steering.point_to_world_space(target_local, self.heading, self.side, Vector(self.x, self.y)) + self.wander_f:set((target_world.x - self.x)*(weight or 1), (target_world.y - self.y)*(weight or 1)) +end + + + + +-- Steering behavior specific auxiliary functions, shouldn't really be used elsewhere +C2DMatrix = Object:extend() +function C2DMatrix:init() + self._11, self._12, self._13 = 0, 0, 0 + self._21, self._22, self._23 = 0, 0, 0 + self._31, self._32, self._33 = 0, 0, 0 + self:identity() +end + + +function C2DMatrix:multiply(other) + local mat_temp = C2DMatrix() + mat_temp._11 = (self._11 * other._11) + (self._12 * other._21) + (self._13 * other._31); + mat_temp._12 = (self._11 * other._12) + (self._12 * other._22) + (self._13 * other._32); + mat_temp._13 = (self._11 * other._13) + (self._12 * other._23) + (self._13 * other._33); + mat_temp._21 = (self._21 * other._11) + (self._22 * other._21) + (self._23 * other._31); + mat_temp._22 = (self._21 * other._12) + (self._22 * other._22) + (self._23 * other._32); + mat_temp._23 = (self._21 * other._13) + (self._22 * other._23) + (self._23 * other._33); + mat_temp._31 = (self._31 * other._11) + (self._32 * other._21) + (self._33 * other._31); + mat_temp._32 = (self._31 * other._12) + (self._32 * other._22) + (self._33 * other._32); + mat_temp._33 = (self._31 * other._13) + (self._32 * other._23) + (self._33 * other._33); + self._11 = mat_temp._11; self._12 = mat_temp._12; self._13 = mat_temp._13 + self._21 = mat_temp._21; self._22 = mat_temp._22; self._23 = mat_temp._23 + self._31 = mat_temp._31; self._32 = mat_temp._32; self._33 = mat_temp._33 +end + + +function C2DMatrix:identity() + self._11, self._12, self._13 = 1, 0, 0 + self._21, self._22, self._23 = 0, 1, 0 + self._31, self._32, self._33 = 0, 0, 1 +end + + +function C2DMatrix:transform_vector(point) + local temp_x = (self._11 * point.x) + (self._21 * point.y) + (self._31) + local temp_y = (self._12 * point.x) + (self._22 * point.y) + (self._32) + point.x, point.y = temp_x, temp_y +end + + +function C2DMatrix:translate(x, y) + local mat = C2DMatrix() + mat._11 = 1; mat._12 = 0; mat._13 = 0; + mat._21 = 0; mat._22 = 1; mat._23 = 0; + mat._31 = x; mat._32 = y; mat._33 = 1; + self:multiply(mat) +end + + +function C2DMatrix:scale(sx, sy) + local mat = C2DMatrix() + mat._11 = sx; mat._12 = 0; mat._13 = 0; + mat._21 = 0; mat._22 = sy; mat._23 = 0; + mat._31 = 0; mat._32 = 0; mat._33 = 1; + self:multiply(mat) +end + + +function C2DMatrix:rotate(fwd, side) + local mat = C2DMatrix() + mat._11 = fwd.x; mat._12 = fwd.y; mat._13 = 0; + mat._21 = side.x; mat._22 = side.y; mat._23 = 0; + mat._31 = 0; mat._32 = 0; mat._33 = 1; + self:multiply(mat) +end + + +function C2DMatrix:rotater(r) + local mat = C2DMatrix() + local sin = math.sin(r) + local cos = math.cos(r) + mat._11 = cos; mat._12 = sin; mat._13 = 0; + mat._21 = -sin; mat._22 = cos; mat._23 = 0; + mat._31 = 0; mat._32 = 0; mat._33 = 1; + self:multiply(mat) +end + + +steering = {} +function steering.point_to_world_space(point, heading, side, position) + local trans_point = Vector(point.x, point.y) + local mat_transform = C2DMatrix() + mat_transform:rotate(heading, side) + mat_transform:translate(position.x, position.y) + mat_transform:transform_vector(trans_point) + return trans_point +end + + +function steering.point_to_local_space(point, heading, side, position) + local trans_point = Vector(point.x, point.y) + local mat_transform = C2DMatrix() + local tx, ty = -position:dot(heading), -position:dot(side) + mat_transform._11 = heading.x; mat_transform._12 = side.x; + mat_transform._21 = heading.y; mat_transform._22 = side.y; + mat_transform._31 = tx; mat_transform._32 = ty; + mat_transform:transform_vector(trans_point) + return trans_point +end + + +function steering.vector_to_world_space(v, heading, side) + local trans_v = Vector(v.x, v.y) + local mat_transform = C2DMatrix() + mat_transform:rotate(heading, side) + mat_transform:transform_vector(trans_v) + return trans_v +end + + +function steering.rotate_vector_around_origin(v, r) + local mat = C2DMatrix() + mat:rotater(r) + mat:transform_vector(v) + return v +end diff --git a/engine/game/trigger.lua b/engine/game/trigger.lua new file mode 100644 index 0000000..9c55cfe --- /dev/null +++ b/engine/game/trigger.lua @@ -0,0 +1,231 @@ +-- The base Trigger class. +-- A global instance of this called "trigger" is available by default. +Trigger = Object:extend() +function Trigger:init() + self.triggers = {} +end + + +-- Calls the action every frame until it's cancelled via trigger:cancel. +-- The tag must be passed in otherwise there will be no way to stop this from running. +-- If after is passed in then it is called after the run is cancelled. +function Trigger:run(action, after, tag) + local tag = tag or random:uid() + local after = after or function() end + self.triggers[tag] = {type = "run", timer = 0, after = after, action = action} +end + + +-- Calls the action after delay seconds. +-- Or calls the action after the condition is true. +-- If tag is passed in then any other trigger actions with the same tag are automatically cancelled. +-- trigger:after(2, function() print(1) end) -> prints 1 after 2 seconds +-- trigger:after(function() return self.should_print_1 end, function() print(1) end) -> prints 1 after self.should_print_1 is set to true +function Trigger:after(delay, action, tag) + local tag = tag or random:uid() + if type(delay) == "number" or type(delay) == "table" then + self.triggers[tag] = {type = "after", timer = 0, unresolved_delay = delay, delay = self:resolve_delay(delay), action = action} + else + self.triggers[tag] = {type = "conditional_after", condition = delay, action = action} + end +end + + +-- Calls the action every delay seconds. +-- Or calls the action once every time the condition becomes true. +-- If times is passed in then it only calls action for that amount of times. +-- If after is passed in then it is called after the last time action is called. +-- If tag is passed in then any other trigger actions with the same tag are automatically cancelled. +-- trigger:every(2, function() print(1) end) -> prints 1 every 2 seconds +-- trigger:every(2, function() print(1) end, 5, function() print(2) end) -> prints 1 every 2 seconds 5 times, and then prints 2 +-- trigger:every(function() return player.hit end, function() print(1) end) -> prints 1 every time the player is hit +-- trigger:every(function() return player.grounded end, function() print(1), 5, function() print(2) end) -> prints 1 every time the player becomes grounded 5 times, and then prints 2 +-- Note that if using this as a condition, the action will only be triggered when the condition jumps from being false to true. +-- If the condition remains true for multiple frames then the action won't be triggered further, unless it becomes false and then becomes true again. +function Trigger:every(delay, action, times, after, tag) + local times = times or 0 + local after = after or function() end + local tag = tag or random:uid() + if type(delay) == "number" or type(delay) == "table" then + self.triggers[tag] = {type = "every", timer = 0, unresolved_delay = delay, delay = self:resolve_delay(delay), action = action, times = times, max_times = times, after = after, multiplier = 1} + else + self.triggers[tag] = {type = "conditional_every", condition = delay, last_condition = false, action = action, times = times, max_times = times, after = after} + end +end + + +-- Same as every except the action is called immediately when this function is called, and then every delay seconds. +function Trigger:every_immediate(delay, action, times, after, tag) + local times = times or 0 + local after = after or function() end + local tag = tag or random:uid() + self.triggers[tag] = {type = "every", timer = 0, unresolved_delay = delay, delay = self:resolve_delay(delay), action = action, times = times, max_times = times, after = after, multiplier = 1} + action() +end + + +-- Calls the action every frame for delay seconds. +-- Or calls the action every frame the condition is true. +-- If after is passed in then it is called after the duration ends or after the condition becomes false. +-- If tag is passed in then any other trigger actions with the same tag are automatically cancelled. +-- trigger:during(5, function() print(random:float(0, 100)) end) +-- trigger:during(function() return self.should_print_random_float end, function() print(random:float(0, 100)) end) -> prints the random float as long as self.should_print_random_float is true +function Trigger:during(delay, action, after, tag) + local after = after or function() end + local tag = tag or random:uid() + if type(delay) == "number" or type(delay) == "table" then + self.triggers[tag] = {type = "during", timer = 0, unresolved_delay = delay, delay = self:resolve_delay(delay), action = action, after = after} + elseif type(delay) == "function" then + self.triggers[tag] = {type = "conditional_during", condition = delay, last_condition = false, action = action, after = after} + end +end + + +-- Tweens the target's values specified by the source table for delay seconds using the given tweening method. +-- All tween methods can be found in the math/math file. +-- If after is passed in then it is called after the duration ends. +-- If tag is passed in then any other trigger actions with the same tag are automatically cancelled. +-- trigger:tween(0.2, self, {sx = 0, sy = 0}, math.linear) -> tweens this object's scale variables to 0 linearly over 0.2 seconds +-- trigger:tween(0.2, self, {sx = 0, sy = 0}, math.linear, function() self.dead = true end) -> tweens this object's scale variables to 0 linearly over 0.2 seconds and then kills it +function Trigger:tween(delay, target, source, method, after, tag) + local method = method or math.linear + local after = after or function() end + local tag = tag or random:uid() + local initial_values = {} + for k, _ in pairs(source) do initial_values[k] = target[k] end + self.triggers[tag] = {type = "tween", timer = 0, unresolved_delay = delay, delay = self:resolve_delay(delay), target = target, initial_values = initial_values, source = source, method = method, after = after} +end + + +-- Cancels a trigger action based on its tag. +-- This is automatically called if repeated tags are given to trigger actions. +function Trigger:cancel(tag) + if self.triggers[tag] and self.triggers[tag].type == "run" then + self.triggers[tag].after() + end + self.triggers[tag] = nil +end + + +-- Resets the timer for a tag. +-- Useful when you need to start counting that tag from 0 after an event happens. +function Trigger:reset(tag) + self.triggers[tag].timer = 0 +end + + +-- Returns the delay of a given tag. +-- This is useful when delays are set randomly (trigger:every({2, 4}, ...) would set the delay at a random number between 2 and 4) and you need to know what the value chosen was. +function Trigger:get_delay(tag) + return self.triggers[tag].delay +end + + +-- Returns the current iteration of an every trigger action with the given tag. +-- Useful if you need to know that its the nth time an every action has been called. +function Trigger:get_every_iteration(tag) + return self.triggers[tag].max_times - self.triggers[tag].times +end + + +-- Sets a multiplier for an every tag. +-- This is useful when you need the event to happen in a varying interval, like based on the player's attack speed, which might change every frame based on buffs. +-- Call this on the update function with the appropriate multiplier. +function Trigger:set_every_multiplier(tag, multiplier) + self.triggers[tag].multiplier = multiplier or 1 +end + + +-- Returns the elapsed time of a given trigger as a number between 0 and 1. +-- Useful if you need to know where you currently are in the duration of a during call. +function Trigger:get_during_elapsed_time(tag) + return self.triggers[tag].trigger/self.triggers[tag].delay +end + + +function Trigger:resolve_delay(delay) + if type(delay) == "table" then + return random:float(delay[1], delay[2]) + else + return delay + end +end + + +function Trigger:update(dt) + for tag, trigger in pairs(self.triggers) do + if trigger.timer then + trigger.timer = trigger.timer + dt + end + + if trigger.type == "run" then + trigger.action() + + elseif trigger.type == "after" then + if trigger.timer > trigger.delay then + trigger.action() + self.triggers[tag] = nil + end + + elseif trigger.type == "conditional_after" then + if trigger.condition() then + trigger.action() + self.triggers[tag] = nil + end + + elseif trigger.type == "every" then + if trigger.timer > trigger.delay*trigger.multiplier then + trigger.action() + trigger.timer = trigger.timer - trigger.delay*trigger.multiplier + trigger.delay = self:resolve_delay(trigger.unresolved_delay) + if trigger.times > 0 then + trigger.times = trigger.times - 1 + if trigger.times <= 0 then + trigger.after() + self.triggers[tag] = nil + end + end + end + + elseif trigger.type == "conditional_every" then + local condition = trigger.condition() + if condition and not trigger.last_condition then + trigger.action() + if trigger.times > 0 then + trigger.times = trigger.times - 1 + if trigger.times <= 0 then + trigger.after() + self.triggers[tag] = nil + end + end + end + trigger.last_condition = condition + + elseif trigger.type == "during" then + trigger.action() + if trigger.timer > trigger.delay then + self.triggers[tag] = nil + end + + elseif trigger.type == "conditional_during" then + local condition = trigger.condition() + if condition then + trigger.action() + end + if trigger.last_condition and not condition then + trigger.after() + end + trigger.last_condition = condition + + elseif trigger.type == "tween" then + local t = trigger.method(trigger.timer/trigger.delay) + for k, v in pairs(trigger.source) do + trigger.target[k] = math.lerp(t, trigger.initial_values[k], v) + end + if trigger.timer > trigger.delay then + trigger.after() + self.triggers[tag] = nil + end + end + end +end diff --git a/engine/gamecontrollerdb.txt b/engine/gamecontrollerdb.txt new file mode 100644 index 0000000..9430d29 --- /dev/null +++ b/engine/gamecontrollerdb.txt @@ -0,0 +1,751 @@ +# Game Controller DB for SDL in 2.0.10 format +# Source: https://github.com/gabomdq/SDL_GameControllerDB + +# Windows +03000000fa2d00000100000000000000,3DRUDDER,leftx:a0,lefty:a1,rightx:a5,righty:a2,platform:Windows, +03000000c82d00002038000000000000,8bitdo,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b4,y:b3,platform:Windows, +03000000c82d000011ab000000000000,8BitDo F30,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a5,start:b11,x:b4,y:b3,platform:Windows, +03000000c82d00001038000000000000,8BitDo F30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a5,start:b11,x:b4,y:b3,platform:Windows, +03000000c82d00000090000000000000,8BitDo FC30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b4,y:b3,platform:Windows, +03000000c82d00000650000000000000,8BitDo M30,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:a4,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b6,righttrigger:b7,start:b11,x:b3,y:b4,platform:Windows, +03000000c82d00000310000000000000,8BitDo N30,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b11,x:b3,y:b4,platform:Windows, +03000000c82d00002028000000000000,8BitDo N30,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a5,start:b11,x:b4,y:b3,platform:Windows, +03000000c82d00008010000000000000,8BitDo N30,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b11,x:b3,y:b4,platform:Windows, +03000000c82d00000190000000000000,8BitDo N30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a5,start:b11,x:b4,y:b3,platform:Windows, +03000000c82d00001590000000000000,8BitDo N30 Pro 2,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a5,start:b11,x:b4,y:b3,platform:Windows, +03000000c82d00006528000000000000,8BitDo N30 Pro 2,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a5,start:b11,x:b4,y:b3,platform:Windows, +03000000c82d00015900000000000000,8BitDo N30 Pro 2,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a5,start:b11,x:b4,y:b3,platform:Windows, +03000000c82d00065280000000000000,8BitDo N30 Pro 2,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a5,start:b11,x:b4,y:b3,platform:Windows, +03000000022000000090000000000000,8Bitdo NES30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b4,y:b3,platform:Windows, +03000000203800000900000000000000,8Bitdo NES30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b4,y:b3,platform:Windows, +03000000c82d00000130000000000000,8BitDo SF30,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a5,start:b11,x:b4,y:b3,platform:Windows, +03000000c82d00000060000000000000,8Bitdo SF30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b4,y:b3,platform:Windows, +03000000c82d00000061000000000000,8Bitdo SF30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b4,y:b3,platform:Windows, +03000000c82d000021ab000000000000,8BitDo SFC30,a:b1,b:b0,back:b10,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b11,x:b4,y:b3,platform:Windows, +03000000102800000900000000000000,8Bitdo SFC30 GamePad,a:b1,b:b0,back:b10,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b11,x:b4,y:b3,platform:Windows, +03000000c82d00003028000000000000,8Bitdo SFC30 GamePad,a:b1,b:b0,back:b10,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b11,x:b4,y:b3,platform:Windows, +03000000c82d00000030000000000000,8BitDo SN30,a:b1,b:b0,back:b10,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b11,x:b4,y:b3,platform:Windows, +03000000c82d00000351000000000000,8BitDo SN30,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a5,start:b11,x:b4,y:b3,platform:Windows, +03000000c82d00001290000000000000,8BitDo SN30,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a5,start:b11,x:b4,y:b3,platform:Windows, +03000000c82d000020ab000000000000,8BitDo SN30,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a5,start:b11,x:b4,y:b3,platform:Windows, +03000000c82d00004028000000000000,8BitDo SN30,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a5,start:b11,x:b4,y:b3,platform:Windows, +03000000c82d00006228000000000000,8BitDo SN30 GP,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a5,start:b11,x:b4,y:b3,platform:Windows, +03000000c82d00000160000000000000,8BitDo SN30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a5,start:b11,x:b4,y:b3,platform:Windows, +03000000c82d00000161000000000000,8BitDo SN30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a5,start:b11,x:b4,y:b3,platform:Windows, +03000000c82d00000260000000000000,8BitDo SN30 Pro+,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a5,start:b11,x:b4,y:b3,platform:Windows, +03000000c82d00000261000000000000,8BitDo SN30 Pro+,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a5,start:b11,x:b4,y:b3,platform:Windows, +03000000c82d00000031000000000000,8BitDo Wireless Adapter,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b4,y:b3,platform:Windows, +03000000a00500003232000000000000,8Bitdo Zero GamePad,a:b0,b:b1,back:b10,dpdown:+a2,dpleft:-a0,dpright:+a0,dpup:-a2,leftshoulder:b6,rightshoulder:b7,start:b11,x:b3,y:b4,platform:Windows, +030000008f0e00001200000000000000,Acme GA-02,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b2,y:b3,platform:Windows, +03000000fa190000f0ff000000000000,Acteck AGJ-3200,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows, +030000006f0e00001413000000000000,Afterglow,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows, +03000000341a00003608000000000000,Afterglow PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows, +030000006f0e00000263000000000000,Afterglow PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows, +030000006f0e00001101000000000000,Afterglow PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows, +030000006f0e00001401000000000000,Afterglow PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows, +030000006f0e00001402000000000000,Afterglow PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows, +030000006f0e00001901000000000000,Afterglow PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows, +030000006f0e00001a01000000000000,Afterglow PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows, +03000000d62000001d57000000000000,Airflo PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows, +03000000869800002400000000007801,Astro C40 TR,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b8,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Windows, +03000000d6200000e557000000000000,Batarang,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows, +03000000c01100001352000000000000,Battalife Joystick,a:b6,b:b7,back:b2,leftshoulder:b0,leftx:a0,lefty:a1,rightshoulder:b1,start:b3,x:b4,y:b5,platform:Windows, +030000006f0e00003201000000000000,Battlefield 4 PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows, +03000000bc2000006012000000000000,Betop 2126F,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows, +03000000bc2000000055000000000000,Betop BFM Gamepad,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b3,y:b4,platform:Windows, +03000000bc2000006312000000000000,Betop Controller,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows, +03000000bc2000006321000000000000,BETOP CONTROLLER,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows, +03000000bc2000006412000000000000,Betop Controller,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows, +03000000c01100000555000000000000,Betop Controller,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows, +03000000c01100000655000000000000,Betop Controller,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows, +03000000790000000700000000000000,Betop Gamepad,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a4,start:b9,x:b3,y:b0,platform:Windows, +03000000808300000300000000000000,Betop Gamepad,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a4,start:b9,x:b3,y:b0,platform:Windows, +030000006b1400000055000000000000,Bigben PS3 Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Windows, +030000006b1400000103000000000000,Bigben PS3 Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b2,platform:Windows, +0300000066f700000500000000000000,BrutalLegendTest,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b0,y:b3,platform:Windows, +03000000d81d00000b00000000000000,BUFFALO BSGP1601 Series ,a:b5,b:b3,back:b12,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b8,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b9,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b13,x:b4,y:b2,platform:Windows, +03000000e82000006058000000000000,Cideko AK08b,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows, +03000000457500000401000000000000,Cobra,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows, +030000005e0400008e02000000000000,Controller (XBOX 360 For Windows),a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b8,lefttrigger:+a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:-a2,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Windows, +030000005e040000a102000000000000,Controller (Xbox 360 Wireless Receiver for Windows),a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b8,lefttrigger:+a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:-a2,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Windows, +030000005e040000ff02000000000000,Controller (Xbox One For Windows) - Wired,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b8,lefttrigger:+a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:-a2,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Windows, +030000005e040000ea02000000000000,Controller (Xbox One For Windows) - Wireless,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b8,lefttrigger:+a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:-a2,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Windows, +03000000260900008888000000000000,Cyber Gadget GameCube Controller,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b6,righttrigger:a4,rightx:a2,righty:a3~,start:b7,x:b2,y:b3,platform:Windows, +03000000a306000022f6000000000000,Cyborg V.3 Rumble Pad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:+a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:-a3,rightx:a2,righty:a4,start:b9,x:b0,y:b3,platform:Windows, +03000000451300000830000000000000,Defender Game Racer X7,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Windows, +03000000791d00000103000000000000,Dual Box WII,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b6,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:b5,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows, +03000000bd12000002e0000000000000,Dual USB Vibration Joystick,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b9,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b10,righttrigger:b5,rightx:a3,righty:a2,start:b11,x:b3,y:b0,platform:Windows, +030000006f0e00003001000000000000,EA SPORTS PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows, +03000000b80500000410000000000000,Elecom Gamepad,a:b2,b:b3,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b1,platform:Windows, +03000000b80500000610000000000000,Elecom Gamepad,a:b2,b:b3,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b1,platform:Windows, +03000000120c0000f61c000000000000,Elite,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows, +030000008f0e00000f31000000000000,EXEQ,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b2,platform:Windows, +03000000341a00000108000000000000,EXEQ RF USB Gamepad 8206,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b8,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Windows, +03000000852100000201000000000000,FF-GP1,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows, +030000000d0f00008500000000000000,Fighting Commander 2016 PS3,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows, +030000000d0f00008400000000000000,Fighting Commander 5,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows, +030000000d0f00008700000000000000,Fighting Stick mini 4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Windows, +030000000d0f00008800000000000000,Fighting Stick mini 4,a:b1,b:b2,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b8,x:b0,y:b3,platform:Windows, +030000000d0f00002700000000000000,FIGHTING STICK V3,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Windows, +78696e70757403000000000000000000,Fightstick TES,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,lefttrigger:a2,rightshoulder:b5,righttrigger:a5,start:b7,x:b2,y:b3,platform:Windows, +03000000790000000600000000000000,G-Shark GS-GP702,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a4,start:b9,x:b3,y:b0,platform:Windows, +03000000790000002201000000000000,Game Controller for PC,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows, +0300000066f700000100000000000000,Game VIB Joystick,a:b2,b:b3,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b8,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:b7,rightx:a3,righty:a2,start:b11,x:b0,y:b1,platform:Windows, +03000000260900002625000000000000,Gamecube Controller,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b6,lefttrigger:a4,leftx:a0,lefty:a1,righttrigger:a5,rightx:a2,righty:a3,start:b7,x:b2,y:b3,platform:Windows, +030000008f0e00000d31000000000000,GAMEPAD 3 TURBO,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows, +03000000280400000140000000000000,GamePad Pro USB,a:b1,b:b2,back:b8,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Windows, +03000000ac0500003d03000000000000,GameSir,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b3,y:b4,platform:Windows, +03000000ac0500004d04000000000000,GameSir,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b3,y:b4,platform:Windows, +03000000ffff00000000000000000000,GameStop Gamepad,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Windows, +030000006f0e00000102000000007801,GameStop Xbox 360 Wired Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b8,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Windows, +030000008305000009a0000000000000,Genius,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Windows, +030000008305000031b0000000000000,Genius Maxfire Blaze 3,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Windows, +03000000451300000010000000000000,Genius Maxfire Grandias 12,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Windows, +030000005c1a00003330000000000000,Genius MaxFire Grandias 12V,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b7,leftx:a0,lefty:a1,rightshoulder:b4,rightstick:b11,righttrigger:b5,rightx:a3,righty:a2,start:b9,x:b2,y:b3,platform:Windows, +03000000300f00000b01000000000000,GGE909 Recoil Pad,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b3,y:b0,platform:Windows, +03000000f0250000c283000000000000,Gioteck,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows, +03000000f025000021c1000000000000,Gioteck PS3 Controller,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows, +03000000f0250000c383000000000000,Gioteck VX2 Controller,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows, +03000000f0250000c483000000000000,Gioteck VX2 Controller,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows, +030000007d0400000540000000000000,Gravis Eliminator GamePad Pro,a:b1,b:b2,back:b8,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Windows, +03000000341a00000302000000000000,Hama Scorpad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows, +030000000d0f00004900000000000000,Hatsune Miku Sho Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows, +03000000d81400000862000000000000,HitBox Edition Cthulhu+,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b5,lefttrigger:b4,rightshoulder:b7,righttrigger:b6,start:b9,x:b0,y:b3,platform:Windows, +03000000632500002605000000000000,HJD-X,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b3,y:b4,platform:Windows, +030000000d0f00002d00000000000000,Hori Fighting Commander 3 Pro,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows, +030000000d0f00005f00000000000000,Hori Fighting Commander 4 (PS3),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows, +030000000d0f00005e00000000000000,Hori Fighting Commander 4 (PS4),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows, +030000000d0f00004000000000000000,Hori Fighting Stick Mini 3,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b5,lefttrigger:b4,rightshoulder:b7,righttrigger:b6,start:b9,x:b0,y:b3,platform:Windows, +030000000d0f00005400000000000000,Hori Pad 3,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows, +030000000d0f00000900000000000000,Hori Pad 3 Turbo,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows, +030000000d0f00004d00000000000000,Hori Pad A,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows, +030000000d0f00009200000000000000,Hori Pokken Tournament DX Pro Pad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Windows, +030000000d0f00001600000000007803,HORI Real Arcade Pro EX-SE (Xbox 360),a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,lefttrigger:a2,rightshoulder:b5,righttrigger:a5,start:b7,x:b2,y:b3,platform:Windows, +030000000d0f00009c00000000000000,Hori TAC Pro,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows, +030000000d0f0000c100000000000000,Horipad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows, +030000000d0f00006e00000000000000,HORIPAD 4 (PS3),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows, +030000000d0f00006600000000000000,HORIPAD 4 (PS4),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows, +030000000d0f00005500000000000000,Horipad 4 FPS,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows, +030000000d0f0000ee00000000000000,HORIPAD mini4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows, +03000000250900000017000000000000,HRAP2 on PS/SS/N64 Joypad to USB BOX,a:b2,b:b1,back:b9,leftshoulder:b5,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:b6,start:b8,x:b3,y:b0,platform:Windows, +030000008f0e00001330000000000000,HuiJia SNES Controller,a:b2,b:b1,back:b8,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b6,rightshoulder:b7,start:b9,x:b3,y:b0,platform:Windows, +03000000d81d00000f00000000000000,iBUFFALO BSGP1204 Series,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows, +03000000d81d00001000000000000000,iBUFFALO BSGP1204P Series,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows, +03000000830500006020000000000000,iBuffalo SNES Controller,a:b1,b:b0,back:b6,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b4,rightshoulder:b5,start:b7,x:b3,y:b2,platform:Windows, +03000000b50700001403000000000000,Impact Black,a:b2,b:b3,back:b8,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b0,y:b1,platform:Windows, +030000006f0e00002401000000000000,INJUSTICE FightStick PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Windows, +03000000ac0500002c02000000000000,IPEGA,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b8,leftstick:b13,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b9,rightstick:b14,righttrigger:b7,rightx:a3,righty:a4,start:b11,x:b3,y:b4,platform:Windows, +03000000491900000204000000000000,Ipega PG-9023,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b3,y:b4,platform:Windows, +03000000491900000304000000000000,Ipega PG-9087 - Bluetooth Gamepad,+righty:+a5,-righty:-a4,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,start:b11,x:b3,y:b4,platform:Windows, +030000006e0500000a20000000000000,JC-DUX60 ELECOM MMO Gamepad,a:b2,b:b3,back:b17,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b8,leftstick:b14,lefttrigger:b12,leftx:a0,lefty:a1,rightshoulder:b11,rightstick:b15,righttrigger:b13,rightx:a3,righty:a4,start:b20,x:b0,y:b1,platform:Windows, +030000006e0500000520000000000000,JC-P301U,a:b2,b:b3,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b8,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:b7,rightx:a2,righty:a3,start:b11,x:b0,y:b1,platform:Windows, +030000006e0500000320000000000000,JC-U3613M (DInput),a:b2,b:b3,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b8,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:b7,rightx:a2,righty:a3,start:b11,x:b0,y:b1,platform:Windows, +030000006e0500000720000000000000,JC-W01U,a:b2,b:b3,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b1,platform:Windows, +030000007e0500000620000000000000,Joy-Con (L),+leftx:h0.2,+lefty:h0.4,-leftx:h0.8,-lefty:h0.1,a:b0,b:b1,back:b13,leftshoulder:b4,leftstick:b10,rightshoulder:b5,start:b8,x:b2,y:b3,platform:Windows, +030000007e0500000620000001000000,Joy-Con (L),+leftx:h0.2,+lefty:h0.4,-leftx:h0.8,-lefty:h0.1,a:b0,b:b1,back:b13,leftshoulder:b4,leftstick:b10,rightshoulder:b5,start:b8,x:b2,y:b3,platform:Windows, +030000007e0500000720000000000000,Joy-Con (R),+leftx:h0.2,+lefty:h0.4,-leftx:h0.8,-lefty:h0.1,a:b0,b:b1,back:b12,leftshoulder:b4,leftstick:b11,rightshoulder:b5,start:b9,x:b2,y:b3,platform:Windows, +030000007e0500000720000001000000,Joy-Con (R),+leftx:h0.2,+lefty:h0.4,-leftx:h0.8,-lefty:h0.1,a:b0,b:b1,back:b12,leftshoulder:b4,leftstick:b11,rightshoulder:b5,start:b9,x:b2,y:b3,platform:Windows, +03000000bd12000003c0000000000000,JY-P70UR,a:b1,b:b0,back:b5,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b7,leftx:a0,lefty:a1,rightshoulder:b8,rightstick:b11,righttrigger:b9,rightx:a3,righty:a2,start:b4,x:b3,y:b2,platform:Windows, +03000000790000000200000000000000,King PS3 Controller,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a4,start:b9,x:b3,y:b0,platform:Windows, +030000006d040000d1ca000000000000,Logitech ChillStream,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows, +030000006d040000d2ca000000000000,Logitech Cordless Precision,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows, +030000006d04000011c2000000000000,Logitech Cordless Wingman,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b9,leftstick:b5,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b2,righttrigger:b7,rightx:a3,righty:a4,x:b4,platform:Windows, +030000006d04000016c2000000000000,Logitech Dual Action,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows, +030000006d04000018c2000000000000,Logitech F510 Gamepad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows, +030000006d04000019c2000000000000,Logitech F710 Gamepad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows, +03000000380700006652000000000000,Mad Catz C.T.R.L.R,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a3,righty:a4,start:b9,x:b0,y:b3,platform:Windows, +03000000380700005032000000000000,Mad Catz FightPad PRO (PS3),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows, +03000000380700005082000000000000,Mad Catz FightPad PRO (PS4),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows, +03000000380700008433000000000000,Mad Catz FightStick TE S+ (PS3),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows, +03000000380700008483000000000000,Mad Catz FightStick TE S+ (PS4),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows, +03000000380700008134000000000000,Mad Catz FightStick TE2+ PS3,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b7,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b4,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows, +03000000380700008184000000000000,Mad Catz FightStick TE2+ PS4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b5,leftstick:b10,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b4,rightstick:b11,righttrigger:b7,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows, +03000000380700006252000000000000,Mad Catz Micro C.T.R.L.R,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a3,righty:a4,start:b9,x:b0,y:b3,platform:Windows, +03000000380700008034000000000000,Mad Catz TE2 PS3 Fightstick,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows, +03000000380700008084000000000000,Mad Catz TE2 PS4 Fightstick,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows, +03000000380700008532000000000000,Madcatz Arcade Fightstick TE S PS3,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows, +03000000380700003888000000000000,Madcatz Arcade Fightstick TE S+ PS3,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows, +03000000380700001888000000000000,MadCatz SFIV FightStick PS3,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b5,lefttrigger:b7,leftx:a0,lefty:a1,rightshoulder:b4,righttrigger:b6,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Windows, +03000000380700008081000000000000,MADCATZ SFV Arcade FightStick Alpha PS4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows, +030000002a0600001024000000000000,Matricom,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a3,righty:a4,start:b9,x:b2,y:b3,platform:Windows, +03000000250900000128000000000000,Mayflash Arcade Stick,a:b1,b:b2,back:b8,leftshoulder:b0,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b3,righttrigger:b7,start:b9,x:b5,y:b6,platform:Windows, +03000000790000004418000000000000,Mayflash GameCube Controller,a:b1,b:b2,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:a4,rightx:a5,righty:a2,start:b9,x:b0,y:b3,platform:Windows, +03000000790000004318000000000000,Mayflash GameCube Controller Adapter,a:b1,b:b2,back:b0,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b0,leftshoulder:b4,leftstick:b0,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b0,righttrigger:a4,rightx:a5,righty:a2,start:b9,x:b0,y:b3,platform:Windows, +03000000242f00007300000000000000,Mayflash Magic NS,a:b1,b:b4,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:b8,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b0,y:b3,platform:Windows, +0300000079000000d218000000000000,Mayflash Magic NS,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows, +03000000d620000010a7000000000000,Mayflash Magic NS,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows, +030000008f0e00001030000000000000,Mayflash USB Adapter for original Sega Saturn controller,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,lefttrigger:b5,rightshoulder:b2,righttrigger:b7,start:b9,x:b3,y:b4,platform:Windows, +0300000025090000e803000000000000,Mayflash Wii Classic Controller,a:b1,b:b0,back:b8,dpdown:b13,dpleft:b12,dpright:b14,dpup:b11,guide:b10,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b2,platform:Windows, +03000000790000000018000000000000,Mayflash WiiU Pro Game Controller Adapter (DInput),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows, +03000000790000002418000000000000,Mega Drive,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,rightshoulder:b2,start:b9,x:b3,y:b4,platform:Windows, +03000000380700006382000000000000,MLG GamePad PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows, +03000000efbe0000edfe000000000000,Monect Virtual Controller,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a5,rightx:a3,righty:a4,start:b9,x:b3,y:b0,platform:Windows, +03000000250900006688000000000000,MP-8866 Super Dual Box,a:b2,b:b1,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a2,righty:a3,start:b8,x:b3,y:b0,platform:Windows, +030000001008000001e5000000000000,NEXT SNES Controller,a:b2,b:b1,back:b8,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b4,rightshoulder:b6,start:b9,x:b3,y:b0,platform:Windows, +03000000152000000182000000000000,NGDS,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a3,righty:a4,start:b9,x:b3,y:b0,platform:Windows, +03000000bd12000015d0000000000000,Nintendo Retrolink USB Super SNES Classic Controller,a:b2,b:b1,back:b8,leftshoulder:b4,leftx:a0,lefty:a1,rightshoulder:b5,start:b9,x:b3,y:b0,platform:Windows, +030000007e0500000920000000000000,Nintendo Switch Pro Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Windows, +030000000d0500000308000000000000,Nostromo N45,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b9,leftshoulder:b4,leftstick:b12,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b10,x:b2,y:b3,platform:Windows, +03000000550900001472000000000000,NVIDIA Controller v01.04,a:b11,b:b10,back:b13,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b7,leftstick:b5,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b4,righttrigger:a5,rightx:a3,righty:a6,start:b3,x:b9,y:b8,platform:Windows, +030000004b120000014d000000000000,NYKO AIRFLO,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:a3,leftstick:a0,lefttrigger:b6,rightshoulder:b5,rightstick:a2,righttrigger:b7,start:b9,x:b2,y:b3,platform:Windows, +03000000782300000a10000000000000,Onlive Wireless Controller,a:b15,b:b14,back:b7,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b5,leftshoulder:b11,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a3,righty:a4,start:b6,x:b13,y:b12,platform:Windows, +03000000d62000006d57000000000000,OPP PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows, +030000006b14000001a1000000000000,Orange Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a4,rightx:a5,righty:a2,start:b9,x:b2,y:b3,platform:Windows, +03000000362800000100000000000000,OUYA Game Controller,a:b0,b:b3,dpdown:b9,dpleft:b10,dpright:b11,dpup:b8,guide:b14,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:b13,rightx:a3,righty:a4,x:b1,y:b2,platform:Windows, +03000000120c0000f60e000000000000,P4 Wired Gamepad,a:b1,b:b2,back:b12,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b5,lefttrigger:b7,rightshoulder:b4,righttrigger:b6,start:b9,x:b0,y:b3,platform:Windows, +030000008f0e00000300000000000000,Piranha xtreme,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a3,righty:a2,start:b9,x:b3,y:b0,platform:Windows, +030000004c050000da0c000000000000,PlayStation Classic Controller,a:b2,b:b1,back:b8,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b6,lefttrigger:b4,rightshoulder:b7,righttrigger:b5,start:b9,x:b3,y:b0,platform:Windows, +03000000d62000006dca000000000000,PowerA Pro Ex,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows, +03000000d62000009557000000000000,Pro Elite PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows, +03000000d62000009f31000000000000,Pro Ex mini PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows, +03000000d6200000c757000000000000,Pro Ex mini PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows, +03000000632500002306000000000000,PS Controller,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Windows, +03000000e30500009605000000000000,PS to USB convert cable,a:b2,b:b1,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a2,righty:a3,start:b8,x:b3,y:b0,platform:Windows, +03000000100800000100000000000000,PS1 Controller,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a3,righty:a2,start:b9,x:b3,y:b0,platform:Windows, +030000008f0e00007530000000000000,PS1 Controller,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b1,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows, +03000000100800000300000000000000,PS2 Controller,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a4,righty:a2,start:b9,x:b3,y:b0,platform:Windows, +03000000250900008888000000000000,PS2 Controller,a:b2,b:b1,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a2,righty:a3,start:b8,x:b3,y:b0,platform:Windows, +03000000666600006706000000000000,PS2 Controller,a:b2,b:b1,back:b8,dpdown:b14,dpleft:b15,dpright:b13,dpup:b12,leftshoulder:b6,leftstick:b9,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b10,righttrigger:b5,rightx:a2,righty:a3,start:b11,x:b3,y:b0,platform:Windows, +030000006b1400000303000000000000,PS2 Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Windows, +030000009d0d00001330000000000000,PS2 Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Windows, +03000000250900000500000000000000,PS3 Controller,a:b2,b:b1,back:b9,dpdown:h0.8,dpleft:h0.4,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a2,righty:a3,start:b8,x:b0,y:b3,platform:Windows, +030000004c0500006802000000000000,PS3 Controller,a:b2,b:b1,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b10,lefttrigger:a3~,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:a4~,rightx:a2,righty:a5,start:b8,x:b3,y:b0,platform:Windows, +03000000632500007505000000000000,PS3 Controller,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows, +03000000888800000803000000000000,PS3 Controller,a:b2,b:b1,back:b8,dpdown:h0.8,dpleft:h0.4,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b9,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:b7,rightx:a3,righty:a4,start:b11,x:b0,y:b3,platform:Windows, +030000008f0e00001431000000000000,PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows, +030000003807000056a8000000000000,PS3 RF pad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows, +03000000100000008200000000000000,PS360+ v1.66,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,leftx:h0.4,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Windows, +030000004c050000a00b000000000000,PS4 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows, +030000004c050000c405000000000000,PS4 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows, +030000004c050000cc09000000000000,PS4 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows, +03000000300f00000011000000000000,QanBa Arcade JoyStick 1008,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,start:b10,x:b0,y:b3,platform:Windows, +03000000300f00001611000000000000,QanBa Arcade JoyStick 4018,a:b1,b:b2,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b9,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b8,x:b0,y:b3,platform:Windows, +03000000222c00000020000000000000,QANBA DRONE ARCADE JOYSTICK,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:a3,rightshoulder:b5,righttrigger:a4,start:b9,x:b0,y:b3,platform:Windows, +03000000300f00001210000000000000,QanBa Joystick Plus,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,rightshoulder:b5,start:b9,x:b2,y:b3,platform:Windows, +03000000341a00000104000000000000,QanBa Joystick Q4RAF,a:b5,b:b6,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b0,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b3,righttrigger:b7,start:b9,x:b1,y:b2,platform:Windows, +03000000222c00000223000000000000,Qanba Obsidian Arcade Joystick PS3 Mode,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows, +03000000222c00000023000000000000,Qanba Obsidian Arcade Joystick PS4 Mode,a:b1,b:b2,back:b13,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows, +03000000321500000003000000000000,Razer Hydra,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b8,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:a2,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Windows, +03000000321500000204000000000000,Razer Panthera (PS3),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows, +03000000321500000104000000000000,Razer Panthera (PS4),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows, +03000000321500000507000000000000,Razer Raiju Mobile,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b3,y:b4,platform:Windows, +03000000321500000707000000000000,Razer Raiju Mobile,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b3,y:b4,platform:Windows, +030000000d0f00001100000000000000,REAL ARCADE PRO.3,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,rightshoulder:b5,rightstick:b11,righttrigger:b7,start:b9,x:b0,y:b3,platform:Windows, +030000000d0f00006a00000000000000,Real Arcade Pro.4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows, +030000000d0f00006b00000000000000,Real Arcade Pro.4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows, +030000000d0f00008a00000000000000,Real Arcade Pro.4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows, +030000000d0f00008b00000000000000,Real Arcade Pro.4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows, +030000000d0f00007000000000000000,REAL ARCADE PRO.4 VLX,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,rightshoulder:b5,rightstick:b11,righttrigger:b7,start:b9,x:b0,y:b3,platform:Windows, +030000000d0f00002200000000000000,REAL ARCADE Pro.V3,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows, +030000000d0f00005b00000000000000,Real Arcade Pro.V4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows, +030000000d0f00005c00000000000000,Real Arcade Pro.V4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows, +03000000790000001100000000000000,Retrolink SNES Controller,a:b2,b:b1,back:b8,dpdown:+a4,dpleft:-a3,dpright:+a3,dpup:-a4,leftshoulder:b4,rightshoulder:b5,start:b9,x:b3,y:b0,platform:Windows, +0300000000f000000300000000000000,RetroUSB.com RetroPad,a:b1,b:b5,back:b2,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b3,x:b0,y:b4,platform:Windows, +0300000000f00000f100000000000000,RetroUSB.com Super RetroPort,a:b1,b:b5,back:b2,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b3,x:b0,y:b4,platform:Windows, +030000006b140000010d000000000000,Revolution Pro Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows, +030000006b140000020d000000000000,Revolution Pro Controller 2(1/2),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows, +030000006f0e00001e01000000000000,Rock Candy PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows, +030000006f0e00002801000000000000,Rock Candy PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows, +030000006f0e00002f01000000000000,Rock Candy PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows, +030000004f04000003d0000000000000,run'n'drive,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b7,leftshoulder:a3,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:a4,rightstick:b11,righttrigger:b5,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows, +03000000a30600001af5000000000000,Saitek Cyborg,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a3,righty:a4,start:b9,x:b0,y:b3,platform:Windows, +03000000a306000023f6000000000000,Saitek Cyborg V.1 Game pad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a4,start:b9,x:b0,y:b3,platform:Windows, +03000000300f00001201000000000000,Saitek Dual Analog Pad,a:b2,b:b3,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b0,y:b1,platform:Windows, +03000000a30600000701000000000000,Saitek P220,a:b2,b:b3,back:b4,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b6,rightshoulder:b7,start:b5,x:b0,y:b1,platform:Windows, +03000000a30600000cff000000000000,Saitek P2500 Force Rumble Pad,a:b2,b:b3,back:b11,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b8,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:b7,rightx:a2,righty:a3,x:b0,y:b1,platform:Windows, +03000000a30600000c04000000000000,Saitek P2900,a:b1,b:b2,back:b12,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b0,y:b3,platform:Windows, +03000000300f00001001000000000000,Saitek P480 Rumble Pad,a:b2,b:b3,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b0,y:b1,platform:Windows, +03000000a30600000b04000000000000,Saitek P990,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b0,y:b3,platform:Windows, +03000000a30600000b04000000010000,Saitek P990 Dual Analog Pad,a:b1,b:b2,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b8,x:b0,y:b3,platform:Windows, +03000000a30600002106000000000000,Saitek PS1000,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a4,start:b9,x:b0,y:b3,platform:Windows, +03000000a306000020f6000000000000,Saitek PS2700,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a4,start:b9,x:b0,y:b3,platform:Windows, +03000000300f00001101000000000000,Saitek Rumble Pad,a:b2,b:b3,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b0,y:b1,platform:Windows, +03000000730700000401000000000000,Sanwa PlayOnline Mobile,a:b0,b:b1,back:b2,leftx:a0,lefty:a1,start:b3,platform:Windows, +0300000000050000289b000000000000,Saturn_Adapter_2.0,a:b1,b:b2,leftshoulder:b6,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:b5,start:b9,x:b0,y:b3,platform:Windows, +030000009b2800000500000000000000,Saturn_Adapter_2.0,a:b1,b:b2,leftshoulder:b6,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:b5,start:b9,x:b0,y:b3,platform:Windows, +030000005e0400008e02000000007801,ShanWan PS3/PC Wired GamePad,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b8,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Windows, +03000000341a00000208000000000000,SL-6555-SBK,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b8,lefttrigger:-a4,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:a4,rightx:a3,righty:a2,start:b7,x:b2,y:b3,platform:Windows, +03000000341a00000908000000000000,SL-6566,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Windows, +030000008f0e00000800000000000000,SpeedLink Strike FX,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows, +03000000c01100000591000000000000,Speedlink Torid,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows, +03000000d11800000094000000000000,Stadia Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:b12,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:b11,rightx:a3,righty:a4,start:b9,x:b2,y:b3,platform:Windows, +03000000110100001914000000000000,SteelSeries,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftstick:b13,lefttrigger:b6,leftx:a0,lefty:a1,rightstick:b14,righttrigger:b7,rightx:a3,righty:a4,start:b11,x:b3,y:b4,platform:Windows, +03000000381000001214000000000000,SteelSeries Free,a:b0,b:b1,back:b12,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Windows, +03000000381000001814000000000000,SteelSeries Stratus XL,a:b0,b:b1,back:b18,dpdown:b13,dpleft:b14,dpright:b15,dpup:b12,guide:b19,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b2,y:b3,platform:Windows, +03000000790000001c18000000000000,STK-7024X,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b3,y:b4,platform:Windows, +03000000ff1100003133000000000000,SVEN X-PAD,a:b2,b:b3,back:b4,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:b9,rightx:a2,righty:a4,start:b5,x:b0,y:b1,platform:Windows, +03000000d620000011a7000000000000,Switch,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows, +030000004f04000007d0000000000000,T Mini Wireless,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows, +030000004f0400000ab1000000000000,T.16000M,a:b0,b:b1,back:b12,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b11,leftshoulder:b4,lefttrigger:b9,leftx:a0,lefty:a1,rightshoulder:b6,righttrigger:b7,start:b10,x:b2,y:b3,platform:Windows, +03000000fa1900000706000000000000,Team 5,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows, +03000000b50700001203000000000000,Techmobility X6-38V,a:b2,b:b3,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b0,y:b1,platform:Windows, +030000004f04000015b3000000000000,Thrustmaster Dual Analog 4,a:b0,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b1,y:b3,platform:Windows, +030000004f04000023b3000000000000,Thrustmaster Dual Trigger 3-in-1,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows, +030000004f04000000b3000000000000,Thrustmaster Firestorm Dual Power,a:b0,b:b2,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b11,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b12,righttrigger:b7,rightx:a2,righty:a3,start:b10,x:b1,y:b3,platform:Windows, +030000004f04000004b3000000000000,Thrustmaster Firestorm Dual Power 3,a:b0,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b1,y:b3,platform:Windows, +03000000666600000488000000000000,TigerGame PS/PS2 Game Controller Adapter,a:b2,b:b1,back:b9,dpdown:b14,dpleft:b15,dpright:b13,dpup:b12,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a2,righty:a3,start:b8,x:b3,y:b0,platform:Windows, +03000000d62000006000000000000000,Tournament PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows, +030000005f140000c501000000000000,Trust Gamepad,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows, +03000000b80500000210000000000000,Trust Gamepad,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows, +030000004f04000087b6000000000000,TWCS Throttle,dpdown:b8,dpleft:b9,dpright:b7,dpup:b6,leftstick:b5,lefttrigger:-a5,leftx:a0,lefty:a1,righttrigger:+a5,platform:Windows, +03000000d90400000200000000000000,TwinShock PS2,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a3,righty:a2,start:b9,x:b3,y:b0,platform:Windows, +030000006e0500001320000000000000,U4113,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows, +03000000101c0000171c000000000000,uRage Gamepad,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows, +03000000300f00000701000000000000,USB 4-Axis 12-Button Gamepad,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b3,y:b0,platform:Windows, +03000000341a00002308000000000000,USB gamepad,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Windows, +030000005509000000b4000000000000,USB gamepad,a:b10,b:b11,back:b5,dpdown:b1,dpleft:b2,dpright:b3,dpup:b0,guide:b14,leftshoulder:b8,leftstick:b6,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b9,rightstick:b7,righttrigger:a5,rightx:a2,righty:a3,start:b4,x:b12,y:b13,platform:Windows, +030000006b1400000203000000000000,USB gamepad,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Windows, +03000000790000000a00000000000000,USB gamepad,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a4,start:b9,x:b3,y:b0,platform:Windows, +03000000f0250000c183000000000000,USB gamepad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows, +03000000ff1100004133000000000000,USB gamepad,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a4,righty:a2,start:b9,x:b3,y:b0,platform:Windows, +03000000632500002305000000000000,USB Vibration Joystick (BM),a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows, +03000000790000001a18000000000000,Venom,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows, +03000000790000001b18000000000000,Venom Arcade Joystick,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Windows, +030000006f0e00000302000000000000,Victrix Pro Fight Stick for PS4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Windows, +030000005e0400000a0b000000000000,Xbox Adaptive Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b8,lefttrigger:+a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:-a2,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Windows, +03000000341a00000608000000000000,Xeox,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Windows, +03000000450c00002043000000000000,XEOX Gamepad SL-6556-BK,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Windows, +03000000172700004431000000000000,XiaoMi Game Controller,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b20,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a7,rightx:a2,righty:a5,start:b11,x:b3,y:b4,platform:Windows, +03000000786901006e70000000000000,XInput Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b8,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Windows, +xinput,XInput Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b8,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Windows, +03000000790000004f18000000000000,ZD-T Android,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b3,y:b4,platform:Windows, + +# Mac OS X +030000008f0e00000300000009010000,2In1 USB Joystick,+leftx:h0.2,+lefty:h0.4,-leftx:h0.8,-lefty:h0.1,a:b2,b:b1,back:b8,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Mac OS X, +03000000c82d00000650000001000000,8BitDo M30,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b8,lefttrigger:b9,leftx:a0,lefty:a1,rightshoulder:b6,righttrigger:b7,start:b11,x:b3,y:b4,platform:Mac OS X, +03000000022000000090000001000000,8Bitdo NES30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Mac OS X, +03000000203800000900000000010000,8Bitdo NES30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Mac OS X, +03000000c82d00000190000001000000,8Bitdo NES30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Mac OS X, +03000000102800000900000000000000,8Bitdo SFC30 GamePad Joystick,a:b1,b:b0,back:b10,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b11,x:b4,y:b3,platform:Mac OS X, +03000000c82d00000260000001000000,8BitDo SN30 Pro+,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b4,y:b3,platform:Mac OS X, +03000000c82d00000261000000010000,8BitDo SN30 Pro+,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b4,y:b3,platform:Mac OS X, +03000000c82d00000031000001000000,8BitDo Wireless Adapter,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Mac OS X, +03000000a00500003232000008010000,8Bitdo Zero GamePad,a:b0,b:b1,back:b10,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b6,rightshoulder:b7,start:b11,x:b3,y:b4,platform:Mac OS X, +03000000a00500003232000009010000,8Bitdo Zero GamePad,a:b0,b:b1,back:b10,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b6,rightshoulder:b7,start:b11,x:b3,y:b4,platform:Mac OS X, +03000000050b00000045000031000000,ASUS Gamepad,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b7,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b8,righttrigger:a4,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Mac OS X, +030000008305000031b0000000000000,Cideko AK08b,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X, +03000000260900008888000088020000,Cyber Gadget GameCube Controller,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b6,righttrigger:a5,rightx:a2,righty:a3~,start:b7,x:b2,y:b3,platform:Mac OS X, +03000000a306000022f6000001030000,Cyborg V.3 Rumble Pad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:+a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:-a3,rightx:a2,righty:a4,start:b9,x:b0,y:b3,platform:Mac OS X, +03000000790000000600000000000000,G-Shark GP-702,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a3,righty:a4,start:b9,x:b3,y:b0,platform:Mac OS X, +03000000ad1b000001f9000000000000,Gamestop BB-070 X360 Controller,a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b8,x:b2,y:b3,platform:Mac OS X, +0500000047532047616d657061640000,GameStop Gamepad,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Mac OS X, +030000006f0e00000102000000000000,GameStop Xbox 360 Wired Controller,a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b8,x:b2,y:b3,platform:Mac OS X, +030000007d0400000540000001010000,Gravis Eliminator GamePad Pro,a:b1,b:b2,back:b8,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Mac OS X, +030000000d0f00002d00000000100000,Hori Fighting Commander 3 Pro,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X, +030000000d0f00005f00000000010000,Hori Fighting Commander 4 (PS3),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X, +030000000d0f00005e00000000010000,Hori Fighting Commander 4 (PS4),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Mac OS X, +030000000d0f00005f00000000000000,HORI Fighting Commander 4 PS3,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X, +030000000d0f00005e00000000000000,HORI Fighting Commander 4 PS4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X, +030000000d0f00004d00000000000000,HORI Gem Pad 3,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X, +030000000d0f00009200000000010000,Hori Pokken Tournament DX Pro Pad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Mac OS X, +030000000d0f00006e00000000010000,HORIPAD 4 (PS3),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X, +030000000d0f00006600000000010000,HORIPAD 4 (PS4),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Mac OS X, +030000000d0f00006600000000000000,HORIPAD FPS PLUS 4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Mac OS X, +030000000d0f0000ee00000000010000,HORIPAD mini4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Mac OS X, +030000008f0e00001330000011010000,HuiJia SNES Controller,a:b4,b:b2,back:b16,dpdown:+a2,dpleft:-a0,dpright:+a0,dpup:-a2,leftshoulder:b12,rightshoulder:b14,start:b18,x:b6,y:b0,platform:Mac OS X, +03000000830500006020000000010000,iBuffalo SNES Controller,a:b1,b:b0,back:b6,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b4,rightshoulder:b5,start:b7,x:b3,y:b2,platform:Mac OS X, +03000000830500006020000000000000,iBuffalo USB 2-axis 8-button Gamepad,a:b1,b:b0,back:b6,leftshoulder:b4,leftx:a0,lefty:a1,rightshoulder:b5,start:b7,x:b3,y:b2,platform:Mac OS X, +030000007e0500000620000001000000,Joy-Con (L),+leftx:h0.2,+lefty:h0.4,-leftx:h0.8,-lefty:h0.1,a:b0,b:b1,back:b13,leftshoulder:b4,leftstick:b10,rightshoulder:b5,start:b8,x:b2,y:b3,platform:Mac OS X, +030000007e0500000720000001000000,Joy-Con (R),+leftx:h0.2,+lefty:h0.4,-leftx:h0.8,-lefty:h0.1,a:b0,b:b1,back:b12,leftshoulder:b4,leftstick:b11,rightshoulder:b5,start:b9,x:b2,y:b3,platform:Mac OS X, +030000006d04000016c2000000020000,Logitech Dual Action,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X, +030000006d04000016c2000000030000,Logitech Dual Action,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X, +030000006d04000016c2000014040000,Logitech Dual Action,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X, +030000006d04000016c2000000000000,Logitech F310 Gamepad (DInput),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X, +030000006d04000018c2000000000000,Logitech F510 Gamepad (DInput),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X, +030000006d04000019c2000005030000,Logitech F710,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X, +030000006d0400001fc2000000000000,Logitech F710 Gamepad (XInput),a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b8,x:b2,y:b3,platform:Mac OS X, +030000006d04000018c2000000010000,Logitech RumblePad 2 USB,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1~,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3~,start:b9,x:b0,y:b3,platform:Mac OS X, +030000006d04000019c2000000000000,Logitech Wireless Gamepad (DInput),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X, +03000000380700005032000000010000,Mad Catz FightPad PRO (PS3),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X, +03000000380700005082000000010000,Mad Catz FightPad PRO (PS4),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Mac OS X, +03000000380700008433000000010000,Mad Catz FightStick TE S+ (PS3),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X, +03000000380700008483000000010000,Mad Catz FightStick TE S+ (PS4),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Mac OS X, +03000000790000004418000000010000,Mayflash GameCube Controller,a:b1,b:b2,dpdown:b14,dpleft:b15,dpright:b13,dpup:b12,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:a4,rightx:a5,righty:a2,start:b9,x:b0,y:b3,platform:Mac OS X, +03000000242f00007300000000020000,Mayflash Magic NS,a:b1,b:b4,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:b8,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b0,y:b3,platform:Mac OS X, +0300000079000000d218000026010000,Mayflash Magic NS,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Mac OS X, +03000000d620000010a7000003010000,Mayflash Magic NS,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X, +0300000025090000e803000000000000,Mayflash Wii Classic Controller,a:b1,b:b0,back:b8,dpdown:b13,dpleft:b12,dpright:b14,dpup:b11,guide:b10,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b2,platform:Mac OS X, +03000000790000000018000000000000,Mayflash WiiU Pro Game Controller Adapter (DInput),a:b4,b:b8,back:b32,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b16,leftstick:b40,lefttrigger:b24,leftx:a0,lefty:a4,rightshoulder:b20,rightstick:b44,righttrigger:b28,rightx:a8,righty:a12,start:b36,x:b0,y:b12,platform:Mac OS X, +03000000d8140000cecf000000000000,MC Cthulhu,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Mac OS X, +03000000d62000007162000001000000,Moga Pro 2 HID,a:b0,b:b1,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b7,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b8,righttrigger:a4,rightx:a2,righty:a3,start:b6,x:b2,y:b3,platform:Mac OS X, +03000000632500007505000000020000,NEOGEO mini PAD Controller,a:b1,b:b0,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,start:b9,x:b2,y:b3,platform:Mac OS X, +030000001008000001e5000006010000,NEXT SNES Controller,a:b2,b:b1,back:b8,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b4,rightshoulder:b6,start:b9,x:b3,y:b0,platform:Mac OS X, +030000007e0500000920000000000000,Nintendo Switch Pro Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Mac OS X, +030000007e0500000920000001000000,Nintendo Switch Pro Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Mac OS X, +030000008f0e00000300000000000000,Piranha xtreme,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a3,righty:a2,start:b9,x:b3,y:b0,platform:Mac OS X, +030000004c050000da0c000000010000,Playstation Classic Controller,a:b2,b:b1,back:b8,leftshoulder:b6,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:b5,start:b9,x:b3,y:b0,platform:Mac OS X, +03000000d62000006dca000000010000,PowerA Pro Ex,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X, +030000004c0500006802000000000000,PS3 Controller,a:b14,b:b13,back:b0,dpdown:b6,dpleft:b7,dpright:b5,dpup:b4,guide:b16,leftshoulder:b10,leftstick:b1,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b11,rightstick:b2,righttrigger:b9,rightx:a2,righty:a3,start:b3,x:b15,y:b12,platform:Mac OS X, +030000004c0500006802000000010000,PS3 Controller,a:b14,b:b13,back:b0,dpdown:b6,dpleft:b7,dpright:b5,dpup:b4,guide:b16,leftshoulder:b10,leftstick:b1,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b11,rightstick:b2,righttrigger:b9,rightx:a2,righty:a3,start:b3,x:b15,y:b12,platform:Mac OS X, +030000004c050000a00b000000010000,PS4 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Mac OS X, +030000004c050000c405000000000000,PS4 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Mac OS X, +030000004c050000c405000000010000,PS4 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Mac OS X, +030000004c050000cc09000000010000,PS4 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Mac OS X, +030000008916000000fd000000000000,Razer Onza TE,a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b8,x:b2,y:b3,platform:Mac OS X, +03000000321500000204000000010000,Razer Panthera (PS3),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X, +03000000321500000104000000010000,Razer Panthera (PS4),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Mac OS X, +03000000321500000010000000010000,Razer RAIJU,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Mac OS X, +03000000321500000507000001010000,Razer Raiju Mobile,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b21,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Mac OS X, +03000000321500000009000000020000,Razer Serval,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a4,rightx:a2,righty:a3,start:b7,x:b2,y:b3,platform:Mac OS X, +030000003215000000090000163a0000,Razer Serval,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a4,rightx:a2,righty:a3,start:b7,x:b2,y:b3,platform:Mac OS X, +0300000032150000030a000000000000,Razer Wildcat,a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b8,x:b2,y:b3,platform:Mac OS X, +03000000790000001100000000000000,Retrolink Classic Controller,a:b2,b:b1,back:b8,leftshoulder:b4,leftx:a3,lefty:a4,rightshoulder:b5,start:b9,x:b3,y:b0,platform:Mac OS X, +03000000790000001100000006010000,Retrolink SNES Controller,a:b2,b:b1,back:b8,dpdown:+a4,dpleft:-a3,dpright:+a3,dpup:-a4,leftshoulder:b4,rightshoulder:b5,start:b9,x:b3,y:b0,platform:Mac OS X, +030000006b140000010d000000010000,Revolution Pro Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Mac OS X, +03000000c6240000fefa000000000000,Rock Candy Gamepad for PS3,a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b8,x:b2,y:b3,platform:Mac OS X, +03000000730700000401000000010000,Sanwa PlayOnline Mobile,a:b0,b:b1,back:b2,leftx:a0,lefty:a1,start:b3,platform:Mac OS X, +03000000811700007e05000000000000,Sega Saturn,a:b2,b:b4,dpdown:b16,dpleft:b15,dpright:b14,dpup:b17,leftshoulder:b8,lefttrigger:a5,leftx:a0,lefty:a2,rightshoulder:b9,righttrigger:a4,start:b13,x:b0,y:b6,platform:Mac OS X, +03000000b40400000a01000000000000,Sega Saturn USB Gamepad,a:b0,b:b1,back:b5,guide:b2,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b8,x:b3,y:b4,platform:Mac OS X, +030000003512000021ab000000000000,SFC30 Joystick,a:b1,b:b0,back:b10,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b11,x:b4,y:b3,platform:Mac OS X, +0300000000f00000f100000000000000,SNES RetroPort,a:b2,b:b3,back:b4,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b5,rightshoulder:b7,start:b6,x:b0,y:b1,platform:Mac OS X, +030000004c050000cc09000000000000,Sony DualShock 4 V2,a:b1,b:b2,back:b13,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Mac OS X, +030000004c050000a00b000000000000,Sony DualShock 4 Wireless Adaptor,a:b1,b:b2,back:b13,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Mac OS X, +030000005e0400008e02000001000000,Steam Virtual Gamepad,a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b8,x:b2,y:b3,platform:Mac OS X, +03000000110100002014000000000000,SteelSeries Nimbus,a:b0,b:b1,dpdown:b9,dpleft:b11,dpright:b10,dpup:b8,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3,start:b12,x:b2,y:b3,platform:Mac OS X, +03000000110100002014000001000000,SteelSeries Nimbus,a:b0,b:b1,dpdown:b9,dpleft:b11,dpright:b10,dpup:b8,guide:b12,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1~,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3~,x:b2,y:b3,platform:Mac OS X, +03000000381000002014000001000000,SteelSeries Nimbus,a:b0,b:b1,dpdown:b9,dpleft:b11,dpright:b10,dpup:b8,guide:b12,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1~,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3~,x:b2,y:b3,platform:Mac OS X, +03000000110100001714000000000000,SteelSeries Stratus XL,a:b0,b:b1,dpdown:b9,dpleft:b11,dpright:b10,dpup:b8,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1~,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3~,start:b12,x:b2,y:b3,platform:Mac OS X, +03000000110100001714000020010000,SteelSeries Stratus XL,a:b0,b:b1,dpdown:b9,dpleft:b11,dpright:b10,dpup:b8,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1~,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3~,start:b12,x:b2,y:b3,platform:Mac OS X, +030000004f04000015b3000000000000,Thrustmaster Dual Analog 3.2,a:b0,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b1,y:b3,platform:Mac OS X, +030000004f04000000b3000000000000,Thrustmaster Firestorm Dual Power,a:b0,b:b2,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b11,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,righttrigger:b7,rightx:a2,righty:a3,start:b10,x:b1,y:b3,platform:Mac OS X, +03000000bd12000015d0000000000000,Tomee SNES USB Controller,a:b2,b:b1,back:b8,leftshoulder:b4,leftx:a0,lefty:a1,rightshoulder:b5,start:b9,x:b3,y:b0,platform:Mac OS X, +03000000bd12000015d0000000010000,Tomee SNES USB Controller,a:b2,b:b1,back:b8,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b4,rightshoulder:b5,start:b9,x:b3,y:b0,platform:Mac OS X, +03000000100800000100000000000000,Twin USB Joystick,a:b4,b:b2,back:b16,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b12,leftstick:b20,lefttrigger:b8,leftx:a0,lefty:a2,rightshoulder:b14,rightstick:b22,righttrigger:b10,rightx:a6,righty:a4,start:b18,x:b6,y:b0,platform:Mac OS X, +030000006f0e00000302000025040000,Victrix Pro Fight Stick for PS4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Mac OS X, +03000000791d00000103000009010000,Wii Classic Controller,a:b2,b:b1,back:b8,dpdown:b14,dpleft:b15,dpright:b13,dpup:b12,guide:b10,leftshoulder:b6,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:b5,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Mac OS X, +050000005769696d6f74652028303000,Wii Remote,a:b4,b:b5,back:b7,dpdown:b3,dpleft:b0,dpright:b1,dpup:b2,guide:b8,leftshoulder:b11,lefttrigger:b12,leftx:a0,lefty:a1,start:b6,x:b10,y:b9,platform:Mac OS X, +050000005769696d6f74652028313800,Wii U Pro Controller,a:b16,b:b15,back:b7,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b8,leftshoulder:b19,leftstick:b23,lefttrigger:b21,leftx:a0,lefty:a1,rightshoulder:b20,rightstick:b24,righttrigger:b22,rightx:a2,righty:a3,start:b6,x:b18,y:b17,platform:Mac OS X, +030000005e0400008e02000000000000,X360 Controller,a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b8,x:b2,y:b3,platform:Mac OS X, +03000000c6240000045d000000000000,Xbox 360 Wired Controller,a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b8,x:b2,y:b3,platform:Mac OS X, +030000005e0400000a0b000000000000,Xbox Adaptive Controller,a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b8,x:b2,y:b3,platform:Mac OS X, +030000005e040000d102000000000000,Xbox One Wired Controller,a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b8,x:b2,y:b3,platform:Mac OS X, +030000005e040000dd02000000000000,Xbox One Wired Controller,a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b8,x:b2,y:b3,platform:Mac OS X, +030000005e040000e302000000000000,Xbox One Wired Controller,a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b8,x:b2,y:b3,platform:Mac OS X, +030000005e040000e002000000000000,Xbox Wireless Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b8,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Mac OS X, +030000005e040000e002000003090000,Xbox Wireless Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b8,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Mac OS X, +030000005e040000ea02000000000000,Xbox Wireless Controller,a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b8,x:b2,y:b3,platform:Mac OS X, +030000005e040000fd02000003090000,Xbox Wireless Controller,a:b0,b:b1,back:b16,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b15,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Mac OS X, +03000000172700004431000029010000,XiaoMi Game Controller,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b15,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a6,rightx:a2,righty:a5,start:b11,x:b3,y:b4,platform:Mac OS X, +03000000120c0000100e000000010000,ZEROPLUS P4 Gamepad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Mac OS X, + +# Linux +05000000c82d00001038000000010000,8Bitdo FC30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Linux, +05000000c82d00005106000000010000,8BitDo M30,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b8,lefttrigger:b9,leftx:a0,lefty:a1,rightshoulder:b6,righttrigger:b7,start:b11,x:b3,y:b4,platform:Linux, +03000000c82d00001590000011010000,8BitDo N30 Pro 2,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Linux, +05000000c82d00006528000000010000,8BitDo N30 Pro 2,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Linux, +03000000c82d00000310000011010000,8BitDo NES30,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b7,lefttrigger:b6,rightshoulder:b9,righttrigger:b8,start:b11,x:b3,y:b4,platform:Linux, +05000000c82d00008010000000010000,8BitDo NES30,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b7,lefttrigger:b6,rightshoulder:b9,righttrigger:b8,start:b11,x:b3,y:b4,platform:Linux, +03000000022000000090000011010000,8Bitdo NES30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Linux, +05000000203800000900000000010000,8Bitdo NES30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Linux, +05000000c82d00002038000000010000,8Bitdo NES30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Linux, +03000000c82d00000190000011010000,8Bitdo NES30 Pro 8Bitdo NES30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a5,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Linux, +05000000c82d00000060000000010000,8BitDo SF30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Linux, +05000000c82d00000061000000010000,8Bitdo SF30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Linux, +03000000c82d000021ab000010010000,8BitDo SFC30,a:b1,b:b0,back:b10,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b11,x:b4,y:b3,platform:Linux, +030000003512000012ab000010010000,8Bitdo SFC30 GamePad,a:b2,b:b1,back:b6,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b4,rightshoulder:b5,start:b7,x:b3,y:b0,platform:Linux, +05000000102800000900000000010000,8Bitdo SFC30 GamePad,a:b1,b:b0,back:b10,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b11,x:b4,y:b3,platform:Linux, +05000000c82d00003028000000010000,8Bitdo SFC30 GamePad,a:b1,b:b0,back:b10,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b11,x:b4,y:b3,platform:Linux, +03000000c82d00000160000000000000,8BitDo SN30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b4,y:b3,platform:Linux, +03000000c82d00000160000011010000,8BitDo SN30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Linux, +03000000c82d00000161000000000000,8BitDo SN30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b4,y:b3,platform:Linux, +03000000c82d00001290000011010000,8BitDo SN30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b4,y:b3,platform:Linux, +05000000c82d00000161000000010000,8BitDo SN30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Linux, +05000000c82d00006228000000010000,8BitDo SN30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Linux, +03000000c82d00000260000011010000,8BitDo SN30 Pro+,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Linux, +05000000c82d00000261000000010000,8BitDo SN30 Pro+,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Linux, +030000005e0400008e02000020010000,8BitDo Wireless Adapter,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux, +03000000c82d00000031000011010000,8BitDo Wireless Adapter,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Linux, +05000000a00500003232000001000000,8Bitdo Zero GamePad,a:b0,b:b1,back:b10,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b11,x:b3,y:b4,platform:Linux, +05000000a00500003232000008010000,8Bitdo Zero GamePad,a:b0,b:b1,back:b10,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b6,rightshoulder:b7,start:b11,x:b3,y:b4,platform:Linux, +030000006f0e00001302000000010000,Afterglow,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux, +030000006f0e00003901000020060000,Afterglow Controller for Xbox One,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux, +030000006f0e00003901000000430000,Afterglow Prismatic Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux, +030000006f0e00003901000013020000,Afterglow Prismatic Wired Controller 048-007-NA,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux, +03000000100000008200000011010000,Akishop Customs PS360+ v1.66,a:b1,b:b2,back:b12,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Linux, +05000000491900000204000021000000,Amazon Fire Game Controller,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Linux, +05000000050b00000045000031000000,ASUS Gamepad,a:b0,b:b1,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b6,leftshoulder:b4,leftstick:b7,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b8,righttrigger:a4,rightx:a2,righty:a3,start:b10,x:b2,y:b3,platform:Linux, +05000000050b00000045000040000000,ASUS Gamepad,a:b0,b:b1,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b6,leftshoulder:b4,leftstick:b7,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b8,righttrigger:a4,rightx:a2,righty:a3,start:b10,x:b2,y:b3,platform:Linux, +03000000120c00000500000010010000,AxisPad,a:b2,b:b3,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b8,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:b7,rightx:a3,righty:a2,start:b11,x:b0,y:b1,platform:Linux, +03000000666600006706000000010000,boom PSX to PC Converter,a:b2,b:b1,back:b8,dpdown:b14,dpleft:b15,dpright:b13,dpup:b12,leftshoulder:b6,leftstick:b9,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b10,righttrigger:b5,rightx:a2,righty:a3,start:b11,x:b3,y:b0,platform:Linux, +03000000ffff0000ffff000000010000,Chinese-made Xbox Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b5,leftstick:b8,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b2,rightstick:b9,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b3,y:b4,platform:Linux, +03000000e82000006058000001010000,Cideko AK08b,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Linux, +030000000b0400003365000000010000,Competition Pro,a:b0,b:b1,back:b2,leftx:a0,lefty:a1,start:b3,platform:Linux, +03000000260900008888000000010000,Cyber Gadget GameCube Controller,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b6,righttrigger:a5,rightx:a2,righty:a3~,start:b7,x:b2,y:b3,platform:Linux, +03000000a306000022f6000011010000,Cyborg V.3 Rumble Pad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:+a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:-a3,rightx:a2,righty:a4,start:b9,x:b0,y:b3,platform:Linux, +03000000b40400000a01000000010000,CYPRESS USB Gamepad,a:b0,b:b1,back:b5,guide:b2,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b8,x:b3,y:b4,platform:Linux, +03000000790000000600000010010000,DragonRise Inc. Generic USB Joystick,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a3,righty:a4,start:b9,x:b3,y:b0,platform:Linux, +030000004f04000004b3000010010000,Dual Power 2,a:b0,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b1,y:b3,platform:Linux, +030000006f0e00003001000001010000,EA Sports PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux, +03000000341a000005f7000010010000,GameCube {HuiJia USB box},a:b1,b:b2,dpdown:b14,dpleft:b15,dpright:b13,dpup:b12,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:a4,rightx:a5,righty:a2,start:b9,x:b0,y:b3,platform:Linux, +03000000bc2000000055000011010000,GameSir G3w,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Linux, +0500000047532047616d657061640000,GameStop Gamepad,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Linux, +030000006f0e00000104000000010000,Gamestop Logic3 Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux, +030000008f0e00000800000010010000,Gasia Co. Ltd PS(R) Gamepad,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Linux, +030000006f0e00001304000000010000,Generic X-Box pad,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux, +03000000f0250000c183000010010000,Goodbetterbest Ltd USB Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux, +0300000079000000d418000000010000,GPD Win 2 Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux, +030000007d0400000540000000010000,Gravis Eliminator GamePad Pro,a:b1,b:b2,back:b8,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Linux, +03000000280400000140000000010000,Gravis GamePad Pro USB ,a:b1,b:b2,back:b8,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Linux, +030000008f0e00000610000000010000,GreenAsia Electronics 4Axes 12Keys GamePad ,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b9,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b10,righttrigger:b5,rightx:a3,righty:a2,start:b11,x:b3,y:b0,platform:Linux, +030000008f0e00001200000010010000,GreenAsia Inc. USB Joystick,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b2,y:b3,platform:Linux, +0500000047532067616d657061640000,GS gamepad,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Linux, +03000000f0250000c383000010010000,GT VX2,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Linux, +06000000adde0000efbe000002010000,Hidromancer Game Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux, +03000000d81400000862000011010000,HitBox (PS3/PC) Analog Mode,a:b1,b:b2,back:b8,guide:b9,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,start:b12,x:b0,y:b3,platform:Linux, +03000000c9110000f055000011010000,HJC Game GAMEPAD,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Linux, +030000000d0f00000d00000000010000,hori,a:b0,b:b6,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b3,leftx:b4,lefty:b5,rightshoulder:b7,start:b9,x:b1,y:b2,platform:Linux, +030000000d0f00001000000011010000,HORI CO. LTD. FIGHTING STICK 3,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Linux, +030000000d0f00006a00000011010000,HORI CO. LTD. Real Arcade Pro.4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux, +030000000d0f00006b00000011010000,HORI CO. LTD. Real Arcade Pro.4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux, +030000000d0f00002200000011010000,HORI CO. LTD. REAL ARCADE Pro.V3,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Linux, +030000000d0f00005f00000011010000,Hori Fighting Commander 4 (PS3),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux, +030000000d0f00005e00000011010000,Hori Fighting Commander 4 (PS4),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux, +03000000ad1b000001f5000033050000,Hori Pad EX Turbo 2,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux, +030000000d0f00009200000011010000,Hori Pokken Tournament DX Pro Pad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Linux, +030000000d0f00001600000000010000,Hori Real Arcade Pro.EX-SE (Xbox 360),a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b2,y:b3,platform:Linux, +030000000d0f00006e00000011010000,HORIPAD 4 (PS3),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux, +030000000d0f00006600000011010000,HORIPAD 4 (PS4),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux, +030000000d0f0000ee00000011010000,HORIPAD mini4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux, +030000000d0f00006700000001010000,HORIPAD ONE,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux, +030000008f0e00001330000010010000,HuiJia SNES Controller,a:b2,b:b1,back:b8,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b6,rightshoulder:b7,start:b9,x:b3,y:b0,platform:Linux, +03000000830500006020000010010000,iBuffalo SNES Controller,a:b1,b:b0,back:b6,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b4,rightshoulder:b5,start:b7,x:b3,y:b2,platform:Linux, +050000006964726f69643a636f6e0000,idroid:con,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux, +03000000b50700001503000010010000,impact,a:b2,b:b3,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b0,y:b1,platform:Linux, +03000000d80400008200000003000000,IMS PCU#0 Gamepad Interface,a:b1,b:b0,back:b4,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,start:b5,x:b3,y:b2,platform:Linux, +03000000fd0500000030000000010000,InterAct GoPad I-73000 (Fighting Game Layout),a:b3,b:b4,back:b6,leftx:a0,lefty:a1,rightshoulder:b2,righttrigger:b5,start:b7,x:b0,y:b1,platform:Linux, +0500000049190000020400001b010000,Ipega PG-9069 - Bluetooth Gamepad,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b161,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Linux, +030000006e0500000320000010010000,JC-U3613M - DirectInput Mode,a:b2,b:b3,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b8,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:b7,rightx:a2,righty:a3,start:b11,x:b0,y:b1,platform:Linux, +03000000300f00001001000010010000,Jess Tech Dual Analog Rumble Pad,a:b2,b:b3,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b0,y:b1,platform:Linux, +03000000300f00000b01000010010000,Jess Tech GGE909 PC Recoil Pad,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b3,y:b0,platform:Linux, +03000000ba2200002010000001010000,Jess Technology USB Game Controller,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b3,y:b0,platform:Linux, +030000007e0500000620000001000000,Joy-Con (L),+leftx:h0.2,+lefty:h0.4,-leftx:h0.8,-lefty:h0.1,a:b0,b:b1,back:b13,leftshoulder:b4,leftstick:b10,rightshoulder:b5,start:b8,x:b2,y:b3,platform:Linux, +050000007e0500000620000001000000,Joy-Con (L),+leftx:h0.2,+lefty:h0.4,-leftx:h0.8,-lefty:h0.1,a:b0,b:b1,back:b13,leftshoulder:b4,leftstick:b10,rightshoulder:b5,start:b8,x:b2,y:b3,platform:Linux, +030000007e0500000720000001000000,Joy-Con (R),+leftx:h0.2,+lefty:h0.4,-leftx:h0.8,-lefty:h0.1,a:b0,b:b1,back:b12,leftshoulder:b4,leftstick:b11,rightshoulder:b5,start:b9,x:b2,y:b3,platform:Linux, +050000007e0500000720000001000000,Joy-Con (R),+leftx:h0.2,+lefty:h0.4,-leftx:h0.8,-lefty:h0.1,a:b0,b:b1,back:b12,leftshoulder:b4,leftstick:b11,rightshoulder:b5,start:b9,x:b2,y:b3,platform:Linux, +030000006f0e00000103000000020000,Logic3 Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux, +030000006d04000019c2000010010000,Logitech Cordless RumblePad 2,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux, +030000006d04000016c2000010010000,Logitech Dual Action,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux, +030000006d04000016c2000011010000,Logitech Dual Action,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux, +030000006d0400001dc2000014400000,Logitech F310 Gamepad (XInput),a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux, +030000006d0400001ec2000020200000,Logitech F510 Gamepad (XInput),a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux, +030000006d04000019c2000011010000,Logitech F710 Gamepad (DInput),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux, +030000006d0400001fc2000005030000,Logitech F710 Gamepad (XInput),a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux, +030000006d0400000ac2000010010000,Logitech Inc. WingMan RumblePad,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:b2,rightx:a3,righty:a4,x:b3,y:b4,platform:Linux, +030000006d04000015c2000010010000,Logitech Logitech Extreme 3D,a:b0,b:b4,back:b6,guide:b8,leftshoulder:b9,leftstick:h0.8,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:h0.2,start:b7,x:b2,y:b5,platform:Linux, +030000006d04000018c2000010010000,Logitech RumblePad 2,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux, +030000006d04000011c2000010010000,Logitech WingMan Cordless RumblePad,a:b0,b:b1,back:b2,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b5,leftshoulder:b6,lefttrigger:b9,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:b10,rightx:a3,righty:a4,start:b8,x:b3,y:b4,platform:Linux, +05000000380700006652000025010000,Mad Catz C.T.R.L.R ,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux, +03000000380700005032000011010000,Mad Catz FightPad PRO (PS3),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux, +03000000380700005082000011010000,Mad Catz FightPad PRO (PS4),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux, +03000000ad1b00002ef0000090040000,Mad Catz Fightpad SFxT,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,lefttrigger:a2,rightshoulder:b5,righttrigger:a5,start:b7,x:b2,y:b3,platform:Linux, +03000000380700008034000011010000,Mad Catz fightstick (PS3),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux, +03000000380700008084000011010000,Mad Catz fightstick (PS4),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux, +03000000380700008433000011010000,Mad Catz FightStick TE S+ (PS3),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux, +03000000380700008483000011010000,Mad Catz FightStick TE S+ (PS4),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux, +03000000380700001647000010040000,Mad Catz Wired Xbox 360 Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux, +03000000380700003847000090040000,Mad Catz Wired Xbox 360 Controller (SFIV),a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Linux, +03000000ad1b000016f0000090040000,Mad Catz Xbox 360 Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux, +03000000380700001888000010010000,MadCatz PC USB Wired Stick 8818,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux, +03000000380700003888000010010000,MadCatz PC USB Wired Stick 8838,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:a0,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux, +03000000120c00000500000000010000,Manta Dualshock 2,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b2,y:b3,platform:Linux, +03000000790000004418000010010000,Mayflash GameCube Controller,a:b1,b:b2,dpdown:b14,dpleft:b15,dpright:b13,dpup:b12,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:a4,rightx:a5,righty:a2,start:b9,x:b0,y:b3,platform:Linux, +03000000790000004318000010010000,Mayflash GameCube Controller Adapter,a:b1,b:b0,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:a4,rightx:a5,righty:a2,start:b9,x:b2,y:b3,platform:Linux, +03000000242f00007300000011010000,Mayflash Magic NS,a:b1,b:b4,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:b8,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b0,y:b3,platform:Linux, +0300000079000000d218000011010000,Mayflash Magic NS,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux, +03000000d620000010a7000011010000,Mayflash Magic NS,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux, +0300000025090000e803000001010000,Mayflash Wii Classic Controller,a:b1,b:b0,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:a4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:a5,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b2,platform:Linux, +03000000780000000600000010010000,Microntek USB Joystick,a:b2,b:b1,back:b8,leftshoulder:b6,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:b5,start:b9,x:b3,y:b0,platform:Linux, +030000005e0400000e00000000010000,Microsoft SideWinder,a:b0,b:b1,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,rightshoulder:b7,start:b8,x:b3,y:b4,platform:Linux, +030000005e0400008e02000004010000,Microsoft X-Box 360 pad,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux, +030000005e0400008e02000062230000,Microsoft X-Box 360 pad,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux, +030000005e040000e302000003020000,Microsoft X-Box One Elite pad,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux, +030000005e040000d102000001010000,Microsoft X-Box One pad,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux, +050000005e040000050b000003090000,Microsoft X-Box One Elite 2 pad,a:b0,b:b1,y:b4,x:b3,start:b11,guide:b12,back:b17,leftstick:b13,rightstick:b14,leftshoulder:b6,rightshoulder:b7,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a5,righttrigger:a4,platform:Linux, +030000005e040000dd02000003020000,Microsoft X-Box One pad (Firmware 2015),a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux, +030000005e040000d102000003020000,Microsoft X-Box One pad v2,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux, +030000005e0400008502000000010000,Microsoft X-Box pad (Japan),a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b5,leftstick:b8,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b2,rightstick:b9,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b3,y:b4,platform:Linux, +030000005e0400008902000021010000,Microsoft X-Box pad v2 (US),a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b5,leftstick:b8,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b2,rightstick:b9,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b3,y:b4,platform:Linux, +03000000c62400001a53000000010000,Mini PE,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux, +03000000030000000300000002000000,Miroof,a:b1,b:b0,back:b6,leftshoulder:b4,leftx:a0,lefty:a1,rightshoulder:b5,start:b7,x:b3,y:b2,platform:Linux, +05000000d6200000e589000001000000,Moga 2 HID,a:b0,b:b1,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b7,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b8,righttrigger:a4,rightx:a2,righty:a3,start:b6,x:b2,y:b3,platform:Linux, +05000000d6200000ad0d000001000000,Moga Pro,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b7,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b8,righttrigger:a4,rightx:a2,righty:a3,start:b6,x:b2,y:b3,platform:Linux, +05000000d62000007162000001000000,Moga Pro 2 HID,a:b0,b:b1,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b7,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b8,righttrigger:a4,rightx:a2,righty:a3,start:b6,x:b2,y:b3,platform:Linux, +03000000250900006688000000010000,MP-8866 Super Dual Box,a:b2,b:b1,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a2,righty:a3,start:b8,x:b3,y:b0,platform:Linux, +030000000d0f00000900000010010000,Natec Genesis P44,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux, +030000001008000001e5000010010000,NEXT SNES Controller,a:b2,b:b1,back:b8,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b4,rightshoulder:b6,start:b9,x:b3,y:b0,platform:Linux, +030000007e0500003703000000016800,Nintendo GameCube Controller,a:b0,b:b2,dpdown:b6,dpleft:b4,dpright:b5,dpup:b7,lefttrigger:a4,leftx:a0,lefty:a1~,rightshoulder:b9,righttrigger:a5,rightx:a2,righty:a3~,start:b8,x:b1,y:b3,platform:Linux, +050000007e0500000920000001000000,Nintendo Switch Pro Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Linux, +050000007e0500003003000001000000,Nintendo Wii Remote Pro Controller,a:b0,b:b1,back:b8,dpdown:b14,dpleft:b15,dpright:b16,dpup:b13,guide:b10,leftshoulder:b4,leftstick:b11,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b12,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b2,platform:Linux, +05000000010000000100000003000000,Nintendo Wiimote,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b11,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b12,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Linux, +030000000d0500000308000010010000,Nostromo n45 Dual Analog Gamepad,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b9,leftshoulder:b4,leftstick:b12,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b10,x:b2,y:b3,platform:Linux, +03000000550900001072000011010000,NVIDIA Controller,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b13,leftshoulder:b4,leftstick:b8,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:a4,rightx:a2,righty:a3,start:b7,x:b2,y:b3,platform:Linux, +03000000550900001472000011010000,NVIDIA Controller v01.04,a:b0,b:b1,back:b14,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b16,leftshoulder:b4,leftstick:b7,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b8,righttrigger:a4,rightx:a2,righty:a5,start:b6,x:b2,y:b3,platform:Linux, +05000000550900001472000001000000,NVIDIA Controller v01.04,a:b0,b:b1,back:b14,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b16,leftshoulder:b4,leftstick:b7,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b8,righttrigger:a4,rightx:a2,righty:a5,start:b6,x:b2,y:b3,platform:Linux, +03000000451300000830000010010000,NYKO CORE,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux, +030000005e0400000202000000010000,Old Xbox pad,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b5,leftstick:b8,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b2,rightstick:b9,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b3,y:b4,platform:Linux, +05000000362800000100000002010000,OUYA Game Controller,a:b0,b:b3,dpdown:b9,dpleft:b10,dpright:b11,dpup:b8,guide:b14,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,x:b1,y:b2,platform:Linux, +05000000362800000100000003010000,OUYA Game Controller,a:b0,b:b3,dpdown:b9,dpleft:b10,dpright:b11,dpup:b8,guide:b14,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,x:b1,y:b2,platform:Linux, +03000000ff1100003133000010010000,PC Game Controller,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Linux, +030000006f0e00006401000001010000,PDP Battlefield One,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux, +030000006f0e0000a802000023020000,PDP Wired Controller for Xbox One,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b11,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b12,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Linux, +030000004c050000da0c000011010000,Playstation Controller,a:b2,b:b1,back:b8,leftshoulder:b6,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:b5,start:b9,x:b3,y:b0,platform:Linux, +03000000c62400000053000000010000,PowerA,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux, +03000000c62400003a54000001010000,PowerA 1428124-01,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux, +03000000d62000006dca000011010000,PowerA Pro Ex,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux, +030000006d040000d2ca000011010000,Precision Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux, +03000000ff1100004133000010010000,PS2 Controller,a:b2,b:b1,back:b8,leftshoulder:b6,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:b5,start:b9,x:b3,y:b0,platform:Linux, +03000000341a00003608000011010000,PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux, +030000004c0500006802000010010000,PS3 Controller,a:b14,b:b13,back:b0,dpdown:b6,dpleft:b7,dpright:b5,dpup:b4,guide:b16,leftshoulder:b10,leftstick:b1,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b11,rightstick:b2,righttrigger:b9,rightx:a2,righty:a3,start:b3,x:b15,y:b12,platform:Linux, +030000004c0500006802000010810000,PS3 Controller,a:b0,b:b1,back:b8,dpdown:b14,dpleft:b15,dpright:b16,dpup:b13,guide:b10,leftshoulder:b4,leftstick:b11,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b12,righttrigger:a5,rightx:a3,righty:a4,start:b9,x:b3,y:b2,platform:Linux, +030000004c0500006802000011010000,PS3 Controller,a:b14,b:b13,back:b0,dpdown:b6,dpleft:b7,dpright:b5,dpup:b4,guide:b16,leftshoulder:b10,leftstick:b1,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b11,rightstick:b2,righttrigger:b9,rightx:a2,righty:a3,start:b3,x:b15,y:b12,platform:Linux, +030000004c0500006802000011810000,PS3 Controller,a:b0,b:b1,back:b8,dpdown:b14,dpleft:b15,dpright:b16,dpup:b13,guide:b10,leftshoulder:b4,leftstick:b11,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b12,righttrigger:a5,rightx:a3,righty:a4,start:b9,x:b3,y:b2,platform:Linux, +030000006f0e00001402000011010000,PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux, +030000008f0e00000300000010010000,PS3 Controller,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Linux, +050000004c0500006802000000010000,PS3 Controller,a:b14,b:b13,back:b0,dpdown:b6,dpleft:b7,dpright:b5,dpup:b4,guide:b16,leftshoulder:b10,leftstick:b1,lefttrigger:a12,leftx:a0,lefty:a1,rightshoulder:b11,rightstick:b2,righttrigger:a13,rightx:a2,righty:a3,start:b3,x:b15,y:b12,platform:Linux, +050000004c0500006802000000800000,PS3 Controller,a:b0,b:b1,back:b8,dpdown:b14,dpleft:b15,dpright:b16,dpup:b13,guide:b10,leftshoulder:b4,leftstick:b11,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b12,righttrigger:a5,rightx:a3,righty:a4,start:b9,x:b3,y:b2,platform:Linux, +050000004c0500006802000000810000,PS3 Controller,a:b0,b:b1,back:b8,dpdown:b14,dpleft:b15,dpright:b16,dpup:b13,guide:b10,leftshoulder:b4,leftstick:b11,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b12,righttrigger:a5,rightx:a3,righty:a4,start:b9,x:b3,y:b2,platform:Linux, +05000000504c415953544154494f4e00,PS3 Controller,a:b14,b:b13,back:b0,dpdown:b6,dpleft:b7,dpright:b5,dpup:b4,guide:b16,leftshoulder:b10,leftstick:b1,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b11,rightstick:b2,righttrigger:b9,rightx:a2,righty:a3,start:b3,x:b15,y:b12,platform:Linux, +060000004c0500006802000000010000,PS3 Controller,a:b14,b:b13,back:b0,dpdown:b6,dpleft:b7,dpright:b5,dpup:b4,guide:b16,leftshoulder:b10,leftstick:b1,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b11,rightstick:b2,righttrigger:b9,rightx:a2,righty:a3,start:b3,x:b15,y:b12,platform:Linux, +030000004c050000a00b000011010000,PS4 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux, +030000004c050000a00b000011810000,PS4 Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b11,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b12,righttrigger:a5,rightx:a3,righty:a4,start:b9,x:b3,y:b2,platform:Linux, +030000004c050000c405000011010000,PS4 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux, +030000004c050000c405000011810000,PS4 Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b11,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b12,righttrigger:a5,rightx:a3,righty:a4,start:b9,x:b3,y:b2,platform:Linux, +030000004c050000cc09000000010000,PS4 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux, +030000004c050000cc09000011010000,PS4 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux, +030000004c050000cc09000011810000,PS4 Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b11,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b12,righttrigger:a5,rightx:a3,righty:a4,start:b9,x:b3,y:b2,platform:Linux, +03000000c01100000140000011010000,PS4 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux, +050000004c050000c405000000010000,PS4 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux, +050000004c050000c405000000810000,PS4 Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b11,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b12,righttrigger:a5,rightx:a3,righty:a4,start:b9,x:b3,y:b2,platform:Linux, +050000004c050000cc09000000010000,PS4 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux, +050000004c050000cc09000000810000,PS4 Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b11,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b12,righttrigger:a5,rightx:a3,righty:a4,start:b9,x:b3,y:b2,platform:Linux, +050000004c050000cc09000001800000,PS4 Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b11,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b12,righttrigger:a5,rightx:a3,righty:a4,start:b9,x:b3,y:b2,platform:Linux, +03000000300f00001211000011010000,QanBa Arcade JoyStick,a:b2,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b5,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:b6,start:b9,x:b1,y:b3,platform:Linux, +030000009b2800000300000001010000,raphnet.net 4nes4snes v1.5,a:b0,b:b4,back:b2,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b3,x:b1,y:b5,platform:Linux, +030000008916000001fd000024010000,Razer Onza Classic Edition,a:b0,b:b1,back:b6,dpdown:b14,dpleft:b11,dpright:b12,dpup:b13,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux, +030000008916000000fd000024010000,Razer Onza Tournament Edition,a:b0,b:b1,back:b6,dpdown:b14,dpleft:b11,dpright:b12,dpup:b13,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux, +03000000321500000204000011010000,Razer Panthera (PS3),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux, +03000000321500000104000011010000,Razer Panthera (PS4),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux, +03000000321500000010000011010000,Razer RAIJU,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux, +03000000321500000507000000010000,Razer Raiju Mobile,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b21,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Linux, +030000008916000000fe000024010000,Razer Sabertooth,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux, +03000000c6240000045d000024010000,Razer Sabertooth,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux, +03000000c6240000045d000025010000,Razer Sabertooth,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux, +03000000321500000009000011010000,Razer Serval,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a4,rightx:a2,righty:a3,start:b7,x:b2,y:b3,platform:Linux, +050000003215000000090000163a0000,Razer Serval,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a4,rightx:a2,righty:a3,start:b7,x:b2,y:b3,platform:Linux, +0300000032150000030a000001010000,Razer Wildcat,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux, +03000000790000001100000010010000,Retrolink SNES Controller,a:b2,b:b1,back:b8,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b4,rightshoulder:b5,start:b9,x:b3,y:b0,platform:Linux, +0300000081170000990a000001010000,Retronic Adapter,a:b0,leftx:a0,lefty:a1,platform:Linux, +0300000000f000000300000000010000,RetroPad,a:b1,b:b5,back:b2,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b3,x:b0,y:b4,platform:Linux, +030000006b140000010d000011010000,Revolution Pro Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux, +030000006f0e00001f01000000010000,Rock Candy,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux, +030000006f0e00001e01000011010000,Rock Candy PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux, +030000006f0e00004601000001010000,Rock Candy Xbox One Controller,a:b0,b:b1,back:b6,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux, +03000000a306000023f6000011010000,Saitek Cyborg V.1 Game Pad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a4,start:b9,x:b0,y:b3,platform:Linux, +03000000a30600000cff000010010000,Saitek P2500 Force Rumble Pad,a:b2,b:b3,back:b11,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b8,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:b7,rightx:a3,righty:a2,x:b0,y:b1,platform:Linux, +03000000a30600000c04000011010000,Saitek P2900 Wireless Pad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b9,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a3,righty:a2,start:b12,x:b0,y:b3,platform:Linux, +03000000300f00001201000010010000,Saitek P380,a:b2,b:b3,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a1,righty:a2,start:b9,x:b0,y:b1,platform:Linux, +03000000a30600000901000000010000,Saitek P880,a:b2,b:b3,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b8,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:b7,rightx:a3,righty:a2,x:b0,y:b1,platform:Linux, +03000000a30600000b04000000010000,Saitek P990 Dual Analog Pad,a:b1,b:b2,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b8,x:b0,y:b3,platform:Linux, +03000000a306000018f5000010010000,Saitek PLC Saitek P3200 Rumble Pad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a3,righty:a4,start:b9,x:b0,y:b3,platform:Linux, +03000000d81d00000e00000010010000,Savior,a:b0,b:b1,back:b8,leftshoulder:b6,leftstick:b10,lefttrigger:b7,leftx:a0,lefty:a1,rightshoulder:b2,rightstick:b11,righttrigger:b3,start:b9,x:b4,y:b5,platform:Linux, +03000000c01600008704000011010000,Serial/Keyboard/Mouse/Joystick,a:b12,b:b10,back:b4,dpdown:b2,dpleft:b3,dpright:b1,dpup:b0,leftshoulder:b9,leftstick:b14,lefttrigger:b6,leftx:a1,lefty:a0,rightshoulder:b8,rightstick:b15,righttrigger:b7,rightx:a2,righty:a3,start:b5,x:b13,y:b11,platform:Linux, +03000000f025000021c1000010010000,ShanWan Gioteck PS3 Wired Controller,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Linux, +03000000632500007505000010010000,SHANWAN PS3/PC Gamepad,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Linux, +03000000bc2000000055000010010000,ShanWan PS3/PC Wired GamePad,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Linux, +03000000632500002305000010010000,ShanWan USB Gamepad,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Linux, +03000000341a00000908000010010000,SL-6566,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Linux, +03000000250900000500000000010000,Sony PS2 pad with SmartJoy adapter,a:b2,b:b1,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a2,righty:a3,start:b8,x:b3,y:b0,platform:Linux, +030000005e0400008e02000073050000,Speedlink TORID Wireless Gamepad,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux, +030000005e0400008e02000020200000,SpeedLink XEOX Pro Analog Gamepad pad,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux, +03000000de2800000112000001000000,Steam Controller,a:b0,b:b1,back:b6,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a3,start:b7,x:b2,y:b3,platform:Linux, +03000000de2800000211000001000000,Steam Controller,a:b0,b:b1,back:b6,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a3,start:b7,x:b2,y:b3,platform:Linux, +03000000de2800004211000001000000,Steam Controller,a:b0,b:b1,back:b6,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a3,start:b7,x:b2,y:b3,platform:Linux, +03000000de280000fc11000001000000,Steam Controller,a:b0,b:b1,back:b6,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux, +05000000de2800000212000001000000,Steam Controller,a:b0,b:b1,back:b6,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a3,start:b7,x:b2,y:b3,platform:Linux, +05000000de2800000511000001000000,Steam Controller,a:b0,b:b1,back:b6,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a3,start:b7,x:b2,y:b3,platform:Linux, +05000000de2800000611000001000000,Steam Controller,a:b0,b:b1,back:b6,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a3,start:b7,x:b2,y:b3,platform:Linux, +03000000de280000ff11000001000000,Steam Virtual Gamepad,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux, +03000000381000003014000075010000,SteelSeries Stratus Duo,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux, +03000000381000003114000075010000,SteelSeries Stratus Duo,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux, +03000000ad1b000038f0000090040000,Street Fighter IV FightStick TE,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux, +03000000666600000488000000010000,Super Joy Box 5 Pro,a:b2,b:b1,back:b9,dpdown:b14,dpleft:b15,dpright:b13,dpup:b12,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a2,righty:a3,start:b8,x:b3,y:b0,platform:Linux, +0300000000f00000f100000000010000,Super RetroPort,a:b1,b:b5,back:b2,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b3,x:b0,y:b4,platform:Linux, +030000004f04000020b3000010010000,Thrustmaster 2 in 1 DT,a:b0,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b1,y:b3,platform:Linux, +030000004f04000015b3000010010000,Thrustmaster Dual Analog 4,a:b0,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b1,y:b3,platform:Linux, +030000004f04000023b3000000010000,Thrustmaster Dual Trigger 3-in-1,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux, +030000004f04000000b3000010010000,Thrustmaster Firestorm Dual Power,a:b0,b:b2,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b11,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b12,righttrigger:b7,rightx:a2,righty:a3,start:b10,x:b1,y:b3,platform:Linux, +030000004f04000026b3000002040000,Thrustmaster Gamepad GP XID,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux, +03000000c6240000025b000002020000,Thrustmaster GPX Gamepad,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux, +030000004f04000008d0000000010000,Thrustmaster Run N Drive Wireless,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux, +030000004f04000009d0000000010000,Thrustmaster Run N Drive Wireless PS3,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux, +030000004f04000012b3000010010000,Thrustmaster vibrating gamepad,a:b0,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b1,y:b3,platform:Linux, +03000000bd12000015d0000010010000,Tomee SNES USB Controller,a:b2,b:b1,back:b8,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b4,rightshoulder:b5,start:b9,x:b3,y:b0,platform:Linux, +03000000d814000007cd000011010000,Toodles 2008 Chimp PC/PS3,a:b0,b:b1,back:b8,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,start:b9,x:b3,y:b2,platform:Linux, +030000005e0400008e02000070050000,Torid,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux, +03000000c01100000591000011010000,Torid,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Linux, +03000000100800000100000010010000,Twin USB PS2 Adapter,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a3,righty:a2,start:b9,x:b3,y:b0,platform:Linux, +03000000100800000300000010010000,USB Gamepad,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a3,righty:a2,start:b9,x:b3,y:b0,platform:Linux, +03000000790000000600000007010000,USB gamepad,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a3,righty:a4,start:b9,x:b3,y:b0,platform:Linux, +03000000790000001100000000010000,USB Gamepad1,a:b2,b:b1,back:b8,dpdown:a0,dpleft:a1,dpright:a2,dpup:a4,start:b9,platform:Linux, +030000006f0e00000302000011010000,Victrix Pro Fight Stick for PS4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Linux, +05000000ac0500003232000001000000,VR-BOX,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a3,righty:a2,start:b9,x:b2,y:b3,platform:Linux, +03000000791d00000103000010010000,Wii Classic Controller,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b6,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:b5,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Linux, +030000005e0400008e02000010010000,X360 Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux, +030000005e0400008e02000014010000,X360 Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux, +030000005e0400001907000000010000,X360 Wireless Controller,a:b0,b:b1,back:b6,dpdown:b14,dpleft:b11,dpright:b12,dpup:b13,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux, +030000005e0400009102000007010000,X360 Wireless Controller,a:b0,b:b1,back:b6,dpdown:b14,dpleft:b11,dpright:b12,dpup:b13,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux, +030000005e040000a102000000010000,X360 Wireless Controller,a:b0,b:b1,back:b6,dpdown:b14,dpleft:b11,dpright:b12,dpup:b13,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux, +030000005e040000a102000007010000,X360 Wireless Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux, +0000000058626f782033363020576900,Xbox 360 Wireless Controller,a:b0,b:b1,back:b14,dpdown:b11,dpleft:b12,dpright:b13,dpup:b10,guide:b7,leftshoulder:b4,leftstick:b8,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:a5,rightx:a3,righty:a4,start:b6,x:b2,y:b3,platform:Linux, +030000005e040000a102000014010000,Xbox 360 Wireless Receiver (XBOX),a:b0,b:b1,back:b6,dpdown:b14,dpleft:b11,dpright:b12,dpup:b13,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux, +0000000058626f782047616d65706100,Xbox Gamepad (userspace driver),a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a4,rightx:a2,righty:a3,start:b7,x:b2,y:b3,platform:Linux, +030000005e040000d102000002010000,Xbox One Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux, +050000005e040000fd02000030110000,Xbox One Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux, +050000005e040000e002000003090000,Xbox One Wireless Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b8,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux, +050000005e040000fd02000003090000,Xbox One Wireless Controller,a:b0,b:b1,back:b15,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b16,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Linux, +030000005e040000ea02000001030000,Xbox One Wireless Controller (Model 1708),a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux, +03000000450c00002043000010010000,XEOX Gamepad SL-6556-BK,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Linux, +05000000172700004431000029010000,XiaoMi Game Controller,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b20,leftshoulder:b6,leftstick:b13,lefttrigger:a7,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a6,rightx:a2,righty:a5,start:b11,x:b3,y:b4,platform:Linux, +03000000c0160000e105000001010000,Xin-Mo Xin-Mo Dual Arcade,a:b4,b:b3,back:b6,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b9,leftshoulder:b2,leftx:a0,lefty:a1,rightshoulder:b5,start:b7,x:b1,y:b0,platform:Linux, +xinput,XInput Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux, +03000000120c0000100e000011010000,ZEROPLUS P4 Gamepad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux, + +# Android +05000000bc20000000550000ffff3f00,GameSir G3w,a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,leftshoulder:b9,leftstick:b7,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a4,rightx:a2,righty:a3,start:b6,x:b2,y:b3,platform:Android, +05000000d6020000e5890000dfff3f00,GPD XD Plus,a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,leftshoulder:b9,leftstick:b7,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a4,rightx:a2,righty:a5,start:b6,x:b2,y:b3,platform:Android, +64633436313965656664373634323364,Microsoft X-Box 360 pad,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,x:b2,y:b3,platform:Android, +050000007e05000009200000ffff0f00,Nintendo Switch Pro Controller,a:b0,b:b1,back:b15,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b5,leftshoulder:b3,leftstick:b4,lefttrigger:b9,leftx:a0,lefty:a1,rightshoulder:b18,rightstick:b6,righttrigger:b10,rightx:a2,righty:a3,start:b16,x:b17,y:b2,platform:Android, +37336435666338653565313731303834,NVIDIA Controller,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b2,y:b3,platform:Android, +4e564944494120436f72706f72617469,NVIDIA Controller,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b2,y:b3,platform:Android, +61363931656135336130663561616264,NVIDIA Controller,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b2,y:b3,platform:Android, +050000005509000003720000cf7f3f00,NVIDIA Controller v01.01,a:b0,b:b1,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b2,y:b3,platform:Android, +050000005509000010720000ffff3f00,NVIDIA Controller v01.03,a:b0,b:b1,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b2,y:b3,platform:Android, +050000004c05000068020000dfff3f00,PS3 Controller,a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b2,y:b3,platform:Android, +050000004c050000c4050000fffe3f00,PS4 Controller,a:b1,b:b17,back:b15,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b5,leftshoulder:b3,leftstick:b4,lefttrigger:+a3,leftx:a0,lefty:a1,rightshoulder:b18,rightstick:b6,righttrigger:+a4,rightx:a2,righty:a5,start:b16,x:b0,y:b2,platform:Android, +050000004c050000cc090000fffe3f00,PS4 Controller,a:b1,b:b17,back:b15,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b5,leftshoulder:b3,leftstick:b4,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b18,rightstick:b6,righttrigger:a4,rightx:a2,righty:a5,start:b16,x:b0,y:b2,platform:Android, +35643031303033326130316330353564,PS4 Controller,a:b1,b:b17,back:b15,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b5,leftshoulder:b3,leftstick:b4,lefttrigger:+a3,leftx:a0,lefty:a1,rightshoulder:b18,rightstick:b6,righttrigger:+a4,rightx:a2,righty:a5,start:b16,x:b0,y:b2,platform:Android, +050000003215000005070000ffff3f00,Razer Raiju Mobile,a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b2,y:b3,platform:Android, +050000003215000007070000ffff3f00,Razer Raiju Mobile,a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b2,y:b3,platform:Android, +050000003215000000090000bf7f3f00,Razer Serval,a:b0,b:b1,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b5,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,x:b2,y:b3,platform:Android, +05000000de2800000511000001000000,Steam Controller,a:b0,b:b1,back:b6,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a3,start:b7,x:b2,y:b3,platform:Android, +05000000de2800000611000001000000,Steam Controller,a:b0,b:b1,back:b6,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a3,start:b7,x:b2,y:b3,platform:Android, +5477696e20555342204a6f7973746963,Twin USB Joystick,a:b22,b:b21,back:b28,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b26,leftstick:b30,lefttrigger:b24,leftx:a0,lefty:a1,rightshoulder:b27,rightstick:b31,righttrigger:b25,rightx:a3,righty:a2,start:b29,x:b23,y:b20,platform:Android, +050000005e040000e00200000ffe3f00,Xbox One Wireless Controller,a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,leftshoulder:b3,leftstick:b15,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b18,rightstick:b16,righttrigger:a5,rightx:a3,righty:a4,start:b10,x:b17,y:b2,platform:Android, +050000005e040000fd020000ffff3f00,Xbox One Wireless Controller,a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,leftshoulder:b9,leftstick:b7,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a4,rightx:a2,righty:a3,start:b6,x:b2,y:b3,platform:Android, +050000005e04000091020000ff073f00,Xbox Wireless Controller,a:b0,b:b1,back:b4,guide:b5,leftshoulder:b9,leftstick:b7,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a3,righty:a4,start:b6,x:b2,y:b3,platform:Android, +34356136633366613530316338376136,Xbox Wireless Controller,a:b0,b:b1,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b3,leftstick:b15,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b18,rightstick:b16,righttrigger:a5,rightx:a3,righty:a4,x:b17,y:b2,platform:Android, + +# iOS +05000000ac0500000100000000006d01,*,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b6,leftshoulder:b4,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a5,rightx:a3,righty:a4,x:b2,y:b3,platform:iOS, +05000000ac050000010000004f066d01,*,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b6,leftshoulder:b4,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a5,rightx:a3,righty:a4,x:b2,y:b3,platform:iOS, +05000000ac05000001000000cf076d01,*,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,x:b2,y:b3,platform:iOS, +05000000ac0500000200000000006d02,*,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b6,leftshoulder:b4,rightshoulder:b5,x:b2,y:b3,platform:iOS, +05000000ac050000020000004f066d02,*,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b6,leftshoulder:b4,rightshoulder:b5,x:b2,y:b3,platform:iOS, +050000004c050000cc090000df070000,DUALSHOCK 4 Wireless Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b9,x:b2,y:b3,platform:iOS, +4d466947616d65706164010000000000,MFi Extended Gamepad,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a5,rightx:a3,righty:a4,start:b6,x:b2,y:b3,platform:iOS, +4d466947616d65706164020000000000,MFi Gamepad,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,rightshoulder:b5,start:b6,x:b2,y:b3,platform:iOS, +05000000ac0500000300000000006d03,Remote,a:b0,b:b2,leftx:a0,lefty:a1,platform:iOS, +05000000ac0500000300000043006d03,Remote,a:b0,b:b2,leftx:a0,lefty:a1,platform:iOS, +05000000de2800000511000001000000,Steam Controller,a:b0,b:b1,back:b6,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a3,start:b7,x:b2,y:b3,platform:iOS, +05000000de2800000611000001000000,Steam Controller,a:b0,b:b1,back:b6,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a3,start:b7,x:b2,y:b3,platform:iOS, +050000005e040000e0020000df070000,Xbox Wireless Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b9,x:b2,y:b3,platform:iOS, diff --git a/engine/graphics/animation.lua b/engine/graphics/animation.lua new file mode 100644 index 0000000..69cd546 --- /dev/null +++ b/engine/graphics/animation.lua @@ -0,0 +1,141 @@ +-- The class responsible for holding an animation's graphics. +-- It takes in an already loaded image, the width and height of each frames, and a list of frames in terms of indexed position on the image. +-- player_sheet = Image('player_sheet') +-- player_idle_frames = AnimationFrames(player_sheet, 32, 32, {{1, 1}, {2, 1}}) +-- player_run_frames = AnimationFrames(player_sheet, 32, 32, {{1, 2}, {2, 2}, {3, 2}}) +-- player_attack_frames = AnimationFrames(player_sheet, 32, 32, {{1, 3}, {2, 3}, {3, 3}, {4, 3}}) +-- +-- In the example above we first load an image, and then load 3 player animations. +-- Each animation comes from different rows in the same spritesheet, and that's reflected by the last argument in each call. +-- If your animation comes from a single spritesheet that doesn't have multiple animations, then you can omit the last argument and it will automatically go through it. +AnimationFrames = Object:extend() +function AnimationFrames:init(image, frame_w, frame_h, frames_list) + self.source = image + self.frame_w, self.frame_h = frame_w, frame_h + self.frames_list = frames_list + + if type(self.frames_list) == 'number' then -- the source is a single row spritesheet and number of frames are specified + local frames_list = {} + for i = 1, self.frames_list do table.insert(frames_list, {i, 1}) end + self.frames_list = frames_list + elseif not self.frames_list then + local frames_list = {} + for i = 1, math.floor(self.source.w/self.frame_w) do table.insert(frames_list, {i, 1}) end + self.frames_list = frames_list + end + + self.frames = {} + for i, frame in ipairs(self.frames_list) do + self.frames[i] = {quad = love.graphics.newQuad((frame[1]-1)*self.frame_w, (frame[2]-1)*self.frame_h, self.frame_w, self.frame_h, self.source.w, self.source.h), w = self.frame_w, h = self.frame_h} + end + self.size = #self.frames +end + + +function AnimationFrames:draw(frame, x, y, r, sx, sy, ox, oy, color) + local _r, g, b, a + if color then + _r, g, b, a = love.graphics.getColor() + graphics.set_color(color) + end + love.graphics.draw(self.source.image, self.frames[frame].quad, x, y, r or 0, sx or 1, sy or sx or 1, self.frames[frame].w/2 + (ox or 0), self.frames[frame].h/2 + (oy or 0)) + if color then love.graphics.setColor(_r, g, b, a) end +end + + + + +-- The class that logically updates an animation. +-- This being separated from the visual part of an animation is useful whenever you need animation-like behavior unrelated to graphics, like making your own animations with code only. For instance: +--[[ +self.animation = AnimationLogic(0.04, 6, 'loop', { + [1] = function() + if self.parent:is(Player) then + for i = 1, random:int(1, 3) do DustParticle(game.current_state.floor, self.parent.x, self.parent.y)) end + end + self.z = 9 + end, + [2] = function() self.parent.timer:tween(0.025, self, {z = 6}, math.linear, nil, 'move_2') end, + [3] = function() self.parent.timer:tween(0.025, self, {z = 3}, math.linear, nil, 'move_3') end, + [4] = function() + self.parent.timer:tween(0.025, self, {z = 0}, math.linear, nil, 'move_4') + self.sx = 0.1 + self.parent.timer:tween(0.05, self, {sx = 0}, math.linear, nil, 'move_5') + end, +}) +]]-- +-- +-- That was an example of a code-only movement animation for a game I'm making. +-- The arguments that this takes are the delay between each frame, how many frames there are, the loop mode ('loop', 'once' or 'bounce') and a table of actions. +-- The delay argument can either be a number or a table, if it's a table then the delay for each frame can be set individually: +-- animation = AnimationLogic({0.02, 0.04, 0.06, 0.04}, ...) +-- In the example above, it would take 0.02s to go from frame 1 to 2, 0.04s from 2 to 3, 0.06s from 3 to 4 and 0.04s from 4 to 5 (or 1 if there are only 4 frames). +-- Loop can be either: 'loop', the animation will start once from frame 1 once it reaches the end; 'once', it will stop once it reaches the end; 'bounce', it will reverse once it reaches the end or start +-- Finally, the actions table can contain a list of functions, as shown in the code-only animation example above, and each function will be performed when that frame is reached. +-- In that example, once the second frame is reached, this function would be executed: +-- function() self.parent.timer:tween(0.025, self, {z = 6}, math.linear, nil, 'move_2') end +-- The index 0 can be used to perform an action once the animation reaches its end: +-- self.animation = AnimationLogic(0.04, self.player_dead_frames.size, 'once', {[0] = function() self.dead = true end}) +AnimationLogic = Object:extend() +function AnimationLogic:init(delay, frames, loop_mode, actions) + self.delay = delay + self.frames = frames + self.loop_mode = loop_mode or "once" + self.actions = actions + self.timer = 0 + self.frame = 1 + self.direction = 1 +end + + +function AnimationLogic:update(dt) + if self.dead then return end + + self.timer = self.timer + dt + local delay = self.delay + if type(self.delay) == "table" then delay = self.delay[self.frame] end + + if self.timer > delay then + self.timer = 0 + self.frame = self.frame + self.direction + if self.frame > self.frames or self.frame < 1 then + if self.loop_mode == "once" then + self.frame = self.frames + self.dead = true + elseif self.loop_mode == "loop" then + self.frame = 1 + elseif self.loop_mode == "bounce" then + self.direction = -self.direction + self.frame = self.frame + 2*self.direction + end + if self.actions and self.actions[0] then self.actions[0]() end + end + if self.actions and self.actions[self.frame] then self.actions[self.frame]() end + end +end + + + + +-- The Animation class, a mix of AnimationFrames and AnimationLogic. +-- Takes in a delay, an AnimationFrames object, the loop mode and a table of actions. +-- Read more about the AnimationFrames and AnimationLogic classes as everything there applies here. +Animation = Object:extend() +function Animation:init(delay, animation_frames, loop_mode, actions) + self.delay = delay + self.animation_frames = animation_frames + self.size = self.animation_frames.size + self.loop_mode = loop_mode + self.actions = actions + self.animation_logic = AnimationLogic(self.delay, self.animation_frames.size, self.loop_mode, self.actions) +end + + +function Animation:update(dt) + self.animation_logic:update(dt) +end + + +function Animation:draw(x, y, r, sx, sy, ox, oy, color) + self.animation_frames:draw(self.animation_logic.frame, x, y, r, sx, sy, ox, oy, color) +end diff --git a/engine/graphics/camera.lua b/engine/graphics/camera.lua new file mode 100644 index 0000000..5c42cf3 --- /dev/null +++ b/engine/graphics/camera.lua @@ -0,0 +1,364 @@ +Shake = Object:extend() +function Shake:init(amplitude, duration, frequency) + self.amplitude = amplitude or 0 + self.duration = duration or 0 + self.frequency = frequency or 60 + self.samples = {} + for i = 1, (duration/1000)*frequency do self.samples[i] = 2*love.math.random()-1 end + self.ti = love.timer.getTime()*1000 + self.t = 0 + self.shaking = true +end + + +function Shake:update(dt) + self.t = love.timer.getTime()*1000 - self.ti + if self.t > self.duration then + self.shaking = false + end +end + + +function Shake:get_noise(s) + return self.samples[s] or 0 +end + + +function Shake:get_decay(t) + if t > self.duration then return end + return (self.duration - t)/self.duration +end + + +function Shake:get_amplitude(t) + if not t then + if not self.shaking then return 0 end + t = self.t + end + local s = (t/1000)*self.frequency + local s0 = math.floor(s) + local s1 = s0 + 1 + local k = self:get_decay(t) + return self.amplitude*(self:get_noise(s0) + (s-s0)*(self:get_noise(s1) - self:get_noise(s0)))*k +end + + +-- The camera object. A global instance of this called "camera" is created automatically, and the Game class also contains its own instance of in the .camera attribute. +-- This class handles drawing of the game world through a viewport and the functions needed to make that happen. +-- A common setup looks like this: +--[[ +function Arena:on_enter() + game.camera.follow_style = 'lockon' + game.camera.lerp.x = 0.1 + game.camera.lerp.y = 0.1 + + self.main = Group(game.camera):set_as_physics_world(192, 0, 0, {'player', 'enemy', 'projectile', 'solid'}) + self.effects = Group(game.camera) + self.floor = Group(game.camera) + self.ui = Group() + + self.player = Player(gw/2, gh/2) + self.main:add_object(self.player) +end + +function Arena:update(dt) + game.camera:follow_object(self.player) + game.camera.x = math.floor(game.camera.x) + game.camera.y = math.floor(game.camera.y) + + self.main:update(dt) + self.floor:update(dt) + self.effects:update(dt) + self.ui:update(dt) +end + +function Arena:draw() + self.floor:draw() + self.main:sort_by_y() + self.main:draw() + self.effects:draw() + self.ui:draw() +end +]]-- + +-- Here we see 4 groups being created and for 3 of them the game's camera instance is attached. +-- If a group has a camera instance attached to it then whenever group:draw() is called it will draw all objects to the camera's canvas affected by the camera's translation, zoom and rotation. +-- Additionally, we also see some basic following functionality, as the camera is told to follow the player with the 'lockon' follow style and with some lerping going on. +-- Finally, the 4th group has no camera attached to it, because for UI elements we want them to be drawn in static screen positions. +-- +-- The arguments passed in to create a camera area: +-- x, y - the camera's position in world coordinates, the camera is always centered around its x, y coordinates +-- w, h - the camera's size, generally this should be the same as game_width and game_height (or gw and gh) passed in engine_run +Camera = Object:extend() +function Camera:init(x, y, w, h) + self.x, self.y = x, y + self.w, self.h = w or gw, h or gh + self.r, self.sx, self.sy = 0, 1, 1 + self.mouse = Vector(0, 0) + self.last_mouse = Vector(0, 0) + self.mouse_dt = Vector(0, 0) + self.shakes = {x = {}, y = {}} + self.spring = {x = Spring(), y = Spring()} + self.lerp = Vector(1, 1) + self.lead = Vector(1, 1) + self.impulse = Vector(0, 0) + self.follow_style = "no_deadzone" + self.shake_amount = Vector(0, 0) + self.last_shake_amount = Vector(0, 0) + self.last_target = Vector(0, 0) + self.scroll = Vector(0, 0) +end + + +-- Set ignore_scale to true when you want drawing of objects to be scaled when drawing the canvas rather than the objects themselves +-- That is useful for mipmapping a pixelated canvas, for instance, such that zooming out doesn't create lots of ugly artifacts +-- In that case you want to set ignore_scale to true, and then when drawing the main canvas multiply it by camera.sx*sx, camera.sy*sy instead of only sx, sy +-- You'll also want to create a canvas that is bigger than normal to account for the fact that you're zooming out of it +-- TODO: classify and unify all disparate methods of drawing in this class, also move "main canvas" here + +-- Attaches the camera, meaning all further draw operations will be affected by its transform. +-- Accepts two values that go from 0 to 1 that represent how much parallaxing there should be for the next operations. +-- A value of 1 means no parallaxing, meaning the elements drawn will move at the same rate as all other elements, while a value of 0 means maximum parallaxing, which means the elements won't move at all. +-- Groups automatically call this function, but you can still pass these scroll factors to their draw calls. +-- In general if you have multiple layers of backgrounds and you want them to be parallaxed you'd do something like this: +--[[ +function init() + back_backgrounds = Group(game.camera) + middle_backgrounds = Group(game.camera) + front_backgrounds = Group(game.camera) + main = Group(game.camera) +end + +function draw() + back_backgrounds:draw(0.5) + middle_backgrounds:draw(0.75) + front_backgrounds:draw(0.9) + main:draw() +end +]]-- +-- +-- In this example we have 4 layers are all drawn with different levels of parallax: 0.5 (half speed), 0.75, 0.9 and 1 (normal speed = no parallax). +function Camera:attach(scroll_factor_x, scroll_factor_y) + self.bx, self.by = self.x, self.y + self.x = self.bx*(scroll_factor_x or 1) + self.y = self.by*(scroll_factor_y or scroll_factor_x or 1) + love.graphics.push() + love.graphics.translate(self.w/2, self.h/2) + if not self.ignore_scale then love.graphics.scale(self.sx, self.sy) end + love.graphics.rotate(self.r) + love.graphics.translate(-self.x*(scroll_factor_x or 1), -self.y*(scroll_factor_y or 1)) +end + + +-- Detaches the camera, meaning all further draw operations won't be affected by its transform. +-- This is also called automatically by groups that have cameras attached to them. +function Camera:detach() + love.graphics.pop() + self.x, self.y = self.bx, self.by +end + + +-- Returns the values passed in in world coordinates. This is useful when transforming things from screen space to world space, like when the mouse clicks on something. +-- If you look at camera:get_mouse_position you'll see that it uses this function on the values returned by love.mouse.getPosition (which return values in screen coordinates). +-- camera:get_world_coords(love.mouse.getPosition()) +function Camera:get_world_coords(x, y) + local c, s = math.cos(-self.r), math.sin(-self.r) + x, y = (x - sx*self.w/2)/(sx*self.sx), (y - sy*self.h/2)/(sy*self.sy) + x, y = c*x - s*y, s*x + c*y + return x + self.x*(v or 1), y + self.y*(v or 1) +end + + +-- Returns the values passed in in local coordinates. This is useful when transforming things from world space to screen space, like when displaying UI according to the position of game objects. +-- x, y = camera:get_local_coords(player.x, player.y) +function Camera:get_local_coords(x, y) + local c, s = math.cos(self.r), math.sin(self.r) + x, y = x - self.x*(v or 1), y - self.y*(v or 1) + x, y = c*x - s*y, s*x + c*y + return x*self.sx + self.w/2, y*self.sy + self.h/2 +end + + +function Camera:update(dt) + self.mouse.x, self.mouse.y = self:get_mouse_position() + self.mouse_dt.x, self.mouse_dt.y = self.mouse.x - self.last_mouse.x, self.mouse.y - self.last_mouse.y + self.shake_amount:set(0, 0) + for _, z in ipairs({"x", "y"}) do + for i = #self.shakes[z], 1, -1 do + self.shakes[z][i]:update(dt) + self.shake_amount[z] = self.shake_amount[z] + self.shakes[z][i]:get_amplitude() + if not self.shakes[z][i].shaking then + table.remove(self.shakes[z], i) + end + end + end + + self.spring.x:update(dt) + self.spring.y:update(dt) + self.shake_amount:add(self.spring.x.x, self.spring.y.x) + self.x, self.y = self.x - self.last_shake_amount.x, self.y - self.last_shake_amount.y + self.x, self.y = self.x + self.shake_amount.x, self.y + self.shake_amount.y + self.last_shake_amount:set(self.shake_amount) + self.x = self.x + self.impulse.x*dt + self.y = self.y + self.impulse.y*dt + self.impulse:mul(0.9*refresh_rate*dt) + + if self.bound then + self.x = math.min(math.max(self.x, self.bounds_min.x + self.w/2), self.bounds_max.x - self.w/2) + self.y = math.min(math.max(self.y, self.bounds_min.y + self.h/2), self.bounds_max.y - self.h/2) + end + + self.last_mouse.x, self.last_mouse.y = self.mouse.x, self.mouse.y + if not self.target then return end + + if self.follow_style == "lockon" then + local w, h = self.w/16, self.w/16 + self:set_deadzone((self.w - w)/2, (self.h - h)/2, w, h) + elseif self.follow_style == "lockon_tight" then + local w, h = self.w/64, self.w/64 + self:set_deadzone((self.w - w)/2, (self.h - h)/2, w, h) + elseif self.follow_style == "lockon_loose" then + local w, h = self.w/4, self.w/4 + self:set_deadzone((self.w - w)/2, (self.h - h)/2, w, h) + elseif self.follow_style == "platformer" then + local w, h = self.w/8, self.h/3 + self:set_deadzone((self.w - w)/2, (self.h - h)/2 - h*0.25, w, h) + elseif self.follow_style == "topdown" then + local s = math.max(self.w, self.h)/4 + self:set_deadzone((self.w - s)/2, (self.h - s)/2, s, s) + elseif self.follow_style == "topdown_tight" then + local s = math.max(self.w, self.h)/8 + self:set_deadzone((self.w - s)/2, (self.h - s)/2, s, s) + elseif self.follow_style == "screen_by_screen" then + self:set_deadzone(0, 0, 0, 0) + elseif self.follow_style == "no_deadzone" then + self.deadzone = nil + end + + if not self.deadzone then + self.x, self.y = self.target.x, self.target.y + if self.bound then + self.x = math.min(math.max(self.x, self.bounds_min.x + self.w/2), self.bounds_max.x - self.w/2) + self.y = math.min(math.max(self.y, self.bounds_min.y + self.h/2), self.bounds_max.y - self.h/2) + end + return + end + + local dx1, dy1, dx2, dy2 = self.deadzone.x, self.deadzone.y, self.deadzone.x + self.deadzone.w, self.deadzone.y + self.deadzone.h + local scroll_x, scroll_y = 0, 0 + local target_x, target_y = self:get_local_coords(self.target.x, self.target.y) + local x, y = self:get_local_coords(self.x, self.y) + + if self.follow_style == "screen_by_screen" then + if self.bound then + if self.x > self.bounds_min.x + self.w/2 and target_x < 0 then self.scroll.x = math.snap_center(self.scroll.x - self.w/self.sx, self.w/self.sx) end + if self.x < self.bounds_max.x - self.w/2 and target_x >= self.w then self.scroll.x = math.snap_center(self.scroll.x + self.w/self.sx, self.w/self.sx) end + if self.y > self.bounds_min.y + self.h/2 and target_y < 0 then self.scroll.y = math.snap_center(self.scroll.y - self.h/self.sy, self.h/self.sy) end + if self.y < self.bounds_max.y - self.h/2 and target_y >= self.h then self.scroll.y = math.snap_center(self.scroll.y + self.h/self.sy, self.h/self.sy) end + else + if target_x < 0 then self.scroll.x = math.snap_center(self.scroll.x - self.w/self.sx, self.w/self.sx) end + if target_x >= self.w then self.scroll.x = math.snap_center(self.scroll.x + self.w/self.sx, self.w/self.sx) end + if target_y < 0 then self.scroll.y = math.snap_center(self.scroll.y - self.h/self.sy, self.h/self.sy) end + if target_y >= self.h then self.scroll.y = math.snap_center(self.scroll.y + self.h/self.sy, self.h/self.sy) end + end + self.x = math.lerp(self.lerp.x, self.x, self.scroll.x) + self.y = math.lerp(self.lerp.y, self.y, self.scroll.y) + + if self.bound then + self.x = math.min(math.max(self.x, self.bounds_min.x + self.w/2), self.bounds_max.x - self.w/2) + self.y = math.min(math.max(self.y, self.bounds_min.y + self.h/2), self.bounds_max.y - self.h/2) + end + + else + if target_x < x + (dx1 + dx2 - x) then + local d = target_x - dx1 + if d < 0 then scroll_x = d end + end + if target_x > x - (dx1 + dx2 - x) then + local d = target_x - dx2 + if d > 0 then scroll_x = d end + end + if target_y < y + (dy1 + dy2 - y) then + local d = target_y - dy1 + if d < 0 then scroll_y = d end + end + if target_y > y - (dy1 + dy2 - y) then + local d = target_y - dy2 + if d > 0 then scroll_y = d end + end + + if not self.last_target.x and not self.last_target.y then self.last_target.x, self.last_target.y = self.target.x, self.target.y end + scroll_x = scroll_x + (self.target.x - self.last_target.x)*self.lead.x + scroll_y = scroll_y + (self.target.y - self.last_target.y)*self.lead.y + self.last_target.x, self.last_target.y = self.target.x, self.target.y + self.x = math.lerp(self.lerp.x, self.x, self.x + scroll_x) + self.y = math.lerp(self.lerp.y, self.y, self.y + scroll_y) + + if self.bound then + self.x = math.min(math.max(self.x, self.bounds_min.x + self.w/2), self.bounds_max.x - self.w/2) + self.y = math.min(math.max(self.y, self.bounds_min.y + self.h/2), self.bounds_max.y - self.h/2) + end + end +end + + +-- Shakes the camera with a certain intensity for duration seconds and with the specified frequency +-- Higher frequency means jerkier movement, lower frequency means smoother movement +-- camera:shake(10, 1, 120) -> shakes the camera with 10 intensity for 1 second and 120 frequency +function Camera:shake(intensity, duration, frequency) + table.insert(self.shakes.x, Shake(intensity, 1000*(duration or 0), frequency or 60)) + table.insert(self.shakes.y, Shake(intensity, 1000*(duration or 0), frequency or 60)) +end + + +-- Shakes the camera with a certain intensity towards angle r using a spring mechanism +-- k and d are stiffness and damping spring values (see spring file for more) +-- camera:shake(10, math.pi/4) -> shakes the camera with 10 intensity diagonally +function Camera:spring_shake(intensity, r, k, d) + self.spring.x:pull(-intensity*math.cos(r or 0), k, d) + self.spring.y:pull(-intensity*math.sin(r or 0), k, d) +end + + +-- When following an object, this function sets a deadzone in which the camera can move freely in before having to go back to following the object +-- TODO: add STALKER-X documentation examples of all deadzones and lerping modes here +function Camera:set_deadzone(x, y, w, h) + self.deadzone = {x = x, y = y, w = w, h = h} +end + + +-- Sets the boundaries of the camera as a rectangle. +-- The camera's center will not be allowed to move outside the boundaries of this rectangle. +-- TODO: this doesn't seem to work when zooming levels are different than 1, fix it +function Camera:set_bounds(x, y, w, h) + self.bound = true + self.bounds_min = {x = x - w/2, y = y - h/2} + self.bounds_max = {x = x + w/2, y = y + h/2} +end + + +-- Tells the camera to follow the object +-- Previously set lerp, lead, follow styles and deadzone variables apply when following the object +function Camera:follow_object(obj) + self.target = obj +end + + +-- Returns the mouse's position in world coordinates +-- x, y = camera:get_mouse_position() +function Camera:get_mouse_position() + return self:get_world_coords(love.mouse.getPosition()) +end + + +-- Returns the angle from a point to the mouse +-- x, y = camera:angle_to_mouse(point.x, point.y) +function Camera:angle_to_mouse(x, y) + local mx, my = self:get_mouse_position() + return math.angle(x, y, mx, my) +end + + +function Camera:apply_impulse(f, r) + self.impulse:set(f*math.cos(r), f*math.sin(r)) +end diff --git a/engine/graphics/canvas.lua b/engine/graphics/canvas.lua new file mode 100644 index 0000000..deff544 --- /dev/null +++ b/engine/graphics/canvas.lua @@ -0,0 +1,67 @@ +-- A canvas object for offscreen rendering. +Canvas = Object:extend() +function Canvas:init(w, h, opts) + local opts = opts or {} + self.w, self.h = w, h + self.canvas = love.graphics.newCanvas(self.w, self.h, {msaa = opts.msaa}) + self.stencil = opts.stencil +end + + +-- Draws the canvas to the screen. +--[[ +function init() + canvas = Canvas(gw, gh) +end + +function draw() + canvas:draw_to(function() + -- draw your game + end) + canvas:draw(0, 0, 0, sx, sy) +end +]]-- +function Canvas:draw(x, y, r, sx, sy, ox, oy) + love.graphics.setColor(1, 1, 1, 1) + love.graphics.setBlendMode("alpha", "premultiplied") + love.graphics.draw(self.canvas, x or 0, y or 0, r or 0, sx or 1, sy or 1, ox or 0, oy or 0) + love.graphics.setBlendMode("alpha") +end + + +function Canvas:draw2(x, y, r, sx, sy, ox, oy) + love.graphics.setColor(1, 1, 1, 1) + love.graphics.draw(self.canvas, x or 0, y or 0, r or 0, sx or 1, sy or 1, ox or 0, oy or 0) +end + + +-- Takes in a function and uses it to draw to this canvas. +-- canvas:draw_to(function() +-- graphics.rectangle(gw/2, gh/2, 50, 50) +-- end) +function Canvas:draw_to(action) + love.graphics.setCanvas({self.canvas, stencil = self.stencil}) + love.graphics.clear() + action() + love.graphics.setCanvas() +end + + +-- Sets this canvas as the active one. +function Canvas:set() + current_canvas = self + love.graphics.setCanvas(self.canvas) +end + + +-- Unsets this canvas as the active one. +function Canvas:unset() + current_canvas = nil + love.graphics.setCanvas() +end + + +-- Clears this canvas' buffer. +function Canvas:clear() + love.graphics.clear() +end diff --git a/engine/graphics/color.lua b/engine/graphics/color.lua new file mode 100644 index 0000000..9cbc772 --- /dev/null +++ b/engine/graphics/color.lua @@ -0,0 +1,91 @@ +-- A basic color object. +-- Colors can be created in 3 forms: +-- color = Color('#ffffff') +-- color = Color(255, 255, 255) +-- color = Color(1, 1, 1) +-- You can access the colors values via .r, .g, .b and .a. +-- You can create a copy of a color by calling color:clone(). +Color = Object:extend() +function Color:init(r, g, b, a) + if type(r) == "string" then + local hex = r:gsub("#", "") + self.r = tonumber("0x" .. hex:sub(1, 2))/255 + self.g = tonumber("0x" .. hex:sub(3, 4))/255 + self.b = tonumber("0x" .. hex:sub(5, 6))/255 + self.a = 1 + else + if r > 1 or g > 1 or b > 1 then + self.r = r/255 + self.g = g/255 + self.b = b/255 + self.a = (a or 255)/255 + else + self.r = r + self.g = g + self.b = b + self.a = a or 1 + end + end +end + + +function Color:clone() + return Color(self.r, self.g, self.b, self.a) +end + + +function Color:lighten(v) + local h, s, l = self:_to_hsl() + l = l + v + self.r, self.g, self.b = self:_to_rgb(h, s, l) + return self +end + + +function Color:darken(v) + local h, s, l = self:_to_hsl() + l = l - v + self.r, self.g, self.b = self:_to_rgb(h, s, l) + return self +end + + +function Color:fade(v) + self.a = self.a - v + return self +end + + +function Color:_to_hsl() + local max, min = math.max(self.r, self.g, self.b), math.min(self.r, self.g, self.b) + local h, s, l + l = (max + min)/2 + if max == min then h, s = 0, 0 + else + local d = max - min + if l > 0.5 then s = d/(2 - max - min) else s = d/(max + min) end + if max == self.r then + h = (self.g - self.b)/d + if self.g < self.b then h = h + 6 end + elseif max == self.g then h = (self.b - self.r)/d + 2 + elseif max == self.b then h = (self.r - self.g)/d + 4 end + h = h/6 + end + return h, s, l +end + + +function Color:_to_rgb(h, s, l) + if s == 0 then return math.clamp(l, 0, 1), math.clamp(l, 0, 1), math.clamp(l, 0, 1) end + local function to(p, q, t) + if t < 0 then t = t + 1 end + if t > 1 then t = t - 1 end + if t < .16667 then return p + (q - p)*6*t end + if t < .5 then return q end + if t < .66667 then return p + (q - p)*(.66667 - t)*6 end + return p + end + local q = l < .5 and l*(1 + s) or l + s - l*s + local p = 2*l - q + return math.clamp(to(p, q, h + .33334), 0, 1), math.clamp(to(p, q, h), 0, 1), math.clamp(to(p, q, h - .33334), 0, 1) +end diff --git a/engine/graphics/font.lua b/engine/graphics/font.lua new file mode 100644 index 0000000..52ce88b --- /dev/null +++ b/engine/graphics/font.lua @@ -0,0 +1,16 @@ +-- The base Font class. +Font = Object:extend() +function Font:init(asset_name, font_size) + self.font = love.graphics.newFont("assets/fonts/" .. asset_name .. ".ttf", font_size) + self.h = self.font:getHeight() +end + + +function Font:get_text_width(text) + return self.font:getWidth(text) +end + + +function Font:get_height() + return self.font:getHeight() +end diff --git a/engine/graphics/graphics.lua b/engine/graphics/graphics.lua new file mode 100644 index 0000000..640c071 --- /dev/null +++ b/engine/graphics/graphics.lua @@ -0,0 +1,370 @@ +graphics = {} +graphics.debug_queries = {} +graphics.debug_draw = false + + +-- All operations after this is called will be affected by the transform. +function graphics.push(x, y, r, sx, sy) + love.graphics.push() + love.graphics.translate(x or 0, y or 0) + love.graphics.scale(sx or 1, sy or sx or 1) + love.graphics.rotate(r or 0) + love.graphics.translate(-x or 0, -y or 0) +end + + +-- All operations after this is called will not be affected by the transform set with graphics.push. +function graphics.pop() + love.graphics.pop() +end + + +function graphics.translate(x, y) + love.graphics.translate(x or 0, y or 0) +end + + +function graphics.rotate(r) + love.graphics.rotate(r or 0) +end + + +function graphics.scale(sx, sy) + love.graphics.scale(sx or 1, sy or sx or 1) +end + + +function graphics.update(dt) + for i = #self.debug_queries, 1, -1 do + local query = self.debug_queries[i] + query.frames = query.frames - 1 + if query.frames <= 0 then table.remove(self.debug_queries, i) end + end +end + + +-- Adds a polygon to be drawn to the screen for a few frames. Useful when debugging visual shapes. +function graphics.add_polygon_debug_query(vertices, frames) + table.insert(self.debug_queries, {vertices = vertices, frames = frames, type = "polygon"}) +end + + +function graphics.draw_debug_queries() + for _, query in ipairs(self.debug_queries) do + if query.type == "polygon" then + self:polygon(query.vertices) + end + end +end + + +-- Prints text to the screen, alternative to using a Text object. +function graphics.print(text, font, x, y, r, sx, sy, ox, oy, color) + local _r, g, b, a = love.graphics.getColor() + if color then love.graphics.setColor(color.r, color.g, color.b, color.a) end + love.graphics.print(text, font.font, x, y, r or 0, sx or 1, sy or 1, ox or 0, oy or 0) + if color then love.graphics.setColor(_r, g, b, a) end +end + + +-- Prints text to the screen centered on x, y, alternative to using a Text object. +function graphics.print_centered(text, font, x, y, r, sx, sy, ox, oy, color) + local _r, g, b, a = love.graphics.getColor() + if color then love.graphics.setColor(color.r, color.g, color.b, color.a) end + love.graphics.print(text, font.font, x, y, r or 0, sx or 1, sy or 1, (ox or 0) + font:get_text_width(text)/2, (oy or 0) + font.h/2) + if color then love.graphics.setColor(_r, g, b, a) end +end + + +function graphics.shape(shape, color, line_width, ...) + local r, g, b, a = love.graphics.getColor() + if not color and not line_width then love.graphics[shape]("line", ...) + elseif color and not line_width then + love.graphics.setColor(color.r, color.g, color.b, color.a) + love.graphics[shape]("fill", ...) + else + if color then love.graphics.setColor(color.r, color.g, color.b, color.a) end + love.graphics.setLineWidth(line_width) + love.graphics[shape]("line", ...) + love.graphics.setLineWidth(1) + end + love.graphics.setColor(r, g, b, a) +end + + +-- Draws a rectangle of size w, h centered on x, y. +-- If rx, ry are passed in, then the rectangle will have rounded corners with radius of that size. +-- If color is passed in then the rectangle will be filled with that color (color is Color object) +-- If line_width is passed in then the rectangle will not be filled and will instead be drawn as a set of lines of the given width. +function graphics.rectangle(x, y, w, h, rx, ry, color, line_width) + graphics.shape("rectangle", color, line_width, x - w/2, y - h/2, w, h, rx, ry) +end + + +-- Draws a rectangle of size w, h centered on x - w/2, y - h/2. +-- If rx, ry are passed in, then the rectangle will have rounded corners with radius of that size. +-- If color is passed in then the rectangle will be filled with that color (color is Color object) +-- If line_width is passed in then the rectangle will not be filled and will instead be drawn as a set of lines of the given width. +function graphics.rectangle2(x, y, w, h, rx, ry, color, line_width) + graphics.shape("rectangle", color, line_width, x, y, w, h, rx, ry) +end + + +-- Draws a dashed rectangle of size w, h centerd on x, y. +-- dash_size and gap_size correspond to the dimensions of the dashing behavior. +function graphics.dashed_rectangle(x, y, w, h, dash_size, gap_size, color, line_width) + graphics.dashed_line(x - w/2, y - h/2, x + w/2, y - h/2, dash_size, gap_size, color, line_width) + graphics.dashed_line(x - w/2, y - h/2, x - w/2, y + h/2, dash_size, gap_size, color, line_width) + graphics.dashed_line(x - w/2, y + h/2, x + w/2, y + h/2, dash_size, gap_size, color, line_width) + graphics.dashed_line(x + w/2, y - h/2, x + w/2, y + h/2, dash_size, gap_size, color, line_width) +end + + +-- Draws an isosceles triangle with size w, h centered on x, y pointed to the right (angle 0). +-- If color is passed in then the triangle will be filled with that color (color is Color object) +-- If line_width is passed in then the triangle will not be filled and will instead be drawn as a set of lines of the given width. +function graphics.triangle(x, y, w, h, color, line_width) + local x1, y1 = x + h/2, y + local x2, y2 = x - h/2, y - w/2 + local x3, y3 = x - h/2, y + w/2 + graphics.polygon({x1, y1, x2, y2, x3, y3}, color, line_width) +end + + +-- Draws an equilateral triangle with size w centered on x, y pointed to the right (angle 0). +-- If color is passed in then the triangle will be filled with that color (color is Color object) +-- If line_width is passed in then the triangle will not be filled and will instead be drawn as a set of lines of the given width. +function graphics.triangle_equilateral(x, y, w, color, line_width) + local h = math.sqrt(math.pow(w, 2) - math.pow(w/2, 2)) + graphics.triangle(x, y, w, h, color, line_width) +end + + +-- Draws a circle of radius r centered on x, y. +-- If color is passed in then the circle will be filled with that color (color is Color object) +-- If line_width is passed in then the circle will not be filled and will instead be drawn as a set of lines of the given width. +function graphics.circle(x, y, r, color, line_width) + graphics.shape("circle", color, line_width, x, y, r) +end + + +-- Draws a polygon with the given points. +-- If color is passed in then the polygon will be filled with that color (color is Color object) +-- If line_width is passed in then the polygon will not be filled and will instead be drawn as a set of lines of the given width. +function graphics.polygon(vertices, color, line_width) + graphics.shape("polygon", color, line_width, vertices) +end + + +-- Draws a line with the given points. +function graphics.line(x1, y1, x2, y2, color, line_width) + local r, g, b, a = love.graphics.getColor() + if color then love.graphics.setColor(color.r, color.g, color.b, color.a) end + if line_width then love.graphics.setLineWidth(line_width) end + love.graphics.line(x1, y1, x2, y2) + love.graphics.setColor(r, g, b, a) + love.graphics.setLineWidth(1) +end + + +function graphics.polyline(color, line_width, ...) + local r, g, b, a = love.graphics.getColor() + if color then love.graphics.setColor(color.r, color.g, color.b, color.a) end + if line_width then love.graphics.setLineWidth(line_width) end + love.graphics.line(...) + love.graphics.setColor(r, g, b, a) + love.graphics.setLineWidth(1) +end + + +-- Draws a line with rounded ends with the given points. +-- If color is passed in then the line will be filled with that color (color is Color object) +-- If line_width is passed in then the line will not be filled and will instead be drawn as a set of lines of the given width. +function graphics.rounded_line(x1, y1, x2, y2, color, line_width) + love.graphics.push() + love.graphics.translate(x1, y1) + love.graphics.rotate(math.angle(x1, y1, x2, y2)) + love.graphics.translate(-x1, -y1) + graphics.rectangle(x1, y1 - line_width/4, math.length(x2-x1, y2-y1), line_width/2, line_width/4, line_width/4, color) + love.graphics.pop() +end + + +-- Draws a dashed line with the given points. +-- dash_size and gap_size correspond to the dimensions of the dashing behavior. +-- If color is passed in then the lines will be filled with that color (color is Color object) +-- If line_width is passed in then the lines will not be filled and will instead be drawn as a set of lines of the given width. +function graphics.dashed_line(x1, y1, x2, y2, dash_size, gap_size, color, line_width) + local r, g, b, a = love.graphics.getColor() + if color then love.graphics.setColor(color.r, color.g, color.b, color.a) end + if line_width then love.graphics.setLineWidth(line_width) end + local dx, dy = x2-x1, y2-y1 + local an, st = math.atan2(dy, dx), dash_size + gap_size + local len = math.sqrt(dx*dx + dy*dy) + local nm = (len-dash_size)/st + love.graphics.push() + love.graphics.translate(x1, y1) + love.graphics.rotate(an) + for i = 0, nm do love.graphics.line(i*st, 0, i*st + dash_size, 0) end + love.graphics.line(nm*st, 0, nm*st + dash_size, 0) + love.graphics.pop() +end + + +-- Draws a dashed line with rounded ends with the given points. +-- dash_size and gap_size correspond to the dimensions of the dashing behavior. +-- If color is passed in then the lines will be filled with that color (color is Color object) +-- If line_width is passed in then the lines will not be filled and will instead be drawn as a set of lines of the given width. +function graphics.dashed_rounded_line(x1, y1, x2, y2, dash_size, gap_size, color, line_width) + if color then love.graphics.setColor(color.r, color.g, color.b, color.a) end + if line_width then love.graphics.setLineWidth(line_width) end + local dx, dy = x2-x1, y2-y1 + local an, st = math.atan2(dy, dx), dash_size + gap_size + local len = math.sqrt(dx*dx + dy*dy) + local nm = (len-dash_size)/st + love.graphics.push() + love.graphics.translate(x1, y1) + love.graphics.rotate(an) + for i = 0, nm do + love.graphics.push() + love.graphics.translate(i*st, 0) + love.graphics.rotate(math.angle(i*st, 0, i*st + dash_size, 0)) + love.graphics.translate(-i*st, -0) + graphics.shape("rectangle", color, nil, i*st, 0, math.length((i*st + dash_size)-(i*st), 0-0), line_width/2, line_width/4, line_width/4) + love.graphics.pop() + end + love.graphics.push() + love.graphics.translate(nm*st, 0) + love.graphics.rotate(math.angle(nm*st, 0, nm*st + dash_size, 0)) + love.graphics.translate(-nm*st, -0) + graphics.shape("rectangle", color, nil, nm*st, 0, math.length((nm*st + dash_size)-(nm*st), 0-0), line_width/2, line_width/4, line_width/4) + love.graphics.pop() + love.graphics.pop() +end + + +-- Draws an ellipse with radius rx, ry centered on x, y. +-- If color is passed in then the ellipse will be filled with that color (color is Color object) +-- If line_width is passed in then the ellipse will not be filled and will instead be drawn as a set of lines of the given width. +function graphics.ellipse(x, y, rx, ry, color, line_width) + graphics.shape("ellipse", color, line_width, x, y, rx, ry) +end + + +-- Sets the currently active shader, the passed in argument should be a Shader object. +function graphics.set_shader(shader) + if not shader then love.graphics.setShader() + else love.graphics.setShader(shader.shader) end +end + + +-- Sets the currently active color, the passed in argument should be a Color object. +function graphics.set_color(color) + love.graphics.setColor(color.r, color.g, color.b, color.a) +end + + +-- Sets the currently active background color, the passed in argument should be a Color object. +function graphics.set_background_color(color) + love.graphics.setBackgroundColor(color.r, color.g, color.b, color.a) +end + + +function graphics.set_line_width(line_width) + love.graphics.setLineWidth(line_width) +end + + +-- Sets the line style, possible values are 'rough' and 'smooth'. +function graphics.set_line_style(style) + love.graphics.setLineStyle(style) +end + + +-- Sets the default filter mode, possible values are 'nearest' and 'linear'. +function graphics.set_default_filter(min, max) + love.graphics.setDefaultFilter(min, max) +end + + +function graphics.set_mouse_visible(value) + love.mouse.setVisible(value) +end + + +function graphics.stencil(...) + love.graphics.stencil(...) +end + + +function graphics.set_stencil_test(...) + love.graphics.setStencilTest(...) +end + + +local stencil_mask_shader = love.graphics.newShader[[ +vec4 effect(vec4 color, Image texture, vec2 tc, vec2 pc) { + vec4 t = Texel(texture, tc); + if (t.a == 0.0) { + discard; + } + return t; +} +]] + +-- Draws the second image on top of the first but only the portions of it that aren't transparent are drawn. +-- action1 and action2 are functions that draw the images. +-- graphics.draw_intersection(function() player_image:draw(player.x, player.y) end, function() gradient_image:draw(player.x, player.y) end) -> draws the player with a gradient applied to it +function graphics.draw_intersection(action1, action2) + graphics.stencil(function() love.graphics.setShader(stencil_mask_shader); action1(); love.graphics.setShader() end, 'replace', 1) + graphics.set_stencil_test('greater', 0) + action2() + graphics.set_stencil_test() +end + + +-- A very specific function to be used with rtfx.bat to generated RTFX animations. +-- This is not very useful in contexts other than this very specific thing, so it should probably not be here. +-- TODO: some kind of plugin system for functions like these that are very specific and not generalizable but still useful. +function graphics.generate_rtfx_animation(w, h) + local files = system.enumerate_files("assets/frames") + if #files <= 0 then return end + local frames = {} + for _, file in ipairs(files) do table.insert(frames, love.image.newImageData(file)) end + + local out_frames = {} + local idw, idh = frames[1]:getDimensions() + local tw, th = w or 4, h or 4 + local ow, oh = idw/tw, idh/th + + for k = 1, #frames do + local image_data = frames[k] + local out_image_data = love.image.newImageData(ow, oh) + for i = 1, image_data:getWidth(), tw do + for j = 1, image_data:getHeight(), th do + local yes_or_no = {} + for x = 0, tw-1 do + for y = 0, th-1 do + local r, g, b, a = image_data:getPixel(i+x-1, j+y-1) + -- if r >= 0.01 and g >= 0.01 and b >= 0.01 then table.insert(yes_or_no, 1) end + if a >= 0.5 then table.insert(yes_or_no, 1) end + end + end + if #yes_or_no >= (tw*th)/2 then + out_image_data:setPixel(math.floor((i-1)/tw), math.floor((j-1)/th), 1, 1, 1, 1) + end + end + end + table.insert(out_frames, out_image_data) + end + + local spritesheet_data = love.image.newImageData(ow*#out_frames, oh) + for k = 1, #out_frames do + for i = 0, out_frames[k]:getWidth()-1 do + for j = 0, out_frames[k]:getHeight()-1 do + spritesheet_data:setPixel(i + (k-1)*ow, j, out_frames[k]:getPixel(i, j)) + end + end + end + spritesheet_data:encode("png", "anim.png") +end diff --git a/engine/graphics/image.lua b/engine/graphics/image.lua new file mode 100644 index 0000000..4ed7411 --- /dev/null +++ b/engine/graphics/image.lua @@ -0,0 +1,72 @@ +-- The base Image class. +Image = Object:extend() +function Image:init(asset_name) + self.image = love.graphics.newImage("assets/images/" .. asset_name .. ".png") + self.w = self.image:getWidth() + self.h = self.image:getHeight() +end + + +function Image:draw(x, y, r, sx, sy, ox, oy, color) + local _r, g, b, a + if color then + _r, g, b, a = love.graphics.getColor() + graphics.set_color(color) + end + love.graphics.draw(self.image, x, y, r or 0, sx or 1, sy or sx or 1, self.w/2 + (ox or 0), self.h/2 + (oy or 0)) + if color then love.graphics.setColor(_r, g, b, a) end +end + + + + +-- The base Quad class. Useful for loading pieces of images as independent Image objects. Every function that takes in an Image also takes in a Quad. +Quad = Object:extend() +function Quad:init(image, tile_w, tile_h, tile_coordinates) + self.image = image + self.quad = love.graphics.newQuad((tile_coordinates[1]-1)*tile_w, (tile_coordinates[2]-1)*tile_h, tile_w, tile_h, self.image.w, self.image.h) + self.w, self.h = tile_w, tile_h +end + + +function Quad:draw(x, y, r, sx, sy, ox, oy) + love.graphics.draw(self.image.image, self.quad, x, y, r or 0, sx or 1, sy or sx or 1, self.w/2 + (ox or 0), self.h/2 + (oy or 0)) +end + + + + + +-- A linear gradient image. +-- The first argument is the direction of the gradient and can be either 'horizontal' or 'vertical'. +GradientImage = Object:extend() +function GradientImage:init(direction, ...) + local colors = {...} + local mesh_data = {} + + if direction == "horizontal" then + for i = 1, #colors do + local color = colors[i] + local x = (i-1)/(#colors-1) + table.insert(mesh_data, {x, 1, x, 1, color.r, color.g, color.b, color.a or 1}) + table.insert(mesh_data, {x, 0, x, 0, color.r, color.g, color.b, color.a or 1}) + end + elseif direction == "vertical" then + for i = 1, #colors do + local color = colors[i] + local y = (i-1)/(#colors-1) + table.insert(mesh_data, {1, y, 1, y, color.r, color.g, color.b, color.a or 1}) + table.insert(mesh_data, {0, y, 0, y, color.r, color.g, color.b, color.a or 1}) + end + end + + self.mesh = love.graphics.newMesh(mesh_data, "strip", "static") +end + + +-- Draws the gradient image with size w, h centered on x, y. +function GradientImage:draw(x, y, w, h, r, sx, sy, ox, oy) + graphics.push(x, y, r) + love.graphics.draw(self.mesh, x - (sx or 1)*(w + (ox or 0))/2, y - (sy or 1)*(h + (oy or 0))/2, 0, w*(sx or 1), h*(sy or sx or 1)) + graphics.pop() +end diff --git a/engine/graphics/shader.lua b/engine/graphics/shader.lua new file mode 100644 index 0000000..10ee2a6 --- /dev/null +++ b/engine/graphics/shader.lua @@ -0,0 +1,31 @@ +-- The base Shader class. +Shader = Object:extend() +function Shader:init(vertex_name, fragment_name) + self.shader = love.graphics.newShader("assets/shaders/" .. (vertex_name or "default.vert"), "assets/shaders/" .. fragment_name) +end + + +-- Sets this shader as the active one. +function Shader:set() + current_shader = self + love.graphics.setShader(self.shader) +end + +-- Unsets this shader as the active one. +function Shader:unset() + current_shader = nil + love.graphics.setShader() +end + + +-- Takes in a parameter and the data that corresponds to it and sends it to the shader. +-- shader:send('displacement_map', displacement_canvas) +function Shader:send(value, data) + if data:is(Canvas) then + self.shader:send(value, data.canvas) + elseif data:is(Image) then + self.shader:send(value, data.image) + else + self.shader:send(value, data) + end +end diff --git a/engine/graphics/text.lua b/engine/graphics/text.lua new file mode 100644 index 0000000..2eea30a --- /dev/null +++ b/engine/graphics/text.lua @@ -0,0 +1,276 @@ +-- A generic text object. +-- It implements a character based tagging system which should allow you to implement any kind of text effect possible, from setting a character's color to making it become visible, shake and play sounds. +-- You would use it like this: +--[[ +yellow_text_tag = TextTag({ + init = function(c, i, text) + text.yellow = Color(1, 0.5, 0, 1) + end, + draw = function(c, i, text) + graphics.set_color(text.yellow) + end +}) + +shaking_text_tag = TextTag({ + init = function(c, i, text) + c.shaking_intensity = 8 + end, + update = function(c, dt, i, text) + c.ox = random:float(-c.shaking_intensity, c.shaking_intensity) + c.oy = random:float(-c.shaking_intensity, c.shaking_intensity) + end +}) + +text = Text({ + {text: '[yellow]This text is yellow', font: some_font, alignment: 'center', height_offset: -10} + {text: '[shaking]This text is shaking', font: some_other_font, alignment: 'center', height_multiplier: 1.2} + {text: 'This text is normal', font: yet_another_font, alignment: 'center', height_multiplier: 1.2} + {text: '[yellow, shaking]This text is yellow and shaking []while this text is normal', font: some_font, alignment: 'center'} +}, {yellow = yellow_text_tag, shaking = shaking_text_tag}) +]]-- + +-- There are two main things happening in the example above: first we're creating TextTags and then we're creating a text object that uses those tags. +-- The way each tag works is fairly simple: a tag accepts 3 functions, init, update and draw, and each of those functions operates on the text's characters one at a time. +-- In the example above, the text without tags is 'This text is yellow while this text is shaking and this text is normal' +-- For each of the characters in that string, different functions will be applied based on what tags were previously applied to it. +-- init, update and draw functions take in 3 arguments in common: +-- c - the character in question, a table containing .x, .y, .r, .sx, .sy, .ox, .oy and .character attributes. +-- i - the index of character in the string +-- text - the reference to the text object +-- The update function also takes in dt as the second argument. +-- +-- After we're done creating TextTags, we have to create the actual text object. +-- The way this is done is by specifying each line of the text object, along with its font, alignment, height multipliers and height offsets. +-- The first argument (text_data) is a table of tables containing all relevant info: +-- text - the actual string containing the text to be displayed, along with any tag information +-- font - the font to be used for the text +-- alignment (optional) - how the text should align itself, possible values are 'center', 'justified', 'right', if not specified then by default it's 'left' +-- height_offset (optional) - how many pixels the line below this one should be offset by +-- height_multiplier (optional) - multiplier over the font's height for placing the line below +-- The text object itself also has .w and .h which corresponds to the width of the biggest line and height of all lines + offsets, respectively. +-- If 'alignment_width' is set to a specific line then that line will be automatically set to that width, and if it is the biggest then .w will also be set to that value. +Text = Object:extend() +function Text:init(text_data, text_tags) + self.trigger = Trigger() + self.text_data = text_data + self.text_tags = text_tags + self.white = Color(1, 1, 1, 1) + self:set_text(text_data) + return self +end + + +function Text:update(dt) + self.trigger:update(dt) + self:format_text() + for _, line in ipairs(self.lines) do + for i, c in ipairs(line.characters) do + for k, v in pairs(self.text_tags) do + for _, tag in ipairs(c.tags) do + if tag == k then + if v.actions.update then + v.actions.update(c, dt, i, self) + end + end + end + end + end + end +end + + +-- Draws the text object centered at the specified location. +function Text:draw(x, y, r, sx, sy) + for _, line in ipairs(self.lines) do + for i, c in ipairs(line.characters) do + for k, v in pairs(self.text_tags) do + for _, tag in ipairs(c.tags) do + if tag == k then + if v.actions.draw then + v.actions.draw(c, i, self) + end + end + end + end + graphics.push(x, y, r, sx, sy) + graphics.print(c.character, line.font, x + c.x - self.w/2, y + c.y - self.h/2, c.r or 0, c.sx or 1, c.sy or c.sx or 1, c.ox or 0, c.oy or 0) + graphics.pop() + graphics.set_color(self.white) + end + end +end + + +function Text:format_text() + self.w = 0 + for i, line in ipairs(self.lines) do + local line_width = math.max(line.font:get_text_width(line.raw_text), line.alignment_width or 0) + if line_width > self.w then + self.w = line_width + end + end + + local x, y = 0, 0 + for j, line in ipairs(self.lines) do + local h = (line.font.h*(line.height_multiplier or 1) + (line.height_offset or 0))*(line.sy or 1) + for i, c in ipairs(line.characters) do + c.x = x + c.y = y + c.sx = line.sx or 1 + c.sy = line.sy or 1 + x = x + line.font:get_text_width(c.character) + end + y = y + h + x = 0 + end + self.h = y + + for i, line in ipairs(self.lines) do + if line.alignment == "right" then + local text_width = 0 + for _, c in ipairs(line.characters) do text_width = text_width + line.font:get_text_width(c.character) end + local left_over_width = self.w - (line.alignment_width or text_width) + for _, c in ipairs(line.characters) do c.x = c.x + left_over_width end + + elseif line.alignment == "center" then + local text_width = 0 + for _, c in ipairs(line.characters) do text_width = text_width + line.font:get_text_width(c.character) end + local left_over_width = self.w - (line.alignment_width or text_width) + for _, c in ipairs(line.characters) do c.x = c.x + left_over_width/2 end + + elseif line.alignment == "justified" then + local text_width = 0 + for _, c in ipairs(line.characters) do text_width = text_width + line.font:get_text_width(c.character) end + local left_over_width = self.w - (line.alignment_width or text_width) + local spaces_count = 0 + for _, c in ipairs(line.characters) do + if c.character == " " then + spaces_count = spaces_count + 1 + end + end + local added_width_to_each_space = math.floor(left_over_width/spaces_count) + local total_added_width = 0 + for _, c in ipairs(characters) do + if c.character == " " then + c.x = c.x + added_width_to_each_space + total_added_width = total_added_width + added_width_to_each_space + else + c.x = c.x + total_added_width + end + end + end + end +end + + +function Text:parse(text_data) + for _, line in ipairs(text_data) do + local tags = {} + for i, tags_text, j in line.text:gmatch("()%[(.-)%]()") do + if tags_text == "" then + table.insert(tags, {i = tonumber(i), j = tonumber(j)-1}) + line.tags = tags + else + local local_tags = {} + for tag in tags_text:gmatch("[%w_]+") do table.insert(local_tags, tag) end + table.insert(tags, {i = tonumber(i), j = tonumber(j)-1, tags = local_tags}) + line.tags = tags + end + end + if not line.tags then line.tags = {} end + end + + for _, line in ipairs(text_data) do + line.characters = {} + local current_tags = nil + for i = 1, #line.text do + local c = line.text:sub(i, i) + local inside_tags = false + for _, tag in ipairs(line.tags) do + if i >= tag.i and i <= tag.j then + inside_tags = true + current_tags = tag.tags + break + end + end + if not inside_tags then + table.insert(line.characters, {character = c, visible = true, tags = current_tags or {}}) + end + end + end + + for _, line in ipairs(text_data) do + local raw_text = "" + for _, character in ipairs(line.characters) do + raw_text = raw_text .. character.character + end + line.raw_text = raw_text + end + + return text_data +end + + +-- Sets new text. +-- Reapplies all modifications (wrap width, justification, etc). +function Text:set_text(text_data) + self.lines = self:parse(text_data) + self:format_text() + for _, line in ipairs(self.lines) do + for i, c in ipairs(line.characters) do + for k, v in pairs(self.text_tags) do + for _, tag in ipairs(c.tags) do + if tag == k then + if v.actions.init then + v.actions.init(c, i, self) + end + end + end + end + end + end +end + + +-- Sets the line's alignment width. +-- This is used to align the text according to the alignment option +-- For instance, if the alignment width is 200 and the alignment is 'right', then the right edge used for this alignment will be 200 units to the right +function Text:set_alignment_width(line, alignment_width) + self.alignment_width = alignment_width + self:format_text() + return self +end + + +-- Sets the text's line height. +-- Lines are automatically placed vertically using the font's height for spacing, but you can increase or decrease this distance by setting these values. +function Text:set_line_height_data(line, offset, multiplier) + self.lines[line].height_offset = offset or 0 + self.lines[line].height_multiplier = multiplier or 1 + self:format_text() + return self +end + + +-- Sets the text's font. By default texts use the global font. +function Text:set_font(line, font) + self.lines[line].font = font + self:format_text() + return self +end + + +-- Sets the alignment behavior for the given line. +-- Possible behaviors are: 'right', 'center' and 'justified' +function Text:set_alignment(line, alignment) + self.lines[line].alignment = alignment + self:format_text() + return self +end + + +-- The text tag objects to be used with text instances. +TextTag = Object:extend() +function TextTag:init(actions) + self.actions = actions +end diff --git a/engine/graphics/tileset.lua b/engine/graphics/tileset.lua new file mode 100644 index 0000000..27aa8eb --- /dev/null +++ b/engine/graphics/tileset.lua @@ -0,0 +1,27 @@ +-- The class responsible for loading and drawing tilesets. +-- This is primarily used by the Tilemap class. +Tileset = Object:extend() +function Tileset:init(image, tile_w, tile_h) + self.image = image + self.tile_w, self.tile_h = tile_w, tile_h + self.grid = Grid(math.floor(self.image.w/self.tile_w), math.floor(self.image.h/self.tile_h), 0) + self.w, self.h = self.grid.w, self.grid.h + for i = 1, self.grid.w do + for j = 1, self.grid.h do + self.grid:set(i, j, love.graphics.newQuad((i-1)*self.tile_w, (j-1)*self.tile_h, self.tile_w, self.tile_h, self.image.w, self.image.h)) + end + end +end + + +-- Draws a tile based on its tileset 1D index. +-- If the tileset has width 10 (10 columns) then the index 11 corresponds to the first tile in the second row. +function Tileset:draw_tile(index, x, y, r, sx, sy, ox, oy) + love.graphics.draw(self.image.image, self:get_quad(index), x, y, r or 0, sx or 1, sy or sx or 1, ox or 0, oy or 0) +end + + +-- Returns the quad that represents the tile at the given index. +function Tileset:get_quad(index) + return self.grid:get(math.index_to_coordinates(index, self.w)) +end diff --git a/engine/init.lua b/engine/init.lua new file mode 100644 index 0000000..ada5e58 --- /dev/null +++ b/engine/init.lua @@ -0,0 +1,157 @@ +local path = ... +if not path:find("init") then + require(path .. ".datastructures.string") + require(path .. ".datastructures.table") + require(path .. ".external") + require(path .. ".graphics.graphics") + require(path .. ".game.object") + require(path .. ".system") + require(path .. ".datastructures.graph") + require(path .. ".datastructures.grid") + require(path .. ".game.gameobject") + require(path .. ".game.group") + require(path .. ".game.state") + require(path .. ".game.physics") + require(path .. ".game.steering") + require(path .. ".graphics.animation") + require(path .. ".graphics.camera") + require(path .. ".graphics.canvas") + require(path .. ".graphics.color") + require(path .. ".graphics.font") + require(path .. ".graphics.image") + require(path .. ".graphics.shader") + require(path .. ".graphics.text") + require(path .. ".graphics.tileset") + require(path .. ".map.solid") + require(path .. ".map.tilemap") + require(path .. ".math.polygon") + require(path .. ".math.chain") + require(path .. ".math.circle") + require(path .. ".math.line") + require(path .. ".math.math") + require(path .. ".math.random") + require(path .. ".math.rectangle") + require(path .. ".math.spring") + require(path .. ".math.triangle") + require(path .. ".math.vector") + require(path .. ".game.trigger") + require(path .. ".game.input") + require(path .. ".sound") + require(path .. ".game.parent") + require(path .. ".game.springs") + require(path .. ".game.flashes") + require(path .. ".game.hitfx") +end + +function engine_run(config) + if not web then + love.filesystem.setIdentity(config.game_name) + + local _, _, flags = love.window.getMode() + local window_width, window_height = love.window.getDesktopDimensions(flags.display) + if config.window_width ~= 'max' then window_width = config.window_width end + if config.window_height ~= 'max' then window_height = config.window_height end + + local limits = love.graphics.getSystemLimits() + local anisotropy = limits.anisotropy + msaa = limits.canvasmsaa + if config.msaa ~= 'max' then msaa = config.msaa end + if config.anisotropy ~= 'max' then anisotropy = config.anisotropy end + + gw, gh = config.game_width or 480, config.game_height or 270 + sx, sy = window_width/(config.game_width or 480), window_height/(config.game_height or 270) + ww, wh = window_width, window_height + + love.window.setMode(window_width, window_height, {fullscreen = config.fullscreen, vsync = config.vsync, msaa = msaa or 0, display = config.display}) + love.window.setTitle(config.game_name) + + else + gw, gh = config.game_width or 480, config.game_height or 270 + sx, sy = 2, 2 + ww, wh = 960, 540 + end + + love.graphics.setBackgroundColor(0, 0, 0, 1) + love.graphics.setColor(1, 1, 1, 1) + love.joystick.loadGamepadMappings("engine/gamecontrollerdb.txt") + graphics.set_line_style(config.line_style or "rough") + graphics.set_default_filter(config.default_filter or "nearest", config.default_filter or "nearest", anisotropy or 0) + + combine = Shader("default.vert", "combine.frag") + replace = Shader("default.vert", "replace.frag") + full_combine = Shader("default.vert", "full_combine.frag") + + input = Input() + input:bind_all() + for k, v in pairs(config.input or {}) do input:bind(k, v) end + random = Random() + trigger = Trigger() + camera = Camera(gw/2, gh/2) + mouse = Vector(0, 0) + last_mouse = Vector(0, 0) + mouse_dt = Vector(0, 0) + init() + + if love.timer then love.timer.step() end + + if not web then + _, _, flags = love.window.getMode() + fixed_dt = 1/flags.refreshrate + else fixed_dt = 1/60 end + + local accumulator = fixed_dt + local dt = 0 + frame, time = 0, 0 + + if not web then refresh_rate = flags.refreshrate + else refresh_rate = 60 end + + return function() + if love.event then + love.event.pump() + for name, a, b, c, d, e, f in love.event.poll() do + if name == "quit" then + if not love.quit or not love.quit() then + return a or 0 + end + elseif name == "keypressed" then input.keyboard_state[a] = true; input.last_key_pressed = a + elseif name == "keyreleased" then input.keyboard_state[a] = false + elseif name == "mousepressed" then input.mouse_state[input.mouse_buttons[c]] = true; input.last_key_pressed = input.mouse_buttons[c] + elseif name == "mousereleased" then input.mouse_state[input.mouse_buttons[c]] = false + elseif name == "wheelmoved" then if b == 1 then input.mouse_state.wheel_up = true elseif b == -1 then input.mouse_state.wheel_down = true end + elseif name == "gamepadpressed" then input.gamepad_state[input.index_to_gamepad_button[b]] = true; input.last_key_pressed = input.index_to_gamepad_button[b] + elseif name == "gamepadreleased" then input.gamepad_state[input.index_to_gamepad_button[b]] = false + elseif name == "gamepadaxis" then input.gamepad_axis[input.index_to_gamepad_axis[b]] = c + elseif name == "textinput" then input:textinput(a) end + end + end + + if love.timer then dt = love.timer.step() end + + accumulator = accumulator + dt + while accumulator >= fixed_dt do + frame = frame + 1 + input:update(fixed_dt) + trigger:update(fixed_dt) + camera:update(fixed_dt) + local mx, my = love.mouse.getPosition() + mouse:set(mx/sx, my/sy) + mouse_dt:set(mouse.x - last_mouse.x, mouse.y - last_mouse.y) + update(dt) + system.update() + input.last_key_pressed = nil + last_mouse:set(mouse.x, mouse.y) + accumulator = accumulator - fixed_dt + time = time + fixed_dt + end + + if love.graphics and love.graphics.isActive() then + love.graphics.origin() + love.graphics.clear(love.graphics.getBackgroundColor()) + draw() + love.graphics.present() + end + + if love.timer then love.timer.sleep(0.001) end + end +end diff --git a/engine/love/OpenAL32.dll b/engine/love/OpenAL32.dll new file mode 100644 index 0000000..57fc48b Binary files /dev/null and b/engine/love/OpenAL32.dll differ diff --git a/engine/love/SDL2.dll b/engine/love/SDL2.dll new file mode 100644 index 0000000..4c08014 Binary files /dev/null and b/engine/love/SDL2.dll differ diff --git a/engine/love/build_web.bat b/engine/love/build_web.bat new file mode 100644 index 0000000..aabf092 --- /dev/null +++ b/engine/love/build_web.bat @@ -0,0 +1,4 @@ +call "C:\Program Files\7-Zip\7z.exe" a -r %1.zip -w ..\..\ -xr!engine/love -xr!builds -xr!.git -xr!*.moon +rename %1.zip %1.love +call love-js -c -m 268435456 -t %1 %2\engine\love\%1.love ..\..\builds\web +del %1.love diff --git a/engine/love/build_windows.bat b/engine/love/build_windows.bat new file mode 100644 index 0000000..77b92f6 --- /dev/null +++ b/engine/love/build_windows.bat @@ -0,0 +1,14 @@ +call "C:\Program Files\7-Zip\7z.exe" a -r %1.zip -w ..\..\ -xr!engine/love -xr!builds -xr!.git -xr!*.moon -xr!conf.lua +rename %1.zip %1.love +copy /b "love.exe"+"%1.love" "%1.exe" +del %1.love +mkdir %1 +for %%I in (*.dll) do copy %%I %1\ +for %%I in (*.txt) do copy %%I %1\ +copy %1.exe %1\ +del %1.exe +call "C:\Program Files\7-Zip\7z.exe" a %1.zip %1\ +del /q %1\ +rmdir /q %1\ +copy %1.zip ..\..\builds\windows\ +del %1.zip diff --git a/engine/love/changes.txt b/engine/love/changes.txt new file mode 100644 index 0000000..5ae76fc --- /dev/null +++ b/engine/love/changes.txt @@ -0,0 +1,1350 @@ +LOVE 11.3 [Mysterious Mysteries] +-------------------------------- + +Released: 2019-10-27 + +* Added support for FLAC audio files. +* Added support for microphone recording on Android. +* Added t.audio.mic (false by default). On Android, setting it to true requests microphone recording permission from the user. +* Added Decoder:clone. +* Added Data:getFFIPointer. +* Added Joystick:getDeviceInfo. +* Added Joystick:getGamepadMappingString and love.joystick.getGamepadMappingString(guid). +* Added love.math.colorToBytes and love.math.colorFromBytes. +* Added 'usedpiscale' boolean (true by default) to love.window.setMode and love.conf. Disables automatic DPI scaling when false. +* Added love.window.getDisplayOrientation and a love.displayrotated callback. +* Added love.window.get/setVSync, to allow setting vsync without recreating the window. +* Added love.window.getSafeArea. +* Added an optional vertex count parameter to Mesh:setVertices. +* Added support for rgba4, rgb5a1, rgb565, rgb10a2, rg11b10f, r8, rg8, r16, rg16, r16f, rg16f, r32f, and rg32f formats in ImageData and Images. +* Added support for loading .dds files that contain uncompressed pixel data. + +* Changed audio file type detection, so it probes all supported backends for unrecognized extensions. + +* Fixed "bad lightuserdata" errors when running love on some arm64 devices. +* Fixed boot.lua's line numbers in stack traces to match its source code. +* Fixed the deprecation system not fully restarting when love.event.quit("restart") is used. +* Fixed love.isVersionCompatible. +* Fixed named Channels persisting across love.event.quit("restart") occurrences. +* Fixed race conditions when different love.physics Worlds are used in different threads. +* Fixed World:getJoints to return the fully resolved type of the Joint, instead of the base type. +* Fixed love.timer.sleep(0) to return control to the OS scheduler instead of being a no-op. +* Fixed love.math.randomNormal incorrectly using cached state after love.math.setRandomSeed or setRandomState. +* Fixed love.data.hash returning an incorrect hash for certain input sizes. +* Fixed love.data.newByteData to cause a Lua error instead of crashing when invalid arguments are used. +* Fixed the Data-returning variant of love.filesystem.read and File:read to return the number of bytes that were read. +* Fixed love.filesystem's require loaders to error instead of crashing when no argument is given. +* Fixed love.filesystem.mount(Data). +* Fixed a memory leak when loading files in some situations. +* Fixed t.audio.mixwithsystem. +* Fixed audio clicks immediately after playing a Source on iOS. +* Fixed Source:play + Source:stop + Source:play looping the first few ms of sound for streaming Sources on iOS. +* Fixed Source:play + Source:seek looping the first few ms of sound for streaming Sources on iOS. +* Fixed occasional pops in streaming sources on iOS. +* Fixed love.audio.play(sources) to use previously set playback positions on stopped Sources. +* Fixed Source:setEffect(name, true) and Source:getEffect(name) when the effect has no associated Filter. +* Fixed love.audio.newSource(filename, "queue") to cause a Lua error. +* Fixed Source:setPitch to error if the given pitch is <= 0, NaN, or infinity. +* Fixed video seeking and pausing in various scenarios. +* Fixed an audio Source memory leak when a Video gets garbage collected after playing it. +* Fixed video playback support on some Adreno-based Android devices. +* Fixed black fringes around text in some situations. +* Fixed extreme flickering when text moves along non-integer coordinates. +* Fixed the first character in a string sometimes not being processed during text vertex generation. +* Fixed Text:set(" ") not clearing any previously set text in a Text object. +* Fixed love.graphics.getTextureTypes to return a table with boolean values in its fields instead of number values. +* Fixed lines not rendering properly if a single line has more than 65,000 vertices. +* Fixed a pixel shader performance regression on some graphics drivers when OpenGL 3 or OpenGL ES 3 is used. +* Fixed text not showing up on Radeon HD 3000-series graphics cards on Windows. +* Fixed non-integer DPI scale values being truncated to integers in love.graphics.newCanvas. +* Fixed creating depth canvases on Windows systems when using an Intel HD 3000 GPU. +* Fixed automatic batching performance to be more consistent on all operating systems. +* Fixed gammaToLinearPrecise in shaders not being as precise as it should be. +* Fixed ImageData:paste and ImageData:setPixel to have more consistent clamping and rounding of color values when different formats are used. + +LOVE 11.2 [Mysterious Mysteries] +-------------------------------- + +Released: 2018-11-25 + +* Added Source:setAirAbsorption and Source:getAirAbsorption. +* Added Body:setTransform and Body:getTransform. + +* Improved performance of love.graphics.draw slightly on iOS and Android. + +* Fixed filesystem initialization on Windows 10 update 1809. +* Fixed compatibility with Lua 5.2 and 5.3. +* Fixed the explicit format + Data argument variant of love.data.decompress. +* Fixed love.joystick.setGamepadMapping not being able to change existing mappings. +* Fixed a crash on quit on Linux if a custom cursor is active when quitting. +* Fixed a crash in the Data variant of Shader:send when it's called after love.window.setMode. +* Fixed a love.graphics.setCanvas error message to be less confusing. + +LOVE 11.1 [Mysterious Mysteries] +-------------------------------- + +Released: 2018-04-15 + +* Fixed love.graphics.setCanvas failing randomly. +* Fixed love.graphics.clear(colortable) when no Canvas is active. +* Fixed stencil and depth support on older phones. +* Fixed love.event.quit causing crashes and other unexpected behaviour if a Canvas is active. +* Fixed Fixture:getShape crashing when returning a ChainShape. +* Fixed love.joystick.loadJoystickMappings outputting a deprecation warning about love.filesystem.isFile. +* Fixed Source:queue to show the correct argument name in the error message when an invalid data parameter is given. +* Fixed t.console=true causing an error on Windows if lovec.exe is used. + +LOVE 11.0 [Mysterious Mysteries] +-------------------------------- + +Released: 2018-04-01 + + * Added Object:release. + * Added Data:clone. + * Added queueable audio sources. + * Added audio input support. + * Added Source filters: low gain, high gain and band pass. + * Added audio effect APIs (reverb, echo, etc.) + * Added variants of SoundData:getSample/setSample which take a channel parameter. + * Added variants of all table-with-fields-returning get* functions, the new variants take an existing table to fill in. + * Added a variant to World:update, which accepts the number of iterations to run. The defaults are now 8 and 3. + * Added Body:isTouching. + * Added RopeJoint:setMaxLength. + * Added a click count argument to love.mousepressed and love.mousereleased. + * Added variants of love.filesystem.mount which accept a Data or FileData object containing zipped data. + * Added love.filesystem.get/setCRequirePath, and use that to find c libraries for require. + * Added variants of File:read and love.filesystem.read which take an enum to determine whether they return a FileData or a string. + * Added love.data module. It includes hex/base64 encoding functions, MD5 and SHA hashing, string packing, compression APIs, and more. + * Added Channel:hasRead, which checks if a message has been read. Takes an id, which Channel:push will now return. + * Added variants of Channel:demand and Channel:supply which take a timeout argument. + * Added Transform objects to love.math. + * Added support for different ImageData formats, including RGBA8 (the default), RGBA16, RGBA16F, and RGBA32F. + * Added the ability to load Radiance HDR, OpenEXR, and 16 bit PNG images. + * Added love.graphics.getImageFormats (replaces love.graphics.getCompressedImageFormats). + * Added the ability to specify a per-object pixel density scale factor when creating Images, Canvases, Fonts, and Videos. Affects drawing. + * Added Texture:getPixelWidth/Height and love.graphics.getPixelWidth/Height. + * Added Texture:getPixelDensity, love.graphics.getPixelDensity, and Font:getPixelDensity. + * Added Texture:getMipmapCount, getFormat, getLayerCount, getDepth, and getTextureType. + * Added Array, Cubemap, and Volume texture types and corresponding Image and Canvas APIs. + * Added love.graphics.getTextureTypes, returns a table with fields indicating support for each texture type. + * Added mipmapping support to Canvases, including both auto-generated mipmaps and manually rendering to a specific mipmap level. + * Added 'stencil8', 'depth24stencil8', 'depth32fstencil8', 'depth16', 'depth24', and 'depth32f' pixel formats for Canvases. + * Added variant of love.graphics.newCanvas which accepts a table of settings. + * Added optional 'readable' boolean field to the table passed into love.graphics.newCanvas. + * Added optional 'depthstencil' field to the table passed into love.graphics.setCanvas, for using a depth/stencil Canvas. + * Added optional 'depth' and 'stencil' boolean fields to the table passed into setCanvas, for enabling depth and stencil buffers if 'depthstencil' isn't used. + * Added shadow sampler support for Canvases. + * Added love.graphics.setDepthMode for using the depth buffer for depth testing/writes. Depth values of rendered objects can only be set via shaders. + * Added love.graphics.setMeshCullMode, for culling back- or front-facing triangles when drawing a Mesh. + * Added love.graphics.setFrontFaceWinding. + * Added variant of love.graphics.getCanvasFormats which takes a 'readable' boolean. + * Added love.graphics.drawLayer and SpriteBatch:add/setLayer for easily drawing layers of Array Textures. + * Added variants of love.graphics.print and printf which take a Font argument. + * Added variants of love.graphics.clear to control how the active depth and stencil buffers are cleared. + * Added love.graphics.applyTransform and love.graphics.replaceTransform. + * Added love.graphics.transformPoint and love.graphics.inverseTransformPoint. + * Added love.graphics.getStackDepth. + * Added love.graphics.flushBatch for manually flushing automatically batched draws. + * Added SpriteBatch:setDrawRange. + * Added per-shader opt in support for the GLSL 3.30 and GLSL ES 3.00 shading languages. + * Added 'void effect()' pixel shader entry point. + * Added love.graphics.validateShader. + * Added Shader:hasUniform. + * Added support for non-square shader uniform matrices on desktop platforms and on mobile GLSL 3. + * Added Shader:send(matrixname, is_column_major, matrix, ...) which specifies how to interpret the matrix table arguments. + * Added Shader:send variants which accept a Data object. + * Added 'borderellipse' and 'borderrectangle' ParticleSystem distributions. + * Added variant of ParticleSystem:setEmissionArea which accepts an area angle and a flag for whether particle directions are relative to the center of the area. + * Added ParticleSystem:set/getAreaSpreadAngle and set/getAreaSpreadIsRelativeDirection. + * Added love.graphics.captureScreenshot (replaces love.graphics.newScreenshot). + * Added 'glsl3', 'instancing', 'fullnpot','pixelshaderhighp', and 'shaderderivatives' graphics features. + * Added 'anisotropy' graphics limit. + * Added Mesh instancing support via love.graphics.drawInstanced and Mesh:attachAttribute. + * Added a Mesh:attachAttribute variant that takes a different target attribute name. + * Added Mesh:detachAttribute. + * Added a variant of Mesh:setVertexMap which accepts a Data object. + * Added love.window.updateMode. + * Added love.window.isMinimized. + * Added love.window.restore. + * Added the ability to prevent love from creating a stencil buffer for the window. + * Added cycle detection to Variant's table serialization, cycles now cause an error, rather than a stack overflow. + * Added love.graphics.newShader File and FileData variants. + * Added a default love.threaderror callback, which raises the error in the main thread. + * Added checks for invalid constants passed to love.keyboard.isDown/isScancodeDown. + * Added deprecation warnings, on by default for non-fused games. + * Added love.filesystem.getInfo. + * Added 'drawcallsbatched' to love.graphics.getStats. + * Added support for header-less DEFLATE to love.data.compress/decompress. + + * Deprecated love.filesystem.exists / isFile / isDirectory / isSymlink / getLastModified / getSize (use getInfo instead). + * Deprecated love.math.compress / decompress (use love.data.compress / decompress instead). + + * - All renamed APIs are formally deprecated rather than completely removed. + * Renamed love.window.getPixelScale to love.window.getDPIScale. + * Renamed love.mouse.hasCursor to love.mouse.isCursorSupported. + * Renamed ParticleSystem:setAreaSpread to ParticleSystem:setEmissionArea. + * Renamed love.errhand to love.errorhandler. + * Renamed Source/SoundData/Decoder:getChannels to getChannelCount. + * Renamed PrismaticJoint/RevoluteJoint:hasLimitsEnabled to areLimitsEnabled. + * Renamed love.audio.getSourceCount to love.audio.getActiveSourceCount. + * Renamed all get[Object]List functions to get[Object]s. + + * Removed the default source type for love.audio.newSource. + * Removed variant of love.filesystem.newFileData which takes base64 data, use love.data.decode instead. + * Removed the no-argument variant of Text:set, use Text:clear instead. + * Removed love.graphics.getCompressedImageFormats, use love.graphics.getImageFormats instead. + * Removed the 'void effects(...)' pixel shader entry point. Use the new 'void effect()' instead. + * Removed Shader:getExternVariable, use Shader:hasUniform instead. + * Removed love.graphics.newScreenshot, use love.graphics.captureScreenshot instead. + * Removed deprecated enet function host:socket_get_address. + * Removed functions deprecated in LÖVE 0.10.2: + * Removed Shader:sendInt, Shader:sendBoolean, Shader:sentFloat, Shader:sendMatrix, and Shader:sendTexture (use Shader:send instead). + * Removed love.window.isCreated (use love.window.isOpen instead). + + * Improved performance when drawing textures, shapes, lines, and points by automatically batching their draw calls together when possible. + * Improved performance of Shader:send when the Shader is not active. + * Improved performance of love.math.randomNormal when LuaJIT's JIT compiler is enabled. + * Improved performance of love.filesystem.lines and File:lines, especially when reading from a file inside a zip/.love. + + * Changed all color values to be in the range 0-1, rather than 0-255. + * Changed high-dpi functionality to require much less code (often none at all) for graphics to appear at the correct sizes and positions. + * Changed love.graphics.print and friends to ignore carriage returns. + * Changed the 'multiply' blend mode to error if not used with the 'premultiplied' blend alpha mode, since the formula only works with that anyway. + * Changed some love.graphics, love.window, and love.event APIs to cause an error if a Canvas is active. + * Changed stenciling functionality with a Canvas active to require stencil=true (or a custom stencil-formatted Canvas) to be set in setCanvas. + * Changed Mesh:setDrawRange to take 'start' and 'count' parameters instead of 'min' and 'max'. + * Changed the 'vsync' field of love.window.setMode and t.window in love.conf. It's now an integer with 0 disabling vsync. + * Changed the audio playback APIs drastically. + * Changed enet to no longer set the 'enet' global, again matching luasocket. + * Changed Source seeking behaviour, all kinds of Sources now behave similarly when seeking past the boundaries. + * Changed love.timer.step, it now returns dt. + * Changed love.run and love.errhand to return a function for their main loop, which gets called until love quits. + + * Updated and improved command line argument handling. + * Updated the boot sequence to show an error instead of the no-game screen, if a nonexistant folder is passed in as the source game directory. + * Updated 'love.exe --version' on Windows to print to the parent console. + * Updated Android print rerouting and JIT compilation disabling to apply inside threads. + * Updated invalid enum value error messages to show a list of the valid enum values. + * Updated Source:seek to work if the Source isn't playing. + * Updated love.event.poll to stop allocating memory unnecessarily. + * Updated love.math.random to have improved numeric distribution. + * Updated love.graphics to support Core Profile OpenGL 3.3+ when available. + * Updated shaders to always expose derivative functions (dFdx, dFdy, fwidth) when available in OpenGL ES. + * Updated shaders to allow using VERTEX and PIXEL in shader code. + * Updated love.graphics.circle/ellipse/arc/rectangle to take transformation scale into account when determining the number of segments to use. + * Updated Font glyph generation to improve antialiasing. + * Updated Canvas:newImageData to return an ImageData with a format that matches the Canvas' as closely as possible. + * Updated love.graphics.newImage to treat file names ending with "@2x", "@3x", etc. as a pixel density scale factor if none is explicitly supplied. + * Updated the error message when bad values are given to love.graphics.line. + * Updated the maximum love.graphics transformation/state stack depth from 64 to 128. + * Updated the default error handler to allow copying the error to the clipboard when the user decides to do so. + * Updated love.filesystem.setRequirePath to support multiple template '?' characters in each path. + * Updated luasocket to version 3.0rc1. + * Updated love.joystick.loadGamepadMappings so it doesn't error when given an empty string. + * Updated love.joystick.setGamepadMapping to use the controller's name for the new mapping when possible. + + * Fixed error in default error handler when the error message contains non UTF-8 bytes. + * Fixed a memory leak when sending love objects to threads which never load that object's module. + * Fixed a memory leak in enet when peer:send fails. + * Fixed os.execute always returning -1 in Linux. + * Fixed the default reference angle for WeldJoint, PrismaticJoint, and RevoluteJoint. + * Fixed Fixture:getShape to reuse the existing internal Fixture-owned shape. + * Fixed MouseJoint:setFrequency to error instead of crashing if a frequency of 0 is set. + * Fixed love.system.set/getClipboardText to error instead of crashing, when a window hasn't been created. + * Fixed Joystick:getGamepadMapping to work with xinput controllers. + * Fixed love.joystick.setGamepadMapping's replacement code. + * Fixed baseline calculation when rendering text. + * Fixed VaryingTexCoords and love_ScreenSize in shaders to be 'highp' in OpenGL ES, when supported. + * Fixed ParticleSystem:setParticleLifetime to error if a negative value is given. + * Fixed Shader:send and Shader:sendColor ignoring the last argument for an array. + * Fixed a crash when love.graphics.pop is called after a love.window.setMode while the transformation stack was not empty. + * Fixed love.window.isMaximized. + * Fixed video playback to work with a wider range of Ogg Theora files. + * Fixed video seeking to be faster. + * Fixed BezierCurves to error instead of hanging in some situations. + * Fixed compilation of luasocket with newer luajit 2.1.0 beta versions. + +LOVE 0.10.2 [Super Toast] +------------------------- + +Released: 2016-10-31 + + * Added lovec.exe in Windows. It is the same as love.exe but built with the Console subsystem, so it always uses or provides a console. + * Added the ability to restart the game via love.event.quit("restart"). + * Added support for passing a table to love.mouse.isDown, love.keyboard.isDown, love.keyboard.isScancodeDown, Joystick:isDown, and Joystick:isGamepadDown. + * Added love.window.isMaximized. + * Added 'shaderswitches' field to the table returned by love.graphics.getStats. + * Added Quad:getTextureDimensions. + * Added 'ellipse' area distribution to ParticleSystems. + * Added support for BC4-7 compressed texture formats in KTX files. + * Added PrismaticJoint:getAxis and WheelJoint:getAxis. + * Added 2-point version of love.physics.newRevoluteJoint. + * Added table variants of Fixture:setCategory and Fixture:setMask. + * Added getNextVertex and getPreviousVertex to ChainShape and EdgeShape. + * Added optional reference angle arguments to RevoluteJoint, PrismaticJoint, and WeldJoint constructors. + * Added RevoluteJoint:getReferenceAngle, PrismaticJoint:getReferenceAngle, and WeldJoint:getReferenceAngle. + + * Deprecated undocumented Shader:sendTexture, Shader:sendMatrix, Shader:sendInt, and Shader:sendFloat functions. + + * Fixed love on iOS 6. + * Fixed os.execute always returning -1 on Linux. + * Fixed the love.lowmemory callback to call collectgarbage() after the callback has fired, instead of before. + * Fixed love.math.noise(nil) to error instead of returning nil. + * Fixed an occasional crash when a Thread ends. + * Fixed a hang at the end of video playback with some video files. + * Fixed the video decoding thread to not do any work when there are no videos to decode. + * Fixed love.graphics.newVideo(file) to no longer error if love.audio is disabled. + * Fixed a rare bug in Source:play for streaming Sources if the associated OpenAL source object was previously used for a static Source. + * Fixed corrupted Font glyphs in rare cases. + * Fixed stencils inside Canvases on some OpenGL ES 2 devices. + * Fixed an OpenGL error in OpenGL ES 3 when multiple render targets are used. + * Fixed love.window.setMode crashing when called with a Canvas active. + * Fixed love.window.maximize to update the reported window dimensions immediately. + * Fixed gamma correction of ImageFonts and BMFonts with colored images. + * Fixed the default shader improperly applying gamma correction to per-vertex colors when gamma correction is requested but not supported on OpenGL ES. + * Fixed text coloring breaking because of an empty string. + * Fixed large burst of particles when dramatically increasing the emission rate of a ParticleSystem. + * Fixed SpriteBatch:setBufferSize to keep old sprite data if it can fit. + * Fixed MouseJoint:getBodies unconditionally erroring. + * Fixed memory leak in Text:set. + * Fixed incorrect kerning caused by using kerning information for the wrong character in some fonts. + * Fixed ImageData:setPixel/getPixel/mapPixel and SoundData:setSample/getSample to properly handle non-integer coordinates. + + * Improved performance of Channel methods by roughly 2x in many cases. + * Improved performance of Shader:send when small numbers of arguments are given. + + * Updated love.filesystem.mount to accept a DroppedFile as the first parameter. + * Updated Shader:send to do type and argument checking based on the specified uniform variable's information instead of the arguments to the function. + * Updated Shader:send to accept a flat table for matrix uniforms. + + +LOVE 0.10.1 [Super Toast] +------------------------- + +Released: 2016-02-14 + + * Added a new love.conf flag t.externalstorage, which determines whether files are saved in internal or external storage on Android devices. + * Added a new variant of love.graphics.arc which can draw different types of arcs ("pie", "open", or "closed"). + * Added "lighten" and "darken" BlendModes. They can only be used with the "premultiplied" BlendAlphaMode. + * Added the "lighten" GraphicsFeature constant. + * Added the ability to avoid clearing specific Canvases when calling love.graphics.clear, if multiple Canvases are active at once via love.graphics.setCanvas. + * Added Text:getDimensions. + * Added optional "collideconnected" argument to love.physics.newMotorJoint. + + * Fixed a Lua error in the no-game screen if the window's height is too small. + * Fixed the default error handler to reset the mouse Cursor. + * Fixed love.filesystem functions crashing when called if liblove is used directly without calling love.filesystem.init. + * Fixed audio on Android to pause when the app is inactive, and resume when the app becomes active again. + * Fixed the Video decoding thread hanging after Video:seek or when a Video finishes. + * Fixed Video:isPlaying to always return false after it finishes playing. + * Fixed RandomGenerator:random crashing if a nil 'self' is used. + * Fixed loading BMFont files which have characters with 0 width or height (a space character, for example). + * Fixed love.graphics.newFont causing crashes if FileData is passed in. + * Fixed love.graphics.clear(colortable) causing crashes on OpenGL ES 2 systems when a Canvas is active. + * Fixed a driver bug on some Android devices which caused all objects to show up as black. + * Fixed a driver bug on Windows with AMD graphics cards where love.graphics.clear would not always work. + * Fixed Shader:sendColor incorrectly converting alpha values from sRGB to linear RGB when gamma-correct rendering is enabled. + * Fixed love.graphics.newMesh(vertices) double-converting colors from sRGB to linear RGB when gamma-correct rendering is enabled. + * Fixed love.graphics.new* crashing when there is no graphics context/window. + + * Updated the Windows executable to prefer the high-powered AMD graphics card on systems which have switchable Intel+AMD GPUs. + * Updated love.touch.getTouches to return the list of IDs in the relative order that the touches initially happened, instead of being in a random order. + * Updated the error messages caused by invalid or bad arguments to ImageData and SoundData methods to be more descriptive. + + +LOVE 0.10.0 [Super Toast] +------------------------- + +Released: 2015-12-22 + + * Added an iOS port. + * Added an Android port. + * Added the flag t.accelerometerjoystick to love.conf. Disables accelerometer-as-joystick functionality on mobile devices when false. + * Added the flag t.gammacorrect to love.conf (replaces t.window.srgb.) Enabling it globally enables gamma-correct rendering, when supported. + * Added video playback support for Ogg Theora videos, via love.graphics.newVideo and Video objects. + * Added love.video module. It is not used for displaying videos on-screen, only decoding them. + * Added love.touch module. Note that it has important differences from the touch implementation in the LÖVE 0.9 Android and iOS ports. + * Added love.touchpressed, love.touchreleased, and love.touchmoved. + * Added love.system.vibrate. + * Added love.filesystem.setRequirePath and love.filesystem.getRequirePath. + * Added an optional program exit argument to love.event.quit. + * Added love.filedropped and love.directorydropped event callback functions. + * Added love.lowmemory event callback function, called when the app is running out of memory on mobile operating systems. + * Added love.textedited event callback function, called when the user is compositing text (e.g. via an IME.) + * Added love.wheelmoved event callback function (replaces "wu" and "wd" constants for love.mousepressed.) + * Added love.mouse.hasCursor. + * Added a boolean argument to love.mousepressed and love.mousereleased indicating whether the button event originated from a touch press. + * Added optional x/y/width/height arguments to love.keyboard.setTextInput. They tell the system where text will show up so on-screen keyboards can avoid that area. + * Added Source:getType (replaces Source:isStatic.) + * Added Source:getDuration and Decoder:getDuration. + * Added an optional string argument containing raw pixel byte data to the width/height variant of love.image.newImageData. + * Added love.graphics.ellipse. + * Added rounded-rectangle support to love.graphics.rectangle. + * Added love.graphics.points (replaces love.graphics.point.) + * Added love.graphics.intersectScissor. + * Added an optional argument to love.graphics.setBlendMode which indicates whether to treat the colors of drawn objects as having pre-multiplied alpha. + * Added love.graphics.getSupported (replaces love.graphics.isSupported.) + * Added love.graphics.getSystemLimits (replaces love.graphics.getSystemLimit.) + * Added love.graphics.stencil and love.graphics.set/getStencilTest (replaces love.graphics.setStencil.) + * Added love.graphics.isActive. + * Added color arguments to love.graphics.clear. It no longer always uses the background color value. + * Added love.graphics.discard. + * Added love.graphics.isGammaCorrect. + * Added the "clampzero" WrapMode. + * Added the ability to specify custom mipmaps when creating an image, via love.graphics.newImage(filename, {mipmaps={mip1, mip2, ...}}) + * Added optional x/y/width/height arguments to Image:refresh and Canvas:newImageData. + * Added Image:getFlags. + * Added one- and two-channel Canvas formats: r8, rg8, r16f, rg16f, r32f, and rg32f. + * Added support for different formats in each Canvas when using multi-canvas rendering. Added the "multicanvasformats" Graphics Feature constant. + * Added support for OpenGL ES 2 and 3. + * Added support for loading ETC, EAC, PVRTC, and ASTC compressed textures on systems that support them. + * Added custom vertex attribute support for Meshes via new variants of love.graphics.newMesh. + * Added Mesh:setVertexAttribute and Mesh:getVertexAttribute. + * Added Mesh:getVertexFormat. + * Added Mesh:flush. + * Added an optional 'startvertex' argument to Mesh:setVertices. + * Added the ability for love.graphics.newMesh and Mesh:setVertices to accept a Data object. + * Added Mesh:setAttributeEnabled and Mesh:isAttributeEnabled. + * Added Mesh:attachAttribute. + * Added SpriteBatch:attachAttribute. + * Added Shader:sendColor. + * Added new shader functions: gammaCorrectColor, gammaToLinear, and linearToGamma. The functions also have 'precise' and 'fast' variants. + * Added Text objects and love.graphics.newText. + * Added per-character color support to love.graphics.print/printf and to Text objects. + * Added BMFont bitmap font file support to love.graphics.newFont and love.font. + * Added kerning support for TrueType/OpenType and BMFont Fonts. + * Added an optional font hinting argument to love.graphics.newFont when loading TrueType fonts. + * Added an optional spacing argument to love.graphics.newImageFont, which applies additional spacing to all rendered glyphs. + * Added Font:setFallbacks. + * Added love.window.maximize. + * Added love.window.close. + * Added love.window.requestAttention. + * Added love.window.setDisplaySleepEnabled and love.window.isDisplaySleepEnabled. + * Added BezierCurve:renderSegment and BezierCurve:removeControlPoint. + * Added BezierCurve:getSegment. + * Added love.math.compress and love.math.decompress. + * Added Channel:performAtomic. + + * Changed love.mousepressed, love.mousereleased, and love.mouse.isDown to use button numbers instead of named button constants. + * Changed love.keypressed to be love.keypressed(key, scancode, isrepeat). + * Changed love.keyreleased to be love.keyreleased(key, scancode). + * Changed Font:getWrap's second return value to be a table containing the text split into lines. + * Changed love.graphics.newImage's optional second argument to be a table of flags (flags are "mipmaps" and "linear".) + * Changed the arguments for the standard variants of love.graphics.newMesh to newMesh(vertices [, drawmode, usage]) and newMesh(vertexcount [, drawmode, usage]). + * Changed ImageData:encode to return a FileData object. ImageData:encode's first parameter is now the format to encode to, and the second parameter is an optional filename to write to. + + * Renamed the "normal" Fullscreen Type to "exclusive". + * Renamed the DistanceModel constants "inverse clamped", "linear clamped", and "exponent clamped" to "inverseclamped", "linearclamped", and "exponentclamped". + * Renamed the "additive", "subtractive", and "multiplicative" BlendModes to "add", "subtract", and "multiply". + * Renamed the KeyConstant and Scancode representing the spacebar from " " to "space". + * Renamed File:eof to File:isEOF. + * Renamed Canvas:getImageData to Canvas:newImageData. + * Renamed love.image's CompressedData type to CompressedImageData. + + * Removed callback variant of love.filesystem.getDirectoryItems. + * Removed the "wu" and "wd" constants for love.mousepressed (replaced by love.wheelmoved.) + * Removed the named mouse button constants (replaced by button numbers.) + * Removed Source:isStatic (replaced by Source:getType.) + * Removed image loading support for all (non-compressed texture) file formats except for PNG, JPEG, TGA, and BMP. + * Removed JPEG encoding support from ImageData:encode. + * Removed love.graphics.point (replaced by love.graphics.points.) + * Removed love.graphics.setPointStyle and love.graphics.getPointStyle. + * Removed love.graphics.isSupported (replaced by love.graphics.getSupported.) + * Removed love.graphics.getSystemLimit (replaced by love.graphics.getSystemLimits.) + * Removed love.graphics.setStencil (replaced by love.graphics.stencil and love.graphics.setStencilTest.) + * Removed the "canvas", "shader", "npot", "subtractive", and "mipmap" Graphics Feature constants (the features always have guaranteed support now.) + * Removed the "multicanvas" Graphics Feature constant (use love.graphics.getSystemLimits instead.) + * Removed the "srgb" Graphics Feature constant (use love.graphics.isGammaCorrect() or love.graphics.getCanvasFormats().srgb instead.) + * Removed the "srgb" flag in love.window.setMode and in the t.window table in love.conf (Replaced by t.gammacorrect.) + * Removed the "premultiplied" blend mode (love.graphics.setBlendMode("alpha", "premultiplied") now does the same thing.) + * Removed Canvas:getPixel (use Canvas:newImageData instead.) + * Removed Canvas:clear (use love.graphics.clear instead.) + * Removed Mesh:getVertices. + * Removed Mesh:setVertexColors and Mesh:hasVertexColors (use Mesh:setAttributeEnabled("VertexColor", enable) instead.) + * Removed functions deprecated in LOVE 0.9.1 and 0.9.2: + * Removed love.graphics.getMaxImageSize and love.graphics.getMaxPointSize (replaced by love.graphics.getSystemLimits.) + * Removed Mesh:set/getImage, SpriteBatch:set/getImage, and ParticleSystem:set/getImage (replaced by set/getTexture.) + * Removed SpriteBatch:bind/unbind. + * Removed Canvas:getFSAA and the "fsaa" flag in love.conf and love.window.setMode (replaced by Canvas:getMSAA and "msaa".) + * Removed the "dxt" and "bc5" Graphics Feature constant (replaced by love.graphics.getCompressedImageFormats.) + * Removed the "hdrcanvas" Graphics Feature constant (replaced by love.graphics.getCanvasFormats.) + * Removed love.window.getWidth/getHeight/getDimensions (use love.graphics.getWidth/getHeight/getDimensions or love.window.getMode instead.) + + * Fixed utf8.char. + * Fixed detection of fused love games. + * Fixed World:getCallbacks and World:getContactFilter when used in coroutines. + * Fixed crashes when objects which store Lua callback functions are garbage collected after being used in coroutines. + * Fixed memory leaks in love.physics if World:destroy is never called. When a World is GCed it now destroys all objects it owns. + * Fixed love.keyboard.getKeyFromScancode crashing when an invalid scancode is given. + * Fixed decoding of 8-bit WAV files. + * Fixed a crash issue when rewinding streaming ogg Sources, when certain versions of libvorbis are used. + * Fixed love.audio.stop() not rewinding streaming Sources. + * Fixed the stencil buffer in Canvases when an unsupported MSAA value is used to create the Canvas. + * Fixed Canvas:renderTo to restore the previous Canvas if an error occurs in the passed function. + * Fixed love.graphics.draw(canvas) to cause an error if that Canvas is the active one. + * Fixed Mesh:getVertexMap to return nil rather than an empty table, if no vertex map has been set. + * Fixed love.graphics.getColorMask. + * Fixed the default offset for particles when ParticleSystem:setQuads or ParticleSystem:setTexture is used. + * Fixed love.graphics.shear resetting all love.graphics transformations. + * Fixed the "add" and "subtract" blend modes to no longer modify the alpha of the Canvas / screen. + + * Improved the performance of World:rayCast and World:queryBoundingBox. + * Improved the performance of love.graphics.line and other line drawing functions, when the "smooth" LineStyle is used. + * Improved the performance of Shader:send when matrices are used. + * Improved the performance of ImageData and SoundData methods when LuaJIT's JIT compiler is enabled, by using efficient FFI code. + * Improved the performance of love.math.noise, love.math.gammaToLinear, love.math.linearToGamma, love.math.random, and RandomGenerator:random when LuaJIT's JIT compiler is enabled. + + * Updated the compatibility warning notice to use a message box and to show the version specified in love.conf. + * Updated the compatibility warning notice to display before main.lua is loaded. + * Updated the __tostring metamethod of love objects to output the pointer value, similar to tostring(table). + * Updated World:setCallbacks, World:setContactFilter, World:queryBoundingBox, and World:rayCast to have improved argument type checking. + * Updated threads to load love.filesystem automatically. + * Updated love.filesystem to enable symlinks by default. + * Updated love.math.setRandomSeed and RandomGenerator:setSeed to produce better results for the first few random() calls. + * Updated love.math.random and RandomGenerator:random to produce slightly better results in general. + * Updated Source methods that deal with spatial audio to error rather than failing silently if the Source isn't mono. + * Updated the 3D and 4D variants of love.math.noise to use Perlin noise rather than Simplex noise, to avoid patent issues. + * Updated ImageFonts to no longer treat separator pixels as spacing. + * Updated the default font to use less memory. + * Updated the behavior of text wrapping with love.graphics.printf and Font:getWrap to work better. + * Updated love.graphics.print and love.graphics.printf to no longer automatically round the x and y position arguments. + * Updated some error messages for love.graphics.newImage to be more descriptive. + * Updated love.graphics color functions to automatically apply love.math.gammaToLinear to color values when gamma-correct rendering is enabled. + * Updated the 'normal' Canvas format to internally use 'srgb' rather than 'rgba8' when gamma-correct rendering is enabled. + * Updated love.graphics.setColor to affect all drawn objects, including ParticleSystems, SpriteBatches, and Meshes. + * Updated the default fullscreen type to be "desktop" rather than "exclusive". + * Updated the minimum runtime system requirements of LOVE to require OpenGL 2.1 or OpenGL ES 2 support. + * Updated the pixel shader effect function so screen_coords.y is 0 at the top of the screen instead of the bottom. + * Updated Images to require setting the mipmaps flag to true on creation in order to use mipmaps. + * Updated Images to allow mipmaps for non-power-of-two sizes. + +LOVE 0.9.2 [Baby Inspector] +--------------------------- + + Released: 2015-02-14 + + * Added Lua 5.3's UTF-8 module (via utf8 = require("utf8")). + * Added Shader:getExternVariable. + * Added several new canvas texture formats. + * Added love.graphics.getCanvasFormats. + * Added love.graphics.getCompressedImageFormats. + * Added ParticleSystem:setQuads. + * Added ParticleSystem:setLinearDamping. + * Added SpriteBatch:flush. + * Added love.graphics.getStats. + * Added "mirroredrepeat" wrap mode. + * Added love.audio.setDopplerScale and love.audio.getDopplerScale. + * Added optional duration argument to Joystick:setVibration. + * Added love.joystick.loadGamepadMappings and love.joystick.saveGamepadMappings. + * Added Joint:setUserData and Joint:getUserData. + * Added Joint:getBodies. + * Added GearJoint:getJoints. + * Added Contact:getFixtures and Body:getContactList. + * Added Body:getWorld. + * Added Body:getJointList. + * Added Body/Contact/Fixture/Joint/World:isDestroyed. + * Added love.mousemoved event callback. + * Added love.mouse.setRelativeMode and love.mouse.getRelativeMode. + * Added Scancode enums, love.keyboard.getKeyFromScancode, and love.keyboard.getScancodeFromKey. + * Added love.window.getDisplayName. + * Added love.window.minimize. + * Added love.window.showMessageBox. + * Added 'refreshrate' field to the table returned by love.window.getMode. + * Added love.window.toPixels and love.window.fromPixels. + * Added love.window.setPosition and love.window.getPosition, and 'x' and 'y' fields to love.window.setMode and t.window in love.conf. + * Added love.filesystem.isSymlink, love.filesystem.setSymlinksEnabled, and love.filesystem.areSymlinksEnabled. + * Added love.filesystem.getRealDirectory. + + * Deprecated SpriteBatch:bind and SpriteBatch:unbind. + * Deprecated all uses of the name 'FSAA' in favor of 'MSAA'. + * Deprecated the 'hdrcanvas' graphics feature enum in favor of getCanvasFormats. + * Deprecated the 'dxt' and 'bc5' graphics feature enums in favor of getCompressedImageFormats. + + * Fixed crashes when love objects are used in multiple threads. + * Fixed love.filesystem.setIdentity breaking in some situations when called multiple times. + * Fixed the default love.filesystem identity when in Fused mode in Windows. + * Fixed love.system.openURL sometimes blocking indefinitely on Linux. + * Fixed love.joystick.setGamepadMapping. + * Fixed the order of vertices in ChainShapes. + * Fixed love.mouse.getPosition returning outdated values if love.mouse.setPosition is used in the same frame. + * Fixed love.graphics.newFont to error when given an invalid size argument. + * Fixed the filename and backtrace given when love.graphics.print errors. + * Fixed a small memory leak if love.graphics.newCanvas errors. + * Fixed shader:getWarnings returning unnecessary information. + * Fixed some cases of noncompliant shader code not properly erroring on some nvidia drivers. + * Fixed a potential crash when Shader objects are garbage collected. + * Fixed a potential small memory leak triggered when love.graphics.newShader errors. + * Fixed love.graphics.newMesh(vertexcount, ...) causing the Mesh to do instanced rendering. + * Fixed Mesh:getVertexMap. + * Fixed Image:refresh generating mipmaps multiple times if mipmap filtering is enabled. + * Fixed Image:setMipmapFilter to not keep bad state around if it errors. + * Fixed Mesh:setDrawRange when the Mesh has a vertex map set. + * Fixed internal detection of the 'position' and 'effect' shader functions. + * Fixed Texture memory leak when Meshes are garbage collected. + * Fixed the default line join mode to be 'miter' instead of an undefined value. + * Fixed the default error handler text size when highdpi mode is enabled on a Retina monitor. + * Fixed the default error handler background color when sRGB mode is enabled for the window. + * Fixed love.window.setMode to fall back to the largest available mode if a width or height greater than the largest supported is specified and fullscreen is used. + * Fixed the state of wireframe mode when love.window.setMode is called. + * Fixed Canvas:getPixel to error if the coordinates are not within the Canvas' size. + * Fixed detection of compressed textures to work regardless of the file's extension. + + * Renamed all cases of FSAA to MSAA. The FSAA names still exist for backward-compatibility. + + * Updated the Windows executable to automatically prefer the higher performance GPU on nvidia Optimus systems. + * Updated the --console command-line argument in Windows to open the console before conf.lua is loaded. + * Updated t.console and the --console command-line argument in Windows to use the existing Console window, if love was launched from one. + * Updated the love executable to verify that the love library's version matches. + * Updated the Lua wrapper code for modules to avoid crashes when the module's instance is created, deleted, and recreated. + * Updated internal code for handling garbage collection of love objects to be more efficient. + * Updated love's initialization code to trigger a Lua error if love.conf has an error in it. + * Updated the paths returned by love.filesystem.getSaveDirectory and friends to strip double-slashes from the string. + * Updated the error message when love.filesystem.write or File:open fails because the directory doesn't exist. + * Updated the error message when love.math.setRandomseed(0) is attempted. + * Updated the error message when invalid UTF-8 strings are used in love functions that expect UTF-8. + * Updated love.physics.newPolygonShape and love.physics.newChainShape to accept a table of vertices. + * Updated love.physics.newChainShape to error if the number of arguments is invalid. + * Updated love.thread.newThread to accept a literal string of code directly. + * Updated love-created threads to use names visible in external debuggers. + * Updated SpriteBatch:unbind to use less VRAM if the SpriteBatch has the static usage hint. + * Updated love.graphics.newImage, love.image.newImageData, etc. to leave less Lua-owned memory around. + * Updated love.graphics.push to accept different stack types to push. Current types are "transform" and "all". + * Updated love shaders to accept GLSL ES precision qualifiers on variables, although they do nothing. + * Updated the error message for love.graphics.newShader to be less cryptic if an invalid filename is given. + * Updated compressed texture loading code to allow BC6 and BC7 compressed textures (if the graphics driver supports them.) + +LOVE 0.9.1 [Baby Inspector] +--------------------------- + + Released: 2014-04-01 + + * Added Source:clone. + * Added blend mode "screen". + * Added ParticleSystem:clone. + * Added ParticleSystem:moveTo, has smoother emitter movement compared to setPosition. + * Added ParticleSystem:setRelativeRotation. + * Added love.graphics.setWireframe for debugging. + * Added Mesh:setDrawRange and Mesh:getDrawRange. + * Added CircleShape:getPoint and CircleShape:setPoint. + * Added Mesh/SpriteBatch/ParticleSystem:setTexture, accepts Canvases and Images. + * Added high-dpi window support for Retina displays in OS X, via the 'highdpi' window flag. + * Added love.window.getPixelScale. + * Added love.graphics.getSystemLimit. + * Added antialiasing support to Canvases. + * Added Canvas:getFSAA. + * Added 'love_ScreenSize' built-in variable in shaders. + * Added love.getVersion. + * Added support for gamma-correct rendering. + * Added love.graphics.isSupported("srgb"). + * Added love.math.gammaToLinear and love.math.linearToGamma. + * Added RandomGenerator:getState and RandomGenerator:setState. + * Added Body:setUserData and Body:getUserData. + * Added some missing obscure key constants. + * Added optional callback function argument to love.filesystem.getDirectoryItems. + * Added love.system.openURL. + + * Deprecated Mesh/SpriteBatch/ParticleSystem:setImage. + * Deprecated love.graphics.getMaxImageSize and love.graphics.getMaxPointSize. + + * Fixed love.graphics.scale with negative values causing incorrect line widths. + * Fixed Joystick:isDown using 0-based button index arguments. + * Fixed Source:setPitch to error when infinity or NaN is given. + * Fixed love.graphics.setCanvas() to restore the proper viewport and scissor rectangles. + * Fixed TrueType font glyphs which request a monochrome bitmap pixel mode. + * Fixed love.graphics.reset causing crashes when called in between love.graphics.push/pop. + * Fixed tab characters ("\t") to display properly with love.graphics.print. + * Fixed love.graphics.isCreated to return false when love.window.setMode fails completely. + * Fixed love.window.setMode to not destroy OpenGL resources before checking whether a fullsceren size is supported. + * Fixed World:getBodyList and World:getJointList causing hard crashes. + * Fixed loading BC4 compressed textures. + * Fixed SoundData objects being initialized with garbage values. + * Fixed 8-bit SoundData samples when used in love.audio Sources. + + * Updated the error text for love.filesystem’s module searchers when require fails. + * Updated the love.filesystem module searchers to be tried after package.preload instead of before. + * Updated love.graphics.newParticleSystem, newSpriteBatch, and newMesh to accept Canvases. + * Updated Canvas drawing code, texture coordinates are no longer flipped vertically. + * Updated Canvas:renderTo to work properly if a Canvas is currently active. + * Updated ParticleSystem:setEmissionRate to accept non-integer numbers. + * Updated Source:play to return a boolean indicating success. + * Updated t.console in conf.lua to create the console before modules are loaded in Windows. + * Updated Mesh vertex maps (index buffers) to use less space in VRAM. + * Updated love.graphics.newMesh and Mesh:setVertices to default the UV parameters to 0,0. + * Updated Fixture:set/getUserData to work in Coroutines. + * Updated fullscreen-desktop and resizable window modes in OS X to use Mac OS 10.7's fullscreen Spaces. + * Updated love.filesystem's C library loader to look in paths added via love.filesystem.mount, in Fused mode. + * Updated the default love.run code to make initial love.math.random calls more random. + +LOVE 0.9.0 [Baby Inspector] +--------------------------- + + Released: 2013-12-13 + + * Added better multiplayer networking support via ENet. + * Added --fused command line argument, to simulate fusing. + * Added liblove. + * Added the ability to have exit values. + * Added exit value of 1 in case of error by default. + * Added basic support for the file:// uri scheme. + * Added love.filesystem.isFused. + * Added love.filesystem.getIdentity. + * Added love.filesystem.append. + * Added love.filesystem.getSize. + * Added love.filesystem.mount and love.filesystem.unmount. + * Added optional file search order parameter to love.filesystem.setIdentity. + * Added File:isOpen and File:getMode. + * Added Fie:setBuffer, File:getBuffer, and File:flush. + * Added textinput event for unicode text input. + * Added love.keyboard.setTextInput and love.keyboard.hasTextInput. + * Added previously internal Rasterizer and GlyphData object methods. + * Added support for UTF-8 ImageFonts. + * Added Font:getAscent/getDescent/getBaseline. + * Added Font:setFilter/getFilter. + * Added Font:hasGlyphs. + * Added angle, scale, and shear parameters to love.graphics.printf. + * Added HDR canvas support. + * Added mipmapping support (has isSupported test). + * Added vertex shader support. + * Added boolean support to Shader:send. + * Added Canvas:getPixel. + * Added blend mode "replace". + * Added line join modes. + * Added Mesh objects, allowing for arbitrary textured polygons. + * Added multiple render target support to love.graphics.setCanvas. + * Added love.graphics.setColorMask. + * Added love.graphics.origin. + * Added love.graphics.getRendererInfo. + * Added love.graphics.getMaxImageSize. + * Added SpriteBatch:getCount and SpriteBatch:getBufferSize. + * Added SpriteBatch:getColor. + * Added ParticleSystem:emit. + * Added ParticleSystem:setInsertMode and ParticleSystem:getInsertMode. + * Added many ParticleSystem getter methods. + * Added DXT compressed texture support via love.image.newCompressedData. + * Added love.image.isCompressed and Image:isCompressed. + * Added Image/Canvas/ImageData:getDimensions. + * Added anisotropic filtering support for Images, Canvases, and Fonts. + * Added Image:refresh. + * Added Image:getData. + * Added SoundData:getDuration and SoundData:getSampleCount. + * Added Source:isPlaying. + * Added Source:setRelative and Source:isRelative. + * Added Source:setCone and Source:getCone. + * Added Source:getChannels. + * Added new Channels API for love.thread. + * Added limited table support to Channel:push. + * Added Thread:getError. + * Added Thread:isRunning. + * Added threaderror event. + * Added love.math module. + * Added a platform-independent (good) random implementation to love.math. + * Added RandomGenerator objects. + * Added BezierCurve objects. + * Added love.math.triangulate and love.math.isConvex. + * Added love.math.noise. + * Added love.timer.getAverageDelta. + * Added Data:getString. + * Added Contact:getChildren. + * Added love.system module. + * Added love.system.getClipboardText and love.system.setClipboardText. + * Added love.system.getOS and love.system.getProcessorCount. + * Added love.window module. + * Added love.window.isVisible. + * Added flags to love.window.setMode. + * Added monitor choosing support to love.window.setMode. + * Added support for resizable, borderless, and non-centered windows. + * Added support for "fullscreen-desktop" mode. + * Added window resize and visible events. + * Added love.window.getDimensions. + * Added love.window.getIcon. + * Added t.window.icon to love.conf. + * Added love.mousefocus and love.window.hasMouseFocus. + * Added custom hardware cursors via love.mouse.newCursor. + * Added love.mouse.setX/setY. + * Added Joystick objects. + * Added love.joystick.getJoystick. + * Added joystick connect and disconnect events. + * Added joystickaxis and joystickhat events. + * Added unified Gamepad API for joysticks which have a similar layout to the Xbox controller. + * Added joystick vibration support, works with most common gamepads. + * OPTIONAL: Added support for Game Music Emu. + + * Fixed fused mode in OS X. + * Fixed printing to the console in Windows before love.load is called. + * Fixed the default love.run to not include the time taken by love.load in the first frame's dt. + * Fixed the error screen not always appearing until the next input event. + * Fixed love.event.clear. + * Fixed love.mouse.setPosition when called in love.load. + * Fixed scaling in several love.physics functions. + * Fixed Box2D exception in World:update. + * Fixed many uncaught Box2D / love.physics exceptions for Bodies and Joints. + * Fixed ChainShape:getPoints running out of Lua stack space and crashing. + * Fixed File:read reading past end of file. + * Fixed love.filesystem.setIdentity not removing read access from old directories. + * Fixed possible memory leak in utf-8 decoder. + * Fixed spacing for the last character in an ImageFont. + * Fixed line wrapping in love.graphics.printf. + * Fixed love.graphics.printf to error if the wrap limit is negative. + * Fixed love.graphics.print truncating strings with embedded zeros. + * Fixed crashes with font drawing on some ATI cards. + * Fixed artifacts when drawing lines at huge scale. + * Fixed Fonts and Canvases ignoring default image filter. + * Fixed scissor boxes when a canvas is set after love.graphics.setScissor is called. + * Fixed love.graphics.getLineWidth returning incorrect values. + * Fixed love.graphics.getColor on some Windows systems. + * Fixed alpha blend mode. + * Fixed multiplicative blend mode. + * Fixed love.graphics.getPointStyle. + * Fixed line numbers in shader errors. + * Fixed Shader:send with Images and Canvases failing sometimes. + * Fixed Shader:send to keep a reference to sent Images and Canvases. + * Fixed crash when binding SpriteBatches multiple times. + * Fixed SpriteBatches with more than 16,384 sprites. + * Fixed particle draw order for ParticleSystems. + * Fixed ParticleSystem:setSizes resetting the size variation. + * Fixed the graphics viewport not matching the window size when using an unsupported fullscreen mode. + * Fixed getMode and friends returning wrong values when using desktop size. + * Fixed keyrepeat settings being lost after (indirect) setMode. + * Fixed the icon being reset after setMode. + * Fixed memory leak in the mp3 decoder. + * Fixed sound issues with some versions of OpenAL soft, by enabling direct channels. + * Fixed 'random' hangs in audio. + * Fixed love.sound.newDecoder not accepting FileData. + * Fixed case (in)sensitivity of sound file extension parsing. + * Fixed looping support in tracker music formats. + * Fixed skipping/looping issues when playing streaming audio Sources. + * Fixed race condition in Source:play. + * Fixed WAVE sound playback. + + * Moved love's startup to modules/love. + * Moved window-related functions from love.graphics to love.window. + + * Renamed love's boot script to 'love.boot', which can be required. + * Renamed love.filesystem.mkdir to love.filesystem.createDirectory. + * Renamed love.filesystem.enumerate to love.filesystem.getDirectoryItems. + * Renamed World:setAllowSleeping to World:setSleepingAllowed. + * Renamed ChainShape:setPrevVertex to ChainShape:setPreviousVertex. + * Renamed Joint:enableMotor to Joint:setMotorEnabled. + * Renamed Joint:enableLimit and Joint:isLimitEnabled to Joint:setLimitsEnabled and Joint:hasLimitsEnabled. + * Renamed t.screen to t.window in love.conf. + * Renamed love.graphics.setCaption to love.window.setTitle. + * Renamed PixelEffect to Shader (but now with vertex shaders). + * Renamed love.graphics.setDefaultImageFilter to love.graphics.setDefaultFilter. + * Renamed ParticleSystem:setSprite to ParticleSystem:setImage. + * Renamed ParticleSystem:setGravity to ParticleSystem:setLinearAcceleration. + * Renamed ParticleSystem:setLifetime/setParticleLife to setEmitter/ParticleLifetime. + * Renamed ParticleSystem:count and all getNum* functions to get*Count. + * Renamed Source:setDistance to Source:setAttenuationDistances. + * Renamed SoundData:getBits and Decoder:getBits to SoundData:getBitDepth and Decoder:getBitDepth. + * Renamed love.mouse.setGrab to love.mouse.setGrabbed. + + * Removed release mode. + * Removed love.keyboard.getKeyRepeat (see love.keyboard.hasKeyRepeat). + * Removed the unicode argument from love.keypressed (see love.textinput). + * Removed love.graphics.drawTest. + * Removed love.graphics.quad/triangle. + * Removed love.graphics.setColorMode. + * Removed love.graphics.newStencil. + * Removed love.graphics.setLine/setPoint. + * Removed love.graphics.drawq (functionality is merged into love.graphics.draw). + * Removed SpriteBatch:addq/setq (functionality is merged into SpriteBatch:add/set). + * Removed Quad:flip. + * Removed ParticleSystem:isFull/isEmpty. + * Removed ParticleSystem:getX/getY. + * Removed love.graphics.checkMode. + * Removed love.joystick.open and friends. + * Removed love.joystick module functions which operated on individual joysticks (see Joystick objects). + * Removed joystick ball support. + * Removed thread names. + * Removed old thread messaging API (see Channels). + * Removed love.timer.getMicroTime. + + * Updated functions which return love objects to re-use the Lua-side object instead of always recreating it. + * Updated the windows console, it now tries to re-use an active one first. + * Updated error handling, error handlers now get resolved when the error occurs. + * Updated order of sleep/present in love.run (now draws, *then* sleeps). + * Updated love.filesystem to try to create the appdata directory if it doesn't exist yet. + * Updated the default filesystem identity to omit file extension. + * Updated love.filesystem.newFile to optionally open the file. + * Updated most love.filesystem functions to return nil, error on internal failure. + * Updated love.keyboard.setKeyRepeat to take a boolean argument instead of numbers. + * Updated love.keypressed's second argument to be a boolean indicating key repeat. + * Updated keyboard key constants for some more modern keyboard keys. + * Updated window code to use adaptive vsync when available, if vsync is enabled. + * updated love.graphics.print's x and y arguments to default to 0. + * Updated the setFilter and setWrap methods, the second argument is now optional. + * Updated Font and ParticleSystem rendering code, now more performant. + * Updated SpriteBatch code, now more performant when adding/setting and (un)binding. + * Updated Canvas code to support more systems. + * Updated Canvas:getImageData and love.graphics.newScreenshot to be more efficient. + * Updated love.graphics.newScreenshot to create a fully opaque image by default. + * Updated error messages when sending bad values to Shaders. + * Updated love.graphics.newParticleSystem to have a default buffer size of 1000. + * Updated ImageData:setPixel to accept a table and default to 255 alpha. + * Updated ImageData:mapPixel, is now more efficient and accepts optional x,y,w,h arguments. + * Updated love.image memory handling, improves errors and thread-safety. + * Updated all love object constructors to optionally accept FileData if they accept a filename. + * Updated allocation for SoundData, it's more efficient and less wasteful. + * Updated SoundData:set/getSample to error for invalid samples. + * Updated Source:set* functions to default z to 0. + * Updated Source:seek to error for negative offsets. + * Updated Thread:start to accept arguments which get passed to the thread. + * Updated love.timer.getFPS to be microsecond-accurate. + * Updated love.timer.getTime to be microsecond-accurate and monotonic. + * Updated Box2D to version 2.3.0. + +LOVE 0.8.0 [Rubber Piggy] +------------------------- + + Released: 2012-04-02 + + * Added release error screen. + * Added alpha to love.graphics.setBackgroundColor. + * Added Canvas:clear(r, g, b, a). + * Added Canvas support to love.graphics.drawq. + * Added Canvas:getWidth and Canvas:getHeight. + * Added love.graphics.arc. + * Added seek and tell to Source objects. + * Added color interpolation to ParticleSystem. + * Added automatic PO2 padding for systems not supporting the OpenGL extension. + * Added UTF-8 support for fonts. + * Added Box2D error handling for some commonly failing functions. + * Added ability for fused release games to have their write dir in appdata. + * Added shear transformation to drawing functions. + * Added origin to font printing. + * Added love.graphics.getMode. + * Added per-sprite colors on SpriteBatches. + * Added PixelEffects. + * Added love.graphics.isSupported. + * Added love.graphics.getCanvas. + * Added love.event.quit. + * Added stencil masks. + * Added alternative SpriteBatch provider, it should work everywhere now. + * Added a loader for binary modules. + * Added Thread:getKeys. + * Added option of fractions for Quads. + * Added PNG, JPEG and GIF support to ImageData:encode. + * Added 64-bit support for Mac OS X. + * Added premultiplied blending mode. + * Added functions to set/get default image filter modes. + * Added SpriteBatch:set. + * Added new events system, with support for custom events and long event names. + * Added sound attenuation by distance. + * Added SpriteBatch:getImage. + * Added combine color mode. + * Added automatic random seeding to love.run. + * Added support for the subtract BlendMode on older graphics cards. + * Added love._os field, which contains the OS the game is running on. + + * Fixed wrapping for single words. + * Fixed tracebacks not showing filenames. + * Fixed love.graphics.push/pop capable of causing overflows/underflows. + * Fixed setScissor on Canvases. + * Fixed several issues with audio, e.g. clicks and pops in mp3s. + * Fixed crashes when bodies were destroyed during collisions. + * Fixed bound SpriteBatches corrupting when drawing. + * Fixed thread-safety issues with ImageData. + * Fixed memory leaks in audio sources. + * Fixed thread's set (previously send) accidentally changing the type. + * Fixed SoundData allocating the wrong number of samples. + * Fixed SpriteBatch support on Intel cards. + * Fixed love.filesystem.lines() leaking. + * Fixed most leaking on unclosed File objects. + * Fixed crashes when operating on non-existent files. + * Fixed a bug where empty files on windows would never reach eof. + * Fixed crash when SoundData runs out of memory. + * Fixed ordering of loaders, love should have priority over lua. + * Fixed several miscellaneous memory leaks. + * Fixed a few cases where strings with \0 in them would not be stored correctly. + * Fixed love's startup time being in the first dt. + * Fixed internal string conversions, they are faster now. + * Fixed (bad) performance of ImageData:paste. + * Fixed love.graphics.toggleFullscreen not maintaining graphics state. + + * Renamed SpriteBatch's lock/unlock to bind/unbind. + * Renamed Framebuffer to Canvas. + * Renamed love.thread.send/receive to set/get. + * Renamed love.graphics.setRenderTarget to setCanvas. + + * Removed canvas auto-clearing. + * Removed EncodedImageData. + * Removed old syntax for require (with extension). + * Removed love.graphics.setFont([file], [size]). + * Removed Thread:kill. + + * Updated love.joystick to be 1-indexed. + * Updated Sources to update more cleanly and control more intuitively. + * Updated font engine. + * Updated line drawing to a custom system. + * Updated love.timer.sleep to use seconds, like the rest of love. + * Updated love.timer to be more accurate. + * Updated love.graphics.circle to have max(10, r) as default for segments. + * Updated ImageData:encode to write to files directly. + * Updated version compatibility system to actually do something. + * Updated love.run's order, events are checked just before update. + * Updated Box2D to version 2.2.1. + +LOVE 0.7.2 [Game Slave] +----------------------- + + Released: 2011-05-04 + + * Added Framebuffer:get/setWrap. + * Added love.event.clear. + * Added support for any number of arguments to love.keyboard.isDown, love.mouse.isDown and love.joystick.isDown. + * Added SpriteBatch:setImage(). + + * Fixed fused games not working. + * Fixed ParticleSystem:setSize ignoring the variation argument. + * Fixed some file-opening exceptions not being caught. + * Fixed files loaded by libmodplug being too loud. + * Fixed paths with periods in them not working. + * Fixed love.graphics.getBlendMode not detecting subtractive and multiplicative blend modes. + * Fixed crash when there was no memory available for newImageData(w, h). + + * Updated PhysicsFS version to 2.0.2 on Windows + * Updated OpenAL Soft version to 1.13 on Windows + * Updated libmodplug version to 0.8.8.1 on Windows + * Updated FreeType version to 2.4.4 on Windows + * Updated libmpg123 version to 1.13.2 on Windows + * Windows binary no longer depends on VC2005 runtime. + * Windows binary no longer depends on SSE2 support. + +LOVE 0.7.1 [Game Slave] +----------------------- + + Released: 2011-02-14 + + * Added source:isPaused() + * Added error when initial window can't be created. + * Added framebuffer filter modes. + * Added love.filesystem.getLastModified. + * Added filter modes for ImageFonts. + * Added dead key support by using "unknown" key with correct unicode value. + * Added 0 width and height in love.conf. (for current desktop resolution) + * Added alpha support when encoding TGA images. + + * Fixed a lot of bugs regarding zero characters in threads. + * Fixed handling of a directory named "love" in current directory. + * Fixed a few unhandled errors in setScissor. + * Fixed a bug where old physics callbacks were never dereferenced. + * Fixed loss of mouse visibility settings on setMode. + * Fixed creation of a framebuffer unbinding current framebuffer. + * Fixed several race conditions in love.thread. + * Fixed 'love .', so it won't use lovedir/. as save dir. + * Fixed setLineHeight. + * Fixed extended ascii and ImageFonts. + * Fixed printf's line wrapping. + * Fixed crash when playing sounds. + * Fixed playback of mp3s with arbitrary sample rates. + * Fixed handling of negative indices in love.joystick. + * Fixed toggleFullscreen. + * Fixed unexpected behaviour with hash tables to love.graphics.line. + * Fixed mouse coordinates being capped after setMode. + * Fixed setFont's error handling on a non-existant file. + * Fixed issue where Windows builds would hard crash on Lua errors + + * Removed custom sample rates for Decoders. + +LOVE 0.7.0 [Game Slave] +----------------------- + + Released: 2010-12-05 + + * Added love.thread. + * Added love.font. + * Added love.graphics.Framebuffer. + * Added Source:play, Source:pause, etc. + * Added Source:isStatic(). + * Added get/setPosition, get/setVelocity, and get/setDirection to Source. + * Added get/setGroupIndex to CircleShape and PolygonShape. + * Added Font:getWrap. + * Added identity field to love.conf. + * Added love.quit callback. + * Added love.focus callback. + * Added extra meter parameter to love.physics.newWorld. + * Added love.graphics.setIcon. + * Added way to make the window desktop resolution. + * Added subtractive and multiplicative blend modes. + * Added body:getAllowSleeping. + * Added shape:getBody. + * Added love.filesystem.FileData for public usage. + * Added base64 support for love.filesystem.FileData. + * Added table support for love.graphics.setColor and love.graphics.setBackgroundColor. + * Added love.graphics.hasFocus(). + * Added ?/init.lua to the loader. + + * Fixed the debug module not being an upvalue of the error handlers. (you can now override debug) + * Fixed some cases when love.audio.pause and friends, were acting on everything, not just the passed Source. + * Fixed setFixedRotation enabling other flags. + * Fixed a bug in the loader (for require). + * Fixed ParticleSystem::setSprite not retaining the new image. + * Fixed setMode removing images settings (wrapping, filters). + * Fixed shape:getBody, it's now exposed for LÖVE usage. + * Fixed DistanceJoint:getType() returning "circle" - it now returns "distance". + * Fixed SpriteBatches being unaffected by setColor + * Fixed the audio bug. + * Fixed invalid FSAA values crashing LÖVE. + * Fixed a bunch of compiler warnings. + * Fixed OS X not properly using UTIs for .love files. + * Fixed the modplug decoder not properly handeling files that fail to load. + * Fixed a memory leak in setFont. + * Fixed bug where errors in threads wouldn't get picked up by demand. + * Fixed part of the bug with newlines when scaling text (rotating still messes up the lines). + * Fixed the bug where newImageFont would try to created ImageData out of ImageData. + * Fixed error handler not resetting the blend mode. + + * Changed fonts, they're now po2 safe. + * Changed the traceback in the error screen. + * Changed font origin to top-left. + * Changed linux save dir location to obey to Freedesktop.org's XDG specs. (~/.local/share/love by default.) + + * Removed font functions from love.graphics. + * Removed love.physics.newWorld(w, h). Use love.physics.newWorld(x1, y1, x2, y2) instead. + +LOVE 0.6.2 [Jiggly Juice] +------------------------- + + Released: 2010-03-06 + + * Fixed a bug causing ImageFonts to cut off some pixels. + * Fixed a bug where filled rectangles were too small. + * Fixed a bug in Image:setFilter where it would switch the parameters. + * Fixed a bug in ImageRasterizer where it wasn't using the data. + * Image filter and wrap modes now use string constants as well. + * Fixed double-transform bug in SpriteBatch. + * Errors are reported on stdout again. + * Another fix for the icons on ubuntu. + +LOVE 0.6.1 [Jiggly Juice] +------------------------- + + Released: 2010-02-07 + + * Added Shape:setGroupIndex and getGroupIndex. + * Added Body:setFixedRotation and Body:getFixedRotation. + * Added Body:setInertia. + * Added CircleShape:getLocalCenter and CircleShape:getWorldCenter. + * Added icons and file associations for the debs. + * Added the demos folder to the Mac OS X DMG. + * It's now possible to run a .love from Resources in Mac OS X, thanks to Steve Johnson. + * Fixed a bug with multiple Sources on the same Music. + * Fixed a bug so the mouse doesn't get crippled when the keyboard is disabled. + * Fixed a bug where love.graphics.rectangle drew a too large rectangle. + * Fixed a bug where memory wouldn't be released correctly. + * Fixed epic physics typo (getRestituion->getRestitution). + * Fixed crash on opening non-existent image. + * The error screen redraws when an event occurs. + * The default love.run() now gracefully handles disabled modules. + * The debian packages should now successfully include icons, file associations, etc, and should give the correct architecture. + * Added support for drawing polylines to love.graphics.line - the syntax is the same as love.graphics.polygon. + * Removed Music and Sound. There are now only sources. + * Improved the stability of love.audio/love.sound. + +LOVE 0.6.0 [Jiggly Juice] +------------------------- + + Released: 2009-12-24 + + * Lost track of 0.6.0 changes a long while ago. Don't trust the list below. + + * Added love.graphics.print()/printf(). + * Added unicode-translated parameter to love.keypressed(). + * Added love.event. + * Added love.filesystem.setIdentity(). + * Added OpenAL dependency. + + * Fixed love.fileystem problems with internal \0 in strings. + * Fixed love.filesystem.mkdir/remove not working when write directory not set. + * Fixed position of Window. + + * Changed parameter order of draws(). + * Changed origin for images to top-left. + * Changed love.filesystem.open to accept mode (removed from love.filesystem.newFile). + * Changed love.filesystem.read() which now returns two parameters (data, length). + * Changed love.filesystem.write() which now takes up to four parameters (file, data, length, mode). + * Changed default color mode to "modulate". + * Changed name of love.color_normal to "replace". + * Changed name of love.blend_normal to "alpha". + * Changed the conf file format. + + * Removed Color object. + * Removed Animation. + * Removed several constants. + * Removed love.graphics.draw() for strings. + * Removed love.system. + * Removed SWIG. + * Removed boost. + * Removed SDL_mixer. + + +LOVE 0.5.0 [Salted Nuts] +------------------------ + + Released: 2009-01-02 + + * Added love.joystick. + * Added network support via LuaSocket. + * Added support for loading of appended .love-file. + + * Added love.filesystem.lines(). + * Added a loader function to enable use of normal require(). + * Added love.filesystem.load(). + * Added love.filesystem.getSaveDirectory() + * Added love.filesystem.getWorkingDirectory() + + * Added optional explicit destruction of Box2D objects. + * Added shape:testSegment(). + * Added love.graphics.screenshot() (.bmp only). + * Added default size (12) to font-related functions. + * Added love.graphics.setFont( filename, size ) + * Added love.graphics.setLineStippe and related functions. + * Added love.graphics.setPointSize and related functions. + + * Changed love.filesystem.read() to accept file name. + * Changed love.filesystem.write() to accept file name. + * Changed love.graphics.triangle() to accept CCW and CW ordering. + + * Fixed love.graphics.read adding bogus characters at the end of string. + * Fixed epic swigfusion bug. + * Fixed love.graphics.getFont so it returns nil if no font is present. + * Fixed bug where love.graphics.getBlendMode() always returns blend_normal. + * Fixed bug which caused error screen to be scissored (when enabled). + * Fixed Body:setAngle to accept degrees like everything else. + + * Cleaned up love::File and love_physfs. + * Cleaned up love::Reference so it stores its reference in _G. + +LOVE 0.4.0 [Taco Beam] +---------------------- + + Released: 2008-08-29 + + * Added love.physics. (YES!) + * Added love.audio.setMode(). + * Added love.audio.setChannels(). + * Added love.graphics.polygon(). + * Added love.graphics.setScissor() and love.graphics.getScissor() to handle scissoring the graphical area. + * Fixed missing constants related to image optimization. + * Fixed memory leak related to love::File (thanks amnesiasoft!). + + +LOVE 0.3.2 [Lemony Fresh] +------------------------- + + Released: 2008-07-04 + + * Added love.graphics.rectangle() + * Added love.graphics.setLineWidth() + * Added love.graphics.setLineStyle() + * Added love.graphics.getLineWidth() + * Added love.graphics.getLineStyle() + * Added love.mouse.getPosition() + * Added love.audio_loop + * Added love.timer.getTime() + * Changed love.graphics.quad() to accept CCW and CW ordering. + * Fixed default color mode bug. + * Fixed line width being applied unnecessarily. + * Fixed line width bug related to fullscreen toggle. + * Fixed music not looping. + +LOVE 0.3.1 [Space Meat] +----------------------- + + Released: 2008-06-21 + + * Fixed segfault related to graphics. + * Fixed wait-forever bug related to audio. + * Fixed error reporting not working across modules. + * Fixed bug where games with a trailing "/" would not start. + * Fixed bug which caused love.timer.sleep to delay for (way) too long. + +LOVE 0.3.0 [Mutant Vermin] +-------------------------- + + Released: 2008-06-17 + + * Added ParticleSystem. + * Added visual error reporting. + * Added love.system for game control needs. + * Added input grabbing. + * Added functions in love.graphics for display management. + * Added love.graphics.point(). + * Added functions in love.graphics for getting current color, font, etc. + * Added love.filesystem.enumerate() for getting folder contents. + * Added functions for setting the window caption. + * Added version checking. An error occurs if the game is incompatible. + * Fixed print() :) + * Removed all keyboard shortcuts. + * Save folders are now created only if required. + * On Windows, the new save location is %APPDATA%\LOVE\game + +LOVE 0.2.1 [Impending Doom] +--------------------------- + + Released: 2008-03-29 + + * Added many functions in love.filesystem. + * Added a dedicated save-folder for each game. + * Added timer.sleep. + * Added line heights to font objects. + * Added love.graphics.getWidth/getHeight. + * Added scaling and rotation for text. + * Added variable spacing to ImageFont. + * Added support for variable line quality when drawing primitives. + * Added several functions for drawing sections of images. (love.graphics.draws) + * Added image optimization function and padding function. + * Added love.graphics.getWidth/Height. + + * Split devices up into actual SWIG-modules. This means that: + - Functions are used like this: love.graphics.draw, not love.graphics:draw + - love.objects is no more. Objects are created by an appropriate device. + * How you draw primitives has been altered. + * draw(string, x, y, wrap, align) has become drawf(string, x, y, wrap, align) + + * Changed getFps to getFPS. + * Escape is no more ... enter: Alt+F4. + * love.filesystem.include has been renamed to love.filesystem.require. + * ImageFonts now consider the spacing as well as the glyph size. + * Fixed a massive ImageFont bug which resulted in float-positioning failure. + * Fixed a bug when loading fonts where the specified size doesn't represent the true size of the font. + + * Updated DevIL to version 1.6.8-rc2 (Windows) + * Updated FreeType to freetype-2.3.5-1 (Windows) + * Updated Lua to 5.1.3 (Windows) + * Updated SDL to 1.2.13 (Windows) + * Removed boost::filesystem. + +LOVE 0.2.0 [Mini-Moose] +----------------------- + + Released: 2008-02-06 + + * Added ImageFont + * Added Animation + * Added text formatting functions + * Added setCenter for Image and Animation. + * Added methods for rendering of scaled/rotated sprites. + * Added the drawing of basic shapes. + * Added default font and embedded resources. + * Added Ctrl+R for reload. + * Added blending and color modes. + * Fixed memory usage of Graphics. + * Fixed a bug where the set text color would change the color of any images rendered. + * Fixed CWD bug. + * Fixed titlebar. Game title is now displayed. + + +LOVE 0.1.1 [Santa-Power] +------------------------ + + Initial release! + Released: 2008-01-13 + + * Image loading and rendering. + * Sound loading and playing. + * Font loading and rendering. + * Lua-scriptable games. + * Config files. + * Stuff is loadable from archive files. + * Keyboard, mouse, display, timer, etc. (Basic devices). diff --git a/engine/love/game.ico b/engine/love/game.ico new file mode 100644 index 0000000..ecc5c0d Binary files /dev/null and b/engine/love/game.ico differ diff --git a/engine/love/license.txt b/engine/love/license.txt new file mode 100644 index 0000000..61f28e3 --- /dev/null +++ b/engine/love/license.txt @@ -0,0 +1,1172 @@ +Licensing information +===================== + +This distribution contains code from the following projects (full license text below): + + - LOVE + Website: https://love2d.org/ + License: zlib + Copyright (c) 2006-2019 LOVE Development Team + + - ENet + Website: http://enet.bespin.org/index.html + License: MIT/Expat + Copyright (c) 2002-2016 Lee Salzman + + - GLAD + Website: http://glad.dav1d.de/ + License: MIT/Expat + Copyright (c) 2013 David Herberth, modified by Alex Szpakowski + + - glslang + Website: https://github.com/KhronosGroup/glslang + License: 3-Clause BSD + Copyright (C) 2002-2005 3Dlabs Inc. Ltd. + Copyright (C) 2013-2016 LunarG, Inc. + + - Kepler Project's lua-compat-5.3 + Website: https://github.com/keplerproject/lua-compat-5.3 + License: MIT/Expat + Copyright (c) 2015 Kepler Project. + + - lua-enet + Website: http://leafo.net/lua-enet/ + License: MIT/Expat + Copyright (C) 2011 by Leaf Corcoran + + - LuaJIT + Website: http://luajit.org/ + License: MIT/Expat + LuaJIT is Copyright (c) 2005-2016 Mike Pall + + - Lua's UTF-8 module + Website: https://www.lua.org/ + License: MIT/Expat + Copyright (C) 1994-2015 Lua.org, PUC-Rio, 2015 LOVE Development Team. + + - LuaSocket + Website: http://w3.impa.br/~diego/software/luasocket/home.html + License: MIT/Expat + Copyright (C) 2004-2013 Diego Nehab + + - LZ4 + Website: https://lz4.github.io/lz4/ + License: 2-Clause BSD + Copyright (C) 2011-2015, Yann Collet. + You can contact the author at : + - LZ4 source repository : https://github.com/Cyan4973/lz4 + - LZ4 public forum : https://groups.google.com/forum/#!forum/lz4c + + - TinyEXR + Website: https://github.com/syoyo/tinyexr + License: 3-Clause BSD + Copyright (c) 2014 - 2016, Syoyo Fujita + + - UTF8-CPP + Website: https://github.com/nemtrif/utfcpp + License: Unknown, MIT/Expat-like (listed as UTF8-CPP) + Copyright 2006 Nemanja Trifunovic + + - xxHash + Website: https://cyan4973.github.io/xxHash/ + License: 2-Clause BSD + Copyright (C) 2012-2016, Yann Collet. + You can contact the author at : + - xxHash source repository : https://github.com/Cyan4973/xxHash + + - dr_flac + Website: https://github.com/mackron/dr_libs + Source download: https://github.com/mackron/dr_libs/blob/41bc0e8/dr_flac.h + License: MIT/Expat + Copyright 2018 David Reid + + - libmpg123 + Website: http://www.mpg123.de/ + Source download: http://sourceforge.net/projects/mpg123/files/latest/download + License: LGPL 2.1 + Copyright (c) 1995-2013 by Michael Hipp and others, free software under the terms of the LGPL v2.1 + Detailed information from the debian project: + Copyright 1995-2016 by the mpg123 project + Copyright 2009-2011 by Malcolm Boczek + Copyright 2008 Christian Weisgerber + Copyright 2006-2007 by Zuxy Meng + Copyright 2000-2002 David Olofson + Copyright 1998 Fabrice Bellard + Copyright 1997 Mikko Tommila + + - OpenAL Soft + Website: http://kcat.strangesoft.net/openal.html + Source download: http://kcat.strangesoft.net/openal.html#download + License: Mixed, licensing information obtained from the debian project + - Alc/backends/opensl.c + License: Apache 2.0 + Copyright 2011 The Android Open Source Project + - examples/alhrtf.c examples/allatency.c examples/alloopback.c examples/alreverb.c examples/alstream.c examples/altonegen.c examples/common/alhelpers.c examples/common/sdl_sound.c utils/openal-info.c + License: MIT/Expat + Copyright © 2010, 2015 Chris Robinson + - examples/alffplay.c + License: unclear, presumed LGPL 2.1 or higher + Copyright © 2003 Fabrice Bellard + Copyright © Martin Bohme + - Alc/bs2b.c OpenAL32/Include/bs2b.h + License: MIT/Expat + Copyright 2005 by Boris Mikhaylov + - cmake/FindALSA.cmake cmake/FindFFmpeg.cmake cmake/FindJACK.cmake cmake/FindSDL2.cmake + License: 3-Clause BSD + Copyright © 2006 Matthias Kretz + Copyright © 2008 Alexander Neundorf + Copyright © 2003-2011 Kitware, Inc. + Copyright © 2009-2011 Philip Lowman + Copyright © 2011 Michael Jansen + Copyright © 2012 Benjamin Eikel + - utils/makehrtf.c (not included in distribution) + License: GPL 2 or higher (2 listed below) + Copyright 2011-2014 Christopher Fitzgerald + - Everything else: + License: LGPL 2.0 or higher (2.1 listed below) + Copyright © 1999-2014 the OpenAL team + Copyright © 2008-2015 Christopher Fitzgerald + Copyright © 2009-2015 Chris Robinson + Copyright © 2013 Anis A. Hireche + Copyright © 2013 Nasca Octavian Paul + Copyright © 2013 Mike Gorchak + Copyright © 2014 Timothy Arceri + +License text +============ + +zlib license + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + + 3. This notice may not be removed or altered from any source + distribution. + +MIT/Expat + 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. + +3-Clause BSD + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials provided + with the distribution. + + Neither the name of 3Dlabs Inc. Ltd. nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES + LOSS OF USE, DATA, OR PROFITS OR BUSINESS INTERRUPTION) HOWEVER + CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + +2-Clause BSD + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following disclaimer + in the documentation and/or other materials provided with the + distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES LOSS OF USE, + DATA, OR PROFITS OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +UTF8-CPP + Permission is hereby granted, free of charge, to any person or organization + obtaining a copy of the software and accompanying documentation covered by + this license (the "Software") to use, reproduce, display, distribute, + execute, and transmit the Software, and to prepare derivative works of the + Software, and to permit third-parties to whom the Software is furnished to + do so, all subject to the following: + + The copyright notices in the Software and this entire statement, including + the above license grant, this restriction and the following disclaimer, + must be included in all copies of the Software, in whole or in part, and + all derivative works of the Software, unless such copies or derivative + works are solely in the form of machine-executable object code generated by + a source language processor. + + 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, TITLE AND NON-INFRINGEMENT. IN NO EVENT + SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE + FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, + ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + DEALINGS IN THE SOFTWARE. + +LGPL 2.1 + GNU LESSER GENERAL PUBLIC LICENSE + Version 2.1, February 1999 + + Copyright (C) 1991, 1999 Free Software Foundation, Inc. + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + [This is the first released version of the Lesser GPL. It also counts + as the successor of the GNU Library Public License, version 2, hence + the version number 2.1.] + + Preamble + + The licenses for most software are designed to take away your + freedom to share and change it. By contrast, the GNU General Public + Licenses are intended to guarantee your freedom to share and change + free software--to make sure the software is free for all its users. + + This license, the Lesser General Public License, applies to some + specially designated software packages--typically libraries--of the + Free Software Foundation and other authors who decide to use it. You + can use it too, but we suggest you first think carefully about whether + this license or the ordinary General Public License is the better + strategy to use in any particular case, based on the explanations below. + + When we speak of free software, we are referring to freedom of use, + not price. Our General Public Licenses are designed to make sure that + you have the freedom to distribute copies of free software (and charge + for this service if you wish) that you receive source code or can get + it if you want it that you can change the software and use pieces of + it in new free programs and that you are informed that you can do + these things. + + To protect your rights, we need to make restrictions that forbid + distributors to deny you these rights or to ask you to surrender these + rights. These restrictions translate to certain responsibilities for + you if you distribute copies of the library or if you modify it. + + For example, if you distribute copies of the library, whether gratis + or for a fee, you must give the recipients all the rights that we gave + you. You must make sure that they, too, receive or can get the source + code. If you link other code with the library, you must provide + complete object files to the recipients, so that they can relink them + with the library after making changes to the library and recompiling + it. And you must show them these terms so they know their rights. + + We protect your rights with a two-step method: (1) we copyright the + library, and (2) we offer you this license, which gives you legal + permission to copy, distribute and/or modify the library. + + To protect each distributor, we want to make it very clear that + there is no warranty for the free library. Also, if the library is + modified by someone else and passed on, the recipients should know + that what they have is not the original version, so that the original + author's reputation will not be affected by problems that might be + introduced by others. + + Finally, software patents pose a constant threat to the existence of + any free program. We wish to make sure that a company cannot + effectively restrict the users of a free program by obtaining a + restrictive license from a patent holder. Therefore, we insist that + any patent license obtained for a version of the library must be + consistent with the full freedom of use specified in this license. + + Most GNU software, including some libraries, is covered by the + ordinary GNU General Public License. This license, the GNU Lesser + General Public License, applies to certain designated libraries, and + is quite different from the ordinary General Public License. We use + this license for certain libraries in order to permit linking those + libraries into non-free programs. + + When a program is linked with a library, whether statically or using + a shared library, the combination of the two is legally speaking a + combined work, a derivative of the original library. The ordinary + General Public License therefore permits such linking only if the + entire combination fits its criteria of freedom. The Lesser General + Public License permits more lax criteria for linking other code with + the library. + + We call this license the "Lesser" General Public License because it + does Less to protect the user's freedom than the ordinary General + Public License. It also provides other free software developers Less + of an advantage over competing non-free programs. These disadvantages + are the reason we use the ordinary General Public License for many + libraries. However, the Lesser license provides advantages in certain + special circumstances. + + For example, on rare occasions, there may be a special need to + encourage the widest possible use of a certain library, so that it becomes + a de-facto standard. To achieve this, non-free programs must be + allowed to use the library. A more frequent case is that a free + library does the same job as widely used non-free libraries. In this + case, there is little to gain by limiting the free library to free + software only, so we use the Lesser General Public License. + + In other cases, permission to use a particular library in non-free + programs enables a greater number of people to use a large body of + free software. For example, permission to use the GNU C Library in + non-free programs enables many more people to use the whole GNU + operating system, as well as its variant, the GNU/Linux operating + system. + + Although the Lesser General Public License is Less protective of the + users' freedom, it does ensure that the user of a program that is + linked with the Library has the freedom and the wherewithal to run + that program using a modified version of the Library. + + The precise terms and conditions for copying, distribution and + modification follow. Pay close attention to the difference between a + "work based on the library" and a "work that uses the library". The + former contains code derived from the library, whereas the latter must + be combined with the library in order to run. + + GNU LESSER GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library or other + program which contains a notice placed by the copyright holder or + other authorized party saying it may be distributed under the terms of + this Lesser General Public License (also called "this License"). + Each licensee is addressed as "you". + + A "library" means a collection of software functions and/or data + prepared so as to be conveniently linked with application programs + (which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work + which has been distributed under these terms. A "work based on the + Library" means either the Library or any derivative work under + copyright law: that is to say, a work containing the Library or a + portion of it, either verbatim or with modifications and/or translated + straightforwardly into another language. (Hereinafter, translation is + included without limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for + making modifications to it. For a library, complete source code means + all the source code for all modules it contains, plus any associated + interface definition files, plus the scripts used to control compilation + and installation of the library. + + Activities other than copying, distribution and modification are not + covered by this License they are outside its scope. The act of + running a program using the Library is not restricted, and output from + such a program is covered only if its contents constitute a work based + on the Library (independent of the use of the Library in a tool for + writing it). Whether that is true depends on what the Library does + and what the program that uses the Library does. + + 1. You may copy and distribute verbatim copies of the Library's + complete source code as you receive it, in any medium, provided that + you conspicuously and appropriately publish on each copy an + appropriate copyright notice and disclaimer of warranty keep intact + all the notices that refer to this License and to the absence of any + warranty and distribute a copy of this License along with the + Library. + + You may charge a fee for the physical act of transferring a copy, + and you may at your option offer warranty protection in exchange for a + fee. + + 2. You may modify your copy or copies of the Library or any portion + of it, thus forming a work based on the Library, and copy and + distribute such modifications or work under the terms of Section 1 + above, provided that you also meet all of these conditions: + + a) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + + These requirements apply to the modified work as a whole. If + identifiable sections of that work are not derived from the Library, + and can be reasonably considered independent and separate works in + themselves, then this License, and its terms, do not apply to those + sections when you distribute them as separate works. But when you + distribute the same sections as part of a whole which is a work based + on the Library, the distribution of the whole must be on the terms of + this License, whose permissions for other licensees extend to the + entire whole, and thus to each and every part regardless of who wrote + it. + + Thus, it is not the intent of this section to claim rights or contest + your rights to work written entirely by you rather, the intent is to + exercise the right to control the distribution of derivative or + collective works based on the Library. + + In addition, mere aggregation of another work not based on the Library + with the Library (or with a work based on the Library) on a volume of + a storage or distribution medium does not bring the other work under + the scope of this License. + + 3. You may opt to apply the terms of the ordinary GNU General Public + License instead of this License to a given copy of the Library. To do + this, you must alter all the notices that refer to this License, so + that they refer to the ordinary GNU General Public License, version 2, + instead of to this License. (If a newer version than version 2 of the + ordinary GNU General Public License has appeared, then you can specify + that version instead if you wish.) Do not make any other change in + these notices. + + Once this change is made in a given copy, it is irreversible for + that copy, so the ordinary GNU General Public License applies to all + subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of + the Library into a program that is not a library. + + 4. You may copy and distribute the Library (or a portion or + derivative of it, under Section 2) in object code or executable form + under the terms of Sections 1 and 2 above provided that you accompany + it with the complete corresponding machine-readable source code, which + must be distributed under the terms of Sections 1 and 2 above on a + medium customarily used for software interchange. + + If distribution of object code is made by offering access to copy + from a designated place, then offering equivalent access to copy the + source code from the same place satisfies the requirement to + distribute the source code, even though third parties are not + compelled to copy the source along with the object code. + + 5. A program that contains no derivative of any portion of the + Library, but is designed to work with the Library by being compiled or + linked with it, is called a "work that uses the Library". Such a + work, in isolation, is not a derivative work of the Library, and + therefore falls outside the scope of this License. + + However, linking a "work that uses the Library" with the Library + creates an executable that is a derivative of the Library (because it + contains portions of the Library), rather than a "work that uses the + library". The executable is therefore covered by this License. + Section 6 states terms for distribution of such executables. + + When a "work that uses the Library" uses material from a header file + that is part of the Library, the object code for the work may be a + derivative work of the Library even though the source code is not. + Whether this is true is especially significant if the work can be + linked without the Library, or if the work is itself a library. The + threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data + structure layouts and accessors, and small macros and small inline + functions (ten lines or less in length), then the use of the object + file is unrestricted, regardless of whether it is legally a derivative + work. (Executables containing this object code plus portions of the + Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may + distribute the object code for the work under the terms of Section 6. + Any executables containing that work also fall under Section 6, + whether or not they are linked directly with the Library itself. + + 6. As an exception to the Sections above, you may also combine or + link a "work that uses the Library" with the Library to produce a + work containing portions of the Library, and distribute that work + under terms of your choice, provided that the terms permit + modification of the work for the customer's own use and reverse + engineering for debugging such modifications. + + You must give prominent notice with each copy of the work that the + Library is used in it and that the Library and its use are covered by + this License. You must supply a copy of this License. If the work + during execution displays copyright notices, you must include the + copyright notice for the Library among them, as well as a reference + directing the user to the copy of this License. Also, you must do one + of these things: + + a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above) and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + + b) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (1) uses at run time a + copy of the library already present on the user's computer system, + rather than copying library functions into the executable, and (2) + will operate properly with a modified version of the library, if + the user installs one, as long as the modified version is + interface-compatible with the version that the work was made with. + + c) Accompany the work with a written offer, valid for at + least three years, to give the same user the materials + specified in Subsection 6a, above, for a charge no more + than the cost of performing this distribution. + + d) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + + e) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + + For an executable, the required form of the "work that uses the + Library" must include any data and utility programs needed for + reproducing the executable from it. However, as a special exception, + the materials to be distributed need not include anything that is + normally distributed (in either source or binary form) with the major + components (compiler, kernel, and so on) of the operating system on + which the executable runs, unless that component itself accompanies + the executable. + + It may happen that this requirement contradicts the license + restrictions of other proprietary libraries that do not normally + accompany the operating system. Such a contradiction means you cannot + use both them and the Library together in an executable that you + distribute. + + 7. You may place library facilities that are a work based on the + Library side-by-side in a single library together with other library + facilities not covered by this License, and distribute such a combined + library, provided that the separate distribution of the work based on + the Library and of the other library facilities is otherwise + permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + + b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + + 8. You may not copy, modify, sublicense, link with, or distribute + the Library except as expressly provided under this License. Any + attempt otherwise to copy, modify, sublicense, link with, or + distribute the Library is void, and will automatically terminate your + rights under this License. However, parties who have received copies, + or rights, from you under this License will not have their licenses + terminated so long as such parties remain in full compliance. + + 9. You are not required to accept this License, since you have not + signed it. However, nothing else grants you permission to modify or + distribute the Library or its derivative works. These actions are + prohibited by law if you do not accept this License. Therefore, by + modifying or distributing the Library (or any work based on the + Library), you indicate your acceptance of this License to do so, and + all its terms and conditions for copying, distributing or modifying + the Library or works based on it. + + 10. Each time you redistribute the Library (or any work based on the + Library), the recipient automatically receives a license from the + original licensor to copy, distribute, link with or modify the Library + subject to these terms and conditions. You may not impose any further + restrictions on the recipients' exercise of the rights granted herein. + You are not responsible for enforcing compliance by third parties with + this License. + + 11. If, as a consequence of a court judgment or allegation of patent + infringement or for any other reason (not limited to patent issues), + conditions are imposed on you (whether by court order, agreement or + otherwise) that contradict the conditions of this License, they do not + excuse you from the conditions of this License. If you cannot + distribute so as to satisfy simultaneously your obligations under this + License and any other pertinent obligations, then as a consequence you + may not distribute the Library at all. For example, if a patent + license would not permit royalty-free redistribution of the Library by + all those who receive copies directly or indirectly through you, then + the only way you could satisfy both it and this License would be to + refrain entirely from distribution of the Library. + + If any portion of this section is held invalid or unenforceable under any + particular circumstance, the balance of the section is intended to apply, + and the section as a whole is intended to apply in other circumstances. + + It is not the purpose of this section to induce you to infringe any + patents or other property right claims or to contest validity of any + such claims this section has the sole purpose of protecting the + integrity of the free software distribution system which is + implemented by public license practices. Many people have made + generous contributions to the wide range of software distributed + through that system in reliance on consistent application of that + system it is up to the author/donor to decide if he or she is willing + to distribute software through any other system and a licensee cannot + impose that choice. + + This section is intended to make thoroughly clear what is believed to + be a consequence of the rest of this License. + + 12. If the distribution and/or use of the Library is restricted in + certain countries either by patents or by copyrighted interfaces, the + original copyright holder who places the Library under this License may add + an explicit geographical distribution limitation excluding those countries, + so that distribution is permitted only in or among countries not thus + excluded. In such case, this License incorporates the limitation as if + written in the body of this License. + + 13. The Free Software Foundation may publish revised and/or new + versions of the Lesser General Public License from time to time. + Such new versions will be similar in spirit to the present version, + but may differ in detail to address new problems or concerns. + + Each version is given a distinguishing version number. If the Library + specifies a version number of this License which applies to it and + "any later version", you have the option of following the terms and + conditions either of that version or of any later version published by + the Free Software Foundation. If the Library does not specify a + license version number, you may choose any version ever published by + the Free Software Foundation. + + 14. If you wish to incorporate parts of the Library into other free + programs whose distribution conditions are incompatible with these, + write to the author to ask for permission. For software which is + copyrighted by the Free Software Foundation, write to the Free + Software Foundation we sometimes make exceptions for this. Our + decision will be guided by the two goals of preserving the free status + of all derivatives of our free software and of promoting the sharing + and reuse of software generally. + + NO WARRANTY + + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO + WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. + EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR + OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY + KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE + LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME + THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN + WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY + AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU + FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR + CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE + LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING + RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A + FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF + SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH + DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Libraries + + If you develop a new library, and you want it to be of the greatest + possible use to the public, we recommend making it free software that + everyone can redistribute and change. You can do so by permitting + redistribution under these terms (or, alternatively, under the terms of the + ordinary General Public License). + + To apply these terms, attach the following notices to the library. It is + safest to attach them to the start of each source file to most effectively + convey the exclusion of warranty and each file should have at least the + "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This library is free software you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + + Also add information on how to contact you by electronic and paper mail. + + You should also get your employer (if you work as a programmer) or your + school, if any, to sign a "copyright disclaimer" for the library, if + necessary. Here is a sample alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + library `Frob' (a library for tweaking knobs) written by James Random Hacker. + + , 1 April 1990 + Ty Coon, President of Vice + + That's all there is to it! + +GPL 2 + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your + freedom to share and change it. By contrast, the GNU General Public + License is intended to guarantee your freedom to share and change free + software--to make sure the software is free for all its users. This + General Public License applies to most of the Free Software + Foundation's software and to any other program whose authors commit to + using it. (Some other Free Software Foundation software is covered by + the GNU Lesser General Public License instead.) You can apply it to + your programs, too. + + When we speak of free software, we are referring to freedom, not + price. Our General Public Licenses are designed to make sure that you + have the freedom to distribute copies of free software (and charge for + this service if you wish), that you receive source code or can get it + if you want it, that you can change the software or use pieces of it + in new free programs and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid + anyone to deny you these rights or to ask you to surrender the rights. + These restrictions translate to certain responsibilities for you if you + distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether + gratis or for a fee, you must give the recipients all the rights that + you have. You must make sure that they, too, receive or can get the + source code. And you must show them these terms so they know their + rights. + + We protect your rights with two steps: (1) copyright the software, and + (2) offer you this license which gives you legal permission to copy, + distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain + that everyone understands that there is no warranty for this free + software. If the software is modified by someone else and passed on, we + want its recipients to know that what they have is not the original, so + that any problems introduced by others will not reflect on the original + authors' reputations. + + Finally, any free program is threatened constantly by software + patents. We wish to avoid the danger that redistributors of a free + program will individually obtain patent licenses, in effect making the + program proprietary. To prevent this, we have made it clear that any + patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and + modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains + a notice placed by the copyright holder saying it may be distributed + under the terms of this General Public License. The "Program", below, + refers to any such program or work, and a "work based on the Program" + means either the Program or any derivative work under copyright law: + that is to say, a work containing the Program or a portion of it, + either verbatim or with modifications and/or translated into another + language. (Hereinafter, translation is included without limitation in + the term "modification".) Each licensee is addressed as "you". + + Activities other than copying, distribution and modification are not + covered by this License they are outside its scope. The act of + running the Program is not restricted, and the output from the Program + is covered only if its contents constitute a work based on the + Program (independent of having been made by running the Program). + Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's + source code as you receive it, in any medium, provided that you + conspicuously and appropriately publish on each copy an appropriate + copyright notice and disclaimer of warranty keep intact all the + notices that refer to this License and to the absence of any warranty + and give any other recipients of the Program a copy of this License + along with the Program. + + You may charge a fee for the physical act of transferring a copy, and + you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion + of it, thus forming a work based on the Program, and copy and + distribute such modifications or work under the terms of Section 1 + above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + + These requirements apply to the modified work as a whole. If + identifiable sections of that work are not derived from the Program, + and can be reasonably considered independent and separate works in + themselves, then this License, and its terms, do not apply to those + sections when you distribute them as separate works. But when you + distribute the same sections as part of a whole which is a work based + on the Program, the distribution of the whole must be on the terms of + this License, whose permissions for other licensees extend to the + entire whole, and thus to each and every part regardless of who wrote it. + + Thus, it is not the intent of this section to claim rights or contest + your rights to work written entirely by you rather, the intent is to + exercise the right to control the distribution of derivative or + collective works based on the Program. + + In addition, mere aggregation of another work not based on the Program + with the Program (or with a work based on the Program) on a volume of + a storage or distribution medium does not bring the other work under + the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, + under Section 2) in object code or executable form under the terms of + Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + + The source code for a work means the preferred form of the work for + making modifications to it. For an executable work, complete source + code means all the source code for all modules it contains, plus any + associated interface definition files, plus the scripts used to + control compilation and installation of the executable. However, as a + special exception, the source code distributed need not include + anything that is normally distributed (in either source or binary + form) with the major components (compiler, kernel, and so on) of the + operating system on which the executable runs, unless that component + itself accompanies the executable. + + If distribution of executable or object code is made by offering + access to copy from a designated place, then offering equivalent + access to copy the source code from the same place counts as + distribution of the source code, even though third parties are not + compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program + except as expressly provided under this License. Any attempt + otherwise to copy, modify, sublicense or distribute the Program is + void, and will automatically terminate your rights under this License. + However, parties who have received copies, or rights, from you under + this License will not have their licenses terminated so long as such + parties remain in full compliance. + + 5. You are not required to accept this License, since you have not + signed it. However, nothing else grants you permission to modify or + distribute the Program or its derivative works. These actions are + prohibited by law if you do not accept this License. Therefore, by + modifying or distributing the Program (or any work based on the + Program), you indicate your acceptance of this License to do so, and + all its terms and conditions for copying, distributing or modifying + the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the + Program), the recipient automatically receives a license from the + original licensor to copy, distribute or modify the Program subject to + these terms and conditions. You may not impose any further + restrictions on the recipients' exercise of the rights granted herein. + You are not responsible for enforcing compliance by third parties to + this License. + + 7. If, as a consequence of a court judgment or allegation of patent + infringement or for any other reason (not limited to patent issues), + conditions are imposed on you (whether by court order, agreement or + otherwise) that contradict the conditions of this License, they do not + excuse you from the conditions of this License. If you cannot + distribute so as to satisfy simultaneously your obligations under this + License and any other pertinent obligations, then as a consequence you + may not distribute the Program at all. For example, if a patent + license would not permit royalty-free redistribution of the Program by + all those who receive copies directly or indirectly through you, then + the only way you could satisfy both it and this License would be to + refrain entirely from distribution of the Program. + + If any portion of this section is held invalid or unenforceable under + any particular circumstance, the balance of the section is intended to + apply and the section as a whole is intended to apply in other + circumstances. + + It is not the purpose of this section to induce you to infringe any + patents or other property right claims or to contest validity of any + such claims this section has the sole purpose of protecting the + integrity of the free software distribution system, which is + implemented by public license practices. Many people have made + generous contributions to the wide range of software distributed + through that system in reliance on consistent application of that + system it is up to the author/donor to decide if he or she is willing + to distribute software through any other system and a licensee cannot + impose that choice. + + This section is intended to make thoroughly clear what is believed to + be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in + certain countries either by patents or by copyrighted interfaces, the + original copyright holder who places the Program under this License + may add an explicit geographical distribution limitation excluding + those countries, so that distribution is permitted only in or among + countries not thus excluded. In such case, this License incorporates + the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions + of the General Public License from time to time. Such new versions will + be similar in spirit to the present version, but may differ in detail to + address new problems or concerns. + + Each version is given a distinguishing version number. If the Program + specifies a version number of this License which applies to it and "any + later version", you have the option of following the terms and conditions + either of that version or of any later version published by the Free + Software Foundation. If the Program does not specify a version number of + this License, you may choose any version ever published by the Free Software + Foundation. + + 10. If you wish to incorporate parts of the Program into other free + programs whose distribution conditions are different, write to the author + to ask for permission. For software which is copyrighted by the Free + Software Foundation, write to the Free Software Foundation we sometimes + make exceptions for this. Our decision will be guided by the two goals + of preserving the free status of all derivatives of our free software and + of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY + FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN + OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES + PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED + OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS + TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE + PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, + REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING + WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR + REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, + INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING + OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED + TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY + YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER + PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE + POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest + possible use to the public, the best way to achieve this is to make it + free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest + to attach them to the start of each source file to most effectively + convey the exclusion of warranty and each file should have at least + the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + + Also add information on how to contact you by electronic and paper mail. + + If the program is interactive, make it output a short notice like this + when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions type `show c' for details. + + The hypothetical commands `show w' and `show c' should show the appropriate + parts of the General Public License. Of course, the commands you use may + be called something other than `show w' and `show c' they could even be + mouse-clicks or menu items--whatever suits your program. + + You should also get your employer (if you work as a programmer) or your + school, if any, to sign a "copyright disclaimer" for the program, if + necessary. Here is a sample alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + + This General Public License does not permit incorporating your program into + proprietary programs. If your program is a subroutine library, you may + consider it more useful to permit linking proprietary applications with the + library. If this is what you want to do, use the GNU Lesser General + Public License instead of this License. + +Apache 2.0 + Apache License + + Version 2.0, January 2004 + + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. + + "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: + + You must give any other recipients of the Work or Derivative Works a copy of this License and + You must cause any modified files to carry prominent notices stating that You changed the files and + You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works and + If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works within the Source form or documentation, if provided along with the Derivative Works or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. + + You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + APPENDIX: How to apply the Apache License to your work + + To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License") + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/engine/love/love.dll b/engine/love/love.dll new file mode 100644 index 0000000..aee80b3 Binary files /dev/null and b/engine/love/love.dll differ diff --git a/engine/love/love.exe b/engine/love/love.exe new file mode 100644 index 0000000..b9ab3d8 Binary files /dev/null and b/engine/love/love.exe differ diff --git a/engine/love/love.ico b/engine/love/love.ico new file mode 100644 index 0000000..b703c98 Binary files /dev/null and b/engine/love/love.ico differ diff --git a/engine/love/lovec.exe b/engine/love/lovec.exe new file mode 100644 index 0000000..9fd934c Binary files /dev/null and b/engine/love/lovec.exe differ diff --git a/engine/love/lua51.dll b/engine/love/lua51.dll new file mode 100644 index 0000000..14b5a97 Binary files /dev/null and b/engine/love/lua51.dll differ diff --git a/engine/love/mpg123.dll b/engine/love/mpg123.dll new file mode 100644 index 0000000..c706e10 Binary files /dev/null and b/engine/love/mpg123.dll differ diff --git a/engine/love/msvcp120.dll b/engine/love/msvcp120.dll new file mode 100644 index 0000000..a237d2d Binary files /dev/null and b/engine/love/msvcp120.dll differ diff --git a/engine/love/msvcr120.dll b/engine/love/msvcr120.dll new file mode 100644 index 0000000..8c36149 Binary files /dev/null and b/engine/love/msvcr120.dll differ diff --git a/engine/love/polyclipping.dll b/engine/love/polyclipping.dll new file mode 100644 index 0000000..0ca4218 Binary files /dev/null and b/engine/love/polyclipping.dll differ diff --git a/engine/love/readme.txt b/engine/love/readme.txt new file mode 100644 index 0000000..75030ab --- /dev/null +++ b/engine/love/readme.txt @@ -0,0 +1,98 @@ +LÖVE is an *awesome* framework you can use to make 2D games in Lua. It's free, open-source, and works on Windows, Mac OS X, Linux, Android, and iOS. + +[![Build Status: Windows](https://ci.appveyor.com/api/projects/status/u1a69u5o5ej1pus4?svg=true)](https://ci.appveyor.com/project/AlexSzpakowski/love) + +Documentation +------------- + +We use our [wiki][wiki] for documentation. +If you need further help, feel free to ask on our [forums][forums], our [Discord server][discord], or our IRC channel [#love on OFTC][irc]. + +Compilation +----------- + +### Windows +Follow the instructions at the [megasource][megasource] repository page. + +### *nix +Run `platform/unix/automagic` from the repository root, then run ./configure and make. + + $ platform/unix/automagic + $ ./configure + $ make + +When using a source release, automagic has already been run, and the first step can be skipped. + +### macOS +Download the required frameworks from [here][dependencies] and place them in `/Library/Frameworks/`. + +Then use the Xcode project found at `platform/xcode/love.xcodeproj` to build the `love-macosx` target. + +### iOS +Download the `ios-libraries` zip file corresponding to the LÖVE version being used from [here][dependencies-ios], +unzip it, and place the `include` and `libraries` subfolders into LÖVE's `platform/xcode/ios` folder. + +Then use the Xcode project found at `platform/xcode/love.xcodeproj` to build the `love-ios` target. + +See `readme-iOS.rtf` for more information. + +### Android +Visit the [Android build repository][android-repository] for build instructions. + +Repository information +---------------------- + +We use the 'default' branch for development, and therefore it should not be considered stable. +Also used is the 'minor' branch, which is used for features in the next minor version and it is +not our development target (which would be the next revision - version numbers are formatted major.minor.revision.) + +We tag all our releases (since we started using mercurial), and have binary downloads available for them. + +Experimental changes are developed in the separate [love-experiments][love-experiments] repository. + +Contributing +------------ + +The best places to contribute are through the Bitbucket issue tracker and the official Discord server or IRC channel. +For code contributions, pull requests and patches are welcome. Be sure to read the [source code style guide][codestyle]. + +Builds +------ + +Releases are found in the 'downloads' section on bitbucket, are linked on [the site][site], +and there's a ppa for ubuntu, [ppa:bartbes/love-stable][stableppa]. + +There are also unstable/nightly builds: + +- Most can be found [here][builds]. +- For ubuntu linux they are in [ppa:bartbes/love-unstable][unstableppa] +- For arch linux there's [love-hg][aur] in the AUR. + +Dependencies +------------ + +- SDL2 +- OpenGL 2.1+ / OpenGL ES 2+ +- OpenAL +- Lua / LuaJIT / LLVM-lua +- FreeType +- ModPlug +- mpg123 +- Vorbisfile +- Theora + +[site]: http://love2d.org +[wiki]: http://love2d.org/wiki +[forums]: http://love2d.org/forums +[discord]: https://discord.gg/rhUets9 +[irc]: irc://irc.oftc.net/love +[dependencies]: http://love2d.org/sdk +[dependencies-ios]: https://bitbucket.org/rude/love/downloads/ +[megasource]: https://bitbucket.org/rude/megasource +[builds]: http://love2d.org/builds +[stableppa]: https://launchpad.net/~bartbes/+archive/love-stable +[unstableppa]: https://launchpad.net/~bartbes/+archive/love-unstable +[aur]: http://aur.archlinux.org/packages/love-hg +[love-experiments]: https://bitbucket.org/bartbes/love-experiments +[codestyle]: https://love2d.org/wiki/Code_Style +[android-repository]: https://bitbucket.org/MartinFelis/love-android-sdl2 diff --git a/engine/map/solid.lua b/engine/map/solid.lua new file mode 100644 index 0000000..9a216db --- /dev/null +++ b/engine/map/solid.lua @@ -0,0 +1,19 @@ +Solid = Object:extend() +Solid:implement(GameObject) +Solid:implement(Physics) + + +function Solid:init(args) + self:init_game_object(args) + self:set_as_chain(true, self.vertices, 'static', 'solid') +end + + +function Solid:update(dt) + self:update_game_object(dt) +end + + +function Solid:draw() + self:draw_game_object() +end diff --git a/engine/map/tilemap.lua b/engine/map/tilemap.lua new file mode 100644 index 0000000..f0abd93 --- /dev/null +++ b/engine/map/tilemap.lua @@ -0,0 +1,66 @@ +-- A tilemap class responsible for the loading and drawing of maps made of tiles. +-- The x, y coordinates passed in represent the center of the map. +-- A tileset object containing the tileset to be used by the map must be passed in, as well as a grid object containing the map itself. +-- If tile_rules is also passed in, then the grid instance must contain its values in relation to what the tiling rules expect. +-- If no tiling rules are present then the grid will contain the 1D index of each tile in the tileset, so if the tileset has 5 columns, the first element in the second row will be numbered 6 in the grid. +-- If solid_rules is passed in, then the that function should receive a tile index and return true on those that are supposed to form a solid object, for instance: +-- function(index) return index ~= 0 end would make every tile index that isn't 0 into a solid object. +-- The created solids are stored in .solids after the tilemap instance is created. They should be added to the same group that you want gameplay objects to collide with the map's solid walls. +-- Solids are evaluated before tile rules are applied to the tile grid. +Tilemap = Object:extend() +function Tilemap:init(x, y, tileset, tile_grid, tile_rules, solid_rules) + self.tileset = tileset + self.grid = tile_grid + self.x, self.y = x, y + self.w, self.h = self.grid.w*self.tileset.tile_w, self.grid.h*self.tileset.tile_h + self.tile_rules = tile_rules + self.solid_rules = solid_rules + + -- Create solids from the tile grid + local tw, th = self.tileset.tile_w, self.tileset.tile_h + if self.solid_rules then + local ox, oy = self.x - self.w/2, self.y - self.h/2 + local tile_polygons = {} + for i = 1, self.grid.w do + for j = 1, self.grid.h do + if self.solid_rules(self.grid:get(i, j)) then + table.insert(tile_polygons, Polygon({ox + (i-1)*tw, oy + (j-1)*th, ox + i*tw, oy + (j-1)*th, ox + i*tw, oy + j*th, ox + (i-1)*tw, oy + j*th})) + end + end + end + self.solids_vertices = {} + for _, solid in ipairs(Polygon.merge_polygons(tile_polygons)) do + table.insert(self.solids_vertices, solid) + end + end + + if self.tile_rules:is(TilekitRules) then + self.grid = Grid(self.grid.w, self.grid.h, self.tile_rules.process({w = self.grid.w, h = self.grid.h, data = self.grid.grid}).data) + end + + -- Create spritebatch + self.spritebatch = love.graphics.newSpriteBatch(self.tileset.image.image, 8192, 'static') + for i = 1, self.grid.w do + for j = 1, self.grid.h do + local v = self.grid:get(i, j) + if v ~= 0 then + self.spritebatch:add(self.tileset:get_quad(v), (i-1)*tw, (j-1)*th) + end + end + end +end + + +function Tilemap:draw(r, sx, sy, ox, oy) + love.graphics.draw(self.spritebatch, self.x - self.w/2, self.y - self.h/2, r or 0, sx or 1, sy or sx or 1, ox or 0, oy or 0) +end + + + + +-- This class is responsible for loading tile rules exported by rxi's Tilekit https://rxi.itch.io/tilekit +-- An instance of this class should be passed in as the third argument for a Tilemap instance +TilekitRules = Object:extend() +function TilekitRules:init(rules_filename) + self.process = require('assets/maps/' .. rules_filename) +end diff --git a/engine/math/chain.lua b/engine/math/chain.lua new file mode 100644 index 0000000..1fc16b0 --- /dev/null +++ b/engine/math/chain.lua @@ -0,0 +1,115 @@ +-- A chain class. If loop is true then this is the same as a polygon, otherwise its a collection of connected lines (an open polygon). +-- Implements every function that Polygon does. +Chain = Object:extend() +Chain:implement(Polygon) +function Chain:init(loop, vertices) + self.loop = loop + self.vertices = vertices + self:get_size() + self:get_bounds() + self:get_centroid() +end + + +-- Draws the chain of lines with the given color and width. +function Chain:draw(color, line_width) + if self.loop and not line_width then + graphics.polygon(self.vertices, color, line_width) + else + for i = 1, #self.vertices-2, 2 do + graphics.line(self.vertices[i], self.vertices[i+1], self.vertices[i+2], self.vertices[i+3], color, line_width) + if self.loop and i == #self.vertices-2 then + graphics.line(self.vertices[i], self.vertices[i+1], self.vertices[1], self.vertices[2], color, line_width) + end + end + end +end + + +-- If loop is true, returns true if the point is inside the polygon. +-- If loop is false, returns true if the point lies on any of the chain's lines. +-- colliding = chain:is_colliding_with_point(x, y) +function Chain:is_colliding_with_point(x, y) + if self.loop then + return mlib.polygon.checkPoint(x, y, self.vertices) + else + for i = 1, #self.vertices-2, 2 do + if mlib.segment.checkPoint(x, y, self.vertices[i], self.vertices[i+1], self.vertices[i+2], self.vertices[i+3]) then + return true + end + end + end +end + + +-- If loop is true, returns true if the line is colliding with the polygon. +-- If loop is false, returns true if the line is colliding with any of the chain's lines. +-- colliding = chain:is_colliding_with_line(line) +function Chain:is_colliding_with_line(line) + if self.loop then + return mlib.polygon.isSegmentInside(line.x1, line.y1, line.x2, line.y2, self.vertices) + else + for i = 1, #self.vertices-2, 2 do + if mlib.segment.getIntersection(self.vertices[i], self.vertices[i+1], self.vertices[i+2], self.vertices[i+3], line.x1, line.y1, line.x2, line.y2) then + return true + end + end + end +end + + +-- If loop is true for both chains, returns true if the polygon is colliding with the polygon. +-- If loop is false for both chains, returns true if any of the lines of one chain are colliding with any of the lines of the other chain. +-- If one is true and the other is false, returns true if the one that's a polygon is colliding with any of the lines of the one that is a chain. +-- colliding = chain:is_colliding_with_chain(other_chain) +function Chain:is_colliding_with_chain(chain) + if self.loop and chain.loop then + return mlib.polygon.isPolygonInside(self.vertices, chain.vertices) or mlib.polygon.isPolygonInside(chain.vertices, self.vertices) + elseif self.loop and not chain.loop then + return chain:is_colliding_with_polygon(self) + elseif not self.loop and chain.loop then + return self:is_colliding_with_polygon(chain) + else + for i = 1, #self.vertices-2, 2 do + for j = 1, #chain.vertices-2, 2 do + if mlib.segment.getIntersection(self.vertices[i], self.vertices[i+1], self.vertices[i+2], self.vertices[i+3], chain.vertices[j], chain.vertices[j+1], chain.vertices[j+2], chain.vertices[j+3]) then + return true + end + end + end + end +end + + +-- If loop is true, returns true if the circle is colliding with the polygon. +-- If loop is false, returns true if the circle is colliding with any of the chain's lines. +-- colliding = chain:is_colliding_with_circle(circle) +function Chain:is_colliding_with_circle(circle) + if self.loop then + return mlib.polygon.isCircleCompletelyInside(circle.x, circle.y, circle.rs, self.vertices) or + mlib.circle.isPolygonCompletelyInside(circle.x, circle.y, circle.rs, self.vertices) or + mlib.polygon.getCircleIntersection(circle.x, circle.y, circle.rs, self.vertices) + else + for i = 1, #self.vertices-2, 2 do + if mlib.circle.getSegmentIntersection(circle.x, circle.y, circle.rs, self.vertices[i], self.vertices[i+1], self.vertices[i+2], self.vertices[i+3]) then + return true + end + end + end +end + + +-- If loop is true, returns true if the polygon is colliding with the polygon. +-- If loop is false, returns true if the polygon is colliding with any of the chain's lines. +-- colliding = chain:is_colliding_with_polygon(polygon) +function Chain:is_colliding_with_polygon(polygon) + if self.loop then + return mlib.polygon.isPolygonInside(self.vertices, polygon.vertices) or mlib.polygon.isPolygonInside(polygon.vertices, self.vertices) + else + for i = 1, #self.vertices-2, 2 do + if mlib.polygon.getSegmentIntersection(self.vertices[i], self.vertices[i+1], self.vertices[i+2], self.vertices[i+3], polygon.vertices) then + return true + end + end + end +end diff --git a/engine/math/circle.lua b/engine/math/circle.lua new file mode 100644 index 0000000..fb36349 --- /dev/null +++ b/engine/math/circle.lua @@ -0,0 +1,85 @@ +-- A circle class. +Circle = Object:extend() +function Circle:init(x, y, rs) + self.x, self.y = x, y + self.rs = rs + self.w, self.h = 2*self.rs, 2*self.rs + self.x1, self.y1, self.x2, self.y2 = self.x - self.rs, self.y - self.rs, self.x + self.rs, self.y + self.rs +end + + +-- Draws the circle . +-- If color is passed in then the circle will be filled with that color (color is a Color instance) +-- If line_width is passed in then the circle will not be filled and will instead be drawn as a set of lines of the given width. +function Circle:draw(color, line_width) + graphics.circle(self.x, self.y, self.rs, color, line_width) +end + + +-- Moves the circle directly to the given position. +-- circle:move_to(20, 20) -> moves the circle to position 20, 20 +function Circle:move_to(x, y) + self.x, self.y = x, y +end + + +-- Returns true if this polygon is colliding with the given shape. +-- colliding = polygon:is_colliding_with_shape(shape) +function Circle:is_colliding_with_shape(shape) + if shape:is(Line) then + return self:is_colliding_with_line(shape) + elseif shape:is(Chain) then + return self:is_colliding_with_chain(shape) + elseif shape:is(Circle) then + return self:is_colliding_with_circle(shape) + elseif shape:is(Polygon) then + return self:is_colliding_with_polygon(shape) + elseif shape:is(Rectangle) then + return self:is_colliding_with_polygon(shape) + elseif shape:is(EmeraldRectangle) then + return self:is_colliding_with_polygon(shape) + elseif shape:is(Triangle) then + return self:is_colliding_with_polygon(shape) + elseif shape:is(EquilateralTriangle) then + return self:is_colliding_with_polygon(shape) + end +end + + +-- Returns true if the point is inside the circle. +-- colliding = polygon:is_colliding_with_point(x, y) +function Circle:is_colliding_with_point(x, y) + return mlib.circle.checkPoint(x, y, self.x, self.y, self.rs) +end + + +-- Returns true if the line is colliding with this circle. +-- colliding = circle:is_colliding_with_line(line) +function Circle:is_colliding_with_line(line) + return mlib.circle.getSegmentIntersection(self.x, self.y, self.rs, line.x1, line.y1, line.x2, line.y2) +end + + +-- Returns true if the chain is colliding with this circle. +-- colliding = circle:is_colliding_with_chain(chain) +function Circle:is_colliding_with_chain(chain) + return chain:is_colliding_with_circle(self) +end + + +-- Returns true if the circle is colliding with this circle. +-- colliding = circle:is_colliding_with_circle(other_circle) +function Circle:is_colliding_with_circle(circle) + return mlib.circle.isCircleCompletelyInside(self.x, self.y, self.rs, circle.x, circle.y, circle.rs) or + mlib.circle.isCircleCompletelyInside(circle.x, circle.y, circle.rs, self.x, self.y, self.rs) or + mlib.circle.getCircleIntersection(self.x, self.y, self.rs, circle.x, circle.y, circle.rs) +end + + +-- Returns true if the polygon is colliding with this circle. +-- colliding = circle:is_colliding_with_polygon(polygon) +function Circle:is_colliding_with_polygon(polygon) + return mlib.polygon.isCircleCompletelyInside(self.x, self.y, self.rs, polygon.vertices) or + mlib.circle.isPolygonCompletelyInside(self.x, self.y, self.rs, polygon.vertices) or + mlib.polygon.getCircleIntersection(self.x, self.y, self.rs, polygon.vertices) +end diff --git a/engine/math/line.lua b/engine/math/line.lua new file mode 100644 index 0000000..08769c7 --- /dev/null +++ b/engine/math/line.lua @@ -0,0 +1,96 @@ +-- A line class. +-- Implements every function that Polygon does. +Line = Object:extend() +Line:implement(Polygon) +function Line:init(x1, y1, x2, y2) + self.x1, self.y1, self.x2, self.y2 = x1, y1, x2, y2 + self.x, self.y = (self.x1 + self.x2)/2, (self.y1 + self.y2)/2 + self.vertices = {x1, y1, x2, y2} + self:get_size() + self:get_bounds() + self:get_centroid() +end + + +-- Draws the line with the given color and width. +function Line:draw(color, line_width) + graphics.line(self.x1, self.y1, self.x2, self.y2, color, line_width) +end + + +-- Noisifies the line, returning a Chain instance with the results. +-- offset corresponds to the maximum amount of perpendicular offseting each line will have +-- generations corresponds to the number of times the line will be subdivided +-- The higher the number of generations, the higher the number of final lines generates and the more granular the noisification will be +-- line:noisify(15, 4) -> noisifies the line with 15 maximum units of offseting with 4 generations +function Line:noisify(offset, generations) + local lines = {} + local generations = generations or 4 + local offset = offset or 8 + table.insert(lines, {x1 = self.x1, y1 = self.y1, x2 = self.x2, y2 = self.y2}) + + for i = 1, generations do + for i = #lines, 1, -1 do + local spx, spy = lines[i].x1, lines[i].y1 + local epx, epy = lines[i].x2, lines[i].y2 + table.remove(lines, i) + + local mpx, mpy = (spx + epx)/2, (spy + epy)/2 + local pnx, pny = Vector(epx - spx, epy - spy):normalize():perpendicular():unpack() + mpx = mpx + pnx*random:float(-offset, offset) + mpy = mpy + pny*random:float(-offset, offset) + table.insert(lines, i, {x1 = spx, y1 = spy, x2 = mpx, y2 = mpy}) + table.insert(lines, i+1, {x1 = mpx, y1 = mpy, x2 = epx, y2 = epy}) + end + offset = offset/2 + end + + local vertices = {} + for i, line in ipairs(lines) do + if i == #lines then + table.insert(vertices, line.x1) + table.insert(vertices, line.y1) + table.insert(vertices, line.x2) + table.insert(vertices, line.y2) + else + table.insert(vertices, line.x1) + table.insert(vertices, line.y1) + end + end + return Chain(false, vertices) +end + + +-- Returns true if the point lies on the line. +-- colliding = line:is_colliding_with_point(x, y) +function Line:is_colliding_with_point(x, y) + return mlib.segment.checkPoint(x, y, self.x1, self.y1, self.x2, self.y2) +end + + +-- Returns true if the line is colliding with this line. +-- colliding = line:is_colliding_with_line(other_line) +function Line:is_colliding_with_line(line) + return mlib.segment.getIntersection(self.x1, self.y1, self.x2, self.y2, line.x1, line.y1, line.x2, line.y2) +end + + +-- Returns true if the chain is colliding with this line. +-- colliding = line:is_colliding_with_chain(chain) +function Line:is_colliding_with_chain(chain) + return chain:is_colliding_with_line(self) +end + + +-- Returns true if the circle is colliding with this line. +-- colliding = line:is_colliding_with_circle(circle) +function Line:is_colliding_with_circle(circle) + return mlib.circle.getSegmentIntersection(circle.x, circle.y, circle.rs, self.x1, self.y1, self.x2, self.y2) +end + + +-- Returns true if the polygon is colliding with this line . +-- colliding = line:is_colliding_with_polygon(polygon) +function Line:is_colliding_with_polygon(polygon) + return mlib.polygon.getSegmentIntersection(self.x1, self.y1, self.x2, self.y2, polygon.vertices) +end diff --git a/engine/math/math.lua b/engine/math/math.lua new file mode 100644 index 0000000..38262c7 --- /dev/null +++ b/engine/math/math.lua @@ -0,0 +1,635 @@ +-- Returns the 2D coordinates of a given index with a grid of a given width +-- math.index_to_coordinates(11, 10) -> 1, 2 +-- math.index_to_coordinates(2, 4) -> 2, 1 +-- math.index_to_coordinates(17, 7) -> 3, 3 +-- math.index_to_coordinates(17, 4) -> 1, 5 +-- math.index_to_coordinates(4, 4) -> 4, 1 +function math.index_to_coordinates(n, w) + local i, j = n % w, math.ceil(n/w) + if i == 0 then i = w end + return i, j +end + + +-- Returns the 1D index of the given 2D coordinates with a grid of a given width +-- math.coordinates_to_index(1, 2, 10) -> 11 +-- math.coordinates_to_index(2, 1, 4) -> 2 +-- math.coordinates_to_index(3, 3, 7) -> 17 +-- math.coordinates_to_index(1, 5, 4) -> 17 +-- math.coordinates_to_index(4, 1, 4) -> 4 +function math.coordinates_to_index(i, j, w) + return i + (j-1)*w +end + + +-- Returns rectangle vertices based on top-left and bottom-right coordinates +-- math.to_rectangle_vertices(0, 0, 40, 40) -> vertices for a rectangle centered on 20, 20 +function math.to_rectangle_vertices(x1, y1, x2, y2) + return {x1, y1, x2, y1, x2, y2, x1, y2} +end + + +-- Rotates the point by r radians with ox, oy as pivot. +-- x, y = math.rotate_point(player.x, player.y, math.pi/4) +function math.rotate_point(x, y, r, ox, oy) + return x*math.cos(r) - y*math.sin(r) + ox - ox*math.cos(r) + oy*math.sin(r), x*math.sin(r) + y*math.cos(r) + oy - oy*math.cos(r) - ox*math.sin(r) +end + + +-- Scales the point by sx, sy with ox, oy as pivot. +-- x, y = math.scale_point(player.x, player.y, 2, 2, player.x - player.w/2, player.y - player.h/2) +function math.scale_point(x, y, sx, sy, ox, oy) + return x*sx + ox - ox*sx, y*sy + oy - oy*sy +end + + +-- Rotates and scales the point by r radians and sx, sy with ox, oy as pivot. +-- x, y = math.rotate_scale_point(player.x, player.y, math.pi/4, 2, 2, player.x - player.w/2, player.y - player.h/2) +function math.rotate_scale_point(x, y, r, sx, sy, ox, oy) + local rx, ry = math.rotate_point(x, y, r, ox, oy) + return math.scale_point(rx, ry, sx, sy, ox, oy) +end + + +-- Returns -1 if the angle is on either left quadrants and 1 if its on either right quadrants. +-- h = math.angle_to_horizontal(math.pi/4) -> 1 +-- h = math.angle_to_horizontal(-math.pi/4) -> 1 +-- h = math.angle_to_horizontal(-3*math.pi/4) -> -1 +-- h = math.angle_to_horizontal(3*math.pi/4) -> -1 +function math.angle_to_horizontal(r) + if r > math.pi/2 or r < -math.pi/2 then return -1 + elseif r <= math.pi/2 and r >= -math.pi/2 then return 1 end +end + + +-- Returns -1 if the angle is on either bottom quadrants and 1 if its on either top quadrants. +-- h = math.angle_to_horizontal(math.pi/4) -> -1 +-- h = math.angle_to_horizontal(-math.pi/4) -> 1 +-- h = math.angle_to_horizontal(-3*math.pi/4) -> 1 +-- h = math.angle_to_horizontal(3*math.pi/4) -> -1 +function math.angle_to_vertical(r) + if r > 0 and r < math.pi then return -1 + elseif r <= 0 and r >= -math.pi then return 1 end +end + + +-- Snaps the value v to the closest number divisible by x and then centers it. This is useful when doing calculations for grids where each cell would be of size x, for instance. +-- v = math.snap_center(12, 16) -> 8 +-- v = math.snap_center(17, 16) -> 24 +-- v = math.snap_center(12, 12) -> 6 +-- v = math.snap_center(13, 12) -> 18 +function math.snap_center(v, x) + return math.ceil(v/x)*x - x/2 +end + + +-- Returns the squared distance between both points. +-- d = math.distance(player.x, player.y, enemy.x, enemy) +function math.distance(x1, y1, x2, y2) + return math.sqrt((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1)) +end + + +-- Loops value t such that is never higher than length and never lower than 0. +-- v = math.loop(3, 2.5) -> 0.5 +-- v = math.loop(3*math.pi, 2*math.pi) -> math.pi +function math.loop(t, length) + return math.clamp(t-math.floor(t/length)*length, 0, length) +end + + +-- Clamps the value to between 0 and 1. +-- v = math.clamp01(-0.1) -> 0 +-- v = math.clamp01(1.1) -> 1 +function math.clamp01(v) + if v < 0 then return 0 + elseif v > 1 then return 1 + else return v end +end + + +-- Rounds the number n to p digits of precision. +-- n = math.round(10.94, 1) -> 10.9 +-- n = math.round(45.321, 0) -> 45 +-- n = math.round(101.9157289403, 5) -> 101.91572 +function math.round(n, p) + local m = 10^(p or 0) + return math.floor(n*m+0.5)/m +end + + +-- Floors value v to the closest number divisible by x. +-- v = math.snap(15, 16) -> 0 +-- v = math.snap(17, 16) -> 16 +-- v = math.snap(13, 4) -> 12 +function math.snap(v, x) + return math.round(v/x, 0)*x +end + + +-- Clamps value v between min and max. +-- v = math.clamp(-4, 0, 10) -> 0 +-- v = math.clamp(83, 0, 10) -> 10 +-- v = math.clamp(0, -10, -4) -> -4 +function math.clamp(v, min, max) + return math.min(math.max(v, min), max) +end + + +-- Returns the squared length of x, y. +-- l = math.length(x, y) +function math.length(x, y) + return math.sqrt(x*x + y*y) +end + + +-- Returns the normalized values of x, y. +-- nx, ny = math.normalize(x, y) +function math.normalize(x, y) + if math.abs(x) < 0.0001 and math.abs(y) < 0.0001 then return x, y end + local l = math.length(x, y) + return x/l, y/l +end + + +-- Returns the sign of value v. +-- s = math.sign(10) -> 1 +-- s = math.sign(-10) -> -1 +-- s = math.sign(0) -> 0 +function math.sign(v) + if v > 0 then return 1 + elseif v < 0 then return -1 + else return 0 end +end + + +-- Returns the angle between point x, y and point px, py. +-- r = math.angle(player.x, player.y, enemy.x, enemy) +function math.angle(x, y, px, py) + return math.atan2(py - y, px - x) +end + + +-- Remaps value v using its previous range of old_min, old_max into the new range new_min, new_max. +-- v = math.remap(10, 0, 20, 0, 1) -> 0.5 because 10 is 50% of 0, 20 and thus 0.5 is 50% of 0, 1 +-- v = math.remap(3, 0, 3, 0, 100) -> 100 +-- v = math.remap(2.5, -5, 5, -100, 100) -> 50 +function math.remap(v, old_min, old_max, new_min, new_max) + return ((v - old_min)/(old_max - old_min))*(new_max - new_min) + new_min +end + + +-- TODO: fix this since it doesn't work properly for some reason +-- Lerp corrected for usage with delta time, see more here https://www.construct.net/en/blogs/ashleys-blog-2/using-lerp-delta-time-924 +-- f is a value between 0 and 1 that corresponds to how much of the distance between src and dst will be covered per second, regardless of frame rate. +-- math.lerp_dt(0.25, dt, self.x, self.x + 100) -> will cover 75% of the distance between self.x and self.x + 100 per second +function math.lerp_dt(f, dt, src, dst) + return math.lerp((1-f^dt), src, dst) +end + + +-- Same as math.lerp_angle except correted for usage with delta time. +-- math.lerp_angle_dt(0.1, dt, enemy.r, enemy:angle_to_object(player)) -> will cover 90% of the distance between enemy.r and and the enemy's angle to the player per second +function math.lerp_angle_dt(f, dt, src, dst) + return math.lerp_angle((1-f^dt), src, dst) +end + + +-- Lerps src to dst with lerp value. +-- v = math.lerp(0.2, self.x, self.x + 100) +function math.lerp(value, src, dst) + return src*(1 - value) + dst*value +end + +-- Lerps the src angle towards dst using value as the lerp amount. +-- enemy.r = math.lerp_angle(0.2, enemy.r, enemy:angle_to_object(player)) +function math.lerp_angle(value, src, dst) + local dt = math.loop((dst-src), 2*math.pi) + if dt > math.pi then dt = dt - 2*math.pi end + return src + dt*math.clamp01(value) +end + + + + +local PI = math.pi +local PI2 = math.pi/2 +local LN2 = math.log(2) +local LN210 = 10*math.log(2) + + + + +function math.linear(t) + return t +end + + +function math.sine_in(t) + if t == 0 then return 0 + elseif t == 1 then return 1 + else return 1 - math.cos(t*PI2) end +end + + +function math.sine_out(t) + if t == 0 then return 0 + elseif t == 1 then return 1 + else return math.sin(t*PI2) end +end + + +function math.sine_in_out(t) + if t == 0 then return 0 + elseif t == 1 then return 1 + else return -0.5*(math.cos(t*PI) - 1) end +end + + +function math.sine_out_in(t) + if t == 0 then return 0 + elseif t == 1 then return 1 + elseif t < 0.5 then return 0.5*math.sin((t*2)*PI2) + else return -0.5*math.cos((t*2-1)*PI2) + 1 end +end + + +function math.quad_in(t) + return t*t +end + + +function math.quad_out(t) + return -t*(t-2) +end + + +function math.quad_in_out(t) + if t < 0.5 then + return 2*t*t + else + t = t - 1 + return -2*t*t + 1 + end +end + + +function math.quad_out_in(t) + if t < 0.5 then + t = t*2 + return -0.5*t*(t-2) + else + t = t*2 - 1 + return 0.5*t*t + 0.5 + end +end + + +function math.cubic_in(t) + return t*t*t +end + +function math.cubic_out(t) + t = t - 1 + return t*t*t + 1 +end + + +function math.cubic_in_out(t) + t = t*2 + if t < 1 then + return 0.5*t*t*t + else + t = t - 2 + return 0.5*(t*t*t + 2) + end +end + + +function math.cubic_out_in(t) + t = t*2 - 1 + return 0.5*(t*t*t + 1) +end + + +function math.quart_in(t) + return t*t*t*t +end + + +function math.quart_out(t) + t = t - 1 + t = t*t + return 1 - t*t +end + + +function math.quart_in_out(t) + t = t*2 + if t < 1 then + return 0.5*t*t*t*t + else + t = t - 2 + t = t*t + return -0.5*(t*t - 2) + end +end + + +function math.quart_out_in(t) + if t < 0.5 then + t = t*2 - 1 + t = t*t + return -0.5*t*t + 0.5 + else + t = t*2 - 1 + t = t*t + return 0.5*t*t + 0.5 + end +end + + +function math.quint_in(t) + return t*t*t*t*t +end + + +function math.quint_out(t) + t = t - 1 + return t*t*t*t*t + 1 +end + + +function math.quint_in_out(t) + t = t*2 + if t < 1 then + return 0.5*t*t*t*t*t + else + t = t - 2 + return 0.5*t*t*t*t*t + 1 + end +end + + +function math.quint_out_in(t) + t = t*2 - 1 + return 0.5*(t*t*t*t*t + 1) +end + + +function math.expo_in(t) + if t == 0 then return 0 + else return math.exp(LN210*(t - 1)) end +end + + +function math.expo_out(t) + if t == 1 then return 1 + else return 1 - math.exp(-LN210*t) end +end + + +function math.expo_in_out(t) + if t == 0 then return 0 + elseif t == 1 then return 1 end + t = t*2 + if t < 1 then return 0.5*math.exp(LN210*(t - 1)) + else return 0.5*(2 - math.exp(-LN210*(t - 1))) end +end + + +function math.expo_out_in(t) + if t < 0.5 then return 0.5*(1 - math.exp(-20*LN2*t)) + elseif t == 0.5 then return 0.5 + else return 0.5*(math.exp(20*LN2*(t - 1)) + 1) end +end + + +function math.circ_in(t) + if t < -1 or t > 1 then return 0 + else return 1 - math.sqrt(1 - t*t) end +end + + +function math.circ_out(t) + if t < 0 or t > 2 then return 0 + else return math.sqrt(t*(2 - t)) end +end + + +function math.circ_in_out(t) + if t < -0.5 or t > 1.5 then return 0.5 + else + t = t*2 + if t < 1 then return -0.5*(math.sqrt(1 - t*t) - 1) + else + t = t - 2 + return 0.5*(math.sqrt(1 - t*t) + 1) + end + end +end + + +function math.circ_out_in(t) + if t < 0 then return 0 + elseif t > 1 then return 1 + elseif t < 0.5 then + t = t*2 - 1 + return 0.5*math.sqrt(1 - t*t) + else + t = t*2 - 1 + return -0.5*((math.sqrt(1 - t*t) - 1) - 1) + end +end + + +function math.bounce_in(t) + t = 1 - t + if t < 1/2.75 then return 1 - (7.5625*t*t) + elseif t < 2/2.75 then + t = t - 1.5/2.75 + return 1 - (7.5625*t*t + 0.75) + elseif t < 2.5/2.75 then + t = t - 2.25/2.75 + return 1 - (7.5625*t*t + 0.9375) + else + t = t - 2.625/2.75 + return 1 - (7.5625*t*t + 0.984375) + end +end + + +function math.bounce_out(t) + if t < 1/2.75 then return 7.5625*t*t + elseif t < 2/2.75 then + t = t - 1.5/2.75 + return 7.5625*t*t + 0.75 + elseif t < 2.5/2.75 then + t = t - 2.25/2.75 + return 7.5625*t*t + 0.9375 + else + t = t - 2.625/2.75 + return 7.5625*t*t + 0.984375 + end +end + + +function math.bounce_in_out(t) + if t < 0.5 then + t = 1 - t*2 + if t < 1/2.75 then return (1 - (7.5625*t*t))*0.5 + elseif t < 2/2.75 then + t = t - 1.5/2.75 + return (1 - (7.5625*t*t + 0.75))*0.5 + elseif t < 2.5/2.75 then + t = t - 2.25/2.75 + return (1 - (7.5625*t*t + 0.9375))*0.5 + else + t = t - 2.625/2.75 + return (1 - (7.5625*t*t + 0.984375))*0.5 + end + else + t = t*2 - 1 + if t < 1/2.75 then return (7.5625*t*t)*0.5 + 0.5 + elseif t < 2/2.75 then + t = t - 1.5/2.75 + return (7.5625*t*t + 0.75)*0.5 + 0.5 + elseif t < 2.5/2.75 then + t = t - 2.25/2.75 + return (7.5625*t*t + 0.9375)*0.5 + 0.5 + else + t = t - 2.625/2.75 + return (7.5625*t*t + 0.984375)*0.5 + 0.5 + end + end +end + + +function math.bounce_out_in(t) + if t < 0.5 then + t = t*2 + if t < 1/2.75 then return (7.5625*t*t)*0.5 + elseif t < 2/2.75 then + t = t - 1.5/2.75 + return (7.5625*t*t + 0.75)*0.5 + elseif t < 2.5/2.75 then + t = t - 2.25/2.75 + return (7.5625*t*t + 0.9375)*0.5 + else + t = t - 2.625/2.75 + return (7.5625*t*t + 0.984375)*0.5 + end + else + t = 1 - (t*2 - 1) + if t < 1/2.75 then return 0.5 - (7.5625*t*t)*0.5 + 0.5 + elseif t < 2/2.75 then + t = t - 1.5/2.75 + return 0.5 - (7.5625*t*t + 0.75)*0.5 + 0.5 + elseif t < 2.5/2.75 then + t = t - 2.25/2.75 + return 0.5 - (7.5625*t*t + 0.9375)*0.5 + 0.5 + else + t = t - 2.625/2.75 + return 0.5 - (7.5625*t*t + 0.984375)*0.5 + 0.5 + end + end +end + + +local overshoot = 1.70158 + +function math.back_in(t) + if t == 0 then return 0 + elseif t == 1 then return 1 + else return t*t*((overshoot + 1)*t - overshoot) end +end + + +function math.back_out(t) + if t == 0 then return 0 + elseif t == 1 then return 1 + else + t = t - 1 + return t*t*((overshoot + 1)*t + overshoot) + 1 + end +end + + +function math.back_in_out(t) + if t == 0 then return 0 + elseif t == 1 then return 1 + else + t = t*2 + if t < 1 then return 0.5*(t*t*(((overshoot*1.525) + 1)*t - overshoot*1.525)) + else + t = t - 2 + return 0.5*(t*t*(((overshoot*1.525) + 1)*t + overshoot*1.525) + 2) + end + end +end + + +function math.back_out_in(t) + if t == 0 then return 0 + elseif t == 1 then return 1 + elseif t < 0.5 then + t = t*2 - 1 + return 0.5*(t*t*((overshoot + 1)*t + overshoot) + 1) + else + t = t*2 - 1 + return 0.5*t*t*((overshoot + 1)*t - overshoot) + 0.5 + end +end + + +local amplitude = 1 +local period = 0.0003 + +function math.elastic_in(t) + if t == 0 then return 0 + elseif t == 1 then return 1 + else + t = t - 1 + return -(amplitude*math.exp(LN210*t)*math.sin((t*0.001 - period/4)*(2*PI)/period)) + end +end + + +function math.elastic_out(t) + if t == 0 then return 0 + elseif t == 1 then return 1 + else return math.exp(-LN210*t)*math.sin((t*0.001 - period/4)*(2*PI)/period) + 1 end +end + + +function math.elastic_in_out(t) + if t == 0 then return 0 + elseif t == 1 then return 1 + else + t = t*2 + if t < 1 then + t = t - 1 + return -0.5*(amplitude*math.exp(LN210*t)*math.sin((t*0.001 - period/4)*(2*PI)/period)) + else + t = t - 1 + return amplitude*math.exp(-LN210*t)*math.sin((t*0.001 - period/4)*(2*PI)/period)*0.5 + 1 + end + end +end + + +function math.elastic_out_in(t) + if t < 0.5 then + t = t*2 + if t == 0 then return 0 + else return (amplitude/2)*math.exp(-LN210*t)*math.sin((t*0.001 - period/4)*(2*PI)/period) + 0.5 end + else + if t == 0.5 then return 0.5 + elseif t == 1 then return 1 + else + t = t*2 - 1 + t = t - 1 + return -((amplitude/2)*math.exp(LN210*t)*math.sin((t*0.001 - period/4)*(2*PI)/period)) + 0.5 + end + end +end diff --git a/engine/math/polygon.lua b/engine/math/polygon.lua new file mode 100644 index 0000000..cdcc274 --- /dev/null +++ b/engine/math/polygon.lua @@ -0,0 +1,227 @@ +-- A polygon class. +Polygon = Object:extend() +function Polygon:init(vertices) + self.vertices = vertices + self:get_size() + self:get_bounds() + self:get_centroid() +end + + +-- Draws the polygon. +-- If color is passed in then the polygon will be filled with that color (color is a Color instance) +-- If line_width is passed in then the polygon will not be filled and will instead be drawn as a set of lines of the given width. +function Polygon:draw(color, line_width) + graphics.polygon(self.vertices, color, line_width) +end + + +-- Noisifies each line that makes up the polygon. +-- offset corresponds to the maximum amount of perpendicular offseting each line will have +-- generations corresponds to the number of times the line will be subdivided +-- The higher the number of generations, the higher the number of final lines generates and the more granular the noisification will be +-- polygon:noisify(15, 4) -> noisifies the polygon with 15 maximum units of offseting with 4 generations +function Polygon:noisify(offset, generations) + local noisified_vertices = {} + for i = 1, #self.vertices, 2 do + local x1, y1 = vs[i], vs[i+1] + local x2, y2 = vs[i+2], vs[i+3] + if not x2 and not y2 then x2, y2 = vs[1], vs[2] end + local noisified_line = math.noisify_line(x1, y1, x2, y2, offset, generations) + table.insert(noisified_vertices, noisified_line) + end + local flattened = table.flatten(noisified_vertices) + local final_vertices = {} + for i = 1, #flattened, 2 do + local x1, y1 = flattened[i], flattened[i+1] + local x2, y2 = flattened[i+2], flattened[i+3] + if not x2 and not y2 then x2, y2 = flattened[1], flattened[2] end + if math.distance(x1, y1, x2, y2) > 0.025 then + table.insert(final_vertices, x1) + table.insert(final_vertices, y1) + end + end + self.vertices = final_vertices +end + + +local path_to_polygon = function(path) + local vs = {} + for i = 1, path:size() do + local p = path:get(i) + table.insert(vs, tonumber(p.x)) + table.insert(vs, tonumber(p.y)) + end + return vs +end + + +local polygon_to_path = function(vs) + local path = clipper.Path() + for i = 1, #vs, 2 do path:add(vs[i], vs[i+1]) end + return path +end + + +-- Inflates the polygon around its center. +-- polygon:inflate(10) -> inflates the polygon by 10 units +function Polygon:inflate(s) + self.vertices = path_to_polygon(clipper.ClipperOffset():offsetPath(polygon_to_path(self.vertices), s, 'miter', 'closedPolygon'):get(1)) +end + + +-- Moves the polygon directly to the given position. +-- polygon:move_to(20, 20) -> moves the polygon to position 20, 20 +function Polygon:move_to(x, y) + if self.x and self.y then self:translate(x - self.x, y - self.y) end + self.x, self.y = x, y +end + + +-- Translates the polygon by the given amount. +-- polygon:translate(20, 20) -> moves the polygon by 20, 20 units +function Polygon:translate(x, y) + for i = 1, #self.vertices, 2 do + self.vertices[i] = self.vertices[i] + x + self.vertices[i+1] = self.vertices[i+1] + y + end +end + + +-- Scales the polygon by the given amount around the given pivot. +-- polygon:scale(2) -> scales the polygon by 2 around its center (if set) or 0 +function Polygon:scale(sx, sy, ox, oy) + for i = 1, #self.vertices, 2 do + self.vertices[i], self.vertices[i+1] = math.scale_point(self.vertices[i], self.vertices[i+1], sx or 1, sy or sx or 1, ox or self.cx or 0, oy or self.cy or 0) + end +end + + +-- Rotates the polygon by the given amount around the given pivot. +-- polygon:rotate(math.pi/4) -> rotates the polygon by 45 degrees around its center (if set) or 0 +function Polygon:rotate(r, ox, oy) + for i = 1, #self.vertices, 2 do + self.vertices[i], self.vertices[i+1] = math.rotate_point(self.vertices[i], self.vertices[i+1], r, ox or self.cx or 0, oy or self.cy or 0) + end +end + + +-- Returns the polygons size. +-- This calculates the bounding box of the polygon and sets that size to the .w, .h attributes. +-- w, h = polygon:get_size() +function Polygon:get_size() + local min_x, min_y, max_x, max_y = 1000000, 1000000, -1000000, -1000000 + for i = 1, #self.vertices, 2 do + if self.vertices[i] < min_x then min_x = self.vertices[i] end + if self.vertices[i] > max_x then max_x = self.vertices[i] end + if self.vertices[i+1] < min_y then min_y = self.vertices[i+1] end + if self.vertices[i+1] > max_y then max_y = self.vertices[i+1] end + end + self.w, self.h = math.abs(max_x - min_x), math.abs(max_y - min_y) + return self.w, self.h +end + + +-- Returns the polygons bounding box top-left and bottom-right positions. +-- This calculates the bounding box of the polygon and sets those positions to the .x1, .y1, .x2, .y2 attributes. +-- x1, y1, x2, y2 = polygon:get_bounds() +function Polygon:get_bounds() + local min_x, min_y, max_x, max_y = 1000000, 1000000, -1000000, -1000000 + for i = 1, #self.vertices, 2 do + if self.vertices[i] < min_x then min_x = self.vertices[i] end + if self.vertices[i] > max_x then max_x = self.vertices[i] end + if self.vertices[i+1] < min_y then min_y = self.vertices[i+1] end + if self.vertices[i+1] > max_y then max_y = self.vertices[i+1] end + end + self.x1, self.y1, self.x2, self.y2 = min_x, min_y, max_x, max_y + return self.x1, self.y1, self.x2, self.y2 +end + + +-- Returns the centroid of the polygon. +-- This calculates the centroid (average of all points) and sets it to the .x, .y attributes. +-- x, y = polygon:get_centroid() +-- TODO: implement get_visual_center https://github.com/mapbox/polylabel/blob/master/polylabel.js +function Polygon:get_centroid() + local sum_x, sum_y = 0, 0 + for i = 1, #self.vertices, 2 do + sum_x = sum_x + self.vertices[i] + sum_y = sum_y + self.vertices[i+1] + end + self.cx, self.cy = sum_x/(#self.vertices/2), sum_y/(#self.vertices/2) + return self.cx, self.cy +end + + +-- Returns true if this polygon is colliding with the given shape. +-- colliding = polygon:is_colliding_with_shape(shape) +function Polygon:is_colliding_with_shape(shape) + if shape:is(Line) then + return self:is_colliding_with_line(shape) + elseif shape:is(Chain) then + return self:is_colliding_with_chain(shape) + elseif shape:is(Circle) then + return self:is_colliding_with_circle(shape) + elseif shape:is(Polygon) then + return self:is_colliding_with_polygon(shape) + elseif shape:is(Rectangle) then + return self:is_colliding_with_polygon(shape) + elseif shape:is(EmeraldRectangle) then + return self:is_colliding_with_polygon(shape) + elseif shape:is(Triangle) then + return self:is_colliding_with_polygon(shape) + elseif shape:is(EquilateralTriangle) then + return self:is_colliding_with_polygon(shape) + end +end + + +-- Returns true if the point is inside the polygon. +-- colliding = polygon:is_colliding_with_point(x, y) +function Polygon:is_colliding_with_point(x, y) + return mlib.polygon.checkPoint(x, y, self.vertices) +end + + +-- Returns true if the line is colliding with this polygon. +-- colliding = polygon:is_colliding_with_line(line) +function Polygon:is_colliding_with_line(line) + return mlib.polygon.isSegmentInside(line.x1, line.y1, line.x2, line.y2, self.vertices) +end + + +-- Returns true if the chain is colliding with this polygon. +-- colliding = polygon:is_colliding_with_chain(chain) +function Polygon:is_colliding_with_chain(chain) + return chain:is_colliding_with_polygon(self) +end + + +-- Returns true if the circle is colliding with this circle. +-- colliding = polygon:is_colliding_with_circle(circle) +function Polygon:is_colliding_with_circle(circle) + return mlib.polygon.isCircleCompletelyInside(circle.x, circle.y, circle.rs, self.vertices) or + mlib.circle.isPolygonCompletelyInside(circle.x, circle.y, circle.rs, self.vertices) or + mlib.polygon.getCircleIntersection(circle.x, circle.y, circle.rs, self.vertices) +end + + +-- Returns true if the polygon is colliding with this polygon. +-- colliding = polygon:is_colliding_with_polygon(other_polygon) +function Polygon:is_colliding_with_polygon(polygon) + return mlib.polygon.isPolygonInside(self.vertices, polygon.vertices) or mlib.polygon.isPolygonInside(polygon.vertices, self.vertices) +end + + +-- Returned results can be either the merged polygons or the holes inside them (or a polygon inside a hole, or a hole inside that polygon, and so on...) +-- Unfortunately for now it doesn't really report which polygons are which, so this function has some limited utility. +function Polygon.merge_polygons(polygons) + local cl = clipper.Clipper() + local paths = clipper.Paths() + for _, polygon in ipairs(polygons) do paths:add(polygon_to_path(polygon.vertices)) end + cl:addPaths(paths, 'subject') + local out = cl:execute('union') + local out_polygons = {} + for i = 1, out:size() do table.insert(out_polygons, path_to_polygon(out:get(i))) end + return out_polygons +end diff --git a/engine/math/random.lua b/engine/math/random.lua new file mode 100644 index 0000000..6f1d9a4 --- /dev/null +++ b/engine/math/random.lua @@ -0,0 +1,94 @@ +-- The base random class. +-- You can create a new Random object with its own seed by passing it in on the constructor. +-- A global instance of this called "random" is available by default. +Random = Object:extend() +function Random:init(seed) + seed = seed or os.time() + self.generator = love.math.newRandomGenerator(seed) +end + + +-- Returns true at the given chance. +-- random:bool(50) -> returns true 50% of the time +-- random:bool(25) -> returns true 25% of the time +-- random:bool(3) -> returns true 3% of the time +function Random:bool(chance) + if self.generator:random(1, 1000) < 10*(chance or 50) then + return true + end +end + + +-- Returns a random real number between the range. +-- random:bool(0, 1) -> returns a random number between 0 and 1, like 0.432 +-- random:bool(-100, 45.2) -> returns a random number between -100 and 45.2, like -99.7 +function Random:float(min, max) + min = min or 0 + max = max or 1 + return (min > max and (self.generator:random()*(min - max) + max)) or (self.generator:random()*(max - min) + min) +end + + +-- Returns a random integer number between the range. +-- random:int(1, 7) -> returns a random integer between 1 and 7, like 4 +-- random:int(-2, 0) -> returns a random integer between -2 and 0, like -2 +function Random:int(min, max) + return self.generator:random(min or 0, max or 1) +end + + +-- Returns a random value of the table. +-- a = {7, 6, 5, 4} +-- random:table(a) -> returns either 7, 6, 5 or 4 randomly +function Random:table(t) + return t[self.generator:random(1, #t)] +end + +-- Returns a random value of the table and also removes it. +-- a = {7, 6, 5, 4} +-- random:table(a) -> returns either 7, 6, 5 or 4 randomly and removes it from the table as well +function Random:table_remove(t) + return table.remove(t, self.generator:random(1, #t)) +end + + +-- Returns a 1 at the given chance, otherwise returns -1. +-- random:sign(65) -> returns 1 65% of the time and -1 35% of the time +-- random:sign(20) -> returns 1 20% of the time and -1 80% of the time +function Random:sign(chance) + if self.generator:random(1, 1000) < 10*(chance or 50) then return 1 + else return -1 end +end + + +-- Returns a random index at the given weights. +-- random:weighted_pick(50, 30, 20) -> will return 1 50% of the time, 2 30% of the time and 3 20% of the time +-- random:weighted_pick(10, 8, 2) -> will return 1 50% of the time, 2 40% of the time and 3 10% of the time +-- random:weighted_pick(2, 1) -> will return 1 66% of the time, will return 2 33% of the time +function Random:weighted_pick(...) + local weights = {...} + local total_weight = 0 + local pick = 0 + for _, weight in ipairs(weights) do total_weight = total_weight + weight end + + total_weight = self:float(0, total_weight) + for i = 1, #weights do + if total_weight < weights[i] then + pick = i + break + end + total_weight = total_weight - weights[i] + end + return pick +end + + +-- Returns a unique identifier. +function Random:uid() + local fn = function(x) + local r = self:int(1, 16) - 1 + r = (x == "x") and (r + 1) or (r % 4) + 9 + return ("0123456789abcdef"):sub(r, r) + end + return (("xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx"):gsub("[xy]", fn)) +end diff --git a/engine/math/rectangle.lua b/engine/math/rectangle.lua new file mode 100644 index 0000000..bc63173 --- /dev/null +++ b/engine/math/rectangle.lua @@ -0,0 +1,39 @@ +-- A rectangle class. +-- Implements every function that Polygon does. +Rectangle = Object:extend() +Rectangle:implement(Polygon) +function Rectangle:init(x, y, w, h, r) + self.x, self.y, self.w, self.h, self.r = x, y, w, h, r + local x1, y1 = math.rotate_point(x - w/2, y - h/2, r or 0, x, y) + local x2, y2 = math.rotate_point(x + w/2, y - h/2, r or 0, x, y) + local x3, y3 = math.rotate_point(x + w/2, y + h/2, r or 0, x, y) + local x4, y4 = math.rotate_point(x - w/2, y + h/2, r or 0, x, y) + self.vertices = {x1, y1, x2, y2, x3, y3, x4, y4} + self:get_size() + self:get_bounds() + self:get_centroid() +end + + + + +-- An emerald rectangle class. This is a rectangle with its corners cut by the given rx, ry amount. +-- Implements every function that Polygon does. +EmeraldRectangle = Object:extend() +EmeraldRectangle:implement(Polygon) +function EmeraldRectangle:init(x, y, w, h, rx, ry, r) + self.x, self.y, self.w, self.h, self.r = x, y, w, h, r + self.rx, self.ry = rx, ry + local x1, y1 = math.rotate_scale_point(x - w/2, y - h/2 + ry, r or 0, x, y) + local x2, y2 = math.rotate_scale_point(x - w/2 + rx, y - h/2, r or 0, x, y) + local x3, y3 = math.rotate_scale_point(x + w/2 - rx, y - h/2, r or 0, x, y) + local x4, y4 = math.rotate_scale_point(x + w/2, y - h/2 + ry, r or 0, x, y) + local x5, y5 = math.rotate_scale_point(x + w/2, y + h/2 - ry, r or 0, x, y) + local x6, y6 = math.rotate_scale_point(x + w/2 - rx, y + h/2, r or 0, x, y) + local x7, y7 = math.rotate_scale_point(x - w/2 + rx, y + h/2, r or 0, x, y) + local x8, y8 = math.rotate_scale_point(x - w/2, y + h/2 - ry, r or 0, x, y) + self.vertices = {x1, y1, x2, y2, x3, y3, x4, y4, x5, y5, x6, y6, x7, y7, x8, y8} + self:get_size() + self:get_bounds() + self:get_centroid() +end diff --git a/engine/math/spring.lua b/engine/math/spring.lua new file mode 100644 index 0000000..75a9fbf --- /dev/null +++ b/engine/math/spring.lua @@ -0,0 +1,70 @@ +-- A Spring class. This is extremely useful for juicing things up. +-- See this article https://github.com/a327ex/blog/issues/60 for more details. +-- The argument passed in are: the initial value of the spring, its stiffness and damping. +Spring = Object:extend() +function Spring:init(x, k, d) + self.x = x or 0 + self.k = k or 100 + self.d = d or 10 + self.target_x = self.x + self.v = 0 +end + + +function Spring:update(dt) + local a = -self.k*(self.x - self.target_x) - self.d*self.v + self.v = self.v + a*dt + self.x = self.x + self.v*dt +end + + +-- Pull the spring with a certain amount of force. This force should be related to the initial value you set to the spring. +function Spring:pull(f, k, d) + if k then self.k = k end + if d then self.d = d end + self.x = self.x + f +end + + +-- Animates the spring such that it reaches the target value in a smoothy springy motion. +-- Unlike pull, which tugs on the spring so that it bounces around the anchor, this changes that anchor itself. +function Spring:animate(x, k, d) + if k then self.k = k end + if d then self.d = d end + self.target_x = x +end + + + + +--[[ +NSpring = Object:extend() + + +function NSpring:new(x, z, o) + self.x = x or 0 + self.z = z or 0.5 + self.o = o or 2*math.pi + self.target_x = self.x + self.v = 0 +end + + +function NSpring:update(dt) + local f = 1 + 2*dt*self.z*self.o + local oo = self.o*self.o + local hoo = dt*oo + local hhoo = dt*hoo + local det_inv = 1/(f+hhoo) + local det_x = f*self.x + dt*self.v + hhoo*self.target_x + local det_v = self.v + hoo*(self.target_x - self.x) + self.x = det_x*det_inv + self.v = det_v*det_inv +end + + +function NSpring:animate(target_x, pd, td) + self.z = math.log(pd)/(self.o*td) + self.target_x = target_x +end +]]-- diff --git a/engine/math/triangle.lua b/engine/math/triangle.lua new file mode 100644 index 0000000..e689f7f --- /dev/null +++ b/engine/math/triangle.lua @@ -0,0 +1,31 @@ +-- An isosceles triangle class. This is a triangle with size w, h centered on x, y pointed to the right (angle 0). +-- Implements every function that Polygon does. +Triangle = Object:extend() +Triangle:implement(Polygon) +function Triangle:init(x, y, w, h) + self.x, self.y, self.w, self.h = x, y, w, h + local x1, y1 = x + h/2, y + local x2, y2 = x - h/2, y - w/2 + local x3, y3 = x - h/2, y + w/2 + self.vertices = {x1, y1, x2, y2, x3, y3} + self:get_size() + self:get_bounds() + self:get_centroid() +end + + +-- An equilateral triangle class. This is a tringle with size w centered on x, y pointed to the right (angle 0). +-- Implements every function that Polygon does. +EquilateralTriangle = Object:extend() +EquilateralTriangle:implement(Polygon) +function EquilateralTriangle:init(x, y, w) + self.x, self.y, self.w = x, y, w + local h = math.sqrt(math.pow(w, 2) - math.pow(w/2, 2)) + local x1, y1 = x + h/2, y + local x2, y2 = x - h/2, y - w/2 + local x3, y3 = x - h/2, y + w/2 + self.vertices = {x1, y1, x2, y2, x3, y3} + self:get_size() + self:get_bounds() + self:get_centroid() +end diff --git a/engine/math/vector.lua b/engine/math/vector.lua new file mode 100644 index 0000000..4ff584e --- /dev/null +++ b/engine/math/vector.lua @@ -0,0 +1,253 @@ +-- The base Vector class. +local EPSILON = 0.0001 +local EPSILON_SQUARED = EPSILON*EPSILON +Vector = Object:extend() +function Vector:init(x, y) + self.x = x or 0 + self.y = y or x or 0 +end + + +function Vector:clone() + return Vector(self.x, self.y) +end + + +function Vector:unpack() + return self.x, self.y +end + + +function Vector.__tostring(self) + return "(" .. tonumber(self.x) .. ", " .. tonumber(self.y) .. ")" +end + + +function Vector:set(x, y) + if not y then + self.x = x.x + self.y = x.y + else + self.x = x + self.y = y + end + return self +end + + +function Vector:add(x, y) + if not y then + self.x = self.x + x.x + self.y = self.y + x.y + else + self.x = self.x + x + self.y = self.y + y + end + return self +end + + +function Vector:sub(x, y) + if not y then + self.x = self.x - x.x + self.y = self.y - x.y + else + self.x = self.x - x + self.y = self.y - y + end + return self +end + + +function Vector:mul(s) + if type(s) == "table" then + self.x = self.x*s.x + self.y = self.y*s.y + else + self.x = self.x*s + self.y = self.y*s + end + return self +end + + +function Vector:div(s) + if type(s) == "table" then + self.x = self.x*s.x + self.y = self.y*s.y + else + self.x = self.x/s + self.y = self.y/s + end + return self +end + + +function Vector:scale(k) + self.x = self.x*k + self.y = self.y*k + return self +end + + +function Vector:rotate(p, r) + local cos = math.cos(r) + local sin = math.sin(r) + local dx = self.x - p.x + local dy = self.y - p.y + self.x = dx*cos - sin*dy + p.x + self.y = sin*dx + cos*dy + p.y + return self +end + + +function Vector:floor() + self.x = math.floor(self.x) + self.y = math.floor(self.y) + return self +end + + +function Vector:ceil() + self.x = math.ceil(self.x) + self.y = math.ceil(self.y) + return self +end + + +function Vector:round(p) + self.x = math.round(self.x, p) + self.y = math.round(self.y, p) + return self +end + + +function Vector:dot(v) + return self.x*v.x + self.y*v.y +end + + +function Vector:is_perpendicular(v) + return math.abs(self:dot(v)) < EPSILON_SQUARED +end + + +function Vector:cross(v) + return self.x*v.y - self.y*v.x +end + + +function Vector:is_parallel(v) + return math.abs(self:cross(v)) < EPSILON_SQUARED +end + + +function Vector:is_set() + return self.x or self.y +end + + +function Vector:is_zero() + return math.abs(self.x) < EPSILON and math.abs(self.y) < EPSILON +end + + +function Vector:zero() + self.x = 0 + self.y = 0 + return self +end + + +function Vector:length() + return math.sqrt(self.x*self.x + self.y*self.y) +end + + +function Vector:length_squared() + return self.x*self.x + self.y*self.y +end + + +function Vector:normalize() + if self:is_zero() then return self end + return self:scale(1/self:length()) +end + + +function Vector:perpendicular() + return Vector(-self.y, self.x) +end + + +function Vector:left_normal() + return Vector(self.y, -self.x) +end + + +function Vector:invert() + self.x = self.x*-1 + self.y = self.y*-1 + return self +end + + +function Vector:project_to(v) + local lsq = v:length_squared() + local dp = self:dot(v) + return Vector(dp*v.x/lsq, dp*v.y/lsq) +end + + +function Vector:truncate(max) + local s = max*max/self:length_squared() + s = (s > 1 and 1) or math.sqrt(s) + self.x = self.x*s + self.y = self.y*s + return self +end + + +function Vector:angle_to(v) + return math.atan2(v.y - self.y, v.x - self.x) +end + + +function Vector:angle() + return math.atan2(self.y, self.x) +end + + +function Vector:distance_squared(v) + local dx = v.x - self.x + local dy = v.y - self.y + return dx*dx + dy*dy +end + + +function Vector:distance(v) + return math.sqrt(self:distance_squared(v)) +end + + +function Vector:bounce(normal, bounce_coefficient) + local d = (1 + (bounce_coefficient or 1))*self:dot(normal) + self.x = self.x - d*normal.x + self.y = self.y - d*normal.y + return self +end + + +function Vector:overlaps_with_circle(cx, cy, r) + return mlib.circle.checkPoint(self.x, self.y, cx, cy, r) +end + + +function Vector:overlaps_with_polygon(vs) + return mlib.polygon.checkPoint(self.x, self.y, vs) +end + + +function Vector:overlaps_with_rectangle(x, y, w, h) + return mlib.polygon.checkPoint(self.x, self.y, x - w/2, y - h/2, x + w/2, y - h/2, x + w/2, y + h/2, x - w/2, y + h/2) +end diff --git a/engine/sound.lua b/engine/sound.lua new file mode 100644 index 0000000..60e7edc --- /dev/null +++ b/engine/sound.lua @@ -0,0 +1,4 @@ +-- TODO: actually implement this later, for now ripple works fine with just name swaps on top of it for naming consistency. +Sound = function(asset_name, options) return ripple.newSound(love.audio.newSource('assets/sounds/' .. asset_name, 'static'), options) end +SoundTag = ripple.newTag +Effect = love.audio.setEffect diff --git a/engine/system.lua b/engine/system.lua new file mode 100644 index 0000000..7f0362b --- /dev/null +++ b/engine/system.lua @@ -0,0 +1,154 @@ +system = {} +local state_path = love.filesystem.getSaveDirectory() .. "/state" + + +function system.update(dt) + if input.f12.pressed then + for k, v in pairs(system.type_count()) do + print(k, v) + end + print("-- " .. math.round(tonumber(collectgarbage("count"))/1024, 3) .. "MB --") + print() + end +end + + +global_type_table = nil +function system.type_name(o) + if global_type_table == nil then + global_type_table = {} + for k, v in pairs(_G) do + global_type_table[v] = k + end + global_type_table[0] = "table" + end + return global_type_table[getmetatable(o) or 0] or "Unknown" +end + + +function system.count_all(f) + local seen = {} + local count_table + count_table = function(t) + if seen[t] then return end + f(t) + seen[t] = true + for k, v in pairs(t) do + if type(v) == "table" then count_table(v) + elseif type(v) == "userdata" then f(v) end + end + end + count_table(_G) +end + + +function system.type_count() + local counts = {} + local enumerate = function(o) + local t = system.type_name(o) + counts[t] = (counts[t] or 0) + 1 + end + system.count_all(enumerate) + return counts +end + + +function system.enumerate_files(path, filter) + local function recursive_enumerate(path, files) + local items = love.filesystem.getDirectoryItems(path) + for _, item in ipairs(items) do + local file = path .. "/" .. item + local info = love.filesystem.getInfo(file) + if info.type == "file" then + table.insert(files, file) + elseif info.type == "directory" then + recursive_enumerate(file, files) + end + end + end + + local files = {} + recursive_enumerate(path, files) + if filter then + local filtered_files = {} + for _, file in ipairs(files) do + if file:find(filter) then + table.insert(filtered_files, file:left(filter):right(path .. "/")) + end + end + return filtered_files + else + return files + end +end + + +function system.does_file_exist(path) + local file = io.open(path, "r") + if file then + file:close() + return true + end +end + + +function system.load_files(path, filter, exclude_table) + local exclude_table = {unpack(exclude_table or {})} + for _, file in ipairs(system.enumerate_files(path, filter)) do + if not table.contains(exclude_table, file) then + require(path .. "." .. file) + end + end +end + + +function system.save_file(filename, data) + binser.w(filename, data) +end + + +function system.load_file(filename) + return binser.r(filename)[1] +end + + +function system.save_state() + if not system.does_file_exist(love.filesystem.getSaveDirectory()) then love.filesystem.createDirectory("") end + binser.w(state_path, state) +end + + +function system.load_state() + if not system.does_file_exist(state_path) then system.save_state() end + state = binser.r(state_path)[1] +end + + +function system.get_main_directory() + return love.filesystem.getSource() +end + + +function system.get_save_directory() + return love.filesystem.getSaveDirectory() +end + + +function system.filedropped(file) + game:filedropped(love.filesystem.newFileData(file:read())) +end + + +function system.rename(old_path, new_path) + os.rename(old_path, new_path) +end + + +function system.execute(cmd) + os.execute(cmd) +end + + +function system.remove(path) + os.remove(path) +end diff --git a/main.lua b/main.lua new file mode 100644 index 0000000..d2eefc0 --- /dev/null +++ b/main.lua @@ -0,0 +1,39 @@ +require 'engine' +require 'shared' +require 'arena' +require 'objects' + + +function init() + shared_init() + + input:bind('move_left', {'a', 'left'}) + input:bind('move_right', {'d', 'right'}) + input:bind('move_up', {'w', 'up'}) + input:bind('move_down', {'s', 'down'}) + + main = Main() + main:add(Arena'arena') + main:go_to'arena' +end + + +function update(dt) + main:update(dt) +end + + +function draw() + shared_draw(function() + main:draw() + end) +end + + +function love.run() + return engine_run({ + game_name = 'SNAKRX', + window_width = 480*3, + window_height = 270*3, + }) +end diff --git a/objects.lua b/objects.lua new file mode 100644 index 0000000..6d6797d --- /dev/null +++ b/objects.lua @@ -0,0 +1,208 @@ +Unit = Object:extend() +Unit:implement(GameObject) +Unit:implement(Physics) +function Unit:init(args) + self:init_game_object(args) + self:set_as_rectangle(9, 9, 'dynamic', (self.player and 'player') or (self.enemy and 'enemy')) + + if self.character == 'vagrant' then + self.color = fg[0] + self.visual_shape = 'triangle' + self.classes = {'ranger', 'warrior', 'mage'} + end + + self:calculate_stats() + + self.r = 0 + self.hfx:add('hit', 1) + self.hp = self.max_hp + + if self.leader then + self.previous_positions = {} + self.followers = {} + self.t:every(0.01, function() + table.insert(self.previous_positions, 1, {x = self.x, y = self.y, r = self.r}) + if #self.previous_positions > 256 then self.previous_positions[257] = nil end + end) + end +end + + +function Unit:update(dt) + self:update_game_object(dt) + self:calculate_stats() + + if self.player and self.leader then + if input.move_left.down then self.r = self.r - 1.66*math.pi*dt end + if input.move_right.down then self.r = self.r + 1.66*math.pi*dt end + self:set_velocity(self.v*math.cos(self.r), self.v*math.sin(self.r)) + + local vx, vy = self:get_velocity() + local hd = math.remap(math.abs(self.x - gw/2), 0, 192, 1, 0) + local vd = math.remap(math.abs(self.y - gh/2), 0, 108, 1, 0) + camera.x = camera.x + math.remap(vx, -100, 100, -24*hd, 24*hd)*dt + camera.y = camera.y + math.remap(vy, -100, 100, -8*vd, 8*vd)*dt + if input.move_right.down then camera.r = math.lerp_angle_dt(0.01, dt, camera.r, math.pi/256) + elseif input.move_left.down then camera.r = math.lerp_angle_dt(0.01, dt, camera.r, -math.pi/256) + elseif input.move_down.down then camera.r = math.lerp_angle_dt(0.01, dt, camera.r, math.pi/256) + elseif input.move_up.down then camera.r = math.lerp_angle_dt(0.01, dt, camera.r, -math.pi/256) + else camera.r = math.lerp_angle_dt(0.005, dt, camera.r, 0) end + end + + if not self.leader then + local d = math.ceil(self.v*0.1)*self.follower_index + local p = self.parent.previous_positions[d] + if p then + self:set_position(p.x, p.y) + self.r = p.r + end + end + + self:set_angle(self.r) +end + + +function Unit:draw() + graphics.push(self.x, self.y, self.r, self.hfx.hit.x, self.hfx.hit.x) + if self.visual_shape == 'triangle' then + graphics.triangle(self.x, self.y, self.shape.w, self.shape.h, self.hfx.hit.f and fg[0] or self.color) + elseif self.visual_shape == 'rectangle' then + graphics.rectangle(self.x, self.y, self.shape.w, self.shape.h, 2, 2, self.hfx.hit.f and fg[0] or self.color) + end + graphics.pop() + + graphics.push(self.x, self.y, 0, self.hfx.hit.x, self.hfx.hit.x) + if self.show_hp then + graphics.line(self.x - 0.5*self.shape.w, self.y - self.shape.h, self.x + 0.5*self.shape.w, self.y - self.shape.h, bg[-3], 2) + local n = math.remap(self.hp, 0, self.max_hp, 0, 1) + graphics.line(self.x - 0.5*self.shape.w, self.y - self.shape.h, self.x - 0.5*self.shape.w + n*self.shape.w, self.y - self.shape.h, self.hfx.hit.f and fg[0] or ((self.player and green[0]) or (self.enemy and red[0])), 2) + end + graphics.pop() +end + + +function Unit:on_collision_enter(other, contact) + if other:is(Wall) and self.leader then + self.hfx:use('hit', 0.5, 200, 10, 0.1) + camera:spring_shake(2, math.pi - self.r) + + for i, unit in ipairs(self.followers) do + self.t:after((i-1)*self.v*0.00185, function() + unit.hfx:use('hit', 0.25, 200, 10, 0.1) + end) + end + + local nx, ny = contact:getNormal() + local vx, vy = self:get_velocity() + if nx == 0 then + self:set_velocity(vx, -vy) + self.r = 2*math.pi - self.r + end + if ny == 0 then + self:set_velocity(-vx, vy) + self.r = math.pi - self.r + end + end +end + + +function Unit:add_follower(unit) + table.insert(self.followers, unit) + unit.parent = self + unit.follower_index = #self.followers +end + + +function Unit:calculate_damage(dmg) + if self.def >= 0 then dmg = dmg*(100/(100+self.def)) + else dmg = dmg*(2 - 100/(100+self.def)) end + return dmg +end + + +function Unit:calculate_stats() + self.base_hp = 100 + self.base_dmg = 10 + self.base_aspd = 1 + self.base_cycle = 2 + self.base_def = 0 + self.base_mvspd = 75 + self.class_hp_a = 0 + self.class_dmg_a = 0 + self.class_aspd_a = 0 + self.class_cycle_a = 0 + self.class_def_a = 0 + self.class_mvspd_a = 0 + self.class_hp_m = 1 + self.class_dmg_m = 1 + self.class_aspd_m = 1 + self.class_cycle_m = 1 + self.class_def_m = 1 + self.class_mvspd_m = 1 + self.buff_hp_a = 0 + self.buff_dmg_a = 0 + self.buff_aspd_a = 0 + self.buff_cycle_a = 0 + self.buff_def_a = 0 + self.buff_mvspd_a = 0 + self.buff_hp_m = 1 + self.buff_dmg_m = 1 + self.buff_aspd_m = 1 + self.buff_cycle_m = 1 + self.buff_def_m = 1 + self.buff_mvspd_m = 1 + + for _, class in ipairs(self.classes) do + if class == 'warrior' then self.class_hp_m = self.class_hp_m*1.4 + elseif class == 'ranger' then self.class_hp_m = self.class_hp_m*1 + elseif class == 'mage' then self.class_hp_m = self.class_hp_m*0.6 + elseif class == 'healer' then self.class_hp_m = self.class_hp_m*1.1 + elseif class == 'cycler' then self.class_hp_m = self.class_hp_m*0.9 end + end + self.max_hp = (self.base_hp + self.class_hp_a + self.buff_hp_a)*self.class_hp_m*self.buff_hp_m + + for _, class in ipairs(self.classes) do + if class == 'warrior' then self.class_dmg_m = self.class_dmg_m*1.1 + elseif class == 'ranger' then self.class_dmg_m = self.class_dmg_m*1.2 + elseif class == 'mage' then self.class_dmg_m = self.class_dmg_m*1.4 + elseif class == 'healer' then self.class_dmg_m = self.class_dmg_m*1 + elseif class == 'cycler' then self.class_dmg_m = self.class_dmg_m*1 end + end + self.dmg = (self.base_dmg + self.class_dmg_a + self.buff_dmg_a)*self.class_dmg_m*self.buff_dmg_m + + for _, class in ipairs(self.classes) do + if class == 'warrior' then self.class_aspd_m = self.class_aspd_m*0.9 + elseif class == 'ranger' then self.class_aspd_m = self.class_aspd_m*1.4 + elseif class == 'mage' then self.class_aspd_m = self.class_aspd_m*1 + elseif class == 'healer' then self.class_aspd_m = self.class_aspd_m*0.5 + elseif class == 'cycler' then self.class_aspd_m = self.class_aspd_m*1 end + end + self.aspd = 1/((self.base_aspd + self.class_aspd_a + self.buff_aspd_a)*self.class_aspd_m*self.buff_aspd_m) + + for _, class in ipairs(self.classes) do + if class == 'warrior' then self.class_cycle_m = self.class_cycle_m*1 + elseif class == 'ranger' then self.class_cycle_m = self.class_cycle_m*1 + elseif class == 'mage' then self.class_cycle_m = self.class_cycle_m*1.25 + elseif class == 'healer' then self.class_cycle_m = self.class_cycle_m*1.1 + elseif class == 'cycler' then self.class_cycle_m = self.class_cycle_m*1.5 end + end + self.cycle = (self.base_cycle + self.class_cycle_a + self.buff_cycle_a)*self.class_cycle_m*self.buff_cycle_m + + for _, class in ipairs(self.classes) do + if class == 'warrior' then self.class_def_m = self.class_def_m*1.25 + elseif class == 'ranger' then self.class_def_m = self.class_def_m*1.1 + elseif class == 'mage' then self.class_def_m = self.class_def_m*1.5 + elseif class == 'healer' then self.class_def_m = self.class_def_m*1.2 + elseif class == 'cycler' then self.class_def_m = self.class_def_m*1 end + end + self.def = (self.base_def + self.class_def_a + self.buff_def_a)*self.class_def_m*self.buff_def_m + + for _, class in ipairs(self.classes) do + if class == 'warrior' then self.class_mvspd_m = self.class_mvspd_m*0.9 + elseif class == 'ranger' then self.class_mvspd_m = self.class_mvspd_m*1.2 + elseif class == 'mage' then self.class_mvspd_m = self.class_mvspd_m*1 + elseif class == 'healer' then self.class_mvspd_m = self.class_mvspd_m*1 + elseif class == 'cycler' then self.class_mvspd_m = self.class_mvspd_m*1 end + end + self.v = (self.base_mvspd + self.class_mvspd_a + self.buff_mvspd_a)*self.class_mvspd_m*self.buff_mvspd_m +end diff --git a/run.sh b/run.sh new file mode 100644 index 0000000..773850f --- /dev/null +++ b/run.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +cd E:/a327ex/SNAKRX # change to the directory of the current project +engine/love/love.exe --console . diff --git a/shared.lua b/shared.lua new file mode 100644 index 0000000..5d4c39a --- /dev/null +++ b/shared.lua @@ -0,0 +1,635 @@ +function shared_init() + local colors = { + white = ColorRamp(Color(1, 1, 1, 1), 0.025), + black = ColorRamp(Color(0, 0, 0, 1), 0.025), + bg = ColorRamp(Color'#303030', 0.025), + fg = ColorRamp(Color'#dadada', 0.025), + fg_alt = ColorRamp(Color'#b0a89f', 0.025), + yellow = ColorRamp(Color'#facf00', 0.025), + orange = ColorRamp(Color'#f07021', 0.025), + blue = ColorRamp(Color'#019bd6', 0.025), + green = ColorRamp(Color'#8bbf40', 0.025), + red = ColorRamp(Color'#e91d39', 0.025), + purple = ColorRamp(Color'#8e559e', 0.025), + } + for name, color in pairs(colors) do _G[name] = color end + modal_transparent = Color(0.1, 0.1, 0.1, 0.5) + fg_transparent = Color(fg[0].r, fg[0].g, fg[0].b, 0.5) + + graphics.set_background_color(bg[0]) + graphics.set_color(fg[0]) + slow_amount = 1 + + sfx = SoundTag() + sfx.volume = 0.5 + music = SoundTag() + music.volume = 0.5 + + fat_font = Font('FatPixelFont', 8) + pixul_font = Font('PixulBrush', 8) + main_canvas = Canvas(gw, gh, {stencil = true}) + shadow_canvas = Canvas(gw, gh) + shadow_shader = Shader(nil, 'shadow.frag') +end + + +function shared_draw(draw_action) + main_canvas:draw_to(function() + draw_action() + if flashing then graphics.rectangle(gw/2, gh/2, gw, gh, nil, nil, flash_color) end + end) + + shadow_canvas:draw_to(function() + graphics.set_color(white[0]) + shadow_shader:set() + main_canvas:draw2(0, 0, 0, 1, 1) + shadow_shader:unset() + end) + + shadow_canvas:draw(6, 6, 0, sx, sy) + main_canvas:draw(0, 0, 0, sx, sy) +end + + + + +SpawnEffect = Object:extend() +SpawnEffect:implement(GameObject) +function SpawnEffect:init(args) + self:init_game_object(args) + self.target_color = self.color or red[0] + self.color = fg[0] + self.rs = 0 + self.t:tween(0.1, self, {rs = 6}, math.cubic_in_out, function() + if self.action then self.action(self.x, self.y) end + self.spring:pull(1) + for i = 1, random:int(6, 8) do HitParticle{group = main.current.effects, self.x, self.y, color = self.target_color, duration = random:float(0.3, 0.5), w = random:float(5, 8), v = random:float(150, 200)} end + self.t:tween(0.25, self, {rs = 0}, math.linear, function() self.dead = true end) + self.t:after(0.15, function() self.color = self.target_color end) + end) +end + + +function SpawnEffect:update(dt) + self:update_game_object(dt) +end + + +function SpawnEffect:draw() + graphics.circle(self.x, self.y, random:float(0.9, 1.1)*self.rs*self.spring.x, self.color) +end + + + +-- Mixin to be added to a state so it can have nodemap creation, saving and manipulating capabilities. +Nodemap = Object:extend() +-- nodemap is a table that contains the definition of the skill tree or overmap. +-- Each node in it should have the following attributes defined: +-- .x, .y, .neighbors or .links. Optionally: .rs, .color, .visited, .can_be_visited, .on_visit, .on_draw, .data +-- An example would look like this: +-- nodemap = { +-- [1] = {x = x, y = y, visited = true, links = {2, 3, 4, 5}} +-- [2] = {x = x, y = y - 64, links = {1}} +-- [3] = {x = x + 64, y = y, links = {1}} +-- [4] = {x = x, y = y + 64, links = {1}} +-- [5] = {x = x - 64, y = y, links = {1}} +-- } +-- .data can be a table that contains other attributes. These will be automatically added to the Node object when it's created. +-- .on_visit should be defined if you want the button to do something when it's clicked. Example: +-- [2] = {x = x, y = y - 64, links = {1}, on_visit = function(visited_node) state.goto'level_2' end} +-- .on_draw should be used when you want to draw the node in some specific way rather than the default one. +-- color_mode can be nil or 'skill_tree', if it's the latter then nodes and edges will change colors according to if they were a part of a skill tree: +-- Unvisitable nodes are gray, visitable nodes are white, visited nodes are their default color +-- This is opposed to the default color mode, where all nodes and edges have their their default colors, and when they're visited they turn gray instead. +function Nodemap:generate_nodemap(group, nodemap, color_mode) + for id, node in pairs(nodemap) do + Node{group = group, x = node.x, y = node.y, node_id = id, neighbors = node.links, rs = node.rs, visited = node.visited, can_be_visited = node.can_be_visited, color = node.color, label = node.label, data = node.data, + on_visit = node.on_visit, on_draw = node.on_draw, color_mode = color_mode} + end + + for id, node in pairs(nodemap) do + for _, node_id in ipairs(node.links) do + if nodemap[node_id] then + Edge{group = group, x = 0, y = 0, node1_id = id, node2_id = node_id, color_mode = color_mode} + end + end + end +end + + +Node = Object:extend() +Node:implement(GameObject) +function Node:init(args) + self:init_game_object(args) + for k, v in pairs(self.data) do self[k] = v end + self.data = nil + self.rs = self.rs or 6 + self.shape = Circle(self.x, self.y, 1.5*self.rs) + self.interact_with_mouse = true + + self.src_color = self.color + if self.color_mode == 'skill_tree' then + self.color = bg[5] + if self.visited then self.color = fg[0] end + end + + self.t:every_immediate(1.4, function() + if self.can_be_visited then + self.t:tween(0.7, self, {sx = 0.9, sy = 0.9}, math.linear, function() + self.t:tween(0.7, self, {sx = 1.1, sy = 1.1}, math.linear, nil, 'visit_pulse_1') + end, 'visit_pulse_2') + end + end, nil, nil, 'visit_pulse') + + if self.label then self.label_r = 0 end + self.t:after(0.01, function() + if self.label then + local xs, ys = 0, 0 + for _, neighbor_id in ipairs(self.neighbors) do + local neighbor = self.group:get_object_by_property('node_id', neighbor_id) + local r = math.angle(self.x, self.y, neighbor.x, neighbor.y) + x, y = math.cos(r), math.sin(r) + xs = xs + x + ys = ys + y + end + self.label_r = Vector(-xs, -ys):angle() + self.label_color = self.color + end + + self.edges = {} + for _, neighbor_id in ipairs(self.neighbors) do + local edge = nil + edge = self.group:get_object_by_properties({'node1_id', 'node2_id'}, {self.node_id, neighbor_id}) + if not edge then edge = self.group:get_object_by_properties({'node1_id', 'node2_id'}, {neighbor_id, self.node_id}) end + if edge then table.insert(self.edges, edge) end + end + end) +end + + +function Node:update(dt) + self:update_game_object(dt) + + if not self.visited then + for _, neighbor_id in ipairs(self.neighbors) do + local neighbor = self.group:get_object_by_property('node_id', neighbor_id) + if neighbor and neighbor.visited then + self.can_be_visited = true + end + end + end + + if self.color_mode == 'skill_tree' then + if self.can_be_visited then + self.color = bg[10] + if self.label then self.label_color = bg[10] end + if self.hot then + self.color = fg[0] + if self.label then self.label_color = fg[0] end + end + end + end + + if self.hot and self.can_be_visited and not self.visited and input.m1.pressed then + self.t:cancel'visit_pulse' + self.t:cancel'visit_pulse_1' + self.t:cancel'visit_pulse_2' + self.sx, self.sy = 1, 1 + self.spring:pull(0.25) + self.can_be_visited = false + self.visited = true + self.hot = false + if self.color_mode == 'skill_tree' then + self.color = self.src_color + if self.label then self.label_color = self.src_color end + else + self.color = bg[5] + if self.label then self.label_color = bg[5] end + end + if self.label then self.label_color = self.color end + if self.on_visit then self:on_visit() end + end +end + + +function Node:draw() + if self.on_draw then + self:on_draw() + else + graphics.push(self.x, self.y, 0, self.spring.x*self.sx, self.spring.x*self.sy) + if self.hot and self.can_be_visited then graphics.circle(self.x, self.y, 1.15*self.shape.rs, self.color) + else graphics.circle(self.x, self.y, self.shape.rs, self.color, 3) end + graphics.pop() + end + + if self.label then + local w = pixul_font:get_text_width(self.label) + local s = math.remap(self.rs, 6, 12, 3.5, 2.5) + graphics.print_centered(self.label, pixul_font, self.x + (w/6)*math.cos(self.label_r) + s*self.rs*math.cos(self.label_r), self.y + s*self.rs*math.sin(self.label_r), 0, self.spring.x*self.sx, self.spring.x*self.sy, nil, nil, self.label_color) + end +end + + +function Node:on_mouse_enter() + self.hot = true + self.spring:pull(0.2, 200, 10) + for _, edge in ipairs(self.edges) do edge.spring:pull(0.15, 200, 10) end +end + + +function Node:on_mouse_exit() + self.hot = false + self.spring:pull(0.05, 200, 10) + for _, edge in ipairs(self.edges) do edge.spring:pull(0.05, 200, 10) end +end + + + + +Edge = Object:extend() +Edge:implement(GameObject) +function Edge:init(args) + self:init_game_object(args) + self.node1 = self.group:get_object_by_property('node_id', self.node1_id) + self.node2 = self.group:get_object_by_property('node_id', self.node2_id) + local r = math.angle(self.node1.x, self.node1.y, self.node2.x, self.node2.y) + self.x1, self.y1 = self.node1.x + 2.75*self.node1.rs*math.cos(r), self.node1.y + 2.75*self.node1.rs*math.sin(r) + self.x2, self.y2 = self.node2.x + 2.75*self.node2.rs*math.cos(r - math.pi), self.node2.y + 2.75*self.node2.rs*math.sin(r - math.pi) + + if self.color_mode == 'skill_tree' then self.color = bg[5] + else self.color = fg[0] end +end + + +function Edge:update(dt) + self:update_game_object(dt) + + if self.color_mode == 'skill' then + self.color = bg[5] + if (self.node1.visited and self.node2.can_be_visited) or (self.node2.visited and self.node1.can_be_visited) then self.color = bg[10] end + if (self.node1.visited and self.node2.visited) or (self.node1.visited and self.node2.hot) or (self.node2.visited and self.node1.hot) then self.color = fg[0] end + else + if self.node1.visited and self.node2.visited then self.color = bg[5] end + end + + --[[ + self.color = bg[5] + if (self.node1.visited and self.node2.can_be_visited) or (self.node2.visited and self.node1.can_be_visited) then self.color = bg[10] end + if (self.node1.visited and self.node2.visited) or (self.node1.visited and self.node2.hot) or (self.node2.visited and self.node1.hot) then self.color = fg[0] end + ]]-- +end + + +function Edge:draw() + graphics.push((self.x1+self.x2)/2, (self.y1+self.y2)/2, 0, self.spring.x, self.spring.x) + graphics.line(self.x1, self.y1, self.x2, self.y2, self.color, 4) + graphics.circle(self.x1, self.y1, 2, self.color) + graphics.circle(self.x2, self.y2, 2, self.color) + graphics.pop() +end + + + + +HoverCrosshair = Object:extend() +HoverCrosshair:implement(GameObject) +function HoverCrosshair:init(args) + self:init_game_object(args) + self.ox, self.oy = 0, 0 + self.sx, self.sy = 0, 0 + self.line_width = 2 + self.w, self.h = 10, 10 +end + + +function HoverCrosshair:update(dt) + self:update_game_object(dt) + if self.animation then self.animation:update(dt) end +end + + +function HoverCrosshair:draw() + graphics.push(self.x, self.y, 0, self.sx*self.spring.x, self.sy*self.spring.x) + graphics.polyline(fg[0], self.line_width, self.x - self.ox, self.y - self.oy + 0.4*self.h, self.x - self.ox, self.y - self.oy, self.x - self.ox + 0.4*self.w, self.y - self.oy) + graphics.polyline(fg[0], self.line_width, self.x - self.ox, self.y + self.oy - 0.4*self.h, self.x - self.ox, self.y + self.oy, self.x - self.ox + 0.4*self.w, self.y + self.oy) + graphics.polyline(fg[0], self.line_width, self.x + self.ox - 0.4*self.w, self.y - self.oy, self.x + self.ox, self.y - self.oy, self.x + self.ox, self.y - self.oy + 0.4*self.h) + graphics.polyline(fg[0], self.line_width, self.x + self.ox - 0.4*self.w, self.y + self.oy, self.x + self.ox, self.y + self.oy, self.x + self.ox, self.y + self.oy - 0.4*self.h) + graphics.pop() +end + + +function HoverCrosshair:activate(x, y, w, h, line_width) + w, h = 10, 10 + line_width = 2 + self.x, self.y = camera:get_local_coords(x, y) + self.t:cancel'deactivate' + self.t:tween(0.1, self, {sx = 1, sy = 1}, math.cubic_in_out, function() self.sx, self.sy = 1, 1 end, 'activate') + if self.w <= 10 and self.h <= 10 then + self.animation = AnimationLogic(0.075, 3, 'bounce', { + function() self.ox, self.oy = 0.6*self.w, 0.6*self.h end, + function() self.ox, self.oy = 0.8*self.w, 0.8*self.h end, + function() self.ox, self.oy = self.w, self.h end, + }) + else + self.animation = AnimationLogic(0.075, 3, 'bounce', { + function() self.ox, self.oy = 0.8*self.w, 0.8*self.h end, + function() self.ox, self.oy = 0.9*self.w, 0.9*self.h end, + function() self.ox, self.oy = self.w, self.h end, + }) + end +end + + +function HoverCrosshair:deactivate() + self.t:cancel'activate' + self.t:tween(0.05, self, {sx = 0, sy = 0}, math.linear, function() self.sx, self.sy = 0, 0 end, 'deactivate') +end + + + + +TransitionEffect = Object:extend() +TransitionEffect:implement(GameObject) +function TransitionEffect:init(args) + self:init_game_object(args) + if not self.text then error('TransitionEffect must have a Text object defined to the .text attribute') end + self.rs = 0 + self.text_sx, self.text_sy = 0, 0 + self.t:after(0.25, function() + self.t:after(0.1, function() + self.t:tween(0.1, self, {text_sx = 1, text_sy = 1}, math.cubic_in_out) + end) + self.t:tween(0.75, self, {rs = gw}, math.linear, function() + if self.transition_action then self.transition_action(unpack(self.transition_action_args)) end + self.t:after(0.5, function() + self.x, self.y = gw/2, gh/2 + self.t:after(0.7, function() self.t:tween(0.05, self, {text_sx = 0, text_sy = 0}, math.cubic_in_out) end) + self.t:tween(0.75, self, {rs = 0}, math.linear, function() self.text = nil; self.dead = true end) + end) + end) + end) +end + + +function TransitionEffect:update(dt) + self:update_game_object(dt) + if self.text then self.text:update(dt) end +end + + +function TransitionEffect:draw() + graphics.push(self.x, self.y, 0, self.sx, self.sy) + graphics.circle(self.x, self.y, self.rs, self.color) + graphics.pop() + if self.text then self.text:draw(gw/2, gh/2, 0, self.text_sx, self.text_sy) end +end + + + + +global_text_tags = { + red = TextTag{draw = function(c, i, text) graphics.set_color(red[0]) end}, + orange = TextTag{draw = function(c, i, text) graphics.set_color(orange[0]) end}, + yellow = TextTag{draw = function(c, i, text) graphics.set_color(yellow[0]) end}, + green = TextTag{draw = function(c, i, text) graphics.set_color(green[0]) end}, + purple = TextTag{draw = function(c, i, text) graphics.set_color(purple[0]) end}, + blue = TextTag{draw = function(c, i, text) graphics.set_color(blue[0]) end}, + bg = TextTag{draw = function(c, i, text) graphics.set_color(bg[0]) end}, + fg = TextTag{draw = function(c, i, text) graphics.set_color(fg[0]) end}, + wavy = TextTag{update = function(c, dt, i, text) c.oy = 2*math.sin(4*time + i) end}, +} + +InfoText = Object:extend() +InfoText:implement(GameObject) +function InfoText:init(args) + self:init_game_object(args) + self.sx, self.sy = 0, 0 + self.ox, self.oy = 0, 0 + self.ow, self.oh = 0, 0 + self.text = Text({}, global_text_tags) +end + + +function InfoText:update(dt) + self:update_game_object(dt) +end + + +function InfoText:draw() + graphics.push(self.x + self.ox, self.y + self.oy, 0, self.sx*self.spring.x, self.sy*self.spring.x) + graphics.rectangle(self.x + self.ox, self.y + self.oy, self.text.w + self.ow, self.text.h + self.oh, self.text.h/4, self.text.h/4, bg[-2]) + self.text:draw(self.x + self.ox, self.y + self.oy + self.text.h/2) + graphics.pop() +end + + +function InfoText:activate(text, ox, oy, sx, sy, ow, oh) + ox, oy = 0, 0 + sx, sy = 1, 1 + ow, oh = 16, 4 + self.text:set_text(text) + self.t:cancel'deactivate' + self.t:tween(0.1, self, {sx = sx, sy = sy}, math.cubic_in_out, function() self.sx, self.sy = sx, sy end, 'activate_1') + self.t:after(0.075, function() self.spring:pull(0.1, 200, 10) end, 'activate_2') +end + + +function InfoText:deactivate() + self.t:cancel'activate_1' + self.t:cancel'activate_2' + self.t:tween(0.05, self, {sy = 0}, math.linear, function() self.sy = 0 end, 'deactivate') +end + + + + +ColorRamp = Object:extend() +function ColorRamp:init(color, step) + self.color = color + self.step = step + for i = -10, 10 do + if i < 0 then + self[i] = self.color:clone():lighten(i*self.step) + elseif i > 0 then + self[i] = self.color:clone():lighten(i*self.step) + else + self[i] = self.color:clone() + end + end +end + + + + +RefreshEffect = Object:extend() +RefreshEffect:implement(GameObject) +RefreshEffect:implement(Parent) +function RefreshEffect:init(args) + self:init_game_object(args) + self.oy = self.h/3 + self.t:tween(0.15, self, {h = 0}, math.linear, function() self.dead = true end) +end + + +function RefreshEffect:update(dt) + self:update_game_object(dt) + self:follow_parent_exclusively() +end + + +function RefreshEffect:draw() + graphics.push(self.x, self.y, self.r) + graphics.rectangle2(self.x - self.w/2, self.y - self.oy, self.w, self.h, nil, nil, fg[0]) + graphics.pop() +end + + + + +function flash(duration, color) + flashing = true + flash_color = color or fg[0] + t:after(duration, function() flashing = false end, 'flash') +end + + +function slow(amount, duration, tween_method) + amount = amount or 0.5 + duration = duration or 0.5 + tween_method = tween_method or math.cubic_in_out + slow_amount = amount + t:tween(duration, _G, {slow_amount = 1}, tween_method, function() slow_amount = 1 end, 'slow') +end + + + + +HitCircle = Object:extend() +HitCircle:implement(GameObject) +function HitCircle:init(args) + self:init_game_object(args) + self.rs = self.rs or 8 + self.duration = self.duration or 0.05 + self.color = self.color or white + self.t:after(self.duration, function() self.dead = true end, 'die') + return self +end + + +function HitCircle:update(dt) + self:update_game_object(dt) +end + + +function HitCircle:draw() + graphics.circle(self.x, self.y, self.rs, self.color) +end + + +function HitCircle:scale_down(duration) + duration = duration or 0.2 + self.t:cancel'die' + self.t:tween(self.duration, self, {rs = 0}, math.cubic_in_out, function() self.dead = true end) + return self +end + + +function HitCircle:change_color(delay_multiplier, target_color) + delay_multiplier = delay_multiplier or 0.5 + self.t:after(delay_multiplier*self.duration, function() self.color = target_color end) + return self +end + + + + +HitParticle = Object:extend() +HitParticle:implement(GameObject) +function HitParticle:init(args) + self:init_game_object(args) + self.v = self.v or random:float(50, 150) + self.r = args.r or random:float(0, 2*math.pi) + self.duration = self.duration or random:float(0.2, 0.6) + self.w = self.w or random:float(3.5, 7) + self.h = self.h or self.w/2 + self.color = self.color or white + self.t:tween(self.duration, self, {w = 2, h = 2, v = 0}, math.cubic_in_out, function() self.dead = true end) +end + + +function HitParticle:update(dt) + self:update_game_object(dt) + self.x = self.x + self.v*math.cos(self.r)*dt + self.y = self.y + self.v*math.sin(self.r)*dt +end + + +function HitParticle:draw() + graphics.push(self.x, self.y, self.r) + graphics.rectangle(self.x, self.y, self.w, self.h, 2, 2, self.color) + graphics.pop() +end + + +function HitParticle:change_color(delay_multiplier, target_color) + delay_multiplier = delay_multiplier or 0.5 + self.t:after(delay_multiplier*self.duration, function() self.color = target_color end) + return self +end + + + + +AnimationEffect = Object:extend() +AnimationEffect:implement(GameObject) +function AnimationEffect:init(args) + self:init_game_object(args) + self.animation = Animation(self.delay, self.frames, 'once', {[0] = function() self.dead = true end}) + self.color = self.color or white +end + + +function AnimationEffect:update(dt) + self:update_game_object(dt) + self.animation:update(dt) + if self.linear_movement then + self.x = self.x + self.v*math.cos(self.r)*dt + self.y = self.y + self.v*math.sin(self.r)*dt + end +end + + +function AnimationEffect:draw() + self.animation:draw(self.x + (self.ox or 0), self.y + (self.ox or 0), self.r + (self.oa or 0), (self.flip_sx or 1)*self.sx, (self.flip_sy or 1)*self.sy, nil, nil, self.color) +end + + +function AnimationEffect:set_linear_movement(v, r) + self.v = v + self.r = r + self.linear_movement = true + local duration = self.animation.size*self.delay + self.t:after(2*duration/3, function() self.t:tween(duration/3, self, {v = 0}, math.cubic_in_out) end) +end + + + + +Wall = Object:extend() +Wall:implement(GameObject) +Wall:implement(Physics) +function Wall:init(args) + self:init_game_object(args) + self:set_as_chain(true, self.vertices, 'static', 'solid') + self.color = self.color or fg[0] +end + + +function Wall:update(dt) + self:update_game_object(dt) +end + + +function Wall:draw() + self.shape:draw(self.color) +end diff --git a/todo b/todo new file mode 100644 index 0000000..b184993 --- /dev/null +++ b/todo @@ -0,0 +1,19 @@ +Vagrant: shoots an ethereal projectile at any nearby enemy that deals physical and magical damage, medium range +Scout: throws a knife at any nearby enemy that deals physical damage and chains, small range +Cleric: heals every unit when any one drops below 50% HP +Swordsman: deals physical damage in an area around the unit, small range +Archer: shoots an arrow at any nearby enemy in front of the unit, long range +Wizard: shoots a projectile at any nearby enemy and deals AoE magical damage on contact, small range + +Ranger: yellow, buff attack speed +Warrior: orange, buff attack damage +Healer: green, buff healing effectiveness +Mage: blue, debuff enemy magic resistance +Cycler: purple, buff cycle speed + +HP +Damage +Attack speed -> stacks additively, capped at minimum 0.125s or +300% +Cycle speed -> stacks additively, capped at minimum 0.5s or +300% +Armor -> if armor >= 0 then dmg_m = 100/(100+armor) else dmg_m = 2-100/(100-armor) +Magic resistance -> if mr >= 0 then dmg_m = 100/(100+mr) else dmg_m = 2-100/(100-mr)