Fix building with libnx 4.0.0

This commit is contained in:
p-sam 2021-03-11 18:00:43 +00:00 committed by m4xw
parent 2e215bda5b
commit 1bc588acbd
5 changed files with 27 additions and 32 deletions

View File

@ -144,7 +144,7 @@ static void *libnx_audren_thread_audio_init(const char *device, unsigned rate, u
int mpid; int mpid;
size_t mempool_size; size_t mempool_size;
unsigned real_latency; unsigned real_latency;
uint32_t thread_priority; int32_t thread_priority;
RARCH_LOG("[Audio]: Using libnx_audren_thread driver\n"); RARCH_LOG("[Audio]: Using libnx_audren_thread driver\n");

View File

@ -111,7 +111,7 @@ static void on_applet_hook(AppletHookType hook, void *param)
case AppletHookType_OnFocusState: case AppletHookType_OnFocusState:
focus_state = appletGetFocusState(); focus_state = appletGetFocusState();
RARCH_LOG("Got AppletHook OnFocusState - new focus state is %d\n", focus_state); RARCH_LOG("Got AppletHook OnFocusState - new focus state is %d\n", focus_state);
platform_switch_has_focus = focus_state == AppletFocusState_Focused; platform_switch_has_focus = focus_state == AppletFocusState_InFocus;
if (!platform_switch_has_focus) if (!platform_switch_has_focus)
{ {
@ -133,11 +133,6 @@ static void on_applet_hook(AppletHookType hook, void *param)
/* Performance mode */ /* Performance mode */
case AppletHookType_OnPerformanceMode: case AppletHookType_OnPerformanceMode:
{
/* 0 == Handheld, 1 == Docked
* Since CPU doesn't change we just re-apply */
u32 performance_mode = appletGetPerformanceMode();
}
libnx_apply_overclock(); libnx_apply_overclock();
break; break;

View File

@ -54,7 +54,7 @@ static void switch_ctx_get_video_size(void *data,
*width = 1280; *width = 1280;
*height = 720; *height = 720;
break; break;
case AppletOperationMode_Docked: case AppletOperationMode_Console:
*width = 1920; *width = 1920;
*height = 1080; *height = 1080;
break; break;
@ -279,7 +279,7 @@ bool switch_ctx_get_metrics(void *data,
* the hardware - these hard-coded values are a kludge */ * the hardware - these hard-coded values are a kludge */
switch (appletGetOperationMode()) switch (appletGetOperationMode())
{ {
case AppletOperationMode_Docked: case AppletOperationMode_Console:
/* Docked mode /* Docked mode
* > Resolution: 1920x1080 * > Resolution: 1920x1080
* > Screen Size: 39 inch * > Screen Size: 39 inch

View File

@ -127,7 +127,7 @@ typedef struct switch_input
int32_t simulated_click_start_time[2]; /* initiation time of last simulated left or right click (zero if no click) */ int32_t simulated_click_start_time[2]; /* initiation time of last simulated left or right click (zero if no click) */
/* sensor handles */ /* sensor handles */
uint32_t sixaxis_handles[DEFAULT_MAX_PADS][4]; HidSixAxisSensorHandle sixaxis_handles[DEFAULT_MAX_PADS][4];
unsigned sixaxis_handles_count[DEFAULT_MAX_PADS]; unsigned sixaxis_handles_count[DEFAULT_MAX_PADS];
#else #else
void *empty; void *empty;
@ -221,28 +221,28 @@ static void switch_input_poll(void *data)
/* update physical mouse buttons only when they change /* update physical mouse buttons only when they change
* this allows the physical mouse and touch mouse to coexist */ * this allows the physical mouse and touch mouse to coexist */
mouse_current_report = hidMouseButtonsHeld(); mouse_current_report = hidMouseButtonsHeld();
if ((mouse_current_report & MOUSE_LEFT) if ((mouse_current_report & HidMouseButton_Left)
!= (sw->mouse_previous_report & MOUSE_LEFT)) != (sw->mouse_previous_report & HidMouseButton_Left))
{ {
if (mouse_current_report & MOUSE_LEFT) if (mouse_current_report & HidMouseButton_Left)
sw->mouse_button_left = true; sw->mouse_button_left = true;
else else
sw->mouse_button_left = false; sw->mouse_button_left = false;
} }
if ((mouse_current_report & MOUSE_RIGHT) if ((mouse_current_report & HidMouseButton_Right)
!= (sw->mouse_previous_report & MOUSE_RIGHT)) != (sw->mouse_previous_report & HidMouseButton_Right))
{ {
if (mouse_current_report & MOUSE_RIGHT) if (mouse_current_report & HidMouseButton_Right)
sw->mouse_button_right = true; sw->mouse_button_right = true;
else else
sw->mouse_button_right = false; sw->mouse_button_right = false;
} }
if ((mouse_current_report & MOUSE_MIDDLE) if ((mouse_current_report & HidMouseButton_Middle)
!= (sw->mouse_previous_report & MOUSE_MIDDLE)) != (sw->mouse_previous_report & HidMouseButton_Middle))
{ {
if (mouse_current_report & MOUSE_MIDDLE) if (mouse_current_report & HidMouseButton_Middle)
sw->mouse_button_middle = true; sw->mouse_button_middle = true;
else else
sw->mouse_button_middle = false; sw->mouse_button_middle = false;
@ -863,13 +863,13 @@ static bool switch_input_set_sensor_state(void *data, unsigned port,
case RETRO_SENSOR_GYROSCOPE_ENABLE: case RETRO_SENSOR_GYROSCOPE_ENABLE:
if(port < DEFAULT_MAX_PADS && sw->sixaxis_handles_count[port] == 0) if(port < DEFAULT_MAX_PADS && sw->sixaxis_handles_count[port] == 0)
{ {
hidGetSixAxisSensorHandles(&sw->sixaxis_handles[port][0], 2, port, TYPE_JOYCON_PAIR); hidGetSixAxisSensorHandles(&sw->sixaxis_handles[port][0], 2, port, HidNpadStyleTag_NpadJoyDual);
hidGetSixAxisSensorHandles(&sw->sixaxis_handles[port][2], 1, port, TYPE_PROCONTROLLER); hidGetSixAxisSensorHandles(&sw->sixaxis_handles[port][2], 1, port, HidNpadStyleTag_NpadFullKey);
if(port == 0) if(port == 0)
{ {
hidGetSixAxisSensorHandles(&sw->sixaxis_handles[port][3], 1, CONTROLLER_HANDHELD, TYPE_HANDHELD); hidGetSixAxisSensorHandles(&sw->sixaxis_handles[port][3], 1, HidNpadIdType_Handheld, HidNpadStyleTag_NpadHandheld);
handles_count = 4; handles_count = 4;
} }
else else

View File

@ -26,8 +26,8 @@ extern uint64_t lifecycle_state;
static uint16_t pad_state[DEFAULT_MAX_PADS]; static uint16_t pad_state[DEFAULT_MAX_PADS];
static int16_t analog_state[DEFAULT_MAX_PADS][2][2]; static int16_t analog_state[DEFAULT_MAX_PADS][2][2];
#ifdef HAVE_LIBNX #ifdef HAVE_LIBNX
static u32 vibration_handles[DEFAULT_MAX_PADS][2]; static HidVibrationDeviceHandle vibration_handles[DEFAULT_MAX_PADS][2];
static u32 vibration_handleheld[2]; static HidVibrationDeviceHandle vibration_handleheld[2];
static HidVibrationValue vibration_values[DEFAULT_MAX_PADS][2]; static HidVibrationValue vibration_values[DEFAULT_MAX_PADS][2];
static HidVibrationValue vibration_stop; static HidVibrationValue vibration_stop;
static int previous_handheld = -1; static int previous_handheld = -1;
@ -69,14 +69,14 @@ static void *switch_joypad_init(void *data)
switch_joypad_autodetect_add(i); switch_joypad_autodetect_add(i);
hidInitializeVibrationDevices( hidInitializeVibrationDevices(
vibration_handles[i], 2, i, vibration_handles[i], 2, i,
TYPE_HANDHELD | TYPE_JOYCON_PAIR); HidNpadStyleTag_NpadHandheld | HidNpadStyleTag_NpadJoyDual);
memcpy(&vibration_values[i][0], memcpy(&vibration_values[i][0],
&vibration_stop, sizeof(HidVibrationValue)); &vibration_stop, sizeof(HidVibrationValue));
memcpy(&vibration_values[i][1], memcpy(&vibration_values[i][1],
&vibration_stop, sizeof(HidVibrationValue)); &vibration_stop, sizeof(HidVibrationValue));
} }
hidInitializeVibrationDevices(vibration_handleheld, hidInitializeVibrationDevices(vibration_handleheld,
2, CONTROLLER_HANDHELD, TYPE_HANDHELD | TYPE_JOYCON_PAIR); 2, HidNpadIdType_Handheld, HidNpadStyleTag_NpadHandheld | HidNpadStyleTag_NpadJoyDual);
#else #else
hid_init(); hid_init();
switch_joypad_autodetect_add(0); switch_joypad_autodetect_add(0);
@ -237,7 +237,7 @@ static void switch_joypad_poll(void)
{ {
hidSetNpadJoyAssignmentModeSingleByDefault(i); hidSetNpadJoyAssignmentModeSingleByDefault(i);
hidSetNpadJoyAssignmentModeSingleByDefault(i + 1); hidSetNpadJoyAssignmentModeSingleByDefault(i + 1);
hidSetNpadJoyHoldType(HidJoyHoldType_Horizontal); hidSetNpadJoyHoldType(HidNpadJoyHoldType_Horizontal);
} }
else if (!input_split_joycon) else if (!input_split_joycon)
{ {
@ -265,7 +265,7 @@ static void switch_joypad_poll(void)
{ {
hidSetNpadJoyAssignmentModeSingleByDefault(i); hidSetNpadJoyAssignmentModeSingleByDefault(i);
hidSetNpadJoyAssignmentModeSingleByDefault(i + 1); hidSetNpadJoyAssignmentModeSingleByDefault(i + 1);
hidSetNpadJoyHoldType(HidJoyHoldType_Horizontal); hidSetNpadJoyHoldType(HidNpadJoyHoldType_Horizontal);
} }
} }
} }
@ -282,11 +282,11 @@ static void switch_joypad_poll(void)
for (id_0 = 0; id_0 < MAX_USERS; id_0++) for (id_0 = 0; id_0 < MAX_USERS; id_0++)
{ {
if (hidGetControllerType(id_0) & TYPE_JOYCON_LEFT) if (hidGetNpadStyleSet(id_0) & HidNpadStyleTag_NpadJoyLeft)
{ {
for (id_1 = last_right_id - 1; id_1 >= 0; id_1--) for (id_1 = last_right_id - 1; id_1 >= 0; id_1--)
{ {
if (hidGetControllerType(id_1) & TYPE_JOYCON_RIGHT) if (hidGetNpadStyleSet(id_1) & HidNpadStyleTag_NpadJoyRight)
{ {
/* prevent missing player numbers */ /* prevent missing player numbers */
last_right_id = id_1; last_right_id = id_1;
@ -312,7 +312,7 @@ static void switch_joypad_poll(void)
{ {
hidSetNpadJoyAssignmentModeSingleByDefault(i); hidSetNpadJoyAssignmentModeSingleByDefault(i);
hidSetNpadJoyAssignmentModeSingleByDefault(i + 1); hidSetNpadJoyAssignmentModeSingleByDefault(i + 1);
hidSetNpadJoyHoldType(HidJoyHoldType_Horizontal); hidSetNpadJoyHoldType(HidNpadJoyHoldType_Horizontal);
} }
else if (!input_split_joycon else if (!input_split_joycon
&& previous_split_joycon_setting[i]) && previous_split_joycon_setting[i])
@ -391,7 +391,7 @@ static void switch_joypad_poll(void)
bool switch_joypad_set_rumble(unsigned pad, bool switch_joypad_set_rumble(unsigned pad,
enum retro_rumble_effect type, uint16_t strength) enum retro_rumble_effect type, uint16_t strength)
{ {
u32* handle; HidVibrationDeviceHandle* handle;
float amp; float amp;
if (pad >= DEFAULT_MAX_PADS || !vibration_handles[pad]) if (pad >= DEFAULT_MAX_PADS || !vibration_handles[pad])