1 /* --- 8< --- 8< --- OffscreenGecko headers --- >8 --- >8 --- */
\r
3 /* OffscreenGecko/defs.h */
\r
5 #define OSGK_CLASSTYPE_DEF struct
\r
6 #define OSGK_CLASSTYPE_REF struct
\r
9 #define OSGK_ASSERT(x) assert(x)
\r
11 typedef unsigned int OSGK_GeckoResult;
\r
13 #if defined(__cplusplus) || defined(__GNUC__)
\r
14 # define OSGK_INLINE inline
\r
15 #elif defined(_MSC_VER)
\r
16 # define OSGK_INLINE __inline
\r
18 # define OSGK_INLINE
\r
21 /* OffscreenGecko/baseobj.h */
\r
23 struct OSGK_BaseObject_s
\r
27 typedef struct OSGK_BaseObject_s OSGK_BaseObject;
\r
29 #define OSGK_DERIVEDTYPE(T) \
\r
30 typedef struct T ## _s { \
\r
31 OSGK_BaseObject baseobj; \
\r
34 static int (*osgk_addref) (OSGK_BaseObject* obj);
\r
35 static int (*osgk_release) (OSGK_BaseObject* obj);
\r
37 static OSGK_INLINE int osgk_addref_real (OSGK_BaseObject* obj)
\r
39 return osgk_addref (obj);
\r
42 static OSGK_INLINE int osgk_release_real (OSGK_BaseObject* obj)
\r
44 return osgk_release (obj);
\r
47 #define osgk_addref(obj) osgk_addref_real (&((obj)->baseobj))
\r
48 #define osgk_release(obj) osgk_release_real (&((obj)->baseobj))
\r
50 /* OffscreenGecko/embedding.h */
\r
52 OSGK_DERIVEDTYPE(OSGK_EmbeddingOptions);
\r
54 static OSGK_EmbeddingOptions* (*osgk_embedding_options_create) (void);
\r
55 static void (*osgk_embedding_options_add_search_path) (
\r
56 OSGK_EmbeddingOptions* options, const char* path);
\r
57 /*static void (*osgk_embedding_options_add_components_path) (
\r
58 OSGK_EmbeddingOptions* options, const char* path);*/
\r
59 static void (*osgk_embedding_options_set_profile_dir) (
\r
60 OSGK_EmbeddingOptions* options, const char* profileDir,
\r
61 const char* localProfileDir);
\r
63 OSGK_DERIVEDTYPE(OSGK_Embedding);
\r
65 #define OSGK_API_VERSION 1
\r
67 static OSGK_Embedding* (*osgk_embedding_create2) (
\r
68 unsigned int apiVer, OSGK_EmbeddingOptions* options,
\r
69 OSGK_GeckoResult* geckoResult);
\r
71 static OSGK_INLINE OSGK_Embedding* osgk_embedding_create (
\r
72 OSGK_GeckoResult* geckoResult)
\r
74 return osgk_embedding_create2 (OSGK_API_VERSION, 0, geckoResult);
\r
77 static OSGK_INLINE OSGK_Embedding* osgk_embedding_create_with_options (
\r
78 OSGK_EmbeddingOptions* options, OSGK_GeckoResult* geckoResult)
\r
80 return osgk_embedding_create2 (OSGK_API_VERSION, options, geckoResult);
\r
83 /*static OSGK_GeckoMem* (*osgk_embedding_get_gecko_mem) (
\r
84 OSGK_Embedding* embedding);*/
\r
86 /*static OSGK_ComponentMgr* (*osgk_embedding_get_component_mgr) (
\r
87 OSGK_Embedding* embedding);*/
\r
89 /*OSGK_CLASSTYPE_DEF nsIComponentManager;
\r
90 OSGK_CLASSTYPE_DEF nsIComponentRegistrar;
\r
91 OSGK_CLASSTYPE_DEF nsIServiceManager;*/
\r
93 /*static OSGK_CLASSTYPE_REF nsIComponentManager*
\r
94 (*osgk_embedding_get_gecko_component_manager) (OSGK_Embedding* embedding);*/
\r
95 /*static OSGK_CLASSTYPE_REF nsIComponentRegistrar*
\r
96 (*osgk_embedding_get_gecko_component_registrar) (OSGK_Embedding* embedding);*/
\r
97 /*static OSGK_CLASSTYPE_REF nsIServiceManager*
\r
98 (*osgk_embedding_get_gecko_service_manager) (OSGK_Embedding* embedding);*/
\r
104 /*static int (*osgk_embedding_register_js_global) (
\r
105 OSGK_Embedding* embedding, const char* name, const char* contractID,
\r
106 unsigned int flags, OSGK_String** previousContract,
\r
107 OSGK_GeckoResult* geckoResult);*/
\r
109 /*static void (*osgk_embedding_clear_focus*) (OSGK_Embedding* embedding);*/
\r
110 /*void (*osgk_embedding_set_auto_focus) (OSGK_Embedding* embedding, int autoFocus);*/
\r
111 /*static int (*osgk_embedding_get_auto_focus) (OSGK_Embedding* embedding);*/
\r
113 /* OffscreenGecko/browser.h */
\r
114 OSGK_DERIVEDTYPE(OSGK_Browser);
\r
116 static OSGK_Browser* (*osgk_browser_create) (
\r
117 OSGK_Embedding* embedding, int width, int height);
\r
118 static void (*osgk_browser_navigate) (OSGK_Browser* browser,
\r
121 static int (*osgk_browser_query_dirty) (OSGK_Browser* browser);
\r
122 static const unsigned char* (*osgk_browser_lock_data) (
\r
123 OSGK_Browser* browser, int* isDirty);
\r
124 static void (*osgk_browser_unlock_data) (OSGK_Browser* browser,
\r
125 const unsigned char* data);
\r
127 typedef enum OSGK_MouseButton
\r
132 } OSGK_MouseButton;
\r
134 typedef enum OSGK_MouseButtonEventType
\r
139 } OSGK_MouseButtonEventType;
\r
141 static void (*osgk_browser_event_mouse_move) (
\r
142 OSGK_Browser* browser, int x, int y);
\r
143 static void (*osgk_browser_event_mouse_button) (
\r
144 OSGK_Browser* browser, OSGK_MouseButton button,
\r
145 OSGK_MouseButtonEventType eventType);
\r
147 typedef enum OSGK_WheelAxis
\r
153 typedef enum OSGK_WheelDirection
\r
159 } OSGK_WheelDirection;
\r
161 static void (*osgk_browser_event_mouse_wheel) (
\r
162 OSGK_Browser* browser, OSGK_WheelAxis axis,
\r
163 OSGK_WheelDirection direction);
\r
165 typedef enum OSGK_KeyboardEventType
\r
170 } OSGK_KeyboardEventType;
\r
174 OSGKKey_First = 0x110000,
\r
176 OSGKKey_Backspace = OSGKKey_First,
\r
208 OSGKKey_ScrollLock,
\r
212 static int (*osgk_browser_event_key) (
\r
213 OSGK_Browser* browser, unsigned int key,
\r
214 OSGK_KeyboardEventType eventType);
\r
216 typedef enum OSGK_AntiAliasType
\r
221 } OSGK_AntiAliasType;
\r
223 /*static void (*osgk_browser_set_antialias) (
\r
224 OSGK_Browser* browser, OSGK_AntiAliasType aaType);*/
\r
225 /*static OSGK_AntiAliasType (*osgk_browser_get_antialias) (OSGK_Browser* browser);*/
\r
227 /*static void (*osgk_browser_focus) (OSGK_Browser* browser);*/
\r
229 static void (*osgk_browser_resize) (OSGK_Browser* browser,
\r
230 int width, int height);
\r
232 /* --- >8 --- >8 --- End OffscreenGecko headers --- 8< --- 8< --- */
\r
234 #include "quakedef.h"
\r
235 #include "cl_dyntexture.h"
\r
236 #include "cl_gecko.h"
\r
237 #include "timing.h"
\r
239 #define DEFAULT_GECKO_SIZE 512
\r
241 static rtexturepool_t *cl_geckotexturepool;
\r
242 static OSGK_Embedding *cl_geckoembedding;
\r
246 char name[ MAX_QPATH + 32 ];
\r
248 OSGK_Browser *browser;
\r
250 int texWidth, texHeight;
\r
252 rtexture_t *texture;
\r
255 static clgecko_t cl_geckoinstances[ MAX_GECKO_INSTANCES ];
\r
257 static dllhandle_t osgk_dll = NULL;
\r
259 static clgecko_t * cl_gecko_findunusedinstance( void ) {
\r
261 for( i = 0 ; i < MAX_GECKO_INSTANCES ; i++ ) {
\r
262 clgecko_t *instance = &cl_geckoinstances[ i ];
\r
263 if( !instance->active ) {
\r
267 if( developer.integer > 0 ) {
\r
268 Con_Printf( "cl_gecko_findunusedinstance: out of geckos\n" );
\r
273 clgecko_t * CL_Gecko_FindBrowser( const char *name ) {
\r
276 if( !name || !*name || strncmp( name, CLGECKOPREFIX, sizeof( CLGECKOPREFIX ) - 1 ) != 0 ) {
\r
277 if( developer.integer > 0 ) {
\r
278 Con_Printf( "CL_Gecko_FindBrowser: Bad gecko texture name '%s'!\n", name );
\r
283 for( i = 0 ; i < MAX_GECKO_INSTANCES ; i++ ) {
\r
284 clgecko_t *instance = &cl_geckoinstances[ i ];
\r
285 if( instance->active && strcmp( instance->name, name ) == 0 ) {
\r
290 if( developer.integer > 0 ) {
\r
291 Con_Printf( "CL_Gecko_FindBrowser: No browser named '%s'!\n", name );
\r
297 static void cl_gecko_updatecallback( rtexture_t *texture, clgecko_t *instance ) {
\r
298 const unsigned char *data;
\r
299 if( instance->browser ) {
\r
300 // TODO: OSGK only supports BGRA right now
\r
301 TIMING_TIMESTATEMENT(data = osgk_browser_lock_data( instance->browser, NULL ));
\r
302 R_UpdateTexture( texture, data, 0, 0, instance->width, instance->height );
\r
303 osgk_browser_unlock_data( instance->browser, data );
\r
307 static void cl_gecko_linktexture( clgecko_t *instance ) {
\r
308 // TODO: assert that instance->texture == NULL
\r
309 instance->texture = R_LoadTexture2D( cl_geckotexturepool, instance->name,
\r
310 instance->texWidth, instance->texHeight, NULL, TEXTYPE_BGRA, TEXF_ALPHA | TEXF_PERSISTENT, NULL );
\r
311 R_MakeTextureDynamic( instance->texture, cl_gecko_updatecallback, instance );
\r
312 CL_LinkDynTexture( instance->name, instance->texture );
\r
315 static void cl_gecko_unlinktexture( clgecko_t *instance ) {
\r
316 if( instance->texture ) {
\r
317 CL_UnlinkDynTexture( instance->name );
\r
318 R_FreeTexture( instance->texture );
\r
319 instance->texture = NULL;
\r
323 void CL_Gecko_Resize( clgecko_t *instance, int width, int height ) {
\r
324 int newWidth, newHeight;
\r
326 // early out if bad parameters are passed (no resize to a texture size bigger than the original texture size)
\r
327 if( !instance || !instance->browser) {
\r
331 newWidth = CeilPowerOf2( width );
\r
332 newHeight = CeilPowerOf2( height );
\r
333 if ((newWidth != instance->texWidth) || (newHeight != instance->texHeight))
\r
335 cl_gecko_unlinktexture( instance );
\r
336 instance->texWidth = newWidth;
\r
337 instance->texHeight = newHeight;
\r
338 cl_gecko_linktexture( instance );
\r
342 /* The gecko area will only cover a part of the texture; to avoid
\r
343 'old' pixels bleeding in at the border clear the texture. */
\r
344 R_ClearTexture( instance->texture );
\r
347 osgk_browser_resize( instance->browser, width, height);
\r
348 instance->width = width;
\r
349 instance->height = height;
\r
352 void CL_Gecko_GetTextureExtent( clgecko_t *instance, float* pwidth, float* pheight )
\r
354 if( !instance || !instance->browser ) {
\r
358 *pwidth = (float)instance->width / instance->texWidth;
\r
359 *pheight = (float)instance->height / instance->texHeight;
\r
363 clgecko_t * CL_Gecko_CreateBrowser( const char *name ) {
\r
364 clgecko_t *instance;
\r
366 if (!osgk_dll) return NULL;
\r
368 // TODO: verify that we dont use a name twice
\r
369 instance = cl_gecko_findunusedinstance();
\r
370 // TODO: assert != NULL
\r
372 if( cl_geckoembedding == NULL ) {
\r
373 char profile_path [MAX_OSPATH];
\r
374 OSGK_GeckoResult grc;
\r
375 OSGK_EmbeddingOptions *options;
\r
377 if( developer.integer > 0 ) {
\r
378 Con_Printf( "CL_Gecko_CreateBrowser: setting up gecko embedding\n" );
\r
381 options = osgk_embedding_options_create();
\r
382 osgk_embedding_options_add_search_path( options, "./xulrunner/" );
\r
383 dpsnprintf (profile_path, sizeof (profile_path), "%s/xulrunner_profile/", fs_gamedir);
\r
384 osgk_embedding_options_set_profile_dir( options, profile_path, 0 );
\r
385 cl_geckoembedding = osgk_embedding_create_with_options( options, &grc );
\r
386 osgk_release( options );
\r
388 if( cl_geckoembedding == NULL ) {
\r
389 Con_Printf( "CL_Gecko_CreateBrowser: Couldn't retrieve gecko embedding object (%.8x)!\n", grc );
\r
391 } else if( developer.integer > 0 ) {
\r
392 Con_Printf( "CL_Gecko_CreateBrowser: Embedding set up correctly\n" );
\r
396 instance->active = true;
\r
397 strlcpy( instance->name, name, sizeof( instance->name ) );
\r
398 instance->browser = osgk_browser_create( cl_geckoembedding, DEFAULT_GECKO_SIZE, DEFAULT_GECKO_SIZE );
\r
399 if( instance->browser == NULL ) {
\r
400 Con_Printf( "CL_Gecko_CreateBrowser: Browser object creation failed!\n" );
\r
402 // TODO: assert != NULL
\r
404 instance->width = instance->texWidth = DEFAULT_GECKO_SIZE;
\r
405 instance->height = instance->texHeight = DEFAULT_GECKO_SIZE;
\r
406 cl_gecko_linktexture( instance );
\r
411 void CL_Gecko_DestroyBrowser( clgecko_t *instance ) {
\r
412 if( !instance || !instance->active ) {
\r
416 instance->active = false;
\r
417 cl_gecko_unlinktexture( instance );
\r
419 osgk_release( instance->browser );
\r
420 instance->browser = NULL;
\r
423 void CL_Gecko_Frame( void ) {
\r
425 // FIXME: track cl_numgeckoinstances to avoid scanning the entire array?
\r
426 for( i = 0 ; i < MAX_GECKO_INSTANCES ; i++ ) {
\r
427 clgecko_t *instance = &cl_geckoinstances[ i ];
\r
428 if( instance->active ) {
\r
429 if( instance->browser && osgk_browser_query_dirty( instance->browser ) == 1 ) {
\r
430 R_MarkDirtyTexture( instance->texture );
\r
436 static void cl_gecko_start( void )
\r
439 cl_geckotexturepool = R_AllocTexturePool();
\r
441 // recreate textures on module start
\r
442 for( i = 0 ; i < MAX_GECKO_INSTANCES ; i++ ) {
\r
443 clgecko_t *instance = &cl_geckoinstances[ i ];
\r
444 if( instance->active ) {
\r
445 cl_gecko_linktexture( instance );
\r
450 static void cl_gecko_shutdown( void )
\r
453 for( i = 0 ; i < MAX_GECKO_INSTANCES ; i++ ) {
\r
454 clgecko_t *instance = &cl_geckoinstances[ i ];
\r
455 if( instance->active ) {
\r
456 cl_gecko_unlinktexture( instance );
\r
459 R_FreeTexturePool( &cl_geckotexturepool );
\r
462 static void cl_gecko_newmap( void )
\r
467 void CL_Gecko_Shutdown( void ) {
\r
469 for( i = 0 ; i < MAX_GECKO_INSTANCES ; i++ ) {
\r
470 clgecko_t *instance = &cl_geckoinstances[ i ];
\r
471 if( instance->active ) {
\r
472 cl_gecko_unlinktexture( instance );
\r
476 if (cl_geckoembedding != NULL)
\r
478 osgk_release( cl_geckoembedding );
\r
479 cl_geckoembedding = NULL;
\r
482 if (osgk_dll != NULL)
\r
484 Sys_UnloadLibrary (&osgk_dll);
\r
488 static void cl_gecko_create_f( void ) {
\r
489 char name[MAX_QPATH];
\r
491 if (Cmd_Argc() != 2)
\r
493 Con_Print("usage: gecko_create <name>\npcreates a browser (full texture path " CLGECKOPREFIX "<name>)\n");
\r
497 // TODO: use snprintf instead
\r
498 sprintf(name, CLGECKOPREFIX "%s", Cmd_Argv(1));
\r
499 CL_Gecko_CreateBrowser( name );
\r
502 static void cl_gecko_destroy_f( void ) {
\r
503 char name[MAX_QPATH];
\r
505 if (Cmd_Argc() != 2)
\r
507 Con_Print("usage: gecko_destroy <name>\ndestroys a browser\n");
\r
511 // TODO: use snprintf instead
\r
512 sprintf(name, CLGECKOPREFIX "%s", Cmd_Argv(1));
\r
513 CL_Gecko_DestroyBrowser( CL_Gecko_FindBrowser( name ) );
\r
516 static void cl_gecko_navigate_f( void ) {
\r
517 char name[MAX_QPATH];
\r
520 if (Cmd_Argc() != 3)
\r
522 Con_Print("usage: gecko_navigate <name> <URI>\nnavigates to a certain URI\n");
\r
526 // TODO: use snprintf instead
\r
527 sprintf(name, CLGECKOPREFIX "%s", Cmd_Argv(1));
\r
528 URI = Cmd_Argv( 2 );
\r
529 CL_Gecko_NavigateToURI( CL_Gecko_FindBrowser( name ), URI );
\r
532 static void cl_gecko_injecttext_f( void ) {
\r
533 char name[MAX_QPATH];
\r
535 clgecko_t *instance;
\r
538 if (Cmd_Argc() < 3)
\r
540 Con_Print("usage: gecko_injecttext <name> <text>\ninjects a certain text into the browser\n");
\r
544 // TODO: use snprintf instead
\r
545 sprintf(name, CLGECKOPREFIX "%s", Cmd_Argv(1));
\r
546 instance = CL_Gecko_FindBrowser( name );
\r
548 Con_Printf( "cl_gecko_injecttext_f: gecko instance '%s' couldn't be found!\n", name );
\r
552 text = Cmd_Argv( 2 );
\r
554 for( p = text ; *p ; p++ ) {
\r
574 CL_Gecko_Event_Key( instance, key, CLG_BET_PRESS );
\r
578 static void gl_gecko_movecursor_f( void ) {
\r
579 char name[MAX_QPATH];
\r
582 if (Cmd_Argc() != 4)
\r
584 Con_Print("usage: gecko_movecursor <name> <x> <y>\nmove the cursor to a certain position\n");
\r
588 // TODO: use snprintf instead
\r
589 sprintf(name, CLGECKOPREFIX "%s", Cmd_Argv(1));
\r
590 x = atof( Cmd_Argv( 2 ) );
\r
591 y = atof( Cmd_Argv( 3 ) );
\r
593 CL_Gecko_Event_CursorMove( CL_Gecko_FindBrowser( name ), x, y );
\r
597 #undef osgk_release
\r
599 static const dllfunction_t osgkFuncs[] =
\r
601 {"osgk_addref", (void **) &osgk_addref},
\r
602 {"osgk_release", (void **) &osgk_release},
\r
603 {"osgk_embedding_create2", (void **) &osgk_embedding_create2},
\r
604 {"osgk_embedding_options_create", (void **) &osgk_embedding_options_create},
\r
605 {"osgk_embedding_options_add_search_path", (void **) &osgk_embedding_options_add_search_path},
\r
606 {"osgk_embedding_options_set_profile_dir", (void **) &osgk_embedding_options_set_profile_dir},
\r
607 {"osgk_browser_create", (void **) &osgk_browser_create},
\r
608 {"osgk_browser_query_dirty", (void **) &osgk_browser_query_dirty},
\r
609 {"osgk_browser_navigate", (void **) &osgk_browser_navigate},
\r
610 {"osgk_browser_lock_data", (void **) &osgk_browser_lock_data},
\r
611 {"osgk_browser_unlock_data", (void **) &osgk_browser_unlock_data},
\r
612 {"osgk_browser_resize", (void **) &osgk_browser_resize},
\r
613 {"osgk_browser_event_mouse_move", (void **) &osgk_browser_event_mouse_move},
\r
614 {"osgk_browser_event_mouse_button", (void **) &osgk_browser_event_mouse_button},
\r
615 {"osgk_browser_event_mouse_wheel", (void **) &osgk_browser_event_mouse_wheel},
\r
616 {"osgk_browser_event_key", (void **) &osgk_browser_event_key},
\r
620 void CL_Gecko_Init( void )
\r
622 const char* dllnames [] =
\r
625 "OffscreenGecko64.dll",
\r
626 #elif defined(WIN32)
\r
627 "OffscreenGecko.dll",
\r
628 #elif defined(MACOSX)
\r
629 "OffscreenGecko.dylib",
\r
631 "OffscreenGecko.so",
\r
638 if (! Sys_LoadLibrary (dllnames, &osgk_dll, osgkFuncs))
\r
640 Con_Printf ("Could not load OffscreenGecko, Gecko support unavailable\n");
\r
644 Cmd_AddCommand( "gecko_create", cl_gecko_create_f, "Create a gecko browser instance" );
\r
645 Cmd_AddCommand( "gecko_destroy", cl_gecko_destroy_f, "Destroy a gecko browser instance" );
\r
646 Cmd_AddCommand( "gecko_navigate", cl_gecko_navigate_f, "Navigate a gecko browser to a URI" );
\r
647 Cmd_AddCommand( "gecko_injecttext", cl_gecko_injecttext_f, "Injects text into a browser" );
\r
648 Cmd_AddCommand( "gecko_movecursor", gl_gecko_movecursor_f, "Move the cursor to a certain position" );
\r
650 R_RegisterModule( "CL_Gecko", cl_gecko_start, cl_gecko_shutdown, cl_gecko_newmap );
\r
653 void CL_Gecko_NavigateToURI( clgecko_t *instance, const char *URI ) {
\r
654 if( !instance || !instance->browser ) {
\r
658 if( instance->active ) {
\r
659 osgk_browser_navigate( instance->browser, URI );
\r
663 void CL_Gecko_Event_CursorMove( clgecko_t *instance, float x, float y ) {
\r
664 // TODO: assert x, y \in [0.0, 1.0]
\r
665 int mappedx, mappedy;
\r
667 if( !instance || !instance->browser ) {
\r
671 mappedx = x * instance->width;
\r
672 mappedy = y * instance->height;
\r
673 osgk_browser_event_mouse_move( instance->browser, mappedx, mappedy );
\r
676 typedef struct geckokeymapping_s {
\r
678 unsigned int geckokeycode;
\r
679 } geckokeymapping_t;
\r
681 static geckokeymapping_t geckokeymappingtable[] = {
\r
682 { K_BACKSPACE, OSGKKey_Backspace },
\r
683 { K_TAB, OSGKKey_Tab },
\r
684 { K_ENTER, OSGKKey_Return },
\r
685 { K_SHIFT, OSGKKey_Shift },
\r
686 { K_CTRL, OSGKKey_Control },
\r
687 { K_ALT, OSGKKey_Alt },
\r
688 { K_CAPSLOCK, OSGKKey_CapsLock },
\r
689 { K_ESCAPE, OSGKKey_Escape },
\r
690 { K_SPACE, OSGKKey_Space },
\r
691 { K_PGUP, OSGKKey_PageUp },
\r
692 { K_PGDN, OSGKKey_PageDown },
\r
693 { K_END, OSGKKey_End },
\r
694 { K_HOME, OSGKKey_Home },
\r
695 { K_LEFTARROW, OSGKKey_Left },
\r
696 { K_UPARROW, OSGKKey_Up },
\r
697 { K_RIGHTARROW, OSGKKey_Right },
\r
698 { K_DOWNARROW, OSGKKey_Down },
\r
699 { K_INS, OSGKKey_Insert },
\r
700 { K_DEL, OSGKKey_Delete },
\r
701 { K_F1, OSGKKey_F1 },
\r
702 { K_F2, OSGKKey_F2 },
\r
703 { K_F3, OSGKKey_F3 },
\r
704 { K_F4, OSGKKey_F4 },
\r
705 { K_F5, OSGKKey_F5 },
\r
706 { K_F6, OSGKKey_F6 },
\r
707 { K_F7, OSGKKey_F7 },
\r
708 { K_F8, OSGKKey_F8 },
\r
709 { K_F9, OSGKKey_F9 },
\r
710 { K_F10, OSGKKey_F10 },
\r
711 { K_F11, OSGKKey_F11 },
\r
712 { K_F12, OSGKKey_F12 },
\r
713 { K_NUMLOCK, OSGKKey_NumLock },
\r
714 { K_SCROLLOCK, OSGKKey_ScrollLock }
\r
717 qboolean CL_Gecko_Event_Key( clgecko_t *instance, int key, clgecko_buttoneventtype_t eventtype ) {
\r
718 if( !instance || !instance->browser ) {
\r
722 // determine whether its a keyboard event
\r
723 if( key < K_OTHERDEVICESBEGIN ) {
\r
725 OSGK_KeyboardEventType mappedtype;
\r
726 unsigned int mappedkey = key;
\r
729 // yes! then convert it if necessary!
\r
730 for( i = 0 ; i < sizeof( geckokeymappingtable ) / sizeof( *geckokeymappingtable ) ; i++ ) {
\r
731 const geckokeymapping_t * const mapping = &geckokeymappingtable[ i ];
\r
732 if( key == mapping->keycode ) {
\r
733 mappedkey = mapping->geckokeycode;
\r
738 // convert the eventtype
\r
740 switch( eventtype ) {
\r
742 mappedtype = keDown;
\r
747 case CLG_BET_DOUBLECLICK:
\r
748 // TODO: error message
\r
750 case CLG_BET_PRESS:
\r
751 mappedtype = kePress;
\r
754 return osgk_browser_event_key( instance->browser, mappedkey, mappedtype ) != 0;
\r
755 } else if( K_MOUSE1 <= key && key <= K_MOUSE3 ) {
\r
756 OSGK_MouseButtonEventType mappedtype;
\r
757 OSGK_MouseButton mappedbutton;
\r
759 mappedbutton = (OSGK_MouseButton) (mbLeft + (key - K_MOUSE1));
\r
761 switch( eventtype ) {
\r
763 mappedtype = meDown;
\r
768 case CLG_BET_DOUBLECLICK:
\r
769 mappedtype = meDoubleClick;
\r
771 case CLG_BET_PRESS:
\r
772 // hihi, hacky hacky
\r
773 osgk_browser_event_mouse_button( instance->browser, mappedbutton, meDown );
\r
778 osgk_browser_event_mouse_button( instance->browser, mappedbutton, mappedtype );
\r
780 } else if( K_MWHEELUP <= key && key <= K_MWHEELDOWN ) {
\r
781 if( eventtype == CLG_BET_DOWN )
\r
782 osgk_browser_event_mouse_wheel( instance->browser,
\r
783 waVertical, (key == K_MWHEELUP) ? wdNegative : wdPositive );
\r