am fd606bc3: Migrate to new keycode constants in keycodes.h.

Merge commit 'fd606bc303bdf1fafefc4a6b79d050faa26d0800' into gingerbread-plus-aosp

* commit 'fd606bc303bdf1fafefc4a6b79d050faa26d0800':
  Migrate to new keycode constants in keycodes.h.
This commit is contained in:
Jeff Brown
2010-07-13 17:43:39 -07:00
committed by Android Git Automerger
8 changed files with 52 additions and 52 deletions

View File

@@ -278,7 +278,7 @@ void DeviceManager::UserCancelledRefresh(void)
* *
* The events are defined in display_device.h. * The events are defined in display_device.h.
*/ */
void DeviceManager::SendKeyEvent(KeyCode keyCode, bool down) void DeviceManager::SendKeyEvent(int32_t keyCode, bool down)
{ {
android::MessageStream* pStream = GetStream(); android::MessageStream* pStream = GetStream();
if (pStream == NULL) if (pStream == NULL)

View File

@@ -107,7 +107,7 @@ public:
#endif #endif
// send a key-up or key-down event to the runtime // send a key-up or key-down event to the runtime
void SendKeyEvent(KeyCode keyCode, bool down); void SendKeyEvent(int32_t keyCode, bool down);
// send touch-screen events // send touch-screen events
void SendTouchEvent(android::Simulator::TouchMode mode, int x, int y); void SendTouchEvent(android::Simulator::TouchMode mode, int x, int y);

View File

@@ -27,7 +27,7 @@ bool PhoneButton::Create(const char* label)
assert(!mHasImage); // quick check for re-use assert(!mHasImage); // quick check for re-use
mKeyCode = LookupKeyCode(label); mKeyCode = LookupKeyCode(label);
if (mKeyCode == kKeyCodeUnknown) { if (mKeyCode == AKEYCODE_UNKNOWN) {
fprintf(stderr, "WARNING: key code '%s' not recognized\n", label); fprintf(stderr, "WARNING: key code '%s' not recognized\n", label);
// keep going // keep going
} }
@@ -129,9 +129,9 @@ bool PhoneButton::CheckCollision(int x, int y) const
/* /*
* Look up a key code based on a string. * Look up a key code based on a string.
* *
* Returns kKeyCodeUnknown if the label doesn't match anything. * Returns AKEYCODE_UNKNOWN if the label doesn't match anything.
*/ */
KeyCode PhoneButton::LookupKeyCode(const char* label) const int32_t PhoneButton::LookupKeyCode(const char* label) const
{ {
static const struct { static const struct {
const char* label; const char* label;
@@ -172,9 +172,9 @@ KeyCode PhoneButton::LookupKeyCode(const char* label) const
for (int i = 0; i < numCodes; i++) { for (int i = 0; i < numCodes; i++) {
if (strcmp(label, codeList[i].label) == 0) if (strcmp(label, codeList[i].label) == 0)
return (KeyCode) codeList[i].keyCode; return codeList[i].keyCode;
} }
return kKeyCodeUnknown; return AKEYCODE_UNKNOWN;
}; };

View File

@@ -21,11 +21,11 @@
class PhoneButton { class PhoneButton {
public: public:
PhoneButton(void) PhoneButton(void)
: mHasImage(false), mKeyCode(kKeyCodeUnknown) : mHasImage(false), mKeyCode(AKEYCODE_UNKNOWN)
{} {}
virtual ~PhoneButton(void) {} virtual ~PhoneButton(void) {}
PhoneButton(const PhoneButton& src) PhoneButton(const PhoneButton& src)
: mHasImage(false), mKeyCode(kKeyCodeUnknown) : mHasImage(false), mKeyCode(AKEYCODE_UNKNOWN)
{ {
CopyMembers(src); CopyMembers(src);
} }
@@ -60,7 +60,7 @@ public:
} }
bool CheckCollision(int x, int y) const; bool CheckCollision(int x, int y) const;
KeyCode GetKeyCode(void) const { return mKeyCode; } int32_t GetKeyCode(void) const { return mKeyCode; }
// load or unload the image bitmap, if any // load or unload the image bitmap, if any
bool LoadResources(void); bool LoadResources(void);
@@ -68,13 +68,13 @@ public:
private: private:
void CreateHighlightedBitmap(void); void CreateHighlightedBitmap(void);
KeyCode LookupKeyCode(const char* label) const; int32_t LookupKeyCode(const char* label) const;
LoadableImage mSelectedImage; LoadableImage mSelectedImage;
wxBitmap mHighlightedBitmap; wxBitmap mHighlightedBitmap;
bool mHasImage; // both exist or neither exist bool mHasImage; // both exist or neither exist
KeyCode mKeyCode; int32_t mKeyCode;
}; };
#endif // _SIM_PHONE_BUTTON_H #endif // _SIM_PHONE_BUTTON_H

View File

@@ -413,7 +413,7 @@ PhoneButton* PhoneView::FindButtonHit(int x, int y)
/* /*
* Find the first button with a matching key code. * Find the first button with a matching key code.
*/ */
PhoneButton* PhoneView::FindButtonByKey(KeyCode keyCode) PhoneButton* PhoneView::FindButtonByKey(int32_t keyCode)
{ {
typedef List<PhoneButton>::iterator Iter; typedef List<PhoneButton>::iterator Iter;

View File

@@ -178,7 +178,7 @@ public:
PhoneButton* FindButtonHit(int x, int y); PhoneButton* FindButtonHit(int x, int y);
// find the first button with a matching key code // find the first button with a matching key code
PhoneButton* FindButtonByKey(KeyCode keyCode); PhoneButton* FindButtonByKey(int32_t keyCode);
bool ProcessAndValidate(TiXmlNode* pNode, const char* directory); bool ProcessAndValidate(TiXmlNode* pNode, const char* directory);
bool ProcessImage(TiXmlNode* pNode, const char* directory); bool ProcessImage(TiXmlNode* pNode, const char* directory);

View File

@@ -54,7 +54,7 @@ PhoneWindow::PhoneWindow(wxWindow* parent, const wxPoint& posn)
wxDEFAULT_DIALOG_STYLE), wxDEFAULT_DIALOG_STYLE),
mpMOHViewIndex(-1), mpMOHViewIndex(-1),
mpMOHButton(NULL), mpMOHButton(NULL),
mMouseKeySent(kKeyCodeUnknown), mMouseKeySent(AKEYCODE_UNKNOWN),
mpViewInfo(NULL), mpViewInfo(NULL),
mNumViewInfo(0), mNumViewInfo(0),
mpDeviceWindow(NULL), mpDeviceWindow(NULL),
@@ -113,7 +113,7 @@ void PhoneWindow::OnActivate(wxActivateEvent& event)
if (!event.GetActive()) { if (!event.GetActive()) {
ListIter iter; ListIter iter;
for (iter = mPressedKeys.begin(); iter != mPressedKeys.end(); ) { for (iter = mPressedKeys.begin(); iter != mPressedKeys.end(); ) {
KeyCode keyCode = (*iter).GetKeyCode(); int32_t keyCode = (*iter).GetKeyCode();
GetDeviceManager()->SendKeyEvent(keyCode, false); GetDeviceManager()->SendKeyEvent(keyCode, false);
iter = mPressedKeys.erase(iter); iter = mPressedKeys.erase(iter);
} }
@@ -474,27 +474,27 @@ int PhoneWindow::ConvertKeyCode(int wxKeyCode) const
case WXK_NUMPAD_NEXT: case WXK_NUMPAD_NEXT:
case WXK_NUMPAD9: case WXK_NUMPAD9:
case '9': return KEY_9; case '9': return KEY_9;
case WXK_NUMPAD_MULTIPLY: return KEY_SWITCHVIDEOMODE; //kKeyCodeStar; case WXK_NUMPAD_MULTIPLY: return KEY_SWITCHVIDEOMODE; //AKEYCODE_STAR;
case WXK_LEFT: return KEY_LEFT; case WXK_LEFT: return KEY_LEFT;
case WXK_RIGHT: return KEY_RIGHT; case WXK_RIGHT: return KEY_RIGHT;
case WXK_UP: return KEY_UP; case WXK_UP: return KEY_UP;
case WXK_DOWN: return KEY_DOWN; case WXK_DOWN: return KEY_DOWN;
case WXK_NUMPAD_ENTER: return KEY_REPLY; //kKeyCodeDpadCenter; case WXK_NUMPAD_ENTER: return KEY_REPLY; //AKEYCODE_DPAD_CENTER;
case WXK_HOME: return KEY_HOME; case WXK_HOME: return KEY_HOME;
case WXK_PRIOR: case WXK_PRIOR:
case WXK_PAGEUP: return KEY_MENU; //kKeyCodeSoftLeft; case WXK_PAGEUP: return KEY_MENU; //AKEYCODE_SOFT_LEFT;
case WXK_NEXT: case WXK_NEXT:
case WXK_PAGEDOWN: return KEY_KBDILLUMUP; //kKeyCodeSoftRight; case WXK_PAGEDOWN: return KEY_KBDILLUMUP; //AKEYCODE_SOFT_RIGHT;
case WXK_DELETE: case WXK_DELETE:
case WXK_BACK: return KEY_BACKSPACE; //kKeyCodeDel; case WXK_BACK: return KEY_BACKSPACE; //AKEYCODE_DEL;
case WXK_ESCAPE: case WXK_ESCAPE:
case WXK_END: return KEY_BACK; //kKeyCodeBack; case WXK_END: return KEY_BACK; //AKEYCODE_BACK;
case WXK_NUMPAD_DELETE: case WXK_NUMPAD_DELETE:
case WXK_NUMPAD_DECIMAL: return KEY_KBDILLUMTOGGLE; //kKeyCodePound; case WXK_NUMPAD_DECIMAL: return KEY_KBDILLUMTOGGLE; //AKEYCODE_POUND;
case WXK_SPACE: return KEY_SPACE; //kKeyCodeSpace; case WXK_SPACE: return KEY_SPACE; //AKEYCODE_SPACE;
case WXK_RETURN: return KEY_ENTER; //kKeyCodeNewline; case WXK_RETURN: return KEY_ENTER; //AKEYCODE_ENTER;
case WXK_F3: return KEY_F3; //kKeyCodeCall; case WXK_F3: return KEY_F3; //AKEYCODE_CALL;
case WXK_F4: return KEY_F4; //kKeyCodeEndCall; case WXK_F4: return KEY_F4; //AKEYCODE_END_CALL;
case WXK_NUMPAD_ADD: case WXK_NUMPAD_ADD:
case WXK_F5: return KEY_VOLUMEUP; case WXK_F5: return KEY_VOLUMEUP;
case WXK_NUMPAD_SUBTRACT: case WXK_NUMPAD_SUBTRACT:
@@ -552,7 +552,7 @@ int PhoneWindow::ConvertKeyCode(int wxKeyCode) const
break; break;
} }
return kKeyCodeUnknown; return AKEYCODE_UNKNOWN;
} }
@@ -566,10 +566,10 @@ int PhoneWindow::ConvertKeyCode(int wxKeyCode) const
*/ */
void PhoneWindow::OnKeyDown(wxKeyEvent& event) void PhoneWindow::OnKeyDown(wxKeyEvent& event)
{ {
KeyCode keyCode; int32_t keyCode;
keyCode = (KeyCode) ConvertKeyCode(event.GetKeyCode()); keyCode = ConvertKeyCode(event.GetKeyCode());
if (keyCode != kKeyCodeUnknown) { if (keyCode != AKEYCODE_UNKNOWN) {
if (!IsKeyPressed(keyCode)) { if (!IsKeyPressed(keyCode)) {
//printf("PW: down: key %d\n", keyCode); //printf("PW: down: key %d\n", keyCode);
GetDeviceManager()->SendKeyEvent(keyCode, true); GetDeviceManager()->SendKeyEvent(keyCode, true);
@@ -586,10 +586,10 @@ void PhoneWindow::OnKeyDown(wxKeyEvent& event)
*/ */
void PhoneWindow::OnKeyUp(wxKeyEvent& event) void PhoneWindow::OnKeyUp(wxKeyEvent& event)
{ {
KeyCode keyCode; int32_t keyCode;
keyCode = (KeyCode) ConvertKeyCode(event.GetKeyCode()); keyCode = ConvertKeyCode(event.GetKeyCode());
if (keyCode != kKeyCodeUnknown) { if (keyCode != AKEYCODE_UNKNOWN) {
// Send the key event if we already have this key pressed. // Send the key event if we already have this key pressed.
if (IsKeyPressed(keyCode)) { if (IsKeyPressed(keyCode)) {
//printf("PW: up: key %d\n", keyCode); //printf("PW: up: key %d\n", keyCode);
@@ -617,7 +617,7 @@ void PhoneWindow::OnMouseLeftDown(wxMouseEvent& event)
{ {
if (mpMOHButton != NULL) { if (mpMOHButton != NULL) {
//printf("PW: left down\n"); //printf("PW: left down\n");
KeyCode keyCode = mpMOHButton->GetKeyCode(); int32_t keyCode = mpMOHButton->GetKeyCode();
GetDeviceManager()->SendKeyEvent(keyCode, true); GetDeviceManager()->SendKeyEvent(keyCode, true);
mMouseKeySent = keyCode; mMouseKeySent = keyCode;
AddPressedKey(keyCode); AddPressedKey(keyCode);
@@ -644,7 +644,7 @@ void PhoneWindow::OnMouseLeftDown(wxMouseEvent& event)
*/ */
void PhoneWindow::OnMouseLeftUp(wxMouseEvent& WXUNUSED(event)) void PhoneWindow::OnMouseLeftUp(wxMouseEvent& WXUNUSED(event))
{ {
if (mMouseKeySent != kKeyCodeUnknown) { if (mMouseKeySent != AKEYCODE_UNKNOWN) {
//printf("PW: left up\n"); //printf("PW: left up\n");
GetDeviceManager()->SendKeyEvent(mMouseKeySent, false); GetDeviceManager()->SendKeyEvent(mMouseKeySent, false);
RemovePressedKey(mMouseKeySent); RemovePressedKey(mMouseKeySent);
@@ -658,7 +658,7 @@ void PhoneWindow::OnMouseLeftUp(wxMouseEvent& WXUNUSED(event))
//printf("(ignoring left-up)\n"); //printf("(ignoring left-up)\n");
} }
} }
mMouseKeySent = kKeyCodeUnknown; mMouseKeySent = AKEYCODE_UNKNOWN;
} }
void PhoneWindow::OnMouseRightDown(wxMouseEvent& event) void PhoneWindow::OnMouseRightDown(wxMouseEvent& event)
@@ -909,7 +909,7 @@ void PhoneWindow::OnPaint(wxPaintEvent& WXUNUSED(event))
ListIter iter; ListIter iter;
for (iter = mPressedKeys.begin(); iter != mPressedKeys.end(); ++iter) { for (iter = mPressedKeys.begin(); iter != mPressedKeys.end(); ++iter) {
KeyCode keyCode; int32_t keyCode;
PhoneButton* pButton; PhoneButton* pButton;
keyCode = (*iter).GetKeyCode(); keyCode = (*iter).GetKeyCode();
@@ -933,7 +933,7 @@ void PhoneWindow::OnPaint(wxPaintEvent& WXUNUSED(event))
* *
* Schedules a screen refresh if the set of held-down keys changes. * Schedules a screen refresh if the set of held-down keys changes.
*/ */
void PhoneWindow::AddPressedKey(KeyCode keyCode) void PhoneWindow::AddPressedKey(int32_t keyCode)
{ {
/* /*
* See if the key is already down. This usually means that the key * See if the key is already down. This usually means that the key
@@ -943,8 +943,8 @@ void PhoneWindow::AddPressedKey(KeyCode keyCode)
* a second time. This way, if we did lose a key-up somehow, they * a second time. This way, if we did lose a key-up somehow, they
* can "clear" the stuck key by hitting it again. * can "clear" the stuck key by hitting it again.
*/ */
if (keyCode == kKeyCodeUnknown) { if (keyCode == AKEYCODE_UNKNOWN) {
//printf("--- not adding kKeyCodeUnknown!\n"); //printf("--- not adding AKEYCODE_UNKNOWN!\n");
return; return;
} }
@@ -969,7 +969,7 @@ void PhoneWindow::AddPressedKey(KeyCode keyCode)
* *
* Schedules a screen refresh if the set of held-down keys changes. * Schedules a screen refresh if the set of held-down keys changes.
*/ */
void PhoneWindow::RemovePressedKey(KeyCode keyCode) void PhoneWindow::RemovePressedKey(int32_t keyCode)
{ {
/* /*
* Release the key. If it's not in the list, we either missed a * Release the key. If it's not in the list, we either missed a
@@ -1000,7 +1000,7 @@ void PhoneWindow::ClearPressedKeys(void)
if (!mPressedKeys.empty()) { if (!mPressedKeys.empty()) {
ListIter iter = mPressedKeys.begin(); ListIter iter = mPressedKeys.begin();
while (iter != mPressedKeys.end()) { while (iter != mPressedKeys.end()) {
KeyCode keyCode = (*iter).GetKeyCode(); int32_t keyCode = (*iter).GetKeyCode();
GetDeviceManager()->SendKeyEvent(keyCode, false); GetDeviceManager()->SendKeyEvent(keyCode, false);
iter = mPressedKeys.erase(iter); iter = mPressedKeys.erase(iter);
} }
@@ -1011,7 +1011,7 @@ void PhoneWindow::ClearPressedKeys(void)
/* /*
* Returns "true" if the specified key is currently pressed. * Returns "true" if the specified key is currently pressed.
*/ */
bool PhoneWindow::IsKeyPressed(KeyCode keyCode) bool PhoneWindow::IsKeyPressed(int32_t keyCode)
{ {
ListIter iter; ListIter iter;
for (iter = mPressedKeys.begin(); iter != mPressedKeys.end(); ++iter) { for (iter = mPressedKeys.begin(); iter != mPressedKeys.end(); ++iter) {

View File

@@ -89,7 +89,7 @@ private:
*/ */
class KeyInfo { class KeyInfo {
public: public:
KeyInfo(void) : mKeyCode(kKeyCodeUnknown) {} KeyInfo(void) : mKeyCode(AKEYCODE_UNKNOWN) {}
KeyInfo(const KeyInfo& src) { KeyInfo(const KeyInfo& src) {
mKeyCode = src.mKeyCode; mKeyCode = src.mKeyCode;
} }
@@ -102,14 +102,14 @@ private:
return *this; return *this;
} }
KeyCode GetKeyCode(void) const { return mKeyCode; } int32_t GetKeyCode(void) const { return mKeyCode; }
void SetKeyCode(KeyCode keyCode) { mKeyCode = keyCode; } void SetKeyCode(int32_t keyCode) { mKeyCode = keyCode; }
//PhoneButton* GetPhoneButton(void) const { return mpButton; } //PhoneButton* GetPhoneButton(void) const { return mpButton; }
//void SetPhoneButton(PhoneButton* pButton) { mpButton = pButton; } //void SetPhoneButton(PhoneButton* pButton) { mpButton = pButton; }
private: private:
KeyCode mKeyCode; int32_t mKeyCode;
//PhoneButton* mpButton; //PhoneButton* mpButton;
}; };
@@ -135,13 +135,13 @@ private:
int ConvertKeyCode(int wxKeyCode) const; int ConvertKeyCode(int wxKeyCode) const;
/* press a key on the device */ /* press a key on the device */
void AddPressedKey(KeyCode keyCode); void AddPressedKey(int32_t keyCode);
/* release a key on the device */ /* release a key on the device */
void RemovePressedKey(KeyCode keyCode); void RemovePressedKey(int32_t keyCode);
/* "raise" all keys */ /* "raise" all keys */
void ClearPressedKeys(void); void ClearPressedKeys(void);
/* determine whether a key is down */ /* determine whether a key is down */
bool IsKeyPressed(KeyCode keyCode); bool IsKeyPressed(int32_t keyCode);
/* manage the device runtime */ /* manage the device runtime */
DeviceManager mDeviceManager; DeviceManager mDeviceManager;
@@ -149,7 +149,7 @@ private:
/* button mouse-over highlight handling */ /* button mouse-over highlight handling */
int mpMOHViewIndex; // mouse is in this view int mpMOHViewIndex; // mouse is in this view
PhoneButton* mpMOHButton; // over this button PhoneButton* mpMOHButton; // over this button
KeyCode mMouseKeySent; // to handle "key up" for mouse button int32_t mMouseKeySent; // to handle "key up" for mouse button
/* handle multiple simultaneous key presses */ /* handle multiple simultaneous key presses */
android::List<KeyInfo> mPressedKeys; android::List<KeyInfo> mPressedKeys;