Page 1 sur 1

Listen to Key Events while in Background

Message non luPosté: 15 Avr 2019, 17:29
de the_blaggyS
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.

Re: Listen to Key Events in while in Background

Message non luPosté: 15 Avr 2019, 18:13
de Noury
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.

Re: Listen to Key Events in while in Background

Message non luPosté: 15 Avr 2019, 19:22
de Vogtinator
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.

Re: Listen to Key Events in while in Background

Message non luPosté: 15 Avr 2019, 22:21
de the_blaggyS
@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.

Re: Listen to Key Events while in Background

Message non luPosté: 16 Avr 2019, 13:23
de the_blaggyS
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.

Re: Listen to Key Events while in Background

Message non luPosté: 16 Avr 2019, 18:53
de Vogtinator
the_blaggyS a écrit: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.

Re: Listen to Key Events while in Background

Message non luPosté: 16 Avr 2019, 20:20
de the_blaggyS
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.