Skip to content

Commit

Permalink
sokol.sapp,gg: add a tool_type field to gg.TouchPoint (differenci…
Browse files Browse the repository at this point in the history
…ate different types of touch input) (#15822)
  • Loading branch information
Wertzui123 committed Sep 20, 2022
1 parent 993802f commit a9d63d7
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions thirdparty/sokol/sokol_app.h
Original file line number Diff line number Diff line change
Expand Up @@ -1230,6 +1230,7 @@ typedef struct sapp_touchpoint {
uintptr_t identifier;
float pos_x;
float pos_y;
int tool_type; // __v_
bool changed;
} sapp_touchpoint;

Expand Down Expand Up @@ -8569,6 +8570,7 @@ _SOKOL_PRIVATE bool _sapp_android_touch_event(const AInputEvent* e) {
dst->identifier = (uintptr_t)AMotionEvent_getPointerId(e, (size_t)i);
dst->pos_x = (AMotionEvent_getRawX(e, (size_t)i) / _sapp.window_width) * _sapp.framebuffer_width;
dst->pos_y = (AMotionEvent_getRawY(e, (size_t)i) / _sapp.window_height) * _sapp.framebuffer_height;
dst->tool_type = AMotionEvent_getToolType(e, (size_t)i); // __v_

if (action == AMOTION_EVENT_ACTION_POINTER_DOWN ||
action == AMOTION_EVENT_ACTION_POINTER_UP) {
Expand Down
9 changes: 9 additions & 0 deletions vlib/sokol/sapp/enums.v
Original file line number Diff line number Diff line change
Expand Up @@ -183,3 +183,12 @@ pub enum KeyCode {
right_super = 347
menu = 348
}

pub enum TouchToolType {
unknown
finger
stylus
mouse
eraser
palm
}
1 change: 1 addition & 0 deletions vlib/sokol/sapp/sapp_structs.c.v
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ pub:
identifier u64
pos_x f32
pos_y f32
tool_type TouchToolType
changed bool
}

Expand Down

0 comments on commit a9d63d7

Please sign in to comment.