Jump to content


Photo
* * * * * 5 votes

[STUDIO] Android Onscreen Gamepad


  • Please log in to reply
28 replies to this topic

#1 Arusiasotto

Arusiasotto

    GMC Member

  • GMC Member
  • 760 posts
  • Version:GM:Studio

Posted 07 August 2012 - 09:06 PM

  • Title: Android On-Screen Gamepad
  • Description: A simple emulation of a digital gamepad on screen for Android games. OUYA support in testing!
  • GM Version: :GMS:
  • Registered: Yes
  • File Type: .gmz
  • File Size: 535kb
  • File Link: MediaFire 1605 Downloads
  • File Link: OUYA BETA 98 Downloads.
  • Required Extensions: None
  • Required DLLs: None
  • Tags: GMCSTUDIO GMCTUTORIAL GMCTOUCHSCREEN ANDROID

SUMMARY

This example illustrates how to setup a 4 and 8 directional button pad. Tailored for platforming, it allows a person to press multiple onscreen buttons with one thumb so that it reads two keys at once. Also included is a pause feature and an exit button that only has actions on the pause screen to exit the game.

In addition this code will accept Gamepad button presses that coincide with the Xperia Play, and by extension all but the A and B buttons work on the XBOX 360 controller over an OTG cable on Android OS version 3.2+.

Most of the code is commented for clarification.

To use, simply import the compressed .GMZ into a blank project.

UPDATE: Now uses Draw GUI Event for version 1.1.694 and up!

UPDATE: Updated to current syntax.

 

UPDATE: Added an Alternative link to a file that MIGHT support OUYA. I do not own one to test them, and would appreciate feedback.

 

UPDATE: Got some feedback on OUYA, results is it "Kinda Works". 


Edited by Arusiasotto, 31 August 2013 - 07:43 PM.

  • 2

 

"It should be noted that no ethically-trained software engineer would ever consent to write a DestroyBaghdad procedure. Basic professional ethics would instead require him to write a DestroyCity procedure, to which Baghdad could be given as a parameter." - Nathaniel Borenstein

 

 

 


#2 cotycrg

cotycrg

    GMC Member

  • GMC Member
  • 873 posts
  • Version:GM:Studio

Posted 09 August 2012 - 04:01 AM

You know what would be great? If you got the Xperia Play analog pads working in this example too.

..I don't have one myself, but it would seem like a good idea
  • 0

#3 Arusiasotto

Arusiasotto

    GMC Member

  • GMC Member
  • 760 posts
  • Version:GM:Studio

Posted 09 August 2012 - 04:26 AM

You know what would be great? If you got the Xperia Play analog pads working in this example too.

..I don't have one myself, but it would seem like a good idea

I don't know how those are addrssed. I assume they do what the XBOX analog does, and just maps them to the same keys as the dpad.

I have one in the mail (customer needed it fixed, it was under warranty, so I shipped it out) so I can check around monday.

Edited by Arusiasotto, 09 August 2012 - 04:27 AM.

  • 0

 

"It should be noted that no ethically-trained software engineer would ever consent to write a DestroyBaghdad procedure. Basic professional ethics would instead require him to write a DestroyCity procedure, to which Baghdad could be given as a parameter." - Nathaniel Borenstein

 

 

 


#4 Nocturne

Nocturne

    Nocturne Games

  • Administrators
  • 23960 posts
  • Version:GM:Studio

Posted 09 August 2012 - 06:01 AM

The Xperia button maps are in the manual so it should be easy enough for you to do...
  • 0

Button_DynamicPuddles_zps068ef8eb.png  Button_RogueLike_zps6f3451a3.png 40799.png IKrQvWr.png Button_MyGames_zpse9e80bb0.png


#5 Arusiasotto

Arusiasotto

    GMC Member

  • GMC Member
  • 760 posts
  • Version:GM:Studio

Posted 09 August 2012 - 06:25 AM

This does a check of the device for a keypad. If one is available it returns true (1) otherwise it returns false. Please note that this function is mainly for use with Android devices.

For those users with a Sony Xperia Play, there is a set button/key map setup within GameMaker:Studio, so you can use the vk_up, vk_down, vk_left, vk_right for the joypad keys and triangle is ord('T'), Square is ord('S'), circle is vk_back, Cross is vk_space, select is vk_return and start is vk_rshift.


The analog touchpads are not listed. I will assume they don't function until I get my hands on the device to test it. As it stands, the xbox 360 shares most of the same keycode assignments, and the analog stick merely duplicates the outputs of the d-pad under android.

Edit:
I tested the analog touch pads, and nothing. However, the shoulder buttons are addressed the same as the xbox controls, so to map the keys with my example only requires two keycodes being changed. and those keycodes are included in the example.

Edited by Arusiasotto, 10 August 2012 - 09:33 PM.

  • 0

 

"It should be noted that no ethically-trained software engineer would ever consent to write a DestroyBaghdad procedure. Basic professional ethics would instead require him to write a DestroyCity procedure, to which Baghdad could be given as a parameter." - Nathaniel Borenstein

 

 

 


#6 rbrookstx

rbrookstx

    GMC Member

  • GMC Member
  • 4 posts
  • Version:GM:HTML5

Posted 30 August 2012 - 08:03 PM

would this same thing work for html5/ios?
  • 0

#7 Arusiasotto

Arusiasotto

    GMC Member

  • GMC Member
  • 760 posts
  • Version:GM:Studio

Posted 30 August 2012 - 08:10 PM

I do not know if the physical gamepad buttons will work on iOS, I will test on HTML5, but I don't think it will work there. Touch events however should work fine on any platform that supports virtual keys.
  • 0

 

"It should be noted that no ethically-trained software engineer would ever consent to write a DestroyBaghdad procedure. Basic professional ethics would instead require him to write a DestroyCity procedure, to which Baghdad could be given as a parameter." - Nathaniel Borenstein

 

 

 


#8 Arusiasotto

Arusiasotto

    GMC Member

  • GMC Member
  • 760 posts
  • Version:GM:Studio

Posted 28 November 2012 - 10:47 PM

Updated for GMS 1.1.694
  • 0

 

"It should be noted that no ethically-trained software engineer would ever consent to write a DestroyBaghdad procedure. Basic professional ethics would instead require him to write a DestroyCity procedure, to which Baghdad could be given as a parameter." - Nathaniel Borenstein

 

 

 


#9 ScottBeeson

ScottBeeson

    GMC Member

  • GMC Member
  • 263 posts
  • Version:GM:Studio

Posted 04 December 2012 - 12:17 AM

Why can't I open the stupid gmz file? WTF do I do with this? :sad:/>

Edited by ScottBeeson, 04 December 2012 - 12:17 AM.

  • 0
Posted Image Posted Image

#10 Arusiasotto

Arusiasotto

    GMC Member

  • GMC Member
  • 760 posts
  • Version:GM:Studio

Posted 13 December 2012 - 08:15 AM

GMZ files are exported resource files. In Game Maker Studio, you import them.
  • 0

 

"It should be noted that no ethically-trained software engineer would ever consent to write a DestroyBaghdad procedure. Basic professional ethics would instead require him to write a DestroyCity procedure, to which Baghdad could be given as a parameter." - Nathaniel Borenstein

 

 

 


#11 icebrkr

icebrkr

    GMC Member

  • New Member
  • 25 posts
  • Version:GM8.1

Posted 24 December 2012 - 04:43 AM

GMZ files are exported resource files. In Game Maker Studio, you import them.


Yeah, I was confused with this as well.. There should be an 'Import' menu option under File.. Not just in the GM start-up dialog. :-\
  • 0

#12 wikaman1

wikaman1

    GMC Member

  • YoYo Games Staff
  • 46 posts
  • Version:GM:Studio

Posted 03 February 2013 - 01:57 PM

Is the cube meant to keep moving when you change the colour? Just because it stops and you can only do one action at a time... might be the device I'm using :s

edit: ignore this, definitely the device I'm using (Samsung GT-i5500 doesn't support multi touch). Unless anyone knows a work around?

Edited by wikaman1, 03 February 2013 - 05:06 PM.

  • 0

yYfyHTX.png DTPq3WX.png fR7ylHV.png

Twitter - @neilwicker92


#13 Genaut

Genaut

    GMC Member

  • GMC Member
  • 152 posts
  • Version:GM:Studio

Posted 23 February 2013 - 03:11 PM

Nice example :D
  • 0

#14 green.jelly

green.jelly

    GMC Member

  • New Member
  • 13 posts
  • Version:GM:Studio

Posted 26 February 2013 - 01:31 AM

I am totally amazed at how clever some people are with GML, this is awesome. I don't know why but I find these controls fascinating! Hahah!
  • 0

#15 BeboeLasvagas

BeboeLasvagas

    GMC Member

  • New Member
  • 18 posts
  • Version:GM:Studio

Posted 05 March 2013 - 11:18 PM

hey guys, I'm enjoying this on screen controls example. I'm still noticing this is one of the earlier topics talking about this and my search doesn't help me find suggestions or hints to use touch controls with 3dviews. not that it's a huge jump, but I'm sure you guys might have ideas.

any way, I'll keep trying things. maybe I'll post some code when I get my specifics down.
  • 0

banner.png


#16 7Sins

7Sins

    GMC Member

  • New Member
  • 10 posts
  • Version:GM:Studio

Posted 19 March 2013 - 06:30 PM

Hey there,

 

if implemented the type of code into my project but when i try to start it on my Android Device i get an Error:

 

 

FATAL ERROR in action number 1 of Step Event0 for object obj_player_new
 
VMError!! Occured - Push ::
Exectuion Error - Variable Get -5.k_up(100009,0) at gml_Object_obj_player_new_Step_0
 
do you know what is this about?
 
I´m quite new to GM and Coding i apperciate every answer that could help me :)
i already read trough the code i dont understand everything but no error could be found.
 
 
 
Greetings Shaun

  • 0

#17 Arusiasotto

Arusiasotto

    GMC Member

  • GMC Member
  • 760 posts
  • Version:GM:Studio

Posted 06 May 2013 - 11:10 PM

Do you still need assistance with the code? I don't check back here very often, please feel free to PM me.

 

Hey there,

 

 

if implemented the type of code into my project but when i try to start it on my Android Device i get an Error:

 

 

FATAL ERROR in action number 1 of Step Event0 for object obj_player_new
 
VMError!! Occured - Push ::
Exectuion Error - Variable Get -5.k_up(100009,0) at gml_Object_obj_player_new_Step_0
 
do you know what is this about?
 
I´m quite new to GM and Coding i apperciate every answer that could help me  :)
i already read trough the code i dont understand everything but no error could be found.
 
 
 
Greetings Shaun

 

 

 

 

 

however, the problem is see is "-5.k_up. Looks like you messed up the variable, it should be vk_up


Edited by Arusiasotto, 16 June 2013 - 08:50 PM.

  • 0

 

"It should be noted that no ethically-trained software engineer would ever consent to write a DestroyBaghdad procedure. Basic professional ethics would instead require him to write a DestroyCity procedure, to which Baghdad could be given as a parameter." - Nathaniel Borenstein

 

 

 


#18 Yunus

Yunus

    GMC Member

  • New Member
  • 1 posts
  • Version:GM:Studio

Posted 27 June 2013 - 10:20 AM

I downloaded and setup GameMaker Studio Free version available from http://www.yoyogames.com/gamemaker/download 
and also imported your .gmz (GamePad)  file successfully into it. I can also successfully run the project. But I cant see any option for Android under File -> Preferences tab. Please let me know how can I configure this for my Android?

I already have setup complete development environment on my Windows machine.  

I want to run your GamePad code in my Android device.

Please help me for this asap. 


  • 0

#19 theSchap

theSchap

    GMC Member

  • New Member
  • 15 posts
  • Version:GM:Studio

Posted 28 June 2013 - 05:29 AM

Hi Arusiasotto,

 

I just put this on the OUYA, and some of the buttons are a bit screwy. Once I have some more time I'll go through and try to fix it, but I wanted to know if you were aware.

 

I don't notice any thumb stick support, or trigger support. The buttons and shoulder buttons have mixed mapping as well, but the D-pad works perfectly!

 

If an OUYA supported setup doesn't work I plan to work on one. If I find something I can post it here if anyone else is interested.


  • 0

#20 Arusiasotto

Arusiasotto

    GMC Member

  • GMC Member
  • 760 posts
  • Version:GM:Studio

Posted 28 June 2013 - 05:07 PM

Well, I don't have an OUYA. Also, while I had gamepad support, it was basically for the Android Xperia Play.

What you would need to do to alter this for an  Ouya is run this program.

http://www.retardedl...roid_Inputs.zip

write down all the keycodes for your controller. Use those in place of the Xperia play.

Or give me those codes and I will do it.

 

 

I downloaded and setup GameMaker Studio Free version available from http://www.yoyogames.com/gamemaker/download 
and also imported your .gmz (GamePad)  file successfully into it. I can also successfully run the project. But I cant see any option for Android under File -> Preferences tab. Please let me know how can I configure this for my Android?

I already have setup complete development environment on my Windows machine.  

I want to run your GamePad code in my Android device.

Please help me for this asap. 

 

The free version does not have Android exports. Only Pro and up. With the Exception of GMS: MIPs Edition, which is a n android only program.


Edited by Arusiasotto, 28 June 2013 - 05:08 PM.

  • 0

 

"It should be noted that no ethically-trained software engineer would ever consent to write a DestroyBaghdad procedure. Basic professional ethics would instead require him to write a DestroyCity procedure, to which Baghdad could be given as a parameter." - Nathaniel Borenstein

 

 

 


#21 chrishicksfl

chrishicksfl

    GMC Member

  • New Member
  • 11 posts
  • Version:GM:Studio

Posted 20 July 2013 - 08:43 PM

Awesome job Arusiasotto!


  • 0

#22 Arusiasotto

Arusiasotto

    GMC Member

  • GMC Member
  • 760 posts
  • Version:GM:Studio

Posted 31 August 2013 - 07:43 PM

Updated for her pleasure.


  • 0

 

"It should be noted that no ethically-trained software engineer would ever consent to write a DestroyBaghdad procedure. Basic professional ethics would instead require him to write a DestroyCity procedure, to which Baghdad could be given as a parameter." - Nathaniel Borenstein

 

 

 


#23 Marvens01

Marvens01

    GMC Member

  • GMC Member
  • 54 posts
  • Version:GM8

Posted 13 December 2013 - 01:08 AM

MOD EDIT: Pointless post and massive image macro removed. If you have nothing constructive to add, please don't post! 


Edited by Nocturne, 30 May 2014 - 06:32 AM.

  • 0
Posted Image

Color Strike
Coming Soon

#24 Arusiasotto

Arusiasotto

    GMC Member

  • GMC Member
  • 760 posts
  • Version:GM:Studio

Posted 13 December 2013 - 09:13 AM

...

It's a quote...

http://en.wikiquote....niel_Borenstein

Was there something about my onscreen gamepad that you needed help with?


  • 0

 

"It should be noted that no ethically-trained software engineer would ever consent to write a DestroyBaghdad procedure. Basic professional ethics would instead require him to write a DestroyCity procedure, to which Baghdad could be given as a parameter." - Nathaniel Borenstein

 

 

 


#25 Needle

Needle

    GMC Member

  • GMC Member
  • 41 posts
  • Version:GM:Studio

Posted 18 January 2014 - 01:19 PM

Why buttons doesnt work on windows? I didnt test on android yet but Windows doesnt do anything when I press it


  • 0

:banana:NeedleGames's website! :banana:

 A few new games every month!


#26 Arusiasotto

Arusiasotto

    GMC Member

  • GMC Member
  • 760 posts
  • Version:GM:Studio

Posted 07 February 2014 - 04:38 PM

Why buttons doesnt work on windows? I didnt test on android yet but Windows doesnt do anything when I press it

Virtualkeys do not work on Windows. They are for mobile platforms only.


  • 0

 

"It should be noted that no ethically-trained software engineer would ever consent to write a DestroyBaghdad procedure. Basic professional ethics would instead require him to write a DestroyCity procedure, to which Baghdad could be given as a parameter." - Nathaniel Borenstein

 

 

 


#27 McNe Projects

McNe Projects

    GMC Member

  • New Member
  • 6 posts
  • Version:Unknown

Posted 08 February 2014 - 09:45 PM

Hello,

I have a couple game's I'm making. I f anyone is willing to add on screen controls after I'm finished with the games I WILL pay them! All the hard coding can get confusing and I'm getting errors. I will pay to have this done and ported to android and IOS. PM me if interested! 


  • 0

#28 zerolegends

zerolegends

    GMC Member

  • GMC Member
  • 158 posts

Posted 30 May 2014 - 06:04 AM

I used this to try and work with my android game, im trying to make a Megaman Zero clone... I tried replacing one of the buttons with an "R" button ont he top left of the view as the Shoot and for some reason when i tap the Shoot/Left or right buttons and Jump... it bugs up and when i lift my fingers off of the buttons it doesnt register as me lifting it off.. as a matter of fact i made it to where it was still being held down... any ideas on how to fix?

 

in case you didnt understand that... Its basically bugging up when i use 3 buttons at a time


Edited by zerolegends, 30 May 2014 - 06:09 AM.

  • 0

#29 Arusiasotto

Arusiasotto

    GMC Member

  • GMC Member
  • 760 posts
  • Version:GM:Studio

Posted 06 March 2015 - 06:48 AM

Does your device accept more than two touches at once?


  • 0

 

"It should be noted that no ethically-trained software engineer would ever consent to write a DestroyBaghdad procedure. Basic professional ethics would instead require him to write a DestroyCity procedure, to which Baghdad could be given as a parameter." - Nathaniel Borenstein

 

 

 





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users