Compare commits

..
Author SHA1 Message Date
Stefan MaierandClaude Opus 5.5 6754403d68 VR: the menu pointer leaves the stick's choice be; clicks beside a list step it
A choice the stick moved to (a map among the tiles) is no longer taken back
by the pointer resting on another, until the pointer moves well away; and a
click beside a list's slots or a value's box, along the way it steps (where
its arrows are drawn), steps it back or on.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-04 11:41:09 +02:00
4 changed files with 92 additions and 63 deletions

No files matched your search

+28 -2
View File
@@ -2139,6 +2139,10 @@ static struct
int valid;
float x, y;
float reported_x, reported_y;
/* (a stick moved the menu's choice: the pointer, not moved far from
here since, leaves it be) */
int stick_quiet;
float stick_x, stick_y;
int hand;
int trigger_down[HALO_XR_HAND_COUNT];
int clicks;
@@ -2233,9 +2237,31 @@ int halo_vr_menu_pointer(int *x, int *y, int *click_x, int *click_y, int *moved,
return 0;
*x = (int)menu_pointer.x;
*y = (int)menu_pointer.y;
/* (a stick pushed: what it chooses stays chosen until the pointer
moves well away) */
{
int index;
for (index = 0; index < HALO_XR_HAND_COUNT; index++)
{
const struct halo_xr_hand *hand = &vr.frame.hands[index];
if (hand->active && (fabsf(hand->thumbstick[0]) > 0.4f || fabsf(hand->thumbstick[1]) > 0.4f))
{
menu_pointer.stick_quiet = 1;
menu_pointer.stick_x = menu_pointer.x;
menu_pointer.stick_y = menu_pointer.y;
}
}
if (menu_pointer.stick_quiet && (fabsf(menu_pointer.x - menu_pointer.stick_x) > 25.0f ||
fabsf(menu_pointer.y - menu_pointer.stick_y) > 25.0f))
{
menu_pointer.stick_quiet = 0;
}
}
/* (moved past a hand's tremor: a few pixels) */
*moved = fabsf(menu_pointer.x - menu_pointer.reported_x) >= 3.0f ||
fabsf(menu_pointer.y - menu_pointer.reported_y) >= 3.0f;
*moved = !menu_pointer.stick_quiet && (fabsf(menu_pointer.x - menu_pointer.reported_x) >= 3.0f ||
fabsf(menu_pointer.y - menu_pointer.reported_y) >= 3.0f);
if (*moved)
{
menu_pointer.reported_x = menu_pointer.x;
+1 -11
View File
@@ -813,15 +813,6 @@ In the menus the buttons are the Xbox's by position: A accepts, B goes back. */
int halo_vr_controllers(struct halo_xr_hand hands[HALO_XR_HAND_COUNT], int *menus);
int halo_vr_wheel_held(void);
/* a click that stands for the pad's A (ui_widget.c: the screen where
controllers join by pressing it), held a moment */
static Uint64 vr_pad_a_until;
void halo_vr_pulse_pad_a(void)
{
vr_pad_a_until = SDL_GetTicks() + 120;
}
static SHORT vr_stick(float value)
{
if (value > 1.0f)
@@ -868,8 +859,7 @@ static void vr_gamepad_state(XINPUT_GAMEPAD *pad)
if (abs(value) > abs(pad->sThumbRX)) pad->sThumbRX = value;
value = vr_stick(right->thumbstick[1]);
if (abs(value) > abs(pad->sThumbRY)) pad->sThumbRY = value;
merge_button(pad, XINPUT_GAMEPAD_A, (right->buttons & HALO_XR_BUTTON_A) != 0 ||
SDL_GetTicks() < vr_pad_a_until);
merge_button(pad, XINPUT_GAMEPAD_A, (right->buttons & HALO_XR_BUTTON_A) != 0);
merge_button(pad, XINPUT_GAMEPAD_B, (right->buttons & HALO_XR_BUTTON_B) != 0);
merge_button(pad, XINPUT_GAMEPAD_X, (left->buttons & HALO_XR_BUTTON_A) != 0);
merge_button(pad, XINPUT_GAMEPAD_Y, (left->buttons & HALO_XR_BUTTON_B) != 0);
+4 -37
View File
@@ -961,11 +961,6 @@ static void hud_draw_players(
long player_index = local_player_get_player_index(render.local_player_index);
long team_index = player_get(player_index)->team_index;
#ifdef HALO_ANDROID
/* (VR: over the heads, with the names: hud_draw_player_name) */
if (halo_vr_names_apart())
return;
#endif
if (player_index != NONE)
{
/* the native builds' sessions hold more than 16 players */
@@ -1140,7 +1135,6 @@ static void hud_draw_player_name(
long player_index,
boolean ally,
boolean indicator,
boolean name_shown,
real enemy_range,
boolean vr_apart)
{
@@ -1182,7 +1176,7 @@ static void hud_draw_player_name(
point[0] = head_position.x;
point[1] = head_position.y;
point[2] = head_position.z + (indicator ? 0.06f : 0.0f);
point[2] = head_position.z + (indicator ? 0.15f : 0.0f);
slot = halo_vr_add_name(point);
if (slot < 0)
return;
@@ -1191,31 +1185,7 @@ static void hud_draw_player_name(
y = (short)(slot_bounds[3] - 4);
/* (an ally's whole at any distance it is drawn at) */
view_position.z = -1.0f;
if (indicator)
{
/* (a teammate's triangle at the slot's foot, the name over it:
the game's, drawn on the HUD, would hang before the eyes) */
struct bitmap_data *bitmap = bitmap_group_get_bitmap_from_sequence(
interface_get_tag_index(_interface_bitmap_multiplayer_hud), 0, 0);
if (bitmap && _texture_cache_bitmap_get_hardware_format(bitmap, FALSE, TRUE))
{
point2d tip;
real_rectangle2d whole;
tip.x = x;
tip.y = (short)(slot_bounds[3] - 2);
whole.x0 = 0.0f;
whole.x1 = 1.0f;
whole.y0 = 0.0f;
whole.y1 = 1.0f;
interface_draw_bitmap(bitmap, &tip, &whole, 0.6f, 0.0f, 1.0f);
y = (short)(tip.y - bitmap->registration_point.y * 0.6f);
}
}
indicator = FALSE;
if (!name_shown)
return;
}
else
#endif
@@ -1301,8 +1271,7 @@ static void hud_draw_player_names_now(
long team_index;
real enemy_range;
/* (VR: the triangles over teammates go with the names, shown or not) */
if ((setting == _player_names_none && !vr_apart) || player_index == NONE)
if (setting == _player_names_none || player_index == NONE)
return;
team_index = player_get(player_index)->team_index;
indicators = game_engine_display_team_indicators();
@@ -1312,14 +1281,12 @@ static void hud_draw_player_names_now(
{
/* (allies as the game's triangles tell them: the same team) */
boolean ally = player->team_index == team_index;
boolean shown = !(setting == _player_names_none || (ally && setting == _player_names_enemies) ||
(!ally && setting == _player_names_allies));
if (iterator.datum_index == player_index || player->unit_index == NONE)
continue;
if (!shown && !(vr_apart && ally && indicators))
if ((ally && setting == _player_names_enemies) || (!ally && setting == _player_names_allies))
continue;
hud_draw_player_name(iterator.datum_index, ally, ally && indicators, shown, enemy_range, vr_apart);
hud_draw_player_name(iterator.datum_index, ally, ally && indicators, enemy_range, vr_apart);
}
return;
+59 -13
View File
@@ -5751,6 +5751,57 @@ static void ui_mouse_list_directions(
return;
}
#ifdef HALO_ANDROID
/* VR: a click beside a list's slots or a value's box, along the way it
steps, where its arrows are drawn: a step back or on (TRUE: taken) */
static boolean ui_mouse_click_beside_list(
short x,
short y)
{
struct widget_instance *list = NULL;
rectangle2d bounds;
long index;
short back, forward;
boolean across;
for (index = 0; index < ui_mouse_target_count; index++)
{
struct ui_mouse_target const *target = &ui_mouse_targets[index];
struct widget_instance *owner = target->kind == _ui_mouse_target_list_slot ? target->widget->parent :
target->kind == _ui_mouse_target_value ? target->widget : NULL;
if (!owner)
continue;
if (!list)
{
list = owner;
bounds = target->bounds;
}
else if (owner == list)
{
bounds.x0 = MIN(bounds.x0, target->bounds.x0);
bounds.y0 = MIN(bounds.y0, target->bounds.y0);
bounds.x1 = MAX(bounds.x1, target->bounds.x1);
bounds.y1 = MAX(bounds.y1, target->bounds.y1);
}
}
if (!list)
return FALSE;
ui_mouse_list_directions(list, &back, &forward);
across = back == _widget_event_dpad_left;
if (across ? y < bounds.y0 - 24 || y >= bounds.y1 + 24 : x < bounds.x0 - 24 || x >= bounds.x1 + 24)
return FALSE;
ui_mouse_give_focus(list);
if (across ? x < bounds.x0 && x >= bounds.x0 - 80 : y < bounds.y0 && y >= bounds.y0 - 48)
ui_mouse_press(back);
else if (across ? x >= bounds.x1 && x < bounds.x1 + 80 : y >= bounds.y1 && y < bounds.y1 + 48)
ui_mouse_press(forward);
else
return FALSE;
return TRUE;
}
#endif
/* steps a list that shows several items to the one shown in a slot, as
pressing the d-pad that many times would */
static void ui_mouse_step_list_to_slot(
@@ -5836,7 +5887,6 @@ an invite link does (the game shows up in the list once its host is
reached). */
int p2p_join_code(char *text, int size);
void halo_vr_pulse_pad_a(void);
int p2p_join_with_code(char const *typed);
int p2p_join_code_status(void);
void p2p_join_code_clear_status(void);
@@ -6144,13 +6194,6 @@ static boolean ui_join_code_take_pointer(
press.type = _event_type_button;
press.data.button.index = _gamepad_analog_button_a;
press.data.button.value = 1;
/* (the screen where controllers join by their A: a click is the
pad's A, there, not a menu's) */
if (pointer->left_clicks && y < 400 && ui_join_code_screen_active("4way_start2join_screen"))
{
halo_vr_pulse_pad_a();
return TRUE;
}
if (ui_join_code_globals.panel_open)
{
if (x >= 48 && x < 592 && y >= 128 && y < 128 + ONLINE_PANEL_ROWS * 22)
@@ -6323,16 +6366,13 @@ static void ui_join_code_render(
if (ui_join_code_screen_active("server_list_screen"))
{
char const *status = NULL;
real_argb_color hint_color = { 1.0f, 0.85f, 0.85f, 0.85f };
if (ui_join_code_globals.panel_open)
{
ui_join_code_render_panel();
return;
}
/* (in the key bar's free left, and under it: clear of the map's
picture) */
ui_join_code_draw_text(8, 200, 420, "%x-button Online / code", TRUE, 0, &hint_color);
ui_join_code_draw_line(372, "%x-button Online games: public ones, or join by a code", TRUE, FALSE);
switch (p2p_join_code_status())
{
case _join_code_looking: status = "Looking for the game of that code..."; break;
@@ -6355,7 +6395,7 @@ static void ui_join_code_render(
}
}
if (status)
ui_join_code_draw_line(452, status, FALSE, FALSE);
ui_join_code_draw_line(392, status, FALSE, FALSE);
}
else if (ui_join_code_screen_active("connected_pregame_screen") && global_network_game_server_get())
{
@@ -6551,6 +6591,12 @@ static void ui_widgets_process_mouse(
{
long index;
#ifdef HALO_ANDROID
/* (VR: beside a list, on its arrows) */
if (halo_vr_active() && ui_mouse_click_beside_list(ui_mouse_click_x, ui_mouse_click_y))
index = 0;
else
#endif
/* a screen with nothing to pick (a message to dismiss): the
click is its A */
for (index = 0; index < ui_mouse_target_count; index++)