--[[
    Module for obtaining the input state for the vehicle, using UserInputService
]]

local UserInputService = game:GetService("UserInputService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local ClientVehicleBoosts = require(ReplicatedStorage.Source.ClientVehicleBoosts)
local Flags = require(ReplicatedStorage.Source.Common.Flags)

local FlagEnableBoosts = Flags.EnableBoosts

local UserInput = {}

local throttle = 0
local steer = 0

local actions = {
	Forwards = {Enum.KeyCode.W, Enum.KeyCode.Up},
	Backwards = {Enum.KeyCode.S, Enum.KeyCode.Down},
	Left = {Enum.KeyCode.A, Enum.KeyCode.Left},
	Right = {Enum.KeyCode.D, Enum.KeyCode.Right},
	Boost = {Enum.KeyCode.Space}
}

local function getActionFromInput(inputObject)
	for action, bindings in pairs(actions) do
		for _, keyCode in pairs(bindings) do
			if keyCode == inputObject.KeyCode then
				return action
			end
		end
	end
end

local function isActionHeld(action)
	local bindings = actions[action]
	for _, keyCode in pairs(bindings) do
		if UserInputService:IsKeyDown(keyCode) then
			return true
		end
	end
	return false
end
