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:
I update the controller state in the step event:
In the scr_Gamepad_CheckButton script from above, I check for input: (example)
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:
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;
}
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;
}
}
}
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; }
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.