void on_joystick_event (gint eventtype, gint button) { /*the focus is not set: another windows has been opened or this is an init event */ if (!joystick_focus || (eventtype & JS_EVENT_INIT)) return; GMAMEUI_DEBUG ("joy: event=%i, button=%i", eventtype, button); if ((eventtype & JS_EVENT_BUTTON) && (button < joydata->num_buttons)) { GMAMEUI_DEBUG ("Joystick button %i %s", button, (joydata->buttons[button])?"pressed":"released"); /* Button released*/ if (joydata->buttons[button] == 0) switch (button) { case 0: // FIXME TODO play_game (gui_prefs.current_game); break; case 1: toggle_expand (); break; } } else if ( (eventtype & JS_EVENT_AXIS) && (button < joydata->num_axis)) { if (repeat_source_id) g_source_remove (repeat_source_id); /* LEFT and RIGHT directions * (even Axis number) */ if (! (button & 1)) { if (joydata->axis[button] > (AXIS_MAX / 2)) { GMAMEUI_DEBUG ("Joystick axis %i pushed right", button); move_down (row_number ()); repeat_source_id = g_timeout_add (10 * JOY_TIMEOUT, (GSourceFunc) joy_right_repetition, NULL); } else if (joydata->axis[button] < (AXIS_MIN / 2)) { GMAMEUI_DEBUG ("Joystick axis %i pushed left", button); move_up (row_number ()); repeat_source_id = g_timeout_add (10 * JOY_TIMEOUT, (GSourceFunc) joy_left_repetition, NULL); } } else { /* UP and DOWN directions */ if (joydata->axis[button] > (AXIS_MAX / 2)) { GMAMEUI_DEBUG ("Joystick axis %i pushed down", button); move_down (1); repeat_source_id = g_timeout_add (10 * JOY_TIMEOUT, (GSourceFunc) joy_down_repetition, NULL); } else if (joydata->axis[button] < (AXIS_MIN / 2)) { GMAMEUI_DEBUG ("Joystick axis %i pushed up", button); move_up (1); repeat_source_id = g_timeout_add (10 * JOY_TIMEOUT, (GSourceFunc) joy_up_repetition, NULL); } } } }
/* Test conversion of a long string (larger than STRXFRM_INPUT_LENGTH_LIMIT)*/ void test__gp_strxfrm__LongQuery(void **state) { char *query = "select v from \ (select Ta.environment as v, row_number() over (order by Ta.environment) as r \ from only pg_temp_10.pg_analyze_50600_3 as Ta \ where environment is not null \ union \ select max(Tb.environment) as v, 1 as r \ from only pg_temp_10.pg_analyze_50600_3 as Tb \ where environment is not null) as foo \ where r % 894 = 1 \ group by v \ order by v"; int len = strlen(query); char *tmp_dst = (char *)palloc(len*(char) + 1); size_t result = gp_strxfrm(tmp_dst, query, STRXFRM_INPUT_LENGTH_LIMIT + 1); assert_int_equal((int)result, len*sizeof(char)); assert_int_equal(STRXFRM_INPUT_LENGTH_LIMIT, strlen(tmp_dst)); }
void build_test_matrix(Cel *A, double t, int n){ int i,j; double temp; for(i = 0; i < n; i++) for(j = 0; j < n; j++){ if(i == j) insert_on_matrix(A,1,i,j); else { temp = row_number(t); if(temp) insert_on_matrix(A,temp,i,j); } } }
UINT8 generic_keyboard_device::keyboard_handler(UINT8 last_code, UINT8 *scan_line) { static const char *const keynames[] = { "TERM_LINE0", "TERM_LINE1", "TERM_LINE2", "TERM_LINE3", "TERM_LINE4", "TERM_LINE5", "TERM_LINE6", "TERM_LINE7" }; int i; UINT8 code; UINT8 key_code = 0; UINT8 retVal = 0; UINT8 shift = BIT(ioport("TERM_LINEC")->read(), 1); UINT8 caps = BIT(ioport("TERM_LINEC")->read(), 2); UINT8 ctrl = BIT(ioport("TERM_LINEC")->read(), 0); i = *scan_line; { code = ioport(keynames[i])->read(); if (code != 0) { if (i==0 && shift==0) { key_code = 0x30 + row_number(code) + 8*i; // for numbers and some signs } if (i==0 && shift==1) { key_code = 0x20 + row_number(code) + 8*i; // for shifted numbers } if (i==1 && shift==0) { if (row_number(code) < 4) { key_code = 0x30 + row_number(code) + 8*i; // for numbers and some signs } else { key_code = 0x20 + row_number(code) + 8*i; // for numbers and some signs } } if (i==1 && shift==1) { if (row_number(code) < 4) { key_code = 0x20 + row_number(code) + 8*i; // for numbers and some signs } else { key_code = 0x30 + row_number(code) + 8*i; // for numbers and some signs } } if (i>=2 && i<=4 && (shift ^ caps)==0 && ctrl==0) { key_code = 0x60 + row_number(code) + (i-2)*8; // for small letters } if (i>=2 && i<=4 && (shift ^ caps)==1 && ctrl==0) { key_code = 0x40 + row_number(code) + (i-2)*8; // for big letters } if (i>=2 && i<=4 && ctrl==1) { key_code = 0x00 + row_number(code) + (i-2)*8; // for CTRL + letters } if (i==5 && shift==1 && ctrl==0) { if (row_number(code)<7) { if (row_number(code)<3) { key_code = (caps ? 0x60 : 0x40) + row_number(code) + (i-2)*8; // for big letters } else { key_code = 0x60 + row_number(code) + (i-2)*8; // for upper symbols letters } } else { key_code = 0x40 + row_number(code) + (i-2)*8; // for DEL it is switched } } if (i==5 && shift==0 && ctrl==0) { if (row_number(code)<7) { if (row_number(code)<3) { key_code = (caps ? 0x40 : 0x60) + row_number(code) + (i-2)*8; // for small letters } else { key_code = 0x40 + row_number(code) + (i-2)*8; // for lower symbols letters } } else { key_code = 0x60 + row_number(code) + (i-2)*8; // for DEL it is switched } } if (i==5 && shift==1 && ctrl==1) { key_code = 0x00 + row_number(code) + (i-2)*8; // for letters + ctrl } if (i==6) { switch(row_number(code)) { /* case 0: key_code = 0x11; break; case 1: key_code = 0x12; break; case 2: key_code = 0x13; break; case 3: key_code = 0x14; break;*/ case 4: key_code = 0x20; break; // Space case 5: key_code = 0x0A; break; // LineFeed case 6: key_code = 0x09; break; // TAB case 7: key_code = 0x0D; break; // Enter } } if (i==7) { switch(row_number(code)) { case 0: key_code = 0x1B; break; // Escape case 1: key_code = 0x08; break; // Backspace } } retVal = key_code; } else { *scan_line += 1; if (*scan_line==8) { *scan_line = 0; } } } return retVal; }
static TIMER_CALLBACK(keyboard_callback) { poly88_state *state = machine.driver_data<poly88_state>(); static const char *const keynames[] = { "LINE0", "LINE1", "LINE2", "LINE3", "LINE4", "LINE5", "LINE6" }; int i; UINT8 code; UINT8 key_code = 0; UINT8 shift = input_port_read(machine, "LINEC") & 0x02 ? 1 : 0; UINT8 ctrl = input_port_read(machine, "LINEC") & 0x01 ? 1 : 0; for(i = 0; i < 7; i++) { code = input_port_read(machine, keynames[i]); if (code != 0) { if (i==0 && shift==0) { key_code = 0x30 + row_number(code) + 8*i; // for numbers and some signs } if (i==0 && shift==1) { key_code = 0x20 + row_number(code) + 8*i; // for shifted numbers } if (i==1 && shift==0) { if (row_number(code) < 4) { key_code = 0x30 + row_number(code) + 8*i; // for numbers and some signs } else { key_code = 0x20 + row_number(code) + 8*i; // for numbers and some signs } } if (i==1 && shift==1) { if (row_number(code) < 4) { key_code = 0x20 + row_number(code) + 8*i; // for numbers and some signs } else { key_code = 0x30 + row_number(code) + 8*i; // for numbers and some signs } } if (i>=2 && i<=4 && shift==1 && ctrl==0) { key_code = 0x60 + row_number(code) + (i-2)*8; // for small letters } if (i>=2 && i<=4 && shift==0 && ctrl==0) { key_code = 0x40 + row_number(code) + (i-2)*8; // for big letters } if (i>=2 && i<=4 && ctrl==1) { key_code = 0x00 + row_number(code) + (i-2)*8; // for CTRL + letters } if (i==5 && shift==1 && ctrl==0) { if (row_number(code)<7) { key_code = 0x60 + row_number(code) + (i-2)*8; // for small letters } else { key_code = 0x40 + row_number(code) + (i-2)*8; // for signs it is switched } } if (i==5 && shift==0 && ctrl==0) { if (row_number(code)<7) { key_code = 0x40 + row_number(code) + (i-2)*8; // for small letters } else { key_code = 0x60 + row_number(code) + (i-2)*8; // for signs it is switched } } if (i==5 && shift==0 && ctrl==1) { key_code = 0x00 + row_number(code) + (i-2)*8; // for letters + ctrl } if (i==6) { switch(row_number(code)) { case 0: key_code = 0x11; break; case 1: key_code = 0x12; break; case 2: key_code = 0x13; break; case 3: key_code = 0x14; break; case 4: key_code = 0x20; break; // Space case 5: key_code = 0x0D; break; // Enter case 6: key_code = 0x09; break; // TAB case 7: key_code = 0x0A; break; // LF } } } } if (key_code==0 && state->m_last_code !=0){ state->m_int_vector = 0xef; cputag_set_input_line(machine, "maincpu", 0, HOLD_LINE); } else { state->m_last_code = key_code; } }
UINT8 generic_keyboard_device::keyboard_handler(UINT8 last_code, UINT8 *scan_line) { int i; UINT8 code = 0; UINT8 key_code = 0; UINT8 retVal = 0; UINT8 shift = BIT(m_io_kbdc->read(), 1); UINT8 caps = BIT(m_io_kbdc->read(), 2); UINT8 ctrl = BIT(m_io_kbdc->read(), 0); i = *scan_line; { if (i == 0) code = m_io_kbd0->read(); else if (i == 1) code = m_io_kbd1->read(); else if (i == 2) code = m_io_kbd2->read(); else if (i == 3) code = m_io_kbd3->read(); else if (i == 4) code = m_io_kbd4->read(); else if (i == 5) code = m_io_kbd5->read(); else if (i == 6) code = m_io_kbd6->read(); else if (i == 7) code = m_io_kbd7->read(); else if (i == 8) code = m_io_kbd8->read(); else if (i == 9) code = m_io_kbd9->read(); if (code != 0) { if (i==0 && shift==0) { key_code = 0x30 + row_number(code) + 8*i; // for numbers and some signs } if (i==0 && shift==1) { key_code = 0x20 + row_number(code) + 8*i; // for shifted numbers } if (i==1 && shift==0) { if (row_number(code) < 4) { key_code = 0x30 + row_number(code) + 8*i; // for numbers and some signs } else { key_code = 0x20 + row_number(code) + 8*i; // for numbers and some signs } } if (i==1 && shift==1) { if (row_number(code) < 4) { key_code = 0x20 + row_number(code) + 8*i; // for numbers and some signs } else { key_code = 0x30 + row_number(code) + 8*i; // for numbers and some signs } } if (i>=2 && i<=4 && (shift ^ caps)==0 && ctrl==0) { key_code = 0x60 + row_number(code) + (i-2)*8; // for small letters } if (i>=2 && i<=4 && (shift ^ caps)==1 && ctrl==0) { key_code = 0x40 + row_number(code) + (i-2)*8; // for big letters } if (i>=2 && i<=5 && ctrl==1) { key_code = 0x00 + row_number(code) + (i-2)*8; // for CTRL + letters } if (i==5 && shift==1 && ctrl==0) { if (row_number(code)<7) { if (row_number(code)<3) { key_code = (caps ? 0x60 : 0x40) + row_number(code) + (i-2)*8; // for big letters } else { key_code = 0x60 + row_number(code) + (i-2)*8; // for upper symbols letters } } else { key_code = 0x40 + row_number(code) + (i-2)*8; // for DEL it is switched } } if (i==5 && shift==0 && ctrl==0) { if (row_number(code)<7) { if (row_number(code)<3) { key_code = (caps ? 0x40 : 0x60) + row_number(code) + (i-2)*8; // for small letters } else { key_code = 0x40 + row_number(code) + (i-2)*8; // for lower symbols letters } } else { key_code = 0x60 + row_number(code) + (i-2)*8; // for DEL it is switched } } if (i==6) { switch(row_number(code)) { /* case 0: key_code = 0x11; break; case 1: key_code = 0x12; break; case 2: key_code = 0x13; break; case 3: key_code = 0x14; break;*/ case 4: key_code = 0x20; break; // Space case 5: key_code = 0x0A; break; // LineFeed case 6: key_code = 0x09; break; // TAB case 7: key_code = 0x0D; break; // Enter } } if (i==7) { switch(row_number(code)) { case 0: key_code = 0x1B; break; // Escape case 1: key_code = 0x08; break; // Backspace } } else if (i==8) { key_code = row_number(code)+0x81; if (ctrl) key_code+=0x10; if (shift) key_code+=0x20; } else if (i==9) { key_code = row_number(code)+0x89; if (ctrl) key_code+=0x10; if (shift) key_code+=0x20; } retVal = key_code; } else { *scan_line += 1; if (*scan_line==10) *scan_line = 0; } } return retVal; }
static gboolean joy_right_repetition (gpointer data) { move_down (row_number ()); repeat_source_id = g_timeout_add (JOY_TIMEOUT, (GSourceFunc)joy_right_repetition, NULL); return FALSE; }