Is there any way to exit to the menu from a Prizm addin without manually pressing the Menu key?

I was also wondering if there is any way to block the menu key exiting the addin?
Post your main routine please - if you’re running a loop which checks sendkey code I think you should be able to check for other than menu keys and exit from the loop or make some other way for your main routine to return 0 and exit your add-in. If it is not some other than menu key press you want to exit your addin I believe just adding return 0 or anything when whatever condition is met will exit your addin.

Regarding blocking menu key one of the ways is https://prizm.cemetech.net/index.php?title=SetGetkeyToMainFunctionReturnFlag
You can go back to the main menu by injecting a key press and then triggering GetKeyWait() via syscall. The injection should happen with a timer for best results; see this bit of documentation by SimLo (in the description of 0x0248) or this implementation.

As for disabling the main menu, I believe the easiest way is simply to use GetKeyWait() again since it has a parameter for that. Smile
Lephe wrote:
You can go back to the main menu by injecting a key press and then triggering GetKeyWait() via syscall. The injection should happen with a timer for best results; see this bit of documentation by SimLo (in the description of 0x0248) or this implementation.

As for disabling the main menu, I believe the easiest way is simply to use GetKeyWait() again since it has a parameter for that. Smile

Thanks a lot!
I'll look into these.
Lephe wrote:
You can go back to the main menu by injecting a key press and then triggering GetKeyWait() via syscall. The injection should happen with a timer for best results; see this bit of documentation by SimLo (in the description of 0x0248) or this implementation.

As for disabling the main menu, I believe the easiest way is simply to use GetKeyWait() again since it has a parameter for that. Smile

I've managed to get the exiting to menu working, but I'm a bit confused with menu blocking.
It works, but I was wondering if there is any way to block MENU whilst letting the user enter text.

I'm asking because I'm working on a Lock addin that actually works on fx-CG50.
I'm not sure how you approached the problem. If you look at the documentation for GetKeyWait (0x0248 ; it's the fx-9860G one but the prototype is the same on fx-CG), you will see that the 5th parameter controls whether return-to-menu is enabled. This is independent from other keypresses; you will still be able to enter text when using this option.

(In the official fx-9860G SDK there is a GetKeyWait() function bundled with the library, but it doesn't return keycodes. The syscall must be used instead. I'm assuming you have libfxcg but in any case make sure the syscall is used.)
dr-carlos wrote:

I'm asking because I'm working on a Lock addin that actually works on fx-CG50.

I’d love to hear your feedback on my Lock addin https://www.cemetech.net/downloads/files/1212/x1212 - I believe only icons display showing which programs you opt to go to instead of the default main menu option is not showing correctly on fx-cg50 (I may have lost the source code after all those years but your feedback may make me look for it)
Lephe wrote:
I'm not sure how you approached the problem. If you look at the documentation for GetKeyWait (0x0248 ; it's the fx-9860G one but the prototype is the same on fx-CG), you will see that the 5th parameter controls whether return-to-menu is enabled. This is independent from other keypresses; you will still be able to enter text when using this option.

(In the official fx-9860G SDK there is a GetKeyWait() function bundled with the library, but it doesn't return keycodes. The syscall must be used instead. I'm assuming you have libfxcg but in any case make sure the syscall is used.)

amazonka wrote:
I’d love to hear your feedback on my Lock addin https://www.cemetech.net/downloads/files/1212/x1212 - I believe only icons display showing which programs you opt to go to instead of the default main menu option is not showing correctly on fx-cg50 (I may have lost the source code after all those years but your feedback may make me look for it)


So, I've tried a few things.
First, I tried using GetKeyWait_OS. I tried running it in KEYWAIT_HALTOFF_TIMEROFF mode, as well as doing GetKey, but this didn't work.
I also tried GetKeyWait_OS with KEYWAIT_HALTON_TIMEROFF mode, instead of GetKey, but this just produced a white screen that I could not escape.

Then, I looked at the lock extension that amazonka made.
I tried the SetGetkeyToMainFunctionReturnFlag(0), but this also didn't work.

My current code is on GitHub: https://gist.github.com/dr-carlos/12aeef1a47a4f5908d2983d356cd25b1
Quote:
I also tried GetKeyWait_OS with KEYWAIT_HALTON_TIMEROFF mode, instead of GetKey, but this just produced a white screen that I could not escape.

This is the proper mode to use. You should know that GetKey() calls Bdisp_PutDisp_DD(), so that anything you draw is automatically displayed to screen when using GetKey(). I think GetKeyWait() doesn't. Does adding Bdisp_PutDisp_DD() before GetKeyWait() show you what was invisible?

Also yes if you disable return to MENU you'll be trapped unless you code it yourself, the add-in returns, or you fall back to GetKey() somewhere for testing.
Lephe wrote:
Quote:
I also tried GetKeyWait_OS with KEYWAIT_HALTON_TIMEROFF mode, instead of GetKey, but this just produced a white screen that I could not escape.

This is the proper mode to use. You should know that GetKey() calls Bdisp_PutDisp_DD(), so that anything you draw is automatically displayed to screen when using GetKey(). I think GetKeyWait() doesn't. Does adding Bdisp_PutDisp_DD() before GetKeyWait() show you what was invisible?

Also yes if you disable return to MENU you'll be trapped unless you code it yourself, the add-in returns, or you fall back to GetKey() somewhere for testing.

Okay, I've replaced it and added the Bdisp_PutDist_DD() call, which shows the enter password input.
However, the text editing is not working and I still cannot exit the addon.
I even disabled password checking so pressing EXE or EXIT should leave the addin, but to no avail.

The code as been updated on GitHub.
When using GetKeyWait() I personally always refer to the matrix codes set in [col] and [row]. From the description, I don't think the [keycode] is set as you expect:

Quote:
In *keycode the function returns a keycode, if previously set by Keyboard_PutKeycode(0x910) or zero, if not.

If you need complex GetKey() stuff like the catalog or alphabetic vs. numeric mode, meaning that simply identifying a key by matrix code is not enough for you, then GetKeyWait() will indeed create some difficulties.

As for SetGetkeyToMainFunctionReturnFlag, it actually tries to find the flag address by disassembling a syscall. If it doesn't work, maybe it's fixable by looking at the new code for that syscall?
Lephe wrote:
When using GetKeyWait() I personally always refer to the matrix codes set in [col] and [row]. From the description, I don't think the [keycode] is set as you expect:

Quote:
In *keycode the function returns a keycode, if previously set by Keyboard_PutKeycode(0x910) or zero, if not.

If you need complex GetKey() stuff like the catalog or alphabetic vs. numeric mode, meaning that simply identifying a key by matrix code is not enough for you, then GetKeyWait() will indeed create some difficulties.

As for SetGetkeyToMainFunctionReturnFlag, it actually tries to find the flag address by disassembling a syscall. If it doesn't work, maybe it's fixable by looking at the new code for that syscall?

Yeah, I'm not sure how to do that. I might look later if I can figure it out.

Intriguiingly, I've looked at amazonka's Lock addin, and it works fine with the g3a provided, but when I compile it myself from the provided source, it can still exit to menu.
The provided addin does look different though, and is a different filesize to the compiled version.
Actually it might be a trivial fix.

Code:
if ( ( addr & 0xFF000000 ) != 0x88000000 ) return 0x109;

Just make turn that into the following and you should be good to go.

Code:
if ( ( addr & 0xFF000000 ) != 0x88000000 && ( addr & 0xFF000000 ) != 0x8C000000) return 0x109;
Lephe wrote:
Actually it might be a trivial fix.

Code:
if ( ( addr & 0xFF000000 ) != 0x88000000 ) return 0x109;

Just make turn that into the following and you should be good to go.

Code:
if ( ( addr & 0xFF000000 ) != 0x88000000 && ( addr & 0xFF000000 ) != 0x8C000000) return 0x109;

Yes! Thank you.
My addin finally works.
That's good to hear! Good luck with the rest of development.

Also this change would likely fix amazonka's lock add-in at the same time ^^
Lephe wrote:
That's good to hear! Good luck with the rest of development.

Also this change would likely fix amazonka's lock add-in at the same time ^^

Yes. I tesed it in theirs and it works.
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement