56
56
57
57
public class PApplet extends Object implements PConstants {
58
58
59
+ //static final public boolean DEBUG = true;
60
+ static final public boolean DEBUG = false ;
61
+
62
+ // Convenience public constant holding the SDK version, akin to platform in Java mode
63
+ static final public int SDK = Build .VERSION .SDK_INT ;
64
+
65
+ //static final public int SDK = Build.VERSION_CODES.ICE_CREAM_SANDWICH; // Forcing older SDK for testing
66
+
59
67
/**
60
68
* The surface this sketch draws to.
61
69
*/
@@ -69,14 +77,6 @@ public class PApplet extends Object implements PConstants {
69
77
/** The PGraphics renderer associated with this PApplet */
70
78
public PGraphics g ;
71
79
72
- // static final public boolean DEBUG = true;
73
- static final public boolean DEBUG = false ;
74
-
75
- // Convenience public constant holding the SDK version, akin to platform in Java mode
76
- static final public int SDK = Build .VERSION .SDK_INT ;
77
-
78
- // static final public int SDK = Build.VERSION_CODES.ICE_CREAM_SANDWICH; // Forcing older SDK for testing
79
-
80
80
/**
81
81
* The screen size when the sketch was started. This is initialized inside
82
82
* onCreate().
@@ -147,6 +147,9 @@ public class PApplet extends Object implements PConstants {
147
147
public int pixelWidth ;
148
148
public int pixelHeight ;
149
149
150
+ ///////////////////////////////////////////////////////////////
151
+ // Mouse events
152
+
150
153
/** absolute x position of input on screen */
151
154
public int mouseX ;
152
155
@@ -203,6 +206,8 @@ public class PApplet extends Object implements PConstants {
203
206
*/
204
207
protected int touchPointerId ;
205
208
209
+ ///////////////////////////////////////////////////////////////
210
+ // Key events
206
211
207
212
/**
208
213
* Last key pressed.
@@ -236,6 +241,11 @@ public class PApplet extends Object implements PConstants {
236
241
*/
237
242
public boolean focused = false ;
238
243
244
+ /**
245
+ * Keeps track of ENABLE_KEY_REPEAT hint
246
+ */
247
+ protected boolean keyRepeatEnabled = false ;
248
+
239
249
///////////////////////////////////////////////////////////////
240
250
// Permission handling
241
251
@@ -250,31 +260,9 @@ public class PApplet extends Object implements PConstants {
250
260
*/
251
261
protected ArrayList <String > reqPermissions = new ArrayList <String >();
252
262
263
+
253
264
///////////////////////////////////////////////////////////////
254
- // Wallpaper and watchface variables: these will go away soon...
255
- @ Deprecated
256
- public boolean ambientMode = false ;
257
- @ Deprecated
258
- public boolean isRound = false ;
259
- @ Deprecated
260
- public int insetLeft = 0 ;
261
- @ Deprecated
262
- public int insetRight = 0 ;
263
- @ Deprecated
264
- public int insetTop = 0 ;
265
- @ Deprecated
266
- public int insetBottom = 0 ;
267
- @ Deprecated
268
- public boolean lowBitAmbient = false ;
269
- @ Deprecated
270
- public boolean burnInProtection = false ;
271
- @ Deprecated
272
- public boolean preview = false ;
273
- @ Deprecated
274
- public float homeScreenOffset = 0 ;
275
- @ Deprecated
276
- public int homeScreenCount = 1 ;
277
- ///////////////////////////////////////////////////////////////
265
+ // Rendering/timing
278
266
279
267
/**
280
268
* Time in milliseconds when the applet was started.
@@ -326,9 +314,31 @@ public class PApplet extends Object implements PConstants {
326
314
*/
327
315
protected boolean exitCalled ;
328
316
329
- // Thread thread;
317
+ boolean insideSettings ;
318
+
319
+ String renderer = JAVA2D ;
320
+
321
+ int smooth = 1 ; // default smoothing (whatever that means for the renderer)
322
+
323
+ boolean fullScreen = false ;
324
+
325
+ int display = -1 ; // use default
326
+
327
+ // Background default needs to be different from the default value in
328
+ // PGraphics.backgroundColor, otherwise size(100, 100) bg spills over.
329
+ // https://github.com/processing/processing/issues/2297
330
+ int windowColor = 0xffDDDDDD ;
330
331
331
- // messages to send if attached as an external vm
332
+ PStyle savedStyle ;
333
+
334
+ ///////////////////////////////////////////////////////////////
335
+ // Error messages
336
+
337
+ static final String ERROR_MIN_MAX =
338
+ "Cannot use min() or max() on an empty array." ;
339
+
340
+ ///////////////////////////////////////////////////////////////
341
+ // Command line options
332
342
333
343
/**
334
344
* Position of the upper-lefthand corner of the editor window
@@ -386,25 +396,6 @@ public class PApplet extends Object implements PConstants {
386
396
/** true if this sketch is being run by the PDE */
387
397
boolean external = false ;
388
398
389
- static final String ERROR_MIN_MAX =
390
- "Cannot use min() or max() on an empty array." ;
391
-
392
- boolean insideSettings ;
393
-
394
- String renderer = JAVA2D ;
395
-
396
- int smooth = 1 ; // default smoothing (whatever that means for the renderer)
397
-
398
- boolean fullScreen = false ;
399
-
400
- int display = -1 ; // use default
401
-
402
- // Background default needs to be different from the default value in
403
- // PGraphics.backgroundColor, otherwise size(100, 100) bg spills over.
404
- // https://github.com/processing/processing/issues/2297
405
- int windowColor = 0xffDDDDDD ;
406
-
407
- PStyle savedStyle ;
408
399
409
400
//////////////////////////////////////////////////////////////
410
401
//////////////////////////////////////////////////////////////
@@ -2428,6 +2419,10 @@ boolean wearBurnProtection() {
2428
2419
2429
2420
2430
2421
protected void handleKeyEvent (KeyEvent event ) {
2422
+
2423
+ // Get rid of auto-repeating keys if desired and supported
2424
+ if (!keyRepeatEnabled && event .isAutoRepeat ()) return ;
2425
+
2431
2426
// keyEvent = event;
2432
2427
key = event .getKey ();
2433
2428
keyCode = event .getKeyCode ();
@@ -2469,8 +2464,10 @@ protected void nativeKeyEvent(android.view.KeyEvent event) {
2469
2464
// TODO set up proper key modifier handling
2470
2465
int keModifiers = 0 ;
2471
2466
2467
+ // KeyEvent ke = new KeyEvent(event, event.getEventTime(),
2468
+ // keAction, keModifiers, key, keyCode);
2472
2469
KeyEvent ke = new KeyEvent (event , event .getEventTime (),
2473
- keAction , keModifiers , key , keyCode );
2470
+ keAction , keModifiers , key , keyCode , 0 < event . getRepeatCount () );
2474
2471
2475
2472
postEvent (ke );
2476
2473
}
0 commit comments