/* * keypad.PRG by DC * (c) 2019 Sollia 3 */ PROGRAM keypad; global notation; file_id; struct padkey[50] ch[1]; end = "","","1","!","2","@","3","#","4","$","5","%","6","?","7","&","8","*","9","(","0",")", "q","Q","w","W","e","E","r","R","t","T","y","Y","u","U","i","I","o","O","p","P", "a","A","s","S","d","D","f","F","g","G","h","H","j","J","k","K","l","L", "SHIFT", "SHIFT","z","Z","x","X","c","C","v","V","b","B","n","N","m","M","ENTER","ENTER", "EXIT","EXIT", "<","<", " ", " ", ">", ">", "DEL", "DEL"; BEGIN draw_z = 400; set_mode(m320x400); draw(3,150,15,0,0,0,320,400); notation = load_fnt("notation.FNT"); file_id = load_fpg("kpad.fpg"); input_pad(); mouse.graph = 21; write(notation,160,10,1,"Type something Amazing!"); loop frame; end end process input_pad() private info[1]; msg[1]; shift_state; clicking; string output =""; string c_output =""; string p_output = ""; cpos; begin graph = 202; x= 20; y=120; //msg = write(notation,x,y+200,0,output); msg = write(notation,x,y+160,0,p_output); //msg = write(notation,x,y+180,0,c_output); loop if(collision(type mouse)) info = map_get_pixel(file_id,203,mouse.x-x,mouse.y-y); if(info<50); end if(mouse.left and clicking ==0) switch(info) case 1..29,31..37,41: strcpy(c_output,output); strdel(output,0,strlen(output)-cpos); strdel(c_output,cpos,0); output+=padkey[info].ch[shift_state]; // move_text(msg,x+strlen(output)*8,y+200); cpos+=1; strcat(output,c_output); strcpy(c_output,output); c_output[cpos] ="_"; end case 30: shift_state = 1-shift_state; end case 40,42: cpos= min(max(0, cpos-(41-info)),strlen(output)); strcpy(c_output,output); c_output[cpos] = "_"; end case 43: if(cpos>0) strcpy(c_output,output); strdel(output,0,strlen(output)-cpos+1); strdel(c_output,cpos,0); strcat(output,c_output); cpos-=1; strcpy(c_output,output); c_output[cpos] = "_"; end end default: end end end end clicking = mouse.left; // msg[1] = write_int(0,x, y-50,0,&cpos); if(timer[1]%100<50) p_output = output; else p_output = c_output; end graph = 201+shift_state; frame; if(msg[1]>0) delete_text(msg[1]); msg[1]=0; end end end function max(a,b) begin if(a>b) return(a) ; else return(b); end end function min(a,b) begin if(a