From 93de2db34ee5a2e6ea983597e28db396939d87df Mon Sep 17 00:00:00 2001 From: Franklin Wei Date: Sat, 25 Nov 2017 20:36:40 -0500 Subject: Fake button presses for Palisade --- palisade.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/palisade.c b/palisade.c index 317fb7b..e941661 100644 --- a/palisade.c +++ b/palisade.c @@ -867,13 +867,14 @@ static char *game_text_format(const game_state *state) struct game_ui { int x, y; bool show; + bool fake_ctrl, fake_shift; }; static game_ui *new_ui(const game_state *state) { game_ui *ui = snew(game_ui); ui->x = ui->y = 0; - ui->show = false; + ui->show = ui->fake_ctrl = ui->fake_shift = false; return ui; } @@ -917,7 +918,10 @@ static char *interpret_move(const game_state *state, game_ui *ui, const game_drawstate *ds, int x, int y, int button) { int w = state->shared->params.w, h = state->shared->params.h; - bool control = button & MOD_CTRL, shift = button & MOD_SHFT; + bool control = (button & MOD_CTRL) | ui->fake_ctrl, shift = (button & MOD_SHFT) | ui->fake_shift; + + /* reset */ + ui->fake_ctrl = ui->fake_shift = false; button &= ~MOD_MASK; @@ -1000,6 +1004,16 @@ static char *interpret_move(const game_state *state, game_ui *ui, return UI_UPDATE; } } + else if(IS_CURSOR_SELECT(button)) { + /* CURSOR_SELECT or CURSOR_SELECT2 tells us to toggle whether + * the button press should be interpreted as having CTRL or + * shift pressed along with it, respectively. */ + ui->show = true; + if(button == CURSOR_SELECT2) + ui->fake_shift = !ui->fake_shift; + else + ui->fake_ctrl = !ui->fake_ctrl; + } return NULL; } -- cgit v1.1