Back to index

im-sdk  12.3.91
le_keybinding.c
Go to the documentation of this file.
00001 #include <stdio.h>
00002 
00003 #include "le_info.h"
00004 
00005 ImmKeybindingRec *imm_keybinding_new()
00006 {
00007     ImmKeybindingRec *imm_keybinding = NULL;
00008 
00009     imm_keybinding =
00010        (ImmKeybindingRec *) calloc(1, sizeof(ImmKeybindingRec));
00011     if (imm_keybinding == NULL)
00012        return (NULL);
00013 
00014     imm_keybinding->keycode = 0;
00015     imm_keybinding->keychar = 0;
00016     imm_keybinding->modifier = 0;
00017     imm_keybinding->defined_type = 0;
00018     return (imm_keybinding);
00019 }
00020 
00021 LeResult imm_keybinding_destroy(ImmKeybindingRec * imm_keybinding)
00022 {
00023     if (imm_keybinding == NULL)
00024        return (LE_FAIL);
00025 
00026     free((char *) imm_keybinding);
00027     return (LE_OK);
00028 }
00029 
00030 int imm_keybinding_print(ImmKeybindingRec * imm_keybinding)
00031 {
00032 #if DEBUG
00033     if (imm_keybinding == NULL)
00034        return (LE_FAIL);
00035 
00036     printf(" keycode: 0x%x  modifier: %d: defined_type: %d\n",
00037           imm_keybinding->keycode,
00038           imm_keybinding->modifier, imm_keybinding->defined_type);
00039 
00040     return (LE_OK);
00041 #endif
00042 }
00043 
00044 int imm_keybinding_set_value(ImmKeybindingRec * imm_keybinding,
00045                           char *keycode_str, char *modifier_str,
00046                           char *key_type_str)
00047 {
00048     int keycode, keychar, modifier;
00049     int defined_type;
00050 
00051     if (imm_keybinding == NULL)
00052        return (LE_FAIL);
00053     if (!keycode_str || !*keycode_str)
00054        return (LE_FAIL);
00055     if (!modifier_str || !*modifier_str)
00056        return (LE_FAIL);
00057     if (!key_type_str || !*key_type_str)
00058        return (LE_FAIL);
00059 
00060     DEBUG_printf("keycode: %s, modifier: %s, type: %s\n", keycode_str,
00061                modifier_str, key_type_str);
00062     keycode = 0;
00063     keychar = 0;
00064     modifier = 0;
00065     defined_type = 0;
00066 
00067     imm_keybinding->keycode = keycode;
00068     imm_keybinding->keychar = keychar;
00069     imm_keybinding->modifier = modifier;
00070     imm_keybinding->defined_type = defined_type;
00071 
00072     return (LE_OK);
00073 }