• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!
  • Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

Discussion Virtual Key Issues

Ax209

Member
Hey everyone, not sure if this is something I can work around or what, or even if it's specific to GMS2 but perhaps someone's encountered this before.
I made a game with virtual keys. Because there are so many, I created them when the applicable windows opened, and destroyed them when they closed, so I didn't continue to create an infinite amount of virtual keys by constantly clicking on the window. The ones needed were created and then destroyed with the window.

It worked perfectly but now once the windows have been open too many times, they stop responding. After troubleshooting and seeing that the ACTUAL KEYS themselves work, just not when i click on them with the mouse, I had a look online.

It seems that you can only have 128 virtual keys before the game creates an error. Now, I don't have that many, because I destroy them when the window closes. However, it seems to stop registering them by the same point. I do have a "virtual_key_show" code and when the window opens, you can see the box where the key "is", but I can't click on it with the mouse.

Is this a GMS2 error? Does anyone know a way around this?

Many thanks
 

Nocturne

Friendly Tyrant
Forum Staff
Admin
Could you please show the code (and events) you have setting up and destroying the keys?
 

Ax209

Member
Yeah, so this would be contained into a single object. For example "obj_staffwindow". Here'e the code (I'll just give a couple of examples, not all 10 buttons).

CREATE EVENT

global.vkp=virtual_key_add(96,50,128,128,ord("P"))
global.vko=virtual_key_add(96,50,128,128,ord("O"))

//this above works fine. Creates the keys and they work.

DESTROY EVENT

virtual_key_delete(global.vkp)
virtual_key_delete(global.vko)



//so as I said, it all works okay, and when I i add "virtual_key_show" to the create event, it shows on screen the keys being where they should be, and disappearing when they're supposed to. They even show when they're being unresponsive, which is why I tried pressing P and O keys on the keyboard, which work fine. It's literally just the mouse click that doesn't work after so long....
 

Nocturne

Friendly Tyrant
Forum Staff
Admin
Have you tested in GMS1.4 to see if the same behaviour exists? It does sound like a bug... Have you watched the memory usage to see if there is a leak somewhere? I'd say file a bug, anyway, and if you have a demo program that shows the issue, add a link to download it to the bug report too.
 

Ax209

Member
I havn't tested in GMS1.4, I didn't think the file could go backwards. I've checked the memory, it's all fine, I had a look when I was using the keyboard keys instead (thought it had maybe crashed at first). Pardon my ignorance, but where do I file a bug? I'll get uploading now when, as it's 100Mb, it might take a while :( hahaha.

Thanks for your help, friendly tyrant!
 
P

PhenomenalDev

Guest
Ax8472 might wanna delete repeats from when it crashed multiple times maybe? xD
 

Nocturne

Friendly Tyrant
Forum Staff
Admin
Okay, so, you can't go backwards from 2.0 to 1.4... all I meant was recreate the code in 1.4 and see what happens... As for filing a bug, go here: https://account.yoyogames.com/login?path=/report-bug If you are suplying a link to a game file and you don't want it to be made public, then please mention that in the report and it will be flagged as private.
 

Ax209

Member
Sorry to dig this old thing up again.

I reported this issue a while back, as a bug. I didn't get any sort of reference number or anything, and I checked both my email inboxes and spam folders, but I can't see anything from Yoyo games.

Is there any way it can be traced? I checked the new GMS2 update and the problem persists. Might move back to 1.4. Can anyone advise on how I find whether the report went through at all?
 

Ax209

Member
Thanks Russell. It's asking me to log in before I can view the bug. I've tried my Yoyogames forums credentials but having no success. Nor can I seem to sign up. Would it be rude to ask you to copy and paste the answer for me into here? I'm anxious to continue with my project...sorry to be a pain :)
 

rwkay

GameMaker Staff
GameMaker Dev.
Bug was

Hello.

I'm making a game where I open a certain window (obj_staffmanwindow, i've linked a copy of my game for you to see) that, in it's create event, makes some virtual keys.

global.vkp=virtual_key_create(blah blah blah P)

then at destroy event, i wrote

virtual_key_delete(global.vkp)

this is done for a fair few keys, and it works without a hitch for a few times the windows are opened, generating and then deleting the keys.

Once the windows have been opened a number of times, the virtual keys stop working. And this is the case for any virtual keys afterwards. It creates a limited number of virtual keys but then, even though they are detsroyed, the new ones don't seem to work. I can see them when I use "virtual_key_show", and they still show up, and the keyboard can still input the keys, but the virtual keys cannot be clicked on with a mouse.

I spoke on the forums and a guy called Nocturn asked me to report a bug. As I said I've included the game, you can have a mess about with it (it's still incredibly early). If you run the game, the box in the top left of the game will appear (if the chick isn't speaking to you) and you can go to those boxes. The best one to use is Staff Management as all the functionality is there. if you literally open and close the object, it will eventually create enough virtual keys to stop any virtual keys working.

the reply was

Your obj_menubutton->Key press M event is creating virtual_keys and saving them into global variables each time the panel is opened. These are not being deleted so eventually you run out of virtual keys.

In general when tracking down this sort of issue I would recommend putting in a show_debug_message before each allocation and a show_debug_message before freeing them. If you get a mismatch then you will know you are leaking virtual keys.

Hope this helps,

Fritz
 

Ax209

Member
Oh man I feel like such a tool!!!


Thanks every for the help. Gonna chip at this bad boy tomorrow night!!!!
 
Top