mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-15 02:25:32 -04:00
Split up gamepad controller handling
This commit is contained in:
parent
1b6bbbe6cf
commit
80abeb82ab
@ -448,6 +448,8 @@ void Gamepad_SetAxis(int axis, float x, float y, double delta) {
|
||||
|
||||
void Gamepad_Tick(double delta) {
|
||||
int btn;
|
||||
Input.JoystickMovement = false;
|
||||
Window_ProcessGamepads(delta);
|
||||
|
||||
for (btn = GAMEPAD_BEG_BTN; btn < INPUT_COUNT; btn++)
|
||||
{
|
||||
|
@ -273,6 +273,7 @@ void Launcher_Run(void) {
|
||||
|
||||
for (;;) {
|
||||
Window_ProcessEvents(10 / 1000.0);
|
||||
Window_ProcessGamepads(10 / 1000.0);
|
||||
if (!Window_Main.Exists || Launcher_ShouldExit) break;
|
||||
|
||||
Launcher_Active->Tick(Launcher_Active);
|
||||
|
@ -136,6 +136,8 @@ void Window_SetSize(int width, int height);
|
||||
void Window_RequestClose(void);
|
||||
/* Processes all pending window messages/events. */
|
||||
void Window_ProcessEvents(double delta);
|
||||
/* Processes all pending gamepad/joystick input. */
|
||||
void Window_ProcessGamepads(double delta);
|
||||
|
||||
/* Sets the position of the cursor. */
|
||||
/* NOTE: This should be avoided because it is unsupported on some platforms. */
|
||||
|
@ -89,6 +89,43 @@ void Window_RequestClose(void) {
|
||||
/*########################################################################################################################*
|
||||
*----------------------------------------------------Input processing-----------------------------------------------------*
|
||||
*#########################################################################################################################*/
|
||||
static void ProcessTouchInput(int mods) {
|
||||
touchPosition touch;
|
||||
hidTouchRead(&touch);
|
||||
|
||||
if (mods & KEY_TOUCH) {
|
||||
Input_AddTouch(0, touch.px, touch.py);
|
||||
} else if (hidKeysUp() & KEY_TOUCH) {
|
||||
Input_RemoveTouch(0, Pointers[0].x, Pointers[0].y);
|
||||
}
|
||||
}
|
||||
|
||||
void Window_ProcessEvents(double delta) {
|
||||
hidScanInput();
|
||||
|
||||
if (!aptMainLoop()) {
|
||||
Window_Main.Exists = false;
|
||||
Window_RequestClose();
|
||||
return;
|
||||
}
|
||||
|
||||
u32 mods = hidKeysDown() | hidKeysHeld();
|
||||
ProcessTouchInput(mods);
|
||||
}
|
||||
|
||||
void Window_ProcessGamepads(double delta) { }
|
||||
|
||||
void Cursor_SetPosition(int x, int y) { } // Makes no sense for 3DS
|
||||
|
||||
void Window_EnableRawMouse(void) { Input.RawMode = true; }
|
||||
void Window_DisableRawMouse(void) { Input.RawMode = false; }
|
||||
|
||||
void Window_UpdateRawMouse(void) { }
|
||||
|
||||
|
||||
/*########################################################################################################################*
|
||||
*-------------------------------------------------------Gamepads----------------------------------------------------------*
|
||||
*#########################################################################################################################*/
|
||||
static void HandleButtons(u32 mods) {
|
||||
Gamepad_SetButton(CCPAD_L, mods & KEY_L);
|
||||
Gamepad_SetButton(CCPAD_R, mods & KEY_R);
|
||||
@ -119,31 +156,9 @@ static void ProcessCircleInput(int axis, circlePosition* pos, double delta) {
|
||||
Gamepad_SetAxis(axis, pos->dx / AXIS_SCALE, -pos->dy / AXIS_SCALE, delta);
|
||||
}
|
||||
|
||||
static void ProcessTouchInput(int mods) {
|
||||
touchPosition touch;
|
||||
hidTouchRead(&touch);
|
||||
|
||||
if (mods & KEY_TOUCH) {
|
||||
Input_AddTouch(0, touch.px, touch.py);
|
||||
} else if (hidKeysUp() & KEY_TOUCH) {
|
||||
Input_RemoveTouch(0, Pointers[0].x, Pointers[0].y);
|
||||
}
|
||||
}
|
||||
|
||||
void Window_ProcessEvents(double delta) {
|
||||
hidScanInput();
|
||||
Input.JoystickMovement = false;
|
||||
|
||||
if (!aptMainLoop()) {
|
||||
Window_Main.Exists = false;
|
||||
Window_RequestClose();
|
||||
return;
|
||||
}
|
||||
|
||||
void Window_ProcessGamepads(double delta) {
|
||||
u32 mods = hidKeysDown() | hidKeysHeld();
|
||||
HandleButtons(mods);
|
||||
|
||||
ProcessTouchInput(mods);
|
||||
|
||||
circlePosition hid_pos;
|
||||
hidCircleRead(&hid_pos);
|
||||
@ -160,12 +175,6 @@ void Window_ProcessEvents(double delta) {
|
||||
}
|
||||
}
|
||||
|
||||
void Cursor_SetPosition(int x, int y) { } // Makes no sense for 3DS
|
||||
|
||||
void Window_EnableRawMouse(void) { Input.RawMode = true; }
|
||||
void Window_DisableRawMouse(void) { Input.RawMode = false; }
|
||||
|
||||
void Window_UpdateRawMouse(void) { }
|
||||
|
||||
/*########################################################################################################################*
|
||||
*------------------------------------------------------Framebuffer--------------------------------------------------------*
|
||||
|
@ -373,6 +373,8 @@ void Window_ProcessEvents(double delta) {
|
||||
JavaICall_Void(env, JAVA_processEvents, NULL);
|
||||
}
|
||||
|
||||
void Window_ProcessGamepads(double delta) { }
|
||||
|
||||
/* No actual mouse cursor */
|
||||
static void Cursor_GetRawPos(int* x, int* y) { *x = 0; *y = 0; }
|
||||
void Cursor_SetPosition(int x, int y) { }
|
||||
|
@ -173,6 +173,41 @@ static void ProcessKeyboardInput(void) {
|
||||
/*########################################################################################################################*
|
||||
*----------------------------------------------------Input processing-----------------------------------------------------*
|
||||
*#########################################################################################################################*/
|
||||
static void ProcessMouseInput(double delta) {
|
||||
maple_device_t* mouse;
|
||||
mouse_state_t* state;
|
||||
|
||||
mouse = maple_enum_type(0, MAPLE_FUNC_MOUSE);
|
||||
if (!mouse) return;
|
||||
state = (mouse_state_t*)maple_dev_status(mouse);
|
||||
if (!state) return;
|
||||
|
||||
int mods = state->buttons;
|
||||
Input_SetNonRepeatable(CCMOUSE_L, mods & MOUSE_LEFTBUTTON);
|
||||
Input_SetNonRepeatable(CCMOUSE_R, mods & MOUSE_RIGHTBUTTON);
|
||||
Input_SetNonRepeatable(CCMOUSE_M, mods & MOUSE_SIDEBUTTON);
|
||||
|
||||
if (!Input.RawMode) return;
|
||||
float scale = (delta * 60.0) / 2.0f;
|
||||
Event_RaiseRawMove(&PointerEvents.RawMoved,
|
||||
state->dx * scale, state->dy * scale);
|
||||
}
|
||||
|
||||
void Window_ProcessEvents(double delta) {
|
||||
ProcessKeyboardInput();
|
||||
ProcessMouseInput(delta);
|
||||
}
|
||||
|
||||
void Cursor_SetPosition(int x, int y) { } /* TODO: Dreamcast mouse support */
|
||||
|
||||
void Window_EnableRawMouse(void) { Input.RawMode = true; }
|
||||
void Window_DisableRawMouse(void) { Input.RawMode = false; }
|
||||
void Window_UpdateRawMouse(void) { }
|
||||
|
||||
|
||||
/*########################################################################################################################*
|
||||
*-------------------------------------------------------Gamepads----------------------------------------------------------*
|
||||
*#########################################################################################################################*/
|
||||
static void HandleButtons(int mods) {
|
||||
// TODO CONT_Z
|
||||
|
||||
@ -206,7 +241,7 @@ static void HandleController(cont_state_t* state, double delta) {
|
||||
HandleJoystick(PAD_AXIS_RIGHT, state->joyx, state->joyy, delta);
|
||||
}
|
||||
|
||||
static void ProcessControllerInput(double delta) {
|
||||
void Window_ProcessGamepads(double delta) {
|
||||
maple_device_t* cont;
|
||||
cont_state_t* state;
|
||||
|
||||
@ -219,38 +254,6 @@ static void ProcessControllerInput(double delta) {
|
||||
HandleController(state, delta);
|
||||
}
|
||||
|
||||
static void ProcessMouseInput(double delta) {
|
||||
maple_device_t* mouse;
|
||||
mouse_state_t* state;
|
||||
|
||||
mouse = maple_enum_type(0, MAPLE_FUNC_MOUSE);
|
||||
if (!mouse) return;
|
||||
state = (mouse_state_t*)maple_dev_status(mouse);
|
||||
if (!state) return;
|
||||
|
||||
int mods = state->buttons;
|
||||
Input_SetNonRepeatable(CCMOUSE_L, mods & MOUSE_LEFTBUTTON);
|
||||
Input_SetNonRepeatable(CCMOUSE_R, mods & MOUSE_RIGHTBUTTON);
|
||||
Input_SetNonRepeatable(CCMOUSE_M, mods & MOUSE_SIDEBUTTON);
|
||||
|
||||
if (!Input.RawMode) return;
|
||||
float scale = (delta * 60.0) / 2.0f;
|
||||
Event_RaiseRawMove(&PointerEvents.RawMoved,
|
||||
state->dx * scale, state->dy * scale);
|
||||
}
|
||||
|
||||
void Window_ProcessEvents(double delta) {
|
||||
ProcessControllerInput(delta);
|
||||
ProcessKeyboardInput();
|
||||
ProcessMouseInput(delta);
|
||||
}
|
||||
|
||||
void Cursor_SetPosition(int x, int y) { } /* TODO: Dreamcast mouse support */
|
||||
|
||||
void Window_EnableRawMouse(void) { Input.RawMode = true; }
|
||||
void Window_DisableRawMouse(void) { Input.RawMode = false; }
|
||||
void Window_UpdateRawMouse(void) { }
|
||||
|
||||
|
||||
/*########################################################################################################################*
|
||||
*------------------------------------------------------Framebuffer--------------------------------------------------------*
|
||||
|
@ -225,6 +225,84 @@ static int dragCurX, dragCurY;
|
||||
static int dragStartX, dragStartY;
|
||||
static cc_bool dragActive;
|
||||
|
||||
void Window_ProcessEvents(double delta) {
|
||||
ProcessKeyboardInput();
|
||||
}
|
||||
|
||||
static void GetIRPos(int res, int* x, int* y) {
|
||||
if (res == WPAD_ERR_NONE) {
|
||||
WPADData* wd = WPAD_Data(0);
|
||||
|
||||
*x = wd->ir.x;
|
||||
*y = wd->ir.y;
|
||||
} else {
|
||||
*x = 0;
|
||||
*y = 0;
|
||||
}
|
||||
}
|
||||
|
||||
static void ScanAndGetIRPos(int* x, int* y) {
|
||||
u32 type;
|
||||
WPAD_ScanPads();
|
||||
|
||||
int res = WPAD_Probe(0, &type);
|
||||
GetIRPos(res, x, y);
|
||||
}
|
||||
|
||||
|
||||
static void ProcessWPADDrag(u32 mods) {
|
||||
int x, y;
|
||||
GetIRPos(res, &x, &y);
|
||||
|
||||
if (mods & WPAD_BUTTON_B) {
|
||||
if (!dragActive) {
|
||||
dragStartX = dragCurX = x;
|
||||
dragStartY = dragCurY = y;
|
||||
}
|
||||
dragActive = true;
|
||||
} else {
|
||||
dragActive = false;
|
||||
}
|
||||
Pointer_SetPosition(0, x, y);
|
||||
}
|
||||
|
||||
#define FACTOR 2
|
||||
void Window_UpdateRawMouse(void) {
|
||||
if (!dragActive) return;
|
||||
int x, y;
|
||||
ScanAndGetIRPos(&x, &y);
|
||||
|
||||
// TODO: Refactor the logic. is it 100% right too?
|
||||
dragCurX = dragStartX + (dragCurX - dragStartX) / FACTOR;
|
||||
dragCurY = dragStartY + (dragCurY - dragStartY) / FACTOR;
|
||||
|
||||
int dx = x - dragCurX; Math_Clamp(dx, -40, 40);
|
||||
int dy = y - dragCurY; Math_Clamp(dy, -40, 40);
|
||||
Event_RaiseRawMove(&PointerEvents.RawMoved, dx, dy);
|
||||
|
||||
dragCurX = x; dragCurY = y;
|
||||
}
|
||||
#else
|
||||
void Window_ProcessEvents(double delta) {
|
||||
}
|
||||
|
||||
void Window_UpdateRawMouse(void) { }
|
||||
#endif
|
||||
|
||||
void Cursor_SetPosition(int x, int y) { } // No point in GameCube/Wii
|
||||
// TODO: Display cursor on Wii when not raw mode
|
||||
void Window_EnableRawMouse(void) { Input.RawMode = true; }
|
||||
void Window_DisableRawMouse(void) { Input.RawMode = false; }
|
||||
|
||||
|
||||
/*########################################################################################################################*
|
||||
*-------------------------------------------------------Gamepads----------------------------------------------------------*
|
||||
*#########################################################################################################################*/
|
||||
#if defined HW_RVL
|
||||
static int dragCurX, dragCurY;
|
||||
static int dragStartX, dragStartY;
|
||||
static cc_bool dragActive;
|
||||
|
||||
static void ProcessWPAD_Buttons(int mods) {
|
||||
Gamepad_SetButton(CCPAD_L, mods & WPAD_BUTTON_1);
|
||||
Gamepad_SetButton(CCPAD_R, mods & WPAD_BUTTON_2);
|
||||
@ -320,20 +398,7 @@ static void ProcessClassicInput(double delta) {
|
||||
ProcessClassic_Joystick(PAD_AXIS_RIGHT, &ctrls.rjs, delta);
|
||||
}
|
||||
|
||||
|
||||
static void GetIRPos(int res, int* x, int* y) {
|
||||
if (res == WPAD_ERR_NONE) {
|
||||
WPADData* wd = WPAD_Data(0);
|
||||
|
||||
*x = wd->ir.x;
|
||||
*y = wd->ir.y;
|
||||
} else {
|
||||
*x = 0;
|
||||
*y = 0;
|
||||
}
|
||||
}
|
||||
|
||||
static void ProcessWPADInput(double delta) {
|
||||
static void ProcessWPADInput(double delta) {
|
||||
WPAD_ScanPads();
|
||||
u32 mods = WPAD_ButtonsDown(0) | WPAD_ButtonsHeld(0);
|
||||
u32 type;
|
||||
@ -350,68 +415,19 @@ static void ProcessWPADInput(double delta) {
|
||||
ProcessWPAD_Buttons(mods);
|
||||
}
|
||||
|
||||
int x, y;
|
||||
GetIRPos(res, &x, &y);
|
||||
|
||||
if (mods & WPAD_BUTTON_B) {
|
||||
if (!dragActive) {
|
||||
dragStartX = dragCurX = x;
|
||||
dragStartY = dragCurY = y;
|
||||
}
|
||||
dragActive = true;
|
||||
} else {
|
||||
dragActive = false;
|
||||
}
|
||||
Pointer_SetPosition(0, x, y);
|
||||
ProcessWPADDrag(mods);
|
||||
}
|
||||
|
||||
void Window_ProcessEvents(double delta) {
|
||||
Input.JoystickMovement = false;
|
||||
Input.Sources = INPUT_SOURCE_GAMEPAD;
|
||||
|
||||
void Window_ProcessGamepads(double delta) {
|
||||
ProcessWPADInput(delta);
|
||||
ProcessPADInput(delta);
|
||||
ProcessKeyboardInput();
|
||||
}
|
||||
|
||||
static void ScanAndGetIRPos(int* x, int* y) {
|
||||
u32 type;
|
||||
WPAD_ScanPads();
|
||||
|
||||
int res = WPAD_Probe(0, &type);
|
||||
GetIRPos(res, x, y);
|
||||
}
|
||||
#define FACTOR 2
|
||||
void Window_UpdateRawMouse(void) {
|
||||
if (!dragActive) return;
|
||||
int x, y;
|
||||
ScanAndGetIRPos(&x, &y);
|
||||
|
||||
// TODO: Refactor the logic. is it 100% right too?
|
||||
dragCurX = dragStartX + (dragCurX - dragStartX) / FACTOR;
|
||||
dragCurY = dragStartY + (dragCurY - dragStartY) / FACTOR;
|
||||
|
||||
int dx = x - dragCurX; Math_Clamp(dx, -40, 40);
|
||||
int dy = y - dragCurY; Math_Clamp(dy, -40, 40);
|
||||
Event_RaiseRawMove(&PointerEvents.RawMoved, dx, dy);
|
||||
|
||||
dragCurX = x; dragCurY = y;
|
||||
}
|
||||
#else
|
||||
void Window_ProcessEvents(double delta) {
|
||||
Input.JoystickMovement = false;
|
||||
|
||||
void Window_ProcessGamepads(double delta) {
|
||||
ProcessPADInput(delta);
|
||||
}
|
||||
|
||||
void Window_UpdateRawMouse(void) { }
|
||||
#endif
|
||||
|
||||
void Cursor_SetPosition(int x, int y) { } // No point in GameCube/Wii
|
||||
// TODO: Display cursor on Wii when not raw mode
|
||||
void Window_EnableRawMouse(void) { Input.RawMode = true; }
|
||||
void Window_DisableRawMouse(void) { Input.RawMode = false; }
|
||||
|
||||
|
||||
/*########################################################################################################################*
|
||||
*------------------------------------------------------Framebuffer--------------------------------------------------------*
|
||||
|
@ -74,6 +74,19 @@ void Window_RequestClose(void) {
|
||||
/*########################################################################################################################*
|
||||
*----------------------------------------------------Input processing-----------------------------------------------------*
|
||||
*#########################################################################################################################*/
|
||||
void Window_ProcessEvents(double delta) {
|
||||
joypad_poll();
|
||||
}
|
||||
|
||||
void Cursor_SetPosition(int x, int y) { } // Makes no sense for PSP
|
||||
void Window_EnableRawMouse(void) { Input.RawMode = true; }
|
||||
void Window_DisableRawMouse(void) { Input.RawMode = false; }
|
||||
void Window_UpdateRawMouse(void) { }
|
||||
|
||||
|
||||
/*########################################################################################################################*
|
||||
*-------------------------------------------------------Gamepads----------------------------------------------------------*
|
||||
*#########################################################################################################################*/
|
||||
static void HandleButtons(joypad_buttons_t btns) {
|
||||
Gamepad_SetButton(CCPAD_L, btns.l);
|
||||
Gamepad_SetButton(CCPAD_R, btns.r);
|
||||
@ -106,19 +119,12 @@ static void ProcessAnalogInput(joypad_inputs_t* inputs, double delta) {
|
||||
Gamepad_SetAxis(PAD_AXIS_RIGHT, x / AXIS_SCALE, -y / AXIS_SCALE, delta);
|
||||
}
|
||||
|
||||
void Window_ProcessEvents(double delta) {
|
||||
joypad_poll();
|
||||
|
||||
void Window_ProcessGamepads(double delta) {
|
||||
joypad_inputs_t inputs = joypad_get_inputs(JOYPAD_PORT_1);
|
||||
HandleButtons(inputs.btn);
|
||||
ProcessAnalogInput(&inputs, delta);
|
||||
}
|
||||
|
||||
void Cursor_SetPosition(int x, int y) { } // Makes no sense for PSP
|
||||
void Window_EnableRawMouse(void) { Input.RawMode = true; }
|
||||
void Window_DisableRawMouse(void) { Input.RawMode = false; }
|
||||
void Window_UpdateRawMouse(void) { }
|
||||
|
||||
|
||||
/*########################################################################################################################*
|
||||
*------------------------------------------------------Framebuffer--------------------------------------------------------*
|
||||
|
@ -97,7 +97,41 @@ void Window_RequestClose(void) {
|
||||
/*########################################################################################################################*
|
||||
*----------------------------------------------------Input processing-----------------------------------------------------*
|
||||
*#########################################################################################################################*/
|
||||
static void HandleButtons(int mods) {
|
||||
static void ProcessTouchInput(int mods) {
|
||||
touchPosition touch;
|
||||
touchRead(&touch);
|
||||
Camera.Sensitivity = 100; // TODO not hardcode this
|
||||
|
||||
if (mods & KEY_TOUCH) {
|
||||
Input_AddTouch(0, touch.px, touch.py);
|
||||
} else if (keysUp() & KEY_TOUCH) {
|
||||
Input_RemoveTouch(0, Pointers[0].x, Pointers[0].y);
|
||||
}
|
||||
}
|
||||
|
||||
void Window_ProcessEvents(double delta) {
|
||||
scanKeys();
|
||||
|
||||
if (keyboardOpen) {
|
||||
keyboardUpdate();
|
||||
} else {
|
||||
ProcessTouchInput(keys);
|
||||
}
|
||||
}
|
||||
|
||||
void Cursor_SetPosition(int x, int y) { } // Makes no sense for PSP
|
||||
void Window_EnableRawMouse(void) { Input.RawMode = true; }
|
||||
void Window_DisableRawMouse(void) { Input.RawMode = false; }
|
||||
|
||||
void Window_UpdateRawMouse(void) { }
|
||||
|
||||
|
||||
/*########################################################################################################################*
|
||||
*-------------------------------------------------------Gamepads----------------------------------------------------------*
|
||||
*#########################################################################################################################*/
|
||||
void Window_ProcessGamepads(double delta) {
|
||||
int mods = keysDown() | keysHeld();
|
||||
|
||||
Gamepad_SetButton(CCPAD_L, mods & KEY_L);
|
||||
Gamepad_SetButton(CCPAD_R, mods & KEY_R);
|
||||
|
||||
@ -115,36 +149,6 @@ static void HandleButtons(int mods) {
|
||||
Gamepad_SetButton(CCPAD_DOWN, mods & KEY_DOWN);
|
||||
}
|
||||
|
||||
static void ProcessTouchInput(int mods) {
|
||||
touchPosition touch;
|
||||
touchRead(&touch);
|
||||
Camera.Sensitivity = 100; // TODO not hardcode this
|
||||
|
||||
if (mods & KEY_TOUCH) {
|
||||
Input_AddTouch(0, touch.px, touch.py);
|
||||
} else if (keysUp() & KEY_TOUCH) {
|
||||
Input_RemoveTouch(0, Pointers[0].x, Pointers[0].y);
|
||||
}
|
||||
}
|
||||
|
||||
void Window_ProcessEvents(double delta) {
|
||||
scanKeys();
|
||||
int keys = keysDown() | keysHeld();
|
||||
HandleButtons(keys);
|
||||
|
||||
if (keyboardOpen) {
|
||||
keyboardUpdate();
|
||||
} else {
|
||||
ProcessTouchInput(keys);
|
||||
}
|
||||
}
|
||||
|
||||
void Cursor_SetPosition(int x, int y) { } // Makes no sense for PSP
|
||||
void Window_EnableRawMouse(void) { Input.RawMode = true; }
|
||||
void Window_DisableRawMouse(void) { Input.RawMode = false; }
|
||||
|
||||
void Window_UpdateRawMouse(void) { }
|
||||
|
||||
|
||||
/*########################################################################################################################*
|
||||
*------------------------------------------------------Framebuffer--------------------------------------------------------*
|
||||
|
@ -78,6 +78,19 @@ void Window_RequestClose(void) {
|
||||
/*########################################################################################################################*
|
||||
*----------------------------------------------------Input processing-----------------------------------------------------*
|
||||
*#########################################################################################################################*/
|
||||
void Window_ProcessEvents(double delta) {
|
||||
}
|
||||
|
||||
void Cursor_SetPosition(int x, int y) { } // Makes no sense for PS Vita
|
||||
|
||||
void Window_EnableRawMouse(void) { Input.RawMode = true; }
|
||||
void Window_UpdateRawMouse(void) { }
|
||||
void Window_DisableRawMouse(void) { Input.RawMode = false; }
|
||||
|
||||
|
||||
/*########################################################################################################################*
|
||||
*-------------------------------------------------------Gamepads----------------------------------------------------------*
|
||||
*#########################################################################################################################*/
|
||||
static void HandleButtons(int buttons) {
|
||||
// Confusingly, it seems that when a bit is on, it means the button is NOT pressed
|
||||
// So just flip the bits to make more sense
|
||||
@ -119,17 +132,11 @@ static void ProcessPadInput(PADTYPE* pad, double delta) {
|
||||
}
|
||||
}
|
||||
|
||||
void Window_ProcessEvents(double delta) {
|
||||
void Window_ProcessGamepads(double delta) {
|
||||
PADTYPE* pad = (PADTYPE*)&pad_buff[0][0];
|
||||
if (pad->stat == 0) ProcessPadInput(pad, delta);
|
||||
}
|
||||
|
||||
void Cursor_SetPosition(int x, int y) { } // Makes no sense for PS Vita
|
||||
|
||||
void Window_EnableRawMouse(void) { Input.RawMode = true; }
|
||||
void Window_UpdateRawMouse(void) { }
|
||||
void Window_DisableRawMouse(void) { Input.RawMode = false; }
|
||||
|
||||
|
||||
/*########################################################################################################################*
|
||||
*------------------------------------------------------Framebuffer--------------------------------------------------------*
|
||||
|
@ -84,6 +84,19 @@ void Window_RequestClose(void) {
|
||||
/*########################################################################################################################*
|
||||
*----------------------------------------------------Input processing-----------------------------------------------------*
|
||||
*#########################################################################################################################*/
|
||||
void Window_ProcessEvents(double delta) {
|
||||
}
|
||||
|
||||
void Cursor_SetPosition(int x, int y) { } // Makes no sense for PS Vita
|
||||
|
||||
void Window_EnableRawMouse(void) { Input.RawMode = true; }
|
||||
void Window_UpdateRawMouse(void) { }
|
||||
void Window_DisableRawMouse(void) { Input.RawMode = false; }
|
||||
|
||||
|
||||
/*########################################################################################################################*
|
||||
*-------------------------------------------------------Gamepads----------------------------------------------------------*
|
||||
*#########################################################################################################################*/
|
||||
static void HandleButtons(int buttons) {
|
||||
// Confusingly, it seems that when a bit is on, it means the button is NOT pressed
|
||||
// So just flip the bits to make more sense
|
||||
@ -124,9 +137,8 @@ static void ProcessPadInput(double delta, struct padButtonStatus* pad) {
|
||||
}
|
||||
|
||||
static cc_bool setMode;
|
||||
void Window_ProcessEvents(double delta) {
|
||||
void Window_ProcessGamepads(double delta) {
|
||||
struct padButtonStatus pad;
|
||||
Input.JoystickMovement = false;
|
||||
|
||||
int state = padGetState(0, 0);
|
||||
if (state != PAD_STATE_STABLE) return;
|
||||
@ -141,12 +153,6 @@ void Window_ProcessEvents(double delta) {
|
||||
if (ret != 0) ProcessPadInput(delta, &pad);
|
||||
}
|
||||
|
||||
void Cursor_SetPosition(int x, int y) { } // Makes no sense for PS Vita
|
||||
|
||||
void Window_EnableRawMouse(void) { Input.RawMode = true; }
|
||||
void Window_UpdateRawMouse(void) { }
|
||||
void Window_DisableRawMouse(void) { Input.RawMode = false; }
|
||||
|
||||
|
||||
/*########################################################################################################################*
|
||||
*------------------------------------------------------Framebuffer--------------------------------------------------------*
|
||||
|
@ -252,6 +252,21 @@ static void ProcessKBInput(void) {
|
||||
/*########################################################################################################################*
|
||||
*----------------------------------------------------Input processing-----------------------------------------------------*
|
||||
*#########################################################################################################################*/
|
||||
void Window_ProcessEvents(double delta) {
|
||||
ioKbGetInfo(&kb_info);
|
||||
if (kb_info.status[0]) ProcessKBInput();
|
||||
}
|
||||
|
||||
void Cursor_SetPosition(int x, int y) { } // Makes no sense for PS Vita
|
||||
|
||||
void Window_EnableRawMouse(void) { Input.RawMode = true; }
|
||||
void Window_UpdateRawMouse(void) { }
|
||||
void Window_DisableRawMouse(void) { Input.RawMode = false; }
|
||||
|
||||
|
||||
/*########################################################################################################################*
|
||||
*-------------------------------------------------------Gamepads----------------------------------------------------------*
|
||||
*#########################################################################################################################*/
|
||||
static void HandleButtons(padData* data) {
|
||||
//Platform_Log2("BUTTONS: %h (%h)", &data->button[2], &data->button[0]);
|
||||
Gamepad_SetButton(CCPAD_A, data->BTN_TRIANGLE);
|
||||
@ -287,25 +302,14 @@ static void ProcessPadInput(double delta, padData* pad) {
|
||||
HandleJoystick(PAD_AXIS_RIGHT, pad->ANA_R_H - 0x80, pad->ANA_R_V - 0x80, delta);
|
||||
}
|
||||
|
||||
void Window_ProcessEvents(double delta) {
|
||||
Input.JoystickMovement = false;
|
||||
|
||||
void Window_ProcessGamepads(double delta) {
|
||||
ioPadGetInfo(&pad_info);
|
||||
if (pad_info.status[0]) {
|
||||
ioPadGetData(0, &pad_data);
|
||||
ProcessPadInput(delta, &pad_data);
|
||||
}
|
||||
|
||||
ioKbGetInfo(&kb_info);
|
||||
if (kb_info.status[0]) ProcessKBInput();
|
||||
}
|
||||
|
||||
void Cursor_SetPosition(int x, int y) { } // Makes no sense for PS Vita
|
||||
|
||||
void Window_EnableRawMouse(void) { Input.RawMode = true; }
|
||||
void Window_UpdateRawMouse(void) { }
|
||||
void Window_DisableRawMouse(void) { Input.RawMode = false; }
|
||||
|
||||
|
||||
/*########################################################################################################################*
|
||||
*------------------------------------------------------Framebuffer--------------------------------------------------------*
|
||||
|
@ -67,6 +67,18 @@ void Window_RequestClose(void) {
|
||||
/*########################################################################################################################*
|
||||
*----------------------------------------------------Input processing-----------------------------------------------------*
|
||||
*#########################################################################################################################*/
|
||||
void Window_ProcessEvents(double delta) {
|
||||
}
|
||||
|
||||
void Cursor_SetPosition(int x, int y) { } // Makes no sense for PSP
|
||||
void Window_EnableRawMouse(void) { Input.RawMode = true; }
|
||||
void Window_DisableRawMouse(void) { Input.RawMode = false; }
|
||||
void Window_UpdateRawMouse(void) { }
|
||||
|
||||
|
||||
/*########################################################################################################################*
|
||||
*-------------------------------------------------------Gamepads----------------------------------------------------------*
|
||||
*#########################################################################################################################*/
|
||||
static void HandleButtons(int mods) {
|
||||
Gamepad_SetButton(CCPAD_L, mods & PSP_CTRL_LTRIGGER);
|
||||
Gamepad_SetButton(CCPAD_R, mods & PSP_CTRL_RTRIGGER);
|
||||
@ -96,7 +108,7 @@ static void ProcessCircleInput(SceCtrlData* pad, double delta) {
|
||||
Gamepad_SetAxis(PAD_AXIS_RIGHT, x / AXIS_SCALE, y / AXIS_SCALE, delta);
|
||||
}
|
||||
|
||||
void Window_ProcessEvents(double delta) {
|
||||
void Window_ProcessGamepads(double delta) {
|
||||
SceCtrlData pad;
|
||||
/* TODO implement */
|
||||
int ret = sceCtrlPeekBufferPositive(&pad, 1);
|
||||
@ -107,11 +119,6 @@ void Window_ProcessEvents(double delta) {
|
||||
ProcessCircleInput(&pad, delta);
|
||||
}
|
||||
|
||||
void Cursor_SetPosition(int x, int y) { } // Makes no sense for PSP
|
||||
void Window_EnableRawMouse(void) { Input.RawMode = true; }
|
||||
void Window_DisableRawMouse(void) { Input.RawMode = false; }
|
||||
void Window_UpdateRawMouse(void) { }
|
||||
|
||||
|
||||
/*########################################################################################################################*
|
||||
*------------------------------------------------------Framebuffer--------------------------------------------------------*
|
||||
|
@ -86,33 +86,6 @@ void Window_RequestClose(void) {
|
||||
/*########################################################################################################################*
|
||||
*----------------------------------------------------Input processing-----------------------------------------------------*
|
||||
*#########################################################################################################################*/
|
||||
static void HandleButtons(int mods) {
|
||||
Gamepad_SetButton(CCPAD_A, mods & SCE_CTRL_TRIANGLE);
|
||||
Gamepad_SetButton(CCPAD_B, mods & SCE_CTRL_SQUARE);
|
||||
Gamepad_SetButton(CCPAD_X, mods & SCE_CTRL_CROSS);
|
||||
Gamepad_SetButton(CCPAD_Y, mods & SCE_CTRL_CIRCLE);
|
||||
|
||||
Gamepad_SetButton(CCPAD_START, mods & SCE_CTRL_START);
|
||||
Gamepad_SetButton(CCPAD_SELECT, mods & SCE_CTRL_SELECT);
|
||||
|
||||
Gamepad_SetButton(CCPAD_LEFT, mods & SCE_CTRL_LEFT);
|
||||
Gamepad_SetButton(CCPAD_RIGHT, mods & SCE_CTRL_RIGHT);
|
||||
Gamepad_SetButton(CCPAD_UP, mods & SCE_CTRL_UP);
|
||||
Gamepad_SetButton(CCPAD_DOWN, mods & SCE_CTRL_DOWN);
|
||||
|
||||
Gamepad_SetButton(CCPAD_L, mods & SCE_CTRL_LTRIGGER);
|
||||
Gamepad_SetButton(CCPAD_R, mods & SCE_CTRL_RTRIGGER);
|
||||
}
|
||||
|
||||
#define AXIS_SCALE 16.0f
|
||||
static void ProcessCircleInput(int axis, int x, int y, double delta) {
|
||||
// May not be exactly 0 on actual hardware
|
||||
if (Math_AbsI(x) <= 8) x = 0;
|
||||
if (Math_AbsI(y) <= 8) y = 0;
|
||||
|
||||
Gamepad_SetAxis(axis, x / AXIS_SCALE, y / AXIS_SCALE, delta);
|
||||
}
|
||||
|
||||
static void AdjustTouchPress(int* x, int* y) {
|
||||
if (!frontPanel.maxDispX || !frontPanel.maxDispY) return;
|
||||
// TODO: Shouldn't ever happen? need to check
|
||||
@ -146,6 +119,47 @@ static void ProcessTouchInput(void) {
|
||||
}
|
||||
}
|
||||
|
||||
void Window_ProcessEvents(double delta) {
|
||||
ProcessTouchInput();
|
||||
}
|
||||
|
||||
void Cursor_SetPosition(int x, int y) { } // Makes no sense for PS Vita
|
||||
|
||||
void Window_EnableRawMouse(void) { Input.RawMode = true; }
|
||||
void Window_UpdateRawMouse(void) { }
|
||||
void Window_DisableRawMouse(void) { Input.RawMode = false; }
|
||||
|
||||
|
||||
/*########################################################################################################################*
|
||||
*-------------------------------------------------------Gamepads----------------------------------------------------------*
|
||||
*#########################################################################################################################*/
|
||||
static void HandleButtons(int mods) {
|
||||
Gamepad_SetButton(CCPAD_A, mods & SCE_CTRL_TRIANGLE);
|
||||
Gamepad_SetButton(CCPAD_B, mods & SCE_CTRL_SQUARE);
|
||||
Gamepad_SetButton(CCPAD_X, mods & SCE_CTRL_CROSS);
|
||||
Gamepad_SetButton(CCPAD_Y, mods & SCE_CTRL_CIRCLE);
|
||||
|
||||
Gamepad_SetButton(CCPAD_START, mods & SCE_CTRL_START);
|
||||
Gamepad_SetButton(CCPAD_SELECT, mods & SCE_CTRL_SELECT);
|
||||
|
||||
Gamepad_SetButton(CCPAD_LEFT, mods & SCE_CTRL_LEFT);
|
||||
Gamepad_SetButton(CCPAD_RIGHT, mods & SCE_CTRL_RIGHT);
|
||||
Gamepad_SetButton(CCPAD_UP, mods & SCE_CTRL_UP);
|
||||
Gamepad_SetButton(CCPAD_DOWN, mods & SCE_CTRL_DOWN);
|
||||
|
||||
Gamepad_SetButton(CCPAD_L, mods & SCE_CTRL_LTRIGGER);
|
||||
Gamepad_SetButton(CCPAD_R, mods & SCE_CTRL_RTRIGGER);
|
||||
}
|
||||
|
||||
#define AXIS_SCALE 16.0f
|
||||
static void ProcessCircleInput(int axis, int x, int y, double delta) {
|
||||
// May not be exactly 0 on actual hardware
|
||||
if (Math_AbsI(x) <= 8) x = 0;
|
||||
if (Math_AbsI(y) <= 8) y = 0;
|
||||
|
||||
Gamepad_SetAxis(axis, x / AXIS_SCALE, y / AXIS_SCALE, delta);
|
||||
}
|
||||
|
||||
static void ProcessPadInput(double delta) {
|
||||
SceCtrlData pad;
|
||||
|
||||
@ -160,19 +174,10 @@ static void ProcessPadInput(double delta) {
|
||||
ProcessCircleInput(PAD_AXIS_RIGHT, pad.rx - 127, pad.ry - 127, delta);
|
||||
}
|
||||
|
||||
void Window_ProcessEvents(double delta) {
|
||||
Input.JoystickMovement = false;
|
||||
|
||||
void Window_ProcessGamepads(double delta) {
|
||||
ProcessPadInput(delta);
|
||||
ProcessTouchInput();
|
||||
}
|
||||
|
||||
void Cursor_SetPosition(int x, int y) { } // Makes no sense for PS Vita
|
||||
|
||||
void Window_EnableRawMouse(void) { Input.RawMode = true; }
|
||||
void Window_UpdateRawMouse(void) { }
|
||||
void Window_DisableRawMouse(void) { Input.RawMode = false; }
|
||||
|
||||
|
||||
/*########################################################################################################################*
|
||||
*------------------------------------------------------Framebuffer--------------------------------------------------------*
|
||||
|
@ -295,6 +295,8 @@ void Window_ProcessEvents(double delta) {
|
||||
}
|
||||
}
|
||||
|
||||
void Window_ProcessGamepads(double delta) { }
|
||||
|
||||
static void Cursor_GetRawPos(int* x, int* y) {
|
||||
SDL_GetMouseState(x, y);
|
||||
}
|
||||
|
@ -281,6 +281,8 @@ void Window_ProcessEvents(double delta) {
|
||||
}
|
||||
}
|
||||
|
||||
void Window_ProcessGamepads(double delta) { }
|
||||
|
||||
static void Cursor_GetRawPos(int* x, int* y) {
|
||||
float xPos, yPos;
|
||||
SDL_GetMouseState(&xPos, &yPos);
|
||||
|
@ -78,6 +78,20 @@ void Window_RequestClose(void) {
|
||||
/*########################################################################################################################*
|
||||
*----------------------------------------------------Input processing-----------------------------------------------------*
|
||||
*#########################################################################################################################*/
|
||||
void Window_ProcessEvents(double delta) {
|
||||
smpc_peripheral_process();
|
||||
}
|
||||
|
||||
void Cursor_SetPosition(int x, int y) { } // Makes no sense for PS Vita
|
||||
|
||||
void Window_EnableRawMouse(void) { Input.RawMode = true; }
|
||||
void Window_UpdateRawMouse(void) { }
|
||||
void Window_DisableRawMouse(void) { Input.RawMode = false; }
|
||||
|
||||
|
||||
/*########################################################################################################################*
|
||||
*-------------------------------------------------------Gamepads----------------------------------------------------------*
|
||||
*#########################################################################################################################*/
|
||||
static void ProcessButtons(int mods) {
|
||||
Gamepad_SetButton(CCPAD_A, mods & PERIPHERAL_DIGITAL_A);
|
||||
Gamepad_SetButton(CCPAD_B, mods & PERIPHERAL_DIGITAL_B);
|
||||
@ -95,19 +109,11 @@ static void ProcessButtons(int mods) {
|
||||
Gamepad_SetButton(CCPAD_DOWN, mods & PERIPHERAL_DIGITAL_DOWN);
|
||||
}
|
||||
|
||||
void Window_ProcessEvents(double delta) {
|
||||
smpc_peripheral_process();
|
||||
void Window_ProcessGamepads(double delta) {
|
||||
smpc_peripheral_digital_port(1, &state);
|
||||
|
||||
ProcessButtons(state.pressed.raw | state.held.raw);
|
||||
}
|
||||
|
||||
void Cursor_SetPosition(int x, int y) { } // Makes no sense for PS Vita
|
||||
|
||||
void Window_EnableRawMouse(void) { Input.RawMode = true; }
|
||||
void Window_UpdateRawMouse(void) { }
|
||||
void Window_DisableRawMouse(void) { Input.RawMode = false; }
|
||||
|
||||
|
||||
/*########################################################################################################################*
|
||||
*------------------------------------------------------Framebuffer--------------------------------------------------------*
|
||||
|
@ -108,6 +108,41 @@ void Window_RequestClose(void) {
|
||||
/*########################################################################################################################*
|
||||
*----------------------------------------------------Input processing-----------------------------------------------------*
|
||||
*#########################################################################################################################*/
|
||||
static void ProcessTouchInput(void) {
|
||||
static int prev_touchcount = 0;
|
||||
HidTouchScreenState state = {0};
|
||||
hidGetTouchScreenStates(&state, 1);
|
||||
|
||||
if (state.count) {
|
||||
Input_AddTouch(0, state.touches[0].x, state.touches[0].y);
|
||||
} else if (prev_touchcount) {
|
||||
Input_RemoveTouch(0, Pointers[0].x, Pointers[0].y);
|
||||
}
|
||||
prev_touchcount = state.count;
|
||||
}
|
||||
|
||||
void Window_ProcessEvents(double delta) {
|
||||
// Scan the gamepad. This should be done once for each frame
|
||||
padUpdate(&pad);
|
||||
|
||||
if (!appletMainLoop()) {
|
||||
Window_Main.Exists = false;
|
||||
Window_RequestClose();
|
||||
return;
|
||||
}
|
||||
ProcessTouchInput();
|
||||
}
|
||||
|
||||
void Cursor_SetPosition(int x, int y) { } // Makes no sense for PSP
|
||||
void Window_EnableRawMouse(void) { Input.RawMode = true; }
|
||||
void Window_DisableRawMouse(void) { Input.RawMode = false; }
|
||||
|
||||
void Window_UpdateRawMouse(void) { }
|
||||
|
||||
|
||||
/*########################################################################################################################*
|
||||
*-------------------------------------------------------Gamepads----------------------------------------------------------*
|
||||
*#########################################################################################################################*/
|
||||
static void HandleButtons(u64 mods) {
|
||||
Gamepad_SetButton(CCPAD_L, mods & HidNpadButton_L);
|
||||
Gamepad_SetButton(CCPAD_R, mods & HidNpadButton_R);
|
||||
@ -135,30 +170,7 @@ static void ProcessJoystickInput(int axis, HidAnalogStickState* pos, double delt
|
||||
Gamepad_SetAxis(axis, pos->x / AXIS_SCALE, -pos->y / AXIS_SCALE, delta);
|
||||
}
|
||||
|
||||
static void ProcessTouchInput(void) {
|
||||
static int prev_touchcount = 0;
|
||||
HidTouchScreenState state = {0};
|
||||
hidGetTouchScreenStates(&state, 1);
|
||||
|
||||
if (state.count) {
|
||||
Input_AddTouch(0, state.touches[0].x, state.touches[0].y);
|
||||
} else if (prev_touchcount) {
|
||||
Input_RemoveTouch(0, Pointers[0].x, Pointers[0].y);
|
||||
}
|
||||
prev_touchcount = state.count;
|
||||
}
|
||||
|
||||
void Window_ProcessEvents(double delta) {
|
||||
// Scan the gamepad. This should be done once for each frame
|
||||
padUpdate(&pad);
|
||||
Input.JoystickMovement = false;
|
||||
|
||||
if (!appletMainLoop()) {
|
||||
Window_Main.Exists = false;
|
||||
Window_RequestClose();
|
||||
return;
|
||||
}
|
||||
|
||||
void Window_ProcessGamepads(double delta) {
|
||||
u64 keys = padGetButtons(&pad);
|
||||
HandleButtons(keys);
|
||||
|
||||
@ -167,16 +179,8 @@ void Window_ProcessEvents(double delta) {
|
||||
HidAnalogStickState analog_stick_r = padGetStickPos(&pad, 1);
|
||||
ProcessJoystickInput(PAD_AXIS_LEFT, &analog_stick_l, delta);
|
||||
ProcessJoystickInput(PAD_AXIS_RIGHT, &analog_stick_r, delta);
|
||||
|
||||
ProcessTouchInput();
|
||||
}
|
||||
|
||||
void Cursor_SetPosition(int x, int y) { } // Makes no sense for PSP
|
||||
void Window_EnableRawMouse(void) { Input.RawMode = true; }
|
||||
void Window_DisableRawMouse(void) { Input.RawMode = false; }
|
||||
|
||||
void Window_UpdateRawMouse(void) { }
|
||||
|
||||
|
||||
/*########################################################################################################################*
|
||||
*------------------------------------------------------Framebuffer--------------------------------------------------------*
|
||||
|
@ -529,6 +529,26 @@ static void ProcessPendingResize(void) {
|
||||
UpdateWindowBounds();
|
||||
}
|
||||
|
||||
void Window_ProcessEvents(double delta) {
|
||||
if (!needResize) return;
|
||||
needResize = false;
|
||||
ProcessPendingResize();
|
||||
}
|
||||
|
||||
/* Not needed because browser provides relative mouse and touch events */
|
||||
static void Cursor_GetRawPos(int* x, int* y) { *x = 0; *y = 0; }
|
||||
/* Not allowed to move cursor from javascript */
|
||||
void Cursor_SetPosition(int x, int y) { }
|
||||
|
||||
extern void interop_SetCursorVisible(int visible);
|
||||
static void Cursor_DoSetVisible(cc_bool visible) {
|
||||
interop_SetCursorVisible(visible);
|
||||
}
|
||||
|
||||
|
||||
/*########################################################################################################################*
|
||||
*-------------------------------------------------------Gamepads----------------------------------------------------------*
|
||||
*#########################################################################################################################*/
|
||||
/* https://www.w3.org/TR/gamepad/#dfn-standard-gamepad */
|
||||
#define GetGamepadButton(i) i < numButtons ? ev->digitalButton[i] : 0
|
||||
static void ProcessGamepadButtons(EmscriptenGamepadEvent* ev) {
|
||||
@ -566,7 +586,6 @@ static void ProcessGamepadAxis(int axis, float x, float y, double delta) {
|
||||
|
||||
static void ProcessGamepadInput(EmscriptenGamepadEvent* ev, double delta) {
|
||||
Input.Sources |= INPUT_SOURCE_GAMEPAD;
|
||||
Input.JoystickMovement = false;
|
||||
ProcessGamepadButtons(ev);
|
||||
|
||||
if (ev->numAxes >= 4) {
|
||||
@ -577,7 +596,7 @@ static void ProcessGamepadInput(EmscriptenGamepadEvent* ev, double delta) {
|
||||
}
|
||||
}
|
||||
|
||||
void Window_ProcessEvents(double delta) {
|
||||
void Window_ProcessGamepads(double delta) {
|
||||
int i, res, count;
|
||||
Input.Sources = INPUT_SOURCE_NORMAL;
|
||||
|
||||
@ -591,22 +610,12 @@ void Window_ProcessEvents(double delta) {
|
||||
if (res == 0) ProcessGamepadInput(&ev, delta);
|
||||
}
|
||||
}
|
||||
|
||||
if (!needResize) return;
|
||||
needResize = false;
|
||||
ProcessPendingResize();
|
||||
}
|
||||
|
||||
/* Not needed because browser provides relative mouse and touch events */
|
||||
static void Cursor_GetRawPos(int* x, int* y) { *x = 0; *y = 0; }
|
||||
/* Not allowed to move cursor from javascript */
|
||||
void Cursor_SetPosition(int x, int y) { }
|
||||
|
||||
extern void interop_SetCursorVisible(int visible);
|
||||
static void Cursor_DoSetVisible(cc_bool visible) {
|
||||
interop_SetCursorVisible(visible);
|
||||
}
|
||||
|
||||
/*########################################################################################################################*
|
||||
*-------------------------------------------------------Misc/Other--------------------------------------------------------*
|
||||
*#########################################################################################################################*/
|
||||
extern void interop_ShowDialog(const char* title, const char* msg);
|
||||
static void ShowDialogCore(const char* title, const char* msg) {
|
||||
interop_ShowDialog(title, msg);
|
||||
|
@ -119,6 +119,26 @@ void Window_RequestClose(void) {
|
||||
}
|
||||
|
||||
|
||||
/*########################################################################################################################*
|
||||
*----------------------------------------------------Input processing-----------------------------------------------------*
|
||||
*#########################################################################################################################*/
|
||||
void Window_ProcessEvents(double delta) {
|
||||
if (!WHBProcIsRunning()) {
|
||||
Window_Main.Exists = false;
|
||||
Window_RequestClose();
|
||||
}
|
||||
}
|
||||
|
||||
void Window_UpdateRawMouse(void) { }
|
||||
|
||||
void Cursor_SetPosition(int x, int y) { }
|
||||
void Window_EnableRawMouse(void) { Input.RawMode = true; }
|
||||
void Window_DisableRawMouse(void) { Input.RawMode = false; }
|
||||
|
||||
|
||||
/*########################################################################################################################*
|
||||
*-------------------------------------------------------Gamepads----------------------------------------------------------*
|
||||
*#########################################################################################################################*/
|
||||
static void ProcessKPAD(double delta) {
|
||||
KPADStatus kpad = { 0 };
|
||||
int res = KPADRead(0, &kpad, 1);
|
||||
@ -195,25 +215,11 @@ static void ProcessVPAD(double delta) {
|
||||
}
|
||||
|
||||
|
||||
void Window_ProcessEvents(double delta) {
|
||||
Input.JoystickMovement = false;
|
||||
|
||||
if (!WHBProcIsRunning()) {
|
||||
Window_Main.Exists = false;
|
||||
Window_RequestClose();
|
||||
return;
|
||||
}
|
||||
|
||||
void Window_ProcessGamepads(double delta) {
|
||||
ProcessVPAD(delta);
|
||||
ProcessKPAD(delta);
|
||||
}
|
||||
|
||||
void Window_UpdateRawMouse(void) { }
|
||||
|
||||
void Cursor_SetPosition(int x, int y) { }
|
||||
void Window_EnableRawMouse(void) { Input.RawMode = true; }
|
||||
void Window_DisableRawMouse(void) { Input.RawMode = false; }
|
||||
|
||||
|
||||
/*########################################################################################################################*
|
||||
*------------------------------------------------------Framebuffer--------------------------------------------------------*
|
||||
|
@ -533,6 +533,8 @@ void Window_ProcessEvents(double delta) {
|
||||
}
|
||||
}
|
||||
|
||||
void Window_ProcessGamepads(double delta) { }
|
||||
|
||||
static void Cursor_GetRawPos(int* x, int* y) {
|
||||
POINT point;
|
||||
GetCursorPos(&point);
|
||||
|
@ -699,6 +699,8 @@ void Window_ProcessEvents(double delta) {
|
||||
}
|
||||
}
|
||||
|
||||
void Window_ProcessGamepads(double delta) { }
|
||||
|
||||
static void Cursor_GetRawPos(int* x, int* y) {
|
||||
Window rootW, childW;
|
||||
int childX, childY;
|
||||
|
@ -107,6 +107,20 @@ void Window_RequestClose(void) {
|
||||
/*########################################################################################################################*
|
||||
*----------------------------------------------------Input processing-----------------------------------------------------*
|
||||
*#########################################################################################################################*/
|
||||
void Window_ProcessEvents(double delta) {
|
||||
usbh_pooling_hubs();
|
||||
}
|
||||
|
||||
void Cursor_SetPosition(int x, int y) { } // Makes no sense for Xbox
|
||||
|
||||
void Window_EnableRawMouse(void) { Input.RawMode = true; }
|
||||
void Window_DisableRawMouse(void) { Input.RawMode = false; }
|
||||
void Window_UpdateRawMouse(void) { }
|
||||
|
||||
|
||||
/*########################################################################################################################*
|
||||
*-------------------------------------------------------Gamepads----------------------------------------------------------*
|
||||
*#########################################################################################################################*/
|
||||
// https://docs.microsoft.com/en-us/windows/win32/api/xinput/ns-xinput-xinput_gamepad
|
||||
// NOTE: Analog buttons use dedicated field rather than being part of dButtons
|
||||
#define XINPUT_GAMEPAD_DPAD_UP 0x0001
|
||||
@ -149,9 +163,7 @@ static void HandleJoystick(int axis, int x, int y, double delta) {
|
||||
Gamepad_SetAxis(axis, x / AXIS_SCALE, -y / AXIS_SCALE, delta);
|
||||
}
|
||||
|
||||
void Window_ProcessEvents(double delta) {
|
||||
Input.JoystickMovement = false;
|
||||
usbh_pooling_hubs();
|
||||
void Window_ProcessGamepads(double delta) {
|
||||
if (!xid_ctrl) return;
|
||||
|
||||
HandleButtons(&gp_state);
|
||||
@ -159,12 +171,6 @@ void Window_ProcessEvents(double delta) {
|
||||
HandleJoystick(PAD_AXIS_RIGHT, gp_state.rightStickX, gp_state.rightStickY, delta);
|
||||
}
|
||||
|
||||
void Cursor_SetPosition(int x, int y) { } // Makes no sense for Xbox
|
||||
|
||||
void Window_EnableRawMouse(void) { Input.RawMode = true; }
|
||||
void Window_DisableRawMouse(void) { Input.RawMode = false; }
|
||||
void Window_UpdateRawMouse(void) { }
|
||||
|
||||
|
||||
/*########################################################################################################################*
|
||||
*------------------------------------------------------Framebuffer--------------------------------------------------------*
|
||||
|
@ -71,6 +71,20 @@ void Window_RequestClose(void) {
|
||||
/*########################################################################################################################*
|
||||
*----------------------------------------------------Input processing-----------------------------------------------------*
|
||||
*#########################################################################################################################*/
|
||||
void Window_ProcessEvents(double delta) {
|
||||
usb_do_poll();
|
||||
}
|
||||
|
||||
void Cursor_SetPosition(int x, int y) { } // Makes no sense for Xbox
|
||||
|
||||
void Window_EnableRawMouse(void) { Input.RawMode = true; }
|
||||
void Window_DisableRawMouse(void) { Input.RawMode = false; }
|
||||
void Window_UpdateRawMouse(void) { }
|
||||
|
||||
|
||||
/*########################################################################################################################*
|
||||
*-------------------------------------------------------Gamepads----------------------------------------------------------*
|
||||
*#########################################################################################################################*/
|
||||
/*
|
||||
struct controller_data_s
|
||||
{
|
||||
@ -99,22 +113,14 @@ static void HandleButtons(struct controller_data_s* pad) {
|
||||
Gamepad_SetButton(CCPAD_DOWN, pad->down);
|
||||
}
|
||||
|
||||
void Window_ProcessEvents(double delta) {
|
||||
usb_do_poll();
|
||||
|
||||
void Window_ProcessGamepads(double delta) {
|
||||
struct controller_data_s pad;
|
||||
int res = get_controller_data(&pad, 0);
|
||||
if (res == 0) return;
|
||||
|
||||
HandleButtons(&pad);
|
||||
int res = get_controller_data(&pad, 0);
|
||||
if (res == 0) return;
|
||||
|
||||
HandleButtons(&pad);
|
||||
}
|
||||
|
||||
void Cursor_SetPosition(int x, int y) { } // Makes no sense for Xbox
|
||||
|
||||
void Window_EnableRawMouse(void) { Input.RawMode = true; }
|
||||
void Window_DisableRawMouse(void) { Input.RawMode = false; }
|
||||
void Window_UpdateRawMouse(void) { }
|
||||
|
||||
|
||||
/*########################################################################################################################*
|
||||
*------------------------------------------------------Framebuffer--------------------------------------------------------*
|
||||
|
@ -628,6 +628,8 @@ void Window_ProcessEvents(double delta) {
|
||||
}
|
||||
}
|
||||
|
||||
void Window_ProcessGamepads(double delta) { }
|
||||
|
||||
static void Cursor_GetRawPos(int* x, int* y) {
|
||||
BPoint where;
|
||||
uint32 buttons;
|
||||
|
@ -568,6 +568,8 @@ void Window_ProcessEvents(double delta) {
|
||||
}
|
||||
}
|
||||
|
||||
void Window_ProcessGamepads(double delta) { }
|
||||
|
||||
|
||||
/*########################################################################################################################*
|
||||
*-----------------------------------------------------------Dialogs-------------------------------------------------------*
|
||||
|
@ -493,6 +493,8 @@ void Window_ProcessEvents(double delta) {
|
||||
} while (res == kCFRunLoopRunHandledSource);
|
||||
}
|
||||
|
||||
void Window_ProcessGamepads(double delta) { }
|
||||
|
||||
void ShowDialogCore(const char* title, const char* msg) {
|
||||
// UIAlertController - iOS 8.0
|
||||
// UIAlertAction - iOS 8.0
|
||||
|
Loading…
x
Reference in New Issue
Block a user