Author Topic: Switch the functions of 2nd and enter  (Read 5875 times)

0 Members and 1 Guest are viewing this topic.

Offline CKH4

  • LV3 Member (Next: 100)
  • ***
  • Posts: 42
  • Rating: +1/-0
    • View Profile
Switch the functions of 2nd and enter
« 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/) tutorial but no luck so far.
Profiles:
        
Other Peoples Projects:
   
(I like parentheses)

Offline Digital

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 107
  • Rating: +0/-0
  • 10101
    • View Profile
    • Digital's Hp
Re: Switch the functions of 2nd and enter
« Reply #1 on: December 19, 2014, 01:41:38 pm »
what calc you are using? i think the asm commands are sometimes different
I'm sorry if i might make some mistakes, I'm German so English isn't my first language. Please correct me :)

Offline CKH4

  • LV3 Member (Next: 100)
  • ***
  • Posts: 42
  • Rating: +1/-0
    • View Profile
Re: Switch the functions of 2nd and enter
« Reply #2 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
« Last Edit: December 19, 2014, 02:15:53 pm by CKH4 »
Profiles:
        
Other Peoples Projects:
   
(I like parentheses)

Offline Digital

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 107
  • Rating: +0/-0
  • 10101
    • View Profile
    • Digital's Hp
Re: Switch the functions of 2nd and enter
« Reply #3 on: December 19, 2014, 02:57:57 pm »
Code: [Select]
0->A
while (A!=54)
getkey->A
End

!= is the nonequal charakter
I'm sorry if i might make some mistakes, I'm German so English isn't my first language. Please correct me :)

Offline Sorunome

  • Fox Fox Fox Fox Fox Fox Fox!
  • Support Staff
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 7920
  • Rating: +374/-13
  • Derpy Hooves
    • View Profile
    • My website! (You might lose the game)
Re: Switch the functions of 2nd and enter
« Reply #4 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?)

THE GAME
Also, check out my website
If OmnomIRC is screwed up, blame me!
Click here to give me an internet!

Offline Digital

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 107
  • Rating: +0/-0
  • 10101
    • View Profile
    • Digital's Hp
Re: Switch the functions of 2nd and enter
« Reply #5 on: December 19, 2014, 03:08:30 pm »
um youre right -_-
I'm sorry if i might make some mistakes, I'm German so English isn't my first language. Please correct me :)

Offline Sorunome

  • Fox Fox Fox Fox Fox Fox Fox!
  • Support Staff
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 7920
  • Rating: +374/-13
  • Derpy Hooves
    • View Profile
    • My website! (You might lose the game)
Re: Switch the functions of 2nd and enter
« Reply #6 on: December 19, 2014, 03:52:11 pm »
Yeah, just use getKey(NUM) wherever possible instead of the getKey -> VAR

THE GAME
Also, check out my website
If OmnomIRC is screwed up, blame me!
Click here to give me an internet!

Offline CKH4

  • LV3 Member (Next: 100)
  • ***
  • Posts: 42
  • Rating: +1/-0
    • View Profile
Re: Switch the functions of 2nd and enter
« Reply #7 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)
Profiles:
        
Other Peoples Projects:
   
(I like parentheses)

Offline Runer112

  • Project Author
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2289
  • Rating: +639/-31
    • View Profile
Re: Switch the functions of 2nd and enter
« Reply #8 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.
« Last Edit: December 19, 2014, 04:10:16 pm by Runer112 »

Offline CKH4

  • LV3 Member (Next: 100)
  • ***
  • Posts: 42
  • Rating: +1/-0
    • View Profile
Re: Switch the functions of 2nd and enter
« Reply #9 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?
Profiles:
        
Other Peoples Projects:
   
(I like parentheses)

Offline Runer112

  • Project Author
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2289
  • Rating: +639/-31
    • View Profile
Re: Switch the functions of 2nd and enter
« Reply #10 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)

Offline CKH4

  • LV3 Member (Next: 100)
  • ***
  • Posts: 42
  • Rating: +1/-0
    • View Profile
Re: Switch the functions of 2nd and enter
« Reply #11 on: December 19, 2014, 04:31:03 pm »
Thanks, I'll compile it and hopefully it'll work.
Profiles:
        
Other Peoples Projects:
   
(I like parentheses)