void info_xml_creator::output_switches(const ioport_list &portlist, const char *root_tag, int type, const char *outertag, const char *innertag) { // iterate looking for DIP switches for (ioport_port *port = portlist.first(); port != NULL; port = port->next()) for (ioport_field *field = port->first_field(); field != NULL; field = field->next()) if (field->type() == type) { astring output; astring newtag(port->tag()), oldtag(":"); newtag.substr(newtag.find(oldtag.cat(root_tag)) + oldtag.len()); // output the switch name information astring normalized_field_name(xml_normalize_string(field->name())); astring normalized_newtag(xml_normalize_string(newtag)); output.catprintf("\t\t<%s name=\"%s\" tag=\"%s\" mask=\"%u\">\n", outertag, normalized_field_name.cstr(), normalized_newtag.cstr(), field->mask()); // loop over settings for (ioport_setting *setting = field->first_setting(); setting != NULL; setting = setting->next()) { output.catprintf("\t\t\t<%s name=\"%s\" value=\"%u\"%s/>\n", innertag, xml_normalize_string(setting->name()), setting->value(), setting->value() == field->defvalue() ? " default=\"yes\"" : ""); } // terminate the switch entry output.catprintf("\t\t</%s>\n", outertag); fprintf(m_output, "%s", output.cstr()); } }
void info_xml_creator::output_switches(const ioport_list &portlist, int type, const char *outertag, const char *innertag) { // iterate looking for DIP switches for (input_port_config *port = portlist.first(); port != NULL; port = port->next()) for (input_field_config *field = port->fieldlist().first(); field != NULL; field = field->next()) if (field->type == type) { // output the switch name information fprintf(m_output, "\t\t<%s name=\"%s\"", outertag, xml_normalize_string(input_field_name(field))); fprintf(m_output, " tag=\"%s\"", xml_normalize_string(field->port().tag())); fprintf(m_output, " mask=\"%u\"", field->mask); fprintf(m_output, ">\n"); // loop over settings for (input_setting_config *setting = field->settinglist().first(); setting != NULL; setting = setting->next()) { fprintf(m_output, "\t\t\t<%s name=\"%s\"", innertag, xml_normalize_string(setting->name)); fprintf(m_output, " value=\"%u\"", setting->value); if (setting->value == field->defvalue) fprintf(m_output, " default=\"yes\""); fprintf(m_output, "/>\n"); } // terminate the switch entry fprintf(m_output, "\t\t</%s>\n", outertag); } }
void info_xml_creator::output_adjusters(const ioport_list &portlist) { // iterate looking for Adjusters for (ioport_port *port = portlist.first(); port != NULL; port = port->next()) for (ioport_field *field = port->first_field(); field != NULL; field = field->next()) if (field->type() == IPT_ADJUSTER) fprintf(m_output, "\t\t<adjuster name=\"%s\" default=\"%d\"/>\n", xml_normalize_string(field->name()), field->defvalue()); }
//------------------------------------------------- // output_ports - print the structure of input // ports in the driver //------------------------------------------------- void info_xml_creator::output_ports(const ioport_list &portlist) { // cycle through ports for (ioport_port *port = portlist.first(); port != NULL; port = port->next()) { fprintf(m_output,"\t\t<port tag=\"%s\">\n",port->tag()); for (ioport_field *field = port->first_field(); field != NULL; field = field->next()) { if(field->is_analog()) fprintf(m_output,"\t\t\t<analog mask=\"%u\"/>\n",field->mask()); } // close element fprintf(m_output,"\t\t</port>\n"); } }
void info_xml_creator::output_categories(const ioport_list &portlist) { // iterate looking for Categories for (input_port_config *port = portlist.first(); port != NULL; port = port->next()) for (input_field_config *field = port->fieldlist().first(); field != NULL; field = field->next()) if (field->type == IPT_CATEGORY) { // output the category name information fprintf(m_output, "\t\t<category name=\"%s\">\n", xml_normalize_string(input_field_name(field))); // loop over item settings for (input_setting_config *setting = field->settinglist().first(); setting != NULL; setting = setting->next()) { fprintf(m_output, "\t\t\t<item name=\"%s\"", xml_normalize_string(setting->name)); if (setting->value == field->defvalue) fprintf(m_output, " default=\"yes\""); fprintf(m_output, "/>\n"); } // terminate the category entry fprintf(m_output, "\t\t</category>\n"); } }
void info_xml_creator::output_input(const ioport_list &portlist) { // enumerated list of control types enum { ANALOG_TYPE_PADDLE, ANALOG_TYPE_PEDAL, ANALOG_TYPE_JOYSTICK, ANALOG_TYPE_POSITIONAL, ANALOG_TYPE_LIGHTGUN, ANALOG_TYPE_DIAL, ANALOG_TYPE_TRACKBALL, ANALOG_TYPE_MOUSE, ANALOG_TYPE_COUNT }; // directions const UINT8 DIR_UP = 0x01; const UINT8 DIR_DOWN = 0x02; const UINT8 DIR_LEFT = 0x04; const UINT8 DIR_RIGHT = 0x08; const UINT8 DIR_4WAY = 0x10; // initialize the list of control types struct { const char * type; /* general type of input */ bool analog; bool keyb; INT32 min; /* analog minimum value */ INT32 max; /* analog maximum value */ INT32 sensitivity; /* default analog sensitivity */ INT32 keydelta; /* default analog keydelta */ bool reverse; /* default analog reverse setting */ } control_info[ANALOG_TYPE_COUNT]; memset(&control_info, 0, sizeof(control_info)); // tracking info as we iterate int nplayer = 0; int nbutton = 0; int ncoin = 0; UINT8 joytype[3] = { 0,0,0 }; bool service = false; bool tilt = false; bool keypad = false; bool keyboard = false; bool mahjong = false; bool hanafuda = false; bool gambling = false; // iterate over the ports for (ioport_port *port = portlist.first(); port != NULL; port = port->next()) for (ioport_field *field = port->first_field(); field != NULL; field = field->next()) { int analogtype = -1; // track the highest player number if (nplayer < field->player() + 1) nplayer = field->player() + 1; // switch off of the type switch (field->type()) { // map which joystick directions are present case IPT_JOYSTICK_UP: joytype[0] |= DIR_UP | ((field->way() == 4) ? DIR_4WAY : 0); break; case IPT_JOYSTICK_DOWN: joytype[0] |= DIR_DOWN | ((field->way() == 4) ? DIR_4WAY : 0); break; case IPT_JOYSTICK_LEFT: joytype[0] |= DIR_LEFT | ((field->way() == 4) ? DIR_4WAY : 0); break; case IPT_JOYSTICK_RIGHT: joytype[0] |= DIR_RIGHT | ((field->way() == 4) ? DIR_4WAY : 0); break; case IPT_JOYSTICKLEFT_UP: joytype[1] |= DIR_UP | ((field->way() == 4) ? DIR_4WAY : 0); break; case IPT_JOYSTICKLEFT_DOWN: joytype[1] |= DIR_DOWN | ((field->way() == 4) ? DIR_4WAY : 0); break; case IPT_JOYSTICKLEFT_LEFT: joytype[1] |= DIR_LEFT | ((field->way() == 4) ? DIR_4WAY : 0); break; case IPT_JOYSTICKLEFT_RIGHT: joytype[1] |= DIR_RIGHT | ((field->way() == 4) ? DIR_4WAY : 0); break; case IPT_JOYSTICKRIGHT_UP: joytype[2] |= DIR_UP | ((field->way() == 4) ? DIR_4WAY : 0); break; case IPT_JOYSTICKRIGHT_DOWN: joytype[2] |= DIR_DOWN | ((field->way() == 4) ? DIR_4WAY : 0); break; case IPT_JOYSTICKRIGHT_LEFT: joytype[2] |= DIR_LEFT | ((field->way() == 4) ? DIR_4WAY : 0); break; case IPT_JOYSTICKRIGHT_RIGHT: joytype[2] |= DIR_RIGHT | ((field->way() == 4) ? DIR_4WAY : 0); break; // mark as an analog input, and get analog stats after switch case IPT_AD_STICK_X: case IPT_AD_STICK_Y: case IPT_AD_STICK_Z: control_info[analogtype = ANALOG_TYPE_JOYSTICK].type = "stick"; break; case IPT_PADDLE: case IPT_PADDLE_V: control_info[analogtype = ANALOG_TYPE_PADDLE].type = "paddle"; break; case IPT_PEDAL: case IPT_PEDAL2: case IPT_PEDAL3: control_info[analogtype = ANALOG_TYPE_PEDAL].type = "pedal"; break; case IPT_LIGHTGUN_X: case IPT_LIGHTGUN_Y: control_info[analogtype = ANALOG_TYPE_LIGHTGUN].type = "lightgun"; break; case IPT_POSITIONAL: case IPT_POSITIONAL_V: control_info[analogtype = ANALOG_TYPE_POSITIONAL].type = "positional"; break; case IPT_DIAL: case IPT_DIAL_V: control_info[analogtype = ANALOG_TYPE_DIAL].type = "dial"; break; case IPT_TRACKBALL_X: case IPT_TRACKBALL_Y: control_info[analogtype = ANALOG_TYPE_TRACKBALL].type = "trackball"; break; case IPT_MOUSE_X: case IPT_MOUSE_Y: control_info[analogtype = ANALOG_TYPE_MOUSE].type = "mouse"; break; // track maximum button index case IPT_BUTTON1: case IPT_BUTTON2: case IPT_BUTTON3: case IPT_BUTTON4: case IPT_BUTTON5: case IPT_BUTTON6: case IPT_BUTTON7: case IPT_BUTTON8: case IPT_BUTTON9: case IPT_BUTTON10: case IPT_BUTTON11: case IPT_BUTTON12: case IPT_BUTTON13: case IPT_BUTTON14: case IPT_BUTTON15: case IPT_BUTTON16: nbutton = MAX(nbutton, field->type() - IPT_BUTTON1 + 1); break; // track maximum coin index case IPT_COIN1: case IPT_COIN2: case IPT_COIN3: case IPT_COIN4: case IPT_COIN5: case IPT_COIN6: case IPT_COIN7: case IPT_COIN8: ncoin = MAX(ncoin, field->type() - IPT_COIN1 + 1); break; // track presence of these guys case IPT_KEYPAD: keypad = true; break; case IPT_KEYBOARD: keyboard = true; break; // additional types case IPT_SERVICE: service = true; break; case IPT_TILT: tilt = true; break; default: if (field->type() > IPT_MAHJONG_FIRST && field->type() < IPT_MAHJONG_LAST) mahjong = true; else if (field->type() > IPT_HANAFUDA_FIRST && field->type() < IPT_HANAFUDA_LAST) hanafuda = true; else if (field->type() > IPT_GAMBLING_FIRST && field->type() < IPT_GAMBLING_LAST) gambling = true; break; } // get the analog stats if (analogtype != -1) { if (field->minval() != 0) control_info[analogtype].min = field->minval(); if (field->maxval() != 0) control_info[analogtype].max = field->maxval(); if (field->sensitivity() != 0) control_info[analogtype].sensitivity = field->sensitivity(); if (field->delta() != 0) control_info[analogtype].keydelta = field->delta(); if (field->analog_reverse() != 0) control_info[analogtype].reverse = true; } } // output the basic info fprintf(m_output, "\t\t<input"); fprintf(m_output, " players=\"%d\"", nplayer); if (nbutton != 0) fprintf(m_output, " buttons=\"%d\"", nbutton); if (ncoin != 0) fprintf(m_output, " coins=\"%d\"", ncoin); if (service) fprintf(m_output, " service=\"yes\""); if (tilt) fprintf(m_output, " tilt=\"yes\""); fprintf(m_output, ">\n"); // output the joystick types if (joytype[1]==0 && joytype[2]!=0) { joytype[1] = joytype[2]; joytype[2] = 0; } if (joytype[0]==0 && joytype[1]!=0) { joytype[0] = joytype[1]; joytype[1] = 0; } if (joytype[1]==0 && joytype[2]!=0) { joytype[1] = joytype[2]; joytype[2] = 0; } if (joytype[0] != 0) { const char *joys = (joytype[2]!=0) ? "triple" : (joytype[1]!=0) ? "double" : ""; fprintf(m_output, "\t\t\t<control type=\"%sjoy\"", joys); for (int lp=0; lp<3 && joytype[lp]!=0; lp++) { const char *plural = (lp==2) ? "3" : (lp==1) ? "2" : ""; const char *ways; switch (joytype[lp] & (DIR_UP | DIR_DOWN | DIR_LEFT | DIR_RIGHT)) { case DIR_UP | DIR_DOWN | DIR_LEFT | DIR_RIGHT: ways = ((joytype[lp] & DIR_4WAY) != 0) ? "4" : "8"; break; case DIR_LEFT | DIR_RIGHT: ways = "2"; break; case DIR_UP | DIR_DOWN: ways = "vertical2"; break; case DIR_UP: case DIR_DOWN: case DIR_LEFT: case DIR_RIGHT: ways = "1"; break; case DIR_UP | DIR_DOWN | DIR_LEFT: case DIR_UP | DIR_DOWN | DIR_RIGHT: case DIR_UP | DIR_LEFT | DIR_RIGHT: case DIR_DOWN | DIR_LEFT | DIR_RIGHT: ways = ((joytype[lp] & DIR_4WAY) != 0) ? "3 (half4)" : "5 (half8)"; break; default: ways = "strange2"; break; } fprintf(m_output, " ways%s=\"%s\"", plural,ways); } fprintf(m_output, "/>\n"); } // output analog types for (int type = 0; type < ANALOG_TYPE_COUNT; type++) if (control_info[type].type != NULL) { fprintf(m_output, "\t\t\t<control type=\"%s\"", xml_normalize_string(control_info[type].type)); if (control_info[type].min != 0 || control_info[type].max != 0) { fprintf(m_output, " minimum=\"%d\"", control_info[type].min); fprintf(m_output, " maximum=\"%d\"", control_info[type].max); } if (control_info[type].sensitivity != 0) fprintf(m_output, " sensitivity=\"%d\"", control_info[type].sensitivity); if (control_info[type].keydelta != 0) fprintf(m_output, " keydelta=\"%d\"", control_info[type].keydelta); if (control_info[type].reverse) fprintf(m_output, " reverse=\"yes\""); fprintf(m_output, "/>\n"); } // output keypad and keyboard if (keypad) fprintf(m_output, "\t\t\t<control type=\"keypad\"/>\n"); if (keyboard) fprintf(m_output, "\t\t\t<control type=\"keyboard\"/>\n"); // misc if (mahjong) fprintf(m_output, "\t\t\t<control type=\"mahjong\"/>\n"); if (hanafuda) fprintf(m_output, "\t\t\t<control type=\"hanafuda\"/>\n"); if (gambling) fprintf(m_output, "\t\t\t<control type=\"gambling\"/>\n"); fprintf(m_output, "\t\t</input>\n"); }
void info_xml_creator::output_input(const ioport_list &portlist) { // enumerated list of control types enum { ANALOG_TYPE_JOYSTICK, ANALOG_TYPE_DIAL, ANALOG_TYPE_TRACKBALL, ANALOG_TYPE_PADDLE, ANALOG_TYPE_LIGHTGUN, ANALOG_TYPE_PEDAL, ANALOG_TYPE_COUNT }; // directions const UINT8 DIR_LEFTRIGHT = 0x01; const UINT8 DIR_UPDOWN = 0x02; const UINT8 DIR_4WAY = 0x04; const UINT8 DIR_DUAL = 0x08; // initialize the list of control types struct { const char * type; /* general type of input */ bool analog; bool keyb; INT32 min; /* analog minimum value */ INT32 max; /* analog maximum value */ INT32 sensitivity; /* default analog sensitivity */ INT32 keydelta; /* default analog keydelta */ bool reverse; /* default analog reverse setting */ } control_info[ANALOG_TYPE_COUNT]; memset(&control_info, 0, sizeof(control_info)); // tracking info as we iterate int nplayer = 0; int nbutton = 0; int ncoin = 0; UINT8 joytype = 0; bool service = false; bool tilt = false; bool keypad = false; bool keyboard = false; // iterate over the ports for (input_port_config *port = portlist.first(); port != NULL; port = port->next()) for (input_field_config *field = port->fieldlist().first(); field != NULL; field = field->next()) { int analogtype = -1; // track the highest player number if (nplayer < field->player + 1) nplayer = field->player + 1; // switch off of the type switch (field->type) { // map which joystick directions are present case IPT_JOYSTICKRIGHT_LEFT: case IPT_JOYSTICKRIGHT_RIGHT: case IPT_JOYSTICKLEFT_LEFT: case IPT_JOYSTICKLEFT_RIGHT: joytype |= DIR_DUAL; // fall through... case IPT_JOYSTICK_LEFT: case IPT_JOYSTICK_RIGHT: joytype |= DIR_LEFTRIGHT | ((field->way == 4) ? DIR_4WAY : 0); break; case IPT_JOYSTICKRIGHT_UP: case IPT_JOYSTICKRIGHT_DOWN: case IPT_JOYSTICKLEFT_UP: case IPT_JOYSTICKLEFT_DOWN: joytype |= DIR_DUAL; // fall through... case IPT_JOYSTICK_UP: case IPT_JOYSTICK_DOWN: joytype |= DIR_UPDOWN | ((field->way == 4) ? DIR_4WAY : 0); break; // mark as an analog input, and get analog stats after switch case IPT_PADDLE: control_info[analogtype = ANALOG_TYPE_PADDLE].type = "paddle"; break; case IPT_DIAL: control_info[analogtype = ANALOG_TYPE_DIAL].type = "dial"; analogtype = ANALOG_TYPE_DIAL; break; case IPT_TRACKBALL_X: case IPT_TRACKBALL_Y: control_info[analogtype = ANALOG_TYPE_TRACKBALL].type = "trackball"; analogtype = ANALOG_TYPE_TRACKBALL; break; case IPT_AD_STICK_X: case IPT_AD_STICK_Y: control_info[analogtype = ANALOG_TYPE_JOYSTICK].type = "stick"; break; case IPT_LIGHTGUN_X: case IPT_LIGHTGUN_Y: control_info[analogtype = ANALOG_TYPE_LIGHTGUN].type = "lightgun"; break; case IPT_PEDAL: case IPT_PEDAL2: case IPT_PEDAL3: control_info[analogtype = ANALOG_TYPE_PEDAL].type = "pedal"; break; // track maximum button index case IPT_BUTTON1: case IPT_BUTTON2: case IPT_BUTTON3: case IPT_BUTTON4: case IPT_BUTTON5: case IPT_BUTTON6: case IPT_BUTTON7: case IPT_BUTTON8: case IPT_BUTTON9: case IPT_BUTTON10: case IPT_BUTTON11: case IPT_BUTTON12: case IPT_BUTTON13: case IPT_BUTTON14: case IPT_BUTTON15: case IPT_BUTTON16: nbutton = MAX(nbutton, field->type - IPT_BUTTON1 + 1); break; // track maximum coin index case IPT_COIN1: case IPT_COIN2: case IPT_COIN3: case IPT_COIN4: case IPT_COIN5: case IPT_COIN6: case IPT_COIN7: case IPT_COIN8: ncoin = MAX(ncoin, field->type - IPT_COIN1 + 1); break; // track presence of these guys case IPT_KEYPAD: keypad = true; break; case IPT_KEYBOARD: keyboard = true; break; // additional types case IPT_SERVICE: service = true; break; case IPT_TILT: tilt = true; break; } // get the analog stats if (analogtype != -1) { if (field->min != 0) control_info[analogtype].min = field->min; if (field->max != 0) control_info[analogtype].max = field->max; if (field->sensitivity != 0) control_info[analogtype].sensitivity = field->sensitivity; if (field->delta != 0) control_info[analogtype].keydelta = field->delta; if ((field->flags & ANALOG_FLAG_REVERSE) != 0) control_info[analogtype].reverse = true; } } // output the basic info fprintf(m_output, "\t\t<input"); fprintf(m_output, " players=\"%d\"", nplayer); if (nbutton != 0) fprintf(m_output, " buttons=\"%d\"", nbutton); if (ncoin != 0) fprintf(m_output, " coins=\"%d\"", ncoin); if (service) fprintf(m_output, " service=\"yes\""); if (tilt) fprintf(m_output, " tilt=\"yes\""); fprintf(m_output, ">\n"); // output the joystick types if (joytype != 0) { const char *vertical = ((joytype & DIR_LEFTRIGHT) == 0) ? "v" : ""; const char *doubletype = ((joytype & DIR_DUAL) != 0) ? "doublejoy" : "joy"; const char *way = ((joytype & DIR_LEFTRIGHT) == 0 || (joytype & DIR_UPDOWN) == 0) ? "2way" : ((joytype & DIR_4WAY) != 0) ? "4way" : "8way"; fprintf(m_output, "\t\t\t<control type=\"%s%s%s\"/>\n", vertical, doubletype, way); } // output analog types for (int type = 0; type < ANALOG_TYPE_COUNT; type++) if (control_info[type].type != NULL) { fprintf(m_output, "\t\t\t<control type=\"%s\"", xml_normalize_string(control_info[type].type)); if (control_info[type].min != 0 || control_info[type].max != 0) { fprintf(m_output, " minimum=\"%d\"", control_info[type].min); fprintf(m_output, " maximum=\"%d\"", control_info[type].max); } if (control_info[type].sensitivity != 0) fprintf(m_output, " sensitivity=\"%d\"", control_info[type].sensitivity); if (control_info[type].keydelta != 0) fprintf(m_output, " keydelta=\"%d\"", control_info[type].keydelta); if (control_info[type].reverse) fprintf(m_output, " reverse=\"yes\""); fprintf(m_output, "/>\n"); } // output keypad and keyboard if (keypad) fprintf(m_output, "\t\t\t<control type=\"keypad\"/>\n"); if (keyboard) fprintf(m_output, "\t\t\t<control type=\"keyboard\"/>\n"); fprintf(m_output, "\t\t</input>\n"); }