@@ -513,6 +513,58 @@ var LibraryGLFW = {
513
513
win . windowRefreshFunc = cbfun ;
514
514
} ,
515
515
516
+ onClickRequestPointerLock : function ( e ) {
517
+ if ( ! Browser . pointerLock && Module [ 'canvas' ] . requestPointerLock ) {
518
+ Module [ 'canvas' ] . requestPointerLock ( ) ;
519
+ e . preventDefault ( ) ;
520
+ }
521
+ } ,
522
+
523
+ setInputMode : function ( winid , mode , value ) {
524
+ var win = GLFW . WindowFromId ( winid ) ;
525
+ if ( ! win ) return ;
526
+
527
+ switch ( mode ) {
528
+ case 0x00033001 : // GLFW_CURSOR
529
+ {
530
+ switch ( value ) {
531
+ case 0x00034001 : // GLFW_CURSOR_NORMAL
532
+ win . inputModes [ mode ] = value ;
533
+ Module [ 'canvas' ] . removeEventListener ( 'click' , GLFW . onClickRequestPointerLock , true ) ;
534
+ Module [ 'canvas' ] . exitPointerLock ( ) ;
535
+ break ;
536
+
537
+ case 0x00034002 : // GLFW_CURSOR_HIDDEN
538
+ console . log ( "glfwSetInputMode called with GLFW_CURSOR_HIDDEN value not implemented." ) ;
539
+ break ;
540
+
541
+ case 0x00034003 : // GLFW_CURSOR_DISABLED
542
+ win . inputModes [ mode ] = value ;
543
+ Module [ 'canvas' ] . addEventListener ( 'click' , GLFW . onClickRequestPointerLock , true ) ;
544
+ Module [ 'canvas' ] . requestPointerLock ( ) ;
545
+ break ;
546
+
547
+ default :
548
+ console . log ( "glfwSetInputMode called with unknown value parameter value: " + value + "." ) ;
549
+ break ;
550
+ }
551
+ }
552
+ break ;
553
+
554
+ case 0x00033002 : // GLFW_STICKY_KEYS
555
+ console . log ( "glfwSetInputMode called with GLFW_STICKY_KEYS mode not implemented." ) ;
556
+ break ;
557
+
558
+ case 0x00033003 : // GLFW_STICKY_MOUSE_BUTTONS
559
+ console . log ( "glfwSetInputMode called with GLFW_STICKY_MOUSE_BUTTONS mode not implemented." ) ;
560
+ break ;
561
+
562
+ default :
563
+ console . log ( "glfwSetInputMode called with unknown mode parameter value: " + mode + "." ) ;
564
+ break ;
565
+ }
566
+ } ,
567
+
516
568
getKey : function ( winid , key ) {
517
569
var win = GLFW . WindowFromId ( winid ) ;
518
570
if ( ! win ) return 0 ;
@@ -588,14 +640,14 @@ var LibraryGLFW = {
588
640
}
589
641
}
590
642
591
- if ( ! win . windowResizeFunc ) return ;
643
+ if ( ! win . windowSizeFunc ) return ;
592
644
593
645
#if USE_GLFW == 2
594
- Runtime . dynCall ( 'vii' , win . windowResizeFunc , [ width , height ] ) ;
646
+ Runtime . dynCall ( 'vii' , win . windowSizeFunc , [ width , height ] ) ;
595
647
#endif
596
648
597
649
#if USE_GLFW == 3
598
- Runtime . dynCall ( 'viii' , win . windowResizeFunc , [ win . id , width , height ] ) ;
650
+ Runtime . dynCall ( 'viii' , win . windowSizeFunc , [ win . id , width , height ] ) ;
599
651
#endif
600
652
} ,
601
653
@@ -1004,11 +1056,9 @@ var LibraryGLFW = {
1004
1056
return win . inputModes [ mode ] ;
1005
1057
} ,
1006
1058
1007
- // TODO: implement
1008
- // GLFW_STICKY_KEYS == key stays pressed until pressed second time
1009
- // GLFW_STICKY_MOUSE_BUTTONS == same as above but for mouse buttons
1010
- // GLFW_CURSOR == NORMAL, HIDDEN (no pointer), DISABLED (hidden && always centered)
1011
- glfwSetInputMode : function ( winid , mode , value ) { } ,
1059
+ glfwSetInputMode : function ( winid , mode , value ) {
1060
+ GLFW . setInputMode ( winid , mode , value ) ;
1061
+ } ,
1012
1062
1013
1063
glfwGetKey : function ( winid , key ) {
1014
1064
return GLFW . getKey ( winid , key ) ;
0 commit comments