Author Topic: HotkeySE | DoorsCS  (Read 6965 times)

0 Members and 1 Guest are viewing this topic.

Offline NonstickAtom785

  • LV3 Member (Next: 100)
  • ***
  • Posts: 78
  • Rating: +4/-0
  • Just live life. Cal-cu-lat-or style!
    • View Profile
HotkeySE | DoorsCS
« on: September 14, 2020, 11:35:22 am »

Here's the source code to a new shell expansion I made for Doors CS. You can download it below as a file.


Can anybody tell me if I could optimize this some more? This is my first functional/released assembly program and I don't know if I've missed some optimizations. Thanks all and I hope you find this useful! The source is in the download.


Edit: I got some help from Zeda at optimizing my program as well as some from Kerm. @Roccolox helped me realize that I didn't need to check the arrow keys so now the mouse goes a lot faster because it skips the iterations when the arrow keys are pressed and uses an optimized key routine.


Edit2: I finished the configuration program. It allows you to remove keys and change keys based upon your key presses. Check it out! I also made some very minor optimizations that make the program smaller. DO NOT use the older versions of HOTKEYSE with this program. I've packed the HOTKEYSE that will work in the latest HotkeySE.zip along with the KEYCONF program. (Source and documentation included.) The download link is below! Enjoy!

Yet Another Edit:
I have made my code even smaller for this. At the moment I am working on a smaller version of KEYCONF. (I had it working but I thought I was being clever while optimizing it and broke it... only 420 bytes). This new version of HOTKEYSE will not be compatible with the KEYCONF, but if you're feeling venturous(or just know what you're doing) then you can change what keys do things and recompile it yourself. I've included the download. :)
« Last Edit: February 26, 2021, 01:09:02 pm by NonstickAtom785 »
Grammer2 is Good!

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Hotkeys SE | DoorsCS
« Reply #1 on: September 14, 2020, 02:32:13 pm »
I didn't know that Doors CS still supported expansions. I thought that feature was only available in Doors CS 6.x or something (I remember trying an expansion that changed the GUI to something closer to MirageOS)

Offline NonstickAtom785

  • LV3 Member (Next: 100)
  • ***
  • Posts: 78
  • Rating: +4/-0
  • Just live life. Cal-cu-lat-or style!
    • View Profile
Re: HotkeySE | DoorsCS
« Reply #2 on: September 17, 2020, 03:13:04 pm »
I didn't know that Doors CS still supported expansions. I thought that feature was only available in Doors CS 6.x or something (I remember trying an expansion that changed the GUI to something closer to MirageOS)

If you got a shell expansion to do that pass it over please :P . Doors kept that feature.
« Last Edit: September 22, 2020, 12:23:30 pm by NonstickAtom785 »
Grammer2 is Good!

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Hotkeys SE | DoorsCS
« Reply #3 on: September 17, 2020, 03:27:49 pm »
Unfortuntately that was about 13-15 years ago and I can no longer locate it. D:

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: Hotkeys SE | DoorsCS
« Reply #4 on: September 20, 2020, 09:32:45 am »
Alright, I just got to try this (it turns out the reason it crashed for me was a bug from another program I was testing).

This is simple and practical; good work! It genuinely improves my DCS experience just by having the [.] and [prgm] buttons for renaming and editing. (Especially the [prgm] one as that is quite intuitive, same with [(] and [)] for copy/paste).

Offline NonstickAtom785

  • LV3 Member (Next: 100)
  • ***
  • Posts: 78
  • Rating: +4/-0
  • Just live life. Cal-cu-lat-or style!
    • View Profile
Re: HotkeySE | DoorsCS
« Reply #5 on: September 21, 2020, 01:46:40 pm »
I was trying to make the buttons make sense when I was programming them(thanks Zeda). I'm making an extra configuration program that will change what key performs an action. I intentionally left out the delete action because I didn't want anybody or myself to accidentally delete something. But I'm going to modify it so that it won't be available until you run and configure that action to the specified key. What I need help with is getting the key name based off the key that is pressed. Any ideas as to what I should do in this scenario? (F.Y.I I'm using Axe but some native assembly code will help me a bunch too!)

I was thinking of making a zero terminated list of strings and using str-Get() to get the string based off of the key, but the only problem is how to set up the routine to do that since there are keys that cannot be used...(enter, on, graph, xton, stat, arrows, alpha, and shift)
« Last Edit: September 22, 2020, 12:22:20 pm by NonstickAtom785 »
Grammer2 is Good!

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: Hotkeys SE | DoorsCS
« Reply #6 on: September 21, 2020, 04:32:17 pm »
What you could do is have a simple menu where the user can move a cursor to highlight an option (like "Edit"), then they press a button to assign to that option. Your code looks for the string associated with the keypress, and if the string is empty (i.e., starts with a null byte), then it isn't a valid option. You also need to verify the keypress isn't already assigned to an option.

It's basically your idea, using an empty string to signify the keypress is invalid.

Offline NonstickAtom785

  • LV3 Member (Next: 100)
  • ***
  • Posts: 78
  • Rating: +4/-0
  • Just live life. Cal-cu-lat-or style!
    • View Profile
Re: HotkeySE | DoorsCS
« Reply #7 on: September 22, 2020, 10:23:15 am »
What you could do is have a simple menu where the user can move a cursor to highlight an option (like "Edit"), then they press a button to assign to that option. Your code looks for the string associated with the keypress, and if the string is empty (i.e., starts with a null byte), then it isn't a valid option. You also need to verify the keypress isn't already assigned to an option.

It's basically your idea, using an empty string to signify the keypress is invalid.

I can't figure out how to make a list of zero terminated strings in axe without entering in the hex codes. Does anyone know if that's possible?
« Last Edit: September 22, 2020, 12:21:45 pm by NonstickAtom785 »
Grammer2 is Good!

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: HotkeySE | DoorsCS
« Reply #8 on: September 22, 2020, 12:22:36 pm »
I think you can do something like:
Code: [Select]
"HELLO"→Str1
"WORLD"[00]
"THIS"[00]
"IS"[00]
"A"[00]
"TEST"[00]

Then Str1 points to the first zero-terminated string (note that Axe will automatically tack on a 00 when you → a string)

Offline NonstickAtom785

  • LV3 Member (Next: 100)
  • ***
  • Posts: 78
  • Rating: +4/-0
  • Just live life. Cal-cu-lat-or style!
    • View Profile
Re: HotkeySE | DoorsCS
« Reply #9 on: September 22, 2020, 12:54:44 pm »
That was useful. So I made a table of all the keys and also realized that I can't use +,-,/, and * either. So I took those out of the equation. I added a section with all of the possible keys. With that I will do something like this:
Code: [Select]
If inData(GDB1,getKey)->A
strGet(Str1,startOfTable-A
End


Edit: I can't seem to get my code to print accurate results but when I use just the routine and output it they are fine here is the current code.
Code: [Select]
Return!If GetCalc("prgmSEHTKY")->A
+100->B
Fix 5:ClrDraw
Text(1,0,"HotkeySE Config")
RectI(0,0,49,7)
HLine(
Text(3,9,"Edit:")
Text(3,15,"Lock:")
Text(3,27,"Arch:")
Text(3,33,"Cut:")
Text(3,39,"Copy:")
Text(3,45,"Paste:")
Text(3,51,"Rename:")
Text(3,57,"Folder:")
For(G,0,8)
GKY()
End
DispGraph
Lbl GKY
If inData({G+B},GDB1)->C
strGet(Str1,C-1)->D
Text(35,6*G+9,D
End
[343337382F2E2D2C2B2A272625211F1E1D19171615110E00]->GDB1"[window]"[00]->Str1
"[zoom]"[00]
"mode"[00]
"[del]"[00]
"[x^-1]"[00]
"[x^2]"[00]"[log]"[00]
"[ln]"[00]
"[sto]"[00]
"[apps]"[00]
"[sin]"[00]
"[,]"[00]
"[0]"[00]
"[prgm]"[00]
"[cos]"[00]
"[(]"[00]
"[.]"[00]
"[vars]"[00]
"[tan]"[00]
"[)]"[00]
"[(-)]"[00]
"[^]"[00]


And here is the code that outputs the correct data:
Code: [Select]
;Same data as above...
ClrHome
Repeat getKey
End
If inData(,GDB1)->A
strGet(Str1,A-1)->B
End
Output(0,0,B)


« Last Edit: September 24, 2020, 09:45:19 am by NonstickAtom785 »
Grammer2 is Good!

Offline E37

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 358
  • Rating: +23/-0
  • Trial and error is the best teacher
    • View Profile
Re: HotkeySE | DoorsCS
« Reply #10 on: September 24, 2020, 09:38:28 am »
Hm. Im not really sure what you are trying to do here but Ill try to point out anything that could be a mistake.
1. I don't see Str1 declared anywhere. Since you said some of it worked I assume you declare it somewhere and just haven't shown it.
2. In you third code block, the if statement doesn't do anything unless you meant :strGet(Str1,A-1)-B to be :strGet(Str1,A-1)->B
3. In your first block of code you say :If inData(GDB1,getKey)->A I assume that you didn't actually use that code because you flipped the arguments for inData.

Nitpicky Axe coding things and optimization:
1. You use :For(G,0,8) : <Body> : End From my experience, using that type of for loop is bad practice. Unless your for loop has a variable end amount (Like you had a variable instead of the 8) using the single argument for loop is always faster, smaller and more reliable. For example :0->G:For( 8 ) : <Body> :G++:End
2. You don't need the colons on lines like "[window]"[00]:"[zoom]"[00]:"mode"[00]:"[del]"[00]:"[x^-1]"[00]:"[x^2]"[00]
3. Please put your data at the end of your code. Scrolling through a giant block of data in the middle of code isn't fun.
4. There is no real reason for GKY to be a subroutine.
5. Why are those text commands not in a loop? You could just do: 0->X:For( 8 ):Text(3,X++*2+1*3,strGet(Str1Menu,X-1)):End:[]->Str1Menu:"Edit"[00]"Lock"[00]"Arch"[00]"Cut"[00]"Copy"[00]"Paste"[00]"Rename"[00]"Folder"[00]
I'm still around... kind of.

Offline NonstickAtom785

  • LV3 Member (Next: 100)
  • ***
  • Posts: 78
  • Rating: +4/-0
  • Just live life. Cal-cu-lat-or style!
    • View Profile
Re: HotkeySE | DoorsCS
« Reply #11 on: September 24, 2020, 11:06:27 am »
I found the issue. Thanks for the optimization tips. They were useful as heck.
Grammer2 is Good!