Jump to content


Photo

Joykeymousecombo


  • Please log in to reply
11 replies to this topic

#1 icuurd12b42

icuurd12b42

    Self Formed Sentient

  • GMC Elder
  • 18181 posts
  • Version:GM:Studio

Posted 29 May 2010 - 10:46 PM

JoyKeyMouseCombo by icuurd12b42
GM7 Pro
Last Update: May 31 2010 9:40AM

This enhances the joystick and mouse and keyboard functions and adds Combo handling

*Combo System is being debugged right now, keyboard combo stops working properly when no joystick is plugged, an interesting problem indeed.

Joystick
Detects the joystick button and POV HAT (DPAD) pressed, down, held (for a period of time) and released
Detect double tap or any button/hat combination of sequenced input (eg combos)

Keyboard and Mouse
Detects the (all) mouse button and keyboard keys (including media buttons) pressed, down, held (for a period of time) and released
Detect double tap or any button/keys combination of sequenced input (eg combos)

Combo Support
Define joystick (game pad) button and DPAD combo sequence of any lenght
Define mouse and/or keyboard combo sequence of any lenght
Adjust the combo trigger and time out
Detect multiple combos combination, eg combo1 followed by combo2
Supports, via combo trigger timer, combos with similar sequences, like AA combo and AAB combo, typing AAB will not trigger AA combo.

Demo Combos
Mouse/Keyboard (Read Object2)
"BB";
"AA";
"AABB";
"BBAA";
"AACC"
"CC"
"CCAA"
doubleclick
lmouseSpacelmouse //shows conflict with double click;
rmouseSpacermouse

Joystick (Read Object3)
"BUT2BUT2";
"BUT1BUT1";
"BUT1BUT1BUT2BUT2";
"BUT2BUT2BUT1BUT1";
"BUT1BUT1BUT3BUT3"
"BUT3BUT3"
"BUT3BUT3BUT1BUT1"
"POV90","POV270","POV90");
"POV90","BUT1","POV90");
"BUT4BUT4"

*Some combos will trigger faster than others according to the method chosen

Axis Help
Object0 shows detection of all joystick interfaces and shows how to implement direction and dead zones
Object1 Shows the joystick button/hat state detection
Object2 Show the keyboard/Mouse state detection and Keyboard Combos
Object3 Show Joystick button/hat combos

*Keyboard/Mouse and joystick support are separate implementation though the interface is almost the same for both.

Update:
Added handler for sticky keys. For example, F24 on my laptop somtimes always return down, its a bug with my laptop, though it allowed me to handle the case where you may have faulty hardware (joystick and keyboard) with stuck keys, only affects combo system.
Added joySmoothAxis to smooth out the axis with a center dead zone and a edge dead zone. So that fidgity controller dont cause weird movement (center dead zone) or some axis mosition dont cause slower movement (edge dead zone) for example, smooth the axis value so that starting at axis value .3 to .7 it returns 0 to 1, where <.3 = 0, .3 to .7 = 0 to 1 and >.7 = 1
Added exclusion from Combo. So you can exclude keys, buttons from the system so it will not add the entry to the combo list, say if you want to move with the arrows while doing combos with wasd. Same with the joystick combo, to exclude the DPAD from the combo detection for example.

Edited by icuurd12b42, 31 May 2010 - 10:11 PM.

  • 0

gmcbanner.pnggmcbanner_tools.png

ICU Live Tutoring Through Slack or Skype | My Tools Page follow.png

I FRANTICALLY MADE MY 18000 POST TOPIC BEFORE MIKE ANNOUNCED A DELAY...
Now I'm squirming not to hit that reply button


#2 icuurd12b42

icuurd12b42

    Self Formed Sentient

  • GMC Elder
  • 18181 posts
  • Version:GM:Studio

Posted 31 May 2010 - 02:20 AM

Added more options and Added combo support ABBA LOL

Fixed a few problems

Added a few more features

Edited by icuurd12b42, 31 May 2010 - 02:04 PM.

  • 0

gmcbanner.pnggmcbanner_tools.png

ICU Live Tutoring Through Slack or Skype | My Tools Page follow.png

I FRANTICALLY MADE MY 18000 POST TOPIC BEFORE MIKE ANNOUNCED A DELAY...
Now I'm squirming not to hit that reply button


#3 kburkhart84

kburkhart84

    Firehammer Games

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

Posted 15 November 2010 - 06:00 AM

I have an extension called kbinput, that does action mapping. It makes it easy to have the game player configure the controls, keyboard or joysticks, and allows your game objects to call the same function to poll the input, no matter what actual button/key is set up with it.

I saw this script set you(icuurd12b42) did and thought that such "combos" may not be a bad thing to add to my extension, though it would likely be combos with actions, not specific keys. Would it be a problem for you if I used your code in some form to implement this in my extension??

I know you are making this script set public, but I still wanted to ask for permission.
  • 0

My KBInput system is now on the marketplace here.  It wraps up nice and tight GMStudio's input system into a few function calls making a user configurable input system that works the same regardless of what inputs the player has chosen including keyboard, mouse buttons, and gamepad/joysticks using DInput/XInput.  The support forum topic for it is here.


#4 icuurd12b42

icuurd12b42

    Self Formed Sentient

  • GMC Elder
  • 18181 posts
  • Version:GM:Studio

Posted 15 November 2010 - 07:29 AM

Go ahead. There is a weird bug in it though, when no joystick is plugged in (or is is unplugged and plugged back in), the combos stop working. I've been too busy with the real world to do any programming in months.

Edited by icuurd12b42, 15 November 2010 - 07:31 AM.

  • 0

gmcbanner.pnggmcbanner_tools.png

ICU Live Tutoring Through Slack or Skype | My Tools Page follow.png

I FRANTICALLY MADE MY 18000 POST TOPIC BEFORE MIKE ANNOUNCED A DELAY...
Now I'm squirming not to hit that reply button


#5 kburkhart84

kburkhart84

    Firehammer Games

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

Posted 15 November 2010 - 07:50 AM

Go ahead. There is a weird bug in it though, when no joystick is plugged in (or is is unplugged and plugged back in), the combos stop working. I've been too busy with the real world to do any programming in months.


Sweet thanks. I'll probably just use my code, and find a way to add on to it with what you have. Watch for the kbinput extension if you are interested. I'm going to have a few things added to it soon enough, and this combo system may or may not be included, though it will likely be added in the future in some form.

Thanks again.
  • 0

My KBInput system is now on the marketplace here.  It wraps up nice and tight GMStudio's input system into a few function calls making a user configurable input system that works the same regardless of what inputs the player has chosen including keyboard, mouse buttons, and gamepad/joysticks using DInput/XInput.  The support forum topic for it is here.


#6 icuurd12b42

icuurd12b42

    Self Formed Sentient

  • GMC Elder
  • 18181 posts
  • Version:GM:Studio

Posted 15 November 2010 - 03:05 PM

Cool. the concept is not that hard to re-implement. simple strings concatinations and string search. Nuking the combo, or not if it accumulates. it can make you go nuts sometimes though.
  • 0

gmcbanner.pnggmcbanner_tools.png

ICU Live Tutoring Through Slack or Skype | My Tools Page follow.png

I FRANTICALLY MADE MY 18000 POST TOPIC BEFORE MIKE ANNOUNCED A DELAY...
Now I'm squirming not to hit that reply button


#7 kburkhart84

kburkhart84

    Firehammer Games

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

Posted 16 November 2010 - 07:25 AM

Cool. the concept is not that hard to re-implement. simple strings concatinations and string search. Nuking the combo, or not if it accumulates. it can make you go nuts sometimes though.


I haven't looked that hard at it, but I'm already wanting to go nuts. It seems like for something so simple, you made it really complex. I don't know if it will be worth it to me to really unravel it or maybe just roll my own. Atleast I can say for sure this provided me with something I should put into my extension, considering this combo thing hadn't occured to me before. Also, I may use your key to str in my extension. I have something similar, but not near as extensive. My extension is really meant for creating the ability for the player to use custom controls, and they may very well have keyboards with media keys, and may want to use them, so I guess I would be better off adding them to my strings so that they can see what they are doing.

The part that also seems complex for me to try to use your code is that my extension puts joysticks and keyboard all together, even having a single joystick axis work as two buttons if the player so configures his controls. Your code has the keyboard and the joysticks separate. If/when I implement combos in my extension, it will have to work regardless of what the player has set up. For example, they may want the punch button on the mouse, and the jump button to be the space bar. With my extension, you can easily do that, even between joysticks and keyboards, so combos have to be able to do the same thing. Some eccentric players use the keyboard for buttons, but use the joystick axes for fine controlled movement. My extension at this point allows that with no issues, so the combo thing would have to work in the same manner, with whatever the player has set up. Instead of it being "AABB", it would be PUNCH, PUNCH, JUMP, KICK, you know what I mean?

EDIT** Something else just occured to me that makes it even more complex. What happens if you have two players on the same computer?? My extension wouldn't care about that, but as far as making combos, the players would interfere with each other. I would also have to allow some kind of "grouping" in order to let each player make their own combos. You code would work for that, assuming that one player is on a joystick, and the other on the keyboard, but how would you handle if they both were on the keyboard, say one on WSAD and the other on the arrows??

Edited by kburkhart84, 16 November 2010 - 07:28 AM.

  • 0

My KBInput system is now on the marketplace here.  It wraps up nice and tight GMStudio's input system into a few function calls making a user configurable input system that works the same regardless of what inputs the player has chosen including keyboard, mouse buttons, and gamepad/joysticks using DInput/XInput.  The support forum topic for it is here.


#8 icuurd12b42

icuurd12b42

    Self Formed Sentient

  • GMC Elder
  • 18181 posts
  • Version:GM:Studio

Posted 16 November 2010 - 09:18 PM

Complexity is the nature of adding features...

Basic concept. an array, large enough to hold the state for all the keys.
Looping trough and calling keyboard_check_direct (so all the mouse button, keys and media buttons are supported)
State changes from press, held, released

The combo is just a string. Hit A 4 times, it will hold AAAA. You can add your own codes in the string. "<BUT1>" for example.

>> Instead of it being "AABB", it would be PUNCH, PUNCH, JUMP, KICK, you know what I mean?

Yes. Like you can put BUT1 in there already.

Support 2 players, it's useless, unless there are 2 joysticks, it's the only way to support 2 players... It's almost impossible though the keyboard.

I suggest you concentrate on how I detect state changes to support key_check_direct and look at the combo functions. you can isolate them from the rest. It's just adding text in a sting really

Instead of looping through all the possible keys. You can make the array smaller to only check the keys used by the game. For 2 players, you can have a button array, supporting the mouse and keyboard and a joystick array. Have your own code to detect the button and add "PUNCH" in the combo string.
  • 0

gmcbanner.pnggmcbanner_tools.png

ICU Live Tutoring Through Slack or Skype | My Tools Page follow.png

I FRANTICALLY MADE MY 18000 POST TOPIC BEFORE MIKE ANNOUNCED A DELAY...
Now I'm squirming not to hit that reply button


#9 kburkhart84

kburkhart84

    Firehammer Games

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

Posted 16 November 2010 - 11:50 PM

Complexity is the nature of adding features...

Basic concept. an array, large enough to hold the state for all the keys.
Looping trough and calling keyboard_check_direct (so all the mouse button, keys and media buttons are supported)
State changes from press, held, released

The combo is just a string. Hit A 4 times, it will hold AAAA. You can add your own codes in the string. "<BUT1>" for example.

>> Instead of it being "AABB", it would be PUNCH, PUNCH, JUMP, KICK, you know what I mean?

Yes. Like you can put BUT1 in there already.

Support 2 players, it's useless, unless there are 2 joysticks, it's the only way to support 2 players... It's almost impossible though the keyboard.

I suggest you concentrate on how I detect state changes to support key_check_direct and look at the combo functions. you can isolate them from the rest. It's just adding text in a sting really

Instead of looping through all the possible keys. You can make the array smaller to only check the keys used by the game. For 2 players, you can have a button array, supporting the mouse and keyboard and a joystick array. Have your own code to detect the button and add "PUNCH" in the combo string.


Yes, it's the concept I was looking for. It just seems like you have alot of scripts for something that seems like it would be more simple. That's what I was getting at. As far as complex goes, my scripts are very much that. The one that waits for the player to hit a button is pretty long, because it checks both joysticks, keyboard and mouse, and also assuming it is button requested, can check each axis as if they were buttons. It makes for a long script I wouldn't want to have to rewrite.

About the string, I don't think I need to put the actual words in there, rather I would need to simply put numbers, that refer to the action number. The difference will be that I have to put a separator, comma, period, probably anything I want, since you can most likely have more than 10 actions. This would be better than doing it as actual names for the actions.

About multiplayer, I have seen a few(very) where you could both use the keyboard. More common is where one there is atleast one joystick. My extension works either way, though I can't control if the keyboard hardware is not capable of doing the keypresses due to the sensors. I don't remember what they are called, but most cheap keyboards can only pick up a certain amount of keys at the same time. It isn't the actual amount, rather how the keys are grouped on the sensors. My other issue will be having to have the capability to have two different strings, one per player. My solution is probably to have a dynamic amount of "combo detectors" which have a limited amount of keys they check. Then, they only iterate checking for the "allowed" actions to put in the combo.

Something else I was also thinking. It may be that a lot of what your scripts are doing, my scripts already do, just a little differently. For example, I already check all of the keys/buttons, but only the ones that are actually set to actions. I also have a thing it checks if the key is just pressed or being held. It would likely be trivial to add a script that checks for how long the key has actually been held down. Then with the combos, it would be set where you could say how long the key had to be held(min and max), like in some fighting games where you had to charge a direction and then press the other direction with an attack key to pull the special move. It could also be useful even without combos in use, for example in Megaman or Metroid games, you can see how long the key has actually been held down and display an animation accordingly. I'm glad you gave me that idea.

Thanks for your help. I think the only code from your scripts I will likely use would be the key values from the keytostr script. I just need the values and strings for the media keys. I'm pretty sure my scripts already use keyboard_direct() so can pick them up just fine, but since I don't have strings related to them, that function wouldn't be able to return anything, and for the moment just returns "unknown".

Thanks for the help!!!
  • 0

My KBInput system is now on the marketplace here.  It wraps up nice and tight GMStudio's input system into a few function calls making a user configurable input system that works the same regardless of what inputs the player has chosen including keyboard, mouse buttons, and gamepad/joysticks using DInput/XInput.  The support forum topic for it is here.


#10 icuurd12b42

icuurd12b42

    Self Formed Sentient

  • GMC Elder
  • 18181 posts
  • Version:GM:Studio

Posted 17 November 2010 - 01:47 AM

My check is not too complicated since I use keyboard_check_direct which allows both mouse and keyboard checking.

You can use characters, or text or tags... AAA or PUNCHPUNCHPUNCH or <A><A><A>. I think I initialy had a delimiter in it but found it was not needed. I think adding the <> to separate the codes would be a wize idea.

Keyheld status in my code is defined as keyaboard state array value >0... where as 0 is not pressed 1 is just down, then it increases, the number matches the number of steps held, the transition from count to 0 is the key released trigger, where you could sneek in, in the release detection, at the amount of time held, to see if it's in the range. The you could add <PP> or <POWERPUNCH> to the combo there.

Yes, if you would design a game to use only keyboard tapping. you could possibly have better 2 player support. Combo system would come in handy. You would need to use 2 different array. Like I mentioned. or a means to segregate the 2 player info.

Took me a while to convert that Microsoft List of named keyboard keys. It's fun that GM has a function compatible with those.
  • 0

gmcbanner.pnggmcbanner_tools.png

ICU Live Tutoring Through Slack or Skype | My Tools Page follow.png

I FRANTICALLY MADE MY 18000 POST TOPIC BEFORE MIKE ANNOUNCED A DELAY...
Now I'm squirming not to hit that reply button


#11 kburkhart84

kburkhart84

    Firehammer Games

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

Posted 17 November 2010 - 03:17 AM

My check is not too complicated since I use keyboard_check_direct which allows both mouse and keyboard checking.

You can use characters, or text or tags... AAA or PUNCHPUNCHPUNCH or <A><A><A>. I think I initialy had a delimiter in it but found it was not needed. I think adding the <> to separate the codes would be a wize idea.

Keyheld status in my code is defined as keyaboard state array value >0... where as 0 is not pressed 1 is just down, then it increases, the number matches the number of steps held, the transition from count to 0 is the key released trigger, where you could sneek in, in the release detection, at the amount of time held, to see if it's in the range. The you could add <PP> or <POWERPUNCH> to the combo there.

Yes, if you would design a game to use only keyboard tapping. you could possibly have better 2 player support. Combo system would come in handy. You would need to use 2 different array. Like I mentioned. or a means to segregate the 2 player info.

Took me a while to convert that Microsoft List of named keyboard keys. It's fun that GM has a function compatible with those.


"delimiter" was the word I was looking for when I mentioned it above, but I had forgotten what it was. In my case, for my extension, I would HAVE to have the delimiters, because in order to keep my extension useful for all games needing it, the string would simply be numbers, corresponding to the actions. So if I'm using generic numbers, than anything above 9 would start working like 1,0 instead of "10", making delimiters mandatory, atleast in my case.

Since I already have easy detection of whatever key/button my actions are set too, I don't think I have to worry about making a game only keyboard. And the more I think about it, the more I feel that I'm going to end up with dynamic amounts of combo detectors, with a limited amount of actions each one can pick up on.
  • 0

My KBInput system is now on the marketplace here.  It wraps up nice and tight GMStudio's input system into a few function calls making a user configurable input system that works the same regardless of what inputs the player has chosen including keyboard, mouse buttons, and gamepad/joysticks using DInput/XInput.  The support forum topic for it is here.


#12 Byzantium

Byzantium

    GMC Member

  • New Member
  • 20 posts

Posted 13 July 2011 - 08:11 PM

Just posting to say thanks for the awesome scripts. I've found your solutions to be the most elegant for working with the persnickety keys that do everything they can to rebel against your plans for them (my hunt for an extension like this began when I decided to use Tab in my game). Your way of handling key presses should be the default for Game Maker, in my opinion.
  • 0