π
<-

Ndless KeyListener

C, C++, ASM...

Re: Ndless KeyListener

Unread postby Vogtinator » 07 May 2016, 19:25

Yes, the touchpad code is somewhere else. Do you need that too?
Regarding the error, could you post your current code?
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: Ndless KeyListener

Unread postby MishaShapo » 07 May 2016, 19:51

Yes, my teacher's program needs the touchpad as well. If you could get that, it would be swell.

Here is my code. Sorry for not thinking to post it earlier:

Code: Select all
#include <os.h>
#include "libndls.h"
#include <nspireio/nspireio.h>
char *cmd = "";
bool quit = false;


void testPushButton(){
    uart_puts("key pressed!\n");
}


void pushButton(){
    if (isKeyPressed(KEY_NSPIRE_TAB))
        cmd = "\t";
    if (isKeyPressed(KEY_NSPIRE_ENTER))
        cmd = "\n";
    if (isKeyPressed(KEY_NSPIRE_DEL))
        cmd = "\b";
    if (isKeyPressed(KEY_NSPIRE_A))
        cmd = isKeyPressed(KEY_NSPIRE_SHIFT) ? "A" : "a";
    if (isKeyPressed(KEY_NSPIRE_B))
        cmd = isKeyPressed(KEY_NSPIRE_SHIFT) ? "B" : "b";
    if (isKeyPressed(KEY_NSPIRE_C))
        cmd = isKeyPressed(KEY_NSPIRE_SHIFT) ? "C" : "c";
    if (isKeyPressed(KEY_NSPIRE_D))
        cmd = isKeyPressed(KEY_NSPIRE_SHIFT) ? "D" : "d";
    if (isKeyPressed(KEY_NSPIRE_E))
        cmd = isKeyPressed(KEY_NSPIRE_SHIFT) ? "E" : "e";
    if (isKeyPressed(KEY_NSPIRE_F))
        cmd = isKeyPressed(KEY_NSPIRE_SHIFT) ? "F" : "f";
    if (isKeyPressed(KEY_NSPIRE_G))
        cmd = isKeyPressed(KEY_NSPIRE_SHIFT) ? "G" : "g";
    if (isKeyPressed(KEY_NSPIRE_H))
        cmd = isKeyPressed(KEY_NSPIRE_SHIFT) ? "H" : "h";
    if (isKeyPressed(KEY_NSPIRE_I))
        cmd = isKeyPressed(KEY_NSPIRE_SHIFT) ? "I" : "i";
    if (isKeyPressed(KEY_NSPIRE_J))
        cmd = isKeyPressed(KEY_NSPIRE_SHIFT) ? "J" : "j";
    if (isKeyPressed(KEY_NSPIRE_K))
        cmd = isKeyPressed(KEY_NSPIRE_SHIFT) ? "K" : "k";
    if (isKeyPressed(KEY_NSPIRE_L))
        cmd = isKeyPressed(KEY_NSPIRE_SHIFT) ? "L" : "l";
    if (isKeyPressed(KEY_NSPIRE_M))
        cmd = isKeyPressed(KEY_NSPIRE_SHIFT) ? "M" : "m";
    if (isKeyPressed(KEY_NSPIRE_N))
        cmd = isKeyPressed(KEY_NSPIRE_SHIFT) ? "N" : "n";
    if (isKeyPressed(KEY_NSPIRE_O))
        cmd = isKeyPressed(KEY_NSPIRE_SHIFT) ? "O" : "o";
    if (isKeyPressed(KEY_NSPIRE_P))
        cmd = isKeyPressed(KEY_NSPIRE_SHIFT) ? "P" : "p";
    if (isKeyPressed(KEY_NSPIRE_Q))
        cmd = isKeyPressed(KEY_NSPIRE_SHIFT) ? "Q" : "q";
    if (isKeyPressed(KEY_NSPIRE_R))
        cmd = isKeyPressed(KEY_NSPIRE_SHIFT) ? "R" : "r";
    if (isKeyPressed(KEY_NSPIRE_S))
        cmd = isKeyPressed(KEY_NSPIRE_SHIFT) ? "S" : "s";
    if (isKeyPressed(KEY_NSPIRE_T))
        cmd = isKeyPressed(KEY_NSPIRE_SHIFT) ? "T" : "t";
    if (isKeyPressed(KEY_NSPIRE_U))
        cmd = isKeyPressed(KEY_NSPIRE_SHIFT) ? "U" : "u";
    if (isKeyPressed(KEY_NSPIRE_V))
        cmd = isKeyPressed(KEY_NSPIRE_SHIFT) ? "V" : "v";
    if (isKeyPressed(KEY_NSPIRE_W))
        cmd = isKeyPressed(KEY_NSPIRE_SHIFT) ? "W" : "w";
    if (isKeyPressed(KEY_NSPIRE_X))
        cmd = isKeyPressed(KEY_NSPIRE_SHIFT) ? "X" : "x";
    if (isKeyPressed(KEY_NSPIRE_Y))
        cmd = isKeyPressed(KEY_NSPIRE_SHIFT) ? "Y" : "y";
    if (isKeyPressed(KEY_NSPIRE_Z))
        cmd = isKeyPressed(KEY_NSPIRE_SHIFT) ? "Z" : "z";
    if (isKeyPressed(KEY_NSPIRE_1))
        cmd = "1";
    if (isKeyPressed(KEY_NSPIRE_2))
        cmd = "2";
    if (isKeyPressed(KEY_NSPIRE_3))
        cmd = "3";
    if (isKeyPressed(KEY_NSPIRE_4))
        cmd = "4";
    if (isKeyPressed(KEY_NSPIRE_5))
        cmd = "5";
    if (isKeyPressed(KEY_NSPIRE_6))
        cmd = "6";
    if (isKeyPressed(KEY_NSPIRE_7))
        cmd = "7";
    if (isKeyPressed(KEY_NSPIRE_8))
        cmd = "8";
    if (isKeyPressed(KEY_NSPIRE_9))
        cmd = "9";
    if (isKeyPressed(KEY_NSPIRE_0))
        cmd = "0";
    if (isKeyPressed(KEY_NSPIRE_SPACE))
        cmd = " ";
    if (isKeyPressed(KEY_NSPIRE_PERIOD))
        cmd = isKeyPressed(KEY_NSPIRE_SHIFT) ? ":" : ".";
    if (isKeyPressed(KEY_NSPIRE_COLON))
        cmd = ":";
    if (isKeyPressed(KEY_NSPIRE_COMMA)){
                if (isKeyPressed(KEY_NSPIRE_SHIFT))
                        cmd = ";";
                if (isKeyPressed(KEY_NSPIRE_CTRL))
                        cmd = "`";
                else
                        cmd = ",";
        }
    if (isKeyPressed(KEY_NSPIRE_QUESEXCL) || isKeyPressed(KEY_NSPIRE_QUES))
        cmd = isKeyPressed(KEY_NSPIRE_SHIFT) ? "!" : "?";
    if (isKeyPressed(KEY_NSPIRE_PLUS))
        cmd = isKeyPressed(KEY_NSPIRE_SHIFT) ? "&" : "+";
    if (isKeyPressed(KEY_NSPIRE_NEGATIVE) || isKeyPressed(KEY_NSPIRE_MINUS)) {
        if (isKeyPressed(KEY_NSPIRE_SHIFT))
            cmd = "_";
        if (isKeyPressed(KEY_NSPIRE_CTRL))
            cmd = "~";
        else
            cmd = "-";
    }
    if (isKeyPressed(KEY_NSPIRE_MULTIPLY))
        cmd = isKeyPressed(KEY_NSPIRE_SHIFT) ? "#" : "*";
    if (isKeyPressed(KEY_NSPIRE_DIVIDE)) {
        if (isKeyPressed(KEY_NSPIRE_SHIFT))
            cmd = "\\";
        if (isKeyPressed(KEY_NSPIRE_CTRL))
            cmd = "|";
        else
            cmd = "/";
    }
    if (isKeyPressed(KEY_NSPIRE_BAR))
        cmd = "|";
    if (isKeyPressed(KEY_NSPIRE_QUOTE))
        cmd = "\"";
    if (isKeyPressed(KEY_NSPIRE_APOSTROPHE))
        cmd = "'";
    if (isKeyPressed(KEY_NSPIRE_EXP)) {
        if (isKeyPressed(KEY_NSPIRE_SHIFT))
            cmd = "'";
        if (isKeyPressed(KEY_NSPIRE_CTRL))
            cmd = "\"";
        else
            cmd = "^";
    }
    if (isKeyPressed(KEY_NSPIRE_EQU)) {
        if (isKeyPressed(KEY_NSPIRE_SHIFT))
            cmd = ">";
        if (isKeyPressed(KEY_NSPIRE_CTRL))
            cmd = "<";
        else
            cmd = "= ";
    }
    if (isKeyPressed(KEY_NSPIRE_LTHAN))
        cmd = "<";
    if (isKeyPressed(KEY_NSPIRE_GTHAN))
        cmd = ">";
    if (isKeyPressed(KEY_NSPIRE_LP)) {
        if (isKeyPressed(KEY_NSPIRE_SHIFT))
            cmd = "[";
        if (isKeyPressed(KEY_NSPIRE_CTRL))
            cmd = "{";
        else
            cmd = "(";
    }
    if (isKeyPressed(KEY_NSPIRE_RP)) {
        if (isKeyPressed(KEY_NSPIRE_SHIFT))
            cmd = "]";
        if (isKeyPressed(KEY_NSPIRE_CTRL))
            cmd = "}";
        else
            cmd = ")";
    }
    if (isKeyPressed(KEY_NSPIRE_FLAG)) {
                if (isKeyPressed(KEY_NSPIRE_SHIFT))
                        cmd = "$";
                if (isKeyPressed(KEY_NSPIRE_CTRL))
                        cmd = "@";
        cmd = "%";
    }
    if(isKeyPressed(KEY_NSPIRE_ESC)) cmd = "ESC";
    if(isKeyPressed(KEY_NSPIRE_DEL)) cmd = "DEL";
    if(isKeyPressed(KEY_NSPIRE_ENTER)) cmd = "ENT";
    if(isKeyPressed(KEY_NSPIRE_RET)) cmd = "RET";
    if(isKeyPressed(KEY_NSPIRE_THETA)) cmd = "THETA";
    if(isKeyPressed(KEY_NSPIRE_eEXP)) cmd = "eEXP";
    if(isKeyPressed(KEY_NSPIRE_PI)) cmd = "PI";
    if(isKeyPressed(KEY_NSPIRE_TENX)) cmd = "TENX";
    if(isKeyPressed(KEY_NSPIRE_EE)) cmd = "EE";
    if(isKeyPressed(KEY_NSPIRE_SQU)) cmd = "SQU";
    if(isKeyPressed(KEY_NSPIRE_II)) cmd = "II";
    if(isKeyPressed(KEY_NSPIRE_TAN)) cmd = "TAN";
    if(isKeyPressed(KEY_NSPIRE_COS)) cmd = "COS";
    if(isKeyPressed(KEY_NSPIRE_SIN)) cmd = "SIN";
    if(isKeyPressed(KEY_NSPIRE_EXP)) cmd = "EXP";
    if(isKeyPressed(KEY_NSPIRE_CAT)) cmd = "CAT";
    if(isKeyPressed(KEY_NSPIRE_FRAC)) cmd = "FRAC";
    if(isKeyPressed(KEY_NSPIRE_VAR)) cmd = "VAR";
    if(isKeyPressed(KEY_NSPIRE_DEL)) cmd = "DEL";
    if(isKeyPressed(KEY_NSPIRE_FLAG)){ cmd = "FLAG";quit=true;}
    if(isKeyPressed(KEY_NSPIRE_CLICK)) cmd = "CLICK";
    if(isKeyPressed(KEY_NSPIRE_HOME)) cmd = "HOME";
    if(isKeyPressed(KEY_NSPIRE_MENU)) cmd = "MENU";
    if(isKeyPressed(KEY_NSPIRE_UP)) cmd = "UP";
    if(isKeyPressed(KEY_NSPIRE_UPRIGHT)) cmd = "UPRIGHT";
    if(isKeyPressed(KEY_NSPIRE_RIGHT)) cmd = "RIGHT";
    if(isKeyPressed(KEY_NSPIRE_RIGHTDOWN)) cmd = "RIGHTDOWN";
    if(isKeyPressed(KEY_NSPIRE_DOWN)) cmd = "DOWN";
    if(isKeyPressed(KEY_NSPIRE_DOWNLEFT)) cmd = "DOWNLEFT";
    if(isKeyPressed(KEY_NSPIRE_LEFT)) cmd = "LEFT";
    if(isKeyPressed(KEY_NSPIRE_LEFTUP)) cmd = "LEFTUP";
    if(isKeyPressed(KEY_NSPIRE_SHIFT)) cmd = "SHIFT";
    if(isKeyPressed(KEY_NSPIRE_CTRL)) cmd = "CTRL";
    if(isKeyPressed(KEY_NSPIRE_DOC)) cmd = "DOC";
    if(isKeyPressed(KEY_NSPIRE_TRIG)) cmd = "TRIG";
    if(isKeyPressed(KEY_NSPIRE_SCRATCHPAD)) cmd = "SCRPAD";

    uart_puts(cmd);
    uart_puts("!\n");
}


static const int hook_addrs[] = {0x100B66C8, 0x100B6988,  // Clickpad / Touchpad 3.1
                                 0x100EAAAC, 0x100EADC4,  // CX 3.1
                                 0x100E72CC, 0x100E75E4,  // CM 3.1
                                 0x101122b8, 0x100eb288,  // Clickpad / Touchpad 3.6
                                 0x10111cfc, 0x1011201C, // CX 3.6
                                                                 0x101184C0, 0, // ClickPad / Touchpad 3.9.0
                                 0, 0, // ClickPad / Touchpad 3.9.1
                                 0, 0, // CX 3.9.0
                                                                 0, 0x101184B0, // CX 3.9.1
                                                                 0, 0, // CX 4.0.0
                                                                 0x1011EF68, 0x1011EDB8, // CX 4.0.3
                                                                0x1006A220, 0x10069ce0, // CX 4.2
                                                                };

HOOK_DEFINE(hook_pushButton){
    pushButton();
//    HOOK_RESTORE_RETURN(hook_pushButton);
}

int main(int argc, char* argv[]){

    if(argc < 1) return 0;
    cmd = "URTX";
    uart_puts(cmd);
    uart_puts("!\n");
    HOOK_INSTALL(nl_osvalue((int*)hook_addrs, sizeof(hook_addrs)/sizeof(hook_addrs[0])), hook_pushButton);
//    HOOK_INSTALL(0x1006A220, hook_pushButton);
    nl_set_resident();
    return 0;
}


User avatar
MishaShapo
Niveau 3: MH (Membre Habitué)
Niveau 3: MH (Membre Habitué)
Level up: 68%
 
Posts: 17
Joined: 06 May 2016, 04:58
Gender: Not specified
Calculator(s):
MyCalcs profile

Re: Ndless KeyListener

Unread postby Vogtinator » 07 May 2016, 20:04

For the touchpad you can use 0x1022f824 on CX CAS and 0x1022F2C0 on CX.

You need to use HOOK_RESTORE_RETURN(hook_pushButton); in your HOOK, otherwise it'll crash sooner or later.
Also, why "if(argc < 1) return 0;"? argv[0] is the current program, so argc is always >= 1.
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: Ndless KeyListener

Unread postby MishaShapo » 07 May 2016, 20:21

Thanks for the tip on argv[0]. I just saw it in other programs, but didn't know what it does exactly. I didn't use HOOK_RESTORE_RETURN() because it was giving me this error right when I opened the program:

Code: Select all
Warning (e59ff018): Prefetch abort: address=e59ff018 status=05

Warning (1039c978): Data abort: address=00000001 status=01 instruction at 1039c978


Also, unfortunately, the new hooks are crashing. When I comment out HOOK_RESTORE_RETURN(), it at least runs but the new hooks throw this error

Code: Select all
Warning (fffffb48): Prefetch abort: address=fffffb48 status=05

Error (100cbbb8): Cannot set T bit with MSR instruction


Here is my current code. :

Code: Select all
#include <os.h>
#include "libndls.h"
#include <nspireio/nspireio.h>
char *cmd = "";
bool quit = false;


void testPushButton(){
    uart_puts("key pressed!\n");
}


void keyPushButton(){
    if (isKeyPressed(KEY_NSPIRE_TAB))
        cmd = "\t";
    if (isKeyPressed(KEY_NSPIRE_ENTER))
        cmd = "\n";
    if (isKeyPressed(KEY_NSPIRE_DEL))
        cmd = "\b";
    if (isKeyPressed(KEY_NSPIRE_A))
        cmd = isKeyPressed(KEY_NSPIRE_SHIFT) ? "A" : "a";
    if (isKeyPressed(KEY_NSPIRE_B))
        cmd = isKeyPressed(KEY_NSPIRE_SHIFT) ? "B" : "b";
    if (isKeyPressed(KEY_NSPIRE_C))
        cmd = isKeyPressed(KEY_NSPIRE_SHIFT) ? "C" : "c";
    if (isKeyPressed(KEY_NSPIRE_D))
        cmd = isKeyPressed(KEY_NSPIRE_SHIFT) ? "D" : "d";
    if (isKeyPressed(KEY_NSPIRE_E))
        cmd = isKeyPressed(KEY_NSPIRE_SHIFT) ? "E" : "e";
    if (isKeyPressed(KEY_NSPIRE_F))
        cmd = isKeyPressed(KEY_NSPIRE_SHIFT) ? "F" : "f";
    if (isKeyPressed(KEY_NSPIRE_G))
        cmd = isKeyPressed(KEY_NSPIRE_SHIFT) ? "G" : "g";
    if (isKeyPressed(KEY_NSPIRE_H))
        cmd = isKeyPressed(KEY_NSPIRE_SHIFT) ? "H" : "h";
    if (isKeyPressed(KEY_NSPIRE_I))
        cmd = isKeyPressed(KEY_NSPIRE_SHIFT) ? "I" : "i";
    if (isKeyPressed(KEY_NSPIRE_J))
        cmd = isKeyPressed(KEY_NSPIRE_SHIFT) ? "J" : "j";
    if (isKeyPressed(KEY_NSPIRE_K))
        cmd = isKeyPressed(KEY_NSPIRE_SHIFT) ? "K" : "k";
    if (isKeyPressed(KEY_NSPIRE_L))
        cmd = isKeyPressed(KEY_NSPIRE_SHIFT) ? "L" : "l";
    if (isKeyPressed(KEY_NSPIRE_M))
        cmd = isKeyPressed(KEY_NSPIRE_SHIFT) ? "M" : "m";
    if (isKeyPressed(KEY_NSPIRE_N))
        cmd = isKeyPressed(KEY_NSPIRE_SHIFT) ? "N" : "n";
    if (isKeyPressed(KEY_NSPIRE_O))
        cmd = isKeyPressed(KEY_NSPIRE_SHIFT) ? "O" : "o";
    if (isKeyPressed(KEY_NSPIRE_P))
        cmd = isKeyPressed(KEY_NSPIRE_SHIFT) ? "P" : "p";
    if (isKeyPressed(KEY_NSPIRE_Q))
        cmd = isKeyPressed(KEY_NSPIRE_SHIFT) ? "Q" : "q";
    if (isKeyPressed(KEY_NSPIRE_R))
        cmd = isKeyPressed(KEY_NSPIRE_SHIFT) ? "R" : "r";
    if (isKeyPressed(KEY_NSPIRE_S))
        cmd = isKeyPressed(KEY_NSPIRE_SHIFT) ? "S" : "s";
    if (isKeyPressed(KEY_NSPIRE_T))
        cmd = isKeyPressed(KEY_NSPIRE_SHIFT) ? "T" : "t";
    if (isKeyPressed(KEY_NSPIRE_U))
        cmd = isKeyPressed(KEY_NSPIRE_SHIFT) ? "U" : "u";
    if (isKeyPressed(KEY_NSPIRE_V))
        cmd = isKeyPressed(KEY_NSPIRE_SHIFT) ? "V" : "v";
    if (isKeyPressed(KEY_NSPIRE_W))
        cmd = isKeyPressed(KEY_NSPIRE_SHIFT) ? "W" : "w";
    if (isKeyPressed(KEY_NSPIRE_X))
        cmd = isKeyPressed(KEY_NSPIRE_SHIFT) ? "X" : "x";
    if (isKeyPressed(KEY_NSPIRE_Y))
        cmd = isKeyPressed(KEY_NSPIRE_SHIFT) ? "Y" : "y";
    if (isKeyPressed(KEY_NSPIRE_Z))
        cmd = isKeyPressed(KEY_NSPIRE_SHIFT) ? "Z" : "z";
    if (isKeyPressed(KEY_NSPIRE_1))
        cmd = "1";
    if (isKeyPressed(KEY_NSPIRE_2))
        cmd = "2";
    if (isKeyPressed(KEY_NSPIRE_3))
        cmd = "3";
    if (isKeyPressed(KEY_NSPIRE_4))
        cmd = "4";
    if (isKeyPressed(KEY_NSPIRE_5))
        cmd = "5";
    if (isKeyPressed(KEY_NSPIRE_6))
        cmd = "6";
    if (isKeyPressed(KEY_NSPIRE_7))
        cmd = "7";
    if (isKeyPressed(KEY_NSPIRE_8))
        cmd = "8";
    if (isKeyPressed(KEY_NSPIRE_9))
        cmd = "9";
    if (isKeyPressed(KEY_NSPIRE_0))
        cmd = "0";
    if (isKeyPressed(KEY_NSPIRE_SPACE))
        cmd = " ";
    if (isKeyPressed(KEY_NSPIRE_PERIOD))
        cmd = isKeyPressed(KEY_NSPIRE_SHIFT) ? ":" : ".";
    if (isKeyPressed(KEY_NSPIRE_COLON))
        cmd = ":";
    if (isKeyPressed(KEY_NSPIRE_COMMA)){
                if (isKeyPressed(KEY_NSPIRE_SHIFT))
                        cmd = ";";
                if (isKeyPressed(KEY_NSPIRE_CTRL))
                        cmd = "`";
                else
                        cmd = ",";
        }
    if (isKeyPressed(KEY_NSPIRE_QUESEXCL) || isKeyPressed(KEY_NSPIRE_QUES))
        cmd = isKeyPressed(KEY_NSPIRE_SHIFT) ? "!" : "?";
    if (isKeyPressed(KEY_NSPIRE_PLUS))
        cmd = isKeyPressed(KEY_NSPIRE_SHIFT) ? "&" : "+";
    if (isKeyPressed(KEY_NSPIRE_NEGATIVE) || isKeyPressed(KEY_NSPIRE_MINUS)) {
        if (isKeyPressed(KEY_NSPIRE_SHIFT))
            cmd = "_";
        if (isKeyPressed(KEY_NSPIRE_CTRL))
            cmd = "~";
        else
            cmd = "-";
    }
    if (isKeyPressed(KEY_NSPIRE_MULTIPLY))
        cmd = isKeyPressed(KEY_NSPIRE_SHIFT) ? "#" : "*";
    if (isKeyPressed(KEY_NSPIRE_DIVIDE)) {
        if (isKeyPressed(KEY_NSPIRE_SHIFT))
            cmd = "\\";
        if (isKeyPressed(KEY_NSPIRE_CTRL))
            cmd = "|";
        else
            cmd = "/";
    }
    if (isKeyPressed(KEY_NSPIRE_BAR))
        cmd = "|";
    if (isKeyPressed(KEY_NSPIRE_QUOTE))
        cmd = "\"";
    if (isKeyPressed(KEY_NSPIRE_APOSTROPHE))
        cmd = "'";
    if (isKeyPressed(KEY_NSPIRE_EXP)) {
        if (isKeyPressed(KEY_NSPIRE_SHIFT))
            cmd = "'";
        if (isKeyPressed(KEY_NSPIRE_CTRL))
            cmd = "\"";
        else
            cmd = "^";
    }
    if (isKeyPressed(KEY_NSPIRE_EQU)) {
        if (isKeyPressed(KEY_NSPIRE_SHIFT))
            cmd = ">";
        if (isKeyPressed(KEY_NSPIRE_CTRL))
            cmd = "<";
        else
            cmd = "= ";
    }
    if (isKeyPressed(KEY_NSPIRE_LTHAN))
        cmd = "<";
    if (isKeyPressed(KEY_NSPIRE_GTHAN))
        cmd = ">";
    if (isKeyPressed(KEY_NSPIRE_LP)) {
        if (isKeyPressed(KEY_NSPIRE_SHIFT))
            cmd = "[";
        if (isKeyPressed(KEY_NSPIRE_CTRL))
            cmd = "{";
        else
            cmd = "(";
    }
    if (isKeyPressed(KEY_NSPIRE_RP)) {
        if (isKeyPressed(KEY_NSPIRE_SHIFT))
            cmd = "]";
        if (isKeyPressed(KEY_NSPIRE_CTRL))
            cmd = "}";
        else
            cmd = ")";
    }
    if (isKeyPressed(KEY_NSPIRE_FLAG)) {
                if (isKeyPressed(KEY_NSPIRE_SHIFT))
                        cmd = "$";
                if (isKeyPressed(KEY_NSPIRE_CTRL))
                        cmd = "@";
        cmd = "%";
    }
    if(isKeyPressed(KEY_NSPIRE_ESC)) cmd = "ESC";
    if(isKeyPressed(KEY_NSPIRE_DEL)) cmd = "DEL";
    if(isKeyPressed(KEY_NSPIRE_ENTER)) cmd = "ENT";
    if(isKeyPressed(KEY_NSPIRE_RET)) cmd = "RET";
    if(isKeyPressed(KEY_NSPIRE_THETA)) cmd = "THETA";
    if(isKeyPressed(KEY_NSPIRE_eEXP)) cmd = "eEXP";
    if(isKeyPressed(KEY_NSPIRE_PI)) cmd = "PI";
    if(isKeyPressed(KEY_NSPIRE_TENX)) cmd = "TENX";
    if(isKeyPressed(KEY_NSPIRE_EE)) cmd = "EE";
    if(isKeyPressed(KEY_NSPIRE_SQU)) cmd = "SQU";
    if(isKeyPressed(KEY_NSPIRE_II)) cmd = "II";
    if(isKeyPressed(KEY_NSPIRE_TAN)) cmd = "TAN";
    if(isKeyPressed(KEY_NSPIRE_COS)) cmd = "COS";
    if(isKeyPressed(KEY_NSPIRE_SIN)) cmd = "SIN";
    if(isKeyPressed(KEY_NSPIRE_EXP)) cmd = "EXP";
    if(isKeyPressed(KEY_NSPIRE_CAT)) cmd = "CAT";
    if(isKeyPressed(KEY_NSPIRE_FRAC)) cmd = "FRAC";
    if(isKeyPressed(KEY_NSPIRE_VAR)) cmd = "VAR";
    if(isKeyPressed(KEY_NSPIRE_DEL)) cmd = "DEL";
    if(isKeyPressed(KEY_NSPIRE_FLAG)){ cmd = "FLAG";quit=true;}
    if(isKeyPressed(KEY_NSPIRE_CLICK)) cmd = "CLICK";
    if(isKeyPressed(KEY_NSPIRE_HOME)) cmd = "HOME";
    if(isKeyPressed(KEY_NSPIRE_MENU)) cmd = "MENU";
    if(isKeyPressed(KEY_NSPIRE_SHIFT)) cmd = "SHIFT";
    if(isKeyPressed(KEY_NSPIRE_CTRL)) cmd = "CTRL";
    if(isKeyPressed(KEY_NSPIRE_DOC)) cmd = "DOC";
    if(isKeyPressed(KEY_NSPIRE_TRIG)) cmd = "TRIG";
    if(isKeyPressed(KEY_NSPIRE_SCRATCHPAD)) cmd = "SCRPAD";

    uart_puts(cmd);
    uart_puts("!\n");
}

void padPushButton(){
    if(isKeyPressed(KEY_NSPIRE_UP)) cmd = "UP";
    if(isKeyPressed(KEY_NSPIRE_UPRIGHT)) cmd = "UPRIGHT";
    if(isKeyPressed(KEY_NSPIRE_RIGHT)) cmd = "RIGHT";
    if(isKeyPressed(KEY_NSPIRE_RIGHTDOWN)) cmd = "RIGHTDOWN";
    if(isKeyPressed(KEY_NSPIRE_DOWN)) cmd = "DOWN";
    if(isKeyPressed(KEY_NSPIRE_DOWNLEFT)) cmd = "DOWNLEFT";
    if(isKeyPressed(KEY_NSPIRE_LEFT)) cmd = "LEFT";
    if(isKeyPressed(KEY_NSPIRE_LEFTUP)) cmd = "LEFTUP";

    uart_puts(cmd);
    uart_puts("!\n");

}


static const int key_hook_addrs[] = {0x100B66C8, 0x100B6988,  // Clickpad / Touchpad 3.1
                                 0x100EAAAC, 0x100EADC4,  // CX 3.1
                                 0x100E72CC, 0x100E75E4,  // CM 3.1
                                 0x101122b8, 0x100eb288,  // Clickpad / Touchpad 3.6
                                 0x10111cfc, 0x1011201C, // CX 3.6
                                                                 0x101184C0, 0, // ClickPad / Touchpad 3.9.0
                                 0, 0, // ClickPad / Touchpad 3.9.1
                                 0, 0, // CX 3.9.0
                                                                 0, 0x101184B0, // CX 3.9.1
                                                                 0, 0, // CX 4.0.0
                                                                 0x1011EF68, 0x1011EDB8, // CX 4.0.3
                                                                0x1006A220, 0x10069ce0, // CX 4.2
                                                                };

static const int pad_hook_addrs[] = {0x100B66C8, 0x100B6988,  // Clickpad / Touchpad 3.1
                                 0x100EAAAC, 0x100EADC4,  // CX 3.1
                                 0x100E72CC, 0x100E75E4,  // CM 3.1
                                 0x101122b8, 0x100eb288,  // Clickpad / Touchpad 3.6
                                 0x10111cfc, 0x1011201C, // CX 3.6
                                                                 0x101184C0, 0, // ClickPad / Touchpad 3.9.0
                                 0, 0, // ClickPad / Touchpad 3.9.1
                                 0, 0, // CX 3.9.0
                                                                 0, 0x101184B0, // CX 3.9.1
                                                                 0, 0, // CX 4.0.0
                                                                 0x1011EF68, 0x1011EDB8, // CX 4.0.3
                                                                0x1022F2C0, 0x1022f824, // CX 4.2
                                                                };

HOOK_DEFINE(hook_keyPushButton){
    keyPushButton();
//    HOOK_RESTORE_RETURN(hook_keyPushButton);
}
HOOK_DEFINE(hook_padPushButton){
    padPushButton();
//    HOOK_RESTORE_RETURN(hook_padPushButton);
}

int main(int argc, char* argv[]){

    cmd = "URTX";
    uart_puts(cmd);
    uart_puts("!\n");
    HOOK_INSTALL(nl_osvalue((int*)pad_hook_addrs, sizeof(pad_hook_addrs)/sizeof(pad_hook_addrs[0])), hook_padPushButton);
    HOOK_INSTALL(nl_osvalue((int*)key_hook_addrs, sizeof(key_hook_addrs)/sizeof(key_hook_addrs[0])), hook_keyPushButton);
    nl_set_resident();
    return 0;
}



User avatar
MishaShapo
Niveau 3: MH (Membre Habitué)
Niveau 3: MH (Membre Habitué)
Level up: 68%
 
Posts: 17
Joined: 06 May 2016, 04:58
Gender: Not specified
Calculator(s):
MyCalcs profile

Re: Ndless KeyListener

Unread postby Vogtinator » 07 May 2016, 22:58

Looks like that was just bad hook placement, directly overwriting the push on a function prologue.
Just increment all addresses I gave you by 16 (0x10) and it should work.
Don't forget the HOOK_RESTORE_RETURN! That it even worked was undefined behaviour.
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: Ndless KeyListener

Unread postby MishaShapo » 07 May 2016, 23:43

Hi, Vogtinator, I incremented the addresses and make sure to include HOOK_RESTORE_RETURN. The keys and touchpad both fire off the event handlers, but for some reason, the touchpad events do not propagate to the OS so it acts in a "blocking" behavior. Also, the HOME button for some reason prints the last character sent rather than the string "HOME".

Do you think you could find a way to eliminate the blocking behavior and the Home button bug? Thank you! =)

Here is a link to a video showing the behavior: https://www.youtube.com/watch?v=8bZMTpRWBAY&feature=youtu.be

And here is my code:

Code: Select all
#include <os.h>
#include "libndls.h"
#include <nspireio/nspireio.h>
char *cmd = "";
bool quit = false;


void testPushButton(){
    uart_puts("key pressed!\n");
}


void keyPushButton(){
    if (isKeyPressed(KEY_NSPIRE_TAB))
        cmd = "\t";
    if (isKeyPressed(KEY_NSPIRE_ENTER))
        cmd = "\n";
    if (isKeyPressed(KEY_NSPIRE_DEL))
        cmd = "\b";
    if (isKeyPressed(KEY_NSPIRE_A))
        cmd = isKeyPressed(KEY_NSPIRE_SHIFT) ? "A" : "a";
    if (isKeyPressed(KEY_NSPIRE_B))
        cmd = isKeyPressed(KEY_NSPIRE_SHIFT) ? "B" : "b";
    if (isKeyPressed(KEY_NSPIRE_C))
        cmd = isKeyPressed(KEY_NSPIRE_SHIFT) ? "C" : "c";
    if (isKeyPressed(KEY_NSPIRE_D))
        cmd = isKeyPressed(KEY_NSPIRE_SHIFT) ? "D" : "d";
    if (isKeyPressed(KEY_NSPIRE_E))
        cmd = isKeyPressed(KEY_NSPIRE_SHIFT) ? "E" : "e";
    if (isKeyPressed(KEY_NSPIRE_F))
        cmd = isKeyPressed(KEY_NSPIRE_SHIFT) ? "F" : "f";
    if (isKeyPressed(KEY_NSPIRE_G))
        cmd = isKeyPressed(KEY_NSPIRE_SHIFT) ? "G" : "g";
    if (isKeyPressed(KEY_NSPIRE_H))
        cmd = isKeyPressed(KEY_NSPIRE_SHIFT) ? "H" : "h";
    if (isKeyPressed(KEY_NSPIRE_I))
        cmd = isKeyPressed(KEY_NSPIRE_SHIFT) ? "I" : "i";
    if (isKeyPressed(KEY_NSPIRE_J))
        cmd = isKeyPressed(KEY_NSPIRE_SHIFT) ? "J" : "j";
    if (isKeyPressed(KEY_NSPIRE_K))
        cmd = isKeyPressed(KEY_NSPIRE_SHIFT) ? "K" : "k";
    if (isKeyPressed(KEY_NSPIRE_L))
        cmd = isKeyPressed(KEY_NSPIRE_SHIFT) ? "L" : "l";
    if (isKeyPressed(KEY_NSPIRE_M))
        cmd = isKeyPressed(KEY_NSPIRE_SHIFT) ? "M" : "m";
    if (isKeyPressed(KEY_NSPIRE_N))
        cmd = isKeyPressed(KEY_NSPIRE_SHIFT) ? "N" : "n";
    if (isKeyPressed(KEY_NSPIRE_O))
        cmd = isKeyPressed(KEY_NSPIRE_SHIFT) ? "O" : "o";
    if (isKeyPressed(KEY_NSPIRE_P))
        cmd = isKeyPressed(KEY_NSPIRE_SHIFT) ? "P" : "p";
    if (isKeyPressed(KEY_NSPIRE_Q))
        cmd = isKeyPressed(KEY_NSPIRE_SHIFT) ? "Q" : "q";
    if (isKeyPressed(KEY_NSPIRE_R))
        cmd = isKeyPressed(KEY_NSPIRE_SHIFT) ? "R" : "r";
    if (isKeyPressed(KEY_NSPIRE_S))
        cmd = isKeyPressed(KEY_NSPIRE_SHIFT) ? "S" : "s";
    if (isKeyPressed(KEY_NSPIRE_T))
        cmd = isKeyPressed(KEY_NSPIRE_SHIFT) ? "T" : "t";
    if (isKeyPressed(KEY_NSPIRE_U))
        cmd = isKeyPressed(KEY_NSPIRE_SHIFT) ? "U" : "u";
    if (isKeyPressed(KEY_NSPIRE_V))
        cmd = isKeyPressed(KEY_NSPIRE_SHIFT) ? "V" : "v";
    if (isKeyPressed(KEY_NSPIRE_W))
        cmd = isKeyPressed(KEY_NSPIRE_SHIFT) ? "W" : "w";
    if (isKeyPressed(KEY_NSPIRE_X))
        cmd = isKeyPressed(KEY_NSPIRE_SHIFT) ? "X" : "x";
    if (isKeyPressed(KEY_NSPIRE_Y))
        cmd = isKeyPressed(KEY_NSPIRE_SHIFT) ? "Y" : "y";
    if (isKeyPressed(KEY_NSPIRE_Z))
        cmd = isKeyPressed(KEY_NSPIRE_SHIFT) ? "Z" : "z";
    if (isKeyPressed(KEY_NSPIRE_1))
        cmd = "1";
    if (isKeyPressed(KEY_NSPIRE_2))
        cmd = "2";
    if (isKeyPressed(KEY_NSPIRE_3))
        cmd = "3";
    if (isKeyPressed(KEY_NSPIRE_4))
        cmd = "4";
    if (isKeyPressed(KEY_NSPIRE_5))
        cmd = "5";
    if (isKeyPressed(KEY_NSPIRE_6))
        cmd = "6";
    if (isKeyPressed(KEY_NSPIRE_7))
        cmd = "7";
    if (isKeyPressed(KEY_NSPIRE_8))
        cmd = "8";
    if (isKeyPressed(KEY_NSPIRE_9))
        cmd = "9";
    if (isKeyPressed(KEY_NSPIRE_0))
        cmd = "0";
    if (isKeyPressed(KEY_NSPIRE_SPACE))
        cmd = " ";
    if (isKeyPressed(KEY_NSPIRE_PERIOD))
        cmd = isKeyPressed(KEY_NSPIRE_SHIFT) ? ":" : ".";
    if (isKeyPressed(KEY_NSPIRE_COLON))
        cmd = ":";
    if (isKeyPressed(KEY_NSPIRE_COMMA)){
                if (isKeyPressed(KEY_NSPIRE_SHIFT))
                        cmd = ";";
                if (isKeyPressed(KEY_NSPIRE_CTRL))
                        cmd = "`";
                else
                        cmd = ",";
        }
    if (isKeyPressed(KEY_NSPIRE_QUESEXCL) || isKeyPressed(KEY_NSPIRE_QUES))
        cmd = isKeyPressed(KEY_NSPIRE_SHIFT) ? "!" : "?";
    if (isKeyPressed(KEY_NSPIRE_PLUS))
        cmd = isKeyPressed(KEY_NSPIRE_SHIFT) ? "&" : "+";
    if (isKeyPressed(KEY_NSPIRE_NEGATIVE) || isKeyPressed(KEY_NSPIRE_MINUS)) {
        if (isKeyPressed(KEY_NSPIRE_SHIFT))
            cmd = "_";
        if (isKeyPressed(KEY_NSPIRE_CTRL))
            cmd = "~";
        else
            cmd = "-";
    }
    if (isKeyPressed(KEY_NSPIRE_MULTIPLY))
        cmd = isKeyPressed(KEY_NSPIRE_SHIFT) ? "#" : "*";
    if (isKeyPressed(KEY_NSPIRE_DIVIDE)) {
        if (isKeyPressed(KEY_NSPIRE_SHIFT))
            cmd = "\\";
        if (isKeyPressed(KEY_NSPIRE_CTRL))
            cmd = "|";
        else
            cmd = "/";
    }
    if (isKeyPressed(KEY_NSPIRE_BAR))
        cmd = "|";
    if (isKeyPressed(KEY_NSPIRE_QUOTE))
        cmd = "\"";
    if (isKeyPressed(KEY_NSPIRE_APOSTROPHE))
        cmd = "'";
    if (isKeyPressed(KEY_NSPIRE_EXP)) {
        if (isKeyPressed(KEY_NSPIRE_SHIFT))
            cmd = "'";
        if (isKeyPressed(KEY_NSPIRE_CTRL))
            cmd = "\"";
        else
            cmd = "^";
    }
    if (isKeyPressed(KEY_NSPIRE_EQU)) {
        if (isKeyPressed(KEY_NSPIRE_SHIFT))
            cmd = ">";
        if (isKeyPressed(KEY_NSPIRE_CTRL))
            cmd = "<";
        else
            cmd = "= ";
    }
    if (isKeyPressed(KEY_NSPIRE_LTHAN))
        cmd = "<";
    if (isKeyPressed(KEY_NSPIRE_GTHAN))
        cmd = ">";
    if (isKeyPressed(KEY_NSPIRE_LP)) {
        if (isKeyPressed(KEY_NSPIRE_SHIFT))
            cmd = "[";
        if (isKeyPressed(KEY_NSPIRE_CTRL))
            cmd = "{";
        else
            cmd = "(";
    }
    if (isKeyPressed(KEY_NSPIRE_RP)) {
        if (isKeyPressed(KEY_NSPIRE_SHIFT))
            cmd = "]";
        if (isKeyPressed(KEY_NSPIRE_CTRL))
            cmd = "}";
        else
            cmd = ")";
    }
    if (isKeyPressed(KEY_NSPIRE_FLAG)) {
                if (isKeyPressed(KEY_NSPIRE_SHIFT))
                        cmd = "$";
                if (isKeyPressed(KEY_NSPIRE_CTRL))
                        cmd = "@";
        cmd = "%";
    }
    if(isKeyPressed(KEY_NSPIRE_ESC)) cmd = "ESC";
    if(isKeyPressed(KEY_NSPIRE_DEL)) cmd = "DEL";
    if(isKeyPressed(KEY_NSPIRE_ENTER)) cmd = "ENT";
    if(isKeyPressed(KEY_NSPIRE_RET)) cmd = "RET";
    if(isKeyPressed(KEY_NSPIRE_THETA)) cmd = "THETA";
    if(isKeyPressed(KEY_NSPIRE_eEXP)) cmd = "eEXP";
    if(isKeyPressed(KEY_NSPIRE_PI)) cmd = "PI";
    if(isKeyPressed(KEY_NSPIRE_TENX)) cmd = "TENX";
    if(isKeyPressed(KEY_NSPIRE_EE)) cmd = "EE";
    if(isKeyPressed(KEY_NSPIRE_SQU)) cmd = "SQU";
    if(isKeyPressed(KEY_NSPIRE_II)) cmd = "II";
    if(isKeyPressed(KEY_NSPIRE_TAN)) cmd = "TAN";
    if(isKeyPressed(KEY_NSPIRE_COS)) cmd = "COS";
    if(isKeyPressed(KEY_NSPIRE_SIN)) cmd = "SIN";
    if(isKeyPressed(KEY_NSPIRE_EXP)) cmd = "EXP";
    if(isKeyPressed(KEY_NSPIRE_CAT)) cmd = "CAT";
    if(isKeyPressed(KEY_NSPIRE_FRAC)) cmd = "FRAC";
    if(isKeyPressed(KEY_NSPIRE_VAR)) cmd = "VAR";
    if(isKeyPressed(KEY_NSPIRE_DEL)) cmd = "DEL";
    if(isKeyPressed(KEY_NSPIRE_FLAG)){ cmd = "FLAG";quit=true;}
    if(isKeyPressed(KEY_NSPIRE_CLICK)) cmd = "CLICK";
    if(isKeyPressed(KEY_NSPIRE_HOME)) cmd = "HOME";
    if(isKeyPressed(KEY_NSPIRE_MENU)) cmd = "MENU";
    if(isKeyPressed(KEY_NSPIRE_SHIFT)) cmd = "SHIFT";
    if(isKeyPressed(KEY_NSPIRE_CTRL)) cmd = "CTRL";
    if(isKeyPressed(KEY_NSPIRE_DOC)) cmd = "DOC";
    if(isKeyPressed(KEY_NSPIRE_TRIG)) cmd = "TRIG";
    if(isKeyPressed(KEY_NSPIRE_SCRATCHPAD)) cmd = "SCRPAD";

    uart_puts(cmd);
    uart_puts("!\n");
}

void padPushButton(){
    if(isKeyPressed(KEY_NSPIRE_UP)) cmd = "UP";
    if(isKeyPressed(KEY_NSPIRE_UPRIGHT)) cmd = "UPRIGHT";
    if(isKeyPressed(KEY_NSPIRE_RIGHT)) cmd = "RIGHT";
    if(isKeyPressed(KEY_NSPIRE_RIGHTDOWN)) cmd = "RIGHTDOWN";
    if(isKeyPressed(KEY_NSPIRE_DOWN)) cmd = "DOWN";
    if(isKeyPressed(KEY_NSPIRE_DOWNLEFT)) cmd = "DOWNLEFT";
    if(isKeyPressed(KEY_NSPIRE_LEFT)) cmd = "LEFT";
    if(isKeyPressed(KEY_NSPIRE_LEFTUP)) cmd = "LEFTUP";

    uart_puts(cmd);
    uart_puts("!\n");

}


static const int key_hook_addrs[] = {0x100B66C8, 0x100B6988,  // Clickpad / Touchpad 3.1
                                 0x100EAAAC, 0x100EADC4,  // CX 3.1
                                 0x100E72CC, 0x100E75E4,  // CM 3.1
                                 0x101122b8, 0x100eb288,  // Clickpad / Touchpad 3.6
                                 0x10111cfc, 0x1011201C, // CX 3.6
                                                                 0x101184C0, 0, // ClickPad / Touchpad 3.9.0
                                 0, 0, // ClickPad / Touchpad 3.9.1
                                 0, 0, // CX 3.9.0
                                                                 0, 0x101184B0, // CX 3.9.1
                                                                 0, 0, // CX 4.0.0
                                                                 0x1011EF68, 0x1011EDB8, // CX 4.0.3
                                                                0x1006A230, 0x10069cf0, // CX 4.2
                                                                };

static const int pad_hook_addrs[] = {0x100B66C8, 0x100B6988,  // Clickpad / Touchpad 3.1
                                 0x100EAAAC, 0x100EADC4,  // CX 3.1
                                 0x100E72CC, 0x100E75E4,  // CM 3.1
                                 0x101122b8, 0x100eb288,  // Clickpad / Touchpad 3.6
                                 0x10111cfc, 0x1011201C, // CX 3.6
                                                                 0x101184C0, 0, // ClickPad / Touchpad 3.9.0
                                 0, 0, // ClickPad / Touchpad 3.9.1
                                 0, 0, // CX 3.9.0
                                                                 0, 0x101184B0, // CX 3.9.1
                                                                 0, 0, // CX 4.0.0
                                                                 0x1011EF68, 0x1011EDB8, // CX 4.0.3
                                                                0x1022F2D0, 0x1022f834, // CX 4.2
                                                                };

HOOK_DEFINE(hook_keyPushButton){
    keyPushButton();
    HOOK_RESTORE_RETURN(hook_keyPushButton);
}
HOOK_DEFINE(hook_padPushButton){
    padPushButton();
    HOOK_RESTORE_RETURN(hook_padPushButton);
}

int main(int argc, char* argv[]){

    cmd = "URTX";
    uart_puts(cmd);
    uart_puts("!\n");
    HOOK_INSTALL(nl_osvalue((int*)pad_hook_addrs, sizeof(pad_hook_addrs)/sizeof(pad_hook_addrs[0])), hook_padPushButton);
    HOOK_INSTALL(nl_osvalue((int*)key_hook_addrs, sizeof(key_hook_addrs)/sizeof(key_hook_addrs[0])), hook_keyPushButton);
    nl_set_resident();
    return 0;
}


User avatar
MishaShapo
Niveau 3: MH (Membre Habitué)
Niveau 3: MH (Membre Habitué)
Level up: 68%
 
Posts: 17
Joined: 06 May 2016, 04:58
Gender: Not specified
Calculator(s):
MyCalcs profile

Re: Ndless KeyListener

Unread postby Vogtinator » 07 May 2016, 23:54

There is no HOME key on the CX, there's only the ON key. As none of your isKeyPressed tests apply, cmd remains unmodified.
I'm not sure what's going on with the touchpad, it works fine here on 4.2 CX CAS on firebird.
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: Ndless KeyListener

Unread postby MishaShapo » 07 May 2016, 23:58

Is there an isKeyPressed test for the ON Button? The CX has a home picture on it, so I figure it matched with

Code: Select all
  if(isKeyPressed(KEY_NSPIRE_HOME)) cmd = "HOME";


Let me try to reinstall a new image on firebird and test on an actual calculator to see if the touchpad behavior is also there.
User avatar
MishaShapo
Niveau 3: MH (Membre Habitué)
Niveau 3: MH (Membre Habitué)
Level up: 68%
 
Posts: 17
Joined: 06 May 2016, 04:58
Gender: Not specified
Calculator(s):
MyCalcs profile

Re: Ndless KeyListener

Unread postby Vogtinator » 08 May 2016, 00:04

Looks like the ON button is actually missing for CX.
In the meanwhile, use a custom
Code: Select all
static const t_key KEY_NSPIRE_ON = _KEY(0x10, 0x200);
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: Ndless KeyListener

Unread postby MishaShapo » 08 May 2016, 00:21

Vogtinator, I am going to go all out and just give you a rundown of my project in order to not keep you in the dark anymore.

I am trying to send keypresses from the Nspire through the USB port to an chinese Arduino Micro clone which then uses a wireless module https://arduino-info.wikispaces.com/Nrf24L01-2.4GHz-HowTo to connect to another Micro+wireless module on the computer which then uses the Arduino Keyboard and Mouse libraries to emulate a keyboard and a mouse. I even got everything to work using the Lua ASI library which is officially supported by TI https://education.ti.com/html/webhelp/EG_TINspireLUA/EN/content/libraries/stem-iolib/asilibrary.htm

The only problem was that the ASI library did not have key listeners for the ON, Doc, and Menu buttons. And more importantly, those Lua programs can't run in the background which makes for a pretty inconvenient user experience.

Anyway, so now you know. I suppose that my next plan of action is to look at the NavNet API. (I mistakenly though that the NspirIO uart meant the USB port, but now I suppose that it means the serial port on the doc connector). Also, the touchpad "blocking" bug is still there on my real-life non-CAS CX . And the cutsom ON key you suggested also works on firebird.
User avatar
MishaShapo
Niveau 3: MH (Membre Habitué)
Niveau 3: MH (Membre Habitué)
Level up: 68%
 
Posts: 17
Joined: 06 May 2016, 04:58
Gender: Not specified
Calculator(s):
MyCalcs profile

PreviousNext

Return to Native: Ndless, Linux, ...

Who is online

Users browsing this forum: ClaudeBot [spider] and 2 guests

-
Search
-
Social TI-Planet
-
Featured topics
Comparaisons des meilleurs prix pour acheter sa calculatrice !
"1 calculatrice pour tous", le programme solidaire de Texas Instruments. Reçois gratuitement et sans aucune obligation d'achat, 5 calculatrices couleur programmables en Python à donner aux élèves les plus nécessiteux de ton lycée. Tu peux recevoir au choix 5 TI-82 Advanced Edition Python ou bien 5 TI-83 Premium CE Edition Python.
Enseignant(e), reçois gratuitement 1 exemplaire de test de la TI-82 Advanced Edition Python. À demander d'ici le 31 décembre 2024.
Aidez la communauté à documenter les révisions matérielles en listant vos calculatrices graphiques !
1234
-
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.
1446 utilisateurs:
>1403 invités
>35 membres
>8 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)