MCPcopy Create free account
hub / github.com/BlitterStudio/amiberry / switchdevice

Function switchdevice

src/inputdevice.cpp:6048–6332  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6046}
6047
6048static int switchdevice (struct uae_input_device *id, int num, bool buttonmode)
6049{
6050 int ismouse = 0;
6051 int newport = 0;
6052 int newslot = -1;
6053 int devindex = -1;
6054 int flags = 0;
6055 const TCHAR *name = NULL, *fname = NULL;
6056 int otherbuttonpressed = 0;
6057 int acc = input_acquired;
6058 const int *customswitch = NULL;
6059
6060
6061#if SWITCH_DEBUG
6062 write_log (_T("switchdevice '%s' %d %d\n"), id->name, num, buttonmode);
6063#endif
6064
6065 if (num >= 4)
6066 return 0;
6067 if (!currprefs.input_autoswitch)
6068 return false;
6069 if (!target_can_autoswitchdevice())
6070 return 0;
6071
6072 for (int i = 0; i < MAX_INPUT_DEVICES; i++) {
6073 if (id == &joysticks[i]) {
6074 name = idev[IDTYPE_JOYSTICK].get_uniquename (i);
6075 fname = idev[IDTYPE_JOYSTICK].get_friendlyname (i);
6076 newport = num == 0 ? 1 : 0;
6077 flags = idev[IDTYPE_JOYSTICK].get_flags (i);
6078 for (int j = 0; j < MAX_INPUT_DEVICES; j++) {
6079 if (j != i) {
6080 struct uae_input_device2 *id2 = &joysticks2[j];
6081 if (id2->buttonmask)
6082 otherbuttonpressed = 1;
6083 }
6084 }
6085 customswitch = custom_autoswitch_joy;
6086 devindex = i;
6087 } else if (id == &mice[i]) {
6088 ismouse = 1;
6089 name = idev[IDTYPE_MOUSE].get_uniquename (i);
6090 fname = idev[IDTYPE_MOUSE].get_friendlyname (i);
6091 newport = num == 0 ? 0 : 1;
6092 flags = idev[IDTYPE_MOUSE].get_flags (i);
6093 customswitch = custom_autoswitch_mouse;
6094 devindex = i;
6095 }
6096 }
6097 if (!name) {
6098#if SWITCH_DEBUG
6099 write_log(_T("device not found!?\n"));
6100#endif
6101 return 0;
6102 }
6103 if (buttonmode) {
6104 if (num == 0 && otherbuttonpressed)
6105 newport = newport ? 0 : 1;

Callers 3

setbuttonstateallFunction · 0.85
setjoybuttonstateFunction · 0.85
setjoystickstateFunction · 0.85

Calls 11

jsem_ismouseFunction · 0.85
inputdevice_unacquireFunction · 0.85
statusline_add_messageFunction · 0.85
jsem_isjoyFunction · 0.85
inputdevice_copyconfigFunction · 0.85
inputdevice_acquireFunction · 0.85
getoldportFunction · 0.85
write_logFunction · 0.70

Tested by

no test coverage detected