1 /*
   2  * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package com.sun.glass.ui.monocle.input.devices;
  27 
  28 import com.sun.glass.ui.monocle.TestApplication;
  29 import com.sun.glass.ui.monocle.UInput;
  30 import org.junit.Assume;
  31 
  32 /**
  33  * SamsungLMS700KF07004Device sends ABS_X and ABS_Y events. It uses BTN_TOUCH to notify
  34  * presses and releases. It does not send ABS_X or ABS_Y if that coordinate has
  35  * not changed. It also sends BTN_TOOL_PEN events on press events, but not on
  36  * release events.
  37  */
  38 public class SamsungLMS700KF07004Device extends TestTouchDevice {
  39 
  40     public SamsungLMS700KF07004Device() {
  41         super(1);
  42     }
  43 
  44     @Override
  45     public void create() {
  46         Assume.assumeTrue(TestApplication.isMonocle());
  47         ui = new UInput();
  48         ui.processLine("OPEN");
  49         ui.processLine("EVBIT EV_SYN");
  50         ui.processLine("EVBIT EV_KEY");
  51         ui.processLine("KEYBIT BTN_TOUCH");
  52         ui.processLine("KEYBIT BTN_TOOL_PEN");
  53         ui.processLine("EVBIT EV_ABS");
  54         ui.processLine("ABSBIT ABS_X");
  55         ui.processLine("ABSBIT ABS_Y");
  56         ui.processLine("ABSMIN ABS_X 0");
  57         ui.processLine("ABSMAX ABS_X 4095");
  58         ui.processLine("ABSMIN ABS_Y 0");
  59         ui.processLine("ABSMAX ABS_Y 4095");
  60         ui.processLine("PROPBIT INPUT_PROP_POINTER");
  61         ui.processLine("PROPBIT INPUT_PROP_DIRECT");
  62         ui.processLine("PROPERTY ID_INPUT_TABLET 1");
  63         ui.processLine("PROPERTY ID_VENDOR eGalax_Inc.");
  64         ui.processLine("PROPERTY ID_VENDOR_ID 0x0eef");
  65         ui.processLine("PROPERTY ID_VENDOR_ENC eGalax");
  66         ui.processLine("PROPERTY ID_BUS usb");
  67         ui.processLine("PROPERTY ID_INPUT 1");
  68         ui.processLine("PROPERTY ID_MODEL Touch");
  69         ui.processLine("PROPERTY ID_MODEL_ENC Touch");
  70         ui.processLine("PROPERTY ID_MODEL_ID 0001");
  71         ui.processLine("PROPERTY ID_REVISION 0100");
  72         ui.processLine("PROPERTY ID_SERIAL eGalax_Inc._Touch");
  73         ui.processLine("PROPERTY ID_TYPE hid");
  74         ui.processLine("PROPERTY ID_USB_DRIVER usbhid");
  75         ui.processLine("PROPERTY ID_MODEL_ID 0001");
  76         ui.processLine("PROPERTY ID_REVISION 0100");
  77         ui.processLine("PROPERTY ID_USB_INTERFACES :030000:");
  78         ui.processLine("PROPERTY ID_USB_INTERFACE_NUM 00");
  79         ui.processLine("PROPERTY MAJOR 13");
  80         ui.processLine("PROPERTY MINOR 65");
  81         ui.processLine("PROPERTY SUBSYSTEM input");
  82         ui.processLine("CREATE");
  83         setAbsScale(4096, 4096);
  84     }
  85 
  86     @Override
  87     public int addPoint(double x, double y) {
  88         int p = super.addPoint(x, y);
  89         ui.processLine("EV_KEY BTN_TOUCH 1");
  90         ui.processLine("EV_KEY BTN_TOOL_PEN 1");
  91         ui.processLine("EV_ABS ABS_X " + transformedXs[p]);
  92         ui.processLine("EV_ABS ABS_Y " + transformedYs[p]);
  93         return p;
  94     }
  95 
  96     @Override
  97     public void removePoint(int p) {
  98         super.removePoint(p);
  99         ui.processLine("EV_KEY BTN_TOUCH 0");
 100     }
 101 
 102     @Override
 103     public void setPoint(int p, double x, double y) {
 104         int oldX = transformedXs[p];
 105         int oldY = transformedYs[p];
 106         super.setPoint(p, x, y);
 107         // if neither X nor Y have changed, we send X
 108         if (oldX != transformedXs[p] || oldY == transformedYs[p]) {
 109             ui.processLine("EV_ABS ABS_X " + transformedXs[p]);
 110         }
 111         if (oldY != transformedYs[p]) {
 112             ui.processLine("EV_ABS ABS_Y " + transformedYs[p]);
 113         }
 114     }
 115 
 116     @Override
 117     public void resendStateAndSync() {
 118         if (points[0]) {
 119             ui.processLine("EV_ABS ABS_X " + transformedXs[0]);
 120             ui.processLine("EV_ABS ABS_Y " + transformedYs[0]);
 121         }
 122         sync();
 123     }
 124 
 125 }