core: calling InitGame() at the first tick of an entity. InitDraw is still uncalled yet fixed mrpigeon and orbital accordinglyundefined
| @@ -34,7 +34,7 @@ public: | |||||
| m_mouse = InputDevice::Get("Mouse"); | m_mouse = InputDevice::Get("Mouse"); | ||||
| if (m_mouse) | if (m_mouse) | ||||
| { | { | ||||
| m_controller->GetKey(KEY_DRAG_MESH).Bind("Mouse", "ButtonLeft"); | |||||
| m_controller->GetKey(KEY_DRAG_MESH).Bind("Mouse", "Left"); | |||||
| m_controller->GetAxis(AXIS_DRAG_PITCH).Bind("Mouse", "Y"); | m_controller->GetAxis(AXIS_DRAG_PITCH).Bind("Mouse", "Y"); | ||||
| m_controller->GetAxis(AXIS_DRAG_YAW).Bind("Mouse", "X"); | m_controller->GetAxis(AXIS_DRAG_YAW).Bind("Mouse", "X"); | ||||
| } | } | ||||
| @@ -99,7 +99,7 @@ public: | |||||
| if (m_joystick) | if (m_joystick) | ||||
| { | { | ||||
| if (lol::abs(m_controller->GetAxis(AXIS_PITCH).GetValue()) > 0.2f) | if (lol::abs(m_controller->GetAxis(AXIS_PITCH).GetValue()) > 0.2f) | ||||
| m_pitch_angle -= m_controller->GetAxis(AXIS_PITCH).GetValue() * seconds * 100; | |||||
| m_pitch_angle += m_controller->GetAxis(AXIS_PITCH).GetValue() * seconds * 100; | |||||
| if (lol::abs(m_controller->GetAxis(AXIS_YAW).GetValue()) > 0.2f) | if (lol::abs(m_controller->GetAxis(AXIS_YAW).GetValue()) > 0.2f) | ||||
| m_yaw_angle += m_controller->GetAxis(AXIS_YAW).GetValue() * seconds * 100; | m_yaw_angle += m_controller->GetAxis(AXIS_YAW).GetValue() * seconds * 100; | ||||
| } | } | ||||
| @@ -64,9 +64,9 @@ InputDeviceInternal* InputDeviceInternal::CreateStandardKeyboard() | |||||
| InputDeviceInternal* InputDeviceInternal::CreateStandardMouse() | InputDeviceInternal* InputDeviceInternal::CreateStandardMouse() | ||||
| { | { | ||||
| InputDeviceInternal* mouse = new InputDeviceInternal("Mouse"); | InputDeviceInternal* mouse = new InputDeviceInternal("Mouse"); | ||||
| mouse->AddKey("ButtonLeft"); | |||||
| mouse->AddKey("ButtonMiddle"); | |||||
| mouse->AddKey("ButtonRight"); | |||||
| mouse->AddKey("Left"); | |||||
| mouse->AddKey("Middle"); | |||||
| mouse->AddKey("Right"); | |||||
| mouse->AddAxis("X"); | mouse->AddAxis("X"); | ||||
| mouse->AddAxis("Y"); | mouse->AddAxis("Y"); | ||||
| @@ -56,8 +56,21 @@ D3d9Input::D3d9Input() | |||||
| InputDeviceInternal* stick = new InputDeviceInternal(String::Printf("Joystick%d", i+1).C()); | InputDeviceInternal* stick = new InputDeviceInternal(String::Printf("Joystick%d", i+1).C()); | ||||
| for (int j = 0; j < 4; ++j) | for (int j = 0; j < 4; ++j) | ||||
| stick->AddAxis(String::Printf("Axis%d", j+1).C()); | stick->AddAxis(String::Printf("Axis%d", j+1).C()); | ||||
| for (int j = 0; j < 16; ++j) | |||||
| stick->AddKey(String::Printf("Button%d", j+1).C()); | |||||
| stick->AddKey("DPadUp"); | |||||
| stick->AddKey("DPadDown"); | |||||
| stick->AddKey("DPadLeft"); | |||||
| stick->AddKey("DPadRight"); | |||||
| stick->AddKey("Start"); | |||||
| stick->AddKey("Back"); | |||||
| stick->AddKey("LeftThumb"); | |||||
| stick->AddKey("RightThumb"); | |||||
| stick->AddKey("LeftShoulder"); | |||||
| stick->AddKey("RightShoulder"); | |||||
| stick->AddKey("A"); | |||||
| stick->AddKey("B"); | |||||
| stick->AddKey("X"); | |||||
| stick->AddKey("Y"); | |||||
| m_data->m_joysticks.Push(i, stick); | m_data->m_joysticks.Push(i, stick); | ||||
| } | } | ||||
| @@ -82,11 +95,6 @@ D3d9Input::~D3d9Input() | |||||
| void D3d9Input::TickGame(float seconds) | void D3d9Input::TickGame(float seconds) | ||||
| { | { | ||||
| Entity::TickGame(seconds); | Entity::TickGame(seconds); | ||||
| } | |||||
| void D3d9Input::TickDraw(float seconds) | |||||
| { | |||||
| Entity::TickDraw(seconds); | |||||
| #if defined USE_XINPUT | #if defined USE_XINPUT | ||||
| for (int i = 0; i < m_data->m_joysticks.Count(); i++) | for (int i = 0; i < m_data->m_joysticks.Count(); i++) | ||||
| @@ -101,10 +109,23 @@ void D3d9Input::TickDraw(float seconds) | |||||
| m_data->m_joysticks[i].m2->SetAxis(3, -(float)state.Gamepad.sThumbRY / 32768.f); | m_data->m_joysticks[i].m2->SetAxis(3, -(float)state.Gamepad.sThumbRY / 32768.f); | ||||
| for (int b = 0; b < 16; b++) | for (int b = 0; b < 16; b++) | ||||
| m_data->m_joysticks[i].m2->SetKey(b, ((uint16_t)(state.Gamepad.wButtons) >> b) & 1); | |||||
| { | |||||
| // Reserved values | |||||
| if ((1 << b) > XINPUT_GAMEPAD_RIGHT_SHOULDER && (1 << b) < XINPUT_GAMEPAD_A) | |||||
| continue; | |||||
| int key_index = (1 << b) > XINPUT_GAMEPAD_RIGHT_SHOULDER ? b - 2 : b; | |||||
| m_data->m_joysticks[i].m2->SetKey(key_index, ((uint16_t)(state.Gamepad.wButtons) >> b) & 1); | |||||
| } | |||||
| } | } | ||||
| #endif | #endif | ||||
| } | } | ||||
| void D3d9Input::TickDraw(float seconds) | |||||
| { | |||||
| Entity::TickDraw(seconds); | |||||
| } | |||||
| } /* namespace lol */ | } /* namespace lol */ | ||||
| @@ -225,7 +225,8 @@ void SdlInputData::Tick(float seconds) | |||||
| m_mouse->SetCursor(0, vec2((float)(mouse.x) / m_app_w, (float)(mouse.y) / m_app_h), mouse); | m_mouse->SetCursor(0, vec2((float)(mouse.x) / m_app_w, (float)(mouse.y) / m_app_h), mouse); | ||||
| // Note: 100.0f is an arbitrary value that makes it feel about the same than an xbox controller joystick | // Note: 100.0f is an arbitrary value that makes it feel about the same than an xbox controller joystick | ||||
| m_mouse->SetAxis(0, (float)(mouse.x - m_prevmouse.x) * 100.0f / m_screen_w); | m_mouse->SetAxis(0, (float)(mouse.x - m_prevmouse.x) * 100.0f / m_screen_w); | ||||
| m_mouse->SetAxis(1, (float)(mouse.y - m_prevmouse.y) * 100.0f / m_screen_h); | |||||
| // Y Axis is also negated to match the usual joystick Y axis (negatives values are for the upper direction) | |||||
| m_mouse->SetAxis(1, -(float)(mouse.y - m_prevmouse.y) * 100.0f / m_screen_h); | |||||
| } | } | ||||
| if (m_mousecapture) | if (m_mousecapture) | ||||
| @@ -337,6 +337,9 @@ void TickerData::GameThreadTick() | |||||
| data->m_todolist.Remove(-1); | data->m_todolist.Remove(-1); | ||||
| data->m_list[e->m_gamegroup].Push(e); | data->m_list[e->m_gamegroup].Push(e); | ||||
| data->m_list[e->m_drawgroup].Push(e); | data->m_list[e->m_drawgroup].Push(e); | ||||
| // Initialize the entity | |||||
| e->InitGame(); | |||||
| } | } | ||||
| /* Tick objects for the game loop */ | /* Tick objects for the game loop */ | ||||