| version 1.12 | | version 1.13 |
|---|
| | |
| /* | | /* |
| * static char *rcsid_xutil_c = | | * static char *rcsid_xutil_c = |
| * "$Id: xutil.c,v 1.12 2004/01/26 16:54:34 tchize Exp $"; | | * "$Id: xutil.c,v 1.13 2004/01/30 13:30:58 tchize Exp $"; |
| */ | | */ |
| /* | | /* |
| Crossfire client, a client program for the crossfire program. | | Crossfire client, a client program for the crossfire program. |
| | |
| int i, direction=-1; | | int i, direction=-1; |
| | | |
| if (keycode>MAX_KEYCODE) { | | if (keycode>MAX_KEYCODE) { |
| fprintf(stderr,"Warning insert_key:keycode that is passed is greater than 255.\n"); | | LOG(LOG_WARNING,"x11::insert_key", "keycode that is passed is greater than 255."); |
| keycode=0; /* hopefully the rest of the data is OK */ | | keycode=0; /* hopefully the rest of the data is OK */ |
| } | | } |
| if (keys[keycode]==NULL) { | | if (keys[keycode]==NULL) { |
| | |
| | | |
| if (buf[0]=='#' || buf[0]=='\n') return; | | if (buf[0]=='#' || buf[0]=='\n') return; |
| if ((cpnext = strchr(buf,' '))==NULL) { | | if ((cpnext = strchr(buf,' '))==NULL) { |
| fprintf(stderr,"Line %d (%s) corrupted in keybinding file.\n", line,buf); | | LOG(LOG_WARNING,"x11::parse_keybind_line","Line %d (%s) corrupted.", line,buf); |
| return; | | return; |
| } | | } |
| /* Special keybinding line */ | | /* Special keybinding line */ |
| | |
| while (*cpnext == ' ') ++cpnext; | | while (*cpnext == ' ') ++cpnext; |
| cp = strchr(cpnext, ' '); | | cp = strchr(cpnext, ' '); |
| if (!cp) { | | if (!cp) { |
| fprintf(stderr,"Line %d (%s) corrupted in keybinding file.\n", line,buf); | | LOG(LOG_WARNING,"x11::parse_keybind_line","Line %d (%s) corrupted in keybinding file.", line,buf); |
| return; | | return; |
| } | | } |
| *cp++ = 0; /* Null terminate it */ | | *cp++ = 0; /* Null terminate it */ |
| cp1 = strchr(cp, ' '); | | cp1 = strchr(cp, ' '); |
| if (!cp1) { | | if (!cp1) { |
| fprintf(stderr,"Line %d (%s) corrupted in keybinding file.\n", line,buf); | | LOG(LOG_WARNING,"x11::parse_keybind_line","Line %d (%s) corrupted in keybinding file.", line,buf); |
| return; | | return; |
| } | | } |
| *cp1 ++ = 0;/* Null terminate it */ | | *cp1 ++ = 0;/* Null terminate it */ |
| | |
| keysym = XStringToKeysym(cp); | | keysym = XStringToKeysym(cp); |
| /* As of now, all these keys must have keysyms */ | | /* As of now, all these keys must have keysyms */ |
| if (keysym == NoSymbol) { | | if (keysym == NoSymbol) { |
| fprintf(stderr,"Could not convert %s into keysym\n", cp); | | LOG(LOG_WARNING,"x11::parse_keybind_line","Could not convert %s into keysym", cp); |
| return; | | return; |
| } | | } |
| if (!strcmp(cpnext,"commandkey")) { | | if (!strcmp(cpnext,"commandkey")) { |
| | |
| keysym = XStringToKeysym(buf); | | keysym = XStringToKeysym(buf); |
| cp = cpnext; | | cp = cpnext; |
| if ((cpnext = strchr(cp,' '))==NULL) { | | if ((cpnext = strchr(cp,' '))==NULL) { |
| fprintf(stderr,"Line %d (%s) corrupted in keybinding file.\n", line, cp); | | LOG(LOG_WARNING,"x11::parse_keybind_line","Line %d (%s) corrupted in keybinding file.", line, cp); |
| return; | | return; |
| } | | } |
| *cpnext++ = '\0'; | | *cpnext++ = '\0'; |
| | |
| keycode = atoi(cp); | | keycode = atoi(cp); |
| cp = cpnext; | | cp = cpnext; |
| if ((cpnext = strchr(cp,' '))==NULL) { | | if ((cpnext = strchr(cp,' '))==NULL) { |
| fprintf(stderr,"Line %d (%s) corrupted in keybinding file.\n", line, cp); | | LOG(LOG_WARNING,"x11::parse_keybind_line","Line %d (%s) corrupted in keybinding file.", line, cp); |
| return; | | return; |
| } | | } |
| *cpnext++ = '\0'; | | *cpnext++ = '\0'; |
| | |
| flags |= KEYF_STANDARD; | | flags |= KEYF_STANDARD; |
| break; | | break; |
| default: | | default: |
| fprintf(stderr,"Warning: Unknown flag (%c) line %d in key binding file\n", | | LOG(LOG_WARNING,"x11::parse_keybind_line","Unknown flag (%c) line %d in key binding file", |
| *cp, line); | | *cp, line); |
| } | | } |
| cp++; | | cp++; |
| | |
| * it away, but at least print a warning message. | | * it away, but at least print a warning message. |
| */ | | */ |
| if (keycode==0) { | | if (keycode==0) { |
| fprintf(stderr,"Warning: could not convert keysym %s into keycode, ignoring\n", | | LOG(LOG_WARNING,"x11::parse_keybind_line","could not convert keysym %s into keycode, ignoring", |
| buf); | | buf); |
| } | | } |
| } | | } |
| | |
| | | |
| sprintf(buf,"%s/.crossfire/keys", getenv("HOME")); | | sprintf(buf,"%s/.crossfire/keys", getenv("HOME")); |
| if ((fp=fopen(buf,"r"))==NULL) { | | if ((fp=fopen(buf,"r"))==NULL) { |
| fprintf(stderr,"Could not open ~/.crossfire/keys, trying to load global bindings\n"); | | LOG(LOG_INFO,"x11::init_keys","Could not open ~/.crossfire/keys, trying to load global bindings"); |
| if (client_libdir==NULL) { | | if (client_libdir==NULL) { |
| init_default_keybindings(); | | init_default_keybindings(); |
| return; | | return; |
| | |
| | | |
| sprintf(buf,"%s/.crossfire/keys", getenv("HOME")); | | sprintf(buf,"%s/.crossfire/keys", getenv("HOME")); |
| if (make_path_to_file(buf)==-1) { | | if (make_path_to_file(buf)==-1) { |
| fprintf(stderr,"Could not create %s\n", buf); | | LOG(LOG_WARNING,"x11::save_keys","Could not create %s", buf); |
| return; | | return; |
| } | | } |
| if ((fp=fopen(buf,"w"))==NULL) { | | if ((fp=fopen(buf,"w"))==NULL) { |
| | |
| goto unbinded; | | goto unbinded; |
| } | | } |
| } | | } |
| fprintf(stderr,"unbind_key - found number entry, but could not find actual key\n"); | | LOG(LOG_ERROR,"x11::unbind_key","found number entry, but could not find actual key"); |
| } | | } |
| } | | } |
| } | | } |