Jump to content


Photo

keyboard_key_press function in android


  • Please log in to reply
2 replies to this topic

#1 master higgins

master higgins

    GMC Member

  • New Member
  • 11 posts

Posted 08 March 2012 - 09:51 PM

Hi, I've tried using the keyboard_key_press function to simulate key presses in android since I'm porting a game I made in GM 8.1 and I use a lot of keyboard_check_press invocations in the code. I was wondering if it's possible to send virtual keystrokes with keyboard_key_press so keyboard_check_pressed detects the event.

If anyone has tried this please enlighten me, so if it doesn't work that way I continue replacing the keyboard_check_pressed invocations with direct readings of the state of the on-screen controls I'm making.

Thanks for any replies!
Greets!
  • 0

#2 master higgins

master higgins

    GMC Member

  • New Member
  • 11 posts

Posted 12 March 2012 - 07:09 PM

Hi, I've tried using the keyboard_key_press function to simulate key presses in android since I'm porting a game I made in GM 8.1 and I use a lot of keyboard_check_press invocations in the code. I was wondering if it's possible to send virtual keystrokes with keyboard_key_press so keyboard_check_pressed detects the event.

If anyone has tried this please enlighten me, so if it doesn't work that way I continue replacing the keyboard_check_pressed invocations with direct readings of the state of the on-screen controls I'm making.

Thanks for any replies!
Greets!


Anyone has succeded using this function so far?

Actually, what I'd like to know if keyboard_key_press can be read by keyboard_check_pressed or it's impossible since they'll be always be out of sync. For example, if keyboard_key_press is on in the step event of one object and keyboard_check_pressed is in the step event of another object I guess the first can't reach the second because the keyboard_key_press lasts only for the step event of the first object and in the step event of object 2 is inactive.

I hope someone in the staff can help me figure this behaviour. It'd be nice if all functions that don't work in a certain platform be striked out or shown as syntax errors.

Thanks! ;)

Edited by master higgins, 12 March 2012 - 07:10 PM.

  • 0

#3 diogomota

diogomota

    GMC Member

  • New Member
  • 4 posts

Posted 12 March 2012 - 07:31 PM

just add virtual keys on the screen :

globalvar vk1,vk2;
vk1 = YoYo_AddVirtualKey(x,y,w,k,//key to emulate here);
vk2 = YoYo_AddVirtualKey(0,0,200,100, vk_left);
in the code to check for press just do the usual "keyboard_check_pressed(vk_left); and it will detect

note that the position of the virtual keys is relative to the screen of the phone not the room, it'll be fixed to the screen.

to delete a virtual key : YoYo_DeleteVirtualKey(vk1);
  • 1




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users