From 8699cf1dc79f8da61ef026b7610f1378d0941b02 Mon Sep 17 00:00:00 2001 From: coah <100182500+coah80@users.noreply.github.com> Date: Wed, 30 Sep 2026 05:13:50 +0000 Subject: [PATCH] tiHwKeyboard 10/10, tiCandidateBox 105/112, MyTiManager 91/91 (worker 913d06d4) --- README.md | 4 +- include/keyboard/MyTiBg.h | 4 +- include/keyboard/MyTiManager.h | 20 + include/keyboard/tiCellPhone.h | 20 +- include/keyboard/tiHKBManager.h | 15 +- include/keyboard/tiHwKeyboard.h | 12 +- include/keyboard/tiKeyboard.h | 8 +- include/keyboard/tiManager.h | 3 + include/keyboard/tiPcKeyboard.h | 2 +- include/keyboard/tiPcKeyboardImpl.h | 6 + include/keyboard/tiTextInputBase.h | 4 +- include/keyboard/tiToolBar.h | 5 + src/keyboard/MyTiManager.cpp | 988 ++++++++++-------- src/keyboard/tiCandidateBox.cpp | 42 +- src/keyboard/tiHwKeyboard.cpp | 345 ++++++ tools/decomp-assist/MyTiManager.attempts.md | 89 ++ .../decomp-assist/tiCandidateBox.attempts.md | 41 + tools/decomp-assist/tiHwKeyboard.attempts.md | 19 + 18 files changed, 1149 insertions(+), 478 deletions(-) create mode 100644 tools/decomp-assist/MyTiManager.attempts.md create mode 100644 tools/decomp-assist/tiCandidateBox.attempts.md create mode 100644 tools/decomp-assist/tiHwKeyboard.attempts.md diff --git a/README.md b/README.md index 93cae5b2..3f88af20 100644 --- a/README.md +++ b/README.md @@ -53,9 +53,9 @@ Progress | Decompiled | Matched | Linked | Data | |:---:|:---:|:---:|:---:| -| 87.60% | 77.28% | 56.92% | 88.22% | +| 87.88% | 77.62% | 56.92% | 88.23% | -units 752/1027 complete, functions 11313/12563 matched. +units 752/1027 complete, functions 11324/12563 matched. decompiled = code with a C/C++ implementation (objdiff fuzzy), matched = byte-exact code, linked = code actually linked into the DOL, data = byte-exact data diff --git a/include/keyboard/MyTiBg.h b/include/keyboard/MyTiBg.h index aad892fe..dd3805ba 100644 --- a/include/keyboard/MyTiBg.h +++ b/include/keyboard/MyTiBg.h @@ -18,7 +18,9 @@ namespace textinput { LayoutByNW4R(nw4r::lyt::MultiArcResourceAccessor* multiArc, const char* layoutName, EventObserver* event) : nw4rmanager::Layout(multiArc, layoutName, event) {} #endif -#ifdef MYTIMANAGER_IMPLEMENTATION +#if defined(MYTIMANAGER_MATCHING) + virtual ~LayoutByNW4R() {} +#elif defined(MYTIMANAGER_IMPLEMENTATION) virtual ~LayoutByNW4R(); #else virtual ~LayoutByNW4R() {} diff --git a/include/keyboard/MyTiManager.h b/include/keyboard/MyTiManager.h index 584767c5..feebe6e8 100644 --- a/include/keyboard/MyTiManager.h +++ b/include/keyboard/MyTiManager.h @@ -167,6 +167,25 @@ namespace textinput { void setManager(Manager* manager) { mpManager = manager; } #endif virtual ~State(); +#ifdef MYTIMANAGER_MATCHING + virtual Manager::StateType getStateType() = 0; + + virtual void create() = 0; + + virtual void init() = 0; + + virtual void draw() = 0; + virtual void memoDraw() = 0; + + virtual void calc() = 0; + + virtual bool updateInput(int chan, f32 x, f32 y, u32 trig, u32 hold, u32 release) = 0; + virtual bool updateInput(input::HKBManager& hkbManager) = 0; + + virtual void start() = 0; + virtual void end() = 0; + +#else virtual Manager::StateType getStateType(); virtual void create(); @@ -184,6 +203,7 @@ namespace textinput { virtual void start(); virtual void end(); +#endif #ifdef MYTIMANAGER_IMPLEMENTATION virtual InputForm* InputForm(); virtual keyboard::hwkey::HWKeyboard* HWKeyboard(); diff --git a/include/keyboard/tiCellPhone.h b/include/keyboard/tiCellPhone.h index b1bc2349..09e782f9 100644 --- a/include/keyboard/tiCellPhone.h +++ b/include/keyboard/tiCellPhone.h @@ -2,20 +2,20 @@ #define TEXTINPUT_CELL_PHONE_H #include "tiNw4rManager.h" -#if defined(MYTIMANAGER_IMPLEMENTATION) || defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION) +#if defined(MYTIMANAGER_IMPLEMENTATION) || defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIHWKEYBOARD_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION) #include "tiKeyboard.h" #endif namespace textinput { namespace keyboard { namespace cellphonetype { -#if defined(MYTIMANAGER_IMPLEMENTATION) || defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION) +#if defined(MYTIMANAGER_IMPLEMENTATION) || defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIHWKEYBOARD_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION) class Base : public textinput::keyboard::KeyboardBase { #else class Base { #endif public: -#if defined(MYTIMANAGER_IMPLEMENTATION) || defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION) +#if defined(MYTIMANAGER_IMPLEMENTATION) || defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIHWKEYBOARD_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION) enum InputMode { IM_00, IM_01, @@ -32,6 +32,8 @@ namespace textinput { #ifdef TIMANAGER_IMPLEMENTATION Base(Manager* manager) : mpManager(manager) {} virtual int getType() override; +#elif defined(TIHWKEYBOARD_IMPLEMENTATION) + virtual int getType() override; #else virtual void getType() override; #endif @@ -79,7 +81,7 @@ namespace textinput { virtual void vt_0x4C(); virtual void vt_0x50(); -#if defined(MYTIMANAGER_IMPLEMENTATION) || defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION) +#if defined(MYTIMANAGER_IMPLEMENTATION) || defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIHWKEYBOARD_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION) virtual void doNumericMode(bool); #else virtual void vt_0x54(); @@ -95,11 +97,11 @@ namespace textinput { // TODO enum? int getInputType() const; -#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION) +#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIHWKEYBOARD_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION) void resetHoldingButton(); #endif -#if defined(MYTIMANAGER_IMPLEMENTATION) || defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION) +#if defined(MYTIMANAGER_IMPLEMENTATION) || defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIHWKEYBOARD_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION) private: u32 mPreviousInputMode; u32 mCurrentInputMode; @@ -123,7 +125,7 @@ namespace textinput { class LayoutByNW4R : public Base, public nw4rmanager::Layout { public: -#if defined(MYTIMANAGER_IMPLEMENTATION) || defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION) +#if defined(MYTIMANAGER_IMPLEMENTATION) || defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIHWKEYBOARD_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION) #ifdef TIMANAGER_IMPLEMENTATION LayoutByNW4R(Manager* manager, nw4r::lyt::MultiArcResourceAccessor* accessor, EventObserver* observer, const char* layoutName) : Base(manager), nw4rmanager::Layout(accessor, layoutName, observer), mpEventHandler(NULL) {} @@ -162,7 +164,7 @@ namespace textinput { void onPressedShift(bool shift); void onReleasedShift(); -#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION) +#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIHWKEYBOARD_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION) bool hasLineFeedButton() const { return mbLineFeedButton; } private: bool mbLineFeedButton; @@ -176,7 +178,7 @@ namespace textinput { #endif public: #endif -#if defined(MYTIMANAGER_IMPLEMENTATION) || defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION) +#if defined(MYTIMANAGER_IMPLEMENTATION) || defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIHWKEYBOARD_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION) virtual bool updateInput(int chan, f32 x, f32 y, u32 trig, u32 hold, u32 release, void* data) override; virtual bool updateInput(input::HKBManager& hkbManager) override; #endif diff --git a/include/keyboard/tiHKBManager.h b/include/keyboard/tiHKBManager.h index 1f5504a1..f2a43939 100644 --- a/include/keyboard/tiHKBManager.h +++ b/include/keyboard/tiHKBManager.h @@ -119,6 +119,9 @@ namespace textinput { KeySet GetTriggeredKeySet() const; KeySet GetReleasedKeySet() const; KeySet GetRepeatedKeySet() const; +#ifdef TIHWKEYBOARD_IMPLEMENTATION + KeySet GetReleasedKeySet() const; +#endif static void SetLedCB(_KBDEc result, void* userData); static void AttachCB(KBDDevEvent* event); static void DetachCB(KBDDevEvent* event); @@ -148,15 +151,22 @@ namespace textinput { u32 GetModifierState() const; void SetModifierState(u32, u32); -#if defined(TI_PC_KEYBOARD_IMPLEMENTATION) || defined(TISIGNWINDOW_IMPLEMENTATION) +#if defined(TI_PC_KEYBOARD_IMPLEMENTATION) || defined(TISIGNWINDOW_IMPLEMENTATION) || defined(TIHWKEYBOARD_IMPLEMENTATION) class KeySet { public: u8 GetKey() const; +#ifdef TIHWKEYBOARD_IMPLEMENTATION + u32 GetWChar() const; +#else wchar_t GetWChar() const; +#endif bool IsValid() const; KeySet GetNext() const; KeySet(const KeySet& other) : mpManager(other.mpManager), mKind(other.mKind), mIndex(other.mIndex), mDevice(other.mDevice), mCharacter(other.mCharacter) {} +#ifdef TIHWKEYBOARD_IMPLEMENTATION + KeySet() : mpManager(NULL), mKind(0), mIndex(-1), mDevice(0), mCharacter(0) {} +#endif private: const HKBManager* mpManager; u8 mKind; @@ -166,6 +176,9 @@ namespace textinput { }; KeySet GetTriggeredKeySet() const; KeySet GetRepeatedKeySet() const; +#ifdef TIHWKEYBOARD_IMPLEMENTATION + KeySet GetReleasedKeySet() const; +#endif void SetForceModifierState(u32 mask, u32 state); #else class KeySet { diff --git a/include/keyboard/tiHwKeyboard.h b/include/keyboard/tiHwKeyboard.h index 5a8d7bec..1bda5121 100644 --- a/include/keyboard/tiHwKeyboard.h +++ b/include/keyboard/tiHwKeyboard.h @@ -25,7 +25,7 @@ namespace textinput { #endif virtual void init(); -#ifdef TI_PC_KEYBOARD_IMPLEMENTATION +#if defined(TI_PC_KEYBOARD_IMPLEMENTATION) || defined(TIHWKEYBOARD_IMPLEMENTATION) wchar_t convertWCCode(wchar_t code) const; #endif @@ -40,6 +40,11 @@ namespace textinput { void resetQuoteState() { mbSingleQuoteClosing = 0; mbDoubleQuoteClosing = 0; } #endif private: +#ifdef TIHWKEYBOARD_IMPLEMENTATION + bool updateRepeatKey_(input::HKBManager&); + bool updateTriggerKey_(input::HKBManager&); + bool updateTappingShift_(input::HKBManager&); +#endif void updateShift(input::HKBManager& hkbManager); void controlKeyTriggeredHandler(input::HKBManager); @@ -50,9 +55,14 @@ namespace textinput { #ifdef TIINPUTFORM_IMPLEMENTATION u8 mbSingleQuoteClosing; u8 mbDoubleQuoteClosing; +#else +#ifdef TIHWKEYBOARD_IMPLEMENTATION + bool field_0x15; + bool field_0x16; #else u8 field_0x15; // 0x15 u8 field_0x16; // 0x16 +#endif #endif }; diff --git a/include/keyboard/tiKeyboard.h b/include/keyboard/tiKeyboard.h index 5b7b10f4..e641e7e4 100644 --- a/include/keyboard/tiKeyboard.h +++ b/include/keyboard/tiKeyboard.h @@ -12,7 +12,7 @@ namespace textinput { KeyboardBase() : meLanguage(JP) {} #endif virtual ~KeyboardBase() {} -#if !defined(TI_PC_KEYBOARD_IMPLEMENTATION) && !defined(TIMANAGER_IMPLEMENTATION) && !defined(TISIGNWINDOW_IMPLEMENTATION) +#if !(defined(TI_PC_KEYBOARD_IMPLEMENTATION) || defined(TIHWKEYBOARD_IMPLEMENTATION)) && !defined(TIMANAGER_IMPLEMENTATION) && !defined(TISIGNWINDOW_IMPLEMENTATION) virtual void create(MEMAllocator* alloc) override; virtual void init() override; virtual void setCommandReceiver(CommandReceiver* receiver) override; @@ -21,18 +21,18 @@ namespace textinput { #if !defined(TIMANAGER_IMPLEMENTATION) && !defined(TISIGNWINDOW_IMPLEMENTATION) virtual void updateFromReceiver(u32, void*) override; #endif -#if defined(MYTIMANAGER_IMPLEMENTATION) || defined(TIINPUTFORM_IMPLEMENTATION) || defined(TI_PC_KEYBOARD_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION) || defined(TISIGNWINDOW_IMPLEMENTATION) +#if defined(MYTIMANAGER_IMPLEMENTATION) || defined(TIINPUTFORM_IMPLEMENTATION) || (defined(TI_PC_KEYBOARD_IMPLEMENTATION) || defined(TIHWKEYBOARD_IMPLEMENTATION)) || defined(TIMANAGER_IMPLEMENTATION) || defined(TISIGNWINDOW_IMPLEMENTATION) virtual void onKey(u32, void*); #else virtual void onKey(u32); #endif -#if defined(TI_PC_KEYBOARD_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION) || defined(TISIGNWINDOW_IMPLEMENTATION) +#if (defined(TI_PC_KEYBOARD_IMPLEMENTATION) || defined(TIHWKEYBOARD_IMPLEMENTATION)) || defined(TIMANAGER_IMPLEMENTATION) || defined(TISIGNWINDOW_IMPLEMENTATION) virtual int getType(); #else virtual void getType(); #endif virtual void setLanguage(Language language); - #if defined(TI_PC_KEYBOARD_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION) || defined(TISIGNWINDOW_IMPLEMENTATION) + #if (defined(TI_PC_KEYBOARD_IMPLEMENTATION) || defined(TIHWKEYBOARD_IMPLEMENTATION)) || defined(TIMANAGER_IMPLEMENTATION) || defined(TISIGNWINDOW_IMPLEMENTATION) #ifdef TISIGNWINDOW_IMPLEMENTATION virtual Language getLanguage() const; #else diff --git a/include/keyboard/tiManager.h b/include/keyboard/tiManager.h index d954067b..5a7bec30 100644 --- a/include/keyboard/tiManager.h +++ b/include/keyboard/tiManager.h @@ -120,6 +120,9 @@ namespace textinput { virtual void start() {} virtual void end() {} +#ifdef TIHWKEYBOARD_IMPLEMENTATION + EventObserver* getEventObserverForHardware() const { return mpEventObserver; } +#endif virtual InputForm* getInputForm() { return mpInputForm; } virtual const InputForm* getInputForm() const { return mpInputForm; } diff --git a/include/keyboard/tiPcKeyboard.h b/include/keyboard/tiPcKeyboard.h index afd6cc68..916d79f3 100644 --- a/include/keyboard/tiPcKeyboard.h +++ b/include/keyboard/tiPcKeyboard.h @@ -1,7 +1,7 @@ #ifndef TEXTINPUT_PC_KEYBOARD_H #define TEXTINPUT_PC_KEYBOARD_H -#if defined(TI_PC_KEYBOARD_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION) || defined(TISIGNWINDOW_IMPLEMENTATION) +#if (defined(TI_PC_KEYBOARD_IMPLEMENTATION) || defined(TIHWKEYBOARD_IMPLEMENTATION)) || defined(TIMANAGER_IMPLEMENTATION) || defined(TISIGNWINDOW_IMPLEMENTATION) #include "tiPcKeyboardImpl.h" #else diff --git a/include/keyboard/tiPcKeyboardImpl.h b/include/keyboard/tiPcKeyboardImpl.h index a4824790..cc8715a6 100644 --- a/include/keyboard/tiPcKeyboardImpl.h +++ b/include/keyboard/tiPcKeyboardImpl.h @@ -226,6 +226,12 @@ namespace textinput { State mState; const LanguageData* mpInitialLanguageData; KeyState mKeyState; +#ifdef TIHWKEYBOARD_IMPLEMENTATION + public: + KeyState& hardwareKeyState() { return mKeyState; } + bool hardwareLanguageKeyActive() const { return mbLanguageKeyActive; } + protected: +#endif MEMAllocator* mpAllocator; bool mbOnlyQwerty; bool mbLanguageKeyActive; diff --git a/include/keyboard/tiTextInputBase.h b/include/keyboard/tiTextInputBase.h index a7bd8b22..3e21198d 100644 --- a/include/keyboard/tiTextInputBase.h +++ b/include/keyboard/tiTextInputBase.h @@ -70,7 +70,7 @@ namespace textinput { INPUT_COMMAND_37 = 37, } INPUT_COMMAND; -#if defined(TI_PC_KEYBOARD_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION) || defined(TISIGNWINDOW_IMPLEMENTATION) +#if (defined(TI_PC_KEYBOARD_IMPLEMENTATION) || defined(TIHWKEYBOARD_IMPLEMENTATION)) || defined(TIMANAGER_IMPLEMENTATION) || defined(TISIGNWINDOW_IMPLEMENTATION) struct ChangePredictMode { u32 mode; bool enabled; }; #endif virtual void clearSender(); @@ -86,7 +86,7 @@ namespace textinput { CommandSender() : mpCommandReceiver(NULL) {} virtual void setCommandReceiver(CommandReceiver* cmdRecv); - #if defined(TI_PC_KEYBOARD_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION) + #if (defined(TI_PC_KEYBOARD_IMPLEMENTATION) || defined(TIHWKEYBOARD_IMPLEMENTATION)) || defined(TIMANAGER_IMPLEMENTATION) virtual void sendCommand(u32 command, void* data) { if (mpCommandReceiver != NULL) mpCommandReceiver->onCommand(static_cast(command), data); } diff --git a/include/keyboard/tiToolBar.h b/include/keyboard/tiToolBar.h index b29f4668..142704a9 100644 --- a/include/keyboard/tiToolBar.h +++ b/include/keyboard/tiToolBar.h @@ -58,8 +58,13 @@ namespace textinput { virtual void setQwertyWithSE(bool qwerty); virtual bool isEnableKeytopChange() const; virtual void enableKeytopChange(bool enable); +#ifdef MYTIMANAGER_MATCHING + virtual nw4r::lyt::Pane* getDownArea(); + virtual nw4r::lyt::Pane* getUpArea(); +#else virtual nw4r::lyt::Pane* getUpArea(); virtual nw4r::lyt::Pane* getDownArea(); +#endif virtual void setOKButtonVisible(bool visible); virtual void setCancelButtonVisible(bool visible); virtual void setOKButtonCaption(const wchar_t* caption); diff --git a/src/keyboard/MyTiManager.cpp b/src/keyboard/MyTiManager.cpp index 2bb03a87..966007ca 100644 --- a/src/keyboard/MyTiManager.cpp +++ b/src/keyboard/MyTiManager.cpp @@ -1,6 +1,6 @@ #define MYTIMANAGER_IMPLEMENTATION +#define MYTIMANAGER_MATCHING #include "keyboard/MyTiManager.h" -#include "keyboard/MyTiBg.h" #include "keyboard/tiLanguageIndependentData.h" #include "keyboard/tiPredictLang.h" #include "keyboard/tiUtil.h" @@ -75,7 +75,7 @@ public: void start(); void end(); -private: +protected: f32 mTime; }; @@ -93,17 +93,25 @@ public: void end(); }; -class DisappearMemoState : public State { +class DisappearMemoState : public AppearMemoState { public: - DisappearMemoState() : mTime(0.0f) {} + DisappearMemoState() {} Manager::StateType getStateType(); void start(); void calc(); -private: - f32 mTime; }; +} +} +} + +#include "keyboard/MyTiBg.h" + +namespace textinput { +namespace extend { +namespace memo { + static DispMemoState sDispMemoState; static EditMemoState sEditMemoState; static AppearMemoState sAppearMemoState; @@ -173,271 +181,8 @@ Manager::~Manager() { setSignWindowForMemo(NULL); } -State::~State() {} - -void DispMemoState::create() {} - -void DispMemoState::init() { - getManager()->getConfigType(); -} - -void DispMemoState::start() { - switch (getManager()->getConfigType()) { - case Manager::CT_Letter: - case Manager::CT_PhotoLetter: - InputForm()->setEditMode(InputForm::EM_Disp); - InputForm()->getLayout()->GetRootPane()->SetTranslate( - nw4r::math::VEC3(sLetterMemoPosition.x, sLetterMemoPosition.y, 0.0f)); - break; - default: - break; - } -} - -void DispMemoState::calc() { - Manager::ConfigType configType = getManager()->getConfigType(); - switch (configType) { - case Manager::CT_Letter: - case Manager::CT_PhotoLetter: - InputForm()->calc(); - break; - default: - break; - } -} - -bool DispMemoState::updateInput(input::HKBManager& hkbManager) { - Manager::ConfigType configType = getManager()->getConfigType(); - switch (configType) { - case Manager::CT_Letter: - case Manager::CT_PhotoLetter: - InputForm(); - return InputForm()->updateInput(hkbManager); - default: - return false; - } -} - -bool DispMemoState::updateInput(int chan, f32 x, f32 y, u32 trig, u32 hold, u32 release) { - Manager::ConfigType configType = getManager()->getConfigType(); - switch (configType) { - case Manager::CT_Letter: - case Manager::CT_PhotoLetter: { - InputForm(); - struct InputParameters { - int chan; - f32 x; - f32 y; - u32 trig; - u32 hold; - u32 release; - } inputParameters = {chan, x, y, trig, hold, release}; - return InputForm()->updateInput(chan, x, y, trig, hold, release, &inputParameters); - } - default: - return false; - } -} - -void AppearMemoState::init() {} - -void AppearMemoState::calc() { - InputForm()->calc(); - if (ToolBar()->isQwerty()) { - PCKeyboard()->calc(); - } else { - static_cast(CellPhoneKeyboard())->calc(); - } - if (CandidateBox()->isActive()) { - CandidateBox()->calc(); - } - ToolBar()->calc(); - static_cast(BG())->calc(); - if (mTime >= 30.0f) { - getManager()->setState(Manager::ST_Appearing); - } - mTime += 1.0f; -} - -void AppearMemoState::draw() { - if (getManager()->getConfigType() != Manager::CT_Letter && - getManager()->getConfigType() != Manager::CT_PhotoLetter) { - static_cast(BG())->draw(); - } - ToolBar()->draw(); - if (getManager()->getConfigType() != Manager::CT_Letter && - getManager()->getConfigType() != Manager::CT_PhotoLetter) { - InputForm()->draw(); - } - if (CandidateBox()->isActive()) { - CandidateBox()->draw(); - } - if (ToolBar()->isQwerty()) { - PCKeyboard()->draw(); - } else { - static_cast(CellPhoneKeyboard())->draw(); - } -} - -void AppearMemoState::start() { - mTime = 0.0f; - Manager::ConfigType configType = getManager()->getConfigType(); - switch (configType) { - case Manager::CT_Letter: - case Manager::CT_PhotoLetter: - InputForm()->setEditMode(InputForm::EM_Appear); - break; - default: - break; - } -} - -bool AppearMemoState::updateInput(int, f32, f32, u32, u32, u32) { - return false; -} - -bool AppearMemoState::updateInput(input::HKBManager&) { - return false; -} - -void EditMemoState::create() {} - -void EditMemoState::init() {} - -void EditMemoState::calc() { - if (ToolBar()->isQwerty()) { - PCKeyboard()->calc(); - } else { - static_cast(CellPhoneKeyboard())->calc(); - } - ToolBar()->calc(); - if (CandidateBox()->isActive()) { - CandidateBox()->calc(); - } - InputForm()->calc(); - if (static_cast(PredictLanguageSelectDialog())->isActive()) { - static_cast(PredictLanguageSelectDialog())->calc(); - } - if (static_cast(SignKeyboard())->isActive()) { - SignWindowLayout& signWindow = *static_cast(SignKeyboard()); - static_cast(signWindow).calc(); - } - if (getManager()->getConfigType() != Manager::CT_Letter && - getManager()->getConfigType() != Manager::CT_PhotoLetter) { - static_cast(BG())->calc(); - } -} - -void EditMemoState::draw() { - GXSetZMode(GX_TRUE, GX_LEQUAL, GX_TRUE); - if (getManager()->getConfigType() != Manager::CT_Letter && - getManager()->getConfigType() != Manager::CT_PhotoLetter) { - static_cast(BG())->draw(); - } - ToolBar()->draw(); - if (getManager()->getConfigType() != Manager::CT_Letter && - getManager()->getConfigType() != Manager::CT_PhotoLetter) { - InputForm()->draw(); - } - if (CandidateBox()->isActive()) { - CandidateBox()->draw(); - } - if (ToolBar()->isQwerty()) { - PCKeyboard()->draw(); - } else { - static_cast(CellPhoneKeyboard())->draw(); - } - if (static_cast(PredictLanguageSelectDialog())->isActive()) { - static_cast(PredictLanguageSelectDialog())->draw(); - } - if (static_cast(SignKeyboard())->isActive()) { - static_cast(SignKeyboard())->draw(); - } -} - -bool EditMemoState::updateInput(input::HKBManager& hkbManager) { - bool wasQwerty = ToolBar()->isQwerty(); - if (static_cast(PredictLanguageSelectDialog())->isActive()) { - return false; - } - HWKeyboard()->updateInput(hkbManager); - if (static_cast(SignKeyboard())->isActive()) { - return static_cast(SignKeyboard())->updateInput(hkbManager); - } - bool handled; - if (wasQwerty) { - handled = PCKeyboard()->updateInput(hkbManager); - } else { - handled = CellPhoneKeyboard()->updateInput(hkbManager); - } - if (wasQwerty != ToolBar()->isQwerty()) { - InputForm()->onCommand(static_cast(6), NULL); - CandidateBox()->checkValidation(); - if (ToolBar()->isQwerty()) { - PCKeyboard()->onActive(); - } else { - CellPhoneKeyboard()->onActive(); - } - } - return handled; -} - -void EditMemoState::start() { - switch (getManager()->getConfigType()) { - case Manager::CT_Letter: - case Manager::CT_PhotoLetter: - InputForm()->setEditMode(InputForm::EM_Edit); - InputForm()->getLayout()->GetRootPane()->SetTranslate( - nw4r::math::VEC3(sLetterMemoPosition.x, sLetterMemoPosition.y, 0.0f)); - break; - default: - break; - } -} - -bool EditMemoState::updateInput(int chan, f32 x, f32 y, u32 trig, u32 hold, u32 release) { - bool wasQwerty = ToolBar()->isQwerty(); - struct InputParameters { - int chan; - f32 x; - f32 y; - u32 trig; - u32 hold; - u32 release; - } inputParameters = {chan, x, y, trig, hold, release}; - HWKeyboard()->updateInput(chan, x, y, trig, hold, release, &inputParameters); - predictlang::LayoutByNW4R* predictDialog = - static_cast(PredictLanguageSelectDialog()); - if (predictDialog->isActive()) { - return predictDialog->updateInput(chan, x, y, trig, hold, release, &inputParameters); - } - bool inputHandled = InputForm()->updateInput(chan, x, y, trig, hold, release, &inputParameters); - if (static_cast(SignKeyboard())->isActive()) { - return static_cast(SignKeyboard())->updateInput( - chan, x, y, trig, hold, release, &inputParameters); - } - bool handled; - if (wasQwerty) { - handled = PCKeyboard()->updateInput(chan, x, y, trig, hold, release, &inputParameters); - } else { - handled = CellPhoneKeyboard()->updateInput(chan, x, y, trig, hold, release, &inputParameters); - } - bool toolbarHandled = ToolBar()->updateInput(chan, x, y, trig, hold, release, &inputParameters); - bool candidateHandled = false; - if (CandidateBox()->isActive()) { - candidateHandled = CandidateBox()->updateInput(chan, x, y, trig, hold, release, &inputParameters); - } - inputHandled = InputForm()->updateInput(chan, x, y, trig, hold, release, &inputParameters) || inputHandled; - if (wasQwerty != ToolBar()->isQwerty()) { - InputForm()->onCommand(static_cast(6), NULL); - CandidateBox()->checkValidation(); - if (ToolBar()->isQwerty()) { - PCKeyboard()->onActive(); - } else { - CellPhoneKeyboard()->onActive(); - } - } - return handled | candidateHandled | inputHandled | toolbarHandled; +inline void setPaneAlpha(nw4r::lyt::Pane* pane, s32 alpha) { + pane->SetAlpha(alpha); } void Manager::create(MEMAllocator*) { @@ -606,153 +351,6 @@ void* Manager::createBG() { "fs_VK_bg_a.brlyt", eventObserver); } -void Manager::start() { - if (meConfigType >= CT_Numeric) return; - if (meConfigType < CT_Letter) return; - static_cast(getInputFormForMemo())->open(); -} - -void Manager::end() { - if (meConfigType >= CT_Numeric) return; - if (meConfigType < CT_Letter) return; - static_cast(getInputFormForMemo())->close(); -} - -InputForm* State::InputForm() { - return static_cast(getManager()->getInputForm()); -} - -f32 InputForm::getScrollFrom() { - return mfScrollFrom; -} - -f32 InputForm::getScrollTo() { - return mfScrollTo; -} - -keyboard::hwkey::HWKeyboard* State::HWKeyboard() { - return getManager()->getHWKeyboard(); -} - -keyboard::pctype::LayoutByNW4R* State::PCKeyboard() { - return getManager()->getPCKeyboard(); -} - -keyboard::cellphonetype::LayoutByNW4R* State::CellPhoneKeyboard() { - return getManager()->getCellPhoneKeyboard(); -} - -void* State::SignKeyboard() { - return getManager()->getSignKeyboard(); -} - -candidatebox::LayoutByNW4R* State::CandidateBox() { - return getManager()->getCandidateBox(); -} - -toolbar::LayoutByNW4R* State::ToolBar() { - return getManager()->getToolBar(); -} - -void* State::PredictLanguageSelectDialog() { - return getManager()->getPredictLanguageSelectDialog(); -} - -void* State::BG() { - return getManager()->getBackGround(); -} - -Manager::StateType DispMemoState::getStateType() { - return Manager::ST_Hidden; -} - -void DispMemoState::draw() {} - -void DispMemoState::memoDraw() { - if (getManager()->getConfigType() == Manager::CT_Letter || - getManager()->getConfigType() == Manager::CT_PhotoLetter) { - InputForm()->draw(); - } -} - -void DispMemoState::end() {} - -Manager::StateType AppearMemoState::getStateType() { - return Manager::ST_Appearing; -} - -void AppearMemoState::memoDraw() { - if (getManager()->getConfigType() == Manager::CT_Letter || - getManager()->getConfigType() == Manager::CT_PhotoLetter) { - InputForm()->draw(); - } -} - -void AppearMemoState::create() {} - -void AppearMemoState::end() {} - -Manager::StateType EditMemoState::getStateType() { - return Manager::ST_Visible; -} - -void EditMemoState::memoDraw() { - if (getManager()->getConfigType() == Manager::CT_Letter || - getManager()->getConfigType() == Manager::CT_PhotoLetter) { - InputForm()->draw(); - } -} - -void EditMemoState::end() {} - -Manager::StateType DisappearMemoState::getStateType() { - return Manager::ST_Disappearing; -} - -void DisappearMemoState::calc() { - if (mTime >= 30.0f) { - getManager()->setState(Manager::ST_Disappearing); - } - InputForm()->calc(); - if (ToolBar()->isQwerty()) { - PCKeyboard()->calc(); - } else { - static_cast(CellPhoneKeyboard())->calc(); - } - ToolBar()->calc(); - if (CandidateBox()->isActive()) { - CandidateBox()->calc(); - } - static_cast(BG())->calc(); - f32 slideX = util::hermiteInterporation( - mTime, 0.0f, 0.0f, 0.0f, 30.0f, sHiddenMemoPosition.x, 0.0f); - nw4r::lyt::Pane* keyboardPane = PCKeyboard()->getLayout()->GetRootPane(); - nw4r::math::VEC3 keyboardPosition = keyboardPane->GetTranslate(); - keyboardPosition.x = slideX; - keyboardPane->SetTranslate(keyboardPosition); - mTime += 1.0f; -} - -void DisappearMemoState::start() { - mTime = 0.0f; - Manager::ConfigType configType = getManager()->getConfigType(); - switch (configType) { - case Manager::CT_Letter: - case Manager::CT_PhotoLetter: - InputForm()->setEditMode(InputForm::EM_Disappear); - getManager()->setSaveData(); - break; - default: - InputForm()->onClose(); - break; - } -} - -void Manager::configNumericBigTextWithDot() { - configNumericWithDot(); - meConfigType = CT_NumericBigTextWithDot; -} - void Manager::configDefault() { meConfigType = CT_Default; setPCKeyboardForMemo(static_cast(mpDefaultPCKeyboard)); @@ -829,7 +427,7 @@ void Manager::configLetter() { reflectSaveData(); limitStringLength(0x100); limitRowNum(0x10); - sLetterMemoPosition.y = 0.0f; + sLetterMemoPosition.y = 145.0f; getInputFormForMemo()->dirtyCacheAll(); } @@ -861,7 +459,7 @@ void Manager::configPhotoLetter() { reflectSaveData(); limitStringLength(0x100); limitRowNum(0x10); - sLetterMemoPosition.y = 0.0f; + sLetterMemoPosition.y = 151.0f; getInputFormForMemo()->dirtyCacheAll(); } @@ -950,6 +548,17 @@ void Manager::configOnlyQwertyBigTextWithoutLineFeedAndSign() { getInputFormForMemo()->dirtyCacheAll(); } +void Manager::configNumericWithDot() { + configNumeric(); + meConfigType = CT_NumericWithDot; + getCellPhoneKeyboardForMemo()->doNumericWithDotMode(true); +} + +void Manager::configNumericBigTextWithDot() { + configNumericWithDot(); + meConfigType = CT_NumericBigTextWithDot; +} + void Manager::configNormalBigTextWithoutLineFeedWithSign() { configDefault(); setInputFormForMemo(mpBigTextInputForm); @@ -987,12 +596,6 @@ void Manager::configNormalWithoutLineFeedWithSign() { getInputFormForMemo()->dirtyCacheAll(); } -void Manager::configNumericWithDot() { - configNumeric(); - meConfigType = CT_NumericWithDot; - getCellPhoneKeyboardForMemo()->doNumericWithDotMode(true); -} - void Manager::configPredictWithoutLineFeed() { configDefault(); meConfigType = CT_PredictWithoutLineFeed; @@ -1007,6 +610,18 @@ void Manager::configPredictBigText() { textinput::Manager::init(); } +void Manager::start() { + if (meConfigType >= CT_Numeric) return; + if (meConfigType < CT_Letter) return; + static_cast(getInputFormForMemo())->open(); +} + +void Manager::end() { + if (meConfigType >= CT_Numeric) return; + if (meConfigType < CT_Letter) return; + static_cast(getInputFormForMemo())->close(); +} + void Manager::setSaveData() { mMemoSetting.uRevisionAndType = getToolBarForMemo()->isQwerty() | 0x10; mMemoSetting.uDictionary = getInputFormForMemo()->getPredictMode(); @@ -1027,15 +642,14 @@ void Manager::setSaveData() { void Manager::reflectSaveData() { s32 revision = (mMemoSetting.uRevisionAndType >> 4) & 0xF; - if (revision >= 1) { - if (revision <= 1) { - reflectSaveDataRev1(); - } else { - reflectSaveDataDefault(); - } - } else { - reflectSaveDataDefault(); + switch (revision) { + case 0: + break; + case 1: + reflectSaveDataRev1(); + return; } + reflectSaveDataDefault(); } void Manager::reflectSaveDataRev1() { @@ -1115,16 +729,516 @@ void Manager::SetFont(nw4r::lyt::FontRefLink* fontLink) { } } -void bg::Base::init() {} +void DispMemoState::create() {} -void bg::Base::create(MEMAllocator*) {} +void DispMemoState::init() { + getManager()->getConfigType(); +} -bg::LayoutByNW4R::~LayoutByNW4R() {} +void DispMemoState::calc() { + Manager::ConfigType configType = getManager()->getConfigType(); + switch (configType) { + case Manager::CT_Letter: + case Manager::CT_PhotoLetter: + InputForm()->calc(); + break; + default: + break; + } +} + +InputForm* State::InputForm() { + return static_cast(getManager()->getInputForm()); +} + +void DispMemoState::draw() {} + +void DispMemoState::memoDraw() { + if (getManager()->getConfigType() == Manager::CT_Letter || + getManager()->getConfigType() == Manager::CT_PhotoLetter) { + InputForm()->draw(); + } +} + +bool DispMemoState::updateInput(int chan, f32 x, f32 y, u32 trig, u32 hold, u32 release) { + Manager::ConfigType configType = getManager()->getConfigType(); + switch (configType) { + case Manager::CT_Letter: + case Manager::CT_PhotoLetter: { + InputForm(); + struct InputParameters { + int chan; + f32 x; + f32 y; + u32 trig; + u32 hold; + u32 release; + } inputParameters = {chan, x, y, trig, hold, release}; + return InputForm()->updateInput(chan, x, y, trig, hold, release, &inputParameters); + } + default: + return false; + } +} + +bool DispMemoState::updateInput(input::HKBManager& hkbManager) { + Manager::ConfigType configType = getManager()->getConfigType(); + switch (configType) { + case Manager::CT_Letter: + case Manager::CT_PhotoLetter: + InputForm(); + return InputForm()->updateInput(hkbManager); + default: + return false; + } +} + +void DispMemoState::start() { + Manager::ConfigType configType = getManager()->getConfigType(); + switch (configType) { + case Manager::CT_Letter: + case Manager::CT_PhotoLetter: + InputForm()->setEditMode(InputForm::EM_Disp); + InputForm()->getLayout()->GetRootPane()->SetTranslate(nw4r::math::VEC2(0.0f, sLetterMemoPosition.x)); + InputForm()->getLayout()->GetRootPane()->SetAlpha(255); + break; + default: + InputForm()->getLayout()->GetRootPane()->SetTranslate(nw4r::math::VEC2(0.0f, sHiddenMemoPosition.x)); + setPaneAlpha(InputForm()->getLayout()->GetRootPane(), static_cast(sAppearingMemoPosition.x)); + break; + } + PCKeyboard()->getLayout()->GetRootPane()->SetTranslate(nw4r::math::VEC2(0.0f, sHiddenMemoPosition.x)); + CellPhoneKeyboard()->getLayout()->GetRootPane()->SetTranslate(nw4r::math::VEC2(0.0f, sHiddenMemoPosition.x)); + CandidateBox()->getLayout()->GetRootPane()->SetTranslate(nw4r::math::VEC2(0.0f, sHiddenMemoPosition.x)); + ToolBar()->getUpArea()->SetTranslate(nw4r::math::VEC2(0.0f, sHiddenMemoPosition.x / 3.0f)); + ToolBar()->getDownArea()->SetTranslate(nw4r::math::VEC2(0.0f, -sHiddenMemoPosition.x / 3.0f)); + static_cast(BG())->getLayout()->GetRootPane()->SetTranslate(nw4r::math::VEC2(0.0f, 0.0f)); + setPaneAlpha(PCKeyboard()->getLayout()->GetRootPane(), static_cast(sAppearingMemoPosition.x)); + setPaneAlpha(CellPhoneKeyboard()->getLayout()->GetRootPane(), static_cast(sAppearingMemoPosition.x)); + setPaneAlpha(CandidateBox()->getLayout()->GetRootPane(), static_cast(sAppearingMemoPosition.x)); + setPaneAlpha(ToolBar()->getUpArea(), static_cast(sAppearingMemoPosition.x)); + setPaneAlpha(ToolBar()->getDownArea(), static_cast(sAppearingMemoPosition.x)); + setPaneAlpha(static_cast(BG())->getLayout()->GetRootPane(), static_cast(sAppearingMemoPosition.x)); +} + +keyboard::pctype::LayoutByNW4R* State::PCKeyboard() { + return getManager()->getPCKeyboard(); +} + +keyboard::cellphonetype::LayoutByNW4R* State::CellPhoneKeyboard() { + return getManager()->getCellPhoneKeyboard(); +} + +candidatebox::LayoutByNW4R* State::CandidateBox() { + return getManager()->getCandidateBox(); +} + +toolbar::LayoutByNW4R* State::ToolBar() { + return getManager()->getToolBar(); +} + +void* State::BG() { + return getManager()->getBackGround(); +} + +void AppearMemoState::create() {} + +void AppearMemoState::init() {} + +void AppearMemoState::calc() { + InputForm()->calc(); + if (ToolBar()->isQwerty()) { + PCKeyboard()->calc(); + } else { + static_cast(CellPhoneKeyboard())->calc(); + } + if (CandidateBox()->isActive()) { + CandidateBox()->calc(); + } + ToolBar()->calc(); + static_cast(BG())->calc(); + if (30.0f <= mTime) { + getManager()->changeState(Manager::STL_Transition); + } + + f32 offset = textinput::util::hermiteInterporation( + mTime, 0.0f, sHiddenMemoPosition.x, 0.0f, + 30.0f, sHiddenMemoPosition.y, 0.0f); + PCKeyboard()->getLayout()->GetRootPane()->SetTranslate(nw4r::math::VEC2(0.0f, offset)); + CellPhoneKeyboard()->getLayout()->GetRootPane()->SetTranslate(nw4r::math::VEC2(0.0f, offset)); + CandidateBox()->getLayout()->GetRootPane()->SetTranslate(nw4r::math::VEC2(0.0f, offset)); + ToolBar()->getUpArea()->SetTranslate( + nw4r::math::VEC2(0.0f, offset / 3.0f)); + ToolBar()->getDownArea()->SetTranslate( + nw4r::math::VEC2(0.0f, -offset / 3.0f)); + static_cast(BG())->getLayout()->GetRootPane()->SetTranslate(nw4r::math::VEC2(0.0f, 0.0f)); + + f32 alpha = textinput::util::hermiteInterporation( + mTime, 0.0f, sAppearingMemoPosition.x, 0.0f, + 30.0f, sAppearingMemoPosition.y, 0.0f); + s32 alphaByte = static_cast(alpha); + setPaneAlpha(PCKeyboard()->getLayout()->GetRootPane(), alphaByte); + setPaneAlpha(CellPhoneKeyboard()->getLayout()->GetRootPane(), alphaByte); + setPaneAlpha(CandidateBox()->getLayout()->GetRootPane(), alphaByte); + setPaneAlpha(ToolBar()->getUpArea(), alphaByte); + setPaneAlpha(static_cast(BG())->getLayout()->GetRootPane(), alphaByte); + + Manager::ConfigType configType = getManager()->getConfigType(); + switch (configType) { + case Manager::CT_Letter: + case Manager::CT_PhotoLetter: { + f32 letterOffset = textinput::util::hermiteInterporation( + mTime, 0.0f, sLetterMemoPosition.x, 0.0f, + 30.0f, sLetterMemoPosition.y, 0.0f); + InputForm()->getLayout()->GetRootPane()->SetTranslate( + nw4r::math::VEC2(0.0f, letterOffset)); + setPaneAlpha(InputForm()->getLayout()->GetRootPane(), 0xff); + MemoInputForm* inputForm = InputForm(); + inputForm->setScroll(textinput::util::hermiteInterporation( + mTime, 0.0f, inputForm->getScrollFrom(), 0.0f, + 30.0f, inputForm->getScrollTo(), 0.0f)); + break; + } + default: { + InputForm()->getLayout()->GetRootPane()->SetTranslate( + nw4r::math::VEC2(0.0f, offset)); + setPaneAlpha(InputForm()->getLayout()->GetRootPane(), alphaByte); + } + } + mTime += 1.0f; +} + +f32 InputForm::getScrollFrom() { + return mfScrollFrom; +} + +f32 InputForm::getScrollTo() { + return mfScrollTo; +} + +void AppearMemoState::draw() { + if (getManager()->getConfigType() != Manager::CT_Letter && + getManager()->getConfigType() != Manager::CT_PhotoLetter) { + static_cast(BG())->draw(); + } + ToolBar()->draw(); + if (getManager()->getConfigType() != Manager::CT_Letter && + getManager()->getConfigType() != Manager::CT_PhotoLetter) { + InputForm()->draw(); + } + if (CandidateBox()->isActive()) { + CandidateBox()->draw(); + } + if (ToolBar()->isQwerty()) { + PCKeyboard()->draw(); + } else { + static_cast(CellPhoneKeyboard())->draw(); + } +} void bg::LayoutByNW4R::draw() { nw4rmanager::Layout::draw(); } +void AppearMemoState::memoDraw() { + if (getManager()->getConfigType() == Manager::CT_Letter || + getManager()->getConfigType() == Manager::CT_PhotoLetter) { + InputForm()->draw(); + } +} + +bool AppearMemoState::updateInput(int, f32, f32, u32, u32, u32) { + return false; +} + +bool AppearMemoState::updateInput(input::HKBManager&) { + return false; +} + +void AppearMemoState::start() { + mTime = 0.0f; + Manager::ConfigType configType = getManager()->getConfigType(); + switch (configType) { + case Manager::CT_Letter: + case Manager::CT_PhotoLetter: + InputForm()->setEditMode(InputForm::EM_Appear); + break; + default: + break; + } +} + +void EditMemoState::create() {} + +void EditMemoState::init() {} + +void EditMemoState::calc() { + if (ToolBar()->isQwerty()) { + PCKeyboard()->calc(); + } else { + static_cast(CellPhoneKeyboard())->calc(); + } + ToolBar()->calc(); + if (CandidateBox()->isActive()) { + CandidateBox()->calc(); + } + InputForm()->calc(); + if (static_cast(PredictLanguageSelectDialog())->isActive()) { + static_cast(PredictLanguageSelectDialog())->calc(); + } + if (static_cast(SignKeyboard())->isActive()) { + SignWindowLayout& signWindow = *static_cast(SignKeyboard()); + static_cast(signWindow).calc(); + } + if (getManager()->getConfigType() != Manager::CT_Letter && + getManager()->getConfigType() != Manager::CT_PhotoLetter) { + static_cast(BG())->calc(); + } +} + +void* State::PredictLanguageSelectDialog() { + return getManager()->getPredictLanguageSelectDialog(); +} + +void* State::SignKeyboard() { + return getManager()->getSignKeyboard(); +} + +void EditMemoState::draw() { + GXSetZMode(GX_TRUE, GX_LEQUAL, GX_TRUE); + if (getManager()->getConfigType() != Manager::CT_Letter && + getManager()->getConfigType() != Manager::CT_PhotoLetter) { + static_cast(BG())->draw(); + } + ToolBar()->draw(); + if (getManager()->getConfigType() != Manager::CT_Letter && + getManager()->getConfigType() != Manager::CT_PhotoLetter) { + InputForm()->draw(); + } + if (CandidateBox()->isActive()) { + CandidateBox()->draw(); + } + if (ToolBar()->isQwerty()) { + PCKeyboard()->draw(); + } else { + static_cast(CellPhoneKeyboard())->draw(); + } + if (static_cast(PredictLanguageSelectDialog())->isActive()) { + static_cast(PredictLanguageSelectDialog())->draw(); + } + if (static_cast(SignKeyboard())->isActive()) { + static_cast(SignKeyboard())->draw(); + } +} + +void EditMemoState::memoDraw() { + if (getManager()->getConfigType() == Manager::CT_Letter || + getManager()->getConfigType() == Manager::CT_PhotoLetter) { + InputForm()->draw(); + } +} + +bool EditMemoState::updateInput(int chan, f32 x, f32 y, u32 trig, u32 hold, u32 release) { + bool wasQwerty = ToolBar()->isQwerty(); + struct InputParameters { + int chan; + f32 x; + f32 y; + u32 trig; + u32 hold; + u32 release; + } inputParameters = {chan, x, y, trig, hold, release}; + HWKeyboard()->updateInput(chan, x, y, trig, hold, release, &inputParameters); + if (static_cast(PredictLanguageSelectDialog())->isActive()) { + return static_cast(PredictLanguageSelectDialog())->updateInput(chan, x, y, trig, hold, release, &inputParameters); + } + InputForm()->updateInputCommon(chan, trig, hold, release, &inputParameters); + if (static_cast(SignKeyboard())->isActive()) { + return static_cast(SignKeyboard())->updateInput( + chan, x, y, trig, hold, release, &inputParameters); + } + bool handled; + if (wasQwerty) { + handled = PCKeyboard()->updateInput(chan, x, y, trig, hold, release, &inputParameters); + } else { + handled = CellPhoneKeyboard()->updateInput(chan, x, y, trig, hold, release, &inputParameters); + } + bool toolbarHandled = ToolBar()->updateInput(chan, x, y, trig, hold, release, &inputParameters); + bool candidateHandled = false; + if (CandidateBox()->isActive()) { + candidateHandled = CandidateBox()->updateInput(chan, x, y, trig, hold, release, &inputParameters); + } + u32 inputHandled = 0; + if (!candidateHandled) { + inputHandled = InputForm()->updateInput(chan, x, y, trig, hold, release, &inputParameters); + } else { + InputForm()->updateInput(chan, (1.0f / 0.0f), (1.0f / 0.0f), trig, hold, release, &inputParameters); + } + handled = (handled | candidateHandled) | (inputHandled | toolbarHandled); + if (wasQwerty != ToolBar()->isQwerty()) { + InputForm()->onCommand(static_cast(6), NULL); + CandidateBox()->checkValidation(); + if (ToolBar()->isQwerty()) { + PCKeyboard()->onActive(); + } else { + CellPhoneKeyboard()->onActive(); + } + } + return handled; +} + +keyboard::hwkey::HWKeyboard* State::HWKeyboard() { + return getManager()->getHWKeyboard(); +} + +bool EditMemoState::updateInput(input::HKBManager& hkbManager) { + bool wasQwerty = ToolBar()->isQwerty(); + if (static_cast(PredictLanguageSelectDialog())->isActive()) { + return false; + } + HWKeyboard()->updateInput(hkbManager); + if (static_cast(SignKeyboard())->isActive()) { + return static_cast(SignKeyboard())->updateInput(hkbManager); + } + bool handled; + if (wasQwerty) { + handled = PCKeyboard()->updateInput(hkbManager); + } else { + handled = CellPhoneKeyboard()->updateInput(hkbManager); + } + if (wasQwerty != ToolBar()->isQwerty()) { + InputForm()->onCommand(static_cast(6), NULL); + CandidateBox()->checkValidation(); + if (ToolBar()->isQwerty()) { + PCKeyboard()->onActive(); + } else { + CellPhoneKeyboard()->onActive(); + } + } + return handled; +} + +void EditMemoState::start() { + if (getManager()->getConfigType() == Manager::CT_Letter || + getManager()->getConfigType() == Manager::CT_PhotoLetter) { + InputForm()->setEditMode(InputForm::EM_Edit); + InputForm()->getLayout()->GetRootPane()->SetTranslate(nw4r::math::VEC2(0.0f, sLetterMemoPosition.y)); + InputForm()->getLayout()->GetRootPane()->SetAlpha(255); + } else { + InputForm()->getLayout()->GetRootPane()->SetTranslate(nw4r::math::VEC2(0.0f, sHiddenMemoPosition.y)); + setPaneAlpha(InputForm()->getLayout()->GetRootPane(), static_cast(sAppearingMemoPosition.y)); + } + PCKeyboard()->getLayout()->GetRootPane()->SetTranslate(nw4r::math::VEC2(0.0f, sHiddenMemoPosition.y)); + CellPhoneKeyboard()->getLayout()->GetRootPane()->SetTranslate(nw4r::math::VEC2(0.0f, sHiddenMemoPosition.y)); + CandidateBox()->getLayout()->GetRootPane()->SetTranslate(nw4r::math::VEC2(0.0f, sHiddenMemoPosition.y)); + ToolBar()->getUpArea()->SetTranslate(nw4r::math::VEC2(0.0f, sHiddenMemoPosition.y / 3.0f)); + ToolBar()->getDownArea()->SetTranslate(nw4r::math::VEC2(0.0f, -sHiddenMemoPosition.y / 3.0f)); + static_cast(BG())->getLayout()->GetRootPane()->SetTranslate(nw4r::math::VEC2(0.0f, 0.0f)); + setPaneAlpha(PCKeyboard()->getLayout()->GetRootPane(), static_cast(sAppearingMemoPosition.y)); + setPaneAlpha(CellPhoneKeyboard()->getLayout()->GetRootPane(), static_cast(sAppearingMemoPosition.y)); + setPaneAlpha(CandidateBox()->getLayout()->GetRootPane(), static_cast(sAppearingMemoPosition.y)); + setPaneAlpha(ToolBar()->getUpArea(), static_cast(sAppearingMemoPosition.y)); + setPaneAlpha(ToolBar()->getDownArea(), static_cast(sAppearingMemoPosition.y)); + setPaneAlpha(static_cast(BG())->getLayout()->GetRootPane(), static_cast(sAppearingMemoPosition.y)); + PCKeyboard()->onActive(); + CellPhoneKeyboard()->onActive(); + if (ToolBar()->isQwerty()) PCKeyboard()->onActive(); + else CellPhoneKeyboard()->onActive(); +} + +void DisappearMemoState::calc() { + if (30.0f <= mTime) { + getManager()->changeState(Manager::STL_Transition); + } + InputForm()->calc(); + + f32 offset = textinput::util::hermiteInterporation( + mTime, 0.0f, sHiddenMemoPosition.y, 0.0f, + 30.0f, sHiddenMemoPosition.x, 0.0f); + PCKeyboard()->getLayout()->GetRootPane()->SetTranslate(nw4r::math::VEC2(0.0f, offset)); + CellPhoneKeyboard()->getLayout()->GetRootPane()->SetTranslate(nw4r::math::VEC2(0.0f, offset)); + CandidateBox()->getLayout()->GetRootPane()->SetTranslate(nw4r::math::VEC2(0.0f, offset)); + ToolBar()->getUpArea()->SetTranslate( + nw4r::math::VEC2(0.0f, offset / 3.0f)); + ToolBar()->getDownArea()->SetTranslate( + nw4r::math::VEC2(0.0f, -offset / 3.0f)); + static_cast(BG())->getLayout()->GetRootPane()->SetTranslate(nw4r::math::VEC2(0.0f, 0.0f)); + + f32 alpha = textinput::util::hermiteInterporation( + mTime, 0.0f, sAppearingMemoPosition.y, 0.0f, + 30.0f, sAppearingMemoPosition.x, 0.0f); + s32 alphaByte = static_cast(alpha); + setPaneAlpha(PCKeyboard()->getLayout()->GetRootPane(), alphaByte); + setPaneAlpha(CellPhoneKeyboard()->getLayout()->GetRootPane(), alphaByte); + setPaneAlpha(CandidateBox()->getLayout()->GetRootPane(), alphaByte); + setPaneAlpha(ToolBar()->getUpArea(), alphaByte); + setPaneAlpha(ToolBar()->getDownArea(), alphaByte); + setPaneAlpha(static_cast(BG())->getLayout()->GetRootPane(), alphaByte); + + Manager::ConfigType configType = getManager()->getConfigType(); + switch (configType) { + case Manager::CT_Letter: + case Manager::CT_PhotoLetter: { + f32 letterOffset = textinput::util::hermiteInterporation( + mTime, 0.0f, sLetterMemoPosition.y, 0.0f, + 30.0f, sLetterMemoPosition.x, 0.0f); + InputForm()->getLayout()->GetRootPane()->SetTranslate( + nw4r::math::VEC2(0.0f, letterOffset)); + setPaneAlpha(InputForm()->getLayout()->GetRootPane(), 0xff); + break; + } + default: { + InputForm()->getLayout()->GetRootPane()->SetTranslate( + nw4r::math::VEC2(0.0f, offset)); + setPaneAlpha(InputForm()->getLayout()->GetRootPane(), alphaByte); + } + } + mTime += 1.0f; +} + +void DisappearMemoState::start() { + mTime = 0.0f; + Manager::ConfigType configType = getManager()->getConfigType(); + switch (configType) { + case Manager::CT_Letter: + case Manager::CT_PhotoLetter: + InputForm()->setEditMode(InputForm::EM_Disappear); + getManager()->setSaveData(); + break; + default: + InputForm()->onClose(); + break; + } +} + +void bg::Base::init() {} + +void bg::Base::create(MEMAllocator*) {} + +void AppearMemoState::end() {} + +Manager::StateType DisappearMemoState::getStateType() { + return Manager::ST_Disappearing; +} + +void EditMemoState::end() {} + +Manager::StateType EditMemoState::getStateType() { + return Manager::ST_Visible; +} + +inline State::~State() {} + +Manager::StateType AppearMemoState::getStateType() { + return Manager::ST_Appearing; +} + +void DispMemoState::end() {} + +Manager::StateType DispMemoState::getStateType() { + return Manager::ST_Hidden; +} + } } } diff --git a/src/keyboard/tiCandidateBox.cpp b/src/keyboard/tiCandidateBox.cpp index 6b9e17b3..623f8cd8 100644 --- a/src/keyboard/tiCandidateBox.cpp +++ b/src/keyboard/tiCandidateBox.cpp @@ -44,6 +44,8 @@ namespace textinput { }; // name made up, no dwarf (?) + inline const char* commonScrollAnimationName() { return COMMON_SCROLL_ANIM; } + inline const char* commonTextAnimationName() { return COMMON_TEXT_ANIM; } struct PaneToAnimation { s32 type; char paneName[20]; @@ -85,7 +87,7 @@ namespace textinput { {KT_ScrollButton, "P_prdc_scrl_Rght", 7, - COMMON_SCROLL_ANIM, + commonScrollAnimationName(), {&csAninationFile[0], &csAninationFile[1], &csAninationFile[2], &csAninationFile[3], &csAninationFile[4], &csAninationFile[5], &csAninationFile[6]}}, {KT_CandidateText, @@ -96,97 +98,97 @@ namespace textinput { {KT_CandidateText, "T_prdc_Text_01", 5, - COMMON_TEXT_ANIM, + commonTextAnimationName(), {&csAninationFile[0], &csAninationFile[1], &csAninationFile[2], &csAninationFile[3], &csAninationFile[6]}}, {KT_CandidateText, "T_prdc_Text_02", 5, - COMMON_TEXT_ANIM, + commonTextAnimationName(), {&csAninationFile[0], &csAninationFile[1], &csAninationFile[2], &csAninationFile[3], &csAninationFile[6]}}, {KT_CandidateText, "T_prdc_Text_03", 5, - COMMON_TEXT_ANIM, + commonTextAnimationName(), {&csAninationFile[0], &csAninationFile[1], &csAninationFile[2], &csAninationFile[3], &csAninationFile[6]}}, {KT_CandidateText, "T_prdc_Text_04", 5, - COMMON_TEXT_ANIM, + commonTextAnimationName(), {&csAninationFile[0], &csAninationFile[1], &csAninationFile[2], &csAninationFile[3], &csAninationFile[6]}}, {KT_CandidateText, "T_prdc_Text_05", 5, - COMMON_TEXT_ANIM, + commonTextAnimationName(), {&csAninationFile[0], &csAninationFile[1], &csAninationFile[2], &csAninationFile[3], &csAninationFile[6]}}, {KT_CandidateText, "T_prdc_Text_06", 5, - COMMON_TEXT_ANIM, + commonTextAnimationName(), {&csAninationFile[0], &csAninationFile[1], &csAninationFile[2], &csAninationFile[3], &csAninationFile[6]}}, {KT_CandidateText, "T_prdc_Text_07", 5, - COMMON_TEXT_ANIM, + commonTextAnimationName(), {&csAninationFile[0], &csAninationFile[1], &csAninationFile[2], &csAninationFile[3], &csAninationFile[6]}}, {KT_CandidateText, "T_prdc_Text_08", 5, - COMMON_TEXT_ANIM, + commonTextAnimationName(), {&csAninationFile[0], &csAninationFile[1], &csAninationFile[2], &csAninationFile[3], &csAninationFile[6]}}, {KT_CandidateText, "T_prdc_Text_09", 5, - COMMON_TEXT_ANIM, + commonTextAnimationName(), {&csAninationFile[0], &csAninationFile[1], &csAninationFile[2], &csAninationFile[3], &csAninationFile[6]}}, {KT_CandidateText, "T_prdc_Text_10", 5, - COMMON_TEXT_ANIM, + commonTextAnimationName(), {&csAninationFile[0], &csAninationFile[1], &csAninationFile[2], &csAninationFile[3], &csAninationFile[6]}}, {KT_CandidateText, "T_prdc_Text_11", 5, - COMMON_TEXT_ANIM, + commonTextAnimationName(), {&csAninationFile[0], &csAninationFile[1], &csAninationFile[2], &csAninationFile[3], &csAninationFile[6]}}, {KT_CandidateText, "T_prdc_Text_12", 5, - COMMON_TEXT_ANIM, + commonTextAnimationName(), {&csAninationFile[0], &csAninationFile[1], &csAninationFile[2], &csAninationFile[3], &csAninationFile[6]}}, {KT_CandidateText, "T_prdc_Text_13", 5, - COMMON_TEXT_ANIM, + commonTextAnimationName(), {&csAninationFile[0], &csAninationFile[1], &csAninationFile[2], &csAninationFile[3], &csAninationFile[6]}}, {KT_CandidateText, "T_prdc_Text_14", 5, - COMMON_TEXT_ANIM, + commonTextAnimationName(), {&csAninationFile[0], &csAninationFile[1], &csAninationFile[2], &csAninationFile[3], &csAninationFile[6]}}, {KT_CandidateText, "T_prdc_Text_15", 5, - COMMON_TEXT_ANIM, + commonTextAnimationName(), {&csAninationFile[0], &csAninationFile[1], &csAninationFile[2], &csAninationFile[3], &csAninationFile[6]}}, {KT_CandidateText, "T_prdc_Text_16", 5, - COMMON_TEXT_ANIM, + commonTextAnimationName(), {&csAninationFile[0], &csAninationFile[1], &csAninationFile[2], &csAninationFile[3], &csAninationFile[6]}}, {KT_CandidateText, "T_prdc_Text_17", 5, - COMMON_TEXT_ANIM, + commonTextAnimationName(), {&csAninationFile[0], &csAninationFile[1], &csAninationFile[2], &csAninationFile[3], &csAninationFile[6]}}, {KT_CandidateText, "T_prdc_Text_18", 5, - COMMON_TEXT_ANIM, + commonTextAnimationName(), {&csAninationFile[0], &csAninationFile[1], &csAninationFile[2], &csAninationFile[3], &csAninationFile[6]}}, {KT_CandidateText, "T_prdc_Text_19", 5, - COMMON_TEXT_ANIM, + commonTextAnimationName(), {&csAninationFile[0], &csAninationFile[1], &csAninationFile[2], &csAninationFile[3], &csAninationFile[6]}}, {KT_OnOffButton, "P_OnBtn", diff --git a/src/keyboard/tiHwKeyboard.cpp b/src/keyboard/tiHwKeyboard.cpp index 6fa8860c..0cac3b1a 100644 --- a/src/keyboard/tiHwKeyboard.cpp +++ b/src/keyboard/tiHwKeyboard.cpp @@ -1,3 +1,4 @@ +#define TIHWKEYBOARD_IMPLEMENTATION #include "keyboard/tiHwKeyboard.h" #include "keyboard/tiManager.h" @@ -247,6 +248,349 @@ namespace textinput { blr } +struct NavigationCommand { u32 command; u32 modifiers; }; +struct KeyInputData { + wchar_t character; + u16 flags; + u32 modifier; + u8 direct; + u8 repeated; + u16 reserved; + u32 data; +}; +extern const u8 controlKeys[]; + bool HWKeyboard::updateRepeatKey_(input::HKBManager& hkbManager) { + u32 modifierState = hkbManager.GetModifierState(); + input::HKBManager::KeySet currentKeySet; + currentKeySet = hkbManager.GetRepeatedKeySet(); + + if (!currentKeySet.IsValid()) { + return false; + } + + if (!mgr()->getToolBar()->isQwerty()) { + if (mgr()->getToolBar()->isEnableKeytopChange()) { + return true; + } + } + + u32 modifierFlag = modifierState & 0x8; + + while (currentKeySet.IsValid()) { + int key = currentKeySet.GetKey(); + u32 command; + + if (key == 0x4c) { + goto sendCommand2; + } + + if (key < 0x4c) { + if (key != 0x2b) { + if (key < 0x2b) { + if (key >= 0x2a) { + goto sendCommand1; + } + } else { + if (key >= 0x2d) { + goto nextRepeatedKey; + } + goto checkSpecialCommand; + } + } + goto nextRepeatedKey; + } + + if (key == 0x51) { + goto setNavigationCommand1e; + } + + if (key < 0x51) { + if (key == 0x4f) { + goto setNavigationCommand20; + } else if (key >= 0x4f) { + goto setNavigationCommand1f; + } + } else { + if (key >= 0x53) { + goto nextRepeatedKey; + } + goto setNavigationCommand1d; + } + + goto nextRepeatedKey; + + sendCommand2: + sendCommand(2, NULL); + goto nextRepeatedKey; + + sendCommand1: + sendCommand(1, NULL); + goto nextRepeatedKey; + + setNavigationCommand20: + command = 0x20; + goto sendNavigationCommand; + + setNavigationCommand1f: + command = 0x1f; + goto sendNavigationCommand; + + setNavigationCommand1e: + command = 0x1e; + goto sendNavigationCommand; + + setNavigationCommand1d: + command = 0x1d; + + sendNavigationCommand: + { + u32 commandData[2]; + commandData[0] = command; + commandData[1] = modifierState; + sendCommand(0x26, commandData); + } + goto nextRepeatedKey; + + checkSpecialCommand: + if (mgr()->getToolBar()->isQwerty() || + !mgr()->getCellPhoneKeyboard()->isNumeric()) { + if (modifierFlag == 0) { + goto sendSpecialCommand; + } + } + goto nextRepeatedKey; + + sendSpecialCommand: + { + NavigationCommand commandData = {8, modifierState}; + sendCommand(0x26, &commandData); + } + + nextRepeatedKey: + + currentKeySet = currentKeySet.GetNext(); + } + + return false; + } + + bool HWKeyboard::updateTriggerKey_(input::HKBManager& hkbManager) { + u32 modifierState = hkbManager.GetModifierState(); + input::HKBManager::KeySet currentKeySet; + currentKeySet = hkbManager.GetTriggeredKeySet(); + + if (!currentKeySet.IsValid()) { + return false; + } + + if (!mgr()->getToolBar()->isQwerty() && + mgr()->getToolBar()->isEnableKeytopChange()) { + return true; + } + + if (!mgr()->getPCKeyboard()->isABC()) { + if (mgr()->getToolBar()->isQwerty()) { + EventObserver* eventObserver = mgr()->getEventObserverForHardware(); + if (eventObserver != NULL) { + eventObserver->onSE(sound::SE_KETAI_MODE_SWITCHING); + } + } + mgr()->getPCKeyboard()->setABC(true); + } + + while (currentKeySet.IsValid()) { + u32 character = currentKeySet.GetWChar(); + u8 key = currentKeySet.GetKey(); + + if (static_cast(character) == 0x20) { + if ((modifierState & 0x8) != 0) { + NavigationCommand commandData = {8, modifierState}; + sendCommand(0x26, &commandData); + } + } else if (static_cast(character) != 0) { + bool sendCharacter = true; + if (!mgr()->getToolBar()->isQwerty() && + mgr()->getCellPhoneKeyboard()->isNumeric()) { + if (static_cast(character) == '/') { + goto suppressCharacter; + } + if (static_cast(character) < '/') { + if (static_cast(character) >= '.') { + goto checkNumericDot; + } + goto suppressCharacter; + } + if (static_cast(character) >= ':') { + goto suppressCharacter; + } + goto sendCharacterCheck; + checkNumericDot: + if (mgr()->getCellPhoneKeyboard()->isNumericWithDot()) { + goto sendCharacterCheck; + } + suppressCharacter: + sendCharacter = false; + } + + goto sendCharacterCheck; + sendCharacterCheck: + if (sendCharacter) { + modifierState = 0; + if ((hkbManager.GetModifierState() & 0x2) != 0) { + modifierState |= 1; + } + if ((hkbManager.GetModifierState() & 0x200) != 0) { + modifierState |= 2; + } + if ((modifierState & 1) == 0) { + keyboard::pctype::Base::KeyState& keyState = mgr()->getPCKeyboard()->hardwareKeyState(); + keyState.setABCFlag(keyState.abcFlags & 0xffffff70); + } + + character = convertWCCode(character); + KeyInputData keyInputData = {0, 0, 0, 1, 0, 0, 0}; + keyInputData.character = character; + keyInputData.modifier = modifierState; + sendCommand(0, &keyInputData); + + if (mgr()->getLanguage() == CN) { + if (static_cast(character + (0x10000 - 0x201c)) <= 1) { + field_0x16 = !field_0x16; + } else if (static_cast(character + (0x10000 - 0x2018)) <= 1) { + field_0x15 = !field_0x15; + } + + } + } + } else { + bool sendKey = true; + int translatedKey; + if (key < 0x20) { + translatedKey = 0; + } else if (key < 0x98) { + translatedKey = controlKeys[key - 0x20]; + } else if (key < 0xe0) { + translatedKey = 0; + } else if (key < 0xf0) { + translatedKey = controlKeys[key - 0x68]; + } else { + translatedKey = 0; + } + + if (translatedKey == 0x1c) { + bool capsLock = !(hkbManager.GetModifierState() & 0x100); + if (!mgr()->getToolBar()->isQwerty() && + mgr()->getCellPhoneKeyboard()->isNumeric()) { + capsLock = true; + } + hkbManager.SetModifierState(capsLock ? 0x100 : 0, 0x100); + } + + if (mgr()->getToolBar()->isQwerty() || + !mgr()->getCellPhoneKeyboard()->isNumeric()) { + goto sendKeyCheck; + } + + switch (translatedKey) { + case 0x15: + case 0x16: + case 0x1d: + case 0x1e: + case 0x1f: + case 0x20: + break; + default: + sendKey = false; + break; + } + sendKeyCheck: + if (sendKey) { + u32 commandData[2] = {translatedKey, modifierState}; + sendCommand(0x26, commandData); + } + } + + int capsKey = currentKeySet.GetKey(); + switch (capsKey) { + case 0x39: + if (mgr()->getToolBar()->isQwerty() || + mgr()->getToolBar()->isEnableKeytopChange()) { + mgr()->getPCKeyboard()->onPressedCaps(); + } + break; + default: + break; + } + + currentKeySet = currentKeySet.GetNext(); + } + + return false; + } + +const u8 controlKeys[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x01, 0x0a, 0x03, + 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, + 0x00, 0x04, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, + 0x2b, 0x2c, 0x19, 0x1a, 0x1b, 0x13, 0x15, 0x17, 0x14, 0x16, 0x18, 0x00, + 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x0f, 0x0e, + 0x00, 0x00, 0x00, 0x00, + 0x11, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x05, 0x07, 0x0b, + 0x06, 0x05, 0x07, 0x0b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +}; + bool HWKeyboard::updateTappingShift_(input::HKBManager& hkbManager) { + hkbManager.GetModifierState(); + input::HKBManager::KeySet currentKeySet; + input::HKBManager::KeySet triggeredKeySet; + input::HKBManager::KeySet releasedKeySet; + input::HKBManager::KeySet releasedNextKeySet; + triggeredKeySet = hkbManager.GetTriggeredKeySet(); + currentKeySet = triggeredKeySet; + + while (currentKeySet.IsValid()) { + int key = currentKeySet.GetKey(); + switch (key) { + case 0xe5: + case 0xe1: + field_0x14 = 1; + return false; + default: + field_0x14 = 0; + currentKeySet = currentKeySet.GetNext(); + break; + } + } + + if (field_0x14 == 0) { + return false; + } + + releasedKeySet = hkbManager.GetReleasedKeySet(); + currentKeySet = releasedKeySet; + while (currentKeySet.IsValid()) { + int key = currentKeySet.GetKey(); + switch (key) { + case 0xe5: + case 0xe1: + field_0x14 = 0; + if (mgr()->getToolBar()->isQwerty() && + mgr()->getPCKeyboard()->hardwareLanguageKeyActive()) { + sendCommand(0x2e, NULL); + } + return false; + default: + currentKeySet = currentKeySet.GetNext(); + break; + } + } + + return false; + } + HWKeyboard::HWKeyboard(Manager* manager) : mpManager(manager), field_0x14(0), field_0x15(0), field_0x16(0) { } @@ -474,3 +818,4 @@ namespace textinput { } // namespace keyboard } // namespace textinput + diff --git a/tools/decomp-assist/MyTiManager.attempts.md b/tools/decomp-assist/MyTiManager.attempts.md new file mode 100644 index 00000000..0b7e5177 --- /dev/null +++ b/tools/decomp-assist/MyTiManager.attempts.md @@ -0,0 +1,89 @@ +# MyTiManager matching attempts + +Baseline: 84/91 instruction-exact functions, 12748/20196 code bytes, +20/1132 reported data bytes. Existing pool was identical. + +## reflectSaveData + +1. Branch directly on revision one: six instructions versus eight. +2. Switch with revision one and a default call: seven versus eight. +3. Separate revision-zero/default calls: eleven versus eight. +4. Revision-zero break followed by the shared default call: eight/eight, + zero instruction differences. + +## DispMemoState::start + +1. Reconstructed pane translations and alpha assignments using VEC3 and + byte conversion: 321/326 instructions. +2. VEC2 translations and an integer alpha helper: 325/326. +3. Corrected toolbar pane accessor order under the private header guard, + and used the configuration switch: 326/326, zero differences. + +## EditMemoState::start + +1. Full initialization with VEC3 and direct byte conversion: 381/385. +2. VEC2 and integer alpha helper: 385/385, four accessor-slot differences. +3. Corrected the toolbar accessor declarations in the private guard: + 385/385, zero differences. + +## AppearMemoState::calc + +1. Reconstructed interpolation, pane movement, alpha and scrolling: + 437/428. Background movement, toolbar alpha and configuration branches + differed from the target. +2. Kept the background stationary, used the configuration switch and removed + the extra toolbar alpha assignment: 428/428, one accessor-slot difference. +3. Applied alpha to the upper toolbar pane: 428/428, zero differences. + +## EditMemoState::updateInput + +1. Restored common input processing and candidate-dependent pointer handling. + Infinity is computed with ordinary floating arithmetic. 306/309; + caching the prediction dialog removed the repeated virtual getter. +2. Repeated the prediction getter as the target does: 309/309, two register + differences in the combined return value. +3. Reused the keyboard-handled local for the combined result: + 309/309, zero differences. + +## DisappearMemoState::calc + +1. Restored animation interpolation and pane assignments: 370/342. +2. Kept the background stationary, used the configuration switch and removed + the scrolling operation absent from the target: 342/342, zero differences. + +## Static initialization and data + +1. Corrected DisappearMemoState to inherit AppearMemoState and its timer, + and made State's abstract operations pure under the private guard: + 63/64 initializer instructions; the derived table now inherits the correct + appearance operations. +2. Explicit background base construction and moving base function definitions + earlier did not change the initializer differences. Discarded. +3. Inline definitions for the base destructor and background operations: + 64/64, four remaining state-table offsets. Retained the inline State + destructor; discarded the ineffective background edits. +4. Background constructor moved out of the class with an inline definition: + same four offsets; createBG stayed exact. Discarded. +5. Restored function definitions to target object order and fixed the real + letter/photo-letter translation values to 145 and 151. This made the + floating constant pool identical, rather than relying on relocation-only + function scoring. Restored the background destructor omitted by the + ordering experiment before accepting the result. +6. External state globals: no code change, worse .bss score (40% versus 60%). + Reverted to the existing static definitions. +7. Included the background class declarations after the memo state classes: + moved its tables ahead of the state tables, but the strong background + destructor also emitted its derived table there. +8. Made the background destructor inline only for this unit, preserving the + existing header branches: its deduplicated derived table remains external, + background Base is first, and all four state offsets match. Initializer: + 64/64, zero differences. All 91 functions are instruction-exact. + +Pool remains identical. .sdata, .sdata2, .sbss and .ctors report 100%. +Reported .data remains 61.94834% and .bss 60.000004%. The original splits the +Manager vtable at 0x33c into a separately named 156-byte symbol; the compiler +emits one ordinary 320-byte vtable. Its entries and relocations through 0x3ac +agree. The extracted original additionally ends in 40 zero bytes after the +vtable; no source padding was added. The .bss registry buffers and state +objects have identical offsets and 72 zero bytes, but different buffer symbol +boundaries. No symbol configuration or hand-placed data was introduced. diff --git a/tools/decomp-assist/tiCandidateBox.attempts.md b/tools/decomp-assist/tiCandidateBox.attempts.md new file mode 100644 index 00000000..f87c7813 --- /dev/null +++ b/tools/decomp-assist/tiCandidateBox.attempts.md @@ -0,0 +1,41 @@ +# tiCandidateBox continuation + +Baseline: 104/112 objdiff, 102/112 instruction exact; code 17112/24000, data 1132/4652. + +Closest functions first: CalcPaneLocate_, StartScrollToIdx, StartScroll, GetPrevPageIdx_. Attempts 1 reorder margin/scale evaluation, 2 reverse multiplication and use an unsigned fixed pane-loop index, 3 reorder evaluation and addition. None improved the baseline. + +Draw: attempt 1 sequential vector initialization, 2 full scissor rectangle (12 differences), 3 direct corner initialization. Discarded attempt 2 because two unused fields add no readability; original retained. + +createAnmPane_: attempt 1 widened counters, 2 animation reference, 3 direct ID retrieval. All discarded. + +create: attempt 1 combined string allocation/construction, 2 combined candidate allocation/construction, 3 passed the saved allocator. All discarded. + +Static initializer: attempt 1 inline name access by value (exact), 2 const record member (22 differences), 3 inline name access by reference (exact). Retained meaningful shared-name accessors; 25/25 instructions, zero differences. + +Data: pool identical; .rodata and .sdata2 100%. Changing the existing empty-text array's final 1 to the target zero moved its storage and reduced .sdata to 75%; reverted. Existing pinned data and assembly not expanded. No shared-header changes. + +Measured trials: +- CalcPaneLocate_ attempt 1: src 0x6d0 base 0x6cc insns 436/435; --- insert mine 29:29 base 29:31 +- StartScrollToIdx attempt 1: src 0x2e4 base 0x2e0 insns 185/184; --- insert mine 21:21 base 21:23 +- StartScroll attempt 1: src 0x2e8 base 0x2e4 insns 186/185; --- insert mine 21:21 base 21:23 +- GetPrevPageIdx_ attempt 1: src 0x208 base 0x204 insns 130/129; --- replace mine 23:24 base 23:24 +- CalcPaneLocate_ attempt 2: src 0x6cc base 0x6cc insns 435/435; diffs 50: [34, 39, 41, 69, 168, 170, 247, 248, 249, 250, 254, 255, 258, 259, 260, 264, 266, 267, 269, 271] +- StartScrollToIdx attempt 2: src 0x2e0 base 0x2e0 insns 184/184; diffs 21: [27, 33, 35, 47, 54, 58, 60, 65, 70, 73, 74, 85, 88, 97, 102, 103, 121, 126, 141, 142] +- StartScroll attempt 2: src 0x2e4 base 0x2e4 insns 185/185; diffs 27: [27, 33, 35, 41, 50, 54, 56, 57, 58, 61, 63, 68, 73, 76, 77, 88, 90, 98, 106, 110] +- GetPrevPageIdx_ attempt 2: src 0x204 base 0x204 insns 129/129; diffs 23: [28, 36, 38, 39, 42, 51, 52, 58, 59, 61, 63, 64, 65, 71, 75, 76, 79, 80, 89, 90] +- CalcPaneLocate_ attempt 3: src 0x6d0 base 0x6cc insns 436/435; --- insert mine 29:29 base 29:31 +- StartScrollToIdx attempt 3: src 0x2e4 base 0x2e0 insns 185/184; --- insert mine 21:21 base 21:23 +- StartScroll attempt 3: src 0x2e8 base 0x2e4 insns 186/185; --- insert mine 21:21 base 21:23 +- GetPrevPageIdx_ attempt 3: src 0x208 base 0x204 insns 130/129; --- replace mine 23:24 base 23:24 +- Draw attempt 1: src 0x310 base 0x310 insns 196/196; diffs 33: [0, 2, 3, 68, 72, 73, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 93] +- createAnmPane_ attempt 1: src 0x36c base 0x360 insns 219/216; --- replace mine 0:1 base 0:1 +- create attempt 1: src 0x57c base 0x580 insns 351/352; --- replace mine 5:6 base 5:6 +- Draw attempt 2: src 0x310 base 0x310 insns 196/196; diffs 12: [0, 2, 3, 83, 84, 85, 143, 145, 148, 190, 192, 194] +- createAnmPane_ attempt 2: src 0x358 base 0x360 insns 214/216; --- insert mine 5:5 base 5:8 +- create attempt 2: src 0x57c base 0x580 insns 351/352; --- replace mine 5:6 base 5:6 +- Draw attempt 3: src 0x310 base 0x310 insns 196/196; diffs 33: [0, 2, 3, 68, 72, 73, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 93] +- createAnmPane_ attempt 3: src 0x370 base 0x360 insns 220/216; --- delete mine 5:6 base 5:5 +- create attempt 3: src 0x57c base 0x580 insns 351/352; --- replace mine 5:6 base 5:6 +- static initializer attempt 1: src 0x64 base 0x64 insns 25/25; diffs 0: [] +- static initializer attempt 2: src 0x64 base 0x64 insns 25/25; diffs 22: [1, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21] +- static initializer attempt 3: src 0x64 base 0x64 insns 25/25; diffs 0: [] diff --git a/tools/decomp-assist/tiHwKeyboard.attempts.md b/tools/decomp-assist/tiHwKeyboard.attempts.md new file mode 100644 index 00000000..d7ddc26e --- /dev/null +++ b/tools/decomp-assist/tiHwKeyboard.attempts.md @@ -0,0 +1,19 @@ +# tiHwKeyboard + +Baseline: 7/10 exact, 1676/4596 code bytes, 296/568 data bytes. Three functions were absent. Existing assembly bodies and pinned data were not expanded. + +- updateTappingShift_: typed KeySet iteration and inherited keyboard fields reproduce 145/145 instructions exactly on the first implementation. +- updateRepeatKey_ attempt 1: scalar space command produced 182/180 instructions and an extra saved register. +- attempt 2: copying a static NavigationCommand aggregate produced 184/180 and a larger frame. +- attempt 3: initialize the local NavigationCommand with {8, modifierState}; 180/180, one mask difference when using a boolean modifier. +- attempt 4: preserve the masked u32 modifier; 180/180, zero differences. +- updateTriggerKey_ attempt 1: copying the static character-input template was hoisted; 407/405, extra frame space. +- attempt 2: separate aggregate assignment and wider character temporary: 403/405, register and stack differences. +- attempt 3: local navigation aggregate and numeric range simplification: 405/405, 284 differences, mostly allocation/frame offsets. +- attempt 4: initialize the character aggregate locally; 400/405, template copy now occurs inside the loop. +- attempt 5: accurate u32 GetWChar declaration and explicit wchar_t narrowing; restored numeric filter switch. 404/405, quote handling remained. +- attempt 6: quote switch: 405/405, 14 branch differences. +- attempt 7: wchar_t quote-pair ranges: 404/405, missing high-half addition. +- attempt 8: express modular quote distances as character + (0x10000 - quote); 405/405, zero differences. + +Data: the first 64 extracted .rodata bytes belong to the preceding letter animation table (documented in MyTiLetterForm.attempts.md). They were not recreated as hardware dummy data. The real hardware key map and character-input template use ordinary typed C++ objects. Moving the key map after its consumer preserves all exact functions; moving country definitions after their assembly consumer failed compilation and was reverted. Target .bss is unreferenced extracted space; .sdata2 includes trailing zeros. No padding or force-active objects were added. Pools remain identical. Shared changes are isolated behind TIHWKEYBOARD_IMPLEMENTATION. -- 2.49.1