| ... | ... |
@@ -2,8 +2,7 @@ |
| 2 | 2 |
#include "controller.h" |
| 3 | 3 |
|
| 4 | 4 |
/* |
| 5 |
-Copyright (c) 2021 Devine Lu Linvega |
|
| 6 |
-Copyright (c) 2021 Andrew Alderwick |
|
| 5 |
+Copyright (c) 2021 Devine Lu Linvega, Andrew Alderwick |
|
| 7 | 6 |
|
| 8 | 7 |
Permission to use, copy, modify, and distribute this software for any |
| 9 | 8 |
purpose with or without fee is hereby granted, provided that the above |
| ... | ... |
@@ -14,39 +13,29 @@ WITH REGARD TO THIS SOFTWARE. |
| 14 | 13 |
*/ |
| 15 | 14 |
|
| 16 | 15 |
void |
| 17 |
-controller_down(Device *d, Uint8 mask) |
|
| 16 |
+controller_down(Uxn *u, Uint8 *d, Uint8 mask) |
|
| 18 | 17 |
{
|
| 19 | 18 |
if(mask) {
|
| 20 |
- d->dat[2] |= mask; |
|
| 21 |
- uxn_eval(d->u, GETVECTOR(d)); |
|
| 19 |
+ d[2] |= mask; |
|
| 20 |
+ uxn_eval(u, GETVEC(d)); |
|
| 22 | 21 |
} |
| 23 | 22 |
} |
| 24 | 23 |
|
| 25 | 24 |
void |
| 26 |
-controller_up(Device *d, Uint8 mask) |
|
| 25 |
+controller_up(Uxn *u, Uint8 *d, Uint8 mask) |
|
| 27 | 26 |
{
|
| 28 | 27 |
if(mask) {
|
| 29 |
- d->dat[2] &= (~mask); |
|
| 30 |
- uxn_eval(d->u, GETVECTOR(d)); |
|
| 28 |
+ d[2] &= (~mask); |
|
| 29 |
+ uxn_eval(u, GETVEC(d)); |
|
| 31 | 30 |
} |
| 32 | 31 |
} |
| 33 | 32 |
|
| 34 | 33 |
void |
| 35 |
-controller_key(Device *d, Uint8 key) |
|
| 34 |
+controller_key(Uxn *u, Uint8 *d, Uint8 key) |
|
| 36 | 35 |
{
|
| 37 | 36 |
if(key) {
|
| 38 |
- d->dat[3] = key; |
|
| 39 |
- uxn_eval(d->u, GETVECTOR(d)); |
|
| 40 |
- d->dat[3] = 0x00; |
|
| 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, GETVECTOR(d)); |
|
| 50 |
- d->dat[4] = 0x00; |
|
| 37 |
+ d[3] = key; |
|
| 38 |
+ uxn_eval(u, GETVEC(d)); |
|
| 39 |
+ d[3] = 0x00; |
|
| 51 | 40 |
} |
| 52 | 41 |
} |
| ... | ... |
@@ -1,6 +1,5 @@ |
| 1 | 1 |
/* |
| 2 |
-Copyright (c) 2021 Devine Lu Linvega |
|
| 3 |
-Copyright (c) 2021 Andrew Alderwick |
|
| 2 |
+Copyright (c) 2021 Devine Lu Linvega, Andrew Alderwick |
|
| 4 | 3 |
|
| 5 | 4 |
Permission to use, copy, modify, and distribute this software for any |
| 6 | 5 |
purpose with or without fee is hereby granted, provided that the above |
| ... | ... |
@@ -10,7 +9,6 @@ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
| 10 | 9 |
WITH REGARD TO THIS SOFTWARE. |
| 11 | 10 |
*/ |
| 12 | 11 |
|
| 13 |
-void controller_down(Device *d, Uint8 mask); |
|
| 14 |
-void controller_up(Device *d, Uint8 mask); |
|
| 15 |
-void controller_key(Device *d, Uint8 key); |
|
| 16 |
-void controller_special(Device *d, Uint8 key); |
|
| 12 |
+void controller_down(Uxn *u, Uint8 *d, Uint8 mask); |
|
| 13 |
+void controller_up(Uxn *u, Uint8 *d, Uint8 mask); |
|
| 14 |
+void controller_key(Uxn *u, Uint8 *d, Uint8 key); |
| ... | ... |
@@ -411,13 +411,13 @@ handle_events(Uxn *u) |
| 411 | 411 |
mouse_scroll(u, devmouse->dat, event.wheel.x, event.wheel.y); |
| 412 | 412 |
/* Controller */ |
| 413 | 413 |
else if(event.type == SDL_TEXTINPUT) |
| 414 |
- controller_key(devctrl, event.text.text[0]); |
|
| 414 |
+ controller_key(u, devctrl->dat, event.text.text[0]); |
|
| 415 | 415 |
else if(event.type == SDL_KEYDOWN) {
|
| 416 | 416 |
int ksym; |
| 417 | 417 |
if(get_key(&event)) |
| 418 |
- controller_key(devctrl, get_key(&event)); |
|
| 418 |
+ controller_key(u, devctrl->dat, get_key(&event)); |
|
| 419 | 419 |
else if(get_button(&event)) |
| 420 |
- controller_down(devctrl, get_button(&event)); |
|
| 420 |
+ controller_down(u, devctrl->dat, get_button(&event)); |
|
| 421 | 421 |
else |
| 422 | 422 |
do_shortcut(u, &event); |
| 423 | 423 |
ksym = event.key.keysym.sym; |
| ... | ... |
@@ -425,17 +425,17 @@ handle_events(Uxn *u) |
| 425 | 425 |
return 1; |
| 426 | 426 |
} |
| 427 | 427 |
} else if(event.type == SDL_KEYUP) |
| 428 |
- controller_up(devctrl, get_button(&event)); |
|
| 428 |
+ controller_up(u, devctrl->dat, get_button(&event)); |
|
| 429 | 429 |
else if(event.type == SDL_JOYAXISMOTION) {
|
| 430 | 430 |
Uint8 vec = get_vector_joystick(&event); |
| 431 | 431 |
if(!vec) |
| 432 |
- controller_up(devctrl, (0x03 << (!event.jaxis.axis * 2)) << 4); |
|
| 432 |
+ controller_up(u, devctrl->dat, (0x03 << (!event.jaxis.axis * 2)) << 4); |
|
| 433 | 433 |
else |
| 434 |
- controller_down(devctrl, (0x01 << ((vec + !event.jaxis.axis * 2) - 1)) << 4); |
|
| 434 |
+ controller_down(u, devctrl->dat, (0x01 << ((vec + !event.jaxis.axis * 2) - 1)) << 4); |
|
| 435 | 435 |
} else if(event.type == SDL_JOYBUTTONDOWN) |
| 436 |
- controller_down(devctrl, get_button_joystick(&event)); |
|
| 436 |
+ controller_down(u, devctrl->dat, get_button_joystick(&event)); |
|
| 437 | 437 |
else if(event.type == SDL_JOYBUTTONUP) |
| 438 |
- controller_up(devctrl, get_button_joystick(&event)); |
|
| 438 |
+ controller_up(u, devctrl->dat, get_button_joystick(&event)); |
|
| 439 | 439 |
/* Console */ |
| 440 | 440 |
else if(event.type == stdin_event) |
| 441 | 441 |
console_input(u, event.cbutton.button); |