... | ... |
@@ -29,7 +29,7 @@ |
29 | 29 |
|40 @Audio1 &vector $2 &position $2 &output $1 &pad $3 &adsr $2 &length $2 &addr $2 &volume $1 &pitch $1 |
30 | 30 |
|50 @Audio2 &vector $2 &position $2 &output $1 &pad $3 &adsr $2 &length $2 &addr $2 &volume $1 &pitch $1 |
31 | 31 |
|60 @Audio3 &vector $2 &position $2 &output $1 &pad $3 &adsr $2 &length $2 &addr $2 &volume $1 &pitch $1 |
32 |
-|80 @Controller &vector $2 &button $1 &key $1 |
|
32 |
+|80 @Controller &vector $2 &button $1 &key $1 &func $1 |
|
33 | 33 |
|90 @Mouse &vector $2 &x $2 &y $2 &state $1 &pad $3 &scrollx $2 &scrolly $2 |
34 | 34 |
|a0 @File &vector $2 &success $2 &stat $2 &delete $1 &append $1 &name $2 &length $2 &read $2 &write $2 |
35 | 35 |
|b0 @DateTime &year $2 &month $1 &day $1 &hour $1 &minute $1 &second $1 &dotw $1 &doty $2 &isdst $1 |
... | ... |
@@ -29,6 +29,7 @@ |
29 | 29 |
|
30 | 30 |
|00 @System &vector $2 &wst $1 &rst $1 &eaddr $2 &ecode $1 &pad $1 &r $2 &g $2 &b $2 &debug $1 &halt $1 |
31 | 31 |
|20 @Screen &vector $2 &width $2 &height $2 &auto $1 &pad $1 &x $2 &y $2 &addr $2 &pixel $1 &sprite $1 |
32 |
+|80 @Controller &vector $2 &button $1 &key $1 &func $1 |
|
32 | 33 |
|
33 | 34 |
( variables ) |
34 | 35 |
|
... | ... |
@@ -53,6 +54,7 @@ |
53 | 54 |
( vectors ) |
54 | 55 |
;on-error .System/vector DEO2 |
55 | 56 |
;on-frame .Screen/vector DEO2 |
57 |
+ ;on-button .Controller/vector DEO2 |
|
56 | 58 |
|
57 | 59 |
BRK |
58 | 60 |
|
... | ... |
@@ -63,6 +65,12 @@ BRK |
63 | 65 |
|
64 | 66 |
BRK |
65 | 67 |
|
68 |
+@on-button ( -> ) |
|
69 |
+ |
|
70 |
+ .Controller/func DEI DEBUG |
|
71 |
+ |
|
72 |
+BRK |
|
73 |
+ |
|
66 | 74 |
@on-error ( -> ) |
67 | 75 |
|
68 | 76 |
( background ) |
... | ... |
@@ -39,4 +39,14 @@ controller_key(Device *d, Uint8 key) |
39 | 39 |
uxn_eval(d->u, d->vector); |
40 | 40 |
d->dat[3] = 0x00; |
41 | 41 |
} |
42 |
+} |
|
43 |
+ |
|
44 |
+void |
|
45 |
+controller_special(Device *d, Uint8 key) |
|
46 |
+{ |
|
47 |
+ if(key) { |
|
48 |
+ d->dat[4] = key; |
|
49 |
+ uxn_eval(d->u, d->vector); |
|
50 |
+ d->dat[4] = 0x00; |
|
51 |
+ } |
|
42 | 52 |
} |
43 | 53 |
\ No newline at end of file |
... | ... |
@@ -12,4 +12,5 @@ WITH REGARD TO THIS SOFTWARE. |
12 | 12 |
|
13 | 13 |
void controller_down(Device *d, Uint8 mask); |
14 | 14 |
void controller_up(Device *d, Uint8 mask); |
15 |
-void controller_key(Device *d, Uint8 key); |
|
16 | 15 |
\ No newline at end of file |
16 |
+void controller_key(Device *d, Uint8 key); |
|
17 |
+void controller_special(Device *d, Uint8 key); |
|
17 | 18 |
\ No newline at end of file |
... | ... |
@@ -272,8 +272,8 @@ start(Uxn *u, char *rom) |
272 | 272 |
/* audio2 */ uxn_port(u, 0x5, 0xffff, audio_dei, audio_deo); |
273 | 273 |
/* audio3 */ uxn_port(u, 0x6, 0xffff, audio_dei, audio_deo); |
274 | 274 |
/* unused */ uxn_port(u, 0x7, 0xffff, nil_dei, nil_deo); |
275 |
- /* control */ devctrl = uxn_port(u, 0x8, 0xffff, nil_dei, nil_deo); |
|
276 |
- /* mouse */ devmouse = uxn_port(u, 0x9, 0xffff, nil_dei, nil_deo); |
|
275 |
+ /* control */ devctrl = uxn_port(u, 0x8, 0x0000, nil_dei, nil_deo); |
|
276 |
+ /* mouse */ devmouse = uxn_port(u, 0x9, 0x0000, nil_dei, nil_deo); |
|
277 | 277 |
/* file */ uxn_port(u, 0xa, 0xffff, nil_dei, file_deo); |
278 | 278 |
/* datetime */ uxn_port(u, 0xb, 0xffff, datetime_dei, nil_deo); |
279 | 279 |
/* unused */ uxn_port(u, 0xc, 0xffff, nil_dei, nil_deo); |
... | ... |
@@ -285,6 +285,7 @@ start(Uxn *u, char *rom) |
285 | 285 |
uxn_port(&supervisor, 0x0, 0xffff, system_dei, system_deo); |
286 | 286 |
uxn_port(&supervisor, 0x1, 0xffff, nil_dei, console_deo); |
287 | 287 |
uxn_port(&supervisor, 0x2, 0xffff, screen_dei, screen_deo); |
288 |
+ uxn_port(&supervisor, 0x8, 0x0000, nil_dei, nil_deo); |
|
288 | 289 |
|
289 | 290 |
uxn_eval(&supervisor, PAGE_PROGRAM); |
290 | 291 |
|
... | ... |
@@ -348,6 +349,22 @@ get_button(SDL_Event *event) |
348 | 349 |
return 0x00; |
349 | 350 |
} |
350 | 351 |
|
352 |
+static Uint8 |
|
353 |
+get_fkey(SDL_Event *event) |
|
354 |
+{ |
|
355 |
+ switch(event->key.keysym.sym) { |
|
356 |
+ case SDLK_F1: return 0x01; |
|
357 |
+ case SDLK_F2: return 0x02; |
|
358 |
+ case SDLK_F3: return 0x04; |
|
359 |
+ case SDLK_F4: return 0x08; |
|
360 |
+ case SDLK_F5: return 0x10; |
|
361 |
+ case SDLK_F6: return 0x20; |
|
362 |
+ case SDLK_F7: return 0x40; |
|
363 |
+ case SDLK_F8: return 0x80; |
|
364 |
+ } |
|
365 |
+ return 0x00; |
|
366 |
+} |
|
367 |
+ |
|
351 | 368 |
static Uint8 |
352 | 369 |
get_button_joystick(SDL_Event *event) |
353 | 370 |
{ |
... | ... |
@@ -442,6 +459,8 @@ run(Uxn *u) |
442 | 459 |
controller_key(devctrl, get_key(&event)); |
443 | 460 |
else if(get_button(&event)) |
444 | 461 |
controller_down(devctrl, get_button(&event)); |
462 |
+ else if(get_fkey(&event)) |
|
463 |
+ controller_special(&supervisor.dev[0x8], get_fkey(&event)); |
|
445 | 464 |
else |
446 | 465 |
do_shortcut(u, &event); |
447 | 466 |
ksym = event.key.keysym.sym; |