Skip to content

Commit

Permalink
Merge pull request #1 from StormedBubbles/multimouse_ui
Browse files Browse the repository at this point in the history
Add players 7 and 8, clean up
  • Loading branch information
StormedBubbles committed Apr 21, 2022
2 parents 276cfc1 + be37f5f commit 7f27253
Show file tree
Hide file tree
Showing 5 changed files with 104 additions and 112 deletions.
32 changes: 16 additions & 16 deletions src/emu/inpttype.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -380,8 +380,8 @@ namespace {
INPUT_PORT_DIGITAL_TYPE( 5, PLAYER5, BUTTON14, N_p("input-name", "%p Button 14"), input_seq(JOYCODE_BUTTON14_INDEXED(4)) ) \
INPUT_PORT_DIGITAL_TYPE( 5, PLAYER5, BUTTON15, N_p("input-name", "%p Button 15"), input_seq(JOYCODE_BUTTON15_INDEXED(4)) ) \
INPUT_PORT_DIGITAL_TYPE( 5, PLAYER5, BUTTON16, N_p("input-name", "%p Button 16"), input_seq(JOYCODE_BUTTON16_INDEXED(4)) ) \
INPUT_PORT_DIGITAL_TYPE( 5, PLAYER5, START, N_p("input-name", "%p Start"), input_seq() ) \
INPUT_PORT_DIGITAL_TYPE( 5, PLAYER5, SELECT, N_p("input-name", "%p Select"), input_seq() ) \
INPUT_PORT_DIGITAL_TYPE( 5, PLAYER5, START, N_p("input-name", "%p Start"), input_seq(JOYCODE_START_INDEXED(4)) ) \
INPUT_PORT_DIGITAL_TYPE( 5, PLAYER5, SELECT, N_p("input-name", "%p Select"), input_seq(JOYCODE_SELECT_INDEXED(4)) ) \
CORE_INPUT_TYPES_END()

#define CORE_INPUT_TYPES_P6 \
Expand Down Expand Up @@ -414,8 +414,8 @@ namespace {
INPUT_PORT_DIGITAL_TYPE( 6, PLAYER6, BUTTON14, N_p("input-name", "%p Button 14"), input_seq(JOYCODE_BUTTON14_INDEXED(5)) ) \
INPUT_PORT_DIGITAL_TYPE( 6, PLAYER6, BUTTON15, N_p("input-name", "%p Button 15"), input_seq(JOYCODE_BUTTON15_INDEXED(5)) ) \
INPUT_PORT_DIGITAL_TYPE( 6, PLAYER6, BUTTON16, N_p("input-name", "%p Button 16"), input_seq(JOYCODE_BUTTON16_INDEXED(5)) ) \
INPUT_PORT_DIGITAL_TYPE( 6, PLAYER6, START, N_p("input-name", "%p Start"), input_seq() ) \
INPUT_PORT_DIGITAL_TYPE( 6, PLAYER6, SELECT, N_p("input-name", "%p Select"), input_seq() ) \
INPUT_PORT_DIGITAL_TYPE( 6, PLAYER6, START, N_p("input-name", "%p Start"), input_seq(JOYCODE_START_INDEXED(5)) ) \
INPUT_PORT_DIGITAL_TYPE( 6, PLAYER6, SELECT, N_p("input-name", "%p Select"), input_seq(JOYCODE_SELECT_INDEXED(5)) ) \
CORE_INPUT_TYPES_END()

#define CORE_INPUT_TYPES_P7 \
Expand Down Expand Up @@ -448,8 +448,8 @@ namespace {
INPUT_PORT_DIGITAL_TYPE( 7, PLAYER7, BUTTON14, N_p("input-name", "%p Button 14"), input_seq(JOYCODE_BUTTON14_INDEXED(6)) ) \
INPUT_PORT_DIGITAL_TYPE( 7, PLAYER7, BUTTON15, N_p("input-name", "%p Button 15"), input_seq(JOYCODE_BUTTON15_INDEXED(6)) ) \
INPUT_PORT_DIGITAL_TYPE( 7, PLAYER7, BUTTON16, N_p("input-name", "%p Button 16"), input_seq(JOYCODE_BUTTON16_INDEXED(6)) ) \
INPUT_PORT_DIGITAL_TYPE( 7, PLAYER7, START, N_p("input-name", "%p Start"), input_seq() ) \
INPUT_PORT_DIGITAL_TYPE( 7, PLAYER7, SELECT, N_p("input-name", "%p Select"), input_seq() ) \
INPUT_PORT_DIGITAL_TYPE( 7, PLAYER7, START, N_p("input-name", "%p Start"), input_seq(JOYCODE_START_INDEXED(6)) ) \
INPUT_PORT_DIGITAL_TYPE( 7, PLAYER7, SELECT, N_p("input-name", "%p Select"), input_seq(JOYCODE_SELECT_INDEXED(6)) ) \
CORE_INPUT_TYPES_END()

#define CORE_INPUT_TYPES_P8 \
Expand Down Expand Up @@ -482,8 +482,8 @@ namespace {
INPUT_PORT_DIGITAL_TYPE( 8, PLAYER8, BUTTON14, N_p("input-name", "%p Button 14"), input_seq(JOYCODE_BUTTON14_INDEXED(7)) ) \
INPUT_PORT_DIGITAL_TYPE( 8, PLAYER8, BUTTON15, N_p("input-name", "%p Button 15"), input_seq(JOYCODE_BUTTON15_INDEXED(7)) ) \
INPUT_PORT_DIGITAL_TYPE( 8, PLAYER8, BUTTON16, N_p("input-name", "%p Button 16"), input_seq(JOYCODE_BUTTON16_INDEXED(7)) ) \
INPUT_PORT_DIGITAL_TYPE( 8, PLAYER8, START, N_p("input-name", "%p Start"), input_seq() ) \
INPUT_PORT_DIGITAL_TYPE( 8, PLAYER8, SELECT, N_p("input-name", "%p Select"), input_seq() ) \
INPUT_PORT_DIGITAL_TYPE( 8, PLAYER8, START, N_p("input-name", "%p Start"), input_seq(JOYCODE_START_INDEXED(7)) ) \
INPUT_PORT_DIGITAL_TYPE( 8, PLAYER8, SELECT, N_p("input-name", "%p Select"), input_seq(JOYCODE_SELECT_INDEXED(7)) ) \
CORE_INPUT_TYPES_END()

#define CORE_INPUT_TYPES_P9 \
Expand Down Expand Up @@ -560,10 +560,10 @@ namespace {
INPUT_PORT_DIGITAL_TYPE( 0, OTHER, START2, N_p("input-name", "2 Players Start"), input_seq(KEYCODE_2, input_seq::or_code, JOYCODE_START_INDEXED(1)) ) \
INPUT_PORT_DIGITAL_TYPE( 0, OTHER, START3, N_p("input-name", "3 Players Start"), input_seq(KEYCODE_3, input_seq::or_code, JOYCODE_START_INDEXED(2)) ) \
INPUT_PORT_DIGITAL_TYPE( 0, OTHER, START4, N_p("input-name", "4 Players Start"), input_seq(KEYCODE_4, input_seq::or_code, JOYCODE_START_INDEXED(3)) ) \
INPUT_PORT_DIGITAL_TYPE( 0, OTHER, START5, N_p("input-name", "5 Players Start"), input_seq() ) \
INPUT_PORT_DIGITAL_TYPE( 0, OTHER, START6, N_p("input-name", "6 Players Start"), input_seq() ) \
INPUT_PORT_DIGITAL_TYPE( 0, OTHER, START7, N_p("input-name", "7 Players Start"), input_seq() ) \
INPUT_PORT_DIGITAL_TYPE( 0, OTHER, START8, N_p("input-name", "8 Players Start"), input_seq() ) \
INPUT_PORT_DIGITAL_TYPE( 0, OTHER, START5, N_p("input-name", "5 Players Start"), input_seq(JOYCODE_START_INDEXED(4)) ) \
INPUT_PORT_DIGITAL_TYPE( 0, OTHER, START6, N_p("input-name", "6 Players Start"), input_seq(JOYCODE_START_INDEXED(5)) ) \
INPUT_PORT_DIGITAL_TYPE( 0, OTHER, START7, N_p("input-name", "7 Players Start"), input_seq(JOYCODE_START_INDEXED(6)) ) \
INPUT_PORT_DIGITAL_TYPE( 0, OTHER, START8, N_p("input-name", "8 Players Start"), input_seq(JOYCODE_START_INDEXED(7)) ) \
CORE_INPUT_TYPES_END()

#define CORE_INPUT_TYPES_COIN \
Expand All @@ -572,10 +572,10 @@ namespace {
INPUT_PORT_DIGITAL_TYPE( 0, OTHER, COIN2, N_p("input-name", "Coin 2"), input_seq(KEYCODE_6, input_seq::or_code, JOYCODE_SELECT_INDEXED(1)) ) \
INPUT_PORT_DIGITAL_TYPE( 0, OTHER, COIN3, N_p("input-name", "Coin 3"), input_seq(KEYCODE_7, input_seq::or_code, JOYCODE_SELECT_INDEXED(2)) ) \
INPUT_PORT_DIGITAL_TYPE( 0, OTHER, COIN4, N_p("input-name", "Coin 4"), input_seq(KEYCODE_8, input_seq::or_code, JOYCODE_SELECT_INDEXED(3)) ) \
INPUT_PORT_DIGITAL_TYPE( 0, OTHER, COIN5, N_p("input-name", "Coin 5"), input_seq() ) \
INPUT_PORT_DIGITAL_TYPE( 0, OTHER, COIN6, N_p("input-name", "Coin 6"), input_seq() ) \
INPUT_PORT_DIGITAL_TYPE( 0, OTHER, COIN7, N_p("input-name", "Coin 7"), input_seq() ) \
INPUT_PORT_DIGITAL_TYPE( 0, OTHER, COIN8, N_p("input-name", "Coin 8"), input_seq() ) \
INPUT_PORT_DIGITAL_TYPE( 0, OTHER, COIN5, N_p("input-name", "Coin 5"), input_seq(JOYCODE_SELECT_INDEXED(4)) ) \
INPUT_PORT_DIGITAL_TYPE( 0, OTHER, COIN6, N_p("input-name", "Coin 6"), input_seq(JOYCODE_SELECT_INDEXED(5)) ) \
INPUT_PORT_DIGITAL_TYPE( 0, OTHER, COIN7, N_p("input-name", "Coin 7"), input_seq(JOYCODE_SELECT_INDEXED(6)) ) \
INPUT_PORT_DIGITAL_TYPE( 0, OTHER, COIN8, N_p("input-name", "Coin 8"), input_seq(JOYCODE_SELECT_INDEXED(7)) ) \
INPUT_PORT_DIGITAL_TYPE( 0, OTHER, COIN9, N_p("input-name", "Coin 9"), input_seq() ) \
INPUT_PORT_DIGITAL_TYPE( 0, OTHER, COIN10, N_p("input-name", "Coin 10"), input_seq() ) \
INPUT_PORT_DIGITAL_TYPE( 0, OTHER, COIN11, N_p("input-name", "Coin 11"), input_seq() ) \
Expand Down
4 changes: 4 additions & 0 deletions src/osd/libretro/libretro-internal/libretro.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,10 @@ video_changed=true;
input_descriptor_macro(4)

input_descriptor_macro(5)

input_descriptor_macro(6)

input_descriptor_macro(7)

{ 0 },
};
Expand Down
8 changes: 4 additions & 4 deletions src/osd/libretro/libretro-internal/libretro_shared.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,12 @@ extern char mame_4way_map[256];
extern bool res_43;
extern bool video_changed;

extern int mouseLX[4];
extern int mouseLY[4];
extern int mouseLX[8];
extern int mouseLY[8];
extern int mouseBUT[4];

extern int lightgunX[4];
extern int lightgunY[4];
extern int lightgunX[8];
extern int lightgunY[8];
extern int lightgunBUT[4];

extern unsigned short retrokbd_state[RETROK_LAST];
Expand Down
162 changes: 75 additions & 87 deletions src/osd/modules/input/input_retro.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@
static bool libretro_supports_bitmasks = false;
uint16_t retrokbd_state[RETROK_LAST];
uint16_t retrokbd_state2[RETROK_LAST];
int mouseLX[4];
int mouseLY[4];
Joystate joystate[6];
Mousestate mousestate[4];
Lightgunstate lightgunstate[4];
int mouseLX[8];
int mouseLY[8];
Joystate joystate[8];
Mousestate mousestate[8];
Lightgunstate lightgunstate[8];

int lightgunX[4], lightgunY[4];
int lightgunX[8], lightgunY[8];

#ifndef RETROK_TILDE
#define RETROK_TILDE 178
Expand Down Expand Up @@ -568,19 +568,19 @@ void retro_osd_interface::process_joypad_state(running_machine &machine)
{
unsigned i, j;
int analog_l2, analog_r2;
int16_t ret[6];
int16_t ret[8];

if (libretro_supports_bitmasks)
{
for(j = 0;j < 6; j++)
for(j = 0;j < 8; j++)
{
ret[j] = 0;
ret[j] = input_state_cb(j, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_MASK);
}
}
else
{
for(j = 0;j < 6; j++)
for(j = 0;j < 8; j++)
{
ret[j] = 0;
for(i = 0;i < RETRO_MAX_BUTTONS; i++)
Expand All @@ -589,7 +589,7 @@ void retro_osd_interface::process_joypad_state(running_machine &machine)
}
}

for(j = 0;j < 6; j++)
for(j = 0;j < 8; j++)
{
for(i = 0;i < RETRO_MAX_BUTTONS; i++)
{
Expand Down Expand Up @@ -625,14 +625,14 @@ void retro_osd_interface::process_joypad_state(running_machine &machine)
void retro_osd_interface::process_mouse_state(running_machine &machine)
{
unsigned i;
for(i = 0;i < 4; i++)
for(i = 0;i < 8; i++)
{
static int mbL[4] = {0}, mbR[4] = {0}, mbM[4] = {0};
int mouse_l[4];
int mouse_r[4];
int mouse_m[4];
int16_t mouse_x[4];
int16_t mouse_y[4];
static int mbL[8] = {0}, mbR[8] = {0}, mbM[8] = {0};
int mouse_l[8];
int mouse_r[8];
int mouse_m[8];
int16_t mouse_x[8];
int16_t mouse_y[8];
//printf("mouseneable=%d\n",mouse_enable);
if (!mouse_enable)
return;
Expand All @@ -645,112 +645,100 @@ void retro_osd_interface::process_mouse_state(running_machine &machine)
mouseLX[i] = mouse_x[i]*INPUT_RELATIVE_PER_PIXEL;
mouseLY[i] = mouse_y[i]*INPUT_RELATIVE_PER_PIXEL;

static int vmx[4], vmy[4], ovmx[4], ovmy[4];
vmx[i]=fb_width/2;
vmy[i]=fb_height/2;
ovmx[i]=fb_width/2;
ovmy[i]=fb_height/2;

vmx[i]+=mouse_x[i];
vmy[i]+=mouse_y[i];
if(vmx[i]>fb_width)vmx[i]=fb_width-1;
if(vmy[i]>fb_height)vmy[i]=fb_height-1;
if(vmx[i]<0)vmx[i]=0;
if(vmy[i]<0)vmy[i]=0;
if(vmx[i]!=ovmx[i] || vmy[i]!=ovmy[i]){
static int vmx=fb_width/2,vmy=fb_height/2;
static int ovmx=fb_width/2,ovmy=fb_height/2;

vmx+=mouse_x[0];
vmy+=mouse_y[0];
if(vmx>fb_width)vmx=fb_width-1;
if(vmy>fb_height)vmy=fb_height-1;
if(vmx<0)vmx=0;
if(vmy<0)vmy=0;
if(vmx!=ovmx || vmy!=ovmy){
int cx = -1, cy = -1;
auto window = osd_common_t::s_window_list.front();

if (window != nullptr && window->renderer().xy_to_render_target(vmx[i], vmy[i], &cx, &cy))
if (window != nullptr && window->renderer().xy_to_render_target(vmx, vmy, &cx, &cy))
machine.ui_input().push_mouse_move_event(window->target(), cx, cy);
}
ovmx[i]=vmx[i];
ovmy[i]=vmy[i];
}
ovmx=vmx;
ovmy=vmy;

if(mbL[i]==0 && mouse_l[i])
{
mbL[i]=1;
mousestate[i].mouseBUT[0]=0x80;

int cx = -1, cy = -1;
auto window = osd_common_t::s_window_list.front();
//FIXME doubleclick
if (window != nullptr && window->renderer().xy_to_render_target(vmx[i], vmy[i], &cx, &cy))
machine.ui_input().push_mouse_down_event(window->target(), cx, cy);


if(i==0)
{
int cx = -1, cy = -1;
auto window = osd_common_t::s_window_list.front();
//FIXME doubleclick
if (window != nullptr && window->renderer().xy_to_render_target(vmx, vmy, &cx, &cy))
machine.ui_input().push_mouse_down_event(window->target(), cx, cy);
}
}
else if(mbL[i]==1 && !mouse_l[i])
{
mousestate[i].mouseBUT[0]=0;
mbL[i]=0;

int cx = -1, cy = -1;
auto window = osd_common_t::s_window_list.front();
if (window != nullptr && window->renderer().xy_to_render_target(vmx[i], vmy[i], &cx, &cy))
machine.ui_input().push_mouse_up_event(window->target(), cx, cy);

}
if(i==0)
{
int cx = -1, cy = -1;
auto window = osd_common_t::s_window_list.front();
if (window != nullptr && window->renderer().xy_to_render_target(vmx, vmy, &cx, &cy))
machine.ui_input().push_mouse_up_event(window->target(), cx, cy);
}
}

if(mbR[i]==0 && mouse_r[i])
{
mbR[i]=1;
mousestate[i].mouseBUT[1]=0x80;

int cx = -1, cy = -1;
auto window = osd_common_t::s_window_list.front();

if (window != nullptr && window->renderer().xy_to_render_target(vmx[i], vmy[i], &cx, &cy))
machine.ui_input().push_mouse_rdown_event(window->target(), cx, cy);


}
if(i==0)
{
int cx = -1, cy = -1;
auto window = osd_common_t::s_window_list.front();
if (window != nullptr && window->renderer().xy_to_render_target(vmx, vmy, &cx, &cy))
machine.ui_input().push_mouse_rdown_event(window->target(), cx, cy);
}
}
else if(mbR[i]==1 && !mouse_r[i])
{
mousestate[i].mouseBUT[1]=0;
mbR[i]=0;

int cx = -1, cy = -1;
auto window = osd_common_t::s_window_list.front();
if (window != nullptr && window->renderer().xy_to_render_target(vmx[i], vmy[i], &cx, &cy))
machine.ui_input().push_mouse_rup_event(window->target(), cx, cy);

}
if(i==0)
{
int cx = -1, cy = -1;
auto window = osd_common_t::s_window_list.front();
if (window != nullptr && window->renderer().xy_to_render_target(vmx, vmy, &cx, &cy))
machine.ui_input().push_mouse_rup_event(window->target(), cx, cy);
}
}

if(mbM[i]==0 && mouse_m[i])
{
mbM[i]=1;
mousestate[i].mouseBUT[2]=0x80;

int cx = -1, cy = -1;
auto window = osd_common_t::s_window_list.front();

if (window != nullptr && window->renderer().xy_to_render_target(vmx[i], vmy[i], &cx, &cy))
machine.ui_input().push_mouse_rdown_event(window->target(), cx, cy);


}
else if(mbM[i]==1 && !mouse_m[i])
{
mousestate[i].mouseBUT[2]=0;
mbM[i]=0;

int cx = -1, cy = -1;
auto window = osd_common_t::s_window_list.front();
if (window != nullptr && window->renderer().xy_to_render_target(vmx[i], vmy[i], &cx, &cy))
machine.ui_input().push_mouse_rup_event(window->target(), cx, cy);

}
}
//printf("vm(%d,%d) mc(%d,%d) mr(%d,%d)\n",vmx[i],vmy[i],mouse_x[i],mouse_y[i],mouseLX[i],mouseLY[i]);
//printf("vm(%d,%d) mc(%d,%d) mr(%d,%d)\n",vmx,vmy,mouse_x[0],mouse_y[0],mouseLX[0],mouseLY[0]);
}

void retro_osd_interface::process_lightgun_state(running_machine &machine)
{
unsigned i,j;
for(j = 0;j < 4; j++)
for(j = 0;j < 8; j++)
{
int16_t gun_x_raw[4], gun_y_raw[4];
int16_t gun_x_raw[8], gun_y_raw[8];

if ( lightgun_mode == RETRO_SETTING_LIGHTGUN_MODE_DISABLED ) {
return;
Expand All @@ -766,10 +754,10 @@ void retro_osd_interface::process_lightgun_state(running_machine &machine)

// handle pointer presses
// use multi-touch to support different button inputs
int touch_count[4];
touch_count[i] = input_state_cb( i, RETRO_DEVICE_POINTER, 0, RETRO_DEVICE_ID_POINTER_COUNT );
if ( touch_count[i] > 0 && touch_count[i] <= 4 ) {
lightgunstate[j].lightgunBUT[touch_count[i]-1] = 0x80;
int touch_count[8];
touch_count[j] = input_state_cb( j, RETRO_DEVICE_POINTER, 0, RETRO_DEVICE_ID_POINTER_COUNT );
if ( touch_count[j] > 0 && touch_count[j] <= 4 ) {
lightgunstate[j].lightgunBUT[touch_count[j]-1] = 0x80;
}
} else { // lightgun is default when enabled
gun_x_raw[j] = input_state_cb( j, RETRO_DEVICE_LIGHTGUN, 0, RETRO_DEVICE_ID_LIGHTGUN_SCREEN_X );
Expand Down Expand Up @@ -894,7 +882,7 @@ class retro_mouse_device : public event_based_device<KeyPressEventArgs>
void reset() override
{
int j;
for(j = 0; j < 4; j++)
for(j = 0; j < 8; j++)
{
mouseLX[j]=fb_width/2;
mouseLY[j]=fb_height/2;
Expand Down Expand Up @@ -932,7 +920,7 @@ class mouse_input_retro : public retroinput_module
int i;
char defname[32];

for(i = 0; i < 4; i++)
for(i = 0; i < 8; i++)
{
sprintf(defname, "Retro mouse%d", i);

Expand Down Expand Up @@ -1031,7 +1019,7 @@ class joystick_input_retro : public retroinput_module
if (buttons_profiles)
Input_Binding(machine);

for (i = 0; i < 6; i++)
for (i = 0; i < 8; i++)
{
sprintf(defname, "RetroPad%d", i);

Expand Down Expand Up @@ -1142,7 +1130,7 @@ class retro_lightgun_device : public event_based_device<KeyPressEventArgs>
void reset() override
{
int j;
for(j = 0; j < 4; j++)
for(j = 0; j < 8; j++)
{
lightgunX[j]=fb_width/2;
lightgunY[j]=fb_height/2;
Expand Down Expand Up @@ -1180,7 +1168,7 @@ class lightgun_input_retro : public retroinput_module
int i;
char defname[32];

for(i = 0; i < 4; i++)
for(i = 0; i < 8; i++)
{
sprintf(defname, "Retro lightgun%d", i);

Expand Down
Loading

0 comments on commit 7f27253

Please sign in to comment.