mirror of
https://github.com/libretro/RetroArch
synced 2025-04-10 06:44:27 +00:00
Use C-style comments
This commit is contained in:
parent
805c2ad529
commit
7a490aa6d6
@ -705,7 +705,9 @@ void input_poll_overlay(input_overlay_t *ol, float opacity, unsigned analog_dpad
|
|||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if(settings->bools.input_overlay_show_physical_inputs){
|
|
||||||
|
if(settings->bools.input_overlay_show_physical_inputs)
|
||||||
|
{
|
||||||
button_pressed = input_overlay_add_inputs(ol, settings->uints.input_overlay_show_physical_inputs_port, analog_dpad_mode);
|
button_pressed = input_overlay_add_inputs(ol, settings->uints.input_overlay_show_physical_inputs_port, analog_dpad_mode);
|
||||||
}
|
}
|
||||||
if (button_pressed || polled)
|
if (button_pressed || polled)
|
||||||
@ -760,81 +762,88 @@ void input_state_overlay(input_overlay_t *ol, int16_t *ret,
|
|||||||
*/
|
*/
|
||||||
static bool input_overlay_add_inputs(input_overlay_t *ol,
|
static bool input_overlay_add_inputs(input_overlay_t *ol,
|
||||||
unsigned port, unsigned analog_dpad_mode)
|
unsigned port, unsigned analog_dpad_mode)
|
||||||
{
|
{
|
||||||
unsigned i;
|
unsigned i;
|
||||||
uint64_t mask;
|
uint64_t mask;
|
||||||
int id;
|
int id;
|
||||||
bool button_pressed = false;
|
bool button_pressed = false;
|
||||||
bool current_button_pressed = false;
|
bool current_button_pressed = false;
|
||||||
input_overlay_state_t *ol_state = &ol->overlay_state;
|
input_overlay_state_t *ol_state = &ol->overlay_state;
|
||||||
|
|
||||||
if(!ol_state)
|
if(!ol_state)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
for(i = 0; i < ol->active->size; i++)
|
for(i = 0; i < ol->active->size; i++)
|
||||||
|
{
|
||||||
|
overlay_desc_t *desc = &(ol->active->descs[i]);
|
||||||
|
switch(desc->type)
|
||||||
{
|
{
|
||||||
overlay_desc_t *desc = &(ol->active->descs[i]);
|
case OVERLAY_TYPE_BUTTONS:
|
||||||
switch(desc->type)
|
mask = desc->key_mask;
|
||||||
|
id = RETRO_DEVICE_ID_JOYPAD_B;
|
||||||
|
/* Need to check all bits in the mask,
|
||||||
|
* multiple ones can be pressed */
|
||||||
|
current_button_pressed = false;
|
||||||
|
while(mask)
|
||||||
{
|
{
|
||||||
case OVERLAY_TYPE_BUTTONS:
|
/* Get the next button ID */
|
||||||
mask = desc->key_mask;
|
while(mask && (mask & 1) == 0)
|
||||||
id = RETRO_DEVICE_ID_JOYPAD_B;
|
{
|
||||||
//Need to check all bits in the mask, multiple ones can be pressed
|
id+=1;
|
||||||
current_button_pressed = false;
|
mask = mask >> 1;
|
||||||
while(mask){
|
}
|
||||||
//Get the next button ID
|
/* Light up the button if pressed */
|
||||||
while(mask && (mask & 1) == 0){
|
if(input_state(port, RETRO_DEVICE_JOYPAD, 0, id))
|
||||||
id+=1;
|
{
|
||||||
mask = mask >> 1;
|
current_button_pressed = true;
|
||||||
}
|
desc->updated = true;
|
||||||
//light up the button if pressed
|
|
||||||
if(input_state(port, RETRO_DEVICE_JOYPAD, 0, id)){
|
|
||||||
current_button_pressed = true;
|
|
||||||
desc->updated = true;
|
|
||||||
|
|
||||||
id+=1;
|
id+=1;
|
||||||
mask = mask >> 1;
|
mask = mask >> 1;
|
||||||
}else{
|
}
|
||||||
//One of the buttons not pressed
|
else
|
||||||
current_button_pressed = false;
|
{
|
||||||
desc->updated = false;
|
/* One of the buttons not pressed */
|
||||||
break;
|
current_button_pressed = false;
|
||||||
}
|
desc->updated = false;
|
||||||
}
|
break;
|
||||||
button_pressed = button_pressed || current_button_pressed;
|
}
|
||||||
break;
|
|
||||||
case OVERLAY_TYPE_ANALOG_LEFT:
|
|
||||||
case OVERLAY_TYPE_ANALOG_RIGHT:
|
|
||||||
{
|
|
||||||
float analog_x, analog_y;
|
|
||||||
float dx, dy;
|
|
||||||
unsigned int index = (desc->type == OVERLAY_TYPE_ANALOG_RIGHT) ?
|
|
||||||
RETRO_DEVICE_INDEX_ANALOG_RIGHT : RETRO_DEVICE_INDEX_ANALOG_LEFT;
|
|
||||||
|
|
||||||
analog_x = input_state(port, RETRO_DEVICE_ANALOG, index, RETRO_DEVICE_ID_ANALOG_X);
|
|
||||||
analog_y = input_state(port, RETRO_DEVICE_ANALOG, index, RETRO_DEVICE_ID_ANALOG_Y);
|
|
||||||
dx = (analog_x/0x8000)*(desc->range_x/2);
|
|
||||||
dy = (analog_y/0x8000)*(desc->range_y/2);
|
|
||||||
|
|
||||||
desc->delta_x = dx;
|
|
||||||
desc->delta_y = dy;
|
|
||||||
/*Maybe use some option here instead of 0, only display
|
|
||||||
changes greater than some magnitude.
|
|
||||||
*/
|
|
||||||
if((dx*dx) > 0 || (dy*dy) > 0)
|
|
||||||
button_pressed = true;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case OVERLAY_TYPE_KEYBOARD:
|
|
||||||
if(input_state(port, RETRO_DEVICE_KEYBOARD, 0, desc->key_mask)){
|
|
||||||
desc->updated = true;
|
|
||||||
button_pressed = true;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
button_pressed = button_pressed || current_button_pressed;
|
||||||
|
break;
|
||||||
|
case OVERLAY_TYPE_ANALOG_LEFT:
|
||||||
|
case OVERLAY_TYPE_ANALOG_RIGHT:
|
||||||
|
{
|
||||||
|
float analog_x, analog_y;
|
||||||
|
float dx, dy;
|
||||||
|
unsigned int index = (desc->type == OVERLAY_TYPE_ANALOG_RIGHT) ?
|
||||||
|
RETRO_DEVICE_INDEX_ANALOG_RIGHT : RETRO_DEVICE_INDEX_ANALOG_LEFT;
|
||||||
|
|
||||||
return button_pressed;
|
analog_x = input_state(port, RETRO_DEVICE_ANALOG, index, RETRO_DEVICE_ID_ANALOG_X);
|
||||||
|
analog_y = input_state(port, RETRO_DEVICE_ANALOG, index, RETRO_DEVICE_ID_ANALOG_Y);
|
||||||
|
dx = (analog_x/0x8000)*(desc->range_x/2);
|
||||||
|
dy = (analog_y/0x8000)*(desc->range_y/2);
|
||||||
|
|
||||||
|
desc->delta_x = dx;
|
||||||
|
desc->delta_y = dy;
|
||||||
|
/*Maybe use some option here instead of 0, only display
|
||||||
|
changes greater than some magnitude.
|
||||||
|
*/
|
||||||
|
if((dx*dx) > 0 || (dy*dy) > 0)
|
||||||
|
button_pressed = true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case OVERLAY_TYPE_KEYBOARD:
|
||||||
|
if(input_state(port, RETRO_DEVICE_KEYBOARD, 0, desc->key_mask))
|
||||||
|
{
|
||||||
|
desc->updated = true;
|
||||||
|
button_pressed = true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return button_pressed;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user