| 157 |
}; |
}; |
| 158 |
this.receiver.addListener("/orient", listener); |
this.receiver.addListener("/orient", listener); |
| 159 |
// |
// |
| 160 |
|
listener = new OSCListener() { |
| 161 |
|
public void acceptMessage(java.util.Date time, OSCMessage message) { |
| 162 |
|
Object[] args = message.getArguments(); |
| 163 |
|
if (args.length == 1) { |
| 164 |
|
zoom(Boolean.parseBoolean(args[0].toString())); |
| 165 |
|
} |
| 166 |
|
} |
| 167 |
|
}; |
| 168 |
|
this.receiver.addListener("/zoom", listener); |
| 169 |
|
// |
| 170 |
|
listener = new OSCListener() { |
| 171 |
|
public void acceptMessage(java.util.Date time, OSCMessage message) { |
| 172 |
|
Object[] args = message.getArguments(); |
| 173 |
|
if (args.length == 1) { |
| 174 |
|
switchTab(Boolean.parseBoolean(args[0].toString())); |
| 175 |
|
} |
| 176 |
|
} |
| 177 |
|
}; |
| 178 |
|
this.receiver.addListener("/switchtab", listener); |
| 179 |
|
// |
| 180 |
this.receiver.startListening(); |
this.receiver.startListening(); |
| 181 |
// debug |
// debug |
| 182 |
GlobalData.oFrame.addKeyListener(new KeyListener() { |
GlobalData.oFrame.addKeyListener(new KeyListener() { |
| 272 |
} |
} |
| 273 |
} |
} |
| 274 |
|
|
| 275 |
|
private void zoom(boolean zoomIn) { |
| 276 |
|
if (zoomIn) { |
| 277 |
|
zoomIn(); |
| 278 |
|
} else { |
| 279 |
|
zoomOut(); |
| 280 |
|
} |
| 281 |
|
} |
| 282 |
|
|
| 283 |
|
private void switchTab(boolean switchRight) { |
| 284 |
|
if (switchRight) { |
| 285 |
|
switchTabRight(); |
| 286 |
|
} else { |
| 287 |
|
switchTabLeft(); |
| 288 |
|
} |
| 289 |
|
} |
| 290 |
|
|
| 291 |
|
private synchronized void zoomIn() { |
| 292 |
|
this.robot.keyPress(KeyEvent.VK_CONTROL); |
| 293 |
|
this.robot.keyPress(KeyEvent.VK_EQUALS); |
| 294 |
|
this.robot.keyRelease(KeyEvent.VK_EQUALS); |
| 295 |
|
this.robot.keyRelease(KeyEvent.VK_CONTROL); |
| 296 |
|
} |
| 297 |
|
|
| 298 |
|
private synchronized void zoomOut() { |
| 299 |
|
this.robot.keyPress(KeyEvent.VK_CONTROL); |
| 300 |
|
this.robot.keyPress(KeyEvent.VK_MINUS); |
| 301 |
|
this.robot.keyRelease(KeyEvent.VK_MINUS); |
| 302 |
|
this.robot.keyRelease(KeyEvent.VK_CONTROL); |
| 303 |
|
} |
| 304 |
|
|
| 305 |
|
private synchronized void switchTabRight() { |
| 306 |
|
this.robot.keyPress(KeyEvent.VK_CONTROL); |
| 307 |
|
this.robot.keyPress(KeyEvent.VK_TAB); |
| 308 |
|
this.robot.keyRelease(KeyEvent.VK_TAB); |
| 309 |
|
this.robot.keyRelease(KeyEvent.VK_CONTROL); |
| 310 |
|
} |
| 311 |
|
|
| 312 |
|
private synchronized void switchTabLeft() { |
| 313 |
|
this.robot.keyPress(KeyEvent.VK_CONTROL); |
| 314 |
|
this.robot.keyPress(KeyEvent.VK_SHIFT); |
| 315 |
|
this.robot.keyPress(KeyEvent.VK_TAB); |
| 316 |
|
this.robot.keyRelease(KeyEvent.VK_TAB); |
| 317 |
|
this.robot.keyRelease(KeyEvent.VK_SHIFT); |
| 318 |
|
this.robot.keyRelease(KeyEvent.VK_CONTROL); |
| 319 |
|
} |
| 320 |
|
|
| 321 |
/** |
/** |
| 322 |
* TODO: Improve latency by using JNA |
* TODO: Improve latency by using JNA |
| 323 |
*/ |
*/ |
| 343 |
} |
} |
| 344 |
|
|
| 345 |
//Raw keyboard event, no translation, intercepted when argument count is 2 |
//Raw keyboard event, no translation, intercepted when argument count is 2 |
| 346 |
private void keyboardEvent(int type, int keycode) { |
private synchronized void keyboardEvent(int type, int keycode) { |
| 347 |
switch (type) { |
switch (type) { |
| 348 |
case 0: |
case 0: |
| 349 |
// key down |
// key down |
| 366 |
} |
} |
| 367 |
} |
} |
| 368 |
|
|
| 369 |
private void keyboardEvent(int type, int keycode, String value) { |
private synchronized void keyboardEvent(int type, int keycode, String value) { |
| 370 |
// |
// |
| 371 |
KeyCodeData data; |
KeyCodeData data; |
| 372 |
|
|
| 486 |
/** |
/** |
| 487 |
* Calls the robot method and catches exceptions due to invalid key. |
* Calls the robot method and catches exceptions due to invalid key. |
| 488 |
* |
* |
| 489 |
|
* Don't call this directly! Use keyboardEvent(), which is synchronized |
| 490 |
|
* |
| 491 |
* @param localcode |
* @param localcode |
| 492 |
*/ |
*/ |
| 493 |
private void keyPress(int localcode) { |
private void keyPress(int localcode) { |
| 501 |
/** |
/** |
| 502 |
* Calls the robot method and catches exceptions due to invalid key. |
* Calls the robot method and catches exceptions due to invalid key. |
| 503 |
* |
* |
| 504 |
|
* Don't call this directly! Use keyboardEvent(), which is synchronized |
| 505 |
|
* |
| 506 |
* @param localcode |
* @param localcode |
| 507 |
*/ |
*/ |
| 508 |
private void keyRelease(int localcode) { |
private void keyRelease(int localcode) { |