π
<-
Chat plein-écran
[^]

Listen to Key Events while in Background

C, C++, ASM...

Listen to Key Events while in Background

Unread postby the_blaggyS » 15 Apr 2019, 17:29

I'm trying to write a C program which listens for key events while running in background and if a specified key is pressed than it should show a message box.

But I have no idea how to listen for key events while using the calculator normally since if you're testing if a key is pressed (isKeyPressed) in a loop the calculator freezes.
I already tried to forward (sending the key event I got with get_event if its actually a key event), but that didn't worked also.
Last edited by the_blaggyS on 16 Apr 2019, 00:26, edited 1 time in total.
User avatar
the_blaggyS
Niveau 3: MH (Membre Habitué)
Niveau 3: MH (Membre Habitué)
Level up: 12%
 
Posts: 12
Joined: 11 Apr 2019, 20:26
Gender: Not specified
Calculator(s):
MyCalcs profile

Re: Listen to Key Events in while in Background

Unread postby Noury » 15 Apr 2019, 18:13

I use this kind of loop but in the foreground.
It works fine.
I haven't tried the same in the background.
Maybe taking a look at Levak's nCapture can help you.
He waits for a "Ctrl+." to capture screen.
User avatar
NouryVIP++
Niveau 11: LV (Légende Vivante)
Niveau 11: LV (Légende Vivante)
Level up: 52.8%
 
Posts: 287
Joined: 07 Sep 2018, 09:19
Location: Sceaux, France 92
Gender: Male
Calculator(s):
MyCalcs profile

Re: Listen to Key Events in while in Background

Unread postby Vogtinator » 15 Apr 2019, 19:22

While the program is running, interrupts are disabled so no other tasks run.

Unfortunately this can't be implemented without any OS specific hooks right now.
User avatar
VogtinatorPremium
Niveau 9: IC (Compteur Infatigable)
Niveau 9: IC (Compteur Infatigable)
Level up: 1.6%
 
Posts: 217
Joined: 29 Mar 2014, 15:55
Gender: Male
Calculator(s):
MyCalcs profile

Re: Listen to Key Events in while in Background

Unread postby the_blaggyS » 15 Apr 2019, 22:21

@nebnm I will have a look at it, hopefully it's open source.
@Vogtinator do you know nHide? I thought I could write something similar in aspect of the 'activation'. If you're pressing :nsegp: and :ns2: it's executing.
User avatar
the_blaggyS
Niveau 3: MH (Membre Habitué)
Niveau 3: MH (Membre Habitué)
Level up: 12%
 
Posts: 12
Joined: 11 Apr 2019, 20:26
Gender: Not specified
Calculator(s):
MyCalcs profile

Re: Listen to Key Events while in Background

Unread postby the_blaggyS » 16 Apr 2019, 13:23

I found the thread https://tiplanet.org/forum/viewtopic.php?f=20&t=18348&hilit=hooks+tutorial where you're helping another user.
And you said that the OS's key interrupt handler can be found by printing the PC during reads of the keypad.
Maybe you can explain hot to do this? How do I know when it reads the keypad?
Or maybe you can redirect to some manuals or documentation where I can read aboout it.
Also you said it's quite easy therefore it's maybe easier to find it than explaining to me? xD (Just in case: I'm using an TI nSpire CX with OS 3.6)

I'm really interested in this field and probably can adopt some knowledge of nasm and gdb.
I already programmed x86 netwide assembler for unix and also started learning how to use gdb debugger a few years ago.
User avatar
the_blaggyS
Niveau 3: MH (Membre Habitué)
Niveau 3: MH (Membre Habitué)
Level up: 12%
 
Posts: 12
Joined: 11 Apr 2019, 20:26
Gender: Not specified
Calculator(s):
MyCalcs profile

Re: Listen to Key Events while in Background

Unread postby Vogtinator » 16 Apr 2019, 18:53

the_blaggyS wrote:I found the thread https://tiplanet.org/forum/viewtopic.php?f=20&t=18348&hilit=hooks+tutorial where you're helping another user.
And you said that the OS's key interrupt handler can be found by printing the PC during reads of the keypad.
Maybe you can explain hot to do this? How do I know when it reads the keypad?


You'd have to setup firebird with a custom patch to print the PC value when the keypad is accessed, but that's not enough, see below...

Or maybe you can redirect to some manuals or documentation where I can read aboout it.


Unfortunately not, this is a very specific topic. Even to get started here you'll need good knowledge of the ARM architecture and some reverse engineering.

Also you said it's quite easy therefore it's maybe easier to find it than explaining to me? xD (Just in case: I'm using an TI nSpire CX with OS 3.6)


What you're trying to do it actually not as easy the thread you linked. Message boxes can only be opened while running in the GUI task, so the hook would need to be called from the GUI task itself or a second hook has to do that.

I'm really interested in this field and probably can adopt some knowledge of nasm and gdb.
I already programmed x86 netwide assembler for unix and also started learning how to use gdb debugger a few years ago.


Neither x86 nor NASM can help you here - the Nspire uses ARMv5 instructions.
User avatar
VogtinatorPremium
Niveau 9: IC (Compteur Infatigable)
Niveau 9: IC (Compteur Infatigable)
Level up: 1.6%
 
Posts: 217
Joined: 29 Mar 2014, 15:55
Gender: Male
Calculator(s):
MyCalcs profile

Re: Listen to Key Events while in Background

Unread postby the_blaggyS » 16 Apr 2019, 20:20

Okay, first of all thank you for taking the time.

Unfortunately not, this is a very specific topic. Even to get started here you'll need good knowledge of the ARM architecture and some reverse engineering.


Maybe not that easy as I thought. Probably I have to learn about reverse engineering in general first, but that's not too bad since it's a thing I wanted to dig in and I already bought a book about it, maybe I can just combine both topics.

What you're trying to do it actually not as easy the thread you linked. Message boxes can only be opened while running in the GUI task, so the hook would need to be called from the GUI task itself or a second hook has to do that.


Oh I wasn't knowing that a visual element will make such a difference, the message box was just a kind of proof of concept. Actually I just wanted to write my own nHide which won't set the file browser's root to the file systems root, instead it should set it to a custom directory. For example if I open the file browser with nHide it's showing only a sub folder of my documents.

Neither x86 nor NASM can help you here - the Nspire uses ARMv5 instructions.


All I meant was that I know a bit of assembler in general, therefore the beginning should be easier. For a Java programmer it's probably also easier to read C code then it is for a non programmer.
User avatar
the_blaggyS
Niveau 3: MH (Membre Habitué)
Niveau 3: MH (Membre Habitué)
Level up: 12%
 
Posts: 12
Joined: 11 Apr 2019, 20:26
Gender: Not specified
Calculator(s):
MyCalcs profile


Return to Native: Ndless, Linux, ...

Who is online

Users browsing this forum: No registered users and 24 guests

-
Search
-
Social TI-Planet
-
Featured topics
Comparaisons des meilleurs prix pour acheter sa calculatrice !
Aidez la communauté à documenter les révisions matérielles en listant vos calculatrices graphiques !
Phi NumWorks jailbreak
123
-
Donations / Premium
For more contests, prizes, reviews, helping us pay the server and domains...
Donate
Discover the the advantages of a donor account !
JoinRejoignez the donors and/or premium!les donateurs et/ou premium !


Partner and ad
Notre partenaire Jarrety Calculatrices à acheter chez Calcuso
-
Stats.
1399 utilisateurs:
>1368 invités
>27 membres
>4 robots
Record simultané (sur 6 mois):
6892 utilisateurs (le 07/06/2017)
-
Other interesting websites
Texas Instruments Education
Global | France
 (English / Français)
Banque de programmes TI
ticalc.org
 (English)
La communauté TI-82
tout82.free.fr
 (Français)