Rev 9828 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 9828 | Rev 9911 | ||
---|---|---|---|
Line 3... | Line 3... | ||
3 | ;; Copyright (C) KolibriOS team 2004-2022. All rights reserved. ;; |
3 | ;; Copyright (C) KolibriOS team 2004-2022. All rights reserved. ;; |
4 | ;; Copyright (C) MenuetOS 2000-2004 Ville Mikael Turjanmaa ;; |
4 | ;; Copyright (C) MenuetOS 2000-2004 Ville Mikael Turjanmaa ;; |
5 | ;; Distributed under terms of the GNU General Public License ;; |
5 | ;; Distributed under terms of the GNU General Public License ;; |
6 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
6 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
Line 7... | Line 7... | ||
7 | 7 | ||
Line 8... | Line 8... | ||
8 | $Revision: 9828 $ |
8 | $Revision: 9911 $ |
9 | 9 | ||
10 | 10 | ||
Line 100... | Line 100... | ||
100 | stc |
100 | stc |
101 | pop eax |
101 | pop eax |
102 | ret |
102 | ret |
103 | ;--------------------------------------------------------------------- |
103 | ;--------------------------------------------------------------------- |
104 | align 4 |
104 | align 4 |
- | 105 | ; @brief Export function - Add new scancode in buffer |
|
- | 106 | ; @param ecx - scancode |
|
- | 107 | ; @return not return |
|
105 | set_keyboard_data: |
108 | set_keyboard_data: |
106 | movzx eax, word[thread_count]; top window process |
109 | movzx eax, word[thread_count]; top window process |
107 | movzx eax, word[WIN_POS + eax*2] |
110 | movzx eax, word[WIN_POS + eax*2] |
108 | shl eax, BSF sizeof.APPDATA |
111 | shl eax, BSF sizeof.APPDATA |
109 | mov al, [SLOT_BASE + eax + APPDATA.keyboard_mode] |
112 | mov al, [SLOT_BASE + eax + APPDATA.keyboard_mode] |
Line 120... | Line 123... | ||
120 | next dd ? |
123 | next dd ? |
121 | prev dd ? |
124 | prev dd ? |
122 | functions dd ? |
125 | functions dd ? |
123 | userdata dd ? |
126 | userdata dd ? |
124 | ends |
127 | ends |
- | 128 | ||
125 | struct KBDFUNC |
129 | struct KBDFUNC |
126 | strucsize dd ? |
130 | strucsize dd ? |
127 | close dd ? |
131 | close dd ? |
128 | setlights dd ? |
132 | setlights dd ? |
129 | ends |
133 | ends |
Line 135... | Line 139... | ||
135 | endg |
139 | endg |
136 | uglobal |
140 | uglobal |
137 | keyboard_list_mutex MUTEX |
141 | keyboard_list_mutex MUTEX |
138 | endg |
142 | endg |
Line -... | Line 143... | ||
- | 143 | ||
- | 144 | ; @brief Export function - Registration new keyboard |
|
- | 145 | ; @param [esp + 4] - pointer on KBDFUNC this keyboard |
|
- | 146 | ; @param [esp + 8] - userdata for callback function |
|
139 | 147 | ; @return eax = pointer on KEYBOARD structure or 0 on error |
|
140 | register_keyboard: |
148 | register_keyboard: |
141 | push ebx |
149 | push ebx |
142 | movi eax, sizeof.KEYBOARD |
150 | movi eax, sizeof.KEYBOARD |
143 | call malloc |
151 | call malloc |
Line 169... | Line 177... | ||
169 | xchg eax, ebx |
177 | xchg eax, ebx |
170 | .nothing: |
178 | .nothing: |
171 | pop ebx |
179 | pop ebx |
172 | ret 8 |
180 | ret 8 |
Line -... | Line 181... | ||
- | 181 | ||
- | 182 | ; @brief Export function - Delete keyboard |
|
- | 183 | ; @param [esp + 4] - pointer on KEYBOARD structure |
|
173 | 184 | ; @return not return |
|
174 | delete_keyboard: |
185 | delete_keyboard: |
175 | push ebx |
186 | push ebx |
176 | mov ebx, [esp+4+4] |
187 | mov ebx, [esp+4+4] |
177 | mov ecx, keyboard_list_mutex |
188 | mov ecx, keyboard_list_mutex |
Line 575... | Line 586... | ||
575 | ;--------------------------------------------------------------------- |
586 | ;--------------------------------------------------------------------- |
576 | iglobal |
587 | iglobal |
577 | numlock_map db '789-456+1230.' |
588 | numlock_map db '789-456+1230.' |
578 | endg |
589 | endg |
579 | ;--------------------------------------------------------------------- |
590 | ;--------------------------------------------------------------------- |
- | 591 | align 4 |
|
- | 592 | kb_write_wait_ack: |
|
- | 593 | ||
- | 594 | push ecx edx |
|
- | 595 | ||
- | 596 | mov dl, al |
|
- | 597 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
|
- | 598 | .wait_output_ready: |
|
- | 599 | in al, 0x64 |
|
- | 600 | test al, 2 |
|
- | 601 | jz @f |
|
- | 602 | loop .wait_output_ready |
|
- | 603 | mov ah, 1 |
|
- | 604 | jmp .nothing |
|
- | 605 | @@: |
|
- | 606 | mov al, dl |
|
- | 607 | out 0x60, al |
|
- | 608 | mov ecx, 0xfffff; last 0xffff, new value in view of fast CPU's |
|
- | 609 | .wait_ack: |
|
- | 610 | in al, 0x64 |
|
- | 611 | test al, 1 |
|
- | 612 | jnz @f |
|
- | 613 | loop .wait_ack |
|
- | 614 | mov ah, 1 |
|
- | 615 | jmp .nothing |
|
- | 616 | @@: |
|
- | 617 | in al, 0x60 |
|
- | 618 | xor ah, ah |
|
- | 619 | ||
- | 620 | .nothing: |
|
- | 621 | pop edx ecx |
|
- | 622 | ret |
|
- | 623 | ;----------------------------------------------------------------------------- |
|
- | 624 | ||
- | 625 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
|
- | 626 | ;; 66 sys function. ;; |
|
- | 627 | ;; in eax=66,ebx in [0..5],ecx,edx ;; |
|
- | 628 | ;; out eax ;; |
|
- | 629 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
|
- | 630 | iglobal |
|
- | 631 | align 4 |
|
- | 632 | f66call: |
|
- | 633 | dd sys_process_def.1 ; 1 = set keyboard mode |
|
- | 634 | dd sys_process_def.2 ; 2 = get keyboard mode |
|
- | 635 | dd sys_process_def.3 ; 3 = get keyboard ctrl, alt, shift |
|
- | 636 | dd sys_process_def.4 ; 4 = set system-wide hotkey |
|
- | 637 | dd sys_process_def.5 ; 5 = delete installed hotkey |
|
- | 638 | dd sys_process_def.6 ; 6 = disable input, work only hotkeys |
|
- | 639 | dd sys_process_def.7 ; 7 = enable input, opposition to f.66.6 |
|
- | 640 | endg |
|
- | 641 | ;----------------------------------------------------------------------------- |
|
- | 642 | align 4 |
|
- | 643 | sys_process_def: |
|
- | 644 | dec ebx |
|
- | 645 | cmp ebx, 7 |
|
- | 646 | jae .not_support ;if >=8 then or eax,-1 |
|
- | 647 | ||
- | 648 | mov edi, [current_slot] |
|
- | 649 | jmp dword [f66call + ebx*4] |
|
- | 650 | ||
- | 651 | .not_support: |
|
- | 652 | or [esp + SYSCALL_STACK.eax], -1 |
|
- | 653 | ret |
|
- | 654 | ;----------------------------------------------------------------------------- |
|
- | 655 | align 4 |
|
- | 656 | .1: |
|
- | 657 | mov [edi + APPDATA.keyboard_mode], cl |
|
- | 658 | ret |
|
- | 659 | ;----------------------------------------------------------------------------- |
|
- | 660 | align 4 |
|
- | 661 | .2: ; 2 = get keyboard mode |
|
- | 662 | movzx eax, byte [edi + APPDATA.keyboard_mode] |
|
- | 663 | mov [esp + SYSCALL_STACK.eax], eax |
|
- | 664 | ret |
|
- | 665 | ;----------------------------------------------------------------------------- |
|
- | 666 | align 4 |
|
- | 667 | .3: ;3 = get keyboard ctrl, alt, shift |
|
- | 668 | mov eax, [kb_state] |
|
- | 669 | mov [esp + SYSCALL_STACK.eax], eax |
|
- | 670 | ret |
|
- | 671 | ;----------------------------------------------------------------------------- |
|
- | 672 | align 4 |
|
- | 673 | .4: |
|
- | 674 | mov edi, [current_slot_idx] |
|
- | 675 | mov eax, hotkey_list |
|
- | 676 | @@: |
|
- | 677 | cmp dword [eax + 8], 0 |
|
- | 678 | jz .found_free |
|
- | 679 | add eax, 16 |
|
- | 680 | cmp eax, hotkey_list+16*256 |
|
- | 681 | jb @b |
|
- | 682 | mov dword [esp + SYSCALL_STACK.eax], 1 |
|
- | 683 | ret |
|
- | 684 | .found_free: |
|
- | 685 | mov [eax + 8], edi |
|
- | 686 | mov [eax + 4], edx |
|
- | 687 | movzx ecx, cl |
|
- | 688 | lea ecx, [hotkey_scancodes+ecx*4] |
|
- | 689 | mov edx, [ecx] |
|
- | 690 | mov [eax], edx |
|
- | 691 | mov [ecx], eax |
|
- | 692 | mov [eax + 12], ecx |
|
- | 693 | test edx, edx |
|
- | 694 | jz @f |
|
- | 695 | mov [edx + 12], eax |
|
- | 696 | @@: |
|
- | 697 | and dword [esp + SYSCALL_STACK.eax], 0 |
|
- | 698 | ret |
|
- | 699 | ;----------------------------------------------------------------------------- |
|
- | 700 | align 4 |
|
- | 701 | .5: |
|
- | 702 | mov edi, [current_slot_idx] |
|
- | 703 | movzx ebx, cl |
|
- | 704 | lea ebx, [hotkey_scancodes+ebx*4] |
|
- | 705 | mov eax, [ebx] |
|
- | 706 | .scan: |
|
- | 707 | test eax, eax |
|
- | 708 | jz .notfound |
|
- | 709 | cmp [eax + 8], edi |
|
- | 710 | jnz .next |
|
- | 711 | cmp [eax + 4], edx |
|
- | 712 | jz .found |
|
- | 713 | .next: |
|
- | 714 | mov eax, [eax] |
|
- | 715 | jmp .scan |
|
- | 716 | .notfound: |
|
- | 717 | mov dword [esp + SYSCALL_STACK.eax], 1 |
|
- | 718 | ret |
|
- | 719 | .found: |
|
- | 720 | mov ecx, [eax] |
|
- | 721 | jecxz @f |
|
- | 722 | mov edx, [eax + 12] |
|
- | 723 | mov [ecx + 12], edx |
|
- | 724 | @@: |
|
- | 725 | mov ecx, [eax + 12] |
|
- | 726 | mov edx, [eax] |
|
- | 727 | mov [ecx], edx |
|
- | 728 | xor edx, edx |
|
- | 729 | mov [eax + 4], edx |
|
- | 730 | mov [eax + 8], edx |
|
- | 731 | mov [eax + 12], edx |
|
- | 732 | mov [eax], edx |
|
- | 733 | mov [esp + SYSCALL_STACK.eax], edx |
|
- | 734 | ret |
|
- | 735 | ;----------------------------------------------------------------------------- |
|
- | 736 | align 4 |
|
- | 737 | .6: |
|
- | 738 | pushfd |
|
- | 739 | cli |
|
- | 740 | mov eax, [PID_lock_input] |
|
- | 741 | test eax, eax |
|
- | 742 | jnz @f |
|
- | 743 | ; get current PID |
|
- | 744 | mov eax, [current_slot] |
|
- | 745 | mov eax, [eax + APPDATA.tid] |
|
- | 746 | ; set current PID for lock input |
|
- | 747 | mov [PID_lock_input], eax |
|
- | 748 | @@: |
|
- | 749 | popfd |
|
- | 750 | ret |
|
- | 751 | ;----------------------------------------------------------------------------- |
|
- | 752 | align 4 |
|
- | 753 | .7: |
|
- | 754 | mov eax, [PID_lock_input] |
|
- | 755 | test eax, eax |
|
- | 756 | jz @f |
|
- | 757 | ; get current PID |
|
- | 758 | mov ebx, [current_slot] |
|
- | 759 | mov ebx, [ebx + APPDATA.tid] |
|
- | 760 | ; compare current lock input with current PID |
|
- | 761 | cmp ebx, eax |
|
- | 762 | jne @f |
|
- | 763 | ||
- | 764 | xor eax, eax |
|
- | 765 | mov [PID_lock_input], eax |
|
- | 766 | @@: |
|
- | 767 | ret |
|
- | 768 | ;----------------------------------------------------------------------------- |
|
- | 769 | uglobal |
|
- | 770 | PID_lock_input dd 0x0 |
|
- | 771 | endg |
|
- | 772 | ;----------------------------------------------------------------------------- |
|
- | 773 | align 4 |
|
- | 774 | ; @brief System function 2 - Get pressed key |
|
- | 775 | ; @param eax = 2- number function |
|
- | 776 | ; @return eax = 1 - buffer empty, else |
|
- | 777 | ; al = 0, ah = code pressed key, |
|
- | 778 | ; 16-23 bits - scancode pressed key(in ASCII mode) |
|
- | 779 | ; if al=2 ah=scancode pressed key, 16-31 bits - state control keys |
|
- | 780 | sys_getkey: |
|
- | 781 | mov [esp + SYSCALL_STACK.eax], dword 1 |
|
- | 782 | ; test main buffer |
|
- | 783 | mov ebx, [current_slot_idx] ; TOP OF WINDOW STACK |
|
- | 784 | movzx ecx, word [WIN_STACK + ebx * 2] |
|
- | 785 | mov edx, [thread_count] |
|
- | 786 | cmp ecx, edx |
|
- | 787 | jne .finish |
|
- | 788 | cmp [KEY_COUNT], byte 0 |
|
- | 789 | je .finish |
|
- | 790 | movzx ax, byte [KEY_BUFF + 120 + 2] |
|
- | 791 | shl eax, 8 |
|
- | 792 | mov al, byte [KEY_BUFF] |
|
- | 793 | shl eax, 8 |
|
- | 794 | push eax |
|
- | 795 | dec byte [KEY_COUNT] |
|
- | 796 | and byte [KEY_COUNT], 127 |
|
- | 797 | movzx ecx, byte [KEY_COUNT] |
|
- | 798 | add ecx, 2 |
|
- | 799 | mov eax, KEY_BUFF + 1 |
|
- | 800 | mov ebx, KEY_BUFF |
|
- | 801 | call memmove |
|
- | 802 | add eax, 120 + 2 |
|
- | 803 | add ebx, 120 + 2 |
|
- | 804 | call memmove |
|
- | 805 | pop eax |
|
- | 806 | ;-------------------------------------- |
|
- | 807 | align 4 |
|
- | 808 | .ret_eax: |
|
- | 809 | mov [esp + SYSCALL_STACK.eax], eax |
|
- | 810 | ret |
|
- | 811 | ;-------------------------------------- |
|
- | 812 | align 4 |
|
- | 813 | .finish: |
|
- | 814 | ; test hotkeys buffer |
|
- | 815 | mov ecx, hotkey_buffer |
|
- | 816 | ;-------------------------------------- |
|
- | 817 | align 4 |
|
- | 818 | @@: |
|
- | 819 | cmp [ecx], ebx |
|
- | 820 | jz .found |
|
- | 821 | add ecx, 8 |
|
- | 822 | cmp ecx, hotkey_buffer + 120 * 8 |
|
- | 823 | jb @b |
|
- | 824 | ret |
|
- | 825 | ;-------------------------------------- |
|
- | 826 | align 4 |
|
- | 827 | .found: |
|
- | 828 | mov ax, [ecx + 6] |
|
- | 829 | shl eax, 16 |
|
- | 830 | mov ah, [ecx + 4] |
|
- | 831 | mov al, 2 |
|
- | 832 | and dword [ecx + 4], 0 |
|
- | 833 | and dword [ecx], 0 |
|
- | 834 | jmp .ret_eax |
|
- | 835 | ;------------------------------------------------------------------------------ |
|
580 | 836 |