Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics

Joysticker Pro

A Joystick to Keyboard Mapping utility using Lua scripts · By Pixelbyte Studios

Any way to program the script to hold down a key?

A topic by Kupplen created Sep 14, 2017 Views: 660 Replies: 4
Viewing posts 1 to 2

I've been using this lately and I've been loving how customizable this is, but I've got a question - is there any way to map an input to "auto-fire" a key when the button is held down? For example, I currently have the "back" button on the controller set to Z, and when I press and hold the back button it only registers it as a single input, rather than a continuous stream of inputs. Is there any way to modify the lua script for this? Thank you.

Developer (1 edit)

There currently is not, although it is something I've been planning on adding. Your question has prompted me to look into it, and as a result, I'm releasing an updated version that upgrades some internal libraries and fixes a couple of bugs.  Currently I'm unable to look into it much more, but I will as I get time. I'm glad you're finding the program useful.

Thank you for such a prompt response! All the best for your projects!

Hi, I've actually got a follow up query. Is there any way to map a joystick input to multiple inputs? For example, I want to map the left shoulder button to, press, F12 and then F11 to activate all my buffs with a single key. Thank you!

Developer (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

-------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)
            JS.SendKey(keys, state)
    elseif (state == 1) then--Only print the message when the input is active
        print("Unassigned: ".. input_type .. "\n")