Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.kant.remoteBluetooth;
- import java.awt.Robot;
- import java.awt.event.KeyEvent;
- import java.io.InputStream;
- import javax.microedition.io.StreamConnection;
- public class ProcessConnectionThread implements Runnable {
- private StreamConnection comm = null;
- private static final int EXIT_CMD = -1;
- private static final int KEY_RIGHT = 2;
- private static final int KEY_LEFT = 3;
- public ProcessConnectionThread(StreamConnection conn) {
- comm = conn;
- }
- @Override
- public void run() {
- try {
- InputStream inputStream = comm.openInputStream();
- System.out.println("waiting for the input");
- Robot robo = new Robot();
- while (true) {
- int command = inputStream.read();
- if(command == EXIT_CMD){System.out.println("Process terminating");break;}
- switch (command) {
- case KEY_RIGHT:
- robo.keyPress(KeyEvent.VK_RIGHT);
- break;
- case KEY_LEFT:
- robo.keyPress(KeyEvent.VK_LEFT);
- break;
- }
- }
- } catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement