Jump to content
A 2021 backup has been restored. Forums are closed and work in progress. Join our Discord server for more updates! ×
SoaH City Message Board

MMF2 Controller/Joypad example?


Strife

Recommended Posts

Since my game requires more buttons than the default MMF2 Player object will allow, I must move on to using extensions. Ideally, I would like the player to be able to select their input device (keyboard, joypad, etc) and map different keys/buttons to each action. I only know how to do this smoothly with the keyboard, though, since I have no joypad to test things with.

Has anyone here successfully made a Configure Keys menu in MMF2 that I can adopt, preferably with as few extensions as possible? In addition, is there a program out there that would allow me to simulate joypad button presses? (Similar to Joy2Key, but in reverse.)

Link to comment
Share on other sites

I would use Control X from the z33z extensions pack.

This extension is quite versatile, you can easily make a control config screen with it. Aside from that, it can be used as your input interpreter. Instead of hard-coding to "Player pressed PgDn", you store the assigned key values in some array or global value set and use "Player pressed <JumpBtn>", where JumpBtn would be an expression to retrieve the keycode.

Keycodes are the "names" Control X gives to the keys. For example space is 32.

I have a small application that lets you edit controls and saves them to a file. However, it's just a config application, so there's no game element to try it out. Lemme modify it a bit and I'll upload.

EDIT: Done. It uses an ini file for storage. It also shows how it saves a few config settings such as screen size, and "option A/B" (they were autosave and auto-switch in my original game, the ini names reflect this). It's kinda like blazehedgehog's config programs.

To set controls simply click a button and press the desired key. It doesn't check for key conflicts (you can easily add that using a fast loop to check all the other buttons and abort if it finds a conflict), and I added a small "game" frame with a minimal static engine you can control by using the four D-keys you configure. Try it out, change your config and head to the "game" screen.

NOTE: To save the configuration you edited, click the OK button in the upper right corner. If you just close or hit Cancel, the ini won't be saved.

In detail, this uses a subapplication for the "press button" dialog, and control X handles input. If you check the events that handle the storage and whatever, you'll see a lot of the alterable value "Step" in a BG object. There are some "holes" left over by encryption code I removed, since it was using an outdated extension for that. Aside from that, this "step" system allows me to debug easily. :]

You can easily make a text-based config screen instead of the buttons screen I use. And one more thing: Notice how the buttons hold the names (not keycodes) of the keys you hit? Control X lets you "translate" keycodes to strings, check the event that sets the button text. It's more practical to use keycodes when you're making your engine control events, though.

--------------------------------------------------------

I don't think Control X handles joypads.

There must be an extension allowing you to read the 8-12 buttons that joypads usually provide. Maybe fusionwiki has something in the list: http://www.fusionwiki.com/wiki/Extensions

There's a "Key object" that has a few more things than control X, such as unfocused reading and it can read the inbuilt player controls too. I'm sure this one will also work.

EDIT: Bingo, the Joypad object from the same pack should do the job.

I guess you can use OR to create your control events, like this:

//&lt;values&gt; stand for the values stored in the ini or whatever
*Control X object &gt; Key &lt;Jump&gt; pressed
*OR
*Joypad object &gt; Button number &lt;JoyStkJump&gt; pressed
---+(something)

controlapp.zip

  • Like 1
Link to comment
Share on other sites

For my input manager system (which has worked its way in the highly delayed 1.3 build of Delta), I used ControlX for keyboard as gsoft mentioned, and Joystick2 for controller devices. Joystick2 is very versatile and even includes force feedback support, but there are rare cases when it fails to detect a controller. In this case I used Joypad as a fallback. The reason I use both extensions is because the Joypad extension will introduce lag that seems to multiply based on how many input devices you have connected to your computer... so if your device recognizes Joystick2, it's best to use that.

About the reverse of Joy2Key, PPJoy may do the trick, but it is a pain to install on Windows 7 x64.

Link to comment
Share on other sites

Thanks for the advice, folks. ^_^ Regardless of what input device I use, maybe I can have the player's input keys run fastloops, so that "Player 1 pressed Fire 1" would become "On loop "fire1"".

I've used ControlX and Joypad before, but I never knew about Joypad lagging up the game (which makes sense since I have no joypads to test with xD). Kindof a bummer that Joystick2 can fail sometimes as well.

As for PPJoy, is it easier to instead on a 32-bit Windows 7 system? Regardless, I'll see if I can check that out.

Link to comment
Share on other sites

Just try different things. You could make some basic "move object around" application with the configuration screen (feel free to use the one I attached above), and use a variable to set the "game" to either keyboard mode, or joypad mode, so you can deactivate unneeded events.

Then, try sending it to some people and ask them to try out their joypads.

Also, always keep in the application menu an option to reset to keyboard mode (to prevent problems when accidentally unplugging the pad.)

Link to comment
Share on other sites

As for PPJoy, is it easier to instead on a 32-bit Windows 7 system? Regardless, I'll see if I can check that out.

I believe x86 versions of Vista and Windows 7 don't have the same problem of the OS forcing driver signing, but things may be different now. If your OS demands a driver signature, then the alternative is to test sign it in test mode so you can run it anyway.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...