Skip to content

Commit

Permalink
[kobo] update sharenote and drawing_demo to accept touch as stylus
Browse files Browse the repository at this point in the history
  • Loading branch information
okay committed Mar 3, 2024
1 parent c54e1b8 commit ec90ae6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/drawing_demo/main.cpy
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,16 @@ class Note: public ui::Widget:
void on_mouse_up(input::SynMotionEvent &ev):
prevx = prevy = -1

void on_mouse_move(input::SynMotionEvent &ev):
if input::is_touch_event(ev):
return
bool ignore_event(input::SynMotionEvent &ev):
if not ui::MainLoop::in.has_stylus:
ev.pressure = 0.5
ev.tilt_x = 0.5
ev.tilt_y = 0.5
return false

return input::is_touch_event(ev) != NULL

void on_mouse_move(input::SynMotionEvent &ev):
if not mouse_down:
return

Expand Down
6 changes: 6 additions & 0 deletions src/sharenote/main.cpy
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,12 @@ class Note: public ui::Widget:
prevx = prevy = -1

bool ignore_event(input::SynMotionEvent &ev):
if not ui::MainLoop::in.has_stylus:
ev.pressure = 0.5
ev.tilt_x = 0.5
ev.tilt_y = 0.5
return false

return input::is_touch_event(ev) != NULL

void on_mouse_move(input::SynMotionEvent &ev):
Expand Down

0 comments on commit ec90ae6

Please sign in to comment.