Skip to content

Commit

Permalink
sdl_milton: Logic for stylus buttons with gui
Browse files Browse the repository at this point in the history
Added clauses so that when a button on the stylus is pressed an appropriate
functionality is called based on the gui radio buttons in settings
  • Loading branch information
Maciej Wieczór-Retman committed May 29, 2023
1 parent 299c96f commit 5fe10ab
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/sdl_milton.cc
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,26 @@ panning_update(PlatformState* platform)
}
}

static void stylus_buttons_exec_function(MiltonInput *milton_input, Milton *milton, int mode)
{
switch (mode) {
case STYLUS_DEFAULT:
break;
case STYLUS_ERASER:
milton_input->mode_to_set = MiltonMode::ERASER;
break;
case STYLUS_BRUSH:
milton_input->mode_to_set = MiltonMode::PEN;
break;
case STYLUS_DECB:
for (int i=0;i<5;++i) milton_decrease_brush_size(milton);
break;
case STYLUS_INCB:
for (int i=0;i<5;++i) milton_increase_brush_size(milton);
break;
}
}

MiltonInput
sdl_event_loop(Milton* milton, PlatformState* platform)
{
Expand Down Expand Up @@ -277,6 +297,9 @@ sdl_event_loop(Milton* milton, PlatformState* platform)
if(bit_lower && platform->lower_button == STYLUS_BUTTON_NOT_PRESSED) {
if(platform->lower_button == STYLUS_BUTTON_NOT_PRESSED) {
platform->lower_button = STYLUS_BUTTON_PRESSED;
stylus_buttons_exec_function(&milton_input,
milton,
milton->settings->lower_button);
}
}

Expand All @@ -287,6 +310,9 @@ sdl_event_loop(Milton* milton, PlatformState* platform)
if(bit_upper) {
if(platform->upper_button == STYLUS_BUTTON_NOT_PRESSED) {
platform->upper_button = STYLUS_BUTTON_PRESSED;
stylus_buttons_exec_function(&milton_input,
milton,
milton->settings->upper_button);
}
}

Expand Down

0 comments on commit 5fe10ab

Please sign in to comment.