Home | History | Annotate | Download | only in event_injector
      1 /*
      2 * Copyright (C) 2011 The Android Open Source Project
      3 *
      4 * Licensed under the Apache License, Version 2.0 (the "License");
      5 * you may not use this file except in compliance with the License.
      6 * You may obtain a copy of the License at
      7 *
      8 * http://www.apache.org/licenses/LICENSE-2.0
      9 *
     10 * Unless required by applicable law or agreed to in writing, software
     11 * distributed under the License is distributed on an "AS IS" BASIS,
     12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13 * See the License for the specific language governing permissions and
     14 * limitations under the License.
     15 */
     16 /* Event redirector is used to inject user events from a GL window
     17  * into the emulated program.
     18  */
     19 #ifndef EVENT_INJECTOR_H
     20 #define EVENT_INJECTOR_H
     21 
     22 class EventInjectorPrivate;
     23 
     24 class EventInjector
     25 {
     26 public:
     27     EventInjector(int consolePort);
     28     virtual ~EventInjector();
     29 
     30     void wait( int timeout_ms );
     31     void poll( void );
     32 
     33     void sendMouseDown( int x, int y );
     34     void sendMouseUp( int x, int y );
     35     void sendMouseMotion( int x, int y );
     36     void sendKeyDown( int keycode );
     37     void sendKeyUp( int keycode );
     38 
     39     /* Keycode values expected by the Linux kernel, and the emulator */
     40     enum {
     41         KEY_BACK = 158,
     42         KEY_HOME = 102,
     43         KEY_SOFT1 = 229,
     44         KEY_LEFT = 105,
     45         KEY_UP   = 103,
     46         KEY_DOWN =  108,
     47         KEY_RIGHT = 106,
     48         KEY_VOLUMEUP = 115,
     49         KEY_VOLUMEDOWN = 114,
     50         KEY_SEND = 231,
     51         KEY_END = 107,
     52         KEY_ENTER = 28,
     53     };
     54 
     55 private:
     56     EventInjectorPrivate* mPrivate;
     57 };
     58 
     59 #endif /* EVENT_INJECTOR_H */
     60