def __init__(self): self.key_names = defaultdict(lambda:'UNKNOWN') for f in KeyEvent.getDeclaredFields(): if Modifier.isStatic(f.getModifiers()): self.name = f.getName() if self.name.startswith("VK_"): self.key_names[f.getInt(None)] = self.name[3:]
def setup(): size(640, 640) global colors global bobble global position global key_names key_names = defaultdict(lambda: 'UNKNOWN') for f in KeyEvent.getDeclaredFields(): if Modifier.isStatic(f.getModifiers()): name = f.getName() if name.startswith("VK_"): key_names[f.getInt(None)] = name[3:] position = {} position['x'] = width / 2 position['y'] = height / 2 colors = {} colors['white'] = color(255, 255, 255) colors['blueish'] = color(39, 61, 183) colors['redish'] = color(211, 17, 24) # initialize our avatar shape d = 55 bobble = createShape(GROUP) bubble = createShape(ELLIPSE, 0, 0, d, d) bubble.setFill(colors['blueish']) bobble.noStroke() bobble.addChild(bubble) sight = createShape() sight.beginShape() sight.vertex(0, 0) sight.vertex(d / 2, -d / 2) # correction of 45 deg sight.rotate(radians(45)) sight.endShape(CLOSE) bobble.addChild(sight)
#!/usr/bin/env python3 __author__ = 'Yatharth Agarwal <*****@*****.**>' """Map keys for decoding raw key data""" from collections import defaultdict from java.awt.event import KeyEvent from java.lang.reflect import Modifier KEY_NAMES = defaultdict(lambda: 'UNKNOWN') for f in KeyEvent.getDeclaredFields(): if Modifier.isStatic(f.getModifiers()): name = f.getName() if name.startswith("VK_"): KEY_NAMES[f.getInt(None)] = name[3:]