commit aa6e708

zzo38  ·  2023-05-02 05:04:00 +0000 UTC
parent e04238c
Experimental touch screen emulation mode.
2 files changed,  +20, -1
M main.c
+4, -0
 1@@ -16,6 +16,10 @@
 2 -N
 3   Tells the window manager to omit the frame.
 4 
 5+-O
 6+  Emulate touch screen. (This is an experimental feature, and may be
 7+  changed or removed in future.)
 8+
 9 -Q
10   Disable the mouse initially (it can still be enabled at run time).
11 
M main.c
+16, -1
 1@@ -223,6 +223,7 @@ static SDL_Surface*screen;
 2 static Uint8 layers;
 3 static Uint8 palet=7;
 4 static Uint8 eof_trigger=0;
 5+static Uint8 touch_mode=0;
 6 
 7 static Sint32*audio_option;
 8 static SDL_AudioSpec audiospec;
 9@@ -1274,6 +1275,19 @@ static int run_screen(void) {
10         k=SDL_GetMouseState(&i,&j);
11         i/=zoom; j/=zoom;
12         if(i<0 || i>=screen->w || j<0 || j>=screen->h) break;
13+        if(touch_mode) {
14+          if(e.type==SDL_MOUSEBUTTONDOWN && !device[9].d[6]) {
15+            PUT16(device[9].d+2,i);
16+            PUT16(device[9].d+4,j);
17+            run(GET16(device[9].d));
18+          } else if(e.type==SDL_MOUSEBUTTONUP && !k) {
19+            device[9].d[6]=0;
20+            run(GET16(device[9].d));
21+            i=j=0x8000;
22+          } else if(e.type==SDL_MOUSEMOTION && !k) {
23+            break;
24+          }
25+        }
26         PUT16(device[9].d+2,i);
27         PUT16(device[9].d+4,j);
28         device[9].d[6]=k&7;
29@@ -1456,12 +1470,13 @@ int main(int argc,char**argv) {
30   device[10].aux=&uxnfile0;
31   device[11].aux=&uxnfile1;
32   device[12].in=datetime_in;
33-  while((i=getopt(argc,argv,"+ADFIJ:NQST:YZa:dh:ijnp:qs:t:w:xyz:"))>0) switch(i) {
34+  while((i=getopt(argc,argv,"+ADFIJ:NOQST:YZa:dh:ijnp:qs:t:w:xyz:"))>0) switch(i) {
35     case 'D': scrflags|=SDL_DOUBLEBUF; break;
36     case 'F': scrflags|=SDL_FULLSCREEN; break;
37     case 'I': use_thread=1; break;
38     case 'J': set_joystick(optarg); break;
39     case 'N': scrflags|=SDL_NOFRAME; break;
40+    case 'O': touch_mode=1; device[9].d[2]=device[9].d[4]=0x80; break;
41     case 'Q': use_mouse=0; break;
42     case 'S': disallow_size_change=1; break;
43     case 'T': device[12].in=default_in; set_datetime(optarg); break;