Skip to content

Commit bf1105b

Browse files
committed
virt keyboard
1 parent ed8e2a9 commit bf1105b

9 files changed

Lines changed: 32 additions & 76 deletions

File tree

src/ruisapp/application.cpp

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -96,24 +96,6 @@ std::unique_ptr<papki::file> application::get_res_file(std::string_view path) co
9696
{
9797
return std::make_unique<papki::fs_file>(path);
9898
}
99-
100-
# if CFG_OS_NAME != CFG_OS_NAME_EMSCRIPTEN
101-
void application::show_virtual_keyboard() noexcept
102-
{
103-
utki::log_debug([](auto& o) {
104-
o << "application::show_virtual_keyboard(): invoked" << std::endl;
105-
});
106-
// do nothing
107-
}
108-
109-
void application::hide_virtual_keyboard() noexcept
110-
{
111-
utki::log_debug([](auto& o) {
112-
o << "application::hide_virtual_keyboard(): invoked" << std::endl;
113-
});
114-
// do nothing
115-
}
116-
# endif
11799
#endif
118100

119101
ruis::real application::get_pixels_per_pp(

src/ruisapp/application.hpp

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -158,22 +158,6 @@ class application : public utki::intrusive_singleton<application>
158158

159159
~application() override;
160160

161-
/**
162-
* @brief Bring up the virtual keyboard.
163-
* On mobile platforms this function will summon the on-screen keyboard.
164-
* On desktop platforms this function does nothing.
165-
*/
166-
// TODO: move to window?
167-
void show_virtual_keyboard() noexcept;
168-
169-
/**
170-
* @brief Hide virtual keyboard.
171-
* On mobile platforms this function hides the on-screen keyboard.
172-
* On desktop platforms this function does nothing.
173-
*/
174-
// TODO: move to window?
175-
void hide_virtual_keyboard() noexcept;
176-
177161
public:
178162
/**
179163
* @brief Requests application to exit.

src/ruisapp/glue/android/application.cxx

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -182,25 +182,3 @@ void ruisapp::application::quit() noexcept
182182
utki::assert(globals_wrapper::native_activity, SL);
183183
ANativeActivity_finish(globals_wrapper::native_activity);
184184
}
185-
186-
void ruisapp::application::show_virtual_keyboard() noexcept
187-
{
188-
// NOTE:
189-
// ANativeActivity_showSoftInput(native_activity,
190-
// ANATIVEACTIVITY_SHOW_SOFT_INPUT_FORCED); did not work for some reason.
191-
192-
auto& glob = get_glob();
193-
194-
glob.java_functions.show_virtual_keyboard();
195-
}
196-
197-
void ruisapp::application::hide_virtual_keyboard() noexcept
198-
{
199-
// NOTE:
200-
// ANativeActivity_hideSoftInput(native_activity,
201-
// ANATIVEACTIVITY_HIDE_SOFT_INPUT_NOT_ALWAYS); did not work for some reason
202-
203-
auto& glob = get_glob();
204-
205-
glob.java_functions.hide_virtual_keyboard();
206-
}

src/ruisapp/glue/android/window.cxx

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,3 +168,22 @@ void native_window::set_fullscreen_internal(bool enable)
168168
);
169169
}
170170
}
171+
172+
void naitve_window::set_virtual_keyboard_visible(bool visible) noexcept
173+
{
174+
auto& glob = get_glob();
175+
176+
if (visible) {
177+
// NOTE:
178+
// ANativeActivity_showSoftInput(native_activity,
179+
// ANATIVEACTIVITY_SHOW_SOFT_INPUT_FORCED); did not work for some reason.
180+
181+
glob.java_functions.show_virtual_keyboard();
182+
} else {
183+
// NOTE:
184+
// ANativeActivity_hideSoftInput(native_activity,
185+
// ANATIVEACTIVITY_HIDE_SOFT_INPUT_NOT_ALWAYS); did not work for some reason
186+
187+
glob.java_functions.hide_virtual_keyboard();
188+
}
189+
}

src/ruisapp/glue/android/window.hxx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,5 +53,7 @@ public:
5353
r4::vector2<unsigned> get_dims();
5454

5555
void set_fullscreen_internal(bool enable) override;
56+
57+
void set_virtual_keyboard_visible(bool visible) noexcept override;
5658
};
5759
} // namespace

src/ruisapp/glue/ios/glue.mm

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -364,14 +364,6 @@ - (void)touchesCancelled:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
364364
// do nothing, ios swaps frame buffers automatically
365365
}
366366

367-
void application::show_virtual_keyboard()noexcept{
368-
//TODO:
369-
}
370-
371-
void application::hide_virtual_keyboard()noexcept{
372-
//TODO:
373-
}
374-
375367
std::unique_ptr<papki::file> application::get_res_file(std::string_view path)const{
376368
std::string dir([[[NSBundle mainBundle] resourcePath] fileSystemRepresentation]);
377369

src/ruisapp/glue/sdl/application.cxx

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -276,15 +276,3 @@ void ruisapp::application::destroy_window(ruisapp::window& w)
276276
glue.destroy_window(app_win.ruis_native_window.get().get_id());
277277
#endif
278278
}
279-
280-
#if CFG_OS_NAME == CFG_OS_NAME_EMSCRIPTEN
281-
void ruisapp::application::show_virtual_keyboard() noexcept
282-
{
283-
SDL_StartTextInput();
284-
}
285-
286-
void ruisapp::application::hide_virtual_keyboard() noexcept
287-
{
288-
SDL_StopTextInput();
289-
}
290-
#endif

src/ruisapp/glue/sdl/window.cxx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,3 +317,12 @@ void native_window::set_mouse_cursor(ruis::mouse_cursor c)
317317
{
318318
this->display.get().set_cursor(c);
319319
}
320+
321+
void native_window::set_virtual_keyboard_visible(bool visible) noexcept
322+
{
323+
if (visible) {
324+
SDL_StartTextInput();
325+
} else {
326+
SDL_StopTextInput();
327+
}
328+
}

src/ruisapp/glue/sdl/window.hxx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,5 +178,7 @@ public:
178178
));
179179
}
180180
}
181+
182+
void set_virtual_keyboard_visible(bool visible) noexcept override;
181183
};
182184
} // namespace

0 commit comments

Comments
 (0)