8#include "IGUIStaticText.h"
10#include <IEventReceiver.h>
12#include <IGUIEnvironment.h>
16#include <unordered_map>
47 static_assert(std::is_base_of_v<IGUIElement, T>,
48 "grab_gui_element only works for IGUIElement");
49 return std::shared_ptr<T>(element, [](T *e) {
93#define BUTTON_REPEAT_DELAY 0.5f
94#define BUTTON_REPEAT_INTERVAL 0.333f
99#define SIMULATED_CLICK_DURATION_MS 50
116 void emitAction(
bool action, video::IVideoDriver *driver,
157 void step(
float dtime);
236 void addButton(std::vector<button_info> &buttons,
238 const recti &rect,
bool visible=
true);
241 const std::string &image_1,
const std::string &image_2,
242 const recti &rect,
bool visible=
true);
245 const recti &rect,
bool visible);
Definition texturesource.h:25
Definition touchcontrols.h:122
bool m_has_joystick_id
Definition touchcontrols.h:207
void registerHotbarRect(u16 index, const recti &rect)
Definition touchcontrols.cpp:742
bool m_dig_pressed
Definition touchcontrols.h:266
DISABLE_CLASS_COPY(TouchControls)
void applyContextControls(const TouchInteractionMode &mode)
Definition touchcontrols.cpp:839
IGUIImage * makeButtonDirect(touch_gui_button_id id, const recti &rect, bool visible)
Definition touchcontrols.cpp:433
v2s32 m_move_pos
Definition touchcontrols.h:201
void show()
Definition touchcontrols.cpp:809
bool m_visible
Definition touchcontrols.h:180
void updateVisibility()
Definition touchcontrols.cpp:768
TapState m_tap_state
Definition touchcontrols.h:264
double m_camera_pitch_change
Definition touchcontrols.h:187
~TouchControls()
Definition touchcontrols.cpp:405
u64 m_move_downtime
Definition touchcontrols.h:199
IGUIStaticText * getStatusText()
Definition touchcontrols.h:169
void addToggleButton(std::vector< button_info > &buttons, touch_gui_button_id id, const std::string &image_1, const std::string &image_2, const recti &rect, bool visible=true)
Definition touchcontrols.cpp:423
u64 m_place_pressed_until
Definition touchcontrols.h:270
TouchControls(IrrlichtDevice *device, ISimpleTextureSource *tsrc)
Definition touchcontrols.cpp:261
bool m_fixed_joystick
Definition touchcontrols.h:213
v2u32 m_screensize
Definition touchcontrols.h:176
void resetHotbarRects()
Definition touchcontrols.cpp:737
std::optional< u16 > getHotbarSelection()
Definition touchcontrols.cpp:459
bool m_overflow_open
Definition touchcontrols.h:223
double getYawChange()
Definition touchcontrols.h:131
line3d< f32 > m_shootline
A line starting at the camera and pointing towards the selected object.
Definition touchcontrols.h:194
std::vector< button_info > m_overflow_buttons
Definition touchcontrols.h:225
float m_joystick_speed
Definition touchcontrols.h:211
u16 m_long_tap_delay
Definition touchcontrols.h:179
std::shared_ptr< IGUIStaticText > m_overflow_bg
Definition touchcontrols.h:224
std::vector< recti > m_overflow_button_rects
Definition touchcontrols.h:227
v2s32 getPointerPos()
Definition touchcontrols.cpp:814
ISimpleTextureSource * m_texturesource
Definition touchcontrols.h:175
void releaseAll()
Definition touchcontrols.cpp:787
std::vector< std::shared_ptr< IGUIStaticText > > m_overflow_button_titles
Definition touchcontrols.h:226
bool m_move_prevent_short_tap
Definition touchcontrols.h:205
void emitMouseEvent(EMOUSE_INPUT_EVENT type)
Definition touchcontrols.cpp:823
void addButton(std::vector< button_info > &buttons, touch_gui_button_id id, const std::string &image, const recti &rect, bool visible=true)
Definition touchcontrols.cpp:410
std::unordered_map< size_t, v2s32 > m_pointer_pos
Definition touchcontrols.h:259
size_t m_joystick_id
Definition touchcontrols.h:208
TouchInteractionMode m_last_mode
Definition touchcontrols.h:263
std::shared_ptr< IGUIImage > m_joystick_btn_center
Definition touchcontrols.h:218
IGUIEnvironment * m_guienv
Definition touchcontrols.h:173
std::optional< u16 > m_hotbar_selection
Definition touchcontrols.h:183
IEventReceiver * m_receiver
Definition touchcontrols.h:174
float getJoystickSpeed()
Definition touchcontrols.h:155
std::shared_ptr< IGUIImage > m_overflow_btn
Definition touchcontrols.h:221
void setUseCrosshair(bool use_crosshair)
Definition touchcontrols.h:158
void translateEvent(const SEvent &event)
Definition touchcontrols.cpp:513
s32 m_button_size
Definition touchcontrols.h:177
void setVisible(bool visible)
Definition touchcontrols.cpp:747
std::shared_ptr< IGUIImage > m_joystick_btn_bg
Definition touchcontrols.h:217
std::unordered_map< size_t, v2s32 > m_pointer_downpos
Definition touchcontrols.h:257
bool isHotbarButton(const SEvent &event)
Definition touchcontrols.cpp:444
IrrlichtDevice * m_device
Definition touchcontrols.h:172
void handleReleaseEvent(size_t pointer_id)
Definition touchcontrols.cpp:466
bool m_draw_crosshair
Definition touchcontrols.h:215
void applyJoystickStatus()
Definition touchcontrols.cpp:686
void toggleOverflowMenu()
Definition touchcontrols.cpp:760
bool m_had_move_id
Definition touchcontrols.h:204
size_t m_move_id
Definition touchcontrols.h:197
std::shared_ptr< IGUIStaticText > m_status_text
Definition touchcontrols.h:229
double m_touchscreen_threshold
Definition touchcontrols.h:178
std::shared_ptr< IGUIImage > m_joystick_btn_off
Definition touchcontrols.h:216
line3d< f32 > getShootline()
Returns a line which describes what the player is pointing at.
Definition touchcontrols.h:152
u64 m_dig_pressed_until
Definition touchcontrols.h:267
std::vector< button_info > m_buttons
Definition touchcontrols.h:220
void hide()
Definition touchcontrols.cpp:804
std::unordered_map< u16, recti > m_hotbar_rects
Definition touchcontrols.h:182
float m_joystick_direction
Definition touchcontrols.h:210
float getJoystickDirection()
Definition touchcontrols.h:154
bool isStatusTextOverriden()
Definition touchcontrols.h:168
bool m_joystick_status_aux1
Definition touchcontrols.h:212
bool m_move_has_really_moved
Definition touchcontrols.h:198
void step(float dtime)
Definition touchcontrols.cpp:702
double getPitchChange()
Definition touchcontrols.h:138
double m_camera_yaw_change
Definition touchcontrols.h:186
bool m_place_pressed
Definition touchcontrols.h:269
bool m_joystick_has_really_moved
Definition touchcontrols.h:209
bool m_joystick_triggers_aux1
Definition touchcontrols.h:214
bool m_has_move_id
Definition touchcontrols.h:196
core::vector2d< s32 > v2s32
Definition irr_v2d.h:13
core::vector2d< u32 > v2u32
Definition irr_v2d.h:14
TouchInteractionMode
Definition itemdef.h:43
@ TouchInteractionMode_END
Definition itemdef.h:47
Definition fontengine.h:14
Definition clientmap.h:30
TouchControls * g_touchcontrols
Definition touchcontrols.cpp:27
touch_gui_button_id
Definition touchcontrols.h:63
@ joystick_center_id
Definition touchcontrols.h:89
@ fast_id
Definition touchcontrols.h:73
@ chat_id
Definition touchcontrols.h:81
@ inventory_id
Definition touchcontrols.h:82
@ debug_id
Definition touchcontrols.h:74
@ range_id
Definition touchcontrols.h:76
@ zoom_id
Definition touchcontrols.h:66
@ exit_id
Definition touchcontrols.h:84
@ aux1_id
Definition touchcontrols.h:67
@ fly_id
Definition touchcontrols.h:71
@ minimap_id
Definition touchcontrols.h:77
@ camera_id
Definition touchcontrols.h:75
@ drop_id
Definition touchcontrols.h:83
@ jump_id
Definition touchcontrols.h:64
@ joystick_off_id
Definition touchcontrols.h:87
@ toggle_chat_id
Definition touchcontrols.h:78
@ joystick_bg_id
Definition touchcontrols.h:88
@ sneak_id
Definition touchcontrols.h:65
@ noclip_id
Definition touchcontrols.h:72
@ overflow_id
Definition touchcontrols.h:68
std::shared_ptr< T > grab_gui_element(T *element)
Definition touchcontrols.h:45
TapState
Definition touchcontrols.h:56