Apologies - I know there's lots of info out there about this subject, but that's precisely the problem - so much info about this - hard to piece it all together to understand/get it working. So many concepts and approaches involved.
Basically have read an xml file into a Dataset. I want to be able to display the dataset in a datagridview, filterable by "controlleralias.alias" (tablename.field) and by "system.name" (names from the dataset visualizer). Then, any edits within the datagirdview are saved back into the dataset.
The XML file is in the following format:
<!--
Configuration Remap file
-->
<mameconfig version="10">
<!--
############################################################
Define controller aliases, This just makes the controller names
a little easier to deal with for the rest of the file.
############################################################
-->
<controlleralias>
<id>Ultimarc Ultra-Stik Player 1</id>
<alias>U360 Player1</alias>
</controlleralias>
<controlleralias>
<id>WingMan Extreme Digital 3D</id>
<alias>Flightstick</alias>
</controlleralias>
<controlleralias>
<id>HID#VID_061C_PID_AA00#7_35df86d5_0_0000#</id>
<alias>Lightgun1</alias>
</controlleralias>
<!--
############################################################
This is the System Default section
It generally should be the FIRST system section in the cfg file
############################################################
-->
<system name="default">
<!-- put a controller element here to have it copied into ONLY this particular
system element
-->
<controller id="U360 Player1">
<input>
<port type="P1_JOYSTICK_UP">
<newseq type="standard">JOYCODE_YAXIS_UP_SWITCH</newseq>
</port>
<port type="P1_JOYSTICK_DOWN">
<newseq type="standard">
JOYCODE_YAXIS_DOWN_SWITCH
</newseq>
</port>
</input>
</controller>
<controller id="Flightstick">
<input>
<port type="P1_SELECT">
<newseq type="standard">JOYCODE_BUTTON_7</newseq>
</port>
<port type="START1">
<newseq type="standard">JOYCODE_BUTTON8_SWITCH</newseq>
</port>
</input>
</controller>
<!-- this keyboard section provides a way to specify keyboard input
mappings that should ALSO be made for the specific port types. -->
<controller id="keyboard">
<input>
<port type="P1_JOYSTICK_UP">
<newseq type="standard">KEYCODE_UP</newseq>
</port>
<port type="P1_JOYSTICK_DOWN">
<newseq type="standard">KEYCODE_DOWN</newseq>
</port>
<port type="P1_JOYSTICK_LEFT">
<newseq type="standard">KEYCODE_LEFT</newseq>
</port>
<port type="P1_JOYSTICK_RIGHT">
<newseq type="standard">KEYCODE_RIGHT</newseq>
</port>
</input>
</controller>
<!--
###################################################
ACTUAL INPUT MAPPING STARTS HERE
DO NOT actually put anything in this section.
It is completely cleared and regenerated!
###################################################
-->
<input></input>
</system>
<!--
###################################################
This is a GAME specific section
Add additional <controller> sections here
to define how those controllers should map for this
particular game
###################################################
-->
<system name="ribbit">
<!-- This would be stupid to actually use, but as an example
For this game ("Ribbit"), reverse the UP and DOWN directions
on the joystick -->
<controller id="U360 Player1">
<input>
<port type="P1_JOYSTICK_UP">
<newseq type="standard">
JOYCODE_YAXIS_DOWN_SWITCH
</newseq>
</port>
<port type="P1_JOYSTICK_DOWN">
<newseq type="standard">
JOYCODE_YAXIS_UP_SWITCH
</newseq>
</port>
</input>
</controller>
<!--
###################################################
ACTUAL INPUT MAPPING STARTS HERE
DO NOT actually put anything in this section.
It is completely cleared and regenerated!
###################################################
-->
<input></input>
</system>
</mameconfig>
Would appreciate any guidance as feel totally lost at the moment.
----- EDIT 1 and UPDATE ---------------
Getting closer with jd's help! As in comment post 2, the xml in and out: In:
<!--
Configuration Remap file
-->
<mameconfig version="10">
<!--
############################################################
Define controller aliases, This just makes the controller names
a little easier to deal with for the rest of the file.
############################################################
-->
<controlleralias>
<id>HID#Vid_1241_Pid_1111#b_2eabd86_1_0000#</id>
<alias>Trackball</alias>
</controlleralias>
<controlleralias>
<id>Ultimarc Ultra-Stik Player 1</id>
<alias>U360 Player1</alias>
</controlleralias>
<controlleralias>
<id>WingMan Extreme Digital 3D</id>
<alias>Flightstick</alias>
</controlleralias>
<controlleralias>
<id>HID#VID_061C_PID_AA00#7_35df86d5_0_0000#</id>
<alias>Lightgun1</alias>
</controlleralias>
<!--
############################################################
This is the System Default section
It generally should be the FIRST system section in the cfg file
############################################################
-->
<system name="default">
<!-- put a controller element here to have it copied into ONLY this particular
system element
-->
<controller id="U360 Player1">
<input>
<port type="P1_JOYSTICK_UP">
<newseq type="standard">JOYCODE_YAXIS_UP_SWITCH</newseq>
</port>
<port type="P1_JOYSTICK_DOWN">
<newseq type="standard">JOYCODE_YAXIS_DOWN_SWITCH</newseq>
</port>
</input>
</controller>
<controller id="Flightstick">
<input>
<port type="P1_SELECT">
<newseq type="standard">JOYCODE_BUTTON_7</newseq>
</port>
<port type="START1">
<newseq type="standard">JOYCODE_BUTTON8_SWITCH</newseq>
</port>
</input>
</controller>
<!-- this keyboard section provides a way to specify keyboard input
mappings that should ALSO be made for the specific port types. -->
<controller id="keyboard">
<input>
<port type="P1_JOYSTICK_UP">
<newseq type="standard">KEYCODE_UP</newseq>
</port>
<port type="P1_JOYSTICK_DOWN">
<newseq type="standard">KEYCODE_DOWN</newseq>
</port>
<port type="P1_JOYSTICK_LEFT">
<newseq type="standard">KEYCODE_LEFT</newseq>
</port>
<port type="P1_JOYSTICK_RIGHT">
<newseq type="standard">KEYCODE_RIGHT</newseq>
</port>
</input>
</controller>
<controller id="Trackball">
<input>
<port type="P1_TRACKBALL_X">
<newseq type="standard">MOUSECODE_XAXIS</newseq>
</port>
<port type="P1_TRACKBALL_Y">
<newseq type="standard">MOUSECODE_YAXIS</newseq>
</port>
</input>
</controller>
<controller id="Lightgun1">
<input>
<port type="P1_LIGHTGUN_X">
<newseq type="standard">GUNCODE_XAXIS</newseq>
</port>
<port type="P1_LIGHTGUN_Y">
<newseq type="standard">GUNCODE_YAXIS</newseq>
</port>
</input>
</controller>
<!--
###################################################
ACTUAL INPUT MAPPING STARTS HERE
DO NOT actually put anything in this section.
It is completely cleared and regenerated!
###################################################
-->
<input></input>
</system>
<!--
###################################################
This is a GAME specific section
Add additional <controller> sections here
to define how those controllers should map for this
particular game
###################################################
-->
<system name="ribbit">
<!-- This would be stupid to actually use, but as an example
For this game ("Ribbit"), reverse the UP and DOWN directions
on the joystick -->
<controller id="U360 Player1">
<input>
<port type="P1_JOYSTICK_UP">
<newseq type="standard">JOYCODE_YAXIS_DOWN_SWITCH</newseq>
</port>
<port type="P1_JOYSTICK_DOWN">
<newseq type="standard">JOYCODE_YAXIS_UP_SWITCH</newseq>
</port>
</input>
</controller>
<!--
###################################################
ACTUAL INPUT MAPPING STARTS HERE
DO NOT actually put anything in this section.
It is completely cleared and regenerated!
###################################################
-->
<input></input>
</system>
</mameconfig>
Out:
<?xml version="1.0" encoding="utf-8"?>
<mameconfig xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" version="10">
<controlleralias>
<id>Alias edit</id>
<alias>HID#Vid_1241_Pid_1111#b_2eabd86_1_0000#</alias>
</controlleralias>
<controlleralias>
<id>U360 Player1</id>
<alias>HID#Vid_1241_Pid_1111#b_2eabd86_1_0000#</alias>
</controlleralias>
<controlleralias>
<id>Flightstick</id>
<alias>HID#Vid_1241_Pid_1111#b_2eabd86_1_0000#</alias>
</controlleralias>
<controlleralias>
<id>keyboard</id>
<alias>HID#Vid_1241_Pid_1111#b_2eabd86_1_0000#</alias>
</controlleralias>
<controlleralias>
<id>Trackball</id>
<alias>Ultimarc Ultra-Stik Player 1</alias>
</controlleralias>
<controlleralias>
<id>Lightgun1</id>
<alias>HID#Vid_1241_Pid_1111#b_2eabd86_1_0000#</alias>
</controlleralias>
<system name="default">
<controller id="Alias edit">
<input>
<port type="Post edit">
<newseq type="type edit">newseq edit</newseq>
</port>
</input>
</controller>
<controller id="U360 Player1">
<input>
<port type="P1_JOYSTICK_DOWN">
<newseq type="standard">JOYCODE_YAXIS_DOWN_SWITCH</newseq>
</port>
</input>
</controller>
<controller id="Flightstick">
<input>
<port type="P1_SELECT">
<newseq type="standard">JOYCODE_BUTTON_7</newseq>
</port>
<port type="START1">
<newseq type="standard">JOYCODE_BUTTON8_SWITCH</newseq>
</port>
</input>
</controller>
<controller id="keyboard">
<input>
<port type="P1_JOYSTICK_UP">
<newseq type="standard">KEYCODE_UP</newseq>
</port>
<port type="P1_JOYSTICK_DOWN">
<newseq type="standard">KEYCODE_DOWN</newseq>
</port>
<port type="P1_JOYSTICK_LEFT">
<newseq type="standard">KEYCODE_LEFT</newseq>
</port>
<port type="P1_JOYSTICK_RIGHT">
<newseq type="standard">KEYCODE_RIGHT</newseq>
</port>
</input>
</controller>
<controller id="Trackball">
<input>
<port type="P1_TRACKBALL_X">
<newseq type="standard">MOUSECODE_XAXIS</newseq>
</port>
<port type="P1_TRACKBALL_Y">
<newseq type="standard">MOUSECODE_YAXIS</newseq>
</port>
</input>
</controller>
<controller id="Lightgun1">
<input>
<port type="P1_LIGHTGUN_X">
<newseq type="standard">GUNCODE_XAXIS</newseq>
</port>
<port type="P1_LIGHTGUN_Y">
<newseq type="standard">GUNCODE_YAXIS</newseq>
</port>
</input>
</controller>
</system>
<system name="ribbit">
<controller id="U360 Player1">
<input>
<port type="P1_JOYSTICK_UP">
<newseq type="standard">JOYCODE_YAXIS_DOWN_SWITCH</newseq>
</port>
<port type="P1_JOYSTICK_DOWN">
<newseq type="standard">JOYCODE_YAXIS_UP_SWITCH</newseq>
</port>
</input>
</controller>
</system>
</mameconfig>
-------- EDIT 2 ------------
jd's script nearly there (thanks)! Just couple of probs left:
1) <controlleralias>
element: Whilst writing the <id>
and <alias>
the right way round in <controlleralias>
, it seems to be mapping the wrong <id>
s against <alias>
s in places. In:
<mameconfig version="10">
<!--
############################################################
Define controller aliases, This just makes the controller names
a little easier to deal with for the rest of the file.
############################################################
-->
<controlleralias>
<id>HID#Vid_1241_Pid_1111#b_2eabd86_1_0000#</id>
<alias>Trackball</alias>
</controlleralias>
<controlleralias>
<id>Ultimarc Ultra-Stik Player 1</id>
<alias>U360 Player1</alias>
</controlleralias>
<controlleralias>
<id>WingMan Extreme Digital 3D</id>
<alias>Flightstick</alias>
</controlleralias>
<controlleralias>
<id>HID#VID_061C_PID_AA00#7_35df86d5_0_0000#</id>
<alias>Lightgun1</alias>
</controlleralias>
<!--
############################################################
This is the System Default section
It generally should be the FIRST system section in the cfg file
############################################################
-->
<system name="default">
<!-- put a controller element here to have it copied into ONLY this particular
system element
-->
<controller id="U360 Player1">
<input>
<port type="P1_JOYSTICK_UP">
<newseq type="standard">JOYCODE_YAXIS_UP_SWITCH</newseq>
</port>
<port type="P1_JOYSTICK_DOWN">
<newseq type="standard">JOYCODE_YAXIS_DOWN_SWITCH</newseq>
</port>
</input>
</controller>
Out:
<?xml version="1.0" encoding="utf-8"?>
<mameconfig xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" version="10">
<controlleralias>
<id>HID#Vid_1241_Pid_1111#b_2eabd86_1_0000#</id>
<alias>alias edit</alias>
</controlleralias>
<controlleralias>
<id>HID#Vid_1241_Pid_1111#b_2eabd86_1_0000#</id>
<alias>U360 Player1</alias>
</controlleralias>
<controlleralias>
<id>HID#Vid_1241_Pid_1111#b_2eabd86_1_0000#</id>
<alias>Flightstick</alias>
</controlleralias>
<controlleralias>
<id>HID#Vid_1241_Pid_1111#b_2eabd86_1_0000#</id>
<alias>keyboard</alias>
</controlleralias>
<controlleralias>
<id>Ultimarc Ultra-Stik Player 1</id>
<alias>Trackball</alias>
</controlleralias>
<controlleralias>
<id>HID#Vid_1241_Pid_1111#b_2eabd86_1_0000#</id>
<alias>Lightgun1</alias>
</controlleralias>
<system name="default">
<controller id="alias edit">
<input>
<port type="port edit">
<newseq type="type edit">desc edit</newseq>
</port>
</input>
</controller>
2) It appears to be skipping the <input></input>
(before any </system>
tag) of the original (see Edit 1 full Out for example). I realize these are blank, but needed in the final output version too. Suppose could fix this by search and insert text file, but any way of fixing this?
----- EDIT 3 - Finishing touches -------------
jd cracked it! However, wanting to use this script to it's full potential.
I need to populate another datatable on the same form from a separate .xml file in this format:
<?xml version="1.0"?>
<!-- This file is autogenerated; comments and unknown tags will be stripped -->
<mameconfig version="10">
<system name="default">
<input>
<port type="P1_START">
<newseq type="standard">
KEYCODE_1 OR JOYCODE_1_BUTTON10
</newseq>
</port>
<port type="P1_SELECT">
<newseq type="standard">
JOYCODE_1_BUTTON9 OR KEYCODE_F4 OR JOYCODE_2_BUTTON9
</newseq>
</port>
</input>
</system>
</mameconfig>
I have tried this by altering the code, thus (commented outs left in):
Dim xs2 As XmlSerializer = New XmlSerializer(GetType(Mameconfig))
Dim reader2 As XmlTextReader = New XmlTextReader(My.Settings.CfgFile)
mameconfig = CType(xs2.Deserialize(reader2), Mameconfig)
reader2.Close()
Version_textBox2.Text = mameconfig.version
dt2 = New DataTable()
dt2.Columns.Add("Name", GetType(String))
'dt2.Columns.Add("Controller ID", GetType(String))
'dt2.Columns.Add("Controller Alias", GetType(String))
dt2.Columns.Add("Controller Port", GetType(String))
dt2.Columns.Add("Type", GetType(String))
dt2.Columns.Add("Description", GetType(String))
For Each _system As c_System In mameconfig.system
For Each port As Port In _system.input.port
Dim newRow As DataRow = dt2.Rows.Add()
newRow("Name") = _system.name
'newRow("Controller Alias") = m_alias
'newRow("Controller ID") = id
newRow("Controller Port") = port.type
newRow("Type") = port.newSeq._type
newRow("Description") = port.newSeq.description
Next
Next
MameCfgDGV.DataSource = dt2
However, getting some random functioning, either not loading, or loading with random values, I believe from the other xml/datatable. Is there a way to re-use the code to load other xml files into different data tables?
Apologies if not as per usual posting decorum - wasn't sure how to do "follow-up" questions..