namespace portdefs {
portctrl::controller port_tmp_0 = {"(system)", "(system)", {
	{portctrl::button::TYPE_BUTTON,70, "framesync", 1, 0, 0, 0, "F", 70},
	{portctrl::button::TYPE_BUTTON,82, "reset", 1, 0, 0, 0, "R", 82},
	{portctrl::button::TYPE_NULL,0, "", 1, 0, 0, 0, "", 0},
	{portctrl::button::TYPE_NULL,0, "", 1, 0, 0, 0, "", 0},
}};
portctrl::controller port_tmp_1 = {"gb", "gamepad", {
	{portctrl::button::TYPE_BUTTON,65, "A", 0, 0, 0, 0, "A", 65},
	{portctrl::button::TYPE_BUTTON,66, "B", 0, 0, 0, 0, "B", 66},
	{portctrl::button::TYPE_BUTTON,115, "select", 0, 0, 0, 0, "s", 115},
	{portctrl::button::TYPE_BUTTON,83, "start", 0, 0, 0, 0, "S", 83},
	{portctrl::button::TYPE_BUTTON,8594, "right", 0, 0, 0, 0, ">", 114},
	{portctrl::button::TYPE_BUTTON,8592, "left", 0, 0, 0, 0, "<", 108},
	{portctrl::button::TYPE_BUTTON,8593, "up", 0, 0, 0, 0, "^", 117},
	{portctrl::button::TYPE_BUTTON,8595, "down", 0, 0, 0, 0, "v", 100},
}};
portctrl::controller_set port_tmp_2 = {
	"system", "system", "psystem",{port_tmp_0, port_tmp_1, },{0, }
};
}
struct _psystem : public portctrl::type
{
	_psystem() : type("system", "system", 2)
	{
		write = [](const portctrl::type* _this, unsigned char* buffer, unsigned idx, unsigned ctrl, short x) -> void {
			switch(idx) {
			case 0:
				switch(ctrl) {
				case 0:
					if(x) buffer[0]|=1; else buffer[0]&=254;
					break;
				case 1:
					if(x) buffer[0]|=2; else buffer[0]&=253;
					break;
				case 2:
					break;
				case 3:
					break;
				}
				break;
			case 1:
				switch(ctrl) {
				case 0:
					if(x) buffer[0]|=4; else buffer[0]&=251;
					break;
				case 1:
					if(x) buffer[0]|=8; else buffer[0]&=247;
					break;
				case 2:
					if(x) buffer[0]|=16; else buffer[0]&=239;
					break;
				case 3:
					if(x) buffer[0]|=32; else buffer[0]&=223;
					break;
				case 4:
					if(x) buffer[0]|=64; else buffer[0]&=191;
					break;
				case 5:
					if(x) buffer[0]|=128; else buffer[0]&=127;
					break;
				case 6:
					if(x) buffer[1]|=1; else buffer[1]&=254;
					break;
				case 7:
					if(x) buffer[1]|=2; else buffer[1]&=253;
					break;
				}
				break;
			}
		};
		read = [](const portctrl::type* _this, const unsigned char* buffer, unsigned idx, unsigned ctrl) -> short {
			switch(idx) {
			case 0:
				switch(ctrl) {
				case 0:
					return (buffer[0]&1) ? 1 : 0;
				case 1:
					return (buffer[0]&2) ? 1 : 0;
				case 2:
					return 0;
				case 3:
					return 0;
				}
				return 0;
			case 1:
				switch(ctrl) {
				case 0:
					return (buffer[0]&4) ? 1 : 0;
				case 1:
					return (buffer[0]&8) ? 1 : 0;
				case 2:
					return (buffer[0]&16) ? 1 : 0;
				case 3:
					return (buffer[0]&32) ? 1 : 0;
				case 4:
					return (buffer[0]&64) ? 1 : 0;
				case 5:
					return (buffer[0]&128) ? 1 : 0;
				case 6:
					return (buffer[1]&1) ? 1 : 0;
				case 7:
					return (buffer[1]&2) ? 1 : 0;
				}
			return 0;
			return 0;
			}
			return 0;
		};
		serialize = [](const portctrl::type* _this, const unsigned char* buffer, char* textbuf) -> size_t {
			size_t ptr = 0;
			short tmp;
			textbuf[ptr++] = (buffer[0] & 1) ? (char)70 : '.';
			textbuf[ptr++] = (buffer[0] & 2) ? (char)82 : '.';
			textbuf[ptr++] = '|';
			textbuf[ptr++] = (buffer[0] & 4) ? (char)65 : '.';
			textbuf[ptr++] = (buffer[0] & 8) ? (char)66 : '.';
			textbuf[ptr++] = (buffer[0] & 16) ? (char)115 : '.';
			textbuf[ptr++] = (buffer[0] & 32) ? (char)83 : '.';
			textbuf[ptr++] = (buffer[0] & 64) ? (char)114 : '.';
			textbuf[ptr++] = (buffer[0] & 128) ? (char)108 : '.';
			textbuf[ptr++] = (buffer[1] & 1) ? (char)117 : '.';
			textbuf[ptr++] = (buffer[1] & 2) ? (char)100 : '.';
			return ptr;
		};
		deserialize = [](const portctrl::type* _this, unsigned char* buffer, const char* textbuf) -> size_t {
			memset(buffer, 0, 2);
			size_t ptr = 0;
			short tmp;
			if(portctrl::read_button_value(textbuf, ptr)) buffer[0]|=1;
			if(portctrl::read_button_value(textbuf, ptr)) buffer[0]|=2;
			portctrl::skip_rest_of_field(textbuf, ptr, true);
			if(portctrl::read_button_value(textbuf, ptr)) buffer[0]|=4;
			if(portctrl::read_button_value(textbuf, ptr)) buffer[0]|=8;
			if(portctrl::read_button_value(textbuf, ptr)) buffer[0]|=16;
			if(portctrl::read_button_value(textbuf, ptr)) buffer[0]|=32;
			if(portctrl::read_button_value(textbuf, ptr)) buffer[0]|=64;
			if(portctrl::read_button_value(textbuf, ptr)) buffer[0]|=128;
			if(portctrl::read_button_value(textbuf, ptr)) buffer[1]|=1;
			if(portctrl::read_button_value(textbuf, ptr)) buffer[1]|=2;
			portctrl::skip_rest_of_field(textbuf, ptr, false);
			return ptr;
		};
		controller_info = &portdefs::port_tmp_2;
	}
} psystem;
std::vector<portctrl::type*> _port_types{&psystem, };
