Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- import java.io.File;
- import java.io.FileInputStream;
- import java.io.FileNotFoundException;
- import java.io.IOException;
- import java.io.IOException;
- import java.nio.file.Files;
- import java.nio.file.Path;
- import java.nio.file.Paths;
- public class Main {
- public static void main(String[] args){
- try {
- File f = new File(FILE_NAME);
- FileInputStream fis = new FileInputStream(f);
- byte[] b = new byte[20000];
- while (true) {
- int n = fis.read(b);
- System.out.println("n = " + n);
- byte type = b[16];
- byte code = b[18];
- byte value = b[20];
- if (type == 2 && code == 8) {
- if(value == -1) {
- System.out.println("Down");
- } else {
- System.out.println("Up");
- }
- }
- // for (int i = 0; i < 12; i++) {
- // for (int j = 0; j < 4; j++) {
- // System.out.print("" + b[i * 4 + j] + " ");
- // }
- // System.out.println();
- // }
- System.out.println("type = " + type);
- System.out.println("code = " + code);
- System.out.println("value = " + value);
- }
- } catch (FileNotFoundException e) {
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
- }
- /*
- Main binary = new Main();
- try {
- byte[] bytes = binary.readSmallBinaryFile(FILE_NAME);
- System.out.println(bytes.length);
- } catch (IOException e) {
- e.printStackTrace();
- }
- */
- }
- final static String FILE_NAME = "/dev/input/event17";
- byte[] readSmallBinaryFile(String aFileName) throws IOException {
- Path path = Paths.get(aFileName);
- System.out.println(path);
- return Files.readAllBytes(path);
- }
- private static void log(Object aMsg){
- System.out.println(String.valueOf(aMsg));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement