04b26bf20bed64c2c4b95b16a1dddcc427960ffc
[blender-staging.git] / source / blender / python / api2_2x / Draw.c
1 /* 
2  *
3  * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License
7  * as published by the Free Software Foundation; either version 2
8  * of the License, or (at your option) any later version. The Blender
9  * Foundation also sells licenses for use in proprietary software under
10  * the Blender License.  See http://www.blender.org/BL/ for information
11  * about this.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software Foundation,
20  * Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
21  *
22  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
23  * All rights reserved.
24  *
25  * This is a new part of Blender.
26  *
27  * Contributor(s): Willian P. Germano
28  *
29  * ***** END GPL/BL DUAL LICENSE BLOCK *****
30 */
31
32 /* This file is the Blender.Draw part of opy_draw.c, from the old
33  * bpython/intern dir, with minor changes to adapt it to the new Python
34  * implementation.  Non-trivial original comments are marked with an
35  * @ symbol at their beginning. */
36
37 #include "Draw.h"
38
39 static void Button_dealloc(PyObject *self)
40 {
41         Button *but= (Button*) self;
42
43         if(but->type==3) MEM_freeN(but->val.asstr);
44                 
45         PyMem_DEL(self);        
46 }
47
48 static PyObject *Button_getattr(PyObject *self, char *name)
49 {
50         Button *but= (Button*) self;
51         
52         if(strcmp(name, "val") == 0) {
53                 if (but->type==1)
54                         return Py_BuildValue("i", but->val.asint);                      
55                 else if (but->type==2) 
56                         return Py_BuildValue("f", but->val.asfloat);
57                 else if (but->type==3) 
58                         return Py_BuildValue("s", but->val.asstr);
59         }
60
61         PyErr_SetString(PyExc_AttributeError, name);
62         return NULL;
63 }
64
65 static int Button_setattr(PyObject *self,  char *name, PyObject *v)
66 {
67         Button *but= (Button*) self;
68         
69         if(strcmp(name, "val") == 0) {
70                 if  (but->type==1)
71                         PyArg_Parse(v, "i", &but->val.asint);
72                 else if (but->type==2)
73                         PyArg_Parse(v, "f", &but->val.asfloat);                 
74                 else if (but->type==3) {
75                         char *newstr;
76                         
77                         PyArg_Parse(v, "s", &newstr);
78                         strncpy(but->val.asstr, newstr, but->slen); 
79                 }
80         } else {
81                 PyErr_SetString(PyExc_AttributeError, name);
82                 return -1;
83         }
84         
85         return 0;
86 }
87
88 static PyObject *Button_repr(PyObject *self)
89 {
90         return PyObject_Repr(Button_getattr(self, "val"));      
91 }
92
93 static Button *newbutton (void)
94 {
95         Button *but= (Button *) PyObject_NEW(Button, &Button_Type);
96         
97         return but;
98 }
99
100 /* GUI interface routines */
101
102 static void exit_pydraw(SpaceText *st) 
103 {
104         scrarea_queue_redraw(st->area);
105         
106         if (st) {       
107                 Py_XDECREF((PyObject *) st->py_draw);
108                 Py_XDECREF((PyObject *) st->py_event);
109                 Py_XDECREF((PyObject *) st->py_button);
110
111                 st->py_draw= st->py_event= st->py_button= NULL;
112         }
113 }
114
115 static void exec_callback(SpaceText *st, PyObject *callback, PyObject *args) 
116 {
117         PyObject *result= PyEval_CallObject(callback, args);
118         
119         if (result==NULL) {
120                 st->text->compiled= NULL;
121                 PyErr_Print();
122                 exit_pydraw(st);
123         }
124         Py_XDECREF(result);
125         Py_DECREF(args);
126 }
127
128 /*@ the handler for drawing routines (see Register method) */
129
130 void EXPP_spacetext_do_pywin_draw(SpaceText *st) 
131 {
132         uiBlock *block;
133         char butblock[20];
134
135         sprintf(butblock, "win %d", curarea->win);
136         block= uiNewBlock(&curarea->uiblocks, butblock, UI_EMBOSSX,
137                                                                         UI_HELV, curarea->win);
138         
139         if (st->py_draw) {
140                 glPushAttrib(GL_ALL_ATTRIB_BITS);
141                 exec_callback(st, st->py_draw, Py_BuildValue("()"));
142                 glPopAttrib();
143         } else {
144                 glClearColor(0.4375, 0.4375, 0.4375, 0.0); 
145                 glClear(GL_COLOR_BUFFER_BIT);
146         }
147
148         uiDrawBlock(block);
149
150         curarea->win_swap= WIN_BACK_OK;
151 }
152
153 /*@ the handler for button event routines (see Register method) */
154
155 static void spacetext_do_pywin_buttons(SpaceText *st, unsigned short event)
156 {
157         if (st->py_button) {
158                 exec_callback(st, st->py_button, Py_BuildValue("(i)", event));
159         }
160 }
161
162 /*@ calls the generic event handling methods registered with Register */
163
164 void EXPP_spacetext_do_pywin_event(SpaceText *st, unsigned short event, short val)
165 {
166         if (event==QKEY && G.qual & (LR_ALTKEY|LR_CTRLKEY|LR_SHIFTKEY)) {
167                 exit_pydraw(st);
168                 return;
169         }
170
171         if (val) {
172                 if (uiDoBlocks(&curarea->uiblocks, event)!=UI_NOTHING ) event= 0;
173
174                 if (event==UI_BUT_EVENT) {
175                         spacetext_do_pywin_buttons(st, val);
176                 }
177         }
178                 
179         if (st->py_event) {
180                 exec_callback(st, st->py_event, Py_BuildValue("(ii)", event, val));
181         }
182 }
183
184 int EXPP_spacetext_is_pywin(SpaceText *st)
185 {
186         return (st->py_draw || st->py_event || st->py_button);
187 }
188
189 #define EXPP_TRY(x) if((!(x))) \
190   return EXPP_ReturnPyObjError(PyExc_AttributeError, "in module Blender.Draw")
191
192 static PyObject *Method_Exit (PyObject *self, PyObject *args)
193 {       
194         SpaceText *st= curarea->spacedata.first;
195 #ifdef CLEAR_NAMESPACE  
196         PyObject *d;
197 #endif
198         EXPP_TRY(PyArg_ParseTuple(args, ""));
199         
200         exit_pydraw(st);
201 #ifdef CLEAR_NAMESPACE  
202         d = st->py_globaldict; /* The current window's global namespace dictionary */
203         if (d) {
204                 PyDict_Clear(d);
205                 Py_DECREF(d); /* release dictionary */
206         }       
207 #endif
208
209         return EXPP_incr_ret(Py_None);
210 }
211
212 static PyObject *Method_Register (PyObject *self, PyObject *args)
213 {
214         PyObject *newdrawc= NULL, *neweventc= NULL, *newbuttonc= NULL;
215         SpaceText *st= curarea->spacedata.first;
216         
217         EXPP_TRY(PyArg_ParseTuple(args, "O|OO", &newdrawc,
218                                                                                                         &neweventc, &newbuttonc));
219
220         /*@This is a hack again:
221          * Every python script should actually do a global variable cleanup at 
222          * the end of execution. 
223          * For scripts registering GUI callbacks, this does not work, because
224          * the global namespace of the interpreter still needs to be accessed
225          * from the callback. 
226          * Workaround: a text object has a flag which allows the global name
227          * space to be cleared at the end of the script. This flag should be
228          * normally set when executed with Alt-P. For a script registering with
229          * the GUI though, clear the flag and set it when the GUI mode is left
230          * (Method_Exit).
231          */
232
233 /*      EXPP_debug(("--- disable clear namespace")); */
234
235         st->flags &= ~ST_CLEAR_NAMESPACE;
236
237
238         if (!PyCallable_Check(newdrawc)) newdrawc= NULL;
239         if (!PyCallable_Check(neweventc)) neweventc= NULL;
240         if (!PyCallable_Check(newbuttonc)) newbuttonc= NULL;
241
242         if (!(newdrawc || neweventc || newbuttonc))
243                 return EXPP_incr_ret(Py_None);
244                 
245         exit_pydraw(st);
246
247         Py_XINCREF(newdrawc);
248         Py_XINCREF(neweventc);
249         Py_XINCREF(newbuttonc);
250         
251         st->py_draw= newdrawc;
252         st->py_event= neweventc;
253         st->py_button= newbuttonc;
254
255         scrarea_queue_redraw(st->area);
256
257         return EXPP_incr_ret(Py_None);
258 }
259
260 static PyObject *Method_Redraw (PyObject *self,  PyObject *args)
261 {
262         int after= 0;
263         
264         EXPP_TRY(PyArg_ParseTuple(args, "|i", &after));
265
266         if (after) addafterqueue(curarea->win, REDRAW, 1);
267         else scrarea_queue_winredraw(curarea);
268         
269         return EXPP_incr_ret(Py_None);
270 }
271
272 static PyObject *Method_Draw (PyObject *self,  PyObject *args)
273 {
274         /*@ If forced drawing is disable queue a redraw event instead */
275         if (EXPP_disable_force_draw) {
276                 scrarea_queue_winredraw(curarea);
277                 return EXPP_incr_ret(Py_None);
278         }
279         
280         EXPP_TRY(PyArg_ParseTuple(args, ""));
281
282         scrarea_do_windraw(curarea);
283
284         screen_swapbuffers();
285         
286         return EXPP_incr_ret(Py_None);
287 }
288
289 static PyObject *Method_Create (PyObject *self,  PyObject *args)
290 {
291         Button *but;
292         PyObject *in;
293
294         EXPP_TRY(PyArg_ParseTuple(args, "O", &in));
295         
296         but= newbutton();
297         if(PyFloat_Check(in)) {
298                 but->type= 2;
299                 but->val.asfloat= PyFloat_AsDouble(in);
300         } else if (PyInt_Check(in)) {           
301                 but->type= 1;
302                 but->val.asint= PyInt_AsLong(in);
303         } else if (PyString_Check(in)) {
304                 char *newstr= PyString_AsString(in);
305                 
306                 but->type= 3;
307                 but->slen= strlen(newstr);
308                 but->val.asstr= MEM_mallocN(but->slen+1, "button string");
309                 
310                 strcpy(but->val.asstr, newstr);
311         }
312                 
313         return (PyObject *) but;
314 }
315
316 static uiBlock *Get_uiBlock(void)
317 {
318         char butblock[32];
319         
320         sprintf(butblock, "win %d", curarea->win);
321
322         return uiGetBlock(butblock, curarea);
323 }
324
325 static PyObject *Method_Button (PyObject *self,  PyObject *args)
326 {
327         uiBlock *block;
328         char *name, *tip= NULL;
329         int event;
330         int x, y, w, h;
331         
332         EXPP_TRY(PyArg_ParseTuple(args, "siiiii|s", &name, &event,
333                                                                                                         &x, &y, &w, &h, &tip));
334         
335         block= Get_uiBlock();
336
337         if(block) uiDefBut(block, BUT, event, name, x, y, w, h,
338                                                                         0, 0, 0, 0, 0, tip);
339         
340         return EXPP_incr_ret(Py_None);
341 }
342
343 static PyObject *Method_Menu (PyObject *self,  PyObject *args)
344 {
345         uiBlock *block;
346         char *name, *tip= NULL;
347         int event, def;
348         int x, y, w, h;
349         Button *but;
350         
351         EXPP_TRY(PyArg_ParseTuple(args, "siiiiii|s", &name, &event,
352                                                                                                         &x, &y, &w, &h, &def, &tip));
353         
354         but= newbutton();
355         but->type= 1;
356         but->val.asint= def;
357         
358         block= Get_uiBlock();
359         if(block) uiDefButI(block, MENU, event, name, x, y, w, h,
360                                                                         &but->val.asint, 0, 0, 0, 0, tip);
361         
362         return (PyObject *) but;
363 }
364
365 static PyObject *Method_Toggle (PyObject *self,  PyObject *args)
366 {
367         uiBlock *block;
368         char *name, *tip= NULL;
369         int event;
370         int x, y, w, h, def;
371         Button *but;
372         
373         EXPP_TRY(PyArg_ParseTuple(args, "siiiiii|s", &name, &event,
374                                                                                                         &x, &y, &w, &h, &def, &tip));
375         
376         but= newbutton();
377         but->type= 1;
378         but->val.asint= def;
379         
380         block= Get_uiBlock();
381         if(block) uiDefButI(block, TOG, event, name, x, y, w, h,
382                                                                         &but->val.asint, 0, 0, 0, 0, tip);
383         
384         return (PyObject *) but;
385 }
386
387 /*@DO NOT TOUCH THIS FUNCTION !
388    Redrawing a slider inside its own callback routine is actually forbidden
389    with the current toolkit architecture (button routines are not reentrant).
390    But it works anyway.
391    XXX This is condemned to be dinosource in future - it's a hack.
392    */
393
394 static void py_slider_update(void *butv, void *data2_unused) 
395 {
396         uiBut *but= butv;
397
398         EXPP_disable_force_draw= 1;
399                 /*@
400                 Disable forced drawing, otherwise the button object which
401                 is still being used might be deleted 
402                 */
403
404 /*@     UIfrontbuf = 0; 
405         spacetext_do_pywin_buttons(curarea->spacedata.first, but->retval); */
406
407         g_window_redrawn = 0;
408         curarea->win_swap= WIN_BACK_OK; 
409         UIfrontbuf = 1; 
410         spacetext_do_pywin_buttons(curarea->spacedata.first, uiButGetRetVal(but));
411         UIfrontbuf = 0;
412
413         if (!g_window_redrawn) /*@ if Redraw already called */
414                 M_Window_Redraw(0, Py_BuildValue("(i)", SPACE_VIEW3D));
415
416         EXPP_disable_force_draw= 0;
417 }
418
419 static PyObject *Method_Slider (PyObject *self,  PyObject *args)
420 {
421         uiBlock *block;
422         char *name, *tip= NULL;
423         int event;
424         int x, y, w, h, realtime=1;
425         Button *but;
426         PyObject *mino, *maxo, *inio;
427         
428         EXPP_TRY(PyArg_ParseTuple(args, "siiiiiOOO|is", &name, &event,
429                                                                                                         &x, &y, &w, &h, &inio, &mino, &maxo, &realtime, &tip));
430
431         
432         but= newbutton();
433         if (PyFloat_Check(inio)) {
434                 float ini, min, max;
435
436                 ini= PyFloat_AsDouble(inio);
437                 min= PyFloat_AsDouble(mino);
438                 max= PyFloat_AsDouble(maxo);
439                                 
440                 but->type= 2;
441                 but->val.asfloat= ini;
442
443                 block= Get_uiBlock();
444                 if(block) {
445                         uiBut *ubut;
446                         ubut= uiDefButF(block, NUMSLI, event, name, x, y, w, h,
447                                                                                         &but->val.asfloat, min, max, 0, 0, tip);
448                         if (realtime) uiButSetFunc(ubut, py_slider_update, ubut, NULL);
449                 }               
450         } 
451         else {
452                 int ini, min, max;
453
454                 ini= PyInt_AsLong(inio);
455                 min= PyInt_AsLong(mino);
456                 max= PyInt_AsLong(maxo);
457                 
458                 but->type= 1;
459                 but->val.asint= ini;
460         
461                 block= Get_uiBlock();
462                 if(block) {
463                         uiBut *ubut;
464                         ubut= uiDefButI(block, NUMSLI, event, name, x, y, w, h,
465                                                                                         &but->val.asint, min, max, 0, 0, tip);
466                         if (realtime) uiButSetFunc(ubut, py_slider_update, ubut, NULL);
467                 }
468         }
469         return (PyObject *) but;
470 }
471
472 static PyObject *Method_Scrollbar (PyObject *self,  PyObject *args)
473 {
474         char *tip= NULL;
475         uiBlock *block;
476         int event;
477         int x, y, w, h, realtime=1;
478         Button *but;
479         PyObject *mino, *maxo, *inio;
480         float ini, min, max;
481
482         EXPP_TRY(PyArg_ParseTuple(args, "iiiiiOOO|is", &event, &x, &y, &w, &h, &inio, &mino, &maxo, &realtime, &tip));
483         
484         if (!PyNumber_Check(inio) || !PyNumber_Check(inio) || !PyNumber_Check(inio))
485                 return EXPP_ReturnPyObjError (PyExc_AttributeError,
486                                                                                 "expected numbers for initial, min, and max");
487
488         but= newbutton();
489
490         if (PyFloat_Check(inio)) but->type= 2;
491         else but->type= 1;
492
493         ini= PyFloat_AsDouble(inio);
494         min= PyFloat_AsDouble(mino);
495         max= PyFloat_AsDouble(maxo);
496
497         if (but->type==2) {
498                 but->val.asfloat= ini;
499                 block= Get_uiBlock();
500                 if(block) {
501                         uiBut *ubut;
502                         ubut= uiDefButF(block, SCROLL, event, "", x, y, w, h,
503                                                                                         &but->val.asfloat, min, max, 0, 0, tip);
504                         if (realtime) uiButSetFunc(ubut, py_slider_update, ubut, NULL);
505                 }
506         } else {
507                 but->val.asint= ini;
508                 block= Get_uiBlock();
509                 if(block) {
510                         uiBut *ubut;
511                         ubut= uiDefButI(block, SCROLL, event, "", x, y, w, h,
512                                                                                         &but->val.asint, min, max, 0, 0, tip);
513                         if (realtime) uiButSetFunc(ubut, py_slider_update, ubut, NULL);
514                 }
515         }
516
517         return (PyObject *) but;
518 }
519
520 static PyObject *Method_Number (PyObject *self,  PyObject *args)
521 {
522         uiBlock *block;
523         char *name, *tip= NULL;
524         int event;
525         int x, y, w, h;
526         Button *but;
527         PyObject *mino, *maxo, *inio;
528         
529         EXPP_TRY(PyArg_ParseTuple(args, "siiiiiOOO|s", &name, &event,
530                                                                                                         &x, &y, &w, &h, &inio, &mino, &maxo, &tip));
531         
532         but= newbutton();
533         
534         if (PyFloat_Check(inio)) {
535                 float ini, min, max;
536
537                 ini= PyFloat_AsDouble(inio);
538                 min= PyFloat_AsDouble(mino);
539                 max= PyFloat_AsDouble(maxo);
540                                 
541                 but->type= 2;
542                 but->val.asfloat= ini;
543         
544                 block= Get_uiBlock();
545                 if(block) uiDefButF(block, NUM, event, name, x, y, w, h,
546                                                                                 &but->val.asfloat, min, max, 0, 0, tip);
547         } else {
548                 int ini, min, max;
549
550                 ini= PyInt_AsLong(inio);
551                 min= PyInt_AsLong(mino);
552                 max= PyInt_AsLong(maxo);
553                 
554                 but->type= 1;
555                 but->val.asint= ini;
556         
557                 block= Get_uiBlock();
558                 if(block) uiDefButI(block, NUM, event, name, x, y, w, h,
559                                                                                 &but->val.asint, min, max, 0, 0, tip);
560         }
561
562         return (PyObject *) but;
563 }
564
565 static PyObject *Method_String (PyObject *self,  PyObject *args)
566 {
567         uiBlock *block;
568         char *name, *tip= NULL, *newstr;
569         int event;
570         int x, y, w, h, len;
571         Button *but;
572         
573         EXPP_TRY(PyArg_ParseTuple(args, "siiiiisi|s", &name, &event,
574                                                                                                         &x, &y, &w, &h, &newstr, &len, &tip));
575
576         but= newbutton();
577         but->type= 3;
578         but->slen= len;
579         but->val.asstr= MEM_mallocN(len+1, "button string");
580         
581         strncpy(but->val.asstr, newstr, len);
582         but->val.asstr[len]= 0;
583         
584         block= Get_uiBlock();
585         if(block) uiDefBut(block, TEX, event, name, x, y, w, h,
586                                                                         but->val.asstr, 0, len, 0, 0, tip);
587
588         return (PyObject *) but;
589 }
590
591 static PyObject *Method_Text (PyObject *self, PyObject *args)
592 {
593         char *text;
594         
595         EXPP_TRY(PyArg_ParseTuple(args, "s", &text));
596         
597         BMF_DrawString(G.font, text);
598         
599         return EXPP_incr_ret(Py_None);
600 }
601
602 PyObject *M_Draw_Init (void) 
603 {
604         PyObject *submodule, *dict;
605
606         printf("In M_Draw_Init()\n");
607
608         submodule = Py_InitModule3("Blender.Draw", Draw_methods, Draw_doc);
609
610         dict= PyModule_GetDict(submodule);
611
612 #define EXPP_ADDCONST(x) \
613         PyDict_SetItemString(dict, #x, PyInt_FromLong(x))
614
615 /* So, for example:
616  * EXPP_ADDCONST(LEFTMOUSE) becomes
617  * PyDict_SetItemString(dict, "LEFTMOUSE", PyInt_FromLong(LEFTMOUSE)) */
618
619         EXPP_ADDCONST(LEFTMOUSE);
620         EXPP_ADDCONST(MIDDLEMOUSE);
621         EXPP_ADDCONST(RIGHTMOUSE);
622         EXPP_ADDCONST(MOUSEX);
623         EXPP_ADDCONST(MOUSEY);
624         EXPP_ADDCONST(TIMER0);
625         EXPP_ADDCONST(TIMER1);
626         EXPP_ADDCONST(TIMER2);
627         EXPP_ADDCONST(TIMER3);
628         EXPP_ADDCONST(KEYBD);
629         EXPP_ADDCONST(RAWKEYBD);
630         EXPP_ADDCONST(REDRAW);
631         EXPP_ADDCONST(INPUTCHANGE);
632         EXPP_ADDCONST(QFULL);
633         EXPP_ADDCONST(WINFREEZE);
634         EXPP_ADDCONST(WINTHAW);
635         EXPP_ADDCONST(WINCLOSE);
636         EXPP_ADDCONST(WINQUIT);
637 #ifndef IRISGL
638         EXPP_ADDCONST(Q_FIRSTTIME);
639 #endif
640         EXPP_ADDCONST(AKEY);
641         EXPP_ADDCONST(BKEY);
642         EXPP_ADDCONST(CKEY);
643         EXPP_ADDCONST(DKEY);
644         EXPP_ADDCONST(EKEY);
645         EXPP_ADDCONST(FKEY);
646         EXPP_ADDCONST(GKEY);
647         EXPP_ADDCONST(HKEY);
648         EXPP_ADDCONST(IKEY);
649         EXPP_ADDCONST(JKEY);
650         EXPP_ADDCONST(KKEY);
651         EXPP_ADDCONST(LKEY);
652         EXPP_ADDCONST(MKEY);
653         EXPP_ADDCONST(NKEY);
654         EXPP_ADDCONST(OKEY);
655         EXPP_ADDCONST(PKEY);
656         EXPP_ADDCONST(QKEY);
657         EXPP_ADDCONST(RKEY);
658         EXPP_ADDCONST(SKEY);
659         EXPP_ADDCONST(TKEY);
660         EXPP_ADDCONST(UKEY);
661         EXPP_ADDCONST(VKEY);
662         EXPP_ADDCONST(WKEY);
663         EXPP_ADDCONST(XKEY);
664         EXPP_ADDCONST(YKEY);
665         EXPP_ADDCONST(ZKEY);
666         EXPP_ADDCONST(ZEROKEY);
667         EXPP_ADDCONST(ONEKEY);
668         EXPP_ADDCONST(TWOKEY);
669         EXPP_ADDCONST(THREEKEY);
670         EXPP_ADDCONST(FOURKEY);
671         EXPP_ADDCONST(FIVEKEY);
672         EXPP_ADDCONST(SIXKEY);
673         EXPP_ADDCONST(SEVENKEY);
674         EXPP_ADDCONST(EIGHTKEY);
675         EXPP_ADDCONST(NINEKEY);
676         EXPP_ADDCONST(CAPSLOCKKEY);
677         EXPP_ADDCONST(LEFTCTRLKEY);
678         EXPP_ADDCONST(LEFTALTKEY);
679         EXPP_ADDCONST(RIGHTALTKEY);
680         EXPP_ADDCONST(RIGHTCTRLKEY);
681         EXPP_ADDCONST(RIGHTSHIFTKEY);
682         EXPP_ADDCONST(LEFTSHIFTKEY);
683         EXPP_ADDCONST(ESCKEY);
684         EXPP_ADDCONST(TABKEY);
685         EXPP_ADDCONST(RETKEY);
686         EXPP_ADDCONST(SPACEKEY);
687         EXPP_ADDCONST(LINEFEEDKEY);
688         EXPP_ADDCONST(BACKSPACEKEY);
689         EXPP_ADDCONST(DELKEY);
690         EXPP_ADDCONST(SEMICOLONKEY);
691         EXPP_ADDCONST(PERIODKEY);
692         EXPP_ADDCONST(COMMAKEY);
693         EXPP_ADDCONST(QUOTEKEY);
694         EXPP_ADDCONST(ACCENTGRAVEKEY);
695         EXPP_ADDCONST(MINUSKEY);
696         EXPP_ADDCONST(SLASHKEY);
697         EXPP_ADDCONST(BACKSLASHKEY);
698         EXPP_ADDCONST(EQUALKEY);
699         EXPP_ADDCONST(LEFTBRACKETKEY);
700         EXPP_ADDCONST(RIGHTBRACKETKEY);
701         EXPP_ADDCONST(LEFTARROWKEY);
702         EXPP_ADDCONST(DOWNARROWKEY);
703         EXPP_ADDCONST(RIGHTARROWKEY);
704         EXPP_ADDCONST(UPARROWKEY);
705         EXPP_ADDCONST(PAD2);
706         EXPP_ADDCONST(PAD4);
707         EXPP_ADDCONST(PAD6);
708         EXPP_ADDCONST(PAD8);
709         EXPP_ADDCONST(PAD1);
710         EXPP_ADDCONST(PAD3);
711         EXPP_ADDCONST(PAD5);
712         EXPP_ADDCONST(PAD7);
713         EXPP_ADDCONST(PAD9);
714         EXPP_ADDCONST(PADPERIOD);
715         EXPP_ADDCONST(PADSLASHKEY);
716         EXPP_ADDCONST(PADASTERKEY);
717         EXPP_ADDCONST(PAD0);
718         EXPP_ADDCONST(PADMINUS);
719         EXPP_ADDCONST(PADENTER);
720         EXPP_ADDCONST(PADPLUSKEY);
721         EXPP_ADDCONST(F1KEY);
722         EXPP_ADDCONST(F2KEY);
723         EXPP_ADDCONST(F3KEY);
724         EXPP_ADDCONST(F4KEY);
725         EXPP_ADDCONST(F5KEY);
726         EXPP_ADDCONST(F6KEY);
727         EXPP_ADDCONST(F7KEY);
728         EXPP_ADDCONST(F8KEY);
729         EXPP_ADDCONST(F9KEY);
730         EXPP_ADDCONST(F10KEY);
731         EXPP_ADDCONST(F11KEY);
732         EXPP_ADDCONST(F12KEY);
733         EXPP_ADDCONST(PAUSEKEY);
734         EXPP_ADDCONST(INSERTKEY);
735         EXPP_ADDCONST(HOMEKEY);
736         EXPP_ADDCONST(PAGEUPKEY);
737         EXPP_ADDCONST(PAGEDOWNKEY);
738         EXPP_ADDCONST(ENDKEY);
739
740         return submodule;
741 }