Omnimaga

Calculator Community => TI Calculators => Axe => Topic started by: CKH4 on December 19, 2014, 10:32:23 am

Title: Switch the functions of 2nd and enter
Post by: CKH4 on December 19, 2014, 10:32:23 am
Is there a way in axe to swap the functions of the enter key and 2nd?  I have tried using this (http://www.omnimaga.org/axe-language/%28tutorial%29-key-hooks-in-axe/ (http://www.omnimaga.org/axe-language/%28tutorial%29-key-hooks-in-axe/)) tutorial but no luck so far.
Title: Re: Switch the functions of 2nd and enter
Post by: Digital on December 19, 2014, 01:41:38 pm
what calc you are using? i think the asm commands are sometimes different
Title: Re: Switch the functions of 2nd and enter
Post by: CKH4 on December 19, 2014, 02:04:58 pm
Ti-83+. It's not a problem with the commands, I'm struggling to simulate the keypress. Also Getkeyr doesn't have the 2nd key code.

Edit.
Whoops I forgot that I was emulating a ti 84+ se
Title: Re: Switch the functions of 2nd and enter
Post by: Digital on December 19, 2014, 02:57:57 pm
Code: [Select]
0->A
while (A!=54)
getkey->A
End

!= is the nonequal charakter
Title: Re: Switch the functions of 2nd and enter
Post by: Sorunome on December 19, 2014, 03:04:29 pm
um
Code: [Select]
While 1
EndIf getKey(54)
Is more optimized
(we are talking about axe, right?)
Title: Re: Switch the functions of 2nd and enter
Post by: Digital on December 19, 2014, 03:08:30 pm
um youre right -_-
Title: Re: Switch the functions of 2nd and enter
Post by: Sorunome on December 19, 2014, 03:52:11 pm
Yeah, just use getKey(NUM) wherever possible instead of the getKey -> VAR
Title: Re: Switch the functions of 2nd and enter
Post by: CKH4 on December 19, 2014, 03:55:52 pm
How can I use this to tie into the key hooks and simulated key presses? (sorry, pretty much an axe noob)
Title: Re: Switch the functions of 2nd and enter
Post by: Runer112 on December 19, 2014, 04:07:14 pm
In response to the last five posts, I don't think those pertain to what CKH4 is trying to do here...

Anyway, I managed to whip up a small "Axe" program to swap the functionality of the 2ND and ENTER keys. I put "Axe" in quotes because, as you probably know, a fair bit of assembly is needed to make hooks. But the logic of what the hook actually does is written in Axe.

As a preface, this will only work if your code is compiled as an application. With that out of the way, here's how to enable the hook:

Code: [Select]
ʟHook:Asm(DB06EF7B4F)

And here's the hook itself:

Code: [Select]
Lbl Hook
Asm(83FE1BC0260068)
(-9?+9-54??9-54)+54
Asm(F6017D)
Return

The assembly skeleton of this hook doesn't look exactly like those in MGOS' tutorial, and for an important reason. That's because his hook captures the kind of keypresses that you get from getKeyr, while this hook captures the kind of keypresses that you get from getKey. The important difference is that, as you may know, 2ND isn't actually captured by the former; it's a modifier key that changes the eventual result, but doesn't itself register as a key. So we need to intercept what are known as scan codes (the things returned by getKey) instead of key codes (the things returned by getKeyr).

This hook is called whenever the OS scans the keypad. The assembly skeleton handles things in a way such that the Axe code gets in the getKey-style scan code that was read, and should put out a scan code of the same format. In this case, my weird line of code with lots of 9's and 54's swaps scan codes 9 (ENTER) and 54 (2ND), leaving any other scan codes unchanged. If you wanted, you could replace these numbers with any pair of scan codes to swap them.
Title: Re: Switch the functions of 2nd and enter
Post by: CKH4 on December 19, 2014, 04:24:59 pm
Thanks, I'm still a little conconfused but I'll figure it out. Is it the same code to turn it off or is it different?
Title: Re: Switch the functions of 2nd and enter
Post by: Runer112 on December 19, 2014, 04:29:26 pm
Hmm, I probably should've been able to guess you'd need to know how to turn it off too. :P It's pretty straightforward, just one B_CALL which translates into this:

Code: [Select]
Asm(EF7E4F)
Title: Re: Switch the functions of 2nd and enter
Post by: CKH4 on December 19, 2014, 04:31:03 pm
Thanks, I'll compile it and hopefully it'll work.