Commit 82ed460e597eb9a2f8737c13e19f6c6982f5a140
1 parent
546d542b
Exists in
master
and in
5 other branches
Ajustes nas chamadas HLLAPI.
Showing
1 changed file
with
70 additions
and
15 deletions
Show diff stats
src/plugins/hllapi/hllapi.c
... | ... | @@ -49,6 +49,7 @@ |
49 | 49 | static int wait_system(char *buffer, unsigned short *length, unsigned short *rc); |
50 | 50 | static int reset_system(char *buffer, unsigned short *length, unsigned short *rc); |
51 | 51 | static int pause_system(char *buffer, unsigned short *length, unsigned short *rc); |
52 | + static int set_session_parameters(char *buffer, unsigned short *length, unsigned short *rc); | |
52 | 53 | |
53 | 54 | static int get_cursor_position(char *buffer, unsigned short *length, unsigned short *rc); |
54 | 55 | static int set_cursor_position(char *buffer, unsigned short *length, unsigned short *rc); |
... | ... | @@ -64,24 +65,31 @@ |
64 | 65 | int (*exec)(char *buffer, unsigned short *length, unsigned short *rc); |
65 | 66 | } hllapi_call[] = |
66 | 67 | { |
67 | - { HLLAPI_CMD_CONNECTPS, connect_ps }, | |
68 | - { HLLAPI_CMD_DISCONNECTPS, disconnect_ps }, | |
69 | - { HLLAPI_CMD_GETREVISION, get_library_revision }, | |
70 | - { HLLAPI_CMD_QUERYCURSOR, get_cursor_position }, | |
71 | - { HLLAPI_CMD_SETCURSOR, set_cursor_position }, | |
72 | - { HLLAPI_CMD_COPYPSTOSTR, copy_ps_to_str }, | |
73 | - { HLLAPI_CMD_INPUTSTRING, input_string }, | |
74 | - { HLLAPI_CMD_WAIT, wait_system }, | |
75 | - { HLLAPI_CMD_COPYPS, copy_ps }, | |
76 | - { HLLAPI_CMD_SEARCHPS, search_ps }, | |
77 | - { HLLAPI_CMD_COPYSTRTOPS, copy_str_to_ps }, | |
78 | - { HLLAPI_CMD_SENDFILE, invalid_request }, | |
79 | - { HLLAPI_CMD_RECEIVEFILE, invalid_request }, | |
80 | - { HLLAPI_RESET_SYSTEM, reset_system }, | |
81 | - { HLLAPI_CMD_PAUSE, pause_system }, | |
68 | + { HLLAPI_CMD_CONNECTPS, connect_ps }, | |
69 | + { HLLAPI_CMD_DISCONNECTPS, disconnect_ps }, | |
70 | + { HLLAPI_CMD_GETREVISION, get_library_revision }, | |
71 | + { HLLAPI_CMD_QUERYCURSOR, get_cursor_position }, | |
72 | + { HLLAPI_CMD_SETCURSOR, set_cursor_position }, | |
73 | + { HLLAPI_CMD_COPYPSTOSTR, copy_ps_to_str }, | |
74 | + { HLLAPI_CMD_INPUTSTRING, input_string }, | |
75 | + { HLLAPI_CMD_WAIT, wait_system }, | |
76 | + { HLLAPI_CMD_COPYPS, copy_ps }, | |
77 | + { HLLAPI_CMD_SEARCHPS, search_ps }, | |
78 | + { HLLAPI_CMD_COPYSTRTOPS, copy_str_to_ps }, | |
79 | + { HLLAPI_CMD_SENDFILE, invalid_request }, | |
80 | + { HLLAPI_CMD_RECEIVEFILE, invalid_request }, | |
81 | + { HLLAPI_RESET_SYSTEM, reset_system }, | |
82 | + { HLLAPI_CMD_PAUSE, pause_system }, | |
83 | + { HLLAPI_SET_SESSION_PARAMETERS, set_session_parameters } | |
82 | 84 | |
83 | 85 | }; |
84 | 86 | |
87 | + static enum _pause_mode | |
88 | + { | |
89 | + PAUSE_MODE_IPAUSE, ///< @brief Interruptible pause. After the Start Host Notification (23) function is executed, a host event satisfies a pause. | |
90 | + PAUSE_MODE_FPAUSE ///< @brief A full-duration pause lasts for however long you specified in the Pause (18) function. | |
91 | + } pause_mode = PAUSE_MODE_IPAUSE; | |
92 | + | |
85 | 93 | static const char control_char = '@'; |
86 | 94 | |
87 | 95 | /*--[ Implement ]------------------------------------------------------------------------------------*/ |
... | ... | @@ -501,5 +509,52 @@ static int reset_system(char *buffer, unsigned short *length, unsigned short *rc |
501 | 509 | |
502 | 510 | static int pause_system(char *buffer, unsigned short *length, unsigned short *rc) |
503 | 511 | { |
512 | + if(!*length) | |
513 | + { | |
514 | + // If you use the IPAUSE option and the pause value is zero, then the function | |
515 | + // waits up to 2400 half-second intervals, unless interrupted sooner. If you use the | |
516 | + // FPAUSE option and the pause value is zero, then the function returns | |
517 | + // immediately. | |
518 | + | |
519 | + if(pause_mode == PAUSE_MODE_FPAUSE) | |
520 | + { | |
521 | + return HLLAPI_STATUS_SUCCESS; | |
522 | + } | |
523 | + return hllapi_wait_for_ready(1200); | |
524 | + } | |
525 | + | |
526 | + if(pause_mode == PAUSE_MODE_FPAUSE) | |
527 | + { | |
528 | + // Pause fixo - Aguarda pelo tempo informado, independente de eventos. | |
529 | + return hllapi_wait( (*length) / 2); | |
530 | + } | |
531 | + | |
532 | + // Pause "flexivel", aguarda tela limpa | |
504 | 533 | return hllapi_wait_for_ready((*length) / 2); |
505 | 534 | } |
535 | + | |
536 | +static int set_session_parameters(char *buffer, unsigned short *length, unsigned short *rc) | |
537 | +{ | |
538 | + if(!(*length && buffer && *buffer)) | |
539 | + { | |
540 | + return HLLAPI_STATUS_BAD_PARAMETER; | |
541 | + } | |
542 | + | |
543 | + if(!strncasecmp(buffer,"IPAUSE",*length)) | |
544 | + { | |
545 | + // IPAUSE | |
546 | + pause_mode = PAUSE_MODE_IPAUSE; | |
547 | + } | |
548 | + else if(!strncasecmp(buffer,"FPAUSE",*length)) | |
549 | + { | |
550 | + // FPAUSE | |
551 | + pause_mode = PAUSE_MODE_FPAUSE; | |
552 | + } | |
553 | + else | |
554 | + { | |
555 | + return HLLAPI_STATUS_BAD_PARAMETER; | |
556 | + } | |
557 | + | |
558 | + return HLLAPI_STATUS_SUCCESS; | |
559 | + | |
560 | +} | ... | ... |