Trouble making the purupuru (Jump Pack) vibrate

If you have any questions on programming, this is the place to ask them, whether you're a newbie or an experienced programmer. Discussion on programming in general is also welcome. We will help you with programming homework, but we will not do your work for you! Any porting requests must be made in Developmental Ideas.
Post Reply
User avatar
showka
DCEmu Freak
DCEmu Freak
Posts: 95
Joined: Fri Nov 23, 2001 12:01 pm
Location: Border Town
Has liked: 0
Been liked: 0
Contact:

Trouble making the purupuru (Jump Pack) vibrate

Post by showka » Wed Apr 25, 2007 4:17 pm

I don't understand what I'm doing wrong.

The following program simply prints out whats being pressed on Controllers 1 and 2. If Start is pressed, it tries to rumbles the jumppack (or purupuru). Instead what happens is the input stops being detected correctly.

I currently have the jump packs in port B of both controllers. The jump packs are both brand new (presumably) from an e-bay auction (they were pretty cheap and should still be available if anybody wants any).

I'm completely guessing at what to set shockVal to. I'm not sure if 178 is a good value or not.

Code: Select all

#include <cstdlib>
#include <iostream>

#include <kos.h>



using namespace std;


KOS_INIT_FLAGS(INIT_DEFAULT | INIT_MALLOCSTATS);
const int numPlayers = 2;
int main(int argc, char **argv) 
{
    pvr_init_params_t params = {
        // Enable opaque and translucent polygons with size 16
        { PVR_BINSIZE_16, PVR_BINSIZE_0, PVR_BINSIZE_16, PVR_BINSIZE_0, PVR_BINSIZE_16 },
        //{ PVR_BINSIZE_16, PVR_BINSIZE_0, PVR_BINSIZE_0, PVR_BINSIZE_0, PVR_BINSIZE_0 },
        // Vertex buffer size 512K
        512*1024
        };
       
     
    // Initializes KOS
    pvr_init(&params);
    
    
    // Controllers
    maple_device_t * controllers[numPlayers];
    maple_device_t * purupurus[2];
    cont_state_t * state[numPlayers];
    
    for (int i = 0; i < numPlayers; i ++)
    {     
          controllers[i] = maple_enum_type(i, MAPLE_FUNC_CONTROLLER);
          purupurus[i] = maple_enum_type(i, MAPLE_FUNC_PURUPURU);
    }   
    
    uint8 shockVal = 178;
    static purupuru_effect_t effect;
    effect.duration = 255;
     effect.effect2 = PURUPURU_EFFECT2_LINTENSITY(shockVal)
                    | PURUPURU_EFFECT2_PULSE;
     effect.effect1 = PURUPURU_EFFECT1_INTENSITY(shockVal)
                    | PURUPURU_EFFECT1_PULSE;
                    //PURUPURU_SPECIAL_MOTOR1;// | 
     effect.special = PURUPURU_SPECIAL_MOTOR1 | PURUPURU_SPECIAL_PULSE;
    
    
    bool quit = false;
    while(!quit)
    {
        bool x_down = false;
        for (int i = 0; i < numPlayers; i ++)
        {
            state[i] = static_cast<cont_state_t *>(maple_dev_status(controllers[i]));
            if ((state[i]->buttons & CONT_DPAD_UP))
            {
                    printf("Up!");
            }
            if ((state[i]->buttons & CONT_DPAD_DOWN))
            {
                printf("CONT_DPAD_DOWN");
            }
            if ((state[i]->buttons & CONT_DPAD_LEFT))
            {
                printf("CONT_DPAD_LEFT");
            }
            if ((state[i]->buttons & CONT_DPAD_RIGHT))
            {
                      printf("CONT_DPAD_RIGHT");
            }
            if ((state[i]->buttons & CONT_X))
            {
                     printf("CONT_X");
                                   x_down = true;
            }
            if ((state[i]->buttons & CONT_A))
            {
                  printf("CONT_A");
            }
            if ((state[i]->buttons & CONT_B))
            {
                  printf("CONT_B");
                  if (x_down) 
                     quit = true;
            }
            if ((state[i]->buttons & CONT_Y))
            {
                   printf("CONT_Y");
            }
            if ((state[i]->buttons & CONT_START))
            {
                   printf("CONT_START");
                   if (!purupuru_rumble(purupurus[i], &effect))
                     {
                         printf("Error sending shock to purupuru!\n");
                     }
            }
            if ((state[i]->ltrig > 0))
            {
                   printf("ltrig > 0");
            }
            if ((state[i]->rtrig > 0))
            {
                   printf("rtrig > 0");
            }
            
        }
    }
}

User avatar
mankrip
DCEmu Ex-Mod
DCEmu Ex-Mod
Posts: 3697
Joined: Sun Nov 04, 2001 5:12 pm
Has liked: 0
Been liked: 0
Contact:

Post by mankrip » Wed Apr 25, 2007 5:35 pm

There's a description of the purupuru parameters in the KOS headers IIRC.
Ph'nglui mglw'nafh mankrip Hell's end wgah'nagl fhtagn.
==-=-=-=-=-=-=-=-=-=-==
Dev blog / Twitter / YouTube
Image
User avatar
BlueCrab
The Crabby Overlord
The Crabby Overlord
Posts: 5383
Joined: Mon May 27, 2002 11:31 am
Location: Sailing the Skies of Arcadia
Has liked: 1 time
Been liked: 11 times
Contact:

Post by BlueCrab » Wed Apr 25, 2007 6:30 pm

Consult the following part of the header:

Code: Select all

/* Set one of each of the following in the effect2 field of the
   purupuru_effect_t. Valid values for each are 0-7. The LINTENSITY
   value works with the INTENSITY of effect1 to increase the intensity
   of the rumble, where UINTENSITY apparently lowers the rumble's
   intensity somewhat. */
#define PURUPURU_EFFECT2_UINTENSITY(x) (x << 4)
#define PURUPURU_EFFECT2_LINTENSITY(x) (x)
The maximum value for the intensity settings is 7.

As a side note, I should really put an example in KOS of how to use the purupurus....
User avatar
showka
DCEmu Freak
DCEmu Freak
Posts: 95
Joined: Fri Nov 23, 2001 12:01 pm
Location: Border Town
Has liked: 0
Been liked: 0
Contact:

Thanks!

Post by showka » Wed Apr 25, 2007 6:40 pm

Thanks BlueCrab! I changed shockVal to seven and the things started puring.
User avatar
BlueCrab
The Crabby Overlord
The Crabby Overlord
Posts: 5383
Joined: Mon May 27, 2002 11:31 am
Location: Sailing the Skies of Arcadia
Has liked: 1 time
Been liked: 11 times
Contact:

Re: Thanks!

Post by BlueCrab » Wed Apr 25, 2007 10:13 pm

showka wrote:Thanks BlueCrab! I changed shockVal to seven and the things started puring.
That's good to hear. Honestly, I don't think very many people have made use of that driver since I put it in KOS....
User avatar
showka
DCEmu Freak
DCEmu Freak
Posts: 95
Joined: Fri Nov 23, 2001 12:01 pm
Location: Border Town
Has liked: 0
Been liked: 0
Contact:

Post by showka » Fri Apr 27, 2007 11:36 am

Well I *plan* on using it so thanks for the effort!
User avatar
Quzar
Dream Coder
Dream Coder
Posts: 7486
Joined: Wed Jul 31, 2002 12:14 am
Location: Miami, FL
Has liked: 0
Been liked: 3 times
Contact:

Post by Quzar » Sat Apr 28, 2007 12:15 am

I used it for my Shippy 1984 port =). Without an official pack though, I had to calibrate it to my performance pack =P
"When you post fewer lines of text than your signature, consider not posting at all." - A Wise Man
User avatar
GyroVorbis
Elysian Shadows Developer
Elysian Shadows Developer
Posts: 1808
Joined: Mon Mar 22, 2004 4:55 pm
Location: #%^&*!!!11one Super Sonic
Has liked: 0
Been liked: 0
Contact:

Post by GyroVorbis » Tue May 01, 2007 10:31 pm

I've screwed around with it several times. When I get around to actually finishing a project, I'll definitely use it.
Elysian Shadows - "Next-Gen" 2D/3D RPG coming to Sega Dreamcast, Steam, OUYA, and Smartphones
Image
http://www.elysianshadows.com
Post Reply