Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags
(1 edit)

Try this script. It uses a custom state_change handler to check if the key in the map is a single value or a table, if it is a table, it calls SendKey() on all elements of the table. Note: You may not achieve the desired results with this as the SendKey() calls might have to have some delay inserted. I plan to have this built-in as part of a future update.

--
--This script is used with joysticker Pro
--

--Below is our mapping table which tells Joysticker which keys to press for a corresponding Joystick Input

--Remaps analog dp/down/left/right to the arrow keys, Joystick Button a to 'Z' and 'A', and Joystick Button x to 'X' and 'V'

--This demonstrates a way to map single joystick inputs to multiple keypress outputs
local map = Map{
    name = "Player1", --the name is optional
    padUp = Key.Up,
    padDown = Key.Down,
    padLeft = Key.Left,
    padRight = Key.Right,
    a = {Key.Z,Key.A},
    x = {Key.X, Key.V} }

--Tell JoystickerPro to also map the Left analog stick of the joystick
--to the pad controls: up, down, left, right
JS.analog_conversion_mode = JS.CONVERT_LEFT

--Add the maping to JoystickerPro's controller maps
JS.AddMapping(map)

-------Custom Callback:

--state_change() is called whenever a joystick input changes state
--You can provide your own implementations of the state_change callback and
--do whatever you want in response to joystick input
--This handler does some of what the default handler does in that
--it takes the input_type and looks for a corresponding key mapping in the mappings table
--
--NOTE: If you do this, the JS.analog_conversion_mode will no longer work. You can re-implement it
-- by making use of the ConvertAnalogAxisToDigital() method (see docs/README.txt for more info)
function state_change(stick_id, input_type, state)
    local m = JS.FindMapping(stick_id)
    
    local keys = m[input_type]
    if (keys ~= nil) then
        print(input_type .. " =[" .. state .. "]=\n")
         --If it is a table, then assume multiple keys
         if type(keys) == "table" then
            for k,v in pairs(keys) do
                JS.SendKey(v, state)
            end
         else
            JS.SendKey(keys, state)
         end
    elseif (state == 1) then--Only print the message when the input is active
        print("Unassigned: ".. input_type .. "\n")
     end
end