Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Reconfigure Keyboard Input

Author
Message
7RS
11
Years of Service
User Offline
Joined: 10th May 2012
Location:
Posted: 14th Aug 2012 16:29
Hi,
our game should run on Mac too and we think the assigned keys of the virtual buttons and joystick are not so friendly, someone wrote a configurable menu ? there is a easy and quick way to do it ?

Thanks.
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 14th Aug 2012 16:42
The virtual buttons and joystick can be manipulated using the mouse on the Mac. There is no need to use the keyboard.

Cheers,
Ancient Lady
AGK Community Tester
erebusman
12
Years of Service
User Offline
Joined: 23rd Jul 2011
Location: Sacramento, CA
Posted: 14th Aug 2012 17:05
I'd have to hold the opposite opinion myself from Ancient Lady:

If your gaming on a Mac or PC there's always a need to use the keyboard -- its one of the two primary input methods.

What if you had to type your name for a high score? Should you click with the mouse 31 times or type your name on the keyboard?

What if your game is a racer or shooter? Should you click the left arrow on the mouse, then the right arrow and barely be able to control the vehicle? Or should you use the WASD to drive & steer and the mouse to fire?

However I don't know the answer to your question at the moment 7RS -- I may figure it out soon as I'll be putting in High Score screen soon where the user has to type their name and I want it to work on Windows/Mac as well as iOS.


I assume a combination of GetLastChar and AddVirtualButton may do the trick? Map the char pressed to the virtual button so if a person pressed that character on their keyboard it would trigger the virtual button right?
7RS
11
Years of Service
User Offline
Joined: 10th May 2012
Location:
Posted: 14th Aug 2012 17:11
We won't use mouse, the game must work with keyboard and the joystick is not the solution. At the moment when you run the game it use automatically wasd to move in the 4 directions and space, ctrl, e, r, q for the buttons.

We must offer to the players under Windows and Mac to reconfigure their buttons if they haven't a joypad installed.

Play the game with e,r,q, is really difficult if you also have really near the other things like wasd and also the ctrl on Mac is not good.
Rich Dersheimer
AGK Developer
14
Years of Service
User Offline
Joined: 1st Jul 2009
Location: Inside the box
Posted: 14th Aug 2012 18:32
Well, if you are writing the program code, you have total control of what keys do what actions. Just change the code.

You also have commands like GetKeyboardExist() and GetMouseExist() to decide what input scheme you will use for the current device/player.

And GetDeviceName() so you can determine what platform the player is using.

Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 14th Aug 2012 18:54
@erebusbman, I meant there is no need to use the keyboard for navigation done by the virtual joystick or for clicking on virtual buttons.

Certainly you want to use the keyboard for input, that wasn't the question (as I understood it) posed by 7RS.

Quote: "We must offer to the players under Windows and Mac to reconfigure their buttons if they haven't a joypad installed."

It was not clear that you were looking for a solution for when there wasn't a physical device connected to the Mac or Windows box.

Rich is correct, you can programmatically check for what the user is using and set up your own keys for different actions.

Cheers,
Ancient Lady
AGK Community Tester
DVader
20
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 14th Aug 2012 21:10 Edited at: 14th Aug 2012 21:14
I would have thought that the keyboard entry commands default to the appropriate device. So for PC it defaults to the keyboard and on android it defaults to the virtual keyboard. Is this not the same for Mac? Also if you have a joystick or pad connected to your PC, the joystick commands use that, if not it uses a virtual one. I would have thought it would work the same on Mac, but I can only guess of course, not owning one.

Edit - Actually the PC defaults down to the awsd keys when no joystick is found, rather than the virtual one.

Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 14th Aug 2012 22:01
In order to use the virtual joystick, you have to actually program it in. There is nothing that makes it appear magically.

7RS doesn't want to use the virtual joystick (and I agree with that).

Personally, I do not like the virtual joystick. Especially on a small device like the iPhone or iPod Touch).

But I don't think you'll find any commands that let you 'talk' to a Joypad (or Gamepad) in AGK. Certainly you won't be able to connect to the Joypad iPhone app.

AGK has commands for simple joysticks (the old fashioned kind). But I don't think they'll support the fancier joypad/gamepad devices.

Cheers,
Ancient Lady
AGK Community Tester
7RS
11
Years of Service
User Offline
Joined: 10th May 2012
Location:
Posted: 15th Aug 2012 13:03
Yeah,
we want to release the game 1st on Mac because we think the actual joystick support of agk isn't the best, our game isn't so special but we feel we need a better joystick to do not make players hate the controls.
We are trying to make our own or to found a different solution.
DVader
20
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 15th Aug 2012 15:17
Quote: "In order to use the virtual joystick, you have to actually program it in. There is nothing that makes it appear magically."


Really? I have been using AppGameKit since it's launch. Believe me, it does.

That code will work with AWSD keys on the PC, unless you have a joystick plugged in (it CAN detect real new joypads, I am not sure what you mean by "fancy"). On mobile devices it will automatically generate a virtual joystick. You really need to check things out a little before you make statements that sound so definite. It was designed that way to make it easier to make multi platform games. It just happens most people don't use it that way, which always seemed odd to me as it makes early testing far easier.

7RS mentions he wants to release on Mac, not iphone or any other device specifically. Only Mac. Perhaps by Mac he means all Apple devices, but if so it is not clear. On Mac or PC who would want to use a virtual joystick? You would use keys or a real joystick. All the options are available. I do not see a problem.
Also it is possible to change how the virtual joystick responds, but obviously a virtual non tactile joystick is never going to be as good as a real one.

Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 15th Aug 2012 16:46
DVader, I meant the virtual joystick that gets displayed on the game. That funky ball in a circle thingy.

I know that if you use the joystick commands with no joystick, it goes to the keyboard. That is not the virtual joystick. It is an emulation, like using the arrow keys for the accelerometer.

I haven't played with the joystick commands, so I wasn't aware that it automagically popped one up on mobile devices. You are correct about absolute statements. I finally found something in the documentation that says it will create a virtual one if there is no keyboard or physical joystick. I usually do a bit more research before I make an absolute declaration and I failed to do so this time.

From what I've seen of the joypads, they have way more than the 5 buttons supported by the joystick commands. That is why I didn't think they'd be supported.

The Joypad app I was talking about would be used to make an iPhone act like a joypad when talking to a Mac (or iPad).

7RS doesn't want to use the virtual joystick, he just wants to be able to not be forced into using the default keys assigned for the keyboard-pseudo-joystick when there is no physical joystick and he uses the joystick commands.

The problem is that if the game is designed for a joystick (or joypad), and he sticks with only those inputs, he cannot change the key assignments.

If 7RS modifies the code to detect a joystick and sets a flag, the flag can be used to decide to get the movements from specified keys instead of the joystick. Then he could assign whatever keys are recognized. I think the GetRawLastKey and GetRawKeyPressed commands work with the ASCII character set (they are limited to 0 to 255) and not the actual scan codes produced by the keyboard. So, all he needs is a table with the ASCII character set.

Cheers,
Ancient Lady
AGK Community Tester
7RS
11
Years of Service
User Offline
Joined: 10th May 2012
Location:
Posted: 15th Aug 2012 20:30
The raw key pressed is what we are using, i was just curious if someone has a table, array, of all scancodes with text already written. In the documentation there are some but i'm not sure if that are all or the only one supported by AppGameKit, for example left and right SHIFT or CTRL should have a different code but in the list there is just 1.

Anyway is better to leave a bit more details about our game.

The game has been thought to work in a single screen, is an action puzzle, you can move left and right and you will have 3 buttons, 1 for jump and other 2 for standard actions. If you collect some special items you will have an extra button appear on the screen.

We have more than 100 levels already made and we are testing the game to see how it work and if all levels can be solved well.

At the beginning we have designed the game for in-app but AppGameKit for now doesn't support in-app and we have modified something of the design and choose to release the game on Mac OS before move to mobile devices.

For sure on Mac OS we need a button configuration because we must offer to the players a way to choose their preferred keys to play.

We are also testing it on iOS and to be honest the virtual joystick is not so well. Maybe it depend on the way it has been designed or maybe also because it is always an analog but in any case it doesn't give us a good feedback. Changing the deadzone you can improve it but it still isn't well enough. A digital version of it would be nice to have, maybe we will try to make our own, i'm not sure.

At the moment the game look a bit different between Mac OS and iOS due to the joystick respond, with the keyboard is much better to play and more funny.

As soon as i can leave some screen or more info about the game i will do in the gallery.
DVader
20
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 15th Aug 2012 20:59
I just don't like being told something is not possible when I know 100% certain it is. Still, you have learned something new from it, so my posting today has served some purpose. Also my point was the joystick command will drop down and check from real pad to virtual and then keyboard emulation. So the virtual joystick is not needed, and does not need to be created if you do not want to.
But I still don't see the problem. The joystick commands, regardless of being virtual or not, are for the joystick, dropping to keyboard is just a bonus. If you want keyboard support it is easy to add by actually checking the keys. I have several control types in Moon Snaker for instance. The only option I haven't done yet is to configure the keys, but again this would be fairly easy. Configurable keys aren't really needed for my target markets at the minute. However the PC version allows the use of wasd keys or the arrow keys or, of course joystick.

The raw entry commands are the ones needed as you say. 7RS, you really should get reading the documentation for this stuff. With the GetRawLastKey( ) command I imagine it would be simple enough to actually be able to configure the keys. I can't imagine there are no examples for keyboard input in the help files. Also, complaining about the virtual joystick, when you are wanting keyboard control is rather misleading.

An easy way to see the codes for each key is simply



Obviously instead of just printing them you could have a control setup where you press the keys needed and record the code each time like in many PC games.

Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 15th Aug 2012 21:14
For the basic ascii characters try http://www.asciitable.com

You can only use the first table, values 0 to 255.

As far as I can tell from the documentation, there is no way to tell if the control, shift or alt keys have been pressed.

As best as I can tell, AppGameKit does NOT use keyboard scan codes at all. The few keyboard functions work solely in ASCII character code terms.

Cheers,
Ancient Lady
AGK Community Tester
Rich Dersheimer
AGK Developer
14
Years of Service
User Offline
Joined: 1st Jul 2009
Location: Inside the box
Posted: 15th Aug 2012 21:47 Edited at: 15th Aug 2012 21:48
Or, if you own AppGameKit, you can check the help files...

C:\Program Files\The Game Creators\AGK\IDE\Help\guides\scancodes.htm

and get a list of the return for each key press. It's not complete, and that little code loop above works very well.

The help files are online somewhere as well, and there used to be a sticky before the forum got improved. Not sure where they are now.

Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 15th Aug 2012 21:57 Edited at: 15th Aug 2012 22:11
Yup, you could use that page (and get much better information than I gave).

I never noticed that one hiding at the bottom of the guides. Thanks!

EDIT: It shows value 116 as F5 and that is the ascii value for lowercase W!

I guess they are using some sort of internal translations to indicate different things.

The scan codes apparently returned by the key functions have almost nothing to do with ASCII character codes. Many of the characters are moved away from their ASCII positions and there is no allowance for lower/uppercase letters. I guess the assumption is that you assume lower case and check for the shift key being pressed first.

Oh well, they have a page defined for the key codes they use, that is the important thing.

Cheers,
Ancient Lady
AGK Community Tester
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 15th Aug 2012 22:24
Here is a simple program (Tier 1) to show what the keys return:


This works fine on a Windows PC.

I tried to run on my Mac (using a project that used to work) and got the message "The run destination for My Mac 64-bitins not valid for Running the scheme 'agk_interpreter'". My Xcode is version 4.4.1. Go figure.

Cheers,
Ancient Lady
AGK Community Tester
Rich Dersheimer
AGK Developer
14
Years of Service
User Offline
Joined: 1st Jul 2009
Location: Inside the box
Posted: 15th Aug 2012 22:32 Edited at: 15th Aug 2012 22:47
And here's a method for checking if any particular key is being held down, so you can pick up a shift-Up Arrow, or a CTRL-whatever.



Etc., etc., for any key combinations you like, with the possible caveat that some (most?) keyboards have a limit to how many different keys will be reported at one time. Similar to many fine discussions on the DBPro boards about keyboard input.

So, if you were using only devices with keyboards, checking the keystate would be a good way to do thrust, turn and fire all at the same time.

DVader
20
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 16th Aug 2012 00:04
@ Rich, yes the help files are always a good bet, as I have mentioned a few times already The first thing I did when getting AppGameKit was to go to the command files and start reading. There are not many I have not read up on, apart from ones I have never had any need to use. So I am fairly conversant on most tier one stuff, although I regularly use F1 to remind myself of the different flags to use. I also either use something like the code I posted above, or the help file reference page for key states.
@ Ancient Lady, I have used DB and DB Pro since they were released, and am used to the keystate style that both use, including AppGameKit also. Coming from other programming languages, I can understand why you would think of ASCII codes. You are correct in that they have nothing at all to do with each other. The only ASCII command in AppGameKit to my knowledge is Asc( string$ ). That will convert the value you set in string$ to it's ASCII value. The code you post above gives the string of the ASCII value you are inputting I believe. I haven't really looked into trying to use ASCII codes for key presses in AppGameKit, although I used it in DB a few times.

Rich Dersheimer
AGK Developer
14
Years of Service
User Offline
Joined: 1st Jul 2009
Location: Inside the box
Posted: 16th Aug 2012 00:15 Edited at: 16th Aug 2012 00:15
@DVader, that somewhat sarcastic referral to the help files wasn't directed at ya, just to everyone in general.

In those good old days before AppGameKit, a few different folks posted charts for the keystate codes in DBPro. Here's one...



Note that this is NOT the same thing as scan codes for AppGameKit! Just a nostalgic look back. I miss DBPro sometimes, so I do go back and work in it every now and then.

Attachments

Login to view attachments
Paul Johnston
TGC Developer
21
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 16th Aug 2012 00:29
When I was working on the key state commands I discovered that the platforms we were supporting with full keyboards (Windows, Mac, Meego) all had different sets of codes and different distinctions between keys. Mac for example doesn't have a number pad on its wireless keyboard. So I attempted to find as many common keys as possible and map then to a single set of scan codes which has become the AppGameKit scan codes. They can also be found here http://www.appgamekit.com/documentation/guides/scancodes.htm
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 16th Aug 2012 16:17
I had assumed that ASCII was what the key commands returned because that is what is used in the font image files. And you know what they say about the word 'assume'.

I also used the key code commands in DBPro and Dark GDK, but haven't worked with them for a while.

I used to do a lot of work with keyboard scan codes at the bios level (assembly language) and in Turbo Pascal and in various versions of PC basic.

And then they started making many different keyboards and the scan codes were not the same. And, as Paul said, the different platforms use different schemes. I'm glad they (TGC) were able to extract the important keys so that there is consistent behavior across platforms.

@DVader, I finally took down the keyboard scan code chart off my wall about 8 months ago (no kidding). I still have my second edition The Programmer's PC Sourcebook. It was invaluable doing low level assembly programming and still has some useful tables. Although, I don't think there's much need for the Floppy Disk Format Summary table anymore. Or the VGA Memory Maps. Or the Hayes Modem Response Codes (boy does that one bring back memories).

Cheers,
Ancient Lady
AGK Community Tester
Paul Johnston
TGC Developer
21
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 16th Aug 2012 22:43
Quote: "I had assumed that ASCII was what the key commands returned because that is what is used in the font image files"


Thankfully each platform also provides and ASCII key down event, in Windows it is called WM_CHAR whilst the key down is WM_KEYDOWN, the former handles things like capital letters automatically, whilst the latter includes modifier keys such as shift, tab, esc, etc, and it's just these raw key down events that need the scan codes.
7RS
11
Years of Service
User Offline
Joined: 10th May 2012
Location:
Posted: 20th Aug 2012 17:04
Hi,

i'm still trying to create my button config screen, there are some problem because when i ask the player to press any key unfortunately there isn't a function that return just if an any key has been pressed. Following the doc

"Returns the key code of the last key pressed. This only applies to platforms with a full sized keybboard such as PC and Mac. You can check if a keyboard exists by using GetKeyboardExists. This function continue to return the last key pressed even when the key has been released."

so if i check the last key i will get a value in any case and this doesn't work like i expect.

There is something that give me a value if any of they key has been pressed ? If i use the GetRawKeyPressed i need to pass a value but i don't know the value yet because i'm waiting the user press a key. How i can emulate or check a key pressure like the pointer pressure ? I need to know if a key has been pressed and after i will check what is the value.
Funnell7
12
Years of Service
User Offline
Joined: 8th Sep 2011
Location: UK, England
Posted: 20th Aug 2012 18:03
Probably not very elegant but could you not do something like this;



I don't know much about Scan Codes/Ascii but I just used 0 - 255 as that covers most keys (I think), you could change this to what ever is relevant...
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 20th Aug 2012 18:20 Edited at: 20th Aug 2012 18:22
There is an AppGameKit document page (http://www.appgamekit.com/documentation/guides/scancodes.htm) that shows the scan codes for the keys. It is NOT ascii (as we've discovered). Nor is it the actual scan codes from the keyboards (which differ a lot across platform and keyboard).

But your basic idea is probably about what works. The gotchas are in catching the ctrl/alt/shift key and then the actual letter/number/function key pressed right after it.

Cheers,
Ancient Lady
AGK Community Tester
7RS
11
Years of Service
User Offline
Joined: 10th May 2012
Location:
Posted: 21st Aug 2012 16:28
Hi,
i found another way, the problem is only to clear the LastKey, at the beginning of my class i copy the lastkey to a variable and i check if the new pressure is different from that variable. It work fine except if your new pressure is exactly of the value stored at the beginning.

Now the keyconfig work fine except for this small thing, anyway maybe could be good if the agk team give a way to have the keypressed and to clear the lastkey value.
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 21st Aug 2012 16:56
You can add the request for new commands on the google issue board (make sure to add 'New Command Request' somewhere in the title so that it is not considered a bug).

This is a link: http://code.google.com/p/agk/issues/list?can=2&q=&sort=-id

Cheers,
Ancient Lady
AGK Community Tester
7RS
11
Years of Service
User Offline
Joined: 10th May 2012
Location:
Posted: 22nd Aug 2012 17:06
Ancient Lady, thanks, i left a request.
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 22nd Aug 2012 19:14
Looks good. I might add to it to make sure that the intent is clear to the developers. Thank you for starting the process.

Cheers,
Ancient Lady
AGK Community Tester
AgentSam
12
Years of Service
User Offline
Joined: 14th Mar 2012
Location: Virtual Space
Posted: 23rd Aug 2012 09:17 Edited at: 23rd Aug 2012 19:21
Hi, 7RS.

This "any key" problem for your keyconfig interested me, so I decided to give it a try.

Please check to see if the function included in the following code snippet would work for you.

The code includes a small main program with some sample usage, so it should be easy to test via copy/paste/compile/run.



Cheers,
AgenTsam

[EDIT: Fixed a typo in the message, and a comment in the code. ]
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 23rd Aug 2012 16:11
AgentSam, that looks like a good function.

Cheers,
Ancient Lady
AGK Community Tester
7RS
11
Years of Service
User Offline
Joined: 10th May 2012
Location:
Posted: 23rd Aug 2012 20:57
@AgentSam
Thanks, i will convert in T2 and test if can work better than the way i have used but maybe yes

Thanks.

Login to post a reply

Server time is: 2024-05-02 14:42:11
Your offset time is: 2024-05-02 14:42:11