#endif
#include <iostream>
+#include <sstream>
#include <stdlib.h>
#include <stdio.h>
-#include <string.h>
+#include <string>
#include <assert.h>
#include "defines.h"
return string;
}
-/* Set ControlField a key */
+/* Set ControlField for keyboard key */
void Menu::get_controlfield_key_into_input(MenuItem *item)
{
switch(*item->int_p)
}
}
+/* Set ControlField for joystick button */
+void Menu::get_controlfield_js_into_input(MenuItem *item)
+{
+ std::ostringstream oss;
+ oss << "Button " << *item->int_p;
+ item->change_input(oss.str().c_str());
+}
+
/* Free a menu and all its items */
Menu::~Menu()
{
}
case MN_TEXTFIELD:
case MN_NUMFIELD:
- case MN_CONTROLFIELD:
+ case MN_CONTROLFIELD_KB:
+ case MN_CONTROLFIELD_JS:
{
int input_pos = input_width/2;
int text_pos = (text_width + font_width)/2;
input_width + font_width, 18,
0,0,0,128);
- if(pitem.kind == MN_CONTROLFIELD)
+ if(pitem.kind == MN_CONTROLFIELD_KB)
get_controlfield_key_into_input(&pitem);
+ else if (pitem.kind == MN_CONTROLFIELD_JS)
+ get_controlfield_js_into_input(&pitem);
if(pitem.kind == MN_TEXTFIELD || pitem.kind == MN_NUMFIELD)
{
/* An International Character. */
}
- if(item[active_item].kind == MN_CONTROLFIELD)
+ if(item[active_item].kind == MN_CONTROLFIELD_KB)
{
if(key == SDLK_ESCAPE)
{
}
break;
case SDL_JOYBUTTONDOWN:
+ if (item[active_item].kind == MN_CONTROLFIELD_JS)
+ {
+ *item[active_item].int_p = key;
+ menuaction = MENU_ACTION_DOWN;
+ }
menuaction = MENU_ACTION_HIT;
break;
case SDL_MOUSEBUTTONDOWN: