Просмотр исходного кода

Re-add arrow key adjustment during drags (again)

Also check for an initialized keyboard, fixes #77
Dan Elkouby 7 лет назад
Родитель
Сommit
6afaf87485
1 измененных файлов: 17 добавлений и 1 удалений
  1. 17
    1
      src/slopstates.cpp

+ 17
- 1
src/slopstates.cpp Просмотреть файл

@@ -113,7 +113,23 @@ void slop::SlopStartDrag::update( SlopMemory& memory, double dt ) {
113 113
     if ( !mouse->getButton( 1 ) ) {
114 114
         memory.setState( (SlopState*)new SlopEndDrag() );
115 115
     }
116
-    if ( keyboard->getKey( XK_Down ) ) {
116
+    if ( keyboard ) {
117
+        int arrows[2];
118
+        arrows[0] = keyboard->getKey(XK_Down)-keyboard->getKey(XK_Up);		
119
+        arrows[1] = keyboard->getKey(XK_Right)-keyboard->getKey(XK_Left);		
120
+        if ( arrows[0] || arrows[1] ) {		
121
+            if ( repeatTimer == 0 || repeatTimer > .4 ) {		
122
+                startPoint.y += arrows[0]*multiplier;		
123
+                startPoint.x += arrows[1]*multiplier;		
124
+            }		
125
+            if ( repeatTimer > 1 ) {		
126
+                multiplier += dt*2;		
127
+            }		
128
+            repeatTimer += dt;		
129
+        } else {		
130
+            repeatTimer = 0;		
131
+            multiplier = 1;		
132
+        }
117 133
     }
118 134
 }
119 135