void GuiKeyboard::Update(GuiTrigger * t) { if(_elements.size() == 0 || (state == STATE_DISABLED && parentElement)) return; for (u8 i = 0; i < _elements.size(); i++) { try { _elements.at(i)->Update(t); } catch (const std::exception& e) { } } wchar_t charCode = 0; u8 keyCode = 0; bool update = false; ++DeleteDelay; ++BackDelay; if(t->chan == 0) { // Update only once every frame (50-60 times per second) bool bKeyChangeEvent = (KEYBOARD_GetEvent(&keyboardEvent) == 1); if(bKeyChangeEvent) { if(keyboardEvent.type == KEYBOARD_PRESSED) { keyHeldDelay.reset(); } else { // key released -> reset symbol keyboardEvent.symbol = 0; } } // if the key was not released it -> add it again as "new" event if( (keyboardEvent.symbol != 0) && ( bKeyChangeEvent || (keyHeldDelay.elapsedMilliSecs() > 500 && DeleteDelay > 15))) // delay hold key { if(((keyboardEvent.symbol >> 8) == 0xF2) && (keyboardEvent.symbol & 0xFF) < 0x80) { // this is usually a numpad charCode = keyboardEvent.symbol & 0xFF; } else if( (keyboardEvent.symbol < 0xD800) // this is usually a normal character || (keyboardEvent.symbol >= 62102 && keyboardEvent.symbol <= 62105) // up/down/left/right numpad || (keyboardEvent.symbol >= 62340 && keyboardEvent.symbol <= 62343)) // up/down/left/right arrows { charCode = keyboardEvent.symbol; } keyCode = keyboardEvent.modifiers; if(charCode != 0 || keyCode != 0) DeleteDelay = 0; }
static void poll_input(void) { static Sint32 old_x = 1000, old_y = 1000; static Uint32 old_point = 0; static Uint32 old_btns[4] = {0}; static Sint16 old_axes[4][4] = {{0}}; static int old_type[4] = { WPAD_EXP_NONE, WPAD_EXP_NONE, WPAD_EXP_NONE, WPAD_EXP_NONE }; static Uint32 old_gcbtns[4] = {0}; static Sint8 old_gcaxes[4][4] = {{0}}; static Uint16 old_modifiers = 0; static Uint8 old_mousebtns = 0; WPADData *wd; PADStatus pad[4]; keyboard_event ke; mouse_event me; u32 type; union event ev; Uint32 i, j; WPAD_ScanPads(); for(i = 0; i < 4; i++) { if(WPAD_Probe(i, &type) == WPAD_ERR_NONE) { wd = WPAD_Data(i); if((int)type != old_type[i]) { scan_buttons(i, old_btns[i], 0); old_btns[i] = 0; ev.type = EVENT_AXIS_MOVE; ev.axis.pad = i; ev.axis.pos = 0; for(j = 0; j < 4; j++) { if(old_axes[i][j]) { ev.axis.axis = j; write_eq(&ev); old_axes[i][j] = 0; } } ev.type = EVENT_CHANGE_EXT; ev.ext.pad = i; old_type[i] = ev.ext.ext = type; write_eq(&ev); } if(i == 0) { if(wd->ir.valid) { ev.pointer.x = wd->ir.x - PTR_BORDER_W; ev.pointer.y = wd->ir.y - PTR_BORDER_H; if (ev.pointer.x < 0) ev.pointer.x = 0; if (ev.pointer.y < 0) ev.pointer.y = 0; if (ev.pointer.x >= 640) ev.pointer.x = 639; if (ev.pointer.y >= 350) ev.pointer.y = 349; if ((ev.pointer.x != old_x) || (ev.pointer.y != old_y)) { ev.type = EVENT_POINTER_MOVE; write_eq(&ev); old_point = 1; old_x = ev.pointer.x; old_y = ev.pointer.y; } } else { if(old_point) { ev.type = EVENT_POINTER_OUT; write_eq(&ev); old_point = 0; old_x = old_y = 1000; } } } scan_buttons(i, old_btns[i], wd->btns_h); old_btns[i] = wd->btns_h; switch(type) { case WPAD_EXP_NUNCHUK: { scan_joystick(i, 0, wd->exp.nunchuk.js, old_axes[i]); break; } case WPAD_EXP_CLASSIC: { scan_joystick(i, 0, wd->exp.classic.ljs, old_axes[i]); scan_joystick(i, 2, wd->exp.classic.rjs, old_axes[i] + 2); break; } case WPAD_EXP_GUITARHERO3: { scan_joystick(i, 0, wd->exp.gh3.js, old_axes[i]); j = (int)(wd->exp.gh3.whammy_bar * 32767.0); if((int)j != old_axes[i][2]) { ev.type = EVENT_AXIS_MOVE; ev.axis.pad = i; ev.axis.pos = j; write_eq(&ev); } break; } default: break; } } else { scan_buttons(i, old_btns[i], 0); old_btns[i] = 0; ev.type = EVENT_AXIS_MOVE; ev.axis.pad = i; ev.axis.pos = 0; for(j = 0; j < 4; j++) { if(old_axes[i][j]) { ev.axis.axis = j; write_eq(&ev); old_axes[i][j] = 0; } } } } PAD_Read(pad); for(i = 0; i < 4; i++) { if(pad[i].err == PAD_ERR_NONE) { scan_buttons(i + 4, old_gcbtns[i], pad[i].button); old_gcbtns[i] = pad[i].button; ev.type = EVENT_AXIS_MOVE; ev.axis.pad = i + 4; if(pad[i].stickX != old_gcaxes[i][0]) { ev.axis.axis = 0; ev.axis.pos = pad[i].stickX << 8; write_eq(&ev); old_gcaxes[i][0] = pad[i].stickX; } if(pad[i].stickY != old_gcaxes[i][1]) { ev.axis.axis = 1; ev.axis.pos = -(pad[i].stickY << 8); write_eq(&ev); old_gcaxes[i][1] = pad[i].stickY; } if(pad[i].substickX != old_gcaxes[i][2]) { ev.axis.axis = 2; ev.axis.pos = pad[i].substickX << 8; write_eq(&ev); old_gcaxes[i][0] = pad[i].substickX; } if(pad[i].substickY != old_gcaxes[i][3]) { ev.axis.axis = 3; ev.axis.pos = -(pad[i].substickY << 8); write_eq(&ev); old_gcaxes[i][1] = pad[i].substickY; } } else { scan_buttons(i + 4, old_gcbtns[i], 0); old_gcbtns[i] = 0; ev.type = EVENT_AXIS_MOVE; ev.axis.pad = i + 4; ev.axis.pos = 0; for(j = 0; j < 4; j++) { if(old_gcaxes[i][j]) { ev.axis.axis = j; write_eq(&ev); old_gcaxes[i][j] = 0; } } } } while(KEYBOARD_GetEvent(&ke)) { ke.modifiers &= MOD_CAPSLOCK | MOD_NUMLOCK; if(ke.modifiers != old_modifiers) { ev.type = EVENT_KEY_LOCKS; ev.locks.locks = ke.modifiers; write_eq(&ev); old_modifiers = ke.modifiers; } ev.key.key = ke.keycode; // Non-character keys mapped to the private use area if((ke.symbol >= 0xE000) && (ke.symbol < 0xF900)) ev.key.unicode = 0; else ev.key.unicode = ke.symbol; switch(ke.type) { default: case KEYBOARD_CONNECTED: case KEYBOARD_DISCONNECTED: break; case KEYBOARD_PRESSED: ev.type = EVENT_KEY_DOWN; write_eq(&ev); break; case KEYBOARD_RELEASED: ev.type = EVENT_KEY_UP; write_eq(&ev); break; } } ev.type = EVENT_MOUSE_MOVE; ev.mmove.dx = ev.mmove.dy = 0; while(MOUSE_GetEvent(&me)) { ev.mmove.dx += me.rx; ev.mmove.dy += me.ry; me.button &= USB_MOUSE_BTN_MASK; if(me.button != old_mousebtns) { if(ev.mmove.dx || ev.mmove.dy) write_eq(&ev); for(i = 1; i <= (me.button | old_mousebtns); i <<= 1) { if(i & (me.button ^ old_mousebtns)) { if(i & me.button) ev.type = EVENT_MOUSE_BUTTON_DOWN; else ev.type = EVENT_MOUSE_BUTTON_UP; ev.mbutton.button = i; write_eq(&ev); } } old_mousebtns = me.button; ev.type = EVENT_MOUSE_MOVE; ev.mmove.dx = ev.mmove.dy = 0; } } if(ev.mmove.dx || ev.mmove.dy) write_eq(&ev); }
void InputDevices::ScanButtons(void) { m_mutex.Lock(); #ifdef WII keyboard_event kbdEvent; // Scan PAD/WPAD WPAD_ScanPads(); PAD_ScanPads(); // Process WPAD IR ir_t ir; WPAD_IR(WPAD_CHAN_0, &ir); if( !ir.state || !ir.smooth_valid ) { WPAD_IR(WPAD_CHAN_1, &ir); } if( !ir.state || !ir.smooth_valid ) { m_mouse_active = false; }else{ m_mouse_x = (int)(((ir.sx - (500-200)) * GameWindow::GetWidth()) / 400); m_mouse_y = (int)(((ir.sy - (500-150)) * GameWindow::GetHeight()) / 300); m_mouse_angle = ir.angle; m_mouse_active = true; } // Process PAD/WPAD buttons for(int btn = BTN_JOY_FIRST; btn < BTN_LAST; btn++) { m_btnstatus[KEYIDX_NEW][btn] = false; } PADCODE *p = wpad_default; for(int i = 0; i < 2; i++) { m_wpad[0] = GetPadButtonStatus(WPAD_CHAN_0); m_wpad[1] = GetPadButtonStatus(WPAD_CHAN_1); while(p->key_a != BTN_NONE) { if( (m_wpad[0] & p->code) != 0 ) { m_btnstatus[KEYIDX_NEW][p->key_a] = true; } if( (m_wpad[1] & p->code) != 0 ) { m_btnstatus[KEYIDX_NEW][p->key_b] = true; } p++; } if( m_wpad_orientation == WPADO_HORIZONTAL ) { p = wpad_horizontal; }else{ p = wpad_vertical; } } // Handle USB keyboard while( KEYBOARD_GetEvent(&kbdEvent) ) { switch( kbdEvent.type ) { case KEYBOARD_PRESSED: for(int i = 0; syms[i].key != BTN_NONE; i++) { if( kbdEvent.symbol == syms[i].code_a || kbdEvent.symbol == syms[i].code_b ) { m_btnstatus[KEYIDX_NEW][syms[i].key] = true; } } break; case KEYBOARD_RELEASED: for(int i = 0; syms[i].key != BTN_NONE; i++) { if( kbdEvent.symbol == syms[i].code_a || kbdEvent.symbol == syms[i].code_b ) { m_btnstatus[KEYIDX_NEW][syms[i].key] = true; } } break; case KEYBOARD_DISCONNECTED: memset(m_btnstatus, 0, sizeof(m_btnstatus)); m_connected--; break; case KEYBOARD_CONNECTED: m_connected++; break; } } // Handle leds int led = ledGetCapslock(); if( m_leds != led ) { KEYBOARD_SetLed(KEYBOARD_LEDCAPS, led); m_leds = led; } #else // Process mouse float x, y; g_hge->Input_GetMousePos(&x, &y); m_mouse_active = g_hge->Input_IsMouseOver(); m_mouse_x = (int)x; m_mouse_y = (int)y; // Process key events hgeInputEvent event; while( g_hge->Input_GetEvent(&event) ) { switch( event.type ) { case INPUT_KEYDOWN: if( event.key == HGEK_F9 ) { GameWindow::ToggleFullScreen(); break; } case INPUT_MBUTTONDOWN: for(int i = 0; syms[i].key != BTN_NONE; i++) { if( syms[i].code_a == event.key ) { m_btnstatus[KEYIDX_NEW][syms[i].key] = true; } } break; case INPUT_KEYUP: case INPUT_MBUTTONUP: for(int i = 0; syms[i].key != BTN_NONE; i++) { if( syms[i].code_a == event.key ) { m_btnstatus[KEYIDX_NEW][syms[i].key] = false; } } break; } } #endif m_mutex.Unlock(); }
void PumpEvents() { #ifdef HW_RVL if (TerminateRequested) Terminate(); #endif wd = WPAD_Data(0); stat = KEYBOARD_GetEvent(&ke); mstat = MOUSE_GetEvent(&me); if (wd->ir.valid) { int newx = wd->ir.x; int newy = wd->ir.y; int diffx = newx - lastx; int diffy = newy - lasty; lastx = newx; lasty = newy; posted += SDL_PrivateMouseMotion(0, 1, diffx, diffy); Uint8 stateA = SDL_RELEASED; Uint8 stateB = SDL_RELEASED; if (wd->btns_h & WPAD_BUTTON_A) { stateA = SDL_PRESSED; } if (wd->btns_h & WPAD_BUTTON_B) { stateB = SDL_PRESSED; } if (stateA != lastButtonStateA) { lastButtonStateA = stateA; posted += SDL_PrivateMouseButton(stateA, SDL_BUTTON_LEFT, 0, 0); } if (stateB != lastButtonStateB) { lastButtonStateB = stateB; posted += SDL_PrivateMouseButton(stateB, SDL_BUTTON_RIGHT, 0, 0); } } if (stat && (ke.type == KEYBOARD_RELEASED || ke.type == KEYBOARD_PRESSED)) { SDL_keysym keysym; memset(&keysym, 0, sizeof(keysym)); Uint8 keystate = (ke.type == KEYBOARD_PRESSED) ? SDL_PRESSED : SDL_RELEASED; keysym.sym = keymap[ke.keycode]; keysym.mod = 0; posted += SDL_PrivateKeyboard(keystate, &keysym); } if (mstat) { posted += SDL_PrivateMouseMotion(0, 1, me.rx, me.ry); u8 button = me.button; if (button & 0x1) { if (!(SDL_GetMouseState(NULL, NULL) & SDL_BUTTON(1))) { posted += SDL_PrivateMouseButton(SDL_PRESSED, 1, 0, 0); } } else { if ((SDL_GetMouseState(NULL, NULL) & SDL_BUTTON(1))) { posted += SDL_PrivateMouseButton(SDL_RELEASED, 1, 0, 0); } } if (button & 0x2) { if (!(SDL_GetMouseState(NULL, NULL) & SDL_BUTTON(3))) { posted += SDL_PrivateMouseButton(SDL_PRESSED, 3, 0, 0); } } else { if ((SDL_GetMouseState(NULL, NULL) & SDL_BUTTON(3))) { posted += SDL_PrivateMouseButton(SDL_RELEASED, 3, 0, 0); } } } }
void IN_Commands (void) { // Fetch the pad state. PAD_ScanPads(); WPAD_ScanPads(); keyboard_event KB_event; while(KEYBOARD_GetEvent(&KB_event) > 0) { switch(KB_event.type) { case KEYBOARD_CONNECTED: keyboard_connected = TRUE; break; case KEYBOARD_DISCONNECTED: keyboard_connected = FALSE; break; case KEYBOARD_PRESSED: if(!keyboard_shifted) Key_Event(keycode_normal[KB_event.keycode], TRUE); else Key_Event(keycode_shifted[KB_event.keycode], TRUE); if(keycode_normal[KB_event.keycode] == K_LSHIFT || keycode_normal[KB_event.keycode] == K_RSHIFT) keyboard_shifted = TRUE; break; case KEYBOARD_RELEASED: if(!keyboard_shifted) Key_Event(keycode_normal[KB_event.keycode], FALSE); else Key_Event(keycode_shifted[KB_event.keycode], FALSE); if(keycode_normal[KB_event.keycode] == K_LSHIFT || keycode_normal[KB_event.keycode] == K_RSHIFT) keyboard_shifted = FALSE; break; } } u32 exp_type; if ( WPAD_Probe(WPAD_CHAN_0, &exp_type) != 0 ) exp_type = WPAD_EXP_NONE; if(exp_type == WPAD_EXP_NUNCHUK) { if(!nunchuk_connected) wpad_previous_keys = 0x0000; nunchuk_connected = TRUE; classic_connected = FALSE; wpad_keys = WPAD_ButtonsHeld(WPAD_CHAN_0); pad_keys = 0x0000; pad_previous_keys = 0x0000; } else if(exp_type == WPAD_EXP_CLASSIC) { if(!classic_connected) wpad_previous_keys = 0x0000; nunchuk_connected = FALSE; classic_connected = TRUE; wpad_keys = WPAD_ButtonsHeld(WPAD_CHAN_0); pad_keys = 0x0000; pad_previous_keys = 0x0000; } else { if(classic_connected || nunchuk_connected) wpad_previous_keys = 0x0000; nunchuk_connected = FALSE; classic_connected = FALSE; pad_keys = PAD_ButtonsHeld(PAD_CHAN0); wpad_keys = WPAD_ButtonsHeld(WPAD_CHAN_0); } WPAD_IR(WPAD_CHAN_0, &pointer); WPAD_Orientation(WPAD_CHAN_0, &orientation); WPAD_Expansion(WPAD_CHAN_0, &expansion); if (wiimote_connected && (wpad_keys & WPAD_BUTTON_MINUS)) { // ELUTODO: we are using the previous frame wiimote position... FIX IT in_osk = 1; int line = (last_iry - OSK_YSTART) / (osk_line_size * (osk_line_size / osk_charsize)) - 1; int col = (last_irx - OSK_XSTART) / (osk_col_size * (osk_col_size / osk_charsize)) - 1; osk_coords[0] = last_irx; osk_coords[1] = last_iry; line = clamp(line, 0, osk_num_lines); col = clamp(col, 0, osk_num_col); if (nunchuk_connected && (wpad_keys & WPAD_NUNCHUK_BUTTON_Z)) osk_set = osk_shifted; else osk_set = osk_normal; osk_selected = osk_set[line * osk_num_col + col]; if ((wpad_keys & WPAD_BUTTON_B) && osk_selected && (Sys_FloatTime() >= osk_last_press_time + osk_repeat_delay.value || osk_selected != osk_last_selected)) { Key_Event((osk_selected), TRUE); Key_Event((osk_selected), FALSE); osk_last_selected = osk_selected; osk_last_press_time = Sys_FloatTime(); } } else { // TODO: go back to the old method with buton mappings. The code was a lot cleaner that way in_osk = 0; if(classic_connected) { if ((wpad_previous_keys & WPAD_CLASSIC_BUTTON_LEFT) != (wpad_keys & WPAD_CLASSIC_BUTTON_LEFT)) { // Send a press event. Key_Event(K_LEFTARROW, ((wpad_keys & WPAD_CLASSIC_BUTTON_LEFT) == WPAD_CLASSIC_BUTTON_LEFT)); } if ((wpad_previous_keys & WPAD_CLASSIC_BUTTON_RIGHT) != (wpad_keys & WPAD_CLASSIC_BUTTON_RIGHT)) { // Send a press event. Key_Event(K_RIGHTARROW, ((wpad_keys & WPAD_CLASSIC_BUTTON_RIGHT) == WPAD_CLASSIC_BUTTON_RIGHT)); } if ((wpad_previous_keys & WPAD_CLASSIC_BUTTON_DOWN) != (wpad_keys & WPAD_CLASSIC_BUTTON_DOWN)) { // Send a press event. Key_Event(K_DOWNARROW, ((wpad_keys & WPAD_CLASSIC_BUTTON_DOWN) == WPAD_CLASSIC_BUTTON_DOWN)); } if ((wpad_previous_keys & WPAD_CLASSIC_BUTTON_UP) != (wpad_keys & WPAD_CLASSIC_BUTTON_UP)) { // Send a press event. Key_Event(K_UPARROW, ((wpad_keys & WPAD_CLASSIC_BUTTON_UP) == WPAD_CLASSIC_BUTTON_UP)); } if ((wpad_previous_keys & WPAD_CLASSIC_BUTTON_PLUS) != (wpad_keys & WPAD_CLASSIC_BUTTON_PLUS)) { // Send a press event. Key_Event(K_ESCAPE, ((wpad_keys & WPAD_CLASSIC_BUTTON_PLUS) == WPAD_CLASSIC_BUTTON_PLUS)); } if ((wpad_previous_keys & WPAD_CLASSIC_BUTTON_A) != (wpad_keys & WPAD_CLASSIC_BUTTON_A)) { // Send a press event. Key_Event(K_JOY8, ((wpad_keys & WPAD_CLASSIC_BUTTON_A) == WPAD_CLASSIC_BUTTON_A)); } if ((wpad_previous_keys & WPAD_CLASSIC_BUTTON_B) != (wpad_keys & WPAD_CLASSIC_BUTTON_B)) { // Send a press event. Key_Event(K_JOY9, ((wpad_keys & WPAD_CLASSIC_BUTTON_B) == WPAD_CLASSIC_BUTTON_B)); } if ((wpad_previous_keys & WPAD_CLASSIC_BUTTON_MINUS) != (wpad_keys & WPAD_CLASSIC_BUTTON_MINUS)) { // Send a press event. Key_Event(K_JOY10, ((wpad_keys & WPAD_CLASSIC_BUTTON_MINUS) == WPAD_CLASSIC_BUTTON_MINUS)); } if ((wpad_previous_keys & WPAD_CLASSIC_BUTTON_X) != (wpad_keys & WPAD_CLASSIC_BUTTON_X)) { // Send a press event. Key_Event(K_JOY13, ((wpad_keys & WPAD_CLASSIC_BUTTON_X) == WPAD_CLASSIC_BUTTON_X)); } if ((wpad_previous_keys & WPAD_CLASSIC_BUTTON_Y) != (wpad_keys & WPAD_CLASSIC_BUTTON_Y)) { // Send a press event. Key_Event(K_JOY14, ((wpad_keys & WPAD_CLASSIC_BUTTON_Y) == WPAD_CLASSIC_BUTTON_Y)); } if ((wpad_previous_keys & WPAD_CLASSIC_BUTTON_LEFT) != (wpad_keys & WPAD_CLASSIC_BUTTON_LEFT)) { // Send a press event. Key_Event(K_JOY15, ((wpad_keys & WPAD_CLASSIC_BUTTON_LEFT) == WPAD_CLASSIC_BUTTON_LEFT)); } if ((wpad_previous_keys & WPAD_CLASSIC_BUTTON_RIGHT) != (wpad_keys & WPAD_CLASSIC_BUTTON_RIGHT)) { // Send a press event. Key_Event(K_JOY16, ((wpad_keys & WPAD_CLASSIC_BUTTON_RIGHT) == WPAD_CLASSIC_BUTTON_RIGHT)); } if ((wpad_previous_keys & WPAD_CLASSIC_BUTTON_ZL) != (wpad_keys & WPAD_CLASSIC_BUTTON_ZL)) { // Send a press event. Key_Event(K_JOY17, ((wpad_keys & WPAD_CLASSIC_BUTTON_ZL) == WPAD_CLASSIC_BUTTON_ZL)); } if ((wpad_previous_keys & WPAD_CLASSIC_BUTTON_ZR) != (wpad_keys & WPAD_CLASSIC_BUTTON_ZR)) { // Send a press event. Key_Event(K_JOY18, ((wpad_keys & WPAD_CLASSIC_BUTTON_ZR) == WPAD_CLASSIC_BUTTON_ZR)); } } else { if ((wpad_previous_keys & WPAD_BUTTON_LEFT) != (wpad_keys & WPAD_BUTTON_LEFT)) { // Send a press event. Key_Event(K_LEFTARROW, ((wpad_keys & WPAD_BUTTON_LEFT) == WPAD_BUTTON_LEFT)); } if ((wpad_previous_keys & WPAD_BUTTON_RIGHT) != (wpad_keys & WPAD_BUTTON_RIGHT)) { // Send a press event. Key_Event(K_RIGHTARROW, ((wpad_keys & WPAD_BUTTON_RIGHT) == WPAD_BUTTON_RIGHT)); } if ((wpad_previous_keys & WPAD_BUTTON_DOWN) != (wpad_keys & WPAD_BUTTON_DOWN)) { // Send a press event. Key_Event(K_DOWNARROW, ((wpad_keys & WPAD_BUTTON_DOWN) == WPAD_BUTTON_DOWN)); } if ((wpad_previous_keys & WPAD_BUTTON_UP) != (wpad_keys & WPAD_BUTTON_UP)) { // Send a press event. Key_Event(K_UPARROW, ((wpad_keys & WPAD_BUTTON_UP) == WPAD_BUTTON_UP)); } if ((wpad_previous_keys & WPAD_BUTTON_PLUS) != (wpad_keys & WPAD_BUTTON_PLUS)) { // Send a press event. Key_Event(K_ESCAPE, ((wpad_keys & WPAD_BUTTON_PLUS) == WPAD_BUTTON_PLUS)); } if ((wpad_previous_keys & WPAD_BUTTON_A) != (wpad_keys & WPAD_BUTTON_A)) { // Send a press event. Key_Event(K_JOY8, ((wpad_keys & WPAD_BUTTON_A) == WPAD_BUTTON_A)); } if ((wpad_previous_keys & WPAD_BUTTON_B) != (wpad_keys & WPAD_BUTTON_B)) { // Send a press event. Key_Event(K_JOY9, ((wpad_keys & WPAD_BUTTON_B) == WPAD_BUTTON_B)); } if ((wpad_previous_keys & WPAD_BUTTON_MINUS) != (wpad_keys & WPAD_BUTTON_MINUS)) { // Send a press event. Key_Event(K_JOY10, ((wpad_keys & WPAD_BUTTON_MINUS) == WPAD_BUTTON_MINUS)); } if ((wpad_previous_keys & WPAD_BUTTON_1) != (wpad_keys & WPAD_BUTTON_1)) { // Send a press event. Key_Event(K_JOY11, ((wpad_keys & WPAD_BUTTON_1) == WPAD_BUTTON_1)); } if ((wpad_previous_keys & WPAD_BUTTON_2) != (wpad_keys & WPAD_BUTTON_2)) { // Send a press event. Key_Event(K_JOY12, ((wpad_keys & WPAD_BUTTON_2) == WPAD_BUTTON_2)); } if(nunchuk_connected) { if ((wpad_previous_keys & WPAD_NUNCHUK_BUTTON_C) != (wpad_keys & WPAD_NUNCHUK_BUTTON_C)) { // Send a press event. Key_Event(K_JOY13, ((wpad_keys & WPAD_NUNCHUK_BUTTON_C) == WPAD_NUNCHUK_BUTTON_C)); } if ((wpad_previous_keys & WPAD_NUNCHUK_BUTTON_Z) != (wpad_keys & WPAD_NUNCHUK_BUTTON_Z)) { // Send a press event. Key_Event(K_JOY14, ((wpad_keys & WPAD_NUNCHUK_BUTTON_Z) == WPAD_NUNCHUK_BUTTON_Z)); } } } if(!nunchuk_connected && !classic_connected) { if ((pad_previous_keys & PAD_BUTTON_LEFT) != (pad_keys & PAD_BUTTON_LEFT)) { // Send a press event. Key_Event(K_LEFTARROW, ((pad_keys & PAD_BUTTON_LEFT) == PAD_BUTTON_LEFT)); } if ((pad_previous_keys & PAD_BUTTON_RIGHT) != (pad_keys & PAD_BUTTON_RIGHT)) { // Send a press event. Key_Event(K_RIGHTARROW, ((pad_keys & PAD_BUTTON_RIGHT) == PAD_BUTTON_RIGHT)); } if ((pad_previous_keys & PAD_BUTTON_DOWN) != (pad_keys & PAD_BUTTON_DOWN)) { // Send a press event. Key_Event(K_DOWNARROW, ((pad_keys & PAD_BUTTON_DOWN) == PAD_BUTTON_DOWN)); } if ((pad_previous_keys & PAD_BUTTON_UP) != (pad_keys & PAD_BUTTON_UP)) { // Send a press event. Key_Event(K_UPARROW, ((pad_keys & PAD_BUTTON_UP) == PAD_BUTTON_UP)); } if ((pad_previous_keys & PAD_BUTTON_A) != (pad_keys & PAD_BUTTON_A)) { // Send a press event. Key_Event(K_JOY8, ((pad_keys & PAD_BUTTON_A) == PAD_BUTTON_A)); } if ((pad_previous_keys & PAD_BUTTON_B) != (pad_keys & PAD_BUTTON_B)) { // Send a press event. Key_Event(K_JOY9, ((pad_keys & PAD_BUTTON_B) == PAD_BUTTON_B)); } if ((pad_previous_keys & PAD_BUTTON_X) != (pad_keys & PAD_BUTTON_X)) { // Send a press event. Key_Event(K_JOY10, ((pad_keys & PAD_BUTTON_X) == PAD_BUTTON_X)); } if ((pad_previous_keys & PAD_BUTTON_Y) != (pad_keys & PAD_BUTTON_Y)) { // Send a press event. Key_Event(K_JOY10, ((pad_keys & PAD_BUTTON_Y) == PAD_BUTTON_Y)); } if ((pad_previous_keys & PAD_TRIGGER_R) != (pad_keys & PAD_TRIGGER_R)) { // Send a press event. Key_Event(K_JOY11, ((pad_keys & PAD_TRIGGER_R) == PAD_TRIGGER_R)); } if ((pad_previous_keys & PAD_TRIGGER_L) != (pad_keys & PAD_TRIGGER_L)) { // Send a press event. Key_Event(K_JOY12, ((pad_keys & PAD_TRIGGER_L) == PAD_TRIGGER_L)); } if ((pad_previous_keys & PAD_TRIGGER_Z) != (pad_keys & PAD_TRIGGER_Z)) { // Send a press event. Key_Event(K_JOY13, ((pad_keys & PAD_TRIGGER_Z) == PAD_TRIGGER_Z)); } if ((pad_previous_keys & PAD_BUTTON_START) != (pad_keys & PAD_BUTTON_START)) { // Send a press event. Key_Event(K_ESCAPE, ((pad_keys & PAD_BUTTON_START) == PAD_BUTTON_START)); } pad_previous_keys = pad_keys; } } wpad_previous_keys = wpad_keys; }