From f865bef335f17ae7b1bc343c76524fe2fba40aa1 Mon Sep 17 00:00:00 2001 From: Thomas Cherryhomes Date: Thu, 31 Jan 2019 16:51:28 -0600 Subject: [PATCH] implement touch. add one pixel to window X. --- screen.c | 35 +++++++++++++++++++++++++++++++++-- screen.h | 4 ++++ touch.c | 14 +++++++++----- touch.h | 2 +- 4 files changed, 47 insertions(+), 8 deletions(-) diff --git a/screen.c b/screen.c index b4ca397..9dafbef 100644 --- a/screen.c +++ b/screen.c @@ -15,6 +15,7 @@ #include "protocol.h" #include "io.h" #include "keyboard.h" +#include "touch.h" #define true 1 #define false 0 @@ -109,7 +110,7 @@ void screen_init(void) screenRect=qd.screenBits.bounds; windowRect.left=0; - windowRect.right=511; + windowRect.right=512; /* Set window size depending on screen size. */ if (screenRect.bottom < 468) @@ -198,6 +199,32 @@ void screen_menu_command(long menu_command) HiliteMenu(0); } +/** + * screen_handle_touch(where) - Handle touch events + */ +void screen_handle_touch(Point* where) +{ + padPt temp; + SetPort(win); + GlobalToLocal(where); + temp.x = ((long)where->h * PLATOSize.x) / windowWidth; + temp.y = (PLATOSize.y - 1) - (((long)where->v * PLATOSize.y) / + windowHeight); + + touch_main(&temp); +} + +/** + * screen_show_cursor - Hide mouse cursor + */ +void screen_show_cursor(padBool show) +{ + if (show==padT) + ShowCursor(); + else if (show==padF) + ObscureCursor(); +} + /** * screen_main(void) */ @@ -224,7 +251,10 @@ void screen_main(void) screen_menu_command(MenuSelect(theEvent.where)); break; case inContent: - SelectWindow(currentWindow); + if (FrontWindow()!=currentWindow) + SelectWindow(currentWindow); + else + screen_handle_touch(&theEvent.where); break; case inSysWindow: SystemClick(&theEvent,currentWindow); @@ -232,6 +262,7 @@ void screen_main(void) } case keyDown: case autoKey: + screen_show_cursor(padF); keyboard_main(&theEvent); break; case updateEvt: diff --git a/screen.h b/screen.h index f7a6639..5176cbf 100755 --- a/screen.h +++ b/screen.h @@ -27,6 +27,10 @@ void screen_update_menus(void); */ void screen_menu_command(long menu_command); +/** + * screen_show_cursor - Hide mouse cursor + */ +void screen_show_cursor(padBool show); /** * screen_main(void) diff --git a/touch.c b/touch.c index 5944670..73518c0 100644 --- a/touch.c +++ b/touch.c @@ -21,14 +21,18 @@ void touch_init(void) */ void touch_allow(padBool allow) { + isAllowed=allow; + if (isAllowed==padT) + screen_show_cursor(padT); + else + screen_show_cursor(padF); } -padBool touch_lmb(void) -{ -} - -void touch_main(void) +void touch_main(padPt* Coord) { + if (isAllowed==padF) + return; + Touch(Coord); } /** diff --git a/touch.h b/touch.h index 649fc12..256f6cc 100644 --- a/touch.h +++ b/touch.h @@ -22,7 +22,7 @@ padBool touch_lmb(void); /** * Get mouse position, and if LMB pressed, send touch event. */ -void touch_main(void); +void touch_main(padPt* coord); /** * touch done