The MASM Forum Archive 2004 to 2012

General Forums => The Workshop => Topic started by: travism on October 14, 2008, 09:36:05 AM

Title: convert keyboard scancodes to characters
Post by: travism on October 14, 2008, 09:36:05 AM
I searched around quiet awhile for this but I still haven't found an answer so Im sorry if this was answered before so Ill get to it So say we have 23 which is in ecx i want to be able to print it out to the screen as the character or scancode it is.. I thought it would be something with print uhex$() or something along those lines? but it doesnt seem to be printing.. THanks!
Title: Re: convert keyboard scancodes to characters
Post by: travism on October 14, 2008, 09:42:43 AM
Well I guess I could always use wsprintf... is there anything more efficient I could do?
Title: Re: convert keyboard scancodes to characters
Post by: MichaelW on October 14, 2008, 10:04:38 AM
Multiple things. This must be built as a console app.

; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
    include \masm32\include\masm32rt.inc
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
    .data
    .code
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
start:
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
    mov ebx, 23h
    print ustr$(ebx),13,10
    print uhex$(ebx),"h",13,10
    invoke crt_putchar, ebx
    print chr$(13,10)
    invoke crt_printf, chr$("%d%c%Xh%c%c%c"), ebx, 10, ebx, 10, ebx, 10

    inkey "Press any key to exit..."
    exit
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
end start


35
00000023h
#
35
23h
#


Title: Re: convert keyboard scancodes to characters
Post by: MichaelW on October 15, 2008, 06:05:47 AM
Regarding the keyboard scancode to character conversion, a scancode identifies a keyboard key, and while most keys do have a corresponding character, many do not (for example: function keys, cursor control keys, shift keys, etc).
Title: Re: convert keyboard scancodes to characters
Post by: travism on October 15, 2008, 11:43:48 PM
Thanks alot! I went with crt_putchar works great!