Thread: [Wisp-cvs] wisp/users/pisi nupp,NONE,1.1 nupuconvert,NONE,1.1
Status: Alpha
Brought to you by:
digg
From: <pi...@us...> - 2003-02-25 01:08:56
|
Update of /cvsroot/wisp/wisp/users/pisi In directory sc8-pr-cvs1:/tmp/cvs-serv19989 Added Files: nupp nupuconvert Log Message: introduced keyboard event handling --- NEW FILE: nupp --- #!/bin/wisp ;; include/linux/input.h in your linux directory should give some hints ;; this is linux, ia32 (as struct input_event is byte order dependent) ;; for some strange reason there's an empty event after each real event ;; ;; usage: nupp </dev/input/event#> - u must know your keyboard interface! (use dialect.pisi unix lists strings files syscalls) ;;; returns the key symbol (define (key-symbol keycode) (case keycode ((0) 'key_reserved) ((1) 'key_esc) ((2) 'key_1) ((3) 'key_2) ((4) 'key_3) ((5) 'key_4) ((6) 'key_5) ((7) 'key_6) ((8) 'key_7) ((9) 'key_8) ((10) 'key_9) ((11) 'key_0) ((12) 'key_minus) ((13) 'key_equal) ((14) 'key_backspace) ((15) 'key_tab) ((16) 'key_q) ((17) 'key_w) ((18) 'key_e) ((19) 'key_r) ((20) 'key_t) ((21) 'key_y) ((22) 'key_u) ((23) 'key_i) ((24) 'key_o) ((25) 'key_p) ((26) 'key_leftbrace) ((27) 'key_rightbrace) ((28) 'key_enter) ((29) 'key_leftctrl) ((30) 'key_a) ((31) 'key_s) ((32) 'key_d) ((33) 'key_f) ((34) 'key_g) ((35) 'key_h) ((36) 'key_j) ((37) 'key_k) ((38) 'key_l) ((39) 'key_semicolon) ((40) 'key_apostrophe) ((41) 'key_grave) ((42) 'key_leftshift) ((43) 'key_backslash) ((44) 'key_z) ((45) 'key_x) ((46) 'key_c) ((47) 'key_v) ((48) 'key_b) ((49) 'key_n) ((50) 'key_m) ((51) 'key_comma) ((52) 'key_dot) ((53) 'key_slash) ((54) 'key_rightshift) ((55) 'key_kpasterisk) ((56) 'key_leftalt) ((57) 'key_space) ((58) 'key_capslock) ((59) 'key_f1) ((60) 'key_f2) ((61) 'key_f3) ((62) 'key_f4) ((63) 'key_f5) ((64) 'key_f6) ((65) 'key_f7) ((66) 'key_f8) ((67) 'key_f9) ((68) 'key_f10) ((69) 'key_numlock) ((70) 'key_scrolllock) ((71) 'key_kp7) ((72) 'key_kp8) ((73) 'key_kp9) ((74) 'key_kpminus) ((75) 'key_kp4) ((76) 'key_kp5) ((77) 'key_kp6) ((78) 'key_kpplus) ((79) 'key_kp1) ((80) 'key_kp2) ((81) 'key_kp3) ((82) 'key_kp0) ((83) 'key_kpdot) ((84) 'key_103rd) ((85) 'key_f13) ((86) 'key_102nd) ((87) 'key_f11) ((88) 'key_f12) ((89) 'key_f14) ((90) 'key_f15) ((91) 'key_f16) ((92) 'key_f17) ((93) 'key_f18) ((94) 'key_f19) ((95) 'key_f20) ((96) 'key_kpenter) ((97) 'key_rightctrl) ((98) 'key_kpslash) ((99) 'key_sysrq) ((100) 'key_rightalt) ((101) 'key_linefeed) ((102) 'key_home) ((103) 'key_up) ((104) 'key_pageup) ((105) 'key_left) ((106) 'key_right) ((107) 'key_end) ((108) 'key_down) ((109) 'key_pagedown) ((110) 'key_insert) ((111) 'key_delete) ((112) 'key_macro) ((113) 'key_mute) ((114) 'key_volumedown) ((115) 'key_volumeup) ((116) 'key_power) ((117) 'key_kpequal) ((118) 'key_kpplusminus) ((119) 'key_pause) ((120) 'key_f21) ((121) 'key_f22) ((122) 'key_f23) ((123) 'key_f24) ((124) 'key_kpcomma) ((125) 'key_leftmeta) ((126) 'key_rightmeta) ((127) 'key_compose) ((128) 'key_stop) ((129) 'key_again) ((130) 'key_props) ((131) 'key_undo) ((132) 'key_front) ((133) 'key_copy) ((134) 'key_open) ((135) 'key_paste) ((136) 'key_find) ((137) 'key_cut) ((138) 'key_help) ((139) 'key_menu) ((140) 'key_calc) ((141) 'key_setup) ((142) 'key_sleep) ((143) 'key_wakeup) ((144) 'key_file) ((145) 'key_sendfile) ((146) 'key_deletefile) ((147) 'key_xfer) ((148) 'key_prog1) ((149) 'key_prog2) ((150) 'key_www) ((151) 'key_msdos) ((152) 'key_coffee) ((153) 'key_direction) ((154) 'key_cyclewindows) ((155) 'key_mail) ((156) 'key_bookmarks) ((157) 'key_computer) ((158) 'key_back) ((159) 'key_forward) ((160) 'key_closecd) ((161) 'key_ejectcd) ((162) 'key_ejectclosecd) ((163) 'key_nextsong) ((164) 'key_playpause) ((165) 'key_previoussong) ((166) 'key_stopcd) ((167) 'key_record) ((168) 'key_rewind) ((169) 'key_phone) ((170) 'key_iso) ((171) 'key_config) ((172) 'key_homepage) ((173) 'key_refresh) ((174) 'key_exit) ((175) 'key_move) ((176) 'key_edit) ((177) 'key_scrollup) ((178) 'key_scrolldown) ((179) 'key_kpleftparen) ((180) 'key_kprightparen) ((181) 'key_intl1) ((182) 'key_intl2) ((183) 'key_intl3) ((184) 'key_intl4) ((185) 'key_intl5) ((186) 'key_intl6) ((187) 'key_intl7) ((188) 'key_intl8) ((189) 'key_intl9) ((190) 'key_lang1) ((191) 'key_lang2) ((192) 'key_lang3) ((193) 'key_lang4) ((194) 'key_lang5) ((195) 'key_lang6) ((196) 'key_lang7) ((197) 'key_lang8) ((198) 'key_lang9) ((200) 'key_playcd) ((201) 'key_pausecd) ((202) 'key_prog3) ((203) 'key_prog4) ((205) 'key_suspend) ((206) 'key_close) ((207) 'key_play) ((208) 'key_fastforward) ((209) 'key_bassboost) ((210) 'key_print) ((211) 'key_hp) ((212) 'key_camera) ((213) 'key_sound) ((214) 'key_question) ((215) 'key_email) ((216) 'key_chat) ((217) 'key_search) ((218) 'key_connect) ((219) 'key_finance) ((220) 'key_sport) ((221) 'key_shop) ((222) 'key_alterase) ((223) 'key_cancel) ((224) 'key_brightnessdown) ((225) 'key_brightnessup) ((226) 'key_media) ((240) 'key_unknown) ((352) 'key_ok) ((353) 'key_select) ((354) 'key_goto) ((355) 'key_clear) ((356) 'key_power2) ((357) 'key_option) ((358) 'key_info) ((359) 'key_time) ((360) 'key_vendor) ((361) 'key_archive) ((362) 'key_program) ((363) 'key_channel) ((364) 'key_favorites) ((365) 'key_epg) ((366) 'key_pvr) ((367) 'key_mhp) ((368) 'key_language) ((369) 'key_title) ((370) 'key_subtitle) ((371) 'key_angle) ((372) 'key_zoom) ((373) 'key_mode) ((374) 'key_keyboard) ((375) 'key_screen) ((376) 'key_pc) ((377) 'key_tv) ((378) 'key_tv2) ((379) 'key_vcr) ((380) 'key_vcr2) ((381) 'key_sat) ((382) 'key_sat2) ((383) 'key_cd) ((384) 'key_tape) ((385) 'key_radio) ((386) 'key_tuner) ((387) 'key_player) ((388) 'key_text) ((389) 'key_dvd) ((390) 'key_aux) ((391) 'key_mp3) ((392) 'key_audio) ((393) 'key_video) ((394) 'key_directory) ((395) 'key_list) ((396) 'key_memo) ((397) 'key_calendar) ((398) 'key_red) ((399) 'key_green) ((400) 'key_yellow) ((401) 'key_blue) ((402) 'key_channelup) ((403) 'key_channeldown) ((404) 'key_first) ((405) 'key_last) ((406) 'key_ab) ((407) 'key_next) ((408) 'key_restart) ((409) 'key_slow) ((410) 'key_shuffle) ((411) 'key_break) ((412) 'key_previous) ((413) 'key_digits) ((414) 'key_teen) ((415) 'key_twen) ((511) 'key_max) (else (raise 'unknown-keycode keycode)) )) ;;; nupp-event (define (nupp-event source) (let (loop) (my event (read-string 16 source) (my type (unpack-le-integer event[-8 ... -6]) (my code (unpack-le-integer event[-6 ... -4]) (my value (unpack-le-integer event[-4 ...]) (if (or (= type 0) (not (member value '(0 1 2)))) (loop) `(,(case value ((0) 'release) ((1) 'press) ((2) 'repeat)) ,(key-symbol code)) ))))))) (print "let's go!\n") (define nupud (open-input-file (first *arglist*))) (forever (write (nupp-event nupud)) ) --- NEW FILE: nupuconvert --- ;; generate a nupud.txt file like this: ;; egrep "^#define" /usr/src/linux/include/linux/input.h | grep KEY_ ;; ;; (use strings files lists) (define nupud.txt (read-all-lines (open-input-file "nupud.txt"))) (define nupud.wd (open-output-file "nupud.wd")) (map (lambda (napp) (write napp nupud.wd) (newline nupud.wd)) (collect (lambda (emit) (map (lambda (nupp) (my tera (string->word-list nupp ) (emit `(( ,(cond ((string-starts-with? "0x" (third tera)) (string->integer (string-drop-prefix "0x" (third tera)) 16)) ; usual integer (else (string->integer (third tera))) )) ',(string->symbol (string-downcase (second tera))) ))))nupud.txt)))) |