• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!
  • Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

Android [SOLVED] Custom control engine not working with virtual keys and gamepad

KhMaIBQ

Member
Before I explain the custom control engine, I created this custom control engine for the Windows version of my game. It works fine in the Windows version, and now I am trying to port my game to Android to see if it is feasible.

The custom control engine allows the user to remap the controls. They can use the keyboard, a gamepad, or both at the same time. All the controller information is stored within an object. I assign the custom control object to another object (such as the player character) to allow control of the object it was assigned to.

I create the variables to track the controller state in the Create event:
Code:
for ( var i = 0; i < GAMEPAD_TOTAL; i += 1 )
    {
        button_key[ i ] = 0; // Actual keyboard key value (such as vk_left)
        button_joy[ i ] = 0;
       
        trigger[ i ] = false;
        hold[ i ] = false;
        release[ i ] = false;
        hold_time[ i ] = 0;
    }
I update the controller state in the step event:
Code:
for ( var i = 0; i < GAMEPAD_TOTAL; i += 1 )
    {
        trigger[ i ] = false;
        release[ i ] = false;
       
        if ( !hold[ i ] )
        {
            if ( scr_Gamepad_CheckButton( i ) )
            {
                trigger[ i ] = true;
                hold[ i ] = true;
            }
        }
        else
        {
            if ( !scr_Gamepad_CheckButton( i ) )
            {
                release[ i ] = true;
                hold[ i ] = false;
                hold_time[ i ] = 0;
            }
            else
            {
                hold_time[ i ] += 1;
            }
        }
    }
In the scr_Gamepad_CheckButton script from above, I check for input: (example)
Code:
if ( keyboard_check_direct( arg_button ) ) { return true; } else { return false; }

if ( gamepad_button_check( tmp_slot, gp_face1 ) ) { return true; } else { return false; }
As you can see, I'm just checking input through code using keyboard_check_direct and the gamepad functions. I implemented basic virtual keys and confirmed that they work properly for keyboard events (such as Add Event -> Key Press -> Left) that I have in my game. However, virtual keys don't seem to work for checking input through code.

Am I doing something wrong, or do virtual keys not work with checking input through code? Do I need to create a separate custom control engine for the Android version of my game?

Thanks in advance for any help! It is very much appreciated!

Link to the Windows version of the game: https://twitter.com/KhMaIBQ/status/977828547958992896

I might have already found my answer, but I would still like to confirm it. From the help document:
This is done by assigning a "virtual Key" to an internally mapped standard keyboard key and then using the keyboard events that they generate to control your application.
 
Top