Jump to content


Photo
* * * * * 1 votes

Joystick And Joypad Example


  • Please log in to reply
8 replies to this topic

#1 reek

reek

    GMC Member

  • New Member
  • 66 posts

Posted 15 April 2010 - 05:43 AM

  • Title: Joystick and Joypad Example
  • Description: Plug in your usb Joystick/pad and see all the values as you push buttons, move the sticks, etc. Also a simple arrow object can be moved around with one stick and fires bullets with the other, ala Robotron
  • GM Version: GM8
  • Registered: yes but delete a couple lines and can use unregged
  • File Type: .gmk
  • File Size: 287kb
  • File Link: http://s98060354.onl...pad_Example.gmk
Code is thoroughly commented and easy to understand if you spend a few minutes.
I have an axis pad so that's what I used as an example. I'd be interested to know how this code works with other pads.
Also I am wanting to expand the way the program reads the analog sticks. It currently just reduces the analog values to on/off so the movement is one speed and the standard eight directions but could be coded to allow you to shoot or move at any angle and slower or faster depending on how hard the sticks are pressed.

Screenshot of Joystick and Joypad example
  • 1

#2 reek

reek

    GMC Member

  • New Member
  • 66 posts

Posted 10 July 2010 - 05:45 AM

I thought somebody would have wanted to use a joypad by now...
  • 0

#3 Carnivac

Carnivac

    The Hunter

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

Posted 10 July 2010 - 11:06 AM

I thought somebody would have wanted to use a joypad by now...


I'm sure someone people have used this but not commented and others like me have been using joypads for years so already know how to do it all. Don't worry about it. I'm glad you put this up to help try encourage others to put native joypad support into their games so it's here for them if they need it. There are at least 3 different ways the d-pad gets read by GM depending on the joypad in use. 360 degrees POV (which I'll never really understand why a d-pad would need that), joystick_xpos/ypos (normally used for the analogue stick but some pads register that as the d-pad) and then there's the simple button method where the d-pad just reads as fire buttons 13-16. It's a pain in the butt trying to support them all. I need to overhaul my joypad config code so it asks the player to press a button on the d-pad and it'll read which of those ways it detected and set the controls according. I just haven't got around to it yet.

Bonus point for mentioning 'Robotron' in your description too :)
  • 0

#4 reek

reek

    GMC Member

  • New Member
  • 66 posts

Posted 21 July 2010 - 02:25 AM

Robotron was the first game to use two independent joysticks- back in the day I once played for 4 hours on one quarter...arcade games are rigged to kill you or run out of time in about 5 minutes nowadays, lol.
  • 0

#5 sunomi316

sunomi316

    GMC Member

  • GMC Member
  • 1 posts

Posted 27 July 2010 - 09:11 AM

would this work for gm7?
  • 0

#6 reek

reek

    GMC Member

  • New Member
  • 66 posts

Posted 27 July 2010 - 01:03 PM

would this work for gm7?


The joystick code hasn't changed so yes it should work perfectly. I will try and post a GM7 version- I just gotta fire up my old laptop which has GM7 on it...
  • 0

#7 Carnivac

Carnivac

    The Hunter

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

Posted 27 July 2010 - 01:57 PM

Robotron was the first game to use two independent joysticks- back in the day I once played for 4 hours on one quarter...arcade games are rigged to kill you or run out of time in about 5 minutes nowadays, lol.



I still play Robotron often on MAME plugging my laptop into the HDTV for a nice big screen (with arcade scanlines set on) and Dual X-Arcade joysticks for a nice proper arcade feel. 28 years old that game is now and still a lot of fun.
  • 0

#8 b35a13

b35a13

    GMC Member

  • New Member
  • 2 posts

Posted 23 August 2010 - 11:11 AM

Thanks, I was looking for something like this. ;)
  • 0

#9 dcpyatt

dcpyatt

    GMC Member

  • New Member
  • 6 posts

Posted 17 February 2012 - 03:42 AM

I thought somebody would have wanted to use a joypad by now...


Thank you for this! I wanted something that would give me a visual on what was happening with my Red Octane XBOX 360 guitar. PERFECT! THANK YOU AGAIN!

DaveP in Ohio
aka DocMAME
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users