4 * ***** BEGIN GPL LICENSE BLOCK *****
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 * The Original Code is Copyright (C) 2007 Blender Foundation.
21 * All rights reserved.
24 * Contributor(s): Blender Foundation
26 * ***** END GPL LICENSE BLOCK *****
31 #include "DNA_windowmanager_types.h"
33 #include "MEM_guardedalloc.h"
35 #include "BLI_blenlib.h"
37 #include "BKE_blender.h"
38 #include "BKE_global.h"
39 #include "BKE_library.h"
44 #include "wm_window.h"
45 #include "wm_event_system.h"
46 #include "wm_event_types.h"
48 /* ***************** generic call, exported **************** */
50 static void keymap_set(wmKeymapItem *km, short type, short val, int modifier, short keymodifier)
54 km->keymodifier= keymodifier;
56 if(modifier & KM_SHIFT)
58 else if(modifier & KM_SHIFT2)
60 if(modifier & KM_CTRL)
62 else if(modifier & KM_CTRL2)
66 else if(modifier & KM_ALT2)
68 if(modifier & KM_OSKEY)
70 else if(modifier & KM_OSKEY2)
74 /* if item was added, then replace */
75 void WM_keymap_verify_item(ListBase *lb, char *idname, short type, short val, int modifier, short keymodifier)
79 /* if item was added, then bail out */
80 for(km= lb->first; km; km= km->next)
81 if(strncmp(km->idname, idname, OP_MAX_TYPENAME)==0)
84 km= MEM_callocN(sizeof(wmKeymapItem), "keymap entry");
87 BLI_strncpy(km->idname, idname, OP_MAX_TYPENAME);
89 keymap_set(km, type, val, modifier, keymodifier);
94 /* if item was added, then replace */
95 void WM_keymap_set_item(ListBase *lb, char *idname, short type, short val, int modifier, short keymodifier)
99 for(km= lb->first; km; km= km->next)
100 if(strncmp(km->idname, idname, OP_MAX_TYPENAME)==0)
103 km= MEM_callocN(sizeof(wmKeymapItem), "keymap entry");
106 BLI_strncpy(km->idname, idname, OP_MAX_TYPENAME);
108 keymap_set(km, type, val, modifier, keymodifier);