Login
Username:

Password:

Remember me



Lost Password?

Register now!

Sections

Who's Online
141 user(s) are online (125 user(s) are browsing Forums)

Members: 0
Guests: 141

more...

Support us!

Headlines

 
  Register To Post  

lowlevel.library problem??
Just can't stay away
Just can't stay away


See User information
I am experiencing werid behavior from lowlevel.library's GetKey function:

ABSEXECBASE    EQU 4

_LVOOpenLibrary        EQU 
-552
_LVOCloseLibrary    EQU 
-414

_LVODelay    EQU 
-198

_LVOGetKey    EQU 
-48


start
:
    
move.l    ABSEXECBASE.W,a6
    LEA    dos_name
,A1        ;0045243f900000f27
    MOVEQ    
#39,D0            ;00458: 7027
    
JSR    _LVOOpenLibrary(A6)        ;0045a4eaefdd8
    MOVE
.L    D0,DosBase        ;0045e23c000000f34
    BEQ 
exit


    
move.l    ABSEXECBASE.W,a6
    LEA    lowlevel_name
,A1        ;0045243f900000f27
    MOVEQ    
#39,D0            ;00458: 7027
    
JSR    _LVOOpenLibrary(A6)        ;0045a4eaefdd8
    MOVE
.L    D0,LowlevelBase        ;0045e23c000000f34
    BEQ 
exit

loop:
    
MOVEA.L    DosBase,A6
    MOVEQ 
#10,D1
    
JSR _LVODelay(A6)

    
MOVEA.L    LowlevelBase,A6
    JSR _LVOGetKey
(A6)
    
JSR debug_write_ulong
    CMPI
.L    #$45,D0
    
BNE loop


exit:
    
MOVEA.L    ABSEXECBASE.W,A6
    MOVEA
.L    LowlevelBase,A1
    JSR _LVOCloseLibrary
(A6)

    
MOVEA.L    ABSEXECBASE.W,A6
    MOVEA
.L    DosBase,A1
    JSR _LVOCloseLibrary
(A6)

    
MOVEQ    #0,D0
    
RTS

dos_name
:
    
DC.B    "dos.library",0
lowlevel_name
:
    
DC.B    "lowlevel.library",0,0

DosBase
:
    
DC.L    0
LowlevelBase
:
    
DC.L    0


_LVOPutStr        EQU 
-948

debug_buffer
:
    
DS.B    10

debug_write_ulong
:
    
MOVEM.L D0-D7/A0-A6, -(A7)

    
LEA        debug_buffer,A0
    MOVE
.B    #48,(A0)        ;'0'
    
MOVE.B    #120,1(A0)        ;'x'

    
MOVE.L    D0,D1
    SWAP    D1
    LSR
.L    #8,D1
    
LSR.L    #4,D1
    
ANDI.L    #$000f,D1
    
CMPI.B    #10,D1
    
BCS.S    lab_eq20
    SUBI
.B    #10,D1
    
ADDI.B    #97,D1
    
BRA.S    label20
lab_eq20
:
    
ADDI.B    #48,D1
label20:
    
MOVE.B    D1,2(A0)

    
MOVE.L    D0,D1
    SWAP    D1
    LSR
.L    #8,D1
    
ANDI.L    #$000f,D1
    
CMPI.B    #10,D1
    
BCS.S    lab_eq21
    SUBI
.B    #10,D1
    
ADDI.B    #97,D1
    
BRA.S    label21
lab_eq21
:
    
ADDI.B    #48,D1
label21:
    
MOVE.B D1,3(A0)

    
MOVE.L    D0,D1
    SWAP    D1
    LSR
.L    #4,D1
    
ANDI.L    #$000f,D1
    
CMPI.B    #10,D1
    
BCS.S    lab_eq22
    SUBI
.B    #10,D1
    
ADDI.B    #97,D1
    
BRA.S    label22
lab_eq22
:
    
ADDI.B    #48,D1
label22:
    
MOVE.B D1,4(A0)

    
MOVE.L    D0,D1
    SWAP D1
    ANDI
.W    #$000f,D1
    
CMPI.B    #10,D1
    
BCS.S    lab_eq23
    SUBI
.B    #10,D1
    
ADDI.B    #97,D1
    
BRA.S    label23
lab_eq23
:
    
ADDI.B    #48,D1
label23:
    
MOVE.B D1,5(A0)

    
MOVE.L    D0,D1
    LSR
.L    #8,D1
    
LSR.L    #4,D1
    
ANDI.W    #$000f,D1
    
CMPI.B    #10,D1
    
BCS.S    lab_eq24
    SUBI
.B    #10,D1
    
ADDI.B    #97,D1
    
BRA.S    label24
lab_eq24
:
    
ADDI.B    #48,D1
label24:
    
MOVE.B D1,6(A0)

    
MOVE.L    D0,D1
    LSR
.L    #8,D1
    
ANDI.W    #$000f,D1
    
CMPI.B    #10,D1
    
BCS.S    lab_eq25
    SUBI
.B    #10,D1
    
ADDI.B    #97,D1
    
BRA.S    label25
lab_eq25
:
    
ADDI.B    #48,D1
label25:
    
MOVE.B D1,7(A0)

    
MOVE.L    D0,D1
    LSR
.L    #4,D1
    
ANDI.W    #$000f,D1
    
CMPI.B    #10,D1
    
BCS.S    lab_eq26
    SUBI
.B    #10,D1
    
ADDI.B    #97,D1
    
BRA.S    label26
lab_eq26
:
    
ADDI.B    #48,D1
label26:
    
MOVE.B D1,8(A0)

    
MOVE.L    D0,D1
    ANDI
.W    #$000f,D1
    
CMPI.B    #10,D1
    
BCS.S    lab_eq27
    SUBI
.B    #10,D1
    
ADDI.B    #97,D1
    
BRA.S    label27
lab_eq27
:
    
ADDI.B    #48,D1
label27:
    
MOVE.B D1,9(A0)


    
MOVE.B    #10,10(A0)
    
MOVE.B    #0,11(A0)

    
MOVEA.L    DosBaseA6
    MOVE
.L    #debug_buffer,D1
    
JSR    _LVOPutStr(A6)

    
MOVEM.(A7)+, D0-D7/A0-A6
    RTS


Try assembling and running the above code (works with PhxAss). First time you run, it will write a line of 0's until you press a key. If you press ESC it will exit. But now the strange thing: The key you last pressed will get "stuck", even across runnings, so the next time you run it, it will exit immidiately with 0x45. I don't think this behavior is intended.

Also I have tested the QueryKeys function, and it doesn't seem to work at all...

Any enlightened comments are welcome!

Go to top
Re: lowlevel.library problem??
Not too shy to talk
Not too shy to talk


See User information
The debug_buffer is too short. You reserve 10 bytes but write 12 bytes (0x12345678, lf, 0). For me it prints two lines and then crashes. It does not crash if I comment the jsr debug_write_ulong and it works correctly if I increase the buffer to 20.


Go to top
Re: lowlevel.library problem??
Just can't stay away
Just can't stay away


See User information
@thomas

I have tried to set the size of the debug buffer to 20, and it doesn't change the behavior of the code at all, it still exits the second time with a value of $45.

Go to top
Re: lowlevel.library problem??
Not too shy to talk
Not too shy to talk


See User information

Amiga model?
OS version?
lowlevel.library version?

Go to top
Re: lowlevel.library problem??
Just can't stay away
Just can't stay away


See User information
Quote:
Amiga model?
OS version?
lowlevel.library version?


SAM-flex
OS4.1upd3
lowlevel.library 52.3

And yes I have also tried removing the debug output entirely.

EDIT: And I have a standard non-wireless Apple keyboard (USB).

Go to top
Re: lowlevel.library problem??
Not too shy to talk
Not too shy to talk


See User information

Ok, I tried WinUAE and there it works correctly. On OS4 (A1XE) it does what you say.

If you hold down the Esc key before the second run and lift it before the first message appears, the program continues with 0xff until you press Esc again.

So it seems like lowlevel.library only records events while a program is using it. As you leave the program when Esc is pressed, it does not recognise the release of the key.


Go to top
Re: lowlevel.library problem??
Supreme Council
Supreme Council


See User information
As with all libraries, the code contained within it runs on the callers context. So if the calling program has quit, then there's no caller left to call the vector again to clear the key press.

Perhaps exiting on ESC up rather than ESC down might be a better option.

Simon

Comments made in any post are personal opinion, and are in no-way representative of any commercial entity unless specifically stated as such.
----
http://codebench.co.uk
Go to top
Re: lowlevel.library problem??
Not too shy to talk
Not too shy to talk


See User information

The function is documented to return the currently pressed key. It does not say that you need to keep polling until no more keys are pressed. It also says nothing about the maximium time between calls.

This means the function needs to return the current keyboard state even if it is called only once. How this is implemented is up to the maintainer of the library, not of the application programmer. If the library does not recognise key-up events after the application ends (or if the application is busy), this clearly is a bug.


Go to top
Re: lowlevel.library problem??
Just can't stay away
Just can't stay away


See User information
I must agree with thomas, I think this is clearly buggy behavior, first of all because it doesn't do what the autodocs describe, and it doesn't have the same odd behavior on classic amigas. If the current behavior is "intended", it should be at least documented as such in the docs.

Go to top
Re: lowlevel.library problem??
Home away from home
Home away from home


See User information
@Alfkil & Thomas
If someone could write a little C program to demonstrate the problem behaviour, then I could officially report it.

Author of the PortablE programming language.
Go to top
Re: lowlevel.library problem??
Not too shy to talk
Not too shy to talk


See User information

I cannot verify if it does the same because I am not sitting at my A1 right now, but this is basically the program of Alfkil:

#include <proto/dos.h>
#include <proto/lowlevel.h>

int main (void)

{
ULONG key;

do    {
    
Delay (10);
    
key GetKey();
    
Printf ("0x%08lx\n",key);
    }
while (
key != 0x45);

return (
0);
}

Go to top
Re: lowlevel.library problem??
Home away from home
Home away from home


See User information
@thomas
Compile your exampe on peg2/os4u3, like this:
Quote:

gcc -D__USE_INLINE__ test.c -o test -lauto


And its works a bit buggy looks like indeed.. Sometime works, sometime not. I.e. i run it from shell, then press "esc", it draw some character [ in the shell, then backspace, and sometime i have 0x000000045 and exit, but sometime just not. Sometime it exit from first try of esc/backspace, sometime only on 4-5 time.

Join us to improve dopus5!
AmigaOS4 on youtube
Go to top
Re: lowlevel.library problem??
Just can't stay away
Just can't stay away


See User information
@kas1e

I think the problem is with the dos function Printf. If you insert a #include <stdio.h> and change the P to a p (notice the lower caption), it should work as expected.

EDIT: Oh and the n in the end of the first printf argument should be a \n!

Go to top
Re: lowlevel.library problem??
Not too shy to talk
Not too shy to talk


See User information

Printf (with upper case P) ist just fine.

You need to understand that lowlevel.library does not capture input. It just returns the state of input devices at a very low level. It does not influence the input stream in any way.

So if you press any key while the CLI window is active, the key will be printed into the window and output is stopped. In order to continue output you have to delete the printed keys. That's the same with all non-dead keys on the keyboard.


Go to top
Re: lowlevel.library problem??
Just can't stay away
Just can't stay away


See User information
@thomas

Yes you are right, I don't know what I was thinking...

Go to top
Re: lowlevel.library problem??
Just can't stay away
Just can't stay away


See User information
@thread

Is this still relevant?

Go to top
Re: lowlevel.library problem??
Home away from home
Home away from home


See User information
@alfkil

Yes I think so, had make work around in Amos Kittens, becouse key up press was sent to the wrong window (ASL Window), not the window key press down press was sendt to..

(NutsAboutAmiga)

Basilisk II for AmigaOS4
AmigaInputAnywhere
Excalibur
and other tools and apps.
Go to top

  Register To Post

 




Currently Active Users Viewing This Thread: 1 ( 0 members and 1 Anonymous Users )




Powered by XOOPS 2.0 © 2001-2024 The XOOPS Project