remove eventcode.h

This commit is contained in:
侯歌 2024-04-24 23:03:26 +08:00
parent 45222c3c50
commit fc4d07aae5
31 changed files with 567 additions and 875 deletions

View File

@ -170,7 +170,7 @@ bool Dialog::onKeyLongPress(int keyCode,KeyEvent& event){
}
bool Dialog::onKeyUp(int keyCode,KeyEvent& event){
if (keyCode == KEY_BACK && event.isTracking() && !event.isCanceled()) {
if (keyCode == KeyEvent::KEYCODE_BACK && event.isTracking() && !event.isCanceled()) {
onBackPressed();
return true;
}

View File

@ -1,407 +0,0 @@
/* Input event codes
*
* *** IMPORTANT ***
* This file is not only included from C-code but also from devicetree source
* files. As such this file MUST only contain comments and defines.
*/
#ifndef _INPUT_EVENT_CODES_H
#define _INPUT_EVENT_CODES_H
#include <core/keycodes.h>
/*
* Device properties and quirks
*/
#define INPUT_PROP_POINTER 0x00 /* needs a pointer */
#define INPUT_PROP_DIRECT 0x01 /* direct input devices */
#define INPUT_PROP_BUTTONPAD 0x02 /* has button(s) under pad */
#define INPUT_PROP_SEMI_MT 0x03 /* touch rectangle only */
#define INPUT_PROP_TOPBUTTONPAD 0x04 /* softbuttons at top of pad */
#define INPUT_PROP_POINTING_STICK 0x05 /* is a pointing stick */
#define INPUT_PROP_ACCELEROMETER 0x06 /* has accelerometer */
#define INPUT_PROP_MAX 0x1f
#define INPUT_PROP_CNT (INPUT_PROP_MAX + 1)
/*
* Event types
*/
#define EV_SYN 0x00
#define EV_KEY 0x01
#define EV_REL 0x02
#define EV_ABS 0x03
#define EV_MSC 0x04
#define EV_SW 0x05
#define EV_LED 0x11
#define EV_SND 0x12
#define EV_REP 0x14
#define EV_FF 0x15
#define EV_PWR 0x16
#define EV_FF_STATUS 0x17
#define EV_MAX 0x1f
#define EV_CNT (EV_MAX+1)
#ifndef EV_ADD
#define EV_ADD 0xFE/*added by zhhou,used by INPUTEVENT's type, for device add*/
#define EV_REMOVE 0xFF/*added by zhhou,used by INPUTEVENT's type, for device remove*/
#endif
/*
* Synchronization events.
*/
#define SYN_REPORT 0
#define SYN_CONFIG 1
#define SYN_MT_REPORT 2
#define SYN_DROPPED 3
#define SYN_MAX 0xf
#define SYN_CNT (SYN_MAX+1)
/*
* Keys and buttons
*
* Most of the keys/buttons are modeled after USB HUT 1.12
* (see http://www.usb.org/developers/hidpage).
* Abbreviations in the comments:
* AC - Application Control
* AL - Application Launch Button
* SC - System Control
*/
/* Code 255 is reserved for special needs of AT keyboard driver */
#define KEY_LEFT KEY_DPAD_LEFT
#define KEY_RIGHT KEY_DPAD_RIGHT
#define KEY_UP KEY_DPAD_UP
#define KEY_DOWN KEY_DPAD_DOWN
#define KEY_PAGEUP KEY_PAGE_UP
#define KEY_PAGEDOWN KEY_PAGE_DOWN
#define KEY_DELETE KEY_DEL
#define KEY_BACKSPACE KEY_BACK
#define KEY_VOLUMEUP KEY_VOLUME_UP
#define KEY_VOLUMEDOWN KEY_VOLUME_DOWN
#define KEY_RED KEY_PROG_RED
#define KEY_GREEN KEY_PROG_GREEN
#define KEY_YELLOW KEY_PROG_YELLOW
#define KEY_BLUE KEY_PROG_BLUE
#define BTN_MISC 0x100
#define BTN_0 0x100
#define BTN_1 0x101
#define BTN_2 0x102
#define BTN_3 0x103
#define BTN_4 0x104
#define BTN_5 0x105
#define BTN_6 0x106
#define BTN_7 0x107
#define BTN_8 0x108
#define BTN_9 0x109
#define BTN_MOUSE 0x110
#define BTN_LEFT 0x110
#define BTN_RIGHT 0x111
#define BTN_MIDDLE 0x112
#define BTN_SIDE 0x113
#define BTN_EXTRA 0x114
#define BTN_FORWARD 0x115
#define BTN_BACK 0x116
#define BTN_TASK 0x117
#define BTN_JOYSTICK 0x120
#define BTN_TRIGGER 0x120
#define BTN_THUMB 0x121
#define BTN_THUMB2 0x122
#define BTN_TOP 0x123
#define BTN_TOP2 0x124
#define BTN_PINKIE 0x125
#define BTN_BASE 0x126
#define BTN_BASE2 0x127
#define BTN_BASE3 0x128
#define BTN_BASE4 0x129
#define BTN_BASE5 0x12a
#define BTN_BASE6 0x12b
#define BTN_DEAD 0x12f
#define BTN_GAMEPAD 0x130
#define BTN_SOUTH 0x130
#define BTN_A BTN_SOUTH
#define BTN_EAST 0x131
#define BTN_B BTN_EAST
#define BTN_C 0x132
#define BTN_NORTH 0x133
#define BTN_X BTN_NORTH
#define BTN_WEST 0x134
#define BTN_Y BTN_WEST
#define BTN_Z 0x135
#define BTN_TL 0x136
#define BTN_TR 0x137
#define BTN_TL2 0x138
#define BTN_TR2 0x139
#define BTN_SELECT 0x13a
#define BTN_START 0x13b
#define BTN_MODE 0x13c
#define BTN_THUMBL 0x13d
#define BTN_THUMBR 0x13e
#define BTN_DIGI 0x140
#define BTN_TOOL_PEN 0x140
#define BTN_TOOL_RUBBER 0x141
#define BTN_TOOL_BRUSH 0x142
#define BTN_TOOL_PENCIL 0x143
#define BTN_TOOL_AIRBRUSH 0x144
#define BTN_TOOL_FINGER 0x145
#define BTN_TOOL_MOUSE 0x146
#define BTN_TOOL_LENS 0x147
#define BTN_TOOL_QUINTTAP 0x148 /* Five fingers on trackpad */
#define BTN_TOUCH 0x14a
#define BTN_STYLUS 0x14b
#define BTN_STYLUS2 0x14c
#define BTN_TOOL_DOUBLETAP 0x14d
#define BTN_TOOL_TRIPLETAP 0x14e
#define BTN_TOOL_QUADTAP 0x14f /* Four fingers on trackpad */
#define BTN_WHEEL 0x150
#define BTN_GEAR_DOWN 0x150
#define BTN_GEAR_UP 0x151
#if 0
#endif
#define BTN_TRIGGER_HAPPY 0x2c0
#define BTN_TRIGGER_HAPPY1 0x2c0
#define BTN_TRIGGER_HAPPY2 0x2c1
#define BTN_TRIGGER_HAPPY3 0x2c2
#define BTN_TRIGGER_HAPPY4 0x2c3
#define BTN_TRIGGER_HAPPY5 0x2c4
#define BTN_TRIGGER_HAPPY6 0x2c5
#define BTN_TRIGGER_HAPPY7 0x2c6
#define BTN_TRIGGER_HAPPY8 0x2c7
#define BTN_TRIGGER_HAPPY9 0x2c8
#define BTN_TRIGGER_HAPPY10 0x2c9
#define BTN_TRIGGER_HAPPY11 0x2ca
#define BTN_TRIGGER_HAPPY12 0x2cb
#define BTN_TRIGGER_HAPPY13 0x2cc
#define BTN_TRIGGER_HAPPY14 0x2cd
#define BTN_TRIGGER_HAPPY15 0x2ce
#define BTN_TRIGGER_HAPPY16 0x2cf
#define BTN_TRIGGER_HAPPY17 0x2d0
#define BTN_TRIGGER_HAPPY18 0x2d1
#define BTN_TRIGGER_HAPPY19 0x2d2
#define BTN_TRIGGER_HAPPY20 0x2d3
#define BTN_TRIGGER_HAPPY21 0x2d4
#define BTN_TRIGGER_HAPPY22 0x2d5
#define BTN_TRIGGER_HAPPY23 0x2d6
#define BTN_TRIGGER_HAPPY24 0x2d7
#define BTN_TRIGGER_HAPPY25 0x2d8
#define BTN_TRIGGER_HAPPY26 0x2d9
#define BTN_TRIGGER_HAPPY27 0x2da
#define BTN_TRIGGER_HAPPY28 0x2db
#define BTN_TRIGGER_HAPPY29 0x2dc
#define BTN_TRIGGER_HAPPY30 0x2dd
#define BTN_TRIGGER_HAPPY31 0x2de
#define BTN_TRIGGER_HAPPY32 0x2df
#define BTN_TRIGGER_HAPPY33 0x2e0
#define BTN_TRIGGER_HAPPY34 0x2e1
#define BTN_TRIGGER_HAPPY35 0x2e2
#define BTN_TRIGGER_HAPPY36 0x2e3
#define BTN_TRIGGER_HAPPY37 0x2e4
#define BTN_TRIGGER_HAPPY38 0x2e5
#define BTN_TRIGGER_HAPPY39 0x2e6
#define BTN_TRIGGER_HAPPY40 0x2e7
/* We avoid low common keys in module aliases so they don't get huge. */
#define KEY_MIN_INTERESTING KEY_MUTE
#define KEY_MAX 0x2ff
#define KEY_CNT (KEY_MAX+1)
/*
* Relative axes
*/
#define REL_X 0x00
#define REL_Y 0x01
#define REL_Z 0x02
#define REL_RX 0x03
#define REL_RY 0x04
#define REL_RZ 0x05
#define REL_HWHEEL 0x06
#define REL_DIAL 0x07
#define REL_WHEEL 0x08
#define REL_MISC 0x09
#define REL_MAX 0x0f
#define REL_CNT (REL_MAX+1)
/*
* Absolute axes
*/
#define ABS_X 0x00
#define ABS_Y 0x01
#define ABS_Z 0x02
#define ABS_RX 0x03
#define ABS_RY 0x04
#define ABS_RZ 0x05
#define ABS_THROTTLE 0x06
#define ABS_RUDDER 0x07
#define ABS_WHEEL 0x08
#define ABS_GAS 0x09
#define ABS_BRAKE 0x0a
#define ABS_HAT0X 0x10
#define ABS_HAT0Y 0x11
#define ABS_HAT1X 0x12
#define ABS_HAT1Y 0x13
#define ABS_HAT2X 0x14
#define ABS_HAT2Y 0x15
#define ABS_HAT3X 0x16
#define ABS_HAT3Y 0x17
#define ABS_PRESSURE 0x18
#define ABS_DISTANCE 0x19
#define ABS_TILT_X 0x1a
#define ABS_TILT_Y 0x1b
#define ABS_TOOL_WIDTH 0x1c
#define ABS_VOLUME 0x20
#define ABS_MISC 0x28
/*
* 0x2e is reserved and should not be used in input drivers.
* It was used by HID as ABS_MISC+6 and userspace needs to detect if
* the next ABS_* event is correct or is just ABS_MISC + n.
* We define here ABS_RESERVED so userspace can rely on it and detect
* the situation described above.
*/
#define ABS_RESERVED 0x2e
#define ABS_MT_SLOT 0x2f /* MT slot being modified */
#define ABS_MT_TOUCH_MAJOR 0x30 /* Major axis of touching ellipse */
#define ABS_MT_TOUCH_MINOR 0x31 /* Minor axis (omit if circular) */
#define ABS_MT_WIDTH_MAJOR 0x32 /* Major axis of approaching ellipse */
#define ABS_MT_WIDTH_MINOR 0x33 /* Minor axis (omit if circular) */
#define ABS_MT_ORIENTATION 0x34 /* Ellipse orientation */
#define ABS_MT_POSITION_X 0x35 /* Center X touch position */
#define ABS_MT_POSITION_Y 0x36 /* Center Y touch position */
#define ABS_MT_TOOL_TYPE 0x37 /* Type of touching device */
#define ABS_MT_BLOB_ID 0x38 /* Group a set of packets as a blob */
#define ABS_MT_TRACKING_ID 0x39 /* Unique ID of initiated contact */
#define ABS_MT_PRESSURE 0x3a /* Pressure on contact area */
#define ABS_MT_DISTANCE 0x3b /* Contact hover distance */
#define ABS_MT_TOOL_X 0x3c /* Center X tool position */
#define ABS_MT_TOOL_Y 0x3d /* Center Y tool position */
#define ABS_MAX 0x3f
#define ABS_CNT (ABS_MAX+1)
/*
* Switch events
*/
#define SW_LID 0x00 /* set = lid shut */
#define SW_TABLET_MODE 0x01 /* set = tablet mode */
#define SW_HEADPHONE_INSERT 0x02 /* set = inserted */
#define SW_RFKILL_ALL 0x03 /* rfkill master switch, type "any"
set = radio enabled */
#define SW_RADIO SW_RFKILL_ALL /* deprecated */
#define SW_MICROPHONE_INSERT 0x04 /* set = inserted */
#define SW_DOCK 0x05 /* set = plugged into dock */
#define SW_LINEOUT_INSERT 0x06 /* set = inserted */
#define SW_JACK_PHYSICAL_INSERT 0x07 /* set = mechanical switch set */
#define SW_VIDEOOUT_INSERT 0x08 /* set = inserted */
#define SW_CAMERA_LENS_COVER 0x09 /* set = lens covered */
#define SW_KEYPAD_SLIDE 0x0a /* set = keypad slide out */
#define SW_FRONT_PROXIMITY 0x0b /* set = front proximity sensor active */
#define SW_ROTATE_LOCK 0x0c /* set = rotate locked/disabled */
#define SW_LINEIN_INSERT 0x0d /* set = inserted */
#define SW_MUTE_DEVICE 0x0e /* set = device disabled */
#define SW_MAX 0x0f
#define SW_CNT (SW_MAX+1)
/*
* Misc events
*/
#define MSC_SERIAL 0x00
#define MSC_PULSELED 0x01
#define MSC_GESTURE 0x02
#define MSC_RAW 0x03
#define MSC_SCAN 0x04
#define MSC_TIMESTAMP 0x05
#define MSC_MAX 0x07
#define MSC_CNT (MSC_MAX+1)
/*
* LEDs
*/
#define LED_NUM_LOCK 0x00
#define LED_CAPS_LOCK 0x01
#define LED_SCROLL_LOCK 0x02
#define LED_COMPOSE 0x03
#define LED_KANA 0x04
#define LED_SLEEP 0x05
#define LED_SUSPEND 0x06
#define LED_MUTE 0x07
#define LED_MISC 0x08
#define LED_MAIL 0x09
#define LED_CHARGING 0x0a
#define LED_MAX 0x0f
#define LED_CNT (LED_MAX+1)
/*
* Autorepeat values
*/
#define REP_DELAY 0x00
#define REP_PERIOD 0x01
#define REP_MAX 0x01
#define REP_CNT (REP_MAX+1)
/*
* Sounds
*/
#define SND_CLICK 0x00
#define SND_BELL 0x01
#define SND_TONE 0x02
#define SND_MAX 0x07
#define SND_CNT (SND_MAX+1)
/*
* Force feedback effect types
*/
#define FF_RUMBLE 0x50
#define FF_PERIODIC 0x51
#define FF_CONSTANT 0x52
#define FF_SPRING 0x53
#define FF_FRICTION 0x54
#define FF_DAMPER 0x55
#define FF_INERTIA 0x56
#define FF_RAMP 0x57
#define FF_EFFECT_MIN FF_RUMBLE
#define FF_EFFECT_MAX FF_RAMP
/*
* Force feedback periodic effect types
*/
#define FF_SQUARE 0x58
#define FF_TRIANGLE 0x59
#define FF_SINE 0x5a
#define FF_SAW_UP 0x5b
#define FF_SAW_DOWN 0x5c
#define FF_CUSTOM 0x5d
#define FF_WAVEFORM_MIN FF_SQUARE
#define FF_WAVEFORM_MAX FF_CUSTOM
/*
* Set ff device properties
*/
#define FF_GAIN 0x60
#define FF_AUTOCENTER 0x61
#define FF_MAX 0x7f
#define FF_CNT (FF_MAX+1)
#endif

View File

@ -12,6 +12,8 @@
#include <keylayoutmap.h>
#include <core/app.h>
#include <core/windowmanager.h>
//#include <core/eventcodes.h>
#include <linux/input.h>
using namespace std;
namespace cdroid{

View File

@ -1,12 +1,11 @@
#ifndef __INPUT_EVENT_LABE_H__
#define __INPUT_EVENT_LABE_H__
//#include <input.h>
#include <core/keycodes.h>
#include <view/keyevent.h>
#include <string.h>
#include <stdint.h>
#define DEFINE_KEYCODE(key) { #key, KEY_##key }
#define DEFINE_KEYCODE(key) { #key, KeyEvent::KEYCODE_##key }
#define DEFINE_AXIS(axis) { #axis, MOTION_EVENT_AXIS_##axis }
#define DEFINE_LED(led) { #led, LED_##led }
#define DEFINE_LED(led) { #led, KeyEvent::ALED_##led }
#define DEFINE_FLAG(flag) { #flag, POLICY_FLAG_##flag }
namespace cdroid{
@ -245,12 +244,12 @@ static const InputEventLabel KEYCODES[] = {
DEFINE_KEYCODE(SLEEP),
DEFINE_KEYCODE(WAKEUP),
//////////////////////////////////////
#if 0
DEFINE_KEYCODE(OK),
DEFINE_KEYCODE(EPG),
DEFINE_KEYCODE(TELETEXT),
DEFINE_KEYCODE(SUBTITLE),
DEFINE_KEYCODE(AUDIO),
#if 0
DEFINE_KEYCODE(PAIRING),
DEFINE_KEYCODE(MEDIA_TOP_MENU),
DEFINE_KEYCODE(11),
@ -377,10 +376,10 @@ static const InputEventLabel LEDS[] = {
DEFINE_LED(MISC),
DEFINE_LED(MAIL),
DEFINE_LED(CHARGING),
//DEFINE_LED(CONTROLLER_1),
// DEFINE_LED(CONTROLLER_2),
// DEFINE_LED(CONTROLLER_3),
// DEFINE_LED(CONTROLLER_4),
DEFINE_LED(CONTROLLER_1),
DEFINE_LED(CONTROLLER_2),
DEFINE_LED(CONTROLLER_3),
DEFINE_LED(CONTROLLER_4),
// NOTE: If you add new LEDs here, you must also add them to Input.h
{ NULL, 0 }

View File

@ -2,7 +2,6 @@
#include <cdlog.h>
#include <unordered_map>
#include <windowmanager.h>
//#include <uievents.h>
#include <thread>
#include <chrono>
#include <tokenizer.h>
@ -39,7 +38,7 @@ void InputEventSource::doEventsConsume(){
const INPUTEVENT*e = es+i;
struct timeval tv = {(time_t)e->tv_sec,e->tv_usec};
auto it = mDevices.find(e->device);
if(es[i].type > EV_CNT){
if(es[i].type > 0x20/*EV_CNT*/){
onDeviceChanged(es+i);
continue;
}

View File

@ -5,7 +5,6 @@
#include <string>
#include <fstream>
#include <core/looper.h>
//#include <core/uievents.h>
#include <core/inputdevice.h>
#include <core/neverdestroyed.h>
#include <unordered_map>

View File

@ -36,7 +36,7 @@ public:
bool onKeyUp(int keyCode,KeyEvent& evt)override{
LOGV("...%d flags=%x",keyCode,evt.getFlags());
switch(keyCode){
case KEY_ESCAPE:setVisibility(View::INVISIBLE);return true;
case KeyEvent::KEYCODE_ESCAPE:setVisibility(View::INVISIBLE);return true;
default: return Window::onKeyDown(keyCode,evt);
}
}
@ -95,7 +95,7 @@ IMEWindow::IMEWindow(int w,int h):Window(0,0,w,h,TYPE_SYSTEM_WINDOW){
case Keyboard::KEYCODE_BACKSPACE:
case Keyboard::KEYCODE_DELETE:
keyEvent.initialize(0,0,KeyEvent::ACTION_UP/*action*/,0,
KEY_BACK,0/*scancode*/,0/*metaState*/,1/*repeatCount*/,NOW,NOW/*eventtime*/);
KeyEvent::KEYCODE_BACK,0/*scancode*/,0/*metaState*/,1/*repeatCount*/,NOW,NOW/*eventtime*/);
/*sendKeyEvent(keyEvent);*/break;
case -101:break;
default:
@ -127,7 +127,7 @@ IMEWindow::IMEWindow(int w,int h):Window(0,0,w,h,TYPE_SYSTEM_WINDOW){
case Keyboard::KEYCODE_DONE : break;
case Keyboard::KEYCODE_DELETE:
case Keyboard::KEYCODE_BACKSPACE:
keyEvent.initialize(0,0,KeyEvent::ACTION_UP/*action*/,0,KEY_BACK,
keyEvent.initialize(0,0,KeyEvent::ACTION_UP/*action*/,0,KeyEvent::KEYCODE_BACK,
0/*scancode*/,0/*metaState*/,1/*repeatCount*/,NOW,NOW/*eventtime*/);
imm.sendKeyEvent(keyEvent);break;
}

View File

@ -1,8 +1,5 @@
#define LOG_TAG "KeyCharacterMap"
#include <stdlib.h>
#include <string.h>
#include <eventcodes.h>
#include <inputeventlabels.h>
#include <keycharactermap.h>
#include <tokenizer.h>
@ -342,7 +339,7 @@ int KeyCharacterMap::mapKey(int32_t scanCode, int32_t usageCode, int32_t* outKey
#if DEBUG_MAPPING
LOGD("mapKey: scanCode=%d, usageCode=0x%08x ~ Failed.", scanCode, usageCode);
#endif
*outKeyCode = KEY_UNKNOWN;//AKEYCODE_UNKNOWN;
*outKeyCode = KeyEvent::KEYCODE_UNKNOWN;//AKEYCODE_UNKNOWN;
return -1;//NAME_NOT_FOUND;
}

View File

@ -1,273 +0,0 @@
#ifndef __KEYCODES_H__
#define __KEYCODES_H__
#ifdef __cplusplus
extern "C" {
#endif
/* Key codes. */
enum {
KEY_UNKNOWN = 0,
KEY_SOFT_LEFT = 1,
KEY_SOFT_RIGHT = 2,
KEY_HOME = 3,
KEY_BACK = 4,
KEY_CALL = 5,
KEY_ENDCALL = 6,
KEY_0 = 7,
KEY_1 = 8,
KEY_2 = 9,
KEY_3 = 10,
KEY_4 = 11,
KEY_5 = 12,
KEY_6 = 13,
KEY_7 = 14,
KEY_8 = 15,
KEY_9 = 16,
KEY_STAR = 17,
KEY_POUND = 18,
KEY_DPAD_UP = 19,
KEY_DPAD_DOWN = 20,
KEY_DPAD_LEFT = 21,
KEY_DPAD_RIGHT = 22,
KEY_DPAD_CENTER = 23,
KEY_VOLUME_UP = 24,
KEY_VOLUME_DOWN = 25,
KEY_POWER = 26,
KEY_CAMERA = 27,
KEY_CLEAR = 28,
KEY_A = 29,
KEY_B = 30,
KEY_C = 31,
KEY_D = 32,
KEY_E = 33,
KEY_F = 34,
KEY_G = 35,
KEY_H = 36,
KEY_I = 37,
KEY_J = 38,
KEY_K = 39,
KEY_L = 40,
KEY_M = 41,
KEY_N = 42,
KEY_O = 43,
KEY_P = 44,
KEY_Q = 45,
KEY_R = 46,
KEY_S = 47,
KEY_T = 48,
KEY_U = 49,
KEY_V = 50,
KEY_W = 51,
KEY_X = 52,
KEY_Y = 53,
KEY_Z = 54,
KEY_COMMA = 55,
KEY_PERIOD = 56,
KEY_ALT_LEFT = 57,
KEY_ALT_RIGHT = 58,
KEY_SHIFT_LEFT = 59,
KEY_SHIFT_RIGHT = 60,
KEY_TAB = 61,
KEY_SPACE = 62,
KEY_SYM = 63,
KEY_EXPLORER = 64,
KEY_ENVELOPE = 65,
KEY_ENTER = 66,
KEY_DEL = 67,
KEY_GRAVE = 68,
KEY_MINUS = 69,
KEY_EQUALS = 70,
KEY_LEFTBRACE = 71,
KEY_RIGHTBRACE = 72,
KEY_BACKSLASH = 73,
KEY_SEMICOLON = 74,
KEY_APOSTROPHE = 75,
KEY_SLASH = 76,
KEY_AT = 77,
KEY_NUM = 78,
KEY_HEADSETHOOK = 79,
KEY_FOCUS = 80, // *Camera* focus
KEY_PLUS = 81,
KEY_MENU = 82,
KEY_NOTIFICATION = 83,
KEY_SEARCH = 84,
KEY_MEDIA_PLAY_PAUSE= 85,
KEY_MEDIA_STOP = 86,
KEY_MEDIA_NEXT = 87,
KEY_MEDIA_PREVIOUS = 88,
KEY_MEDIA_REWIND = 89,
KEY_MEDIA_FAST_FORWARD = 90,
KEY_MUTE = 91,
KEY_PAGE_UP = 92,
KEY_PAGE_DOWN = 93,
KEY_PICTSYMBOLS = 94,
KEY_SWITCH_CHARSET = 95,
KEY_BUTTON_A = 96,
KEY_BUTTON_B = 97,
KEY_BUTTON_C = 98,
KEY_BUTTON_X = 99,
KEY_BUTTON_Y = 100,
KEY_BUTTON_Z = 101,
KEY_BUTTON_L1 = 102,
KEY_BUTTON_R1 = 103,
KEY_BUTTON_L2 = 104,
KEY_BUTTON_R2 = 105,
KEY_BUTTON_THUMBL = 106,
KEY_BUTTON_THUMBR = 107,
KEY_BUTTON_START = 108,
KEY_BUTTON_SELECT = 109,
KEY_BUTTON_MODE = 110,
KEY_ESCAPE = 111,
KEY_FORWARD_DEL = 112,
KEY_CTRL_LEFT = 113,
KEY_CTRL_RIGHT = 114,
KEY_CAPS_LOCK = 115,
KEY_SCROLL_LOCK = 116,
KEY_META_LEFT = 117,
KEY_META_RIGHT = 118,
KEY_FUNCTION = 119,
KEY_SYSRQ = 120,
KEY_BREAK = 121,
KEY_MOVE_HOME = 122,
KEY_MOVE_END = 123,
KEY_INSERT = 124,
KEY_FORWARD = 125,
KEY_MEDIA_PLAY = 126,
KEY_MEDIA_PAUSE = 127,
KEY_MEDIA_CLOSE = 128,
KEY_MEDIA_EJECT = 129,
KEY_MEDIA_RECORD = 130,
KEY_F1 = 131,
KEY_F2 = 132,
KEY_F3 = 133,
KEY_F4 = 134,
KEY_F5 = 135,
KEY_F6 = 136,
KEY_F7 = 137,
KEY_F8 = 138,
KEY_F9 = 139,
KEY_F10 = 140,
KEY_F11 = 141,
KEY_F12 = 142,
KEY_NUM_LOCK = 143,
KEY_NUMPAD_0 = 144,
KEY_NUMPAD_1 = 145,
KEY_NUMPAD_2 = 146,
KEY_NUMPAD_3 = 147,
KEY_NUMPAD_4 = 148,
KEY_NUMPAD_5 = 149,
KEY_NUMPAD_6 = 150,
KEY_NUMPAD_7 = 151,
KEY_NUMPAD_8 = 152,
KEY_NUMPAD_9 = 153,
KEY_NUMPAD_DIVIDE = 154,
KEY_NUMPAD_MULTIPLY = 155,
KEY_NUMPAD_SUBTRACT = 156,
KEY_NUMPAD_ADD = 157,
KEY_NUMPAD_DOT = 158,
KEY_NUMPAD_COMMA = 159,
KEY_NUMPAD_ENTER = 160,
KEY_NUMPAD_EQUALS = 161,
KEY_NUMPAD_LEFT_PAREN = 162,
KEY_NUMPAD_RIGHT_PAREN = 163,
KEY_VOLUME_MUTE = 164,
KEY_INFO = 165,
KEY_CHANNEL_UP = 166,
KEY_CHANNEL_DOWN = 167,
KEY_ZOOM_IN = 168,
KEY_ZOOM_OUT = 169,
KEY_TV = 170,
KEY_WINDOW = 171,
KEY_GUIDE = 172,
KEY_DVR = 173,
KEY_BOOKMARK = 174,
KEY_CAPTIONS = 175,
KEY_SETTINGS = 176,
KEY_TV_POWER = 177,
KEY_TV_INPUT = 178,
KEY_STB_POWER = 179,
KEY_STB_INPUT = 180,
KEY_AVR_POWER = 181,
KEY_AVR_INPUT = 182,
KEY_PROG_RED = 183,
KEY_PROG_GREEN = 184,
KEY_PROG_YELLOW = 185,
KEY_PROG_BLUE = 186,
KEY_APP_SWITCH = 187,
KEY_BUTTON_1 = 188,
KEY_BUTTON_2 = 189,
KEY_BUTTON_3 = 190,
KEY_BUTTON_4 = 191,
KEY_BUTTON_5 = 192,
KEY_BUTTON_6 = 193,
KEY_BUTTON_7 = 194,
KEY_BUTTON_8 = 195,
KEY_BUTTON_9 = 196,
KEY_BUTTON_10 = 197,
KEY_BUTTON_11 = 198,
KEY_BUTTON_12 = 199,
KEY_BUTTON_13 = 200,
KEY_BUTTON_14 = 201,
KEY_BUTTON_15 = 202,
KEY_BUTTON_16 = 203,
KEY_LANGUAGE_SWITCH = 204,
KEY_MANNER_MODE = 205,
KEY_3D_MODE = 206,
KEY_CONTACTS = 207,
KEY_CALENDAR = 208,
KEY_MUSIC = 209,
KEY_CALCULATOR = 210,
KEY_ZENKAKU_HANKAKU = 211,
KEY_EISU = 212,
KEY_MUHENKAN = 213,
KEY_HENKAN = 214,
KEY_KATAKANA_HIRAGANA = 215,
KEY_YEN = 216,
KEY_RO = 217,
KEY_KANA = 218,
KEY_ASSIST = 219,
KEY_BRIGHTNESS_DOWN = 220,
KEY_BRIGHTNESS_UP = 221,
KEY_MEDIA_AUDIO_TRACK= 222,
/////////////////////////////////////////
KEY_OK =223,
KEY_EPG =224,
KEY_AUDIO =225,
KEY_SUBTITLE =226,
KEY_HELP =227,
KEY_TELETEXT =228,
KEY_SLEEP =229,
KEY_WAKEUP =230
// NOTE: If you add a new keycode here you must also add it to several other files.
// Refer to frameworks/base/core/java/android/view/KeyEvent.java for the full list.
};
enum {
/**
* Constants for LEDs. Hidden from the API since we don't actually expose a way to interact
* with LEDs to developers
*
* NOTE: If you add LEDs here, you must also add them to InputEventLabels.h
*/
LED_NUM_LOCK = 0x00,
LED_CAPS_LOCK = 0x01,
LED_SCROLL_LOCK = 0x02,
LED_COMPOSE = 0x03,
LED_KANA = 0x04,
LED_SLEEP = 0x05,
LED_SUSPEND = 0x06,
LED_MUTE = 0x07,
LED_MISC = 0x08,
LED_MAIL = 0x09,
LED_CHARGING = 0x0a,
LED_CONTROLLER_1 = 0x10,
LED_CONTROLLER_2 = 0x11,
LED_CONTROLLER_3 = 0x12,
LED_CONTROLLER_4 = 0x13,
};
#ifdef __cplusplus
}
#endif
#endif // ___KEYCODES_H__

View File

@ -55,7 +55,7 @@ int KeyLayoutMap::mapKey(int32_t scanCode,int32_t usageCode,int32_t* outKeyCode,
#if DEBUG_MAPPING
LOGD("mapKey: scanCode=%d, usageCode=0x%08x ~ Failed.", scanCode, usageCode);
#endif
*outKeyCode =KEY_UNKNOWN;
*outKeyCode =KeyEvent::KEYCODE_UNKNOWN;
*outFlags = 0;
return -1;//NAME_NOT_FOUND;
}

View File

@ -1,4 +1,6 @@
#include<view/keyevent.h>
//#include <core/eventcodes.h>
#include <linux/input.h>
#include <inputeventlabels.h>
namespace cdroid{
@ -69,7 +71,7 @@ bool KeyEvent::dispatch(KeyEvent::Callback* receiver,KeyEvent::DispatcherState*s
if (receiver->onKeyMultiple(mKeyCode, mRepeatCount, *this)) {
return true;
}
if (mKeyCode != KEY_UNKNOWN) {
if (mKeyCode != KEYCODE_UNKNOWN) {
int count=mRepeatCount;
mAction = ACTION_DOWN;
mRepeatCount = 0;
@ -98,26 +100,26 @@ int32_t KeyEvent::getKeyCodeFromLabel(const char* label) {
bool KeyEvent::isModifierKey(int keyCode){
switch (keyCode) {
case KEY_SHIFT_LEFT:
case KEY_SHIFT_RIGHT:
case KEY_ALT_LEFT:
case KEY_ALT_RIGHT:
case KEY_CTRL_LEFT:
case KEY_CTRL_RIGHT:
case KEY_META_LEFT:
case KEY_META_RIGHT:
case KEY_SYM:
case KEY_NUM:
case KEY_FUNCTION:return true;
case KEYCODE_SHIFT_LEFT:
case KEYCODE_SHIFT_RIGHT:
case KEYCODE_ALT_LEFT:
case KEYCODE_ALT_RIGHT:
case KEYCODE_CTRL_LEFT:
case KEYCODE_CTRL_RIGHT:
case KEYCODE_META_LEFT:
case KEYCODE_META_RIGHT:
case KEYCODE_SYM:
case KEYCODE_NUM:
case KEYCODE_FUNCTION:return true;
default:return false;
}
}
bool KeyEvent::isConfirmKey(int keyCode){
switch(keyCode){
case KEY_ENTER:
case KEY_DPAD_CENTER:
case KEY_NUMPAD_ENTER:
case KEYCODE_ENTER:
case KEYCODE_DPAD_CENTER:
case KEYCODE_NUMPAD_ENTER:
return true;
default:return false;
}

View File

@ -1,7 +1,6 @@
#ifndef __KEY_EVENT_H__
#define __KEY_EVENT_H__
#include <view/inputevent.h>
#include <core/eventcodes.h>
#include <core/sparsearray.h>
namespace cdroid{
@ -165,7 +164,340 @@ public:
static const std::string metaStateToString(int metaState);
static const std::string actionToString(int action);
void toStream(std::ostream& os)const override;
enum{
KEYCODE_UNKNOWN = 0,
KEYCODE_LEFT = 1,
KEYCODE_SOFT_LEFT = 1,
KEYCODE_RIGHT = 2,
KEYCODE_SOFT_RIGHT = 2,
KEYCODE_HOME = 3,
KEYCODE_BACK = 4,
KEYCODE_CALL = 5,
KEYCODE_ENDCALL = 6,
KEYCODE_0 = 7,
KEYCODE_1 = 8,
KEYCODE_2 = 9,
KEYCODE_3 = 10,
KEYCODE_4 = 11,
KEYCODE_5 = 12,
KEYCODE_6 = 13,
KEYCODE_7 = 14,
KEYCODE_8 = 15,
KEYCODE_9 = 16,
KEYCODE_STAR = 17,
KEYCODE_POUND = 18,
KEYCODE_DPAD_UP = 19,
KEYCODE_DPAD_DOWN = 20,
KEYCODE_DPAD_LEFT = 21,
KEYCODE_DPAD_RIGHT = 22,
KEYCODE_DPAD_CENTER = 23,
KEYCODE_VOLUME_UP = 24,
KEYCODE_VOLUME_DOWN = 25,
KEYCODE_POWER = 26,
KEYCODE_CAMERA = 27,
KEYCODE_CLEAR = 28,
KEYCODE_A = 29,
KEYCODE_B = 30,
KEYCODE_C = 31,
KEYCODE_D = 32,
KEYCODE_E = 33,
KEYCODE_F = 34,
KEYCODE_G = 35,
KEYCODE_H = 36,
KEYCODE_I = 37,
KEYCODE_J = 38,
KEYCODE_K = 39,
KEYCODE_L = 40,
KEYCODE_M = 41,
KEYCODE_N = 42,
KEYCODE_O = 43,
KEYCODE_P = 44,
KEYCODE_Q = 45,
KEYCODE_R = 46,
KEYCODE_S = 47,
KEYCODE_T = 48,
KEYCODE_U = 49,
KEYCODE_V = 50,
KEYCODE_W = 51,
KEYCODE_X = 52,
KEYCODE_Y = 53,
KEYCODE_Z = 54,
KEYCODE_COMMA = 55,
KEYCODE_PERIOD = 56,
KEYCODE_ALT_LEFT = 57,
KEYCODE_ALT_RIGHT = 58,
KEYCODE_SHIFT_LEFT = 59,
KEYCODE_SHIFT_RIGHT = 60,
KEYCODE_TAB = 61,
KEYCODE_SPACE = 62,
KEYCODE_SYM = 63,
KEYCODE_EXPLORER = 64,
KEYCODE_ENVELOPE = 65,
KEYCODE_ENTER = 66,
KEYCODE_DEL = 67,
KEYCODE_GRAVE = 68,
KEYCODE_MINUS = 69,
KEYCODE_EQUALS = 70,
KEYCODE_LEFTBRACE = 71,
KEYCODE_RIGHTBRACE = 72,
KEYCODE_BACKSLASH = 73,
KEYCODE_SEMICOLON = 74,
KEYCODE_APOSTROPHE = 75,
KEYCODE_SLASH = 76,
KEYCODE_AT = 77,
KEYCODE_NUM = 78,
KEYCODE_HEADSETHOOK = 79,
KEYCODE_FOCUS = 80, // *Camera* focus
KEYCODE_PLUS = 81,
KEYCODE_MENU = 82,
KEYCODE_NOTIFICATION = 83,
KEYCODE_SEARCH = 84,
KEYCODE_MEDIA_PLAY_PAUSE= 85,
KEYCODE_MEDIA_STOP = 86,
KEYCODE_MEDIA_NEXT = 87,
KEYCODE_MEDIA_PREVIOUS = 88,
KEYCODE_MEDIA_REWIND = 89,
KEYCODE_MEDIA_FAST_FORWARD = 90,
KEYCODE_MUTE = 91,
KEYCODE_PAGE_UP = 92,
KEYCODE_PAGE_DOWN = 93,
KEYCODE_PICTSYMBOLS = 94,
KEYCODE_SWITCH_CHARSET = 95,
KEYCODE_BUTTON_A = 96,
KEYCODE_BUTTON_B = 97,
KEYCODE_BUTTON_C = 98,
KEYCODE_BUTTON_X = 99,
KEYCODE_BUTTON_Y = 100,
KEYCODE_BUTTON_Z = 101,
KEYCODE_BUTTON_L1 = 102,
KEYCODE_BUTTON_R1 = 103,
KEYCODE_BUTTON_L2 = 104,
KEYCODE_BUTTON_R2 = 105,
KEYCODE_BUTTON_THUMBL = 106,
KEYCODE_BUTTON_THUMBR = 107,
KEYCODE_BUTTON_START = 108,
KEYCODE_BUTTON_SELECT = 109,
KEYCODE_BUTTON_MODE = 110,
KEYCODE_ESCAPE = 111,
KEYCODE_FORWARD_DEL = 112,
KEYCODE_BACKSPACE = 112,
KEYCODE_CTRL_LEFT = 113,
KEYCODE_CTRL_RIGHT = 114,
KEYCODE_CAPS_LOCK = 115,
KEYCODE_SCROLL_LOCK = 116,
KEYCODE_META_LEFT = 117,
KEYCODE_META_RIGHT = 118,
KEYCODE_FUNCTION = 119,
KEYCODE_SYSRQ = 120,
KEYCODE_BREAK = 121,
KEYCODE_MOVE_HOME = 122,
KEYCODE_MOVE_END = 123,
KEYCODE_INSERT = 124,
KEYCODE_FORWARD = 125,
KEYCODE_MEDIA_PLAY = 126,
KEYCODE_MEDIA_PAUSE = 127,
KEYCODE_MEDIA_CLOSE = 128,
KEYCODE_MEDIA_EJECT = 129,
KEYCODE_MEDIA_RECORD = 130,
KEYCODE_F1 = 131,
KEYCODE_F2 = 132,
KEYCODE_F3 = 133,
KEYCODE_F4 = 134,
KEYCODE_F5 = 135,
KEYCODE_F6 = 136,
KEYCODE_F7 = 137,
KEYCODE_F8 = 138,
KEYCODE_F9 = 139,
KEYCODE_F10 = 140,
KEYCODE_F11 = 141,
KEYCODE_F12 = 142,
KEYCODE_NUM_LOCK = 143,
KEYCODE_NUMPAD_0 = 144,
KEYCODE_NUMPAD_1 = 145,
KEYCODE_NUMPAD_2 = 146,
KEYCODE_NUMPAD_3 = 147,
KEYCODE_NUMPAD_4 = 148,
KEYCODE_NUMPAD_5 = 149,
KEYCODE_NUMPAD_6 = 150,
KEYCODE_NUMPAD_7 = 151,
KEYCODE_NUMPAD_8 = 152,
KEYCODE_NUMPAD_9 = 153,
KEYCODE_NUMPAD_DIVIDE = 154,
KEYCODE_NUMPAD_MULTIPLY = 155,
KEYCODE_NUMPAD_SUBTRACT = 156,
KEYCODE_NUMPAD_ADD = 157,
KEYCODE_NUMPAD_DOT = 158,
KEYCODE_NUMPAD_COMMA = 159,
KEYCODE_NUMPAD_ENTER = 160,
KEYCODE_NUMPAD_EQUALS = 161,
KEYCODE_NUMPAD_LEFT_PAREN = 162,
KEYCODE_NUMPAD_RIGHT_PAREN = 163,
KEYCODE_VOLUME_MUTE = 164,
KEYCODE_INFO = 165,
KEYCODE_CHANNEL_UP = 166,
KEYCODE_CHANNEL_DOWN = 167,
KEYCODE_ZOOM_IN = 168,
KEYCODE_ZOOM_OUT = 169,
KEYCODE_TV = 170,
KEYCODE_WINDOW = 171,
KEYCODE_GUIDE = 172,
KEYCODE_DVR = 173,
KEYCODE_BOOKMARK = 174,
KEYCODE_CAPTIONS = 175,
KEYCODE_SETTINGS = 176,
KEYCODE_TV_POWER = 177,
KEYCODE_TV_INPUT = 178,
KEYCODE_STB_POWER = 179,
KEYCODE_STB_INPUT = 180,
KEYCODE_AVR_POWER = 181,
KEYCODE_AVR_INPUT = 182,
KEYCODE_PROG_RED = 183,
KEYCODE_PROG_GREEN = 184,
KEYCODE_PROG_YELLOW = 185,
KEYCODE_PROG_BLUE = 186,
KEYCODE_APP_SWITCH = 187,
KEYCODE_BUTTON_1 = 188,
KEYCODE_BUTTON_2 = 189,
KEYCODE_BUTTON_3 = 190,
KEYCODE_BUTTON_4 = 191,
KEYCODE_BUTTON_5 = 192,
KEYCODE_BUTTON_6 = 193,
KEYCODE_BUTTON_7 = 194,
KEYCODE_BUTTON_8 = 195,
KEYCODE_BUTTON_9 = 196,
KEYCODE_BUTTON_10 = 197,
KEYCODE_BUTTON_11 = 198,
KEYCODE_BUTTON_12 = 199,
KEYCODE_BUTTON_13 = 200,
KEYCODE_BUTTON_14 = 201,
KEYCODE_BUTTON_15 = 202,
KEYCODE_BUTTON_16 = 203,
KEYCODE_LANGUAGE_SWITCH = 204,
KEYCODE_MANNER_MODE = 205,
KEYCODE_3D_MODE = 206,
KEYCODE_CONTACTS = 207,
KEYCODE_CALENDAR = 208,
KEYCODE_MUSIC = 209,
KEYCODE_CALCULATOR = 210,
KEYCODE_ZENKAKU_HANKAKU = 211,
KEYCODE_EISU = 212,
KEYCODE_MUHENKAN = 213,
KEYCODE_HENKAN = 214,
KEYCODE_KATAKANA_HIRAGANA = 215,
KEYCODE_YEN = 216,
KEYCODE_RO = 217,
KEYCODE_KANA = 218,
KEYCODE_ASSIST = 219,
KEYCODE_BRIGHTNESS_DOWN = 220,
KEYCODE_BRIGHTNESS_UP = 221,
KEYCODE_MEDIA_AUDIO_TRACK= 222,
KEYCODE_SLEEP =223,
KEYCODE_WAKEUP =224,
KEYCODE_PAIRING =225,
KEYCODE_MEDIA_TOP_MENU =226,
KEYCODE_11 =227,
KEYCODE_12 =228,
KEYCODE_LAST_CHANNEL =229,
KEYCODE_TV_DATA_SERVICE =230,
KEYCODE_VOICE_ASSIST =231,
KEYCODE_TV_RADIO_SERVICE= 232,
KEYCODE_TV_TELETEXT = 233,
KEYCODE_TV_NUMBER_ENTRY = 234,
KEYCODE_TV_TERRESTRIAL_ANALOG = 235,
KEYCODE_TV_TERRESTRIAL_DIGITAL = 236,
KEYCODE_TV_SATELLITE = 237,
KEYCODE_TV_SATELLITE_BS = 238,
KEYCODE_TV_SATELLITE_CS = 239,
KEYCODE_TV_SATELLITE_SERVICE = 240,
KEYCODE_TV_NETWORK = 241,
KEYCODE_TV_ANTENNA_CABLE = 242,
KEYCODE_TV_INPUT_HDMI_1 = 243,
KEYCODE_TV_INPUT_HDMI_2 = 244,
KEYCODE_TV_INPUT_HDMI_3 = 245,
KEYCODE_TV_INPUT_HDMI_4 = 246,
KEYCODE_TV_INPUT_COMPOSITE_1 = 247,
KEYCODE_TV_INPUT_COMPOSITE_2 = 248,
KEYCODE_TV_INPUT_COMPONENT_1 = 249,
KEYCODE_TV_INPUT_COMPONENT_2 = 250,
KEYCODE_TV_INPUT_VGA_1 = 251,
KEYCODE_TV_AUDIO_DESCRIPTION = 252,
KEYCODE_TV_AUDIO_DESCRIPTION_MIX_UP = 253,
KEYCODE_TV_AUDIO_DESCRIPTION_MIX_DOWN = 254,
KEYCODE_TV_ZOOM_MODE = 255,
KEYCODE_TV_CONTENTS_MENU = 256,
KEYCODE_TV_MEDIA_CONTEXT_MENU= 257,
KEYCODE_TV_TIMER_PROGRAMMING = 258,
KEYCODE_HELP = 259,
KEYCODE_NAVIGATE_NEXT = 261,
KEYCODE_NAVIGATE_IN = 262,
KEYCODE_NAVIGATE_OUT = 263,
KEYCODE_STEM_PRIMARY = 264,
KEYCODE_STEM_1 = 265,
KEYCODE_STEM_2 = 266,
KEYCODE_STEM_3 = 267,
KEYCODE_DPAD_UP_LEFT = 268,
KEYCODE_DPAD_DOWN_LEFT = 269,
KEYCODE_DPAD_UP_RIGHT = 270,
KEYCODE_DPAD_DOWN_RIGHT = 271,
KEYCODE_MEDIA_SKIP_FORWARD = 272,
KEYCODE_MEDIA_SKIP_BACKWARD = 273,
KEYCODE_MEDIA_STEP_FORWARD = 274,
KEYCODE_MEDIA_STEP_BACKWARD = 275,
KEYCODE_SOFT_SLEEP = 276,
KEYCODE_CUT = 277,
KEYCODE_COPY = 278,
KEYCODE_PASTE = 279,
KEYCODE_SYSTEM_NAVIGATION_UP = 280,
KEYCODE_SYSTEM_NAVIGATION_DOWN = 281,
KEYCODE_SYSTEM_NAVIGATION_LEFT = 282,
KEYCODE_SYSTEM_NAVIGATION_RIGHT = 283,
KEYCODE_ALL_APPS = 284,
KEYCODE_REFRESH = 285,
KEYCODE_THUMBS_UP = 286,
KEYCODE_THUMBS_DOWN = 287,
KEYCODE_PROFILE_SWITCH = 288,
KEYCODE_VIDEO_APP_1 = 289,
KEYCODE_VIDEO_APP_2 = 290,
KEYCODE_VIDEO_APP_3 = 291,
KEYCODE_VIDEO_APP_4 = 292,
KEYCODE_VIDEO_APP_5 = 293,
KEYCODE_VIDEO_APP_6 = 294,
KEYCODE_VIDEO_APP_7 = 295,
KEYCODE_VIDEO_APP_8 = 296,
KEYCODE_FEATURED_APP_1 = 297,
KEYCODE_FEATURED_APP_2 = 298,
KEYCODE_FEATURED_APP_3 = 299,
KEYCODE_FEATURED_APP_4 = 300,
KEYCODE_DEMO_APP_1 = 301,
KEYCODE_DEMO_APP_2 = 302,
KEYCODE_DEMO_APP_3 = 303,
KEYCODE_DEMO_APP_4 = 304
};/*endof KEYCODES*/
enum {
/**
* Constants for LEDs. Hidden from the API since we don't actually expose a way to interact
* with LEDs to developers
*
* NOTE: If you add LEDs here, you must also add them to InputEventLabels.h
*/
ALED_NUM_LOCK = 0x00,
ALED_CAPS_LOCK = 0x01,
ALED_SCROLL_LOCK = 0x02,
ALED_COMPOSE = 0x03,
ALED_KANA = 0x04,
ALED_SLEEP = 0x05,
ALED_SUSPEND = 0x06,
ALED_MUTE = 0x07,
ALED_MISC = 0x08,
ALED_MAIL = 0x09,
ALED_CHARGING = 0x0a,
ALED_CONTROLLER_1 = 0x10,
ALED_CONTROLLER_2 = 0x11,
ALED_CONTROLLER_3 = 0x12,
ALED_CONTROLLER_4 = 0x13
};
};/*endof class KeyEvent*/
}/*endof namespace*/
#endif/*__KEY_EVENT_H__*/

View File

@ -1,6 +1,5 @@
#ifndef __CDROID_VIEW_H__
#define __CDROID_VIEW_H__
#include <core/eventcodes.h>
#include <core/inputdevice.h>
#include <core/canvas.h>
#include <core/insets.h>

View File

@ -3407,7 +3407,7 @@ bool ViewGroup::performKeyboardGroupNavigation(int direction){
}
static int isExcludedKeys(int key){
return key==KEY_MENU||key==KEY_ESCAPE;//||key==KEY_EXIT;
return key==KeyEvent::KEYCODE_MENU||key==KeyEvent::KEYCODE_ESCAPE;//||key==KEY_EXIT;
}
void ViewGroup::drawableStateChanged(){

View File

@ -487,12 +487,12 @@ void AbsSeekBar::onDraw(Canvas&canvas){
bool AbsSeekBar::onKeyDown(int keyCode,KeyEvent&event){
switch(keyCode){
case KEY_LEFT :
case KEY_MINUS:
case KeyEvent::KEYCODE_LEFT :
case KeyEvent::KEYCODE_MINUS:
setProgressInternal(getProgress()-mKeyProgressIncrement,true);
return true;
case KEY_RIGHT:
case KEY_PLUS :
case KeyEvent::KEYCODE_RIGHT:
case KeyEvent::KEYCODE_PLUS :
setProgressInternal(getProgress()+mKeyProgressIncrement,true);
return true;
default:return ProgressBar::onKeyDown(keyCode,event);

View File

@ -333,10 +333,10 @@ int Window::processKeyEvent(KeyEvent&event){
int handled = FINISH_NOT_HANDLED;
int groupNavigationDirection = 0;
const int action = event.getAction();
LOGV_IF(action==KeyEvent::ACTION_DOWN,"key:0x%x %s %x",event.getKeyCode(),KeyEvent::getLabel(event.getKeyCode()),KEY_DPAD_DOWN);
LOGV_IF(action==KeyEvent::ACTION_DOWN,"key:0x%x %s %x",event.getKeyCode(),KeyEvent::getLabel(event.getKeyCode()),KeyEvent::KEYCODE_DPAD_DOWN);
if(dispatchKeyEvent(event))
return FINISH_HANDLED;
if (action == KeyEvent::ACTION_DOWN && event.getKeyCode() == KEY_TAB) {
if (action == KeyEvent::ACTION_DOWN && event.getKeyCode() == KeyEvent::KEYCODE_TAB) {
if (KeyEvent::metaStateHasModifiers(event.getMetaState(), KeyEvent::META_META_ON)) {
groupNavigationDirection = View::FOCUS_FORWARD;
} else if (KeyEvent::metaStateHasModifiers(event.getMetaState(),
@ -364,7 +364,7 @@ bool Window::dispatchKeyEvent(KeyEvent&event){
if(focused && focused->dispatchKeyEvent(event))
return true;
int groupNavigationDirection = 0;
if (action == KeyEvent::ACTION_DOWN && event.getKeyCode() == KEY_TAB) {
if (action == KeyEvent::ACTION_DOWN && event.getKeyCode() == KeyEvent::KEYCODE_TAB) {
if (KeyEvent::metaStateHasModifiers(event.getMetaState(), KeyEvent::META_META_ON)) {
groupNavigationDirection = View::FOCUS_FORWARD;
} else if (KeyEvent::metaStateHasModifiers(event.getMetaState(),
@ -391,11 +391,11 @@ bool Window::dispatchKeyEvent(KeyEvent&event){
bool Window::performFocusNavigation(KeyEvent& event){
int direction = -1;
switch (event.getKeyCode()) {
case KEY_DPAD_LEFT: direction = View::FOCUS_LEFT; break;
case KEY_DPAD_RIGHT: direction = View::FOCUS_RIGHT; break;
case KEY_DPAD_UP: direction = View::FOCUS_UP; break;
case KEY_DPAD_DOWN: direction = View::FOCUS_DOWN; break;
case KEY_TAB:
case KeyEvent::KEYCODE_DPAD_LEFT: direction = View::FOCUS_LEFT; break;
case KeyEvent::KEYCODE_DPAD_RIGHT: direction = View::FOCUS_RIGHT; break;
case KeyEvent::KEYCODE_DPAD_UP: direction = View::FOCUS_UP; break;
case KeyEvent::KEYCODE_DPAD_DOWN: direction = View::FOCUS_DOWN; break;
case KeyEvent::KEYCODE_TAB:
if (event.hasNoModifiers()) {
direction = View::FOCUS_FORWARD;
} else if (event.hasModifiers(KeyEvent::META_SHIFT_ON)) {
@ -437,7 +437,7 @@ bool Window::performFocusNavigation(KeyEvent& event){
bool Window::onKeyDown(int keyCode,KeyEvent& evt){
switch(keyCode){
case KEY_ESCAPE:
case KeyEvent::KEYCODE_ESCAPE:
evt.startTracking();
LOGD("recv %d %s flags=%x",keyCode,evt.getLabel(),evt.getFlags());
return true;
@ -452,7 +452,7 @@ bool Window::onKeyDown(int keyCode,KeyEvent& evt){
bool Window::onKeyUp(int keyCode,KeyEvent& evt){
LOGV("recv %d %s flags=%x track=%d cance=%d",keyCode,evt.getLabel(),evt.getFlags(),evt.isTracking(),evt.isCanceled());
switch(keyCode){
case KEY_ESCAPE:
case KeyEvent::KEYCODE_ESCAPE:
if(evt.isTracking()&&!evt.isCanceled()){
onBackPressed();
return true;

View File

@ -1197,7 +1197,7 @@ void DrawerLayout::cancelChildViewTouch() {
}
bool DrawerLayout::onKeyDown(int keyCode, KeyEvent& event) {
if (keyCode == KEY_BACK && hasVisibleDrawer()) {
if (keyCode == KeyEvent::KEYCODE_BACK && hasVisibleDrawer()) {
event.startTracking();
return true;
}
@ -1205,7 +1205,7 @@ bool DrawerLayout::onKeyDown(int keyCode, KeyEvent& event) {
}
bool DrawerLayout::onKeyUp(int keyCode, KeyEvent& event) {
if (keyCode == KEY_BACK) {
if (keyCode == KeyEvent::KEYCODE_BACK) {
View* visibleDrawer = findVisibleDrawer();
if (visibleDrawer && getDrawerLockMode(visibleDrawer) == LOCK_MODE_UNLOCKED) {
closeDrawers();

View File

@ -169,21 +169,21 @@ bool EditText::onKeyDown(int keyCode,KeyEvent & event){
std::wstring& wText=getEditable();
int line=mLayout->getLineForOffset(mCaretPos);
switch(keyCode){
case KEY_LEFT:
case KeyEvent::KEYCODE_LEFT:
if(mCaretPos>0){
setCaretPos(mCaretPos-1);
return true;
}break;
case KEY_RIGHT:
case KeyEvent::KEYCODE_RIGHT:
if(mCaretPos<(int)wText.size()){
setCaretPos(mCaretPos+1);
return true;
}break;
case KEY_DOWN:
case KeyEvent::KEYCODE_DPAD_DOWN:
return (!isSingleLine())&&moveCaret2Line(line+1);
case KEY_UP:
case KeyEvent::KEYCODE_DPAD_UP:
return (!isSingleLine())&&moveCaret2Line(line-1);
case KEY_BACKSPACE:
case KeyEvent::KEYCODE_BACKSPACE:
if(wText.size() && (mCaretPos>0) && (mCaretPos<=wText.size()) ){
wchar_t wc0 = wText[mCaretPos-1];
wText.erase(mCaretPos-1,1);
@ -196,7 +196,7 @@ bool EditText::onKeyDown(int keyCode,KeyEvent & event){
ret=true;
}else setCaretPos(wText.size()-1);
break;
case KEY_DELETE:
case KeyEvent::KEYCODE_DEL:
if(mCaretPos<wText.size()){
wchar_t wc0=wText[mCaretPos];
wText.erase(mCaretPos,1);
@ -205,17 +205,19 @@ bool EditText::onKeyDown(int keyCode,KeyEvent & event){
else mLayout->relayout(true);
ret=true;
}break;
case KEY_INSERT:
case KeyEvent::KEYCODE_INSERT:
mEditMode=!mEditMode;
invalidate(true);
break;
case KEY_OK:
#if 0
case KeyEvent::KEYCODE_OK:
if(nullptr!=afterChanged)
afterChanged(*this);
return false;
case KEY_MENU:
#endif
case KeyEvent::KEYCODE_MENU:
return true;
case KEY_ENTER:
case KeyEvent::KEYCODE_ENTER:
if(!isSingleLine()){
if(mCaretPos<wText.length()) wText.insert(mCaretPos,1,'\n');
else wText.append(1,'\n');

View File

@ -1267,19 +1267,19 @@ bool GridView::commonKey(int keyCode, int count, KeyEvent& event) {
if (!handled && action != KeyEvent::ACTION_UP) {
switch (keyCode) {
case KEY_DPAD_LEFT:
case KeyEvent::KEYCODE_DPAD_LEFT:
if (event.hasNoModifiers()) {
handled = resurrectSelectionIfNeeded() || arrowScroll(FOCUS_LEFT);
}
break;
case KEY_DPAD_RIGHT:
case KeyEvent::KEYCODE_DPAD_RIGHT:
if (event.hasNoModifiers()) {
handled = resurrectSelectionIfNeeded() || arrowScroll(FOCUS_RIGHT);
}
break;
case KEY_DPAD_UP:
case KeyEvent::KEYCODE_DPAD_UP:
if (event.hasNoModifiers()) {
handled = resurrectSelectionIfNeeded() || arrowScroll(FOCUS_UP);
} else if (event.hasModifiers(KeyEvent::META_ALT_ON)) {
@ -1287,7 +1287,7 @@ bool GridView::commonKey(int keyCode, int count, KeyEvent& event) {
}
break;
case KEY_DPAD_DOWN:
case KeyEvent::KEYCODE_DPAD_DOWN:
if (event.hasNoModifiers()) {
handled = resurrectSelectionIfNeeded() || arrowScroll(FOCUS_DOWN);
} else if (event.hasModifiers(KeyEvent::META_ALT_ON)) {
@ -1295,7 +1295,7 @@ bool GridView::commonKey(int keyCode, int count, KeyEvent& event) {
}
break;
case KEY_PAGE_UP:
case KeyEvent::KEYCODE_PAGE_UP:
if (event.hasNoModifiers()) {
handled = resurrectSelectionIfNeeded() || pageScroll(FOCUS_UP);
} else if (event.hasModifiers(KeyEvent::META_ALT_ON)) {
@ -1303,7 +1303,7 @@ bool GridView::commonKey(int keyCode, int count, KeyEvent& event) {
}
break;
case KEY_PAGE_DOWN:
case KeyEvent::KEYCODE_PAGE_DOWN:
if (event.hasNoModifiers()) {
handled = resurrectSelectionIfNeeded() || pageScroll(FOCUS_DOWN);
} else if (event.hasModifiers(KeyEvent::META_ALT_ON)) {
@ -1311,19 +1311,19 @@ bool GridView::commonKey(int keyCode, int count, KeyEvent& event) {
}
break;
case KEY_MOVE_HOME:
case KeyEvent::KEYCODE_MOVE_HOME:
if (event.hasNoModifiers()) {
handled = resurrectSelectionIfNeeded() || fullScroll(FOCUS_UP);
}
break;
case KEY_MOVE_END:
case KeyEvent::KEYCODE_MOVE_END:
if (event.hasNoModifiers()) {
handled = resurrectSelectionIfNeeded() || fullScroll(FOCUS_DOWN);
}
break;
case KEY_TAB:
case KeyEvent::KEYCODE_TAB:
// TODO: Sometimes it is useful to be able to TAB through the items in
// a GridView sequentially. Unfortunately this can create an
// asymmetry in TAB navigation order unless the list selection

View File

@ -205,21 +205,21 @@ bool HorizontalScrollView::executeKeyEvent(KeyEvent& event) {
bool handled = false;
if (event.getAction() == KeyEvent::ACTION_DOWN) {
switch (event.getKeyCode()) {
case KEY_DPAD_LEFT:
case KeyEvent::KEYCODE_DPAD_LEFT:
if (!event.isAltPressed()) {
handled = arrowScroll(View::FOCUS_LEFT);
} else {
handled = fullScroll(View::FOCUS_LEFT);
}
break;
case KEY_DPAD_RIGHT:
case KeyEvent::KEYCODE_DPAD_RIGHT:
if (!event.isAltPressed()) {
handled = arrowScroll(View::FOCUS_RIGHT);
} else {
handled = fullScroll(View::FOCUS_RIGHT);
}
break;
case KEY_SPACE:
case KeyEvent::KEYCODE_SPACE:
pageScroll(event.isShiftPressed() ? View::FOCUS_LEFT : View::FOCUS_RIGHT);
break;
}

View File

@ -359,7 +359,7 @@ void KeyboardView::detectAndSendKey(int index, int x, int y, long eventTime){
// Multi-tap
if (mInMultiTap) {
if (mTapCount != -1) {
mKeyboardActionListener.onKey(Keyboard::KEYCODE_DELETE, {KEY_DELETE});
mKeyboardActionListener.onKey(Keyboard::KEYCODE_DELETE, {KeyEvent::KEYCODE_DEL});
} else {
mTapCount = 0;
}

View File

@ -458,7 +458,7 @@ bool ListPopupWindow::onKeyDown(int keyCode,KeyEvent& event){
// also if selection is not currently in the drop down, then don't
// let center or enter presses go there since that would cause it
// to select one of its items
if (keyCode != KEY_SPACE
if (keyCode != KeyEvent::KEYCODE_SPACE
&& (mDropDownList->getSelectedItemPosition() >= 0
|| !KeyEvent::isConfirmKey(keyCode))) {
int curIndex = mDropDownList->getSelectedItemPosition();
@ -480,8 +480,8 @@ bool ListPopupWindow::onKeyDown(int keyCode,KeyEvent& event){
mDropDownList->lookForSelectablePosition(adapter->getCount() - 1, false);
}
if ((below && keyCode == KEY_DPAD_UP && curIndex <= firstItem) ||
(!below && keyCode == KEY_DPAD_DOWN && curIndex >= lastItem)) {
if ((below && keyCode == KeyEvent::KEYCODE_DPAD_UP && curIndex <= firstItem) ||
(!below && keyCode == KeyEvent::KEYCODE_DPAD_DOWN && curIndex >= lastItem)) {
// When the selection is at the top, we block the key
// event to prevent focus from moving.
clearListSelection();
@ -511,20 +511,20 @@ bool ListPopupWindow::onKeyDown(int keyCode,KeyEvent& event){
switch (keyCode) {
// avoid passing the focus from the text view to the
// next component
case KEY_ENTER:
case KEY_DPAD_CENTER:
case KEY_DPAD_DOWN:
case KEY_DPAD_UP:
case KeyEvent::KEYCODE_ENTER:
case KeyEvent::KEYCODE_DPAD_CENTER:
case KeyEvent::KEYCODE_DPAD_DOWN:
case KeyEvent::KEYCODE_DPAD_UP:
return true;
}
} else {
if (below && keyCode == KEY_DPAD_DOWN) {
if (below && keyCode == KeyEvent::KEYCODE_DPAD_DOWN) {
// when the selection is at the bottom, we block the
// event to avoid going to the next focusable widget
if (curIndex == lastItem) {
return true;
}
} else if (!below && keyCode == KEY_DPAD_UP &&
} else if (!below && keyCode == KeyEvent::KEYCODE_DPAD_UP &&
curIndex == firstItem) {
return true;
}

View File

@ -1616,7 +1616,7 @@ bool ListView::commonKey(int keyCode, int count, KeyEvent& event) {
LOGV("%s action=%d handled=%d",KeyEvent::getLabel(keyCode),action,handled);
if (!handled && action != KeyEvent::ACTION_UP) {
switch (keyCode) {
case KEY_DPAD_UP:
case KeyEvent::KEYCODE_DPAD_UP:
if (event.hasNoModifiers()) {
handled = resurrectSelectionIfNeeded();
if (!handled) {
@ -1633,7 +1633,7 @@ bool ListView::commonKey(int keyCode, int count, KeyEvent& event) {
}
break;
case KEY_DPAD_DOWN:
case KeyEvent::KEYCODE_DPAD_DOWN:
if (event.hasNoModifiers()) {
handled = resurrectSelectionIfNeeded();
if (!handled) {
@ -1650,19 +1650,19 @@ bool ListView::commonKey(int keyCode, int count, KeyEvent& event) {
}
break;
case KEY_DPAD_LEFT:
case KeyEvent::KEYCODE_DPAD_LEFT:
if (event.hasNoModifiers()) {
handled = handleHorizontalFocusWithinListItem(FOCUS_LEFT);
}
break;
case KEY_DPAD_RIGHT:
case KeyEvent::KEYCODE_DPAD_RIGHT:
if (event.hasNoModifiers()) {
handled = handleHorizontalFocusWithinListItem(View::FOCUS_RIGHT);
}
break;
case KEY_PAGE_UP:
case KeyEvent::KEYCODE_PAGE_UP:
if (event.hasNoModifiers()) {
handled = resurrectSelectionIfNeeded() || pageScroll(FOCUS_UP);
} else if (event.hasModifiers(KeyEvent::META_ALT_ON)) {
@ -1670,7 +1670,7 @@ bool ListView::commonKey(int keyCode, int count, KeyEvent& event) {
}
break;
case KEY_PAGE_DOWN:
case KeyEvent::KEYCODE_PAGE_DOWN:
if (event.hasNoModifiers()) {
handled = resurrectSelectionIfNeeded() || pageScroll(FOCUS_DOWN);
} else if (event.hasModifiers(KeyEvent::META_ALT_ON)) {
@ -1678,19 +1678,19 @@ bool ListView::commonKey(int keyCode, int count, KeyEvent& event) {
}
break;
case KEY_MOVE_HOME:
case KeyEvent::KEYCODE_MOVE_HOME:
if (event.hasNoModifiers()) {
handled = resurrectSelectionIfNeeded() || fullScroll(FOCUS_UP);
}
break;
case KEY_MOVE_END:
case KeyEvent::KEYCODE_MOVE_END:
if (event.hasNoModifiers()) {
handled = resurrectSelectionIfNeeded() || fullScroll(FOCUS_DOWN);
}
break;
case KEY_TAB:
case KeyEvent::KEYCODE_TAB:
// This creates an asymmetry in TAB navigation order. At some
// point in the future we may decide that it's preferable to
// force the list selection to the top or bottom when receiving

View File

@ -292,9 +292,9 @@ bool MediaController::dispatchKeyEvent(KeyEvent& event) {
const int keyCode = event.getKeyCode();
bool uniqueDown = event.getRepeatCount() == 0
&& event.getAction() == KeyEvent::ACTION_DOWN;
if (keyCode == KEY_HEADSETHOOK
|| keyCode == KEY_MEDIA_PLAY_PAUSE
|| keyCode == KEY_SPACE) {
if (keyCode == KeyEvent::KEYCODE_HEADSETHOOK
|| keyCode == KeyEvent::KEYCODE_MEDIA_PLAY_PAUSE
|| keyCode == KeyEvent::KEYCODE_SPACE) {
if (uniqueDown) {
doPauseResume();
show(sDefaultTimeout);
@ -303,28 +303,28 @@ bool MediaController::dispatchKeyEvent(KeyEvent& event) {
}
}
return true;
} else if (keyCode == KEY_MEDIA_PLAY) {
} else if (keyCode == KeyEvent::KEYCODE_MEDIA_PLAY) {
if (uniqueDown && !mPlayer.isPlaying()) {
mPlayer.start();
updatePausePlay();
show(sDefaultTimeout);
}
return true;
} else if (keyCode ==KEY_MEDIA_STOP
|| keyCode == KEY_MEDIA_PAUSE) {
} else if (keyCode ==KeyEvent::KEYCODE_MEDIA_STOP
|| keyCode == KeyEvent::KEYCODE_MEDIA_PAUSE) {
if (uniqueDown && mPlayer.isPlaying()) {
mPlayer.pause();
updatePausePlay();
show(sDefaultTimeout);
}
return true;
} else if (keyCode == KEY_VOLUME_DOWN
|| keyCode == KEY_VOLUME_UP
|| keyCode == KEY_VOLUME_MUTE
|| keyCode == KEY_CAMERA) {
} else if (keyCode == KeyEvent::KEYCODE_VOLUME_DOWN
|| keyCode == KeyEvent::KEYCODE_VOLUME_UP
|| keyCode == KeyEvent::KEYCODE_VOLUME_MUTE
|| keyCode == KeyEvent::KEYCODE_CAMERA) {
// don't show the controls for volume adjustment
return FrameLayout::dispatchKeyEvent(event);
} else if (keyCode == KEY_BACK || keyCode == KEY_MENU) {
} else if (keyCode == KeyEvent::KEYCODE_BACK || keyCode == KeyEvent::KEYCODE_MENU) {
if (uniqueDown) {
hide();
}

View File

@ -401,7 +401,7 @@ bool NestedScrollView::executeKeyEvent(KeyEvent& event) {
mTempRect.setEmpty();
if (!canScroll()) {
if (isFocused() && event.getKeyCode() != KEY_BACK) {
if (isFocused() && event.getKeyCode() != KeyEvent::KEYCODE_BACK) {
View* currentFocused = findFocus();
if (currentFocused == this) currentFocused = nullptr;
View* nextFocused = FocusFinder::getInstance().findNextFocus(this,
@ -415,21 +415,21 @@ bool NestedScrollView::executeKeyEvent(KeyEvent& event) {
bool handled = false;
if (event.getAction() == KeyEvent::ACTION_DOWN) {
switch (event.getKeyCode()) {
case KEY_DPAD_UP:
case KeyEvent::KEYCODE_DPAD_UP:
if (!event.isAltPressed()) {
handled = arrowScroll(View::FOCUS_UP);
} else {
handled = fullScroll(View::FOCUS_UP);
}
break;
case KEY_DPAD_DOWN:
case KeyEvent::KEYCODE_DPAD_DOWN:
if (!event.isAltPressed()) {
handled = arrowScroll(View::FOCUS_DOWN);
} else {
handled = fullScroll(View::FOCUS_DOWN);
}
break;
case KEY_SPACE:
case KeyEvent::KEYCODE_SPACE:
pageScroll(event.isShiftPressed() ? FOCUS_UP : FOCUS_DOWN);
break;
}

View File

@ -464,20 +464,20 @@ bool NumberPicker::dispatchTouchEvent(MotionEvent& event){
bool NumberPicker::dispatchKeyEvent(KeyEvent& event){
int keyCode = event.getKeyCode();
switch (keyCode) {
case KEY_DPAD_CENTER:
case KEY_ENTER:
case KeyEvent::KEYCODE_DPAD_CENTER:
case KeyEvent::KEYCODE_ENTER:
removeAllCallbacks();
break;
case KEY_DPAD_DOWN:
case KEY_DPAD_UP:
case KeyEvent::KEYCODE_DPAD_DOWN:
case KeyEvent::KEYCODE_DPAD_UP:
switch (event.getAction()) {
case KeyEvent::ACTION_DOWN:
if (mWrapSelectorWheel || ((keyCode == KEY_DPAD_DOWN)
if (mWrapSelectorWheel || ((keyCode == KeyEvent::KEYCODE_DPAD_DOWN)
? getValue() < getMaxValue() : getValue() > getMinValue())) {
requestFocus();
mLastHandledDownDpadKeyCode = keyCode;
removeAllCallbacks();
changeValueByOne(keyCode == KEY_DPAD_DOWN);
changeValueByOne(keyCode == KeyEvent::KEYCODE_DPAD_DOWN);
return true;
}break;
case KeyEvent::ACTION_UP:

View File

@ -1119,7 +1119,7 @@ PopupWindow::PopupDecorView::PopupDecorView(int w,int h)
}
bool PopupWindow::PopupDecorView::dispatchKeyEvent(KeyEvent& event){
if (event.getKeyCode() == KEY_BACK) {
if (event.getKeyCode() == KeyEvent::KEYCODE_BACK) {
if (getKeyDispatcherState() == nullptr) {
return Window::dispatchKeyEvent(event);
}

View File

@ -193,7 +193,7 @@ bool ScrollView::dispatchKeyEvent(KeyEvent& event) {
bool ScrollView::executeKeyEvent(KeyEvent& event) {
if (!canScroll()) {
if (isFocused() && event.getKeyCode() !=KEY_BACK) {
if (isFocused() && event.getKeyCode() !=KeyEvent::KEYCODE_BACK) {
View* currentFocused = findFocus();
if (currentFocused == this) currentFocused = nullptr;
View* nextFocused = FocusFinder::getInstance().findNextFocus(this, currentFocused, View::FOCUS_DOWN);
@ -206,21 +206,21 @@ bool ScrollView::executeKeyEvent(KeyEvent& event) {
bool handled = false;
if (event.getAction() == KeyEvent::ACTION_DOWN) {
switch (event.getKeyCode()) {
case KEY_DPAD_UP:
case KeyEvent::KEYCODE_DPAD_UP:
if (!event.isAltPressed()) {
handled = arrowScroll(View::FOCUS_UP);
} else {
handled = fullScroll(View::FOCUS_UP);
}
break;
case KEY_DPAD_DOWN:
case KeyEvent::KEYCODE_DPAD_DOWN:
if (!event.isAltPressed()) {
handled = arrowScroll(View::FOCUS_DOWN);
} else {
handled = fullScroll(View::FOCUS_DOWN);
}
break;
case KEY_SPACE:
case KeyEvent::KEYCODE_SPACE:
pageScroll(event.isShiftPressed() ? View::FOCUS_UP : View::FOCUS_DOWN);
break;
}

View File

@ -5,21 +5,15 @@
namespace cdroid{
SimpleMonthView::SimpleMonthView(int w,int h):View(w,h){
mOnDayClickListener=nullptr;
mDayTextColor=nullptr;
mDesiredMonthHeight=30;
mDesiredDayHeight=30;
mDesiredDayOfWeekHeight=30;
mDesiredDaySelectorRadius=15;
setFocusable(true);
initMonthView();
mPaddedWidth = w;
mPaddedHeight = h;
// We may have been laid out smaller than our preferred size. If so,
// scale all dimensions to fit.
int measuredPaddedHeight = h;// - paddingTop - paddingBottom;
float scaleH = 1.0f;//paddedHeight / (float) measuredPaddedHeight;
const float scaleH = 1.0f;//paddedHeight / (float) measuredPaddedHeight;
int monthHeight = (int) (mDesiredMonthHeight * scaleH);
int cellWidth = mPaddedWidth / DAYS_IN_WEEK;
mMonthHeight = monthHeight;
@ -38,11 +32,36 @@ SimpleMonthView::SimpleMonthView(int w,int h):View(w,h){
SimpleMonthView::SimpleMonthView(Context*ctx,const AttributeSet&atts)
:View(ctx,atts){
initMonthView();
mDesiredMonthHeight = atts.getDimensionPixelSize("month_height");
mDesiredDayOfWeekHeight =atts.getDimensionPixelSize("day_of_week_height");
mDesiredDayHeight = atts.getDimensionPixelSize("day_height");
mDesiredCellWidth = atts.getDimensionPixelSize("day_width");
mDesiredDaySelectorRadius=atts.getDimensionPixelSize("day_selector_radius");
std::string res = atts.getString("monthTextAppearance");
if(!res.empty())setMonthTextAppearance(res);
res = atts.getString("dayOfWeekTextAppearance");
if(!res.empty())setDayOfWeekTextAppearance(res);
res = atts.getString("dayTextAppearance");
if(!res.empty())setDayTextAppearance(res);
}
void SimpleMonthView::initMonthView(){
mOnDayClickListener = nullptr;
mDayTextColor = nullptr;
mDesiredMonthHeight = 30;
mDesiredDayHeight = 30;
mDesiredDayOfWeekHeight = 30;
mDesiredDaySelectorRadius= 15;
mDayTypeface = nullptr;
mMonthTypeface = nullptr;
mDayOfWeekTypeface = nullptr;
mMonth = 0;
mPaddedWidth = 0;
mPaddedHeight= 0;
mDayTextSize = 18;
mMonthTextSize=24;
mDayOfWeekTextSize=18;
}
void SimpleMonthView::updateMonthYearLabel(){
@ -56,23 +75,28 @@ void SimpleMonthView::updateDayOfWeekLabels(){
}
}
ColorStateList* SimpleMonthView::applyTextAppearance(const std::string& resId){
return nullptr;
ColorStateList* SimpleMonthView::applyTextAppearance(Typeface*&face,int& textSize,const std::string& resId){
AttributeSet attrs = mContext->obtainStyledAttributes(resId);
std::string fontFamily = attrs.getString("fontFamily");
textSize = attrs.getDimensionPixelSize("textSize",textSize);
ColorStateList* textColor = attrs.getColorStateList("textColor");
if(!fontFamily.empty()) face = Typeface::create(fontFamily,0);
return textColor;
}
void SimpleMonthView::setMonthTextAppearance(const std::string& resId) {
applyTextAppearance(resId);
mMonthTextColor = applyTextAppearance(mMonthTypeface,mMonthTextSize,resId);
invalidate();
}
void SimpleMonthView::setDayOfWeekTextAppearance(const std::string& resId) {
applyTextAppearance(resId);
mDayOfWeekTextColor = applyTextAppearance(mDayOfWeekTypeface,mDayOfWeekTextSize,resId);
invalidate();
}
void SimpleMonthView::setDayTextAppearance(const std::string& resId) {
ColorStateList* textColor = applyTextAppearance(resId);
ColorStateList* textColor = applyTextAppearance(mDayTypeface,mDayTextSize,resId);
if (textColor != nullptr) {
mDayTextColor = textColor;
}
@ -89,18 +113,27 @@ int SimpleMonthView::getCellWidth()const{
}
void SimpleMonthView::setMonthTextColor(const ColorStateList* monthTextColor){
mMonthTextColor = monthTextColor;
invalidate();
}
void SimpleMonthView::setDayOfWeekTextColor(const ColorStateList* dayOfWeekTextColor){
mDayOfWeekTextColor = dayOfWeekTextColor;
invalidate();
}
void SimpleMonthView::setDayTextColor(const ColorStateList* dayTextColor){
mDayTextColor = dayTextColor;
invalidate();
}
void SimpleMonthView::setDaySelectorColor(const ColorStateList* dayBackgroundColor){
//mHighlightTextColor = dayBackgroundColor;
invalidate();
}
void SimpleMonthView::setDayHighlightColor(const ColorStateList* dayHighlightColor){
}
void SimpleMonthView::setOnDayClickListener(OnDayClickListener listener){
@ -151,17 +184,17 @@ bool SimpleMonthView::onKeyDown(int keyCode, KeyEvent& event){
// to the next focusable View in the hierarchy.
bool focusChanged = false;
switch (event.getKeyCode()) {
case KEY_DPAD_LEFT:
case KeyEvent::KEYCODE_DPAD_LEFT:
if (event.hasNoModifiers()) {
focusChanged = moveOneDay(isLayoutRtl());
}
break;
case KEY_DPAD_RIGHT:
case KeyEvent::KEYCODE_DPAD_RIGHT:
if (event.hasNoModifiers()) {
focusChanged = moveOneDay(!isLayoutRtl());
}
break;
case KEY_DPAD_UP:
case KeyEvent::KEYCODE_DPAD_UP:
if (event.hasNoModifiers()) {
ensureFocusedDay();
if (mHighlightedDay > 7) {
@ -170,7 +203,7 @@ bool SimpleMonthView::onKeyDown(int keyCode, KeyEvent& event){
}
}
break;
case KEY_DPAD_DOWN:
case KeyEvent::KEYCODE_DPAD_DOWN:
if (event.hasNoModifiers()) {
ensureFocusedDay();
if (mHighlightedDay <= mDaysInMonth - 7) {
@ -179,14 +212,14 @@ bool SimpleMonthView::onKeyDown(int keyCode, KeyEvent& event){
}
}
break;
case KEY_DPAD_CENTER:
case KEY_ENTER:
case KeyEvent::KEYCODE_DPAD_CENTER:
case KeyEvent::KEYCODE_ENTER:
if (mHighlightedDay != -1) {
onDayClicked(mHighlightedDay);
return true;
}
break;
case KEY_TAB: {
case KeyEvent::KEYCODE_TAB: {
int focusChangeDirection = 0;
if (event.hasNoModifiers()) {
focusChangeDirection = View::FOCUS_FORWARD;
@ -382,9 +415,9 @@ const std::string SimpleMonthView::getMonthYearLabel(){
}
void SimpleMonthView::drawDaysOfWeek(Canvas& canvas){
int headerHeight = mMonthHeight;
int rowHeight = mDayOfWeekHeight;
int colWidth = mCellWidth;
const int headerHeight = mMonthHeight;
const int rowHeight = mDayOfWeekHeight;
const int colWidth = mCellWidth;
// Text is vertically centered within the day of week height.
int rowCenter = headerHeight + rowHeight / 2;
@ -393,6 +426,9 @@ void SimpleMonthView::drawDaysOfWeek(Canvas& canvas){
canvas.move_to(0,headerHeight);
canvas.line_to(mRight-mLeft,headerHeight);
canvas.stroke();
canvas.set_font_size(mDayOfWeekTextSize);
if(mDayOfWeekTypeface)
canvas.set_font_face(mDayOfWeekTypeface->getFontFace()->get_font_face());
Rect rctxt={0,headerHeight,mCellWidth,rowHeight};
for (int col = 0; col < DAYS_IN_WEEK; col++) {
int colCenter = colWidth * col + colWidth / 2;
@ -432,17 +468,17 @@ void SimpleMonthView::drawDays(Canvas& canvas){
int stateMask = 0;
bool bDayEnabled = isDayEnabled(day);
const bool bDayEnabled = isDayEnabled(day);
if (bDayEnabled) {
stateMask |= StateSet::VIEW_STATE_ENABLED;
}
bool isDayActivated = mActivatedDay == day;
bool isDayHighlighted = mHighlightedDay == day;
const bool isDayActivated = mActivatedDay == day;
const bool isDayHighlighted = mHighlightedDay == day;
canvas.set_color(0x8000FF00);
if (isDayActivated) {
stateMask |= StateSet::VIEW_STATE_ACTIVATED;
//ColorStateList* cls= isDayActivated?mDayHilight:mDaySelector;
// Adjust the circle to be centered on the row.
canvas.arc(colCenterRtl, rowCenter, mDaySelectorRadius, 0,2*M_PI);
canvas.fill();
@ -461,7 +497,7 @@ void SimpleMonthView::drawDays(Canvas& canvas){
dayTextColor = 0xFF00FF00;//mDaySelectorPaint.getColor();
} else {
std::vector<int> stateSet = StateSet::get(stateMask);
dayTextColor =0xFFFFFFFF;// mDayTextColor->getColorForState(stateSet, 0);
dayTextColor = 0xFFFFFFFF;// mDayTextColor->getColorForState(stateSet, 0);
}
canvas.set_color(dayTextColor);
rctxt.left=colWidth * col;
@ -582,13 +618,13 @@ bool SimpleMonthView::sameDay(int day, Calendar& today){
}
void SimpleMonthView::onMeasure(int widthMeasureSpec, int heightMeasureSpec){
int preferredHeight = mDesiredDayHeight * MAX_WEEKS_IN_MONTH
const int preferredHeight = mDesiredDayHeight * MAX_WEEKS_IN_MONTH
+ mDesiredDayOfWeekHeight + mDesiredMonthHeight
+ getPaddingTop() + getPaddingBottom();
int preferredWidth = mDesiredCellWidth * DAYS_IN_WEEK
const int preferredWidth = mDesiredCellWidth * DAYS_IN_WEEK
+ getPaddingStart() + getPaddingEnd();
int resolvedWidth = resolveSize(preferredWidth, widthMeasureSpec);
int resolvedHeight = resolveSize(preferredHeight, heightMeasureSpec);
const int resolvedWidth = resolveSize(preferredWidth, widthMeasureSpec);
const int resolvedHeight = resolveSize(preferredHeight, heightMeasureSpec);
setMeasuredDimension(resolvedWidth, resolvedHeight);
}
@ -596,14 +632,14 @@ void SimpleMonthView::onLayout(bool changed, int left, int top, int w, int h){
if (!changed) return;
// Let's initialize a completely reasonable number of variables.
int paddingLeft = getPaddingLeft();
int paddingTop = getPaddingTop();
int paddingRight = getPaddingRight();
int paddingBottom = getPaddingBottom();
int paddedRight = w - paddingRight;
int paddedBottom = h - paddingBottom;
int paddedWidth = paddedRight - paddingLeft;
int paddedHeight = paddedBottom - paddingTop;
const int paddingLeft = getPaddingLeft();
const int paddingTop = getPaddingTop();
const int paddingRight = getPaddingRight();
const int paddingBottom = getPaddingBottom();
const int paddedRight = w - paddingRight;
const int paddedBottom = h - paddingBottom;
const int paddedWidth = paddedRight - paddingLeft;
const int paddedHeight = paddedBottom - paddingTop;
if (paddedWidth == mPaddedWidth || paddedHeight == mPaddedHeight) {
return;
}
@ -613,10 +649,10 @@ void SimpleMonthView::onLayout(bool changed, int left, int top, int w, int h){
// We may have been laid out smaller than our preferred size. If so,
// scale all dimensions to fit.
int measuredPaddedHeight = getMeasuredHeight() - paddingTop - paddingBottom;
float scaleH = paddedHeight / (float) measuredPaddedHeight;
int monthHeight = (int) (mDesiredMonthHeight * scaleH);
int cellWidth = mPaddedWidth / DAYS_IN_WEEK;
const int measuredPaddedHeight = getMeasuredHeight() - paddingTop - paddingBottom;
const float scaleH = paddedHeight / (float) measuredPaddedHeight;
const int monthHeight = (int) (mDesiredMonthHeight * scaleH);
const int cellWidth = mPaddedWidth / DAYS_IN_WEEK;
mMonthHeight = monthHeight;
mDayOfWeekHeight = (int) (mDesiredDayOfWeekHeight * scaleH);
mDayHeight = (int) (mDesiredDayHeight * scaleH);
@ -624,8 +660,8 @@ void SimpleMonthView::onLayout(bool changed, int left, int top, int w, int h){
// Compute the largest day selector radius that's still within the clip
// bounds and desired selector radius.
int maxSelectorWidth = cellWidth / 2 + std::min(paddingLeft, paddingRight);
int maxSelectorHeight = mDayHeight / 2 + paddingBottom;
const int maxSelectorWidth = cellWidth / 2 + std::min(paddingLeft, paddingRight);
const int maxSelectorHeight = mDayHeight / 2 + paddingBottom;
mDaySelectorRadius = std::min(mDesiredDaySelectorRadius,
std::min(maxSelectorWidth, maxSelectorHeight));
@ -634,7 +670,7 @@ void SimpleMonthView::onLayout(bool changed, int left, int top, int w, int h){
}
int SimpleMonthView::findDayOffset(){
int offset = mDayOfWeekStart - mWeekStart;
const int offset = mDayOfWeekStart - mWeekStart;
if (mDayOfWeekStart < mWeekStart) {
return offset + DAYS_IN_WEEK;
}
@ -642,29 +678,24 @@ int SimpleMonthView::findDayOffset(){
}
int SimpleMonthView::getDayAtLocation(int x, int y) {
int paddedX = x - getPaddingLeft();
const int paddedX = x - getPaddingLeft();
if (paddedX < 0 || paddedX >= mPaddedWidth) {
return -1;
}
int headerHeight = mMonthHeight + mDayOfWeekHeight;
int paddedY = y - getPaddingTop();
const int headerHeight = mMonthHeight + mDayOfWeekHeight;
const int paddedY = y - getPaddingTop();
if (paddedY < headerHeight || paddedY >= mPaddedHeight) {
return -1;
}
// Adjust for RTL after applying padding.
int paddedXRtl;
if (isLayoutRtl()) {
paddedXRtl = mPaddedWidth - paddedX;
} else {
paddedXRtl = paddedX;
}
const int paddedXRtl = isLayoutRtl()?(mPaddedWidth - paddedX):paddedX;
int row = (paddedY - headerHeight) / mDayHeight;
int col = (paddedXRtl * DAYS_IN_WEEK) / mPaddedWidth;
int index = col + row * DAYS_IN_WEEK;
int day = index + 1 - findDayOffset();
const int row = (paddedY - headerHeight) / mDayHeight;
const int col = (paddedXRtl * DAYS_IN_WEEK) / mPaddedWidth;
const int index = col + row * DAYS_IN_WEEK;
const int day = index + 1 - findDayOffset();
if (!isValidDayOfMonth(day)) {
return -1;
}
@ -677,11 +708,11 @@ bool SimpleMonthView::getBoundsForDay(int id,Rect&outBounds){
return false;
}
int index = id - 1 + findDayOffset();
const int index = id - 1 + findDayOffset();
// Compute left edge, taking into account RTL.
int col = index % DAYS_IN_WEEK;
int colWidth = mCellWidth;
const int col = index % DAYS_IN_WEEK;
const int colWidth = mCellWidth;
int left;
if (isLayoutRtl()) {
left = getWidth() - getPaddingRight() - (col + 1) * colWidth;
@ -690,10 +721,10 @@ bool SimpleMonthView::getBoundsForDay(int id,Rect&outBounds){
}
// Compute top edge.
int row = index / DAYS_IN_WEEK;
int rowHeight = mDayHeight;
int headerHeight = mMonthHeight + mDayOfWeekHeight;
int top = getPaddingTop() + headerHeight + row * rowHeight;
const int row = index / DAYS_IN_WEEK;
const int rowHeight = mDayHeight;
const int headerHeight = mMonthHeight + mDayOfWeekHeight;
const int top = getPaddingTop() + headerHeight + row * rowHeight;
outBounds.set(left, top,colWidth,rowHeight);

View File

@ -2,6 +2,7 @@
#define __SIMPLE_MONTHVIEW_H__
#include <view/view.h>
#include <core/calendar.h>
#include <core/typeface.h>
namespace cdroid{
class SimpleMonthView:public View{
@ -16,6 +17,16 @@ private:
Calendar mCalendar;
std::string mDayOfWeekLabels[7];
Typeface*mDayTypeface;
Typeface*mMonthTypeface;
Typeface*mDayOfWeekTypeface;
int mDayTextSize;
int mMonthTextSize;
int mDayOfWeekTextSize;
const ColorStateList* mDayTextColor;
const ColorStateList* mMonthTextColor;
const ColorStateList* mDayOfWeekTextColor;
int mDesiredMonthHeight;
int mDesiredDayOfWeekHeight;
int mDesiredDayHeight;
@ -57,15 +68,14 @@ private:
/** Optional listener for handling day click actions. */
OnDayClickListener mOnDayClickListener;
ColorStateList* mDayTextColor;
int mHighlightedDay = -1;
int mPreviouslyHighlightedDay = -1;
bool mIsTouchHighlighted = false;
private:
void initMonthView();
void updateMonthYearLabel();
void updateDayOfWeekLabels();
ColorStateList*applyTextAppearance(const std::string& resId);
ColorStateList*applyTextAppearance(Typeface*&face,int& txtSize,const std::string& resId);
bool moveOneDay(bool positive);
int findClosestRow(const Rect* previouslyFocusedRect);
int findClosestColumn(const Rect*previouslyFocusedRect);

View File

@ -1858,21 +1858,21 @@ bool ViewPager::executeKeyEvent(KeyEvent& event){
bool handled = false;
if (event.getAction() == KeyEvent::ACTION_DOWN) {
switch (event.getKeyCode()) {
case KEY_DPAD_LEFT:
case KeyEvent::KEYCODE_DPAD_LEFT:
if (event.hasModifiers(KeyEvent::META_ALT_ON)) {
handled = pageLeft();
} else {
handled = arrowScroll(FOCUS_LEFT);
}
break;
case KEY_DPAD_RIGHT:
case KeyEvent::KEYCODE_DPAD_RIGHT:
if (event.hasModifiers(KeyEvent::META_ALT_ON)) {
handled = pageRight();
} else {
handled = arrowScroll(FOCUS_RIGHT);
}
break;
case KEY_TAB:
case KeyEvent::KEYCODE_TAB:
if (event.hasNoModifiers()) {
handled = arrowScroll(FOCUS_FORWARD);
} else if (event.hasModifiers(KeyEvent::META_SHIFT_ON)) {