Exemple #1
0
/*
 * root_hub_string is used by each host controller's root hub code,
 * so that they're identified consistently throughout the system.
 */
static int usb_root_hub_string (int id, int serial, char *type, __u8 *data, int len)
{
	char buf [30];

	/* assert (len > (2 * (sizeof (buf) + 1)));
	   assert (strlen (type) <= 8);*/

	/* language ids */
	if (id == 0) {
		*data++ = 4; *data++ = 3;	/* 4 bytes data */
		*data++ = 0; *data++ = 0;	/* some language id */
		return 4;

	/* serial number */
	} else if (id == 1) {
		sprintf (buf, "%#x", serial);

	/* product description */
	} else if (id == 2) {
		sprintf (buf, "USB %s Root Hub", type);

	/* id 3 == vendor description */

	/* unsupported IDs --> "stall" */
	} else
	    return 0;

	ascii2utf (buf, data + 2, len - 2);
	data [0] = 2 + strlen(buf) * 2;
	data [1] = 3;
	return data [0];
}
static int lua_setup(lua_State *L){
	int argc = lua_gettop(L);
    #ifndef SKIP_ERROR_HANDLING
		if (argc != 2 && argc != 3 && argc != 4 && argc != 5) return luaL_error(L, "wrong number of arguments");
	#endif
	char* title_ascii = (char*)luaL_checkstring(L, 1);
	char* text = (char*)luaL_checkstring(L, 2);
	SceUInt32 length = SCE_IME_DIALOG_MAX_TEXT_LENGTH;
	SceUInt32 type = SCE_IME_TYPE_BASIC_LATIN;
	SceUInt32 mode = SCE_IME_DIALOG_TEXTBOX_MODE_DEFAULT;
	if (argc >= 3) length = luaL_checkinteger(L, 3);
	if (argc >= 4) type = luaL_checkinteger(L, 4);
	if (argc == 5) mode = luaL_checkinteger(L, 5);
	#ifndef SKIP_ERROR_HANDLING
		if (length > SCE_IME_DIALOG_MAX_TEXT_LENGTH) length = SCE_IME_DIALOG_MAX_TEXT_LENGTH;
		if (type > 3) return luaL_error(L, "invalid keyboard type");
		if (mode > 1) return luaL_error(L, "invalid keyboard mode");
		if (strlen(title_ascii) > SCE_IME_DIALOG_MAX_TITLE_LENGTH) return luaL_error(L, "title is too long");
	#endif
	
	// Converting input to UTF16
	ascii2utf(initial_text, text);
	ascii2utf(title, title_ascii);
	
	// Initializing OSK
	SceImeDialogParam param;
	sceImeDialogParamInit(&param);
	param.supportedLanguages = 0x0001FFFF;
	param.languagesForced = SCE_TRUE;
	param.type = type;
	param.title = title;
	param.textBoxMode = mode;
	param.maxTextLength = length;
	param.initialText = initial_text;
	param.inputTextBuffer = input_text;
	sceImeDialogInit(&param);
	keyboardStarted = true;
	
	return 0;
}