// File: /workspace/github_c_makefile_star2_O2/jonof[P]jftekwar/jfbuild/src/osd.c
// Function: OSD_HandleKey
int OSD_HandleKey(int sc, int press)
{
	if (!osdinited) return sc;
	if (!osdvisible) return sc;

	if (!press) {
		if (sc == 42 || sc == 54) // shift
			osdeditshift = 0;
		if (sc == 29 || sc == 157)	// control
			osdeditcontrol = 0;
		if (sc == 56 || sc == 184)	// alt
			osdeditalt = 0;
		return 0;
	}

	keytime = gettime();

	if (sc != 15) lastmatch = NULL;		// reset tab-completion cycle

	switch (sc) {
		case 1:		// escape
			OSD_ShowDisplay(0); break;
		case 211:	// delete
			OSD_Manipulate(OSDOP_DELETE); break;
		case 199:	// home
			if (osdeditcontrol) {
				OSD_Manipulate(OSDOP_SCROLL_TOP);
			} else {
				OSD_Manipulate(OSDOP_START);
			}
			break;
		case 207:	// end
			if (osdeditcontrol) {
				OSD_Manipulate(OSDOP_SCROLL_BOTTOM);
			} else {
				OSD_Manipulate(OSDOP_END);
			}
			break;
		case 201:	// page up
			OSD_Manipulate(OSDOP_PAGE_UP); break;
		case 209:	// page down
			OSD_Manipulate(OSDOP_PAGE_DOWN); break;
		case 200:	// up
			OSD_Manipulate(OSDOP_HISTORY_UP); break;
		case 208:	// down
			OSD_Manipulate(OSDOP_HISTORY_DOWN); break;
		case 203:	// left
			if (osdeditcontrol) {
				OSD_Manipulate(OSDOP_LEFT_WORD);
			} else {
				OSD_Manipulate(OSDOP_LEFT);
			}
			break;
		case 205:	// right
			if (osdeditcontrol) {
				OSD_Manipulate(OSDOP_RIGHT_WORD);
			} else {
				OSD_Manipulate(OSDOP_RIGHT);
			}
			break;
		case 33:	// f
			if (osdeditalt) {
				OSD_Manipulate(OSDOP_RIGHT_WORD);
			}
			break;
		case 48:	// b
			if (osdeditalt) {
				OSD_Manipulate(OSDOP_LEFT_WORD);
			}
			break;
		case 210:	// insert
			osdovertype ^= 1; break;
		case 58:	// capslock
			osdeditcaps ^= 1; break;
		case 42:
		case 54:	// shift
			osdeditshift = 1; break;
		case 29:
		case 157:	// control
			osdeditcontrol = 1; break;
		case 56:
		case 184:	// alt
			osdeditalt = 1; break;
	}

	return 0;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movl %edi, %r14d
cmpb $0x1, 0x5a97a1(%rip)    # 0x5ed2c8
jne 0x43b82
cmpb $0x0, 0x5ad7ac(%rip)    # 0x5f12dc
je 0x43b82
testl %esi, %esi
je 0x43b8f
callq *0x5a17c(%rip)          # 0x9dcb8
movl %eax, 0x5ad7a6(%rip)    # 0x5f12e8
xorl %ebx, %ebx
cmpl $0xf, %r14d
je 0x43b85
andq $0x0, 0x5ad79e(%rip)    # 0x5f12f0
leal -0xc7(%r14), %eax
cmpl $0xc, %eax
ja 0x43bad
leaq 0x28e17(%rip), %rcx     # 0x6c97c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
cmpb $0x1, 0x5ad76b(%rip)    # 0x5f12e0
jne 0x43c9d
pushq $0x10
jmp 0x43c92
movl %r14d, %ebx
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
andl $0xffffff7f, %r14d      # imm = 0xFFFFFF7F
xorl %ebx, %ebx
cmpl $0x38, %r14d
je 0x43bfa
cmpl $0x1d, %r14d
jne 0x43b85
movb $0x0, 0x5ad735(%rip)    # 0x5f12e0
jmp 0x43b85
cmpl $0xb8, %r14d
je 0x43c0f
cmpl $0x1d, %r14d
je 0x43c03
cmpl $0x21, %r14d
je 0x43c7f
cmpl $0x30, %r14d
je 0x43c6e
cmpl $0x38, %r14d
je 0x43c0f
cmpl $0x3a, %r14d
je 0x43c62
cmpl $0x9d, %r14d
je 0x43c03
cmpl $0x1, %r14d
jne 0x43b85
xorl %ebx, %ebx
xorl %edi, %edi
callq 0x43ca3
jmp 0x43b85
movb $0x0, 0x5ad6e3(%rip)    # 0x5f12e4
jmp 0x43b85
movb $0x1, 0x5ad6d6(%rip)    # 0x5f12e0
jmp 0x43b85
movb $0x1, 0x5ad6ce(%rip)    # 0x5f12e4
jmp 0x43b85
pushq $0x13
jmp 0x43c92
pushq $0x7
jmp 0x43c92
pushq $0xe
jmp 0x43c92
cmpb $0x1, 0x5ad6b2(%rip)    # 0x5f12e0
je 0x43c8c
pushq $0x4
jmp 0x43c92
pushq $0x12
jmp 0x43c92
cmpb $0x1, 0x5ad6a1(%rip)    # 0x5f12e0
jne 0x43c90
pushq $0x11
jmp 0x43c92
pushq $0xf
jmp 0x43c92
cmpb $0x1, 0x5ad690(%rip)    # 0x5f12e0
je 0x43c7b
pushq $0x2
jmp 0x43c92
xorb $0x1, 0x5ad69b(%rip)    # 0x5f12f8
jmp 0x43b85
xorb $0x1, 0x5ad693(%rip)    # 0x5f12fc
jmp 0x43b85
cmpb $0x1, 0x5ad66f(%rip)    # 0x5f12e4
jne 0x43b85
pushq $0x3
jmp 0x43c92
cmpb $0x1, 0x5ad65e(%rip)    # 0x5f12e4
jne 0x43b85
pushq $0x5
jmp 0x43c92
pushq $0x1
popq %rdi
callq 0x433ec
jmp 0x43b85
xorl %ebx, %ebx
xorl %edi, %edi
jmp 0x43c93