1,8 → 1,8 |
; |
; MyKey. Version 0.1. |
; MyKey. Version 0.2. |
; |
; Author: Asper |
; Date of issue: 04.12.2009 |
; Date of issue: 29.12.2009 |
; Compiler: FASM |
; Target: KolibriOS |
; |
10,17 → 10,21 |
use32 |
org 0x0 |
|
db 'MENUET00' ; 8 byte id |
db 'MENUET01' ; 8 byte id |
dd 38 ; required os |
dd STARTAPP ; program start |
dd I_END ; program image size |
dd 0x1000000 ; required amount of memory |
dd 0x00000000 ; reserved=no extended header |
dd 0x1000000 ; stack heap |
dd 0x0 |
dd app_path |
|
include "aspAPI.inc" |
include 'aspAPI.inc' |
include 'string.inc' |
include 'macros.inc' |
include 'editbox_ex.mac' |
include 'load_lib.mac' |
include 'dll.inc' |
|
include 'debug.inc' |
DEBUG equ 0;1 |
27,20 → 31,25 |
|
N_KEYCOLOR equ 0x00EEEEEE ; Normal button color |
C_KEYCOLOR equ 0x00CBE1E1 ; Control button color |
A_KEYCOLOR equ 0x000099BB;258778 ; Active button color |
A_KEYCOLOR equ 0x00FF6400;258778 ; Active button color |
C_TEXTCOLOR equ 0x80000000 ; Button caption color |
CA_TEXTCOLOR equ 0x80FFFFFF ; Active button caption color |
A_TEXTCOLOR equ 0x00FFFFFF ; Active text color |
|
WIN_X equ 265 |
WIN_Y equ 50;175 |
WIN_W equ 595 |
WIN_H equ 415 ;570 |
WIN_COLOR equ 0x04EEEEEE |
WIN_COLOR equ 0x040099BB;0x04EEEEEE |
|
BUT_W equ 192;100 |
BUT_H equ 23 |
BUT_SPACE equ 0 |
ITEM_BUTTON_W equ 192;100 |
ITEM_BUTTON_H equ 23 |
ITEM_BUTTON_SPACE equ 0 |
FIRST_ITEM_BUTTON_ID equ 7 |
|
BUT_W equ 80 |
BUT_H equ 20 |
|
MAX_HOTKEYS_NUM equ 15 ; Bad bounding :/. Until we have normal listbox control. |
PATH_MAX_CHARS equ 255 |
|
47,42 → 56,66 |
@use_library |
|
STARTAPP: |
; Initialize memory |
mcall 68, 11 |
or eax,eax |
jz close_app |
; Import libraries |
sys_load_library boxlib_name, sys_path, boxlib_name, system_dir0, err_message_found_lib, head_f_l, myimport,err_message_import, head_f_i |
cmp eax,-1 |
jz close_app |
;mcall 68,11 |
;or eax,eax |
;jz close_app |
stdcall dll.Load,importTable |
test eax, eax |
jnz close_app |
|
; Get memory for editboxes text |
mcall 68, 12, MAX_HOTKEYS_NUM*PATH_MAX_CHARS |
mov dword [buf_cmd_line], eax |
mov dword [edit1.text], eax |
mcall 68, 12, MAX_HOTKEYS_NUM*PATH_MAX_CHARS |
mov dword [buf_cmd_params], eax |
mov dword [edit2.text], eax |
mcall 68, 12, MAX_HOTKEYS_NUM*32 |
mov dword [it_buf_cmd_line], eax |
mov dword [it_edit.text], eax |
|
call Load_HotkeyList |
|
mcall 66, 1, 1 ; Set keyboard mode to get scancodes. |
mcall 26, 2, 1, ascii_keymap |
|
;get_mykey_window_slot_number: |
; mcall 5, 10 ;wait |
; mcall 18, 7 |
; mov [mykey_window], eax |
get_mykey_window_slot_number: |
call draw_window |
mcall 18, 7 |
mov [mykey_window], eax |
|
set_event_mask: |
mcall 40, 39 |
|
red: |
; .test_slot: |
; mov eax, [mykey_window] ; Test is receiver MyKey window |
; mov ecx, [it_window] |
; cmp eax, ecx |
; je @f;still ; if yes still. |
; .activate_it_window: |
; mov eax, 18 |
; mov ebx, 3 |
; int 0x40 |
; @@: |
.test_slot: |
mcall 18, 7 |
mov ebx, [mykey_window] |
cmp eax, ebx |
jne @f |
|
mov ecx, [it_window] |
cmp ebx, ecx |
je @f |
.activate_it_window: |
mov al, byte [it_alive] |
test al, al |
jz @f |
mov byte [it_alive], 0 |
|
mcall 18, 3 ; Activate input thread window |
@@: |
call draw_window |
|
still: |
call reset_modifiers |
|
mov eax, 10 ; Wait for an event in the queue. |
int 0x40 |
mcall 10 ; Wait for an event in the queue. |
|
cmp al,1 ; redraw request ? |
jz red |
96,19 → 129,16 |
jmp still |
|
key: |
mov eax, 2 |
int 0x40 |
mcall 2 |
|
push eax |
mcall 66, 3 |
mov edx, eax |
and edx, 0x00000FFF |
mov dword [modifiers], edx |
mov dword [modifiers], eax |
pop eax |
|
test word [edit1.flags], 10b;ed_focus ; ¥á«¨ ¥ ¢ 䮪ãá¥, ¢ë室¨¬ |
test word [edit1.flags], 10b |
jnz .editbox_input |
test word [edit2.flags], 10b;ed_focus ; ¥á«¨ ¥ ¢ 䮪ãá¥, ¢ë室¨¬ |
test word [edit2.flags], 10b |
jz @f |
.editbox_input: |
cmp ah, 0x80 ;if key up |
124,9 → 154,7 |
cmp ah, 69 ;Pause/Break |
je still |
|
; cmp [keyUpr],0 |
; jne still |
|
mov esi, ascii_keymap |
call Scan2ASCII |
|
push dword edit1 |
143,14 → 171,13 |
dec cl |
mov bl, cl |
and ebx, 0xFF |
shl ebx, 5 |
mov esi, ebx |
shl ebx, 2 |
add ebx, dword Hotkeys.codes |
|
cmp ah, byte [ebx] |
mov edx, dword [ebx] |
cmp ah, dl |
jne @f |
|
mov edx, dword [ebx] |
shr edx, 8 |
cmp edx, dword [modifiers] |
jne @f |
159,15 → 186,15 |
mov eax, PATH_MAX_CHARS |
mul cl |
mov edx, eax |
add edx, dword buf_cmd_params |
add eax, dword buf_cmd_line |
add edx, dword [buf_cmd_params] |
add eax, dword [buf_cmd_line] |
mov esi, eax |
pop eax |
call RunProgram |
jmp .end_test |
@@: |
or cl, cl ;cmp cl, 0 |
jnz .test_next_hotkey ;jge .test_next_hotkey |
or cl, cl |
jnz .test_next_hotkey |
.end_test: |
;------------------------ |
|
174,8 → 201,7 |
jmp still |
|
button: |
mov eax, 17 ; Get pressed button code |
int 0x40 |
mcall 17 ; Get pressed button code |
cmp ah, 1 ; Test x button |
je close_app |
|
184,30 → 210,34 |
call AddHotKey |
jmp red |
@@: |
cmp ah, 5 |
jne @f |
call Load_HotkeyList |
jmp red |
@@: |
cmp ah, 6 |
jne @f |
call WriteIni |
xor edx, edx |
mov esi, aRamSaver |
call RunProgram |
@@: |
|
cmp ah, 5 ; Test if pressed buttons |
cmp ah, FIRST_ITEM_BUTTON_ID ; Test if pressed buttons |
jb still ; is a HotKey button... |
mov al, ah |
sub al, 5 |
sub al, FIRST_ITEM_BUTTON_ID |
cmp al, byte [hotkeys_num] |
jnb still ; ...so, if not then still, |
|
|
mov byte [butt], ah ; if yes then save pressed button ID |
and eax, 0xFF;shr ax, 8 |
if DEBUG |
dps "Button = " |
dph eax |
end if |
and eax, 0xFF |
mov cl, byte PATH_MAX_CHARS |
mul cl |
if DEBUG |
dps " offset = " |
dph eax |
end if |
mov ebx, eax |
add ebx, dword buf_cmd_params |
add eax, dword buf_cmd_line |
add ebx, dword [buf_cmd_params] |
add eax, dword [buf_cmd_line] |
|
mov dword [edit1.text], eax |
mov dword [edit2.text], ebx |
214,11 → 244,6 |
|
mov esi, eax |
call strlen |
if DEBUG |
dps " len = " |
dph ecx |
newline |
end if |
mov dword [edit1.size], ecx |
mov dword [edit1.pos], ecx |
|
227,17 → 252,14 |
mov dword [edit2.size], ecx |
mov dword [edit2.pos], ecx |
|
jmp red ;still |
jmp red |
|
mouse: |
push dword edit1 |
call [edit_box_mouse] |
|
push dword edit2 |
call [edit_box_mouse] |
|
;test word [edit1.flags],10b;ed_focus ; ¥á«¨ ¥ ¢ 䮪ãá¥, ¢ë室¨¬ |
;jne still |
jmp still |
|
|
249,17 → 271,25 |
draw_window: |
start_draw_window WIN_X,WIN_Y,WIN_W,WIN_H,WIN_COLOR,labelt, 11;labellen-labelt |
|
;bar 5, 24, 585, 385, 0x800000 or 0x90D2 |
;rectangle2 6, 25, 585, 385, 0xFFFFFF, 0 |
|
;bar 5, 24, BUT_W+4, 350, 0x008C00D2;0x800000 or A_KEYCOLOR |
;rectangle2 6, 25, BUT_W+4, 350, 0xFFFFFF, 0 |
|
|
push dword edit1 |
call [edit_box_draw] |
|
push dword edit2 |
call [edit_box_draw] |
|
stdcall draw_button, 7,WIN_H-30,80,20,2,C_KEYCOLOR,AddKeyText, 0,C_TEXTCOLOR ; Add Hot key. |
stdcall draw_button, 7,WIN_H-BUT_H-10,BUT_W,BUT_H,2,0x0050D250,AddKeyText, 0,C_TEXTCOLOR ; Add Hotkey. |
if 0 |
stdcall draw_button, 90,WIN_H-30,80,20,3,C_KEYCOLOR,DeleteKeyText,0,C_TEXTCOLOR ; Delete Hot key. |
stdcall draw_button, 173,WIN_H-30,80,20,4,C_KEYCOLOR,ManageKeyText,0,C_TEXTCOLOR ; Manage Hot key. |
stdcall draw_button, 90,WIN_H-BUT_H-10,BUT_W,BUT_H,3,C_KEYCOLOR,DeleteKeyText,0,C_TEXTCOLOR ; Delete Hotkey. |
stdcall draw_button, 173,WIN_H-BUT_H-10,BUT_W,BUT_H,4,C_KEYCOLOR,ManageKeyText,0,C_TEXTCOLOR ; Manage Hotkey. |
end if |
stdcall draw_button, WIN_W-BUT_W*2-14,WIN_H-BUT_H-10,BUT_W,BUT_H,5,0x0050D250,ReloadKeyText, 0,C_TEXTCOLOR ; Save Hotkeys list. |
stdcall draw_button, WIN_W-BUT_W-7,WIN_H-BUT_H-10,BUT_W,BUT_H,6,0x0050D250,SaveKeyText, 0,C_TEXTCOLOR ; Save Hotkeys list. |
|
movzx ecx, byte [hotkeys_num] |
cmp ecx, MAX_HOTKEYS_NUM |
267,25 → 297,32 |
mov ecx, MAX_HOTKEYS_NUM |
@@: |
mov eax, 30 |
mov ebx, 5 |
mov ebx, FIRST_ITEM_BUTTON_ID |
@@: |
or cl, cl |
jz @f |
|
mov edx, ebx |
sub edx, 5 |
sub edx, FIRST_ITEM_BUTTON_ID |
shl edx, 5; edx=edx*32 |
add edx, dword Hotkeys |
|
cmp bl, byte [butt] |
jne .l1 |
stdcall draw_button, 7,eax,BUT_W,BUT_H,ebx,A_KEYCOLOR,edx,0,CA_TEXTCOLOR ; F5 |
stdcall draw_button, 7,eax,ITEM_BUTTON_W,ITEM_BUTTON_H,ebx,A_KEYCOLOR ,edx,0,CA_TEXTCOLOR |
bar 220, 70, 350, 30, 0x00C8E1F0 ;0x800000 or A_KEYCOLOR |
rectangle2 221, 71, 350, 30, 0xFFFFFF, 0 |
mov esi, Hotkeys.code_names |
sub edx, dword Hotkeys |
shl edx, 1 |
add esi, edx |
stdcall outtextxy, 225, 80, esi, 64, C_TEXTCOLOR |
jmp .l2 |
.l1: |
stdcall draw_button, 7,eax,BUT_W,BUT_H,ebx,N_KEYCOLOR,edx,0,C_TEXTCOLOR ; F5 |
stdcall draw_button, 7,eax,ITEM_BUTTON_W,ITEM_BUTTON_H,ebx,N_KEYCOLOR,edx,0,C_TEXTCOLOR |
.l2: |
|
add eax, BUT_H+BUT_SPACE |
add eax, ITEM_BUTTON_H+ITEM_BUTTON_SPACE |
inc ebx |
dec cl |
jmp @b |
301,16 → 338,41 |
inc al |
mov byte [hotkeys_num], al |
|
mov eax, 51 |
mov ebx, 1 |
mov ecx, start_input_thread |
mov edx, dword input_thread_stack_top |
mcall |
|
mcall 51, 1, dword start_input_thread, dword input_thread_stack_top |
.end: |
ret |
|
|
Load_HotkeyList: |
call ReadIni |
|
mov al, byte [butt] |
mov ah, byte [hotkeys_num] |
cmp al, ah |
jle @f |
mov al, ah |
@@: |
and eax, 0xFF |
sub al, FIRST_ITEM_BUTTON_ID |
mov cl, byte PATH_MAX_CHARS |
mul cl |
mov ebx, eax |
add eax, dword [buf_cmd_line] |
add ebx, dword [buf_cmd_params] |
|
|
mov esi, eax |
call strlen |
mov dword [edit1.size], ecx |
mov dword [edit1.pos], ecx |
|
mov esi, ebx |
call strlen |
mov dword [edit2.size], ecx |
mov dword [edit2.pos], ecx |
ret |
|
|
reset_modifiers: |
pusha |
mov esi, dword [it_hotkey_addr] |
319,7 → 381,8 |
|
lodsd |
|
mov cl, al ; set new hotkey |
; Set new hotkey for the main thread |
mov cl, al |
shr eax, 8 |
|
xor edx, edx |
354,6 → 417,7 |
pop cx |
|
mcall 66, 4 |
mov dword [it_hotkey_addr], 0 |
.end_set_mods: |
popa |
ret |
362,18 → 426,10 |
;######################## Input Thread code start ########################## |
|
start_input_thread: |
|
;get_it_window_slot_number: |
; mcall 5, 10 ;wait |
; mcall 18, 7 |
; mov [it_window], eax |
mov ecx, 1 ; to get scancodes. |
mov eax, 66 |
mov ebx, 1 ; Set keyboard mode |
int 0x40 |
mcall 26, 2, 1, ascii_keymap |
mcall 26, 2, 1, it_ascii_keymap |
mcall 66, 1 ; Set keyboard mode |
mov dword [it_hotkey_addr], 0 |
|
it_set_editbox: |
mov al, byte [hotkeys_num] |
sub al, 1 |
386,8 → 442,11 |
call strlen |
mov dword [it_edit.size], ecx |
mov dword [it_edit.pos], ecx |
get_it_window_slot_number: |
call it_draw_window |
mcall 18, 7 |
mov [it_window], eax |
|
|
it_set_event_mask: |
mcall 40, 39 |
it_red: |
394,8 → 453,7 |
call it_draw_window |
|
it_still: |
mov eax, 10 ; Wait for an event in the queue. |
int 0x40 |
mcall 10 ; Wait for an event in the queue. |
|
cmp al,1 ; redraw request ? |
jz it_red |
402,7 → 460,7 |
cmp al,2 ; key in buffer ? |
jz it_key |
cmp al,3 ; button in buffer ? |
jz button |
jz it_button |
cmp al,6 |
jz it_mouse |
|
409,11 → 467,17 |
jmp it_still |
|
it_key: |
mov eax, 2 |
int 0x40 |
mcall 2 |
|
mov byte [it_keycode], 0 |
stdcall outtextxy, 10, 100, ctrl_key_names, 35, 0 |
|
cmp ah, 1 ;Esc |
jne @f |
dec byte [hotkeys_num] |
jmp close_app |
@@: |
|
cmp ah, 0x80 ;if key up |
ja .end |
cmp ah, 42 ;[Shift] (left) |
427,38 → 491,11 |
cmp ah, 69 ;[Pause Break] |
je .end |
|
|
;------------------------ |
mov cl, byte [hotkeys_num] |
.test_next_hotkey: |
mov bl, cl |
and ebx, 0xFF |
shl ebx, 5 |
mov esi, ebx |
add ebx, dword Hotkeys.codes |
cmp ah, byte [ebx] |
jne @f |
|
push eax |
mov eax, PATH_MAX_CHARS |
mul cl |
add eax, dword buf_cmd_line |
mov esi, eax |
pop eax |
mov edx, 0 ; no parametrs yet <- change it! |
call RunProgram |
jmp .end_test |
@@: |
dec cl |
cmp cl, 0 |
jge .test_next_hotkey |
.end_test: |
;------------------------ |
|
mov byte [it_keycode], ah |
mov esi, it_ascii_keymap |
call Scan2ASCII |
|
test word [it_edit.flags], 10b;ed_focus ; ¥á«¨ ¥ ¢ 䮪ãá¥, ¢ë室¨¬ |
test word [it_edit.flags], 10b |
jz .end |
push dword it_edit |
call [edit_box_key] |
465,7 → 502,15 |
jmp it_still |
.end: |
|
mcall 26, 2, 1, it_ascii_keymap |
call it_test_key_modifiers |
test dl, 3 |
jz @f |
push edx |
mcall 26, 2, 2, it_ascii_keymap |
pop edx |
@@: |
|
mov al, byte [it_keycode] |
test al, al |
jz @f |
475,10 → 520,13 |
mov eax, dword [it_hotkey_addr] |
test eax, eax |
jnz @f |
|
call it_set_keycode_name |
|
mov al, byte [hotkeys_num] |
sub al, 1 |
dec al |
and eax, 0xFF |
shl eax, 5 |
shl eax, 2;5 |
add eax, dword Hotkeys.codes |
mov dword [eax], edx |
mov dword [it_hotkey_addr], eax |
495,35 → 543,127 |
push eax |
mcall 66, 3 ;get control keys state |
mov edx, eax |
and edx, 0x00000FFF |
.lshift: |
test al, 1 ; LShift ? |
jz .rshift |
stdcall outtextxy, 10, 100, ctrl_key_names, 6, 0x00FF0000 |
stdcall outtextxy, 10, 100, ctrl_key_names, 6, A_TEXTCOLOR |
.rshift: |
test al, 2 ; RShift ? |
jz .lctrl |
stdcall outtextxy, 184, 100, ctrl_key_names+29, 6, 0x00FF0000 |
stdcall outtextxy, 184, 100, ctrl_key_names+29, 6, A_TEXTCOLOR |
.lctrl: |
test al, 4 ; LCtrl ? |
jz .rctrl |
stdcall outtextxy, 52, 100, ctrl_key_names+7, 5, 0x00FF0000 |
stdcall outtextxy, 52, 100, ctrl_key_names+7, 5, A_TEXTCOLOR |
.rctrl: |
test al, 8 ; RCtrl ? |
jz .lalt |
stdcall outtextxy, 148, 100, ctrl_key_names+23, 5, 0x00FF0000 |
stdcall outtextxy, 148, 100, ctrl_key_names+23, 5, A_TEXTCOLOR |
.lalt: |
test al, 0x10 ; LAlt ? |
jz .ralt |
stdcall outtextxy, 88, 100, ctrl_key_names+13, 4, 0x00FF0000 |
stdcall outtextxy, 88, 100, ctrl_key_names+13, 4, A_TEXTCOLOR |
.ralt: |
test al, 0x20 ; RAlt ? |
jz @f |
stdcall outtextxy, 118, 100, ctrl_key_names+18, 4, 0x00FF0000 |
stdcall outtextxy, 118, 100, ctrl_key_names+18, 4, A_TEXTCOLOR |
@@: |
pop eax |
ret |
|
|
it_set_keycode_name: |
pusha |
mov al, byte [hotkeys_num] |
dec al |
and eax, 0xFF |
shl eax, 6 |
mov edi, Hotkeys.code_names |
add edi, eax |
|
mov ecx, 64 |
xor ax, ax |
call strnset |
mcall 66, 3 ;get control keys state |
.lshift: |
test al, 1 ; LShift ? |
jz .rshift |
mov esi, ctrl_key_names |
mov ecx, 6 |
call strncat |
|
mov esi, aPlus |
mov ecx, 3 |
call strncat |
.rshift: |
test al, 2 ; RShift ? |
jz .lctrl |
mov esi, ctrl_key_names+29 |
mov ecx, 6 |
call strncat |
|
mov esi, aPlus |
mov ecx, 3 |
call strncat |
.lctrl: |
test al, 4 ; LCtrl ? |
jz .rctrl |
mov esi, ctrl_key_names+7 |
mov ecx, 5 |
call strncat |
|
mov esi, aPlus |
mov ecx, 3 |
call strncat |
.rctrl: |
test al, 8 ; RCtrl ? |
jz .lalt |
mov esi, ctrl_key_names+23 |
mov ecx, 5 |
call strncat |
|
mov esi, aPlus |
mov ecx, 3 |
call strncat |
.lalt: |
test al, 0x10 ; LAlt ? |
jz .ralt |
mov esi, ctrl_key_names+13 |
mov ecx, 4 |
call strncat |
|
mov esi, aPlus |
mov ecx, 3 |
call strncat |
.ralt: |
test al, 0x20 ; RAlt ? |
jz @f |
mov esi, ctrl_key_names+18 |
mov ecx, 4 |
call strncat |
|
mov esi, aPlus |
mov ecx, 3 |
call strncat |
@@: |
mov esi, it_ascii_keymap |
and edx, 0xFF |
add esi, edx |
mov ecx, 1 |
call strncat |
|
popa |
ret |
|
|
it_button: |
mcall 17 ; Get pressed button code |
cmp ah, 1 ; Test x button |
jne @f |
jmp close_app |
@@: |
jmp it_still |
|
it_mouse: |
|
push dword it_edit |
532,23 → 672,188 |
jmp it_still |
|
it_draw_window: |
start_draw_window WIN_X,WIN_Y+250,225,70,WIN_COLOR,it_labelt, 26;labellen-labelt |
start_draw_window 450,WIN_Y+250,225,70,WIN_COLOR,it_labelt, 26;labellen-labelt |
|
push dword it_edit |
call [edit_box_draw] |
|
stdcall outtextxy, 10, 100, ctrl_key_names, 35, 0 |
stdcall outtextxy, 43, 50, it_hint, 0, 0x323232 |
stdcall outtextxy, 10, 100, ctrl_key_names, 0, 0 |
;stdcall draw_button, 7,WIN_H-30,80,20,2,C_KEYCOLOR,AddKeyText, 0,C_TEXTCOLOR ; Add Hot key. |
end_draw_window |
mov byte [it_alive], 1 |
ret |
|
|
;######################## Input Thread code end ########################## |
|
|
; Read configuration file |
ReadIni: |
; Get path |
mov edi, ini_path |
mov esi, app_path |
call strlen |
|
.get_path: |
cmp byte [app_path+ecx-1], '/' |
je @f |
loop .get_path |
@@: |
call strncpy |
mov byte [ini_path+ecx], 0 |
mov esi, aIni |
call strlen |
call strncat |
|
; Get hotkey number |
invoke ini_get_int, ini_path, aMain, aKeynum, 0 |
|
and eax, 0xFF |
test al, al |
jz .end |
cmp al, MAX_HOTKEYS_NUM |
jle @f |
mov al, MAX_HOTKEYS_NUM |
@@: |
mov byte [hotkeys_num], al |
|
mov ecx, eax |
xor eax, eax |
.get_next_hotkey_values: |
call set_next_hotkey_section_name |
; Get hotkey name |
mov edi, eax |
shl edi, 5 ; edi=eax*32 |
add edi, dword Hotkeys |
push eax ecx |
invoke ini_get_str, ini_path, aHotkey, aName, edi, 32, 0 |
pop ecx eax |
; Get hotkey code |
mov edi, eax |
shl edi, 2 ; edi=eax*4 |
add edi, dword Hotkeys.codes |
push eax ecx edx |
invoke ini_get_int, ini_path, aHotkey, aKeycode, 0 |
mov dword [it_hotkey_addr], edi |
stosd |
; set hotkey |
call reset_modifiers |
pop edx ecx eax |
; Get hotkey code_name |
mov edi, eax |
shl edi, 6 ; edi=eax*64 |
add edi, dword Hotkeys.code_names |
push eax ecx |
invoke ini_get_str, ini_path, aHotkey, aKeycodeName, edi, 64, 0 |
pop ecx eax |
; Get hotkey path and param |
push eax ecx |
mov cl, byte PATH_MAX_CHARS |
mul cl |
mov edi, eax |
push edi |
add edi, dword [buf_cmd_line] |
invoke ini_get_str, ini_path, aHotkey, aPath, edi, 32, 0 |
pop edi |
add edi, dword [buf_cmd_params] |
invoke ini_get_str, ini_path, aHotkey, aParam, edi, 32, 0 |
pop ecx eax |
|
inc al |
dec ecx |
test ecx, ecx |
jnz .get_next_hotkey_values |
.end: |
ret |
|
|
; Write configuration file |
WriteIni: |
mov edi, ini_path |
; Set hotkey number |
movzx ecx, byte [hotkeys_num] |
invoke ini_set_int, ini_path, aMain, aKeynum, ecx |
|
xor eax, eax |
.get_next_hotkey_values: |
call set_next_hotkey_section_name |
; Set hotkey name |
push eax ecx |
mov esi, eax |
shl esi, 5 ; edi=eax*32 |
add esi, dword Hotkeys |
call strlen |
invoke ini_set_str, ini_path, aHotkey, aName, esi, ecx |
pop ecx eax |
; Set hotkey code |
mov esi, eax |
shl esi, 2 ; edi=eax*4 |
add esi, dword Hotkeys.codes |
push eax ecx edx |
invoke ini_set_int, ini_path, aHotkey, aKeycode, dword [esi] |
pop edx ecx eax |
; Set hotkey code_name |
mov esi, eax |
shl esi, 6 ; edi=eax*64 |
add esi, dword Hotkeys.code_names |
push eax ecx |
call strlen |
invoke ini_set_str, ini_path, aHotkey, aKeycodeName, esi, ecx |
pop ecx eax |
; Set hotkey path and param |
push eax ecx |
;inc al |
mov cl, byte PATH_MAX_CHARS |
mul cl |
mov esi, eax |
push esi |
add esi, dword [buf_cmd_line] |
call strlen |
invoke ini_set_str, ini_path, aHotkey, aPath, esi, ecx |
pop esi |
add esi, dword [buf_cmd_params] |
call strlen |
invoke ini_set_str, ini_path, aHotkey, aParam, esi, ecx |
pop ecx eax |
|
inc al |
dec ecx |
test ecx, ecx |
jnz .get_next_hotkey_values |
.end: |
ret |
|
|
set_next_hotkey_section_name: ;(eax - num) |
; this code mainly from debug.inc |
push eax ecx edi |
mov edi, aHotkey |
add edi, 6 ; + strlen("hotkey") |
mov ecx, 10 |
push -'0' |
.l0: |
xor edx, edx |
div ecx |
push edx |
test eax, eax |
jnz .l0 |
.l1: |
pop eax |
add al, '0' |
;call debug_outchar |
stosb |
jnz .l1 |
pop edi ecx eax |
ret |
|
|
;**************************************** |
;* input: esi = pointer to keymap * |
;* ah = scan code * |
;* output: ah = ascii code * |
;**************************************** |
Scan2ASCII: |
push esi |
mov esi, ascii_keymap |
shr eax, 8 |
add esi, eax |
lodsb |
557,22 → 862,6 |
ret |
|
|
;**************************************** |
;* input: esi = pointer to string * |
;* output: ecx = length of the string * |
;**************************************** |
strlen: |
push eax |
xor ecx, ecx |
@@: |
lodsb |
or al, al |
jz @f |
inc ecx |
jmp @b |
@@: |
pop eax |
ret |
|
;******************************************** |
;* input: esi = pointer to the file name * |
588,9 → 877,7 |
mov dword [InfoStructure+16], 0 ; reserved |
mov dword [InfoStructure+20], 0 ; reserved |
mov dword [InfoStructure+21], esi ; pointer to the file name |
mov eax, 70 |
mov ebx, InfoStructure |
int 0x40 |
mcall 70, InfoStructure |
cmp eax, 0 |
jl .err_out |
.out: |
607,8 → 894,8 |
; DATA AREA |
|
; Application Title |
labelt db 'MyKey v.0.1' |
;mykey_window dd 0 ; Slot number of MyKey |
labelt db 'MyKey v.0.2' |
mykey_window dd 0 ; Slot number of MyKey main thread |
|
|
;########### Input Thread data start ############ |
617,21 → 904,24 |
it_labelt db "Input hotkey and it's name" |
;labellen: |
it_edit edit_box 180, 20, 30, 0xffffff, 0xAA80, 0x0000ff, 0x0, 0x0, 31, it_buf_cmd_line, 0, 0 |
it_buf_cmd_line db MAX_HOTKEYS_NUM*32 dup(0) ; !Make it dinamyc!!! |
;it_window dd 0 ; Slot number of Input thread |
it_buf_cmd_line dd 0 ;db MAX_HOTKEYS_NUM*32 dup(0) ; !Make it dynamic!!! |
it_window dd 0 ; Slot number of the input thread |
it_alive db 0 ; Flag of the input thread existance |
it_keycode db 0 |
it_hotkey_addr dd 0 |
it_hint db 'or press Esc to cancel',0 |
;########### Input Thread data end ############ |
|
;Button names |
AddKeyText db 'Add',0 |
DeleteKeyText db 'Delete',0 |
ManageKeyText db 'Manage',0 |
ReloadKeyText db 'Reload',0 |
SaveKeyText db 'Save',0 |
;DeleteKeyText db 'Delete',0 |
;ManageKeyText db 'Manage',0 |
|
|
hotkeys_num db 0;15 |
;keyboard_mode db 0 ; Scan or ASCII keys to send ? 0 - ASCII , 1 - Scan |
butt db 5 ; Pressed button ID |
butt db FIRST_ITEM_BUTTON_ID ; Pressed button ID |
modifiers dd 0 |
|
;Data structures for loadlib.mac and editbox_ex.mac [ |
638,8 → 928,8 |
edit1 edit_box 350, 220, 30, 0xffffff, 0xAA80, 0x0000ff, 0x0, 0x0, PATH_MAX_CHARS+1, buf_cmd_line, 0, 0 |
edit2 edit_box 350, 220, 50, 0xffffff, 0xAA80, 0x0000ff, 0x0, 0x0, PATH_MAX_CHARS+1, buf_cmd_params, 0, 0 |
|
buf_cmd_line db MAX_HOTKEYS_NUM*PATH_MAX_CHARS dup(0) ; !Make it dinamyc!!! |
buf_cmd_params db MAX_HOTKEYS_NUM*PATH_MAX_CHARS dup(0) ; !Make it dinamyc!!! |
buf_cmd_line dd 0 |
buf_cmd_params dd 0 |
|
sys_path: |
system_dir0 db '/sys/lib/' |
663,6 → 953,28 |
aEdit_box_mouse db 'edit_box_mouse',0 |
aVersion_ed db 'version_ed',0 |
|
align 16 |
importTable: |
library \ |
libini, 'libini.obj';, \ |
; boxlib, 'boxlib.obj' \ |
|
;import boxlib, \ |
;edit_box_draw , 'edit_box', \ |
;edit_box_key , 'edit_box_key', \ |
;edit_box_mouse , 'edit_box_mouse', \ |
;version_ed , 'version_ed' |
|
|
import libini, \ |
ini_get_str ,'ini_get_str', \ |
ini_set_str ,'ini_set_str', \ |
ini_get_int ,'ini_get_int', \ |
ini_set_int ,'ini_set_int';, \ |
; ini_get_color,'ini_get_color', \ |
; ini_set_color,'ini_set_color' |
|
|
;] Data structures for loadlib.mac and editbox_ex.mac |
|
InfoStructure: |
683,15 → 995,33 |
ascii_keymap: |
db 128 dup(?) |
ctrl_key_names db 'LShift LCtrl LAlt RAlt RCtrl RShift',0 |
aPlus db ' + ',0 |
aIni db 'mykey.ini',0 |
aMain db 'main',0 |
aKeynum db 'keynum',0 |
aHotkey db 'hotkey',0,0,0 |
aName db 'name',0 |
aKeycode db 'keycode',0 |
aKeycodeName db 'keycode_name',0 |
aPath db 'path',0 |
aParam db 'param',0 |
aRamSaver db '/sys/rdsave',0 |
|
Hotkeys: ;(name = 32 b) + (modifiers = 3 b) + (keycode = 1 b) = 36 byte for 1 hotkey |
app_path rb 255 |
ini_path rb 255 |
|
Hotkeys: ;(name = 32 b) + (modifiers = 3 b) + (keycode = 1 b) + (keycode_name = 64 b) = 100 bytes for 1 hotkey |
.names: |
db 'My Favorite 1',0 |
rb 18 |
db 'My Favorite 2',0 |
rb 18 |
db 'My Favorite 3',0 |
rb 18 |
db 'My1',0 |
rb 28 |
db 'My2',0 |
rb 28 |
db 'My3',0 |
rb 28 |
rb MAX_HOTKEYS_NUM*32-3 |
.codes: |
dd MAX_HOTKEYS_NUM dup (0) |
.code_names: |
rb MAX_HOTKEYS_NUM*64 |
|
it_ascii_keymap: |