///////////////////////////////////////////////////////////////////////////// //! This function initializes the KB handler ///////////////////////////////////////////////////////////////////////////// s32 MBNG_KB_Init(u32 mode) { if( mode != 0 ) return -1; // only mode 0 supported { KEYBOARD_Init(0); // disable keyboard SR assignments by default int kb; keyboard_config_t *kc = (keyboard_config_t *)&keyboard_config[0]; for(kb=0; kb<KEYBOARD_NUM; ++kb, ++kc) { kc->num_rows = 0; kc->dout_sr1 = 0; kc->dout_sr2 = 0; kc->din_sr1 = 0; kc->din_sr2 = 0; // due to slower scan rate: kc->delay_fastest = 5; kc->delay_fastest_black_keys = 0; // if 0, we take delay_fastest, otherwise we take the dedicated value for the black keys kc->delay_slowest = 100; } KEYBOARD_Init(1); // re-init runtime variables, don't touch configuration } return 0; // no error }
InputDevices::InputDevices() { static int wpad_initialized = 0; m_wpad_orientation = WPADO_VERTICAL; memset(m_btnstatus, 0, sizeof(m_btnstatus)); m_leds = 0; m_mouse_x = m_mouse_y = m_mouse_angle = 0; m_mouse_active = false; #ifdef WII m_wpad[0] = m_wpad[1] = 0; #endif FillKeyNames(); if( !wpad_initialized ) { #ifdef WII WPAD_Init(); #endif wpad_initialized = 1; } #ifdef WII m_connected = KEYBOARD_Init(NULL); #else m_connected = 1; #endif }
///////////////////////////////////////////////////////////////////////////// // This hook is called after startup to initialize the application ///////////////////////////////////////////////////////////////////////////// void APP_Init(void) { // create semaphores xMIDIINSemaphore = xSemaphoreCreateRecursiveMutex(); xMIDIOUTSemaphore = xSemaphoreCreateRecursiveMutex(); // install SysEx callback MIOS32_MIDI_SysExCallback_Init(APP_SYSEX_Parser); // install MIDI Rx/Tx callback functions MIOS32_MIDI_DirectRxCallback_Init(&NOTIFY_MIDI_Rx); MIOS32_MIDI_DirectTxCallback_Init(&NOTIFY_MIDI_Tx); // install timeout callback function MIOS32_MIDI_TimeOutCallback_Init(&NOTIFY_MIDI_TimeOut); // limit the number of DIN/DOUT SRs which will be scanned for faster scan rate MIOS32_SRIO_ScanNumSet(2); // init keyboard functions KEYBOARD_Init(0); // read EEPROM content PRESETS_Init(0); // init MIDI port/router handling MIDI_PORT_Init(0); MIDI_ROUTER_Init(0); // init terminal TERMINAL_Init(0); // init MIDImon MIDIMON_Init(0); // start uIP task UIP_TASK_Init(0); // print welcome message on MIOS terminal MIOS32_MIDI_SendDebugMessage("\n"); MIOS32_MIDI_SendDebugMessage("=================\n"); MIOS32_MIDI_SendDebugMessage("%s\n", MIOS32_LCD_BOOT_MSG_LINE1); MIOS32_MIDI_SendDebugMessage("=================\n"); MIOS32_MIDI_SendDebugMessage("\n"); // speed up SPI transfer rate (was MIOS32_SPI_PRESCALER_128, initialized by MIOS32_SRIO_Init()) MIOS32_SPI_TransferModeInit(MIOS32_SRIO_SPI, MIOS32_SPI_MODE_CLK1_PHASE1, MIOS32_SPI_PRESCALER_128); // prescaler 64 results into a transfer rate of 0.64 uS per bit // when 2 SRs are transfered, we are able to scan the whole 16x8 matrix in 300 uS // standard SRIO scan has been disabled in programming_models/traditional/main.c via MIOS32_DONT_SERVICE_SRIO_SCAN in mios32_config.h // start the scan here - and retrigger it whenever it's finished APP_SRIO_ServicePrepare(); MIOS32_SRIO_ScanStart(APP_SRIO_ServiceFinish); // start tasks xTaskCreate(TASK_Period_1mS, (signed portCHAR *)"1mS", configMINIMAL_STACK_SIZE, NULL, PRIORITY_TASK_PERIOD_1mS, NULL); }
static void init() { fb = 0; // Initialise the video system. VIDEO_Init(); rmode = VIDEO_GetPreferredMode(NULL); // Allocate the frame buffer. framebuffer[0] = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode)); framebuffer[1] = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode)); // Set up the video system with the chosen mode. VIDEO_Configure(rmode); // Set the frame buffer. VIDEO_SetNextFramebuffer(framebuffer[fb]); VIDEO_SetBlack(FALSE); VIDEO_Flush(); VIDEO_WaitVSync(); if (rmode->viTVMode & VI_NON_INTERLACE) { VIDEO_WaitVSync(); } // Initialise the debug console. // ELUTODO: only one framebuffer with it? console_init(framebuffer[0], 20, 20, rmode->fbWidth, rmode->xfbHeight, rmode->fbWidth * 2); // Initialise the controller library. PAD_Init(); // Initialise the keyboard library KEYBOARD_Init(NULL); if(!fatInitDefault()) Sys_Error("Error initializing filesystem"); #ifndef DISABLE_WIIMOTE if (WPAD_Init() != WPAD_ERR_NONE) Sys_Error("WPAD_Init() failed.\n"); #endif wiimote_ir_res_x = rmode->fbWidth; wiimote_ir_res_y = rmode->xfbHeight; }
static void *wii_poll_thread(void *dud) { WPAD_Init(); WPAD_SetDataFormat(WPAD_CHAN_ALL, WPAD_FMT_BTNS); WPAD_SetDataFormat(0, WPAD_FMT_BTNS_ACC_IR); WPAD_SetVRes(0, 640 + PTR_BORDER_W * 2, 350 + PTR_BORDER_H * 2); PAD_Init(); KEYBOARD_Init(NULL); MOUSE_Init(); while(1) { VIDEO_WaitVSync(); poll_input(); } return 0; }
void vDos_Init(void) { hideWinTill = GetTickCount()+2500; // Auto hidden till first keyboard check, parachute at 2.5 secs LOG_MSG("vDos version: %s", vDosVersion); #ifndef WITHIRQ1 // Wil have been called earlier in starup if WITHIRQ1 is defined vDos_LoadConfig(); #endif GUI_StartUp(); IO_Init(); PAGING_Init(); MEM_Init(); CALLBACK_Init(); PIC_Init(); PROGRAMS_Init(); TIMER_Init(); // CMOS_Init(); VGA_Init(); CPU_Init(); KEYBOARD_Init(); BIOS_Init(); INT10_Init(); MOUSE_Init(); SERIAL_Init(); PARALLEL_Init(); printTimeout = ConfGetBool("timeout"); DOS_Init(); XMS_Init(); EMS_Init(); if (errorMess[0]) MessageBox(NULL, errorMess+1, "vDos: CONFIG.TXT has unresolved items", MB_OK|MB_ICONWARNING); SHELL_Init(); // Start up main machine }
GuiKeyboard::GuiKeyboard(char * t, u32 max, int autofill) { if(bInitUSBKeyboard) { bInitUSBKeyboard = false; KEYBOARD_Init(0); } memset(&keyboardEvent, 0, sizeof(keyboardEvent)); DeleteDelay = 0; BackDelay = 0; CurrentFirstLetter = 0; if(t) { CurrentFirstLetter = CalcMaxLine(t); if(CurrentFirstLetter < 0) CurrentFirstLetter = 0; } width = 540; height = 400; shift = 0; caps = 0; selectable = true; focus = 0; // allow focus alignmentHor = ALIGN_CENTRE; alignmentVert = ALIGN_MIDDLE; strncpy(kbtextstr, t, max); kbtextstr[max] = 0; kbtextmaxlen = max; autocomplete = autofill; memset(autocmpltstr, 0, sizeof(autocmpltstr)); Key thekeys[4][11] = { { {'1','!'}, {'2','@'}, {'3','#'}, {'4','='}, {'5','%'}, {'6','^'}, {'7','&'}, {'8','*'}, {'9','('}, {'0',')'}, {'\0','\0'} }, { {'q','Q'}, {'w','W'}, {'e','E'}, {'r','R'}, {'t','T'}, {'y','Y'}, {'u','U'}, {'i','I'}, {'o','O'}, {'p','P'}, {'-','_'} }, { {'a','A'}, {'s','S'}, {'d','D'}, {'f','F'}, {'g','G'}, {'h','H'}, {'j','J'}, {'k','K'}, {'l','L'}, {';',':'}, {'\'','"'} }, { {'z','Z'}, {'x','X'}, {'c','C'}, {'v','V'}, {'b','B'}, {'n','N'}, {'m','M'}, {',','<'}, {'.','>'}, {'/','?'}, {'\0','\0'} } }; memcpy(keys, thekeys, sizeof(thekeys)); keyTextbox = new GuiImageData(keyboard_textbox_png); keyTextboxImg = new GuiImage(keyTextbox); keyTextboxImg->SetAlignment(ALIGN_CENTRE, ALIGN_TOP); keyTextboxImg->SetPosition(0, 0); this->Append(keyTextboxImg); kbText = new GuiLongText(GetDisplayText(kbtextstr), 20, (GXColor){0, 0, 0, 0xff}); kbText->SetAlignment(ALIGN_LEFT, ALIGN_TOP); kbText->SetPosition(0, 15); kbText->SetLinesToDraw(1); // this->Append(kbText); trigHeldA = new GuiTrigger; trigHeldA->SetHeldTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A); trigLeft = new GuiTrigger; trigLeft->SetButtonOnlyTrigger(-1, WPAD_BUTTON_LEFT | WPAD_CLASSIC_BUTTON_LEFT, PAD_BUTTON_LEFT); trigRight = new GuiTrigger; trigRight->SetButtonOnlyTrigger(-1, WPAD_BUTTON_RIGHT | WPAD_CLASSIC_BUTTON_RIGHT, PAD_BUTTON_RIGHT); GoRight = new GuiButton(1, 1); GoRight->SetSoundClick(keySoundClick); GoRight->SetTrigger(trigRight); GoRight->Clicked.connect(this, &GuiKeyboard::OnPositionMoved); this->Append(GoRight); GoLeft = new GuiButton(1, 1); GoLeft->SetSoundClick(keySoundClick); GoLeft->SetTrigger(trigLeft); GoLeft->Clicked.connect(this, &GuiKeyboard::OnPositionMoved); this->Append(GoLeft); TextPointerBtn = new TextPointer(kbText, 0); TextPointerBtn->SetAlignment(ALIGN_CENTRE, ALIGN_TOP); TextPointerBtn->SetPosition(7, 10); TextPointerBtn->SetHoldable(true); TextPointerBtn->SetTrigger(trigHeldA); TextPointerBtn->Held.connect(this, &GuiKeyboard::OnPointerHeld); this->Append(TextPointerBtn); TextPointerBtn->PositionChanged(0, 0, 0); TextPointerBtn->SetLetterPosition(MAX_KEYBOARD_DISPLAY-1); autoCompleteText = new GuiText("autocmpltstr", 20, (GXColor){0, 0, 0, 150}); autoCompleteText->SetAlignment(ALIGN_LEFT, ALIGN_TOP); autoCompleteText->SetPosition(24+autoCompleteText->GetTextWidth()/2, 10); this->Append(autoCompleteText); key = new GuiImageData(keyboard_key_png); keyOver = new GuiImageData(keyboard_key_over_png); keyMedium = new GuiImageData(keyboard_mediumkey_png); keyMediumOver = new GuiImageData(keyboard_mediumkey_over_png); keyLarge = new GuiImageData(keyboard_largekey_png); keyLargeOver = new GuiImageData(keyboard_largekey_over_png); keySoundOver = new GuiSound(button_over_pcm, button_over_pcm_size, SOUND_PCM); keySoundClick = new GuiSound(button_click_pcm, button_click_pcm_size, SOUND_PCM); trigA = new GuiTrigger; trigA->SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A); trigH = new GuiTrigger; trigH->SetHeldTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A); trig2 = new GuiTrigger; trig2->SetSimpleTrigger(-1, WPAD_BUTTON_2, 0); keyBackImg = new GuiImage(keyMedium); keyBackOverImg = new GuiImage(keyMediumOver); keyBackText = new GuiText("Back", 20, (GXColor){0, 0, 0, 0xff}); keyBack = new GuiButton(keyMedium->GetWidth(), keyMedium->GetHeight()); keyBack->SetImage(keyBackImg); keyBack->SetImageOver(keyBackOverImg); keyBack->SetLabel(keyBackText); keyBack->SetSoundOver(keySoundOver); keyBack->SetSoundHold(keySoundClick); keyBack->SetTrigger(trigH); keyBack->SetTrigger(trig2); keyBack->SetPosition(10*42+40, 0*42+80); keyBack->SetEffectGrow(); keyBack->SetHoldable(true); this->Append(keyBack); keyCapsImg = new GuiImage(keyMedium); keyCapsOverImg = new GuiImage(keyMediumOver); keyCapsText = new GuiText("Caps", 20, (GXColor){0, 0, 0, 0xff}); keyCaps = new GuiButton(keyMedium->GetWidth(), keyMedium->GetHeight()); keyCaps->SetImage(keyCapsImg); keyCaps->SetImageOver(keyCapsOverImg); keyCaps->SetLabel(keyCapsText); keyCaps->SetSoundOver(keySoundOver); keyCaps->SetSoundClick(keySoundClick); keyCaps->SetTrigger(trigA); keyCaps->SetTrigger(trig2); keyCaps->SetPosition(0, 2*42+80); keyCaps->SetEffectGrow(); this->Append(keyCaps); keyShiftImg = new GuiImage(keyMedium); keyShiftOverImg = new GuiImage(keyMediumOver); keyShiftText = new GuiText("Shift", 20, (GXColor){0, 0, 0, 0xff}); keyShift = new GuiButton(keyMedium->GetWidth(), keyMedium->GetHeight()); keyShift->SetImage(keyShiftImg); keyShift->SetImageOver(keyShiftOverImg); keyShift->SetLabel(keyShiftText); keyShift->SetSoundOver(keySoundOver); keyShift->SetSoundClick(keySoundClick); keyShift->SetTrigger(trigA); keyShift->SetTrigger(trig2); keyShift->SetPosition(21, 3*42+80); keyShift->SetEffectGrow(); this->Append(keyShift); keyEnterImg = new GuiImage(keyMedium); keyEnterOverImg = new GuiImage(keyMediumOver); keyEnterText = new GuiText("Enter", 20, (GXColor){0, 0, 0, 0xff}); keyEnter = new GuiButton(keyMedium->GetWidth(), keyMedium->GetHeight()); keyEnter->SetImage(keyEnterImg); keyEnter->SetImageOver(keyEnterOverImg); keyEnter->SetLabel(keyEnterText); keyEnter->SetSoundOver(keySoundOver); keyEnter->SetSoundClick(keySoundClick); keyEnter->SetTrigger(trigA); keyEnter->SetTrigger(trig2); keyEnter->SetPosition(10*42+61, 1*42+80); keyEnter->SetEffectGrow(); this->Append(keyEnter); keySpaceImg = new GuiImage(keyLarge); keySpaceOverImg = new GuiImage(keyLargeOver); keySpace = new GuiButton(keyLarge->GetWidth(), keyLarge->GetHeight()); keySpace->SetImage(keySpaceImg); keySpace->SetImageOver(keySpaceOverImg); keySpace->SetSoundOver(keySoundOver); keySpace->SetSoundClick(keySoundClick); keySpace->SetTrigger(trigA); keySpace->SetTrigger(trig2); keySpace->SetPosition(0, 4*42+80); keySpace->SetAlignment(ALIGN_CENTRE, ALIGN_TOP); keySpace->SetEffectGrow(); this->Append(keySpace); char txt[2] = { 0, 0 }; for(int i=0; i<4; i++) { for(int j=0; j<11; j++) { if(keys[i][j].ch != '\0') { txt[0] = keys[i][j].ch; keyImg[i][j] = new GuiImage(key); keyImgOver[i][j] = new GuiImage(keyOver); keyTxt[i][j] = new GuiText(txt, 20, (GXColor){0, 0, 0, 0xff}); keyTxt[i][j]->SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE); // keyTxt[i][j]->SetPosition(0, -10); keyBtn[i][j] = new GuiButton(key->GetWidth(), key->GetHeight()); keyBtn[i][j]->SetImage(keyImg[i][j]); keyBtn[i][j]->SetImageOver(keyImgOver[i][j]); keyBtn[i][j]->SetSoundOver(keySoundOver); keyBtn[i][j]->SetSoundClick(keySoundClick); keyBtn[i][j]->SetTrigger(trigA); keyBtn[i][j]->SetTrigger(trig2); keyBtn[i][j]->SetLabel(keyTxt[i][j]); if(i != 1) keyBtn[i][j]->SetPosition(j*42+21*i+40, i*42+80); else keyBtn[i][j]->SetPosition(j*42+21*i-1, i*42+80); keyBtn[i][j]->SetEffectGrow(); this->Append(keyBtn[i][j]); } } } }
void REV_init() { //Local variables f32 yscale; u32 xfbHeight; //Load the right IOS, so keyboard works fin u32 iosVersion = IOS_GetVersion(); if(iosVersion != 36) { IOS_ReloadIOS(36); } //// VIDEO_Init();//Video Library Init PAD_Init();//Gamecube Pad Library Init WPAD_Init();//Wiimote Library Init rMode = VIDEO_GetPreferredMode(NULL);//Set render mode // allocate 2 framebuffers for double buffering frameBuffer[0] = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rMode)); frameBuffer[1] = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rMode)); //Configure Video System VIDEO_Configure(rMode); VIDEO_SetNextFramebuffer(frameBuffer[fb]);//Initial Framebuffer VIDEO_Flush(); VIDEO_WaitVSync(); if(rMode->viTVMode&VI_NON_INTERLACE) VIDEO_WaitVSync(); fb ^= 1;//Set next index //Set up the FIFO void *gp_fifo = memalign(32,DEFAULT_FIFO_SIZE);//Allocate memset(gp_fifo,0,DEFAULT_FIFO_SIZE);//and Clear //Init GX hardware GX_Init(gp_fifo,DEFAULT_FIFO_SIZE); // clears the bg to color and clears the z buffer GX_SetCopyClear(DEF_BG_COLOR , 0x00ffffff); //More initialization w = rMode->viWidth; h = rMode->viHeight; yscale = GX_GetYScaleFactor(rMode->efbHeight,rMode->xfbHeight); xfbHeight = GX_SetDispCopyYScale(yscale); GX_SetDispCopySrc(0,0,rMode->fbWidth,rMode->efbHeight); GX_SetDispCopyDst(rMode->fbWidth,xfbHeight); GX_SetFieldMode(rMode->field_rendering,((h==2*rMode->xfbHeight)?GX_ENABLE:GX_DISABLE)); if (rMode->aa) GX_SetPixelFmt(GX_PF_RGB565_Z16, GX_ZC_LINEAR); else GX_SetPixelFmt(GX_PF_RGB8_Z24, GX_ZC_LINEAR); GX_CopyDisp(frameBuffer[fb],GX_TRUE); GX_SetDispCopyGamma(GX_GM_1_0); for(u8 i = 0; i < 4; i++) WPAD_SetVRes(i,w,h); //Hardware Initialized, now engine initialization //Init filesystem fatInitDefault(); //First create a Root mainRoot = new ROOT; mainRoot->init((f32)w,(f32)h); GX_SetBlendMode(GX_BM_BLEND, GX_BL_SRCALPHA, GX_BL_INVSRCALPHA, GX_LO_CLEAR); GX_SetColorUpdate(GX_ENABLE); GX_SetAlphaUpdate(GX_ENABLE); GX_SetZCompLoc(GX_TRUE); GX_SetZMode (GX_TRUE, GX_LEQUAL, GX_TRUE); init3dConfig(); init2dConfig(); init2D(w, h); transQueue = NULL; solidQueue = NULL; zQueue = NULL; REV_fontsInit(); KEYBOARD_Init(NULL); keyboardInit(); }
int main (int argc, char **argv) { VIDEO_Init(); WPAD_Init(); PAD_Init(); sys_rmode = VIDEO_GetPreferredMode(NULL); sys_framebuffer[0] = MEM_K0_TO_K1(SYS_AllocateFramebuffer(sys_rmode)); sys_framebuffer[1] = MEM_K0_TO_K1(SYS_AllocateFramebuffer(sys_rmode)); sys_frame_count = 0; CON_Init(sys_framebuffer[sys_frame_count & 1], 20, 20, sys_rmode->fbWidth, sys_rmode->xfbHeight, sys_rmode->fbWidth * VI_DISPLAY_PIX_SZ); VIDEO_Configure(sys_rmode); VIDEO_SetNextFramebuffer(sys_framebuffer[sys_frame_count & 1]); VIDEO_SetBlack(FALSE); VIDEO_Flush(); VIDEO_WaitVSync(); if(sys_rmode->viTVMode & VI_NON_INTERLACE) { VIDEO_WaitVSync(); }; sys_frame_count++; GXU_Init(sys_rmode, sys_framebuffer[sys_frame_count & 1]); WPAD_SetDataFormat(WPAD_CHAN_0, WPAD_FMT_BTNS_ACC_IR); WPAD_SetVRes(WPAD_CHAN_0, sys_rmode->fbWidth, sys_rmode->xfbHeight); if(!fatInitDefault()) { Sys_Error("Filesystem not enabled"); }; sys_previous_time = Sys_Milliseconds(); do { sys_netinit_error = if_config(sys_ipaddress_text, NULL, NULL, true); } while((sys_netinit_error == -EAGAIN)&&((Sys_Milliseconds() - sys_previous_time) < 3000)); if(sys_netinit_error < 0) { printf("Network not enabled\n"); }; if (KEYBOARD_Init(Sys_KeyPress) != 0) { printf("Keyboard not found\n"); }; OSK_LoadKeys(Keys_dat, Keys_dat_size); int len, i; char *cmdline; // merge the command line, this is kinda silly for (len = 1, i = 1; i < argc; i++) len += strlen(argv[i]) + 1; cmdline = malloc(len); *cmdline = 0; for (i = 1; i < argc; i++) { if (i > 1) strcat(cmdline, " "); strcat(cmdline, argv[i]); } Com_Init(cmdline); WPAD_SetPowerButtonCallback(Sys_PowerOff); while (1) { sys_previous_time = Sys_Milliseconds(); if(MOUSE_IsConnected()) { sys_mouse_valid = MOUSE_GetEvent(&sys_mouse_event); if(sys_mouse_valid) MOUSE_FlushEvents(); } else { sys_mouse_valid = 0; sys_mouse_event.button = 0; }; Com_Frame( ); if(in_osk->value) { OSK_Draw(sys_rmode, sys_framebuffer[sys_frame_count & 1]); }; sys_frame_count++; GXU_EndFrame(sys_framebuffer[sys_frame_count & 1]); KEYBOARD_FlushEvents(); VIDEO_Flush(); VIDEO_WaitVSync(); } return 0; }