* Added 3 missing functions, 2 of them called by blender/src/drawtext.c:
[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 = PyObject_CallObject (callback, args);
118         printf ("In exec_callback\n");
119         if (result==NULL) {
120                 printf("In exec_callback, result == NULL\n");
121                 st->text->compiled= NULL;
122                 PyErr_Print();
123                 exit_pydraw(st);
124         }
125         printf ("In exec_callback 2\n");
126         Py_XDECREF(result);
127         Py_DECREF(args);
128 }
129
130 /* BPY_spacetext_do_pywin_draw, the static spacetext_do_pywin_buttons and
131  * BPY_spacetext_do_pywin_event are the three functions responsible for
132  * calling the draw, buttons and event callbacks registered with Draw.Register
133  * (see Method_Register below).  They are called (only the two BPY_ ones)
134  * from blender/src/drawtext.c */
135
136 void BPY_spacetext_do_pywin_draw(SpaceText *st) 
137 {
138         uiBlock *block;
139         char butblock[20];
140
141         sprintf(butblock, "win %d", curarea->win);
142         block= uiNewBlock(&curarea->uiblocks, butblock, UI_EMBOSSX,
143                                                                         UI_HELV, curarea->win);
144         
145         if (st->py_draw) {
146                 glPushAttrib(GL_ALL_ATTRIB_BITS);
147                 exec_callback(st, st->py_draw, Py_BuildValue("()"));
148                 glPopAttrib();
149         } else {
150                 glClearColor(0.4375, 0.4375, 0.4375, 0.0); 
151                 glClear(GL_COLOR_BUFFER_BIT);
152         }
153
154         uiDrawBlock(block);
155
156         curarea->win_swap= WIN_BACK_OK;
157 }
158
159 static void spacetext_do_pywin_buttons(SpaceText *st, unsigned short event)
160 {
161         if (st->py_button) {
162                 exec_callback(st, st->py_button, Py_BuildValue("(i)", event));
163         }
164 }
165
166 void BPY_spacetext_do_pywin_event(SpaceText *st, unsigned short event, short val)
167 {
168         if (event==QKEY && G.qual & (LR_ALTKEY|LR_CTRLKEY|LR_SHIFTKEY)) {
169                 exit_pydraw(st);
170                 return;
171         }
172
173         if (val) {
174                 if (uiDoBlocks(&curarea->uiblocks, event)!=UI_NOTHING ) event= 0;
175
176                 if (event==UI_BUT_EVENT)
177                         spacetext_do_pywin_buttons(st, val);
178         }
179                 
180         if (st->py_event)
181                 exec_callback(st, st->py_event, Py_BuildValue("(ii)", event, val));
182 }
183
184 int BPY_spacetext_is_pywin(SpaceText *st)
185 {
186         return (st->py_draw || st->py_event || st->py_button);
187 }
188
189 /* the define CLEAR_NAMESPACE is currently ignored.  It should be
190  * substituted by a better method, that was also the intention of the
191  * programmer(s) who put it there. */
192
193 static PyObject *Method_Exit (PyObject *self, PyObject *args)
194 {       
195         SpaceText *st= curarea->spacedata.first;
196 #ifdef CLEAR_NAMESPACE  
197         PyObject *d;
198 #endif
199         if (!PyArg_ParseTuple(args, ""))
200                                         return EXPP_ReturnPyObjError (PyExc_AttributeError,
201                                                                         "expected empty argument list");
202
203         exit_pydraw(st);
204 #ifdef CLEAR_NAMESPACE  
205         d = st->py_globaldict; /* The current window's global namespace dictionary */
206         if (d) {
207                 PyDict_Clear(d);
208                 Py_DECREF(d); /* release dictionary */
209         }       
210 #endif
211
212         return EXPP_incr_ret (Py_None);
213 }
214
215 static PyObject *Method_Register (PyObject *self, PyObject *args)
216 {
217         PyObject *newdrawc= NULL, *neweventc= NULL, *newbuttonc= NULL;
218         SpaceText *st= curarea->spacedata.first;
219         
220         if (!PyArg_ParseTuple(args, "O|OO", &newdrawc,
221                                                                                                         &neweventc, &newbuttonc))
222                         return EXPP_ReturnPyObjError (PyExc_TypeError,
223                                                 "expected one or three PyObjects");
224
225         /*@This is a hack again:
226          * Every python script should actually do a global variable cleanup at 
227          * the end of execution. 
228          * For scripts registering GUI callbacks, this does not work, because
229          * the global namespace of the interpreter still needs to be accessed
230          * from the callback. 
231          * Workaround: a text object has a flag which allows the global name
232          * space to be cleared at the end of the script. This flag should be
233          * normally set when executed with Alt-P. For a script registering with
234          * the GUI though, clear the flag and set it when the GUI mode is left
235          * (Method_Exit).
236          */
237
238 /*      EXPP_debug(("--- disable clear namespace")); */
239
240         st->flags &= ~ST_CLEAR_NAMESPACE;
241
242
243         if (!PyCallable_Check(newdrawc))   newdrawc   = NULL;
244         if (!PyCallable_Check(neweventc))  neweventc  = NULL;
245         if (!PyCallable_Check(newbuttonc)) newbuttonc = NULL;
246
247         if (!(newdrawc || neweventc || newbuttonc))
248                 return EXPP_incr_ret(Py_None);
249
250         exit_pydraw(st);
251
252         Py_XINCREF(newdrawc);
253         Py_XINCREF(neweventc);
254         Py_XINCREF(newbuttonc);
255
256         st->py_draw= newdrawc;
257         st->py_event= neweventc;
258         st->py_button= newbuttonc;
259
260         scrarea_queue_redraw(st->area);
261
262         return EXPP_incr_ret (Py_None);
263 }
264
265 static PyObject *Method_Redraw (PyObject *self,  PyObject *args)
266 {
267         int after= 0;
268         
269         if (!PyArg_ParseTuple(args, "|i", &after))
270                         return EXPP_ReturnPyObjError (PyExc_TypeError,
271                                                         "expected int argument (or nothing)");
272
273         if (after) addafterqueue(curarea->win, REDRAW, 1);
274         else scrarea_queue_winredraw(curarea);
275         
276         return EXPP_incr_ret(Py_None);
277 }
278
279 static PyObject *Method_Draw (PyObject *self,  PyObject *args)
280 {
281         /*@ If forced drawing is disable queue a redraw event instead */
282         if (EXPP_disable_force_draw) {
283                 printf ("\nEXPP_disable_force_draw\n");
284                 scrarea_queue_winredraw(curarea);
285                 return EXPP_incr_ret (Py_None);
286         }
287
288         if (!PyArg_ParseTuple(args, ""))
289                                         return EXPP_ReturnPyObjError (PyExc_AttributeError,
290                                                                                 "expected empty argument list");
291
292         scrarea_do_windraw(curarea);
293
294         screen_swapbuffers();
295
296         return EXPP_incr_ret (Py_None);
297 }
298
299 static PyObject *Method_Create (PyObject *self,  PyObject *args)
300 {
301         Button *but;
302         PyObject *in;
303
304         if (!PyArg_ParseTuple(args, "O", &in))
305                                         return EXPP_ReturnPyObjError (PyExc_TypeError,
306                                                                         "expected PyObject argument");
307         
308         but= newbutton();
309         if(PyFloat_Check(in)) {
310                 but->type= 2;
311                 but->val.asfloat= PyFloat_AsDouble(in);
312         } else if (PyInt_Check(in)) {           
313                 but->type= 1;
314                 but->val.asint= PyInt_AsLong(in);
315         } else if (PyString_Check(in)) {
316                 char *newstr= PyString_AsString(in);
317                 
318                 but->type= 3;
319                 but->slen= strlen(newstr);
320                 but->val.asstr= MEM_mallocN(but->slen+1, "button string");
321                 
322                 strcpy(but->val.asstr, newstr);
323         }
324                 
325         return (PyObject *) but;
326 }
327
328 static uiBlock *Get_uiBlock(void)
329 {
330         char butblock[32];
331         
332         sprintf(butblock, "win %d", curarea->win);
333
334         return uiGetBlock(butblock, curarea);
335 }
336
337 static PyObject *Method_Button (PyObject *self,  PyObject *args)
338 {
339         uiBlock *block;
340         char *name, *tip= NULL;
341         int event;
342         int x, y, w, h;
343         
344         if (!PyArg_ParseTuple(args, "siiiii|s", &name, &event,
345                                                                                                         &x, &y, &w, &h, &tip))
346                 return EXPP_ReturnPyObjError (PyExc_TypeError,
347                         "expected a string, five ints and optionally another string as arguments");
348         
349         block= Get_uiBlock();
350
351         if(block) uiDefBut(block, BUT, event, name, x, y, w, h,
352                                                                         0, 0, 0, 0, 0, tip);
353         
354         return EXPP_incr_ret(Py_None);
355 }
356
357 static PyObject *Method_Menu (PyObject *self,  PyObject *args)
358 {
359         uiBlock *block;
360         char *name, *tip= NULL;
361         int event, def;
362         int x, y, w, h;
363         Button *but;
364         
365         if (!PyArg_ParseTuple(args, "siiiiii|s", &name, &event,
366                                                                                                         &x, &y, &w, &h, &def, &tip))
367                 return EXPP_ReturnPyObjError (PyExc_TypeError,
368                         "expected a string, six ints and optionally another string as arguments");
369
370         but= newbutton();
371         but->type= 1;
372         but->val.asint= def;
373         
374         block= Get_uiBlock();
375         if(block) uiDefButI(block, MENU, event, name, x, y, w, h,
376                                                                         &but->val.asint, 0, 0, 0, 0, tip);
377         
378         return (PyObject *) but;
379 }
380
381 static PyObject *Method_Toggle (PyObject *self,  PyObject *args)
382 {
383         uiBlock *block;
384         char *name, *tip= NULL;
385         int event;
386         int x, y, w, h, def;
387         Button *but;
388         
389         if (!PyArg_ParseTuple(args, "siiiiii|s", &name, &event,
390                                                                                                         &x, &y, &w, &h, &def, &tip))
391                 return EXPP_ReturnPyObjError (PyExc_TypeError,
392                         "expected a string, six ints and optionally another string as arguments");
393
394         but= newbutton();
395         but->type= 1;
396         but->val.asint= def;
397         
398         block= Get_uiBlock();
399         if(block) uiDefButI(block, TOG, event, name, x, y, w, h,
400                                                                         &but->val.asint, 0, 0, 0, 0, tip);
401         
402         return (PyObject *) but;
403 }
404
405 /*@DO NOT TOUCH THIS FUNCTION !
406    Redrawing a slider inside its own callback routine is actually forbidden
407    with the current toolkit architecture (button routines are not reentrant).
408    But it works anyway.
409    XXX This is condemned to be dinosource in future - it's a hack.
410    */
411
412 static void py_slider_update(void *butv, void *data2_unused) 
413 {
414         uiBut *but= butv;
415
416         EXPP_disable_force_draw= 1;
417                 /*@
418                 Disable forced drawing, otherwise the button object which
419                 is still being used might be deleted 
420                 */
421
422 /*@     UIfrontbuf = 0; 
423         spacetext_do_pywin_buttons(curarea->spacedata.first, but->retval); */
424
425         g_window_redrawn = 0;
426         curarea->win_swap= WIN_BACK_OK; 
427         UIfrontbuf = 1; 
428         spacetext_do_pywin_buttons(curarea->spacedata.first, uiButGetRetVal(but));
429         UIfrontbuf = 0;
430
431         if (!g_window_redrawn) /*@ if Redraw already called */
432                 M_Window_Redraw(0, Py_BuildValue("(i)", SPACE_VIEW3D));
433
434         EXPP_disable_force_draw= 0;
435 }
436
437 static PyObject *Method_Slider (PyObject *self,  PyObject *args)
438 {
439         uiBlock *block;
440         char *name, *tip= NULL;
441         int event;
442         int x, y, w, h, realtime=1;
443         Button *but;
444         PyObject *mino, *maxo, *inio;
445         
446         if (!PyArg_ParseTuple(args, "siiiiiOOO|is", &name, &event,
447                                                                                                         &x, &y, &w, &h, &inio, &mino, &maxo, &realtime, &tip))
448                 return EXPP_ReturnPyObjError (PyExc_TypeError,
449                         "expected a string, five ints, three PyObjects\n\
450                         and optionally another int and string as arguments");
451
452         but= newbutton();
453         if (PyFloat_Check(inio)) {
454                 float ini, min, max;
455
456                 ini= PyFloat_AsDouble(inio);
457                 min= PyFloat_AsDouble(mino);
458                 max= PyFloat_AsDouble(maxo);
459                                 
460                 but->type= 2;
461                 but->val.asfloat= ini;
462
463                 block= Get_uiBlock();
464                 if(block) {
465                         uiBut *ubut;
466                         ubut= uiDefButF(block, NUMSLI, event, name, x, y, w, h,
467                                                                                         &but->val.asfloat, min, max, 0, 0, tip);
468                         if (realtime) uiButSetFunc(ubut, py_slider_update, ubut, NULL);
469                 }               
470         } 
471         else {
472                 int ini, min, max;
473
474                 ini= PyInt_AsLong(inio);
475                 min= PyInt_AsLong(mino);
476                 max= PyInt_AsLong(maxo);
477                 
478                 but->type= 1;
479                 but->val.asint= ini;
480         
481                 block= Get_uiBlock();
482                 if(block) {
483                         uiBut *ubut;
484                         ubut= uiDefButI(block, NUMSLI, event, name, x, y, w, h,
485                                                                                         &but->val.asint, min, max, 0, 0, tip);
486                         if (realtime) uiButSetFunc(ubut, py_slider_update, ubut, NULL);
487                 }
488         }
489         return (PyObject *) but;
490 }
491
492 static PyObject *Method_Scrollbar (PyObject *self,  PyObject *args)
493 {
494         char *tip= NULL;
495         uiBlock *block;
496         int event;
497         int x, y, w, h, realtime=1;
498         Button *but;
499         PyObject *mino, *maxo, *inio;
500         float ini, min, max;
501
502         if (!PyArg_ParseTuple(args, "iiiiiOOO|is", &event, &x, &y, &w, &h,
503                                                                                                         &inio, &mino, &maxo, &realtime, &tip))
504                 return EXPP_ReturnPyObjError (PyExc_TypeError,
505                         "expected five ints, three PyObjects and optionally\n\
506                         another int and string as arguments");
507
508         if (!PyNumber_Check(inio) || !PyNumber_Check(inio) || !PyNumber_Check(inio))
509                 return EXPP_ReturnPyObjError (PyExc_AttributeError,
510                                                                                 "expected numbers for initial, min, and max");
511
512         but= newbutton();
513
514         if (PyFloat_Check(inio)) but->type= 2;
515         else but->type= 1;
516
517         ini= PyFloat_AsDouble(inio);
518         min= PyFloat_AsDouble(mino);
519         max= PyFloat_AsDouble(maxo);
520
521         if (but->type==2) {
522                 but->val.asfloat= ini;
523                 block= Get_uiBlock();
524                 if(block) {
525                         uiBut *ubut;
526                         ubut= uiDefButF(block, SCROLL, event, "", x, y, w, h,
527                                                                                         &but->val.asfloat, min, max, 0, 0, tip);
528                         if (realtime) uiButSetFunc(ubut, py_slider_update, ubut, NULL);
529                 }
530         } else {
531                 but->val.asint= ini;
532                 block= Get_uiBlock();
533                 if(block) {
534                         uiBut *ubut;
535                         ubut= uiDefButI(block, SCROLL, event, "", x, y, w, h,
536                                                                                         &but->val.asint, min, max, 0, 0, tip);
537                         if (realtime) uiButSetFunc(ubut, py_slider_update, ubut, NULL);
538                 }
539         }
540
541         return (PyObject *) but;
542 }
543
544 static PyObject *Method_Number (PyObject *self,  PyObject *args)
545 {
546         uiBlock *block;
547         char *name, *tip= NULL;
548         int event;
549         int x, y, w, h;
550         Button *but;
551         PyObject *mino, *maxo, *inio;
552         
553         if (!PyArg_ParseTuple(args, "siiiiiOOO|s", &name, &event,
554                                                                                                         &x, &y, &w, &h, &inio, &mino, &maxo, &tip))
555                 return EXPP_ReturnPyObjError (PyExc_TypeError,
556                         "expected a string, five ints, three PyObjects and\n\
557                         optionally another string as arguments");
558
559         but= newbutton();
560         
561         if (PyFloat_Check(inio)) {
562                 float ini, min, max;
563
564                 ini= PyFloat_AsDouble(inio);
565                 min= PyFloat_AsDouble(mino);
566                 max= PyFloat_AsDouble(maxo);
567                                 
568                 but->type= 2;
569                 but->val.asfloat= ini;
570         
571                 block= Get_uiBlock();
572                 if(block) uiDefButF(block, NUM, event, name, x, y, w, h,
573                                                                                 &but->val.asfloat, min, max, 0, 0, tip);
574         } else {
575                 int ini, min, max;
576
577                 ini= PyInt_AsLong(inio);
578                 min= PyInt_AsLong(mino);
579                 max= PyInt_AsLong(maxo);
580                 
581                 but->type= 1;
582                 but->val.asint= ini;
583         
584                 block= Get_uiBlock();
585                 if(block) uiDefButI(block, NUM, event, name, x, y, w, h,
586                                                                                 &but->val.asint, min, max, 0, 0, tip);
587         }
588
589         return (PyObject *) but;
590 }
591
592 static PyObject *Method_String (PyObject *self,  PyObject *args)
593 {
594         uiBlock *block;
595         char *name, *tip= NULL, *newstr;
596         int event;
597         int x, y, w, h, len;
598         Button *but;
599         
600         if (!PyArg_ParseTuple(args, "siiiiisi|s", &name, &event,
601                                                                                                         &x, &y, &w, &h, &newstr, &len, &tip))
602                 return EXPP_ReturnPyObjError (PyExc_TypeError,
603                         "expected a string, five ints, a string, an int and\n\
604                         optionally another string as arguments");
605
606         but= newbutton();
607         but->type= 3;
608         but->slen= len;
609         but->val.asstr= MEM_mallocN(len+1, "button string");
610         
611         strncpy(but->val.asstr, newstr, len);
612         but->val.asstr[len]= 0;
613         
614         block= Get_uiBlock();
615         if(block) uiDefBut(block, TEX, event, name, x, y, w, h,
616                                                                         but->val.asstr, 0, len, 0, 0, tip);
617
618         return (PyObject *) but;
619 }
620
621 static PyObject *Method_Text (PyObject *self, PyObject *args)
622 {
623         char *text;
624         
625         if (!PyArg_ParseTuple(args, "s", &text))
626                 return EXPP_ReturnPyObjError (PyExc_TypeError,
627                                         "expected string argument");
628
629         BMF_DrawString(G.font, text);
630         
631         return EXPP_incr_ret(Py_None);
632 }
633
634 PyObject *M_Draw_Init (void) 
635 {
636         PyObject *submodule, *dict;
637
638         printf("In M_Draw_Init()\n");
639
640         submodule = Py_InitModule3("Blender.Draw", Draw_methods, Draw_doc);
641
642         dict= PyModule_GetDict(submodule);
643
644 #define EXPP_ADDCONST(x) \
645         PyDict_SetItemString(dict, #x, PyInt_FromLong(x))
646
647 /* So, for example:
648  * EXPP_ADDCONST(LEFTMOUSE) becomes
649  * PyDict_SetItemString(dict, "LEFTMOUSE", PyInt_FromLong(LEFTMOUSE)) */
650
651         EXPP_ADDCONST(LEFTMOUSE);
652         EXPP_ADDCONST(MIDDLEMOUSE);
653         EXPP_ADDCONST(RIGHTMOUSE);
654         EXPP_ADDCONST(MOUSEX);
655         EXPP_ADDCONST(MOUSEY);
656         EXPP_ADDCONST(TIMER0);
657         EXPP_ADDCONST(TIMER1);
658         EXPP_ADDCONST(TIMER2);
659         EXPP_ADDCONST(TIMER3);
660         EXPP_ADDCONST(KEYBD);
661         EXPP_ADDCONST(RAWKEYBD);
662         EXPP_ADDCONST(REDRAW);
663         EXPP_ADDCONST(INPUTCHANGE);
664         EXPP_ADDCONST(QFULL);
665         EXPP_ADDCONST(WINFREEZE);
666         EXPP_ADDCONST(WINTHAW);
667         EXPP_ADDCONST(WINCLOSE);
668         EXPP_ADDCONST(WINQUIT);
669 #ifndef IRISGL
670         EXPP_ADDCONST(Q_FIRSTTIME);
671 #endif
672         EXPP_ADDCONST(AKEY);
673         EXPP_ADDCONST(BKEY);
674         EXPP_ADDCONST(CKEY);
675         EXPP_ADDCONST(DKEY);
676         EXPP_ADDCONST(EKEY);
677         EXPP_ADDCONST(FKEY);
678         EXPP_ADDCONST(GKEY);
679         EXPP_ADDCONST(HKEY);
680         EXPP_ADDCONST(IKEY);
681         EXPP_ADDCONST(JKEY);
682         EXPP_ADDCONST(KKEY);
683         EXPP_ADDCONST(LKEY);
684         EXPP_ADDCONST(MKEY);
685         EXPP_ADDCONST(NKEY);
686         EXPP_ADDCONST(OKEY);
687         EXPP_ADDCONST(PKEY);
688         EXPP_ADDCONST(QKEY);
689         EXPP_ADDCONST(RKEY);
690         EXPP_ADDCONST(SKEY);
691         EXPP_ADDCONST(TKEY);
692         EXPP_ADDCONST(UKEY);
693         EXPP_ADDCONST(VKEY);
694         EXPP_ADDCONST(WKEY);
695         EXPP_ADDCONST(XKEY);
696         EXPP_ADDCONST(YKEY);
697         EXPP_ADDCONST(ZKEY);
698         EXPP_ADDCONST(ZEROKEY);
699         EXPP_ADDCONST(ONEKEY);
700         EXPP_ADDCONST(TWOKEY);
701         EXPP_ADDCONST(THREEKEY);
702         EXPP_ADDCONST(FOURKEY);
703         EXPP_ADDCONST(FIVEKEY);
704         EXPP_ADDCONST(SIXKEY);
705         EXPP_ADDCONST(SEVENKEY);
706         EXPP_ADDCONST(EIGHTKEY);
707         EXPP_ADDCONST(NINEKEY);
708         EXPP_ADDCONST(CAPSLOCKKEY);
709         EXPP_ADDCONST(LEFTCTRLKEY);
710         EXPP_ADDCONST(LEFTALTKEY);
711         EXPP_ADDCONST(RIGHTALTKEY);
712         EXPP_ADDCONST(RIGHTCTRLKEY);
713         EXPP_ADDCONST(RIGHTSHIFTKEY);
714         EXPP_ADDCONST(LEFTSHIFTKEY);
715         EXPP_ADDCONST(ESCKEY);
716         EXPP_ADDCONST(TABKEY);
717         EXPP_ADDCONST(RETKEY);
718         EXPP_ADDCONST(SPACEKEY);
719         EXPP_ADDCONST(LINEFEEDKEY);
720         EXPP_ADDCONST(BACKSPACEKEY);
721         EXPP_ADDCONST(DELKEY);
722         EXPP_ADDCONST(SEMICOLONKEY);
723         EXPP_ADDCONST(PERIODKEY);
724         EXPP_ADDCONST(COMMAKEY);
725         EXPP_ADDCONST(QUOTEKEY);
726         EXPP_ADDCONST(ACCENTGRAVEKEY);
727         EXPP_ADDCONST(MINUSKEY);
728         EXPP_ADDCONST(SLASHKEY);
729         EXPP_ADDCONST(BACKSLASHKEY);
730         EXPP_ADDCONST(EQUALKEY);
731         EXPP_ADDCONST(LEFTBRACKETKEY);
732         EXPP_ADDCONST(RIGHTBRACKETKEY);
733         EXPP_ADDCONST(LEFTARROWKEY);
734         EXPP_ADDCONST(DOWNARROWKEY);
735         EXPP_ADDCONST(RIGHTARROWKEY);
736         EXPP_ADDCONST(UPARROWKEY);
737         EXPP_ADDCONST(PAD2);
738         EXPP_ADDCONST(PAD4);
739         EXPP_ADDCONST(PAD6);
740         EXPP_ADDCONST(PAD8);
741         EXPP_ADDCONST(PAD1);
742         EXPP_ADDCONST(PAD3);
743         EXPP_ADDCONST(PAD5);
744         EXPP_ADDCONST(PAD7);
745         EXPP_ADDCONST(PAD9);
746         EXPP_ADDCONST(PADPERIOD);
747         EXPP_ADDCONST(PADSLASHKEY);
748         EXPP_ADDCONST(PADASTERKEY);
749         EXPP_ADDCONST(PAD0);
750         EXPP_ADDCONST(PADMINUS);
751         EXPP_ADDCONST(PADENTER);
752         EXPP_ADDCONST(PADPLUSKEY);
753         EXPP_ADDCONST(F1KEY);
754         EXPP_ADDCONST(F2KEY);
755         EXPP_ADDCONST(F3KEY);
756         EXPP_ADDCONST(F4KEY);
757         EXPP_ADDCONST(F5KEY);
758         EXPP_ADDCONST(F6KEY);
759         EXPP_ADDCONST(F7KEY);
760         EXPP_ADDCONST(F8KEY);
761         EXPP_ADDCONST(F9KEY);
762         EXPP_ADDCONST(F10KEY);
763         EXPP_ADDCONST(F11KEY);
764         EXPP_ADDCONST(F12KEY);
765         EXPP_ADDCONST(PAUSEKEY);
766         EXPP_ADDCONST(INSERTKEY);
767         EXPP_ADDCONST(HOMEKEY);
768         EXPP_ADDCONST(PAGEUPKEY);
769         EXPP_ADDCONST(PAGEDOWNKEY);
770         EXPP_ADDCONST(ENDKEY);
771
772         return submodule;
773 }