Enhanced C interface to user input control.

This commit is contained in:
Oliver Schmidt 2018-07-27 22:03:26 +02:00
parent 0bd53f3af7
commit 6eb4aef0e8
2 changed files with 26 additions and 3 deletions

View File

@ -373,7 +373,14 @@ uint16_t timer_read(void);
//
bool __fastcall__ timer_timeout(uint16_t time);
// User abort control
// Check whether the abort key is being pressed
//
// Inputs: None
// Output: true if abort key pressed, false otherwise
//
bool input_check_for_abort_key(void);
// Control abort key
//
// Control if the user can abort blocking functions with the abort key
// (making them return IP65_ERROR_ABORTED_BY_USER). Initially the abort
@ -382,6 +389,10 @@ bool __fastcall__ timer_timeout(uint16_t time);
// Inputs: enable: false to disable the key, true to enable the key
// Output: None
//
void __fastcall__ abort_key(bool enable);
void __fastcall__ input_set_abort_key(bool enable);
// Access to actual abort key code
//
extern uint8_t abort_key;
#endif

View File

@ -1,15 +1,27 @@
.include "../inc/common.inc"
.export _input_check_for_abort_key
.export _input_set_abort_key
.export _abort_key
.import check_for_abort_key
.import abort_key
.importzp abort_key_default
.importzp abort_key_disable
_abort_key:
_input_check_for_abort_key:
jsr check_for_abort_key
ldx #$00
txa
rol
rts
_input_set_abort_key:
lsr
lda #abort_key_default
bcs :+
lda #abort_key_disable
: sta abort_key
rts
_abort_key := abort_key