Changeset 2930


Ignore:
Timestamp:
Sep 15, 2013, 6:45:01 AM (6 years ago)
Author:
benlitz
Message:

input: renamed xinput keys to something more human readable (such as A or DPadLeft) and inverted mouse Y axis to match joystick axis (negatives being up)
core: calling InitGame() at the first tick of an entity. InitDraw is still uncalled yet
fixed mrpigeon and orbital accordingly

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/demos/tutorial/07_input.cpp

    r2925 r2930  
    3535        if (m_mouse)
    3636        {
    37             m_controller->GetKey(KEY_DRAG_MESH).Bind("Mouse", "ButtonLeft");
     37            m_controller->GetKey(KEY_DRAG_MESH).Bind("Mouse", "Left");
    3838            m_controller->GetAxis(AXIS_DRAG_PITCH).Bind("Mouse", "Y");
    3939            m_controller->GetAxis(AXIS_DRAG_YAW).Bind("Mouse", "X");
     
    100100        {
    101101            if (lol::abs(m_controller->GetAxis(AXIS_PITCH).GetValue()) > 0.2f)
    102                 m_pitch_angle -= m_controller->GetAxis(AXIS_PITCH).GetValue() * seconds * 100;
     102                m_pitch_angle += m_controller->GetAxis(AXIS_PITCH).GetValue() * seconds * 100;
    103103            if (lol::abs(m_controller->GetAxis(AXIS_YAW).GetValue()) > 0.2f)
    104104                m_yaw_angle += m_controller->GetAxis(AXIS_YAW).GetValue() * seconds * 100;
  • trunk/src/input/input.cpp

    r2918 r2930  
    6565{
    6666    InputDeviceInternal* mouse = new InputDeviceInternal("Mouse");
    67     mouse->AddKey("ButtonLeft");
    68     mouse->AddKey("ButtonMiddle");
    69     mouse->AddKey("ButtonRight");
     67    mouse->AddKey("Left");
     68    mouse->AddKey("Middle");
     69    mouse->AddKey("Right");
    7070
    7171    mouse->AddAxis("X");
  • trunk/src/platform/d3d9/d3d9input.cpp

    r2841 r2930  
    5757        for (int j = 0; j < 4; ++j)
    5858            stick->AddAxis(String::Printf("Axis%d", j+1).C());
    59         for (int j = 0; j < 16; ++j)
    60             stick->AddKey(String::Printf("Button%d", j+1).C());
     59
     60        stick->AddKey("DPadUp");
     61        stick->AddKey("DPadDown");
     62        stick->AddKey("DPadLeft");
     63        stick->AddKey("DPadRight");
     64        stick->AddKey("Start");
     65        stick->AddKey("Back");
     66        stick->AddKey("LeftThumb");
     67        stick->AddKey("RightThumb");
     68        stick->AddKey("LeftShoulder");
     69        stick->AddKey("RightShoulder");
     70        stick->AddKey("A");
     71        stick->AddKey("B");
     72        stick->AddKey("X");
     73        stick->AddKey("Y");
    6174
    6275        m_data->m_joysticks.Push(i, stick);
     
    8396{
    8497    Entity::TickGame(seconds);
    85 }
    86 
    87 void D3d9Input::TickDraw(float seconds)
    88 {
    89     Entity::TickDraw(seconds);
    9098
    9199#if defined USE_XINPUT
     
    102110
    103111        for (int b = 0; b < 16; b++)
    104             m_data->m_joysticks[i].m2->SetKey(b, ((uint16_t)(state.Gamepad.wButtons) >> b) & 1);
     112        {
     113            // Reserved values
     114            if ((1 << b) > XINPUT_GAMEPAD_RIGHT_SHOULDER && (1 << b) < XINPUT_GAMEPAD_A)
     115                continue;
     116
     117            int key_index = (1 << b) > XINPUT_GAMEPAD_RIGHT_SHOULDER ? b - 2 : b;
     118
     119            m_data->m_joysticks[i].m2->SetKey(key_index, ((uint16_t)(state.Gamepad.wButtons) >> b) & 1);
     120        }
    105121    }
    106122#endif
    107123}
    108124
     125void D3d9Input::TickDraw(float seconds)
     126{
     127    Entity::TickDraw(seconds);
     128}
     129
    109130} /* namespace lol */
    110131
  • trunk/src/platform/sdl/sdlinput.cpp

    r2902 r2930  
    226226        // Note: 100.0f is an arbitrary value that makes it feel about the same than an xbox controller joystick
    227227        m_mouse->SetAxis(0, (float)(mouse.x - m_prevmouse.x) * 100.0f / m_screen_w);
    228         m_mouse->SetAxis(1, (float)(mouse.y - m_prevmouse.y) * 100.0f / m_screen_h);
     228        // Y Axis is also negated to match the usual joystick Y axis (negatives values are for the upper direction)
     229        m_mouse->SetAxis(1, -(float)(mouse.y - m_prevmouse.y) * 100.0f / m_screen_h);
    229230    }
    230231
  • trunk/src/ticker.cpp

    r2898 r2930  
    338338        data->m_list[e->m_gamegroup].Push(e);
    339339        data->m_list[e->m_drawgroup].Push(e);
     340
     341        // Initialize the entity
     342        e->InitGame();
    340343    }
    341344
Note: See TracChangeset for help on using the changeset viewer.