diff --git a/src/input/binding.cpp b/src/input/binding.cpp
index 595adc6a8..aa1880fc4 100644
--- a/src/input/binding.cpp
+++ b/src/input/binding.cpp
@@ -29,9 +29,13 @@
*/
void Binding::save(std::ofstream& stream) const
{
- stream << "id=\"" << m_id << "\" "
- << "event=\"" << m_type << "\" "
- << "character=\"" << m_character << "\" ";
+ stream << "event=\"" << m_type << "\" ";
+ stream << "id=\"" << m_id << "\" ";
+
+ if (m_type == Input::IT_KEYBOARD)
+ {
+ stream << "character=\"" << m_character << "\" ";
+ }
// Only serialize the direction and the range for stick motions
if (m_type == Input::IT_STICKMOTION)
diff --git a/src/input/device_manager.cpp b/src/input/device_manager.cpp
index 4ca09160b..50bf27c8f 100644
--- a/src/input/device_manager.cpp
+++ b/src/input/device_manager.cpp
@@ -643,6 +643,18 @@ void DeviceManager::save()
configfile << "\n\n";
+ configfile << "\n\n";
+
for(unsigned int n=0; n