MCPcopy Create free account
hub / github.com/DaedalusX64/daedalus / GetState

Method GetState

Source/SysPSP/Input/InputManagerPSP.cpp:386–432  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

384//
385//*****************************************************************************
386void IInputManager::GetState( OSContPad pPad[4] )
387{
388 // Clear the initial state of the four controllers
389 for(u32 cont = 0; cont < 4; cont++)
390 {
391 pPad[cont].button = 0;
392 pPad[cont].stick_x = 0;
393 pPad[cont].stick_y = 0;
394 }
395
396 SceCtrlData pad;
397
398 sceCtrlPeekBufferPositive(&pad, 1); //Get PSP button inputs
399
400 // 'Normalise' from 0..255 -> -128..+127
401 //
402 s32 normalised_x( pad.Lx - PSP_ANALOGUE_STICK_RANGE );
403 s32 normalised_y( pad.Ly - PSP_ANALOGUE_STICK_RANGE );
404
405 //
406 // Now scale from -128..+127 -> -80..+80 (y is inverted from PSP coords)
407 //
408 v2 stick( f32( normalised_x ) / PSP_ANALOGUE_STICK_RANGE, f32( normalised_y ) / PSP_ANALOGUE_STICK_RANGE );
409
410 stick = ApplyDeadzone( stick, gGlobalPreferences.StickMinDeadzone, gGlobalPreferences.StickMaxDeadzone );
411
412 //Smoother joystick sensitivity //Corn
413 stick.x = 0.5f * stick.x + 0.5f * stick.x * stick.x * stick.x;
414 stick.y = 0.5f * stick.y + 0.5f * stick.y * stick.y * stick.y;
415
416 pPad[0].stick_x = s8(stick.x * N64_ANALOGUE_STICK_RANGE);
417 pPad[0].stick_y = -s8(stick.y * N64_ANALOGUE_STICK_RANGE);
418
419#ifdef DAEDALUS_ENABLE_ASSERTS
420 DAEDALUS_ASSERT( mpControllerConfig != NULL, "We should always have a valid controller" );
421 #endif
422
423 SwapJoyStick(&pPad[0], &pad);
424
425 pPad[0].button = mpControllerConfig->GetN64ButtonsState( pad.Buttons );
426
427 // Synchronise the input - this will overwrite the real pad data when playing back input
428 for(u32 cont = 0; cont < 4; cont++)
429 {
430 SYNCH_DATA( pPad[cont] );
431 }
432}
433
434//*****************************************************************************
435//

Callers

nothing calls this directly

Calls 2

ApplyDeadzoneFunction · 0.85
GetN64ButtonsStateMethod · 0.80

Tested by

no test coverage detected