|
2 | 2 | // Without DM_WINDOW: the guest runs directly on the current thread, behaving the same as with no front end (windowless tests use this). |
3 | 3 | // The window is fullscreen-capable (the green button and ⌃⌘F); DM_FULLSCREEN=1 starts it that way. ⌘Q quits; the left mouse button is the touchscreen. |
4 | 4 | // Key map (Nintendo layout): WASD left stick, arrow keys D-pad, J=A K=B U=X I=Y, Q=L E=R, Z=ZL C=ZR, F=press left stick G=press right stick, Return=+ Tab=−, Space=shake the controller. |
5 | | -// Controllers: buttons by position as on the iPhone (right A, bottom B, top X, left Y), shoulders L R, triggers ZL ZR, Menu + Options −, both sticks and their presses. |
| 5 | +// Controllers: face buttons as on the iPhone, by position (right A, bottom B, top X, left Y) or on a Nintendo pad by its labels (pad_apple.h), shoulders L R, triggers ZL ZR, Menu + Options −, both sticks and their presses. |
6 | 6 | // Each controller is a player of its own (local co-op): the first one connected is player 1, together with the keyboard, the next player 2, and so on up to 8 (pad_slots.h); |
7 | 7 | // DM_PAD_MERGE=1 merges every controller into player 1 instead, DM_KBD_PLAYER=own makes the keyboard player 1 on its own, with the controllers from player 2 on. |
8 | 8 | #import <Cocoa/Cocoa.h> |
|
17 | 17 | #include "haptics_apple.h" |
18 | 18 | #include "motion_apple.h" |
19 | 19 | #include "motion_pro_mac.h" |
| 20 | +#include "pad_apple.h" |
20 | 21 | #include <signal.h> |
21 | 22 | #include <math.h> |
22 | 23 |
|
@@ -123,9 +124,8 @@ static void pad_read(GCExtendedGamepad *g) { |
123 | 124 | if (!g_input_on) return; |
124 | 125 | int p = g_merge ? 0 : pad_slot_of(&g_slots, (__bridge const void *)g.controller); if (p < 0) return; |
125 | 126 | dm_haptics_apple_controller(p, g.controller); |
126 | | - uint64_t m = 0; |
| 127 | + uint64_t m = dm_pad_face(g); // by position, a Nintendo pad by its labels |
127 | 128 | #define K(btn, bit) if (btn.isPressed) m |= bit |
128 | | - K(g.buttonB, DM_BTN_A); K(g.buttonA, DM_BTN_B); K(g.buttonY, DM_BTN_X); K(g.buttonX, DM_BTN_Y); // by position: right A, bottom B, top X, left Y |
129 | 129 | K(g.leftShoulder, DM_BTN_L); K(g.rightShoulder, DM_BTN_R); K(g.leftTrigger, DM_BTN_ZL); K(g.rightTrigger, DM_BTN_ZR); |
130 | 130 | K(g.buttonMenu, DM_BTN_PLUS); K(g.buttonOptions, DM_BTN_MINUS); K(g.leftThumbstickButton, DM_BTN_LS); K(g.rightThumbstickButton, DM_BTN_RS); // nil on pads without them: not pressed |
131 | 131 | K(g.dpad.left, DM_BTN_LEFT); K(g.dpad.up, DM_BTN_UP); K(g.dpad.right, DM_BTN_RIGHT); K(g.dpad.down, DM_BTN_DOWN); |
|
0 commit comments