Skip to content

Commit

Permalink
xrEngine, xrGame: replace DIK_ on SDL_SCANCODE_
Browse files Browse the repository at this point in the history
  • Loading branch information
eagleivg authored and Xottab-DUTY committed Jul 24, 2018
1 parent 6b197d4 commit d82b014
Show file tree
Hide file tree
Showing 89 changed files with 337 additions and 305 deletions.
5 changes: 5 additions & 0 deletions src/editors/xrEditor/packages.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="sdl2" version="2.0.5" targetFramework="native" />
<package id="sdl2.redist" version="2.0.5" targetFramework="native" />
</packages>
12 changes: 12 additions & 0 deletions src/editors/xrEditor/xrEditor.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,19 @@
</Reference>
<Reference Include="WindowsBase" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
<Import Project="..\..\packages\sdl2.redist.2.0.5\build\native\sdl2.redist.targets" Condition="Exists('..\..\packages\sdl2.redist.2.0.5\build\native\sdl2.redist.targets')" />
<Import Project="..\..\packages\sdl2.2.0.5\build\native\sdl2.targets" Condition="Exists('..\..\packages\sdl2.2.0.5\build\native\sdl2.targets')" />
</ImportGroup>
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>Данный проект ссылается на пакеты NuGet, отсутствующие на этом компьютере. Используйте восстановление пакетов NuGet, чтобы скачать их. Дополнительную информацию см. по адресу: http://go.microsoft.com/fwlink/?LinkID=322105. Отсутствует следующий файл: {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\..\packages\sdl2.redist.2.0.5\build\native\sdl2.redist.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\sdl2.redist.2.0.5\build\native\sdl2.redist.targets'))" />
<Error Condition="!Exists('..\..\packages\sdl2.2.0.5\build\native\sdl2.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\sdl2.2.0.5\build\native\sdl2.targets'))" />
</Target>
</Project>
6 changes: 6 additions & 0 deletions src/editors/xrEditor/xrEditor.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,10 @@
<ClCompile Include="pch.cpp" />
<ClCompile Include="entry_point.cpp" />
</ItemGroup>
<ItemGroup>
<Natvis Include="..\..\TypeHelper.natvis" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion src/xrEngine/IInputReceiver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ void IInputReceiver::IR_OnDeactivate(void)
int i;
for (i = 0; i < CInput::COUNT_KB_BUTTONS; i++)
if (IR_GetKeyState(i))
IR_OnKeyboardRelease(i);
IR_OnKeyboardRelease((SDL_Scancode)i);

for (i = 0; i < CInput::COUNT_MOUSE_BUTTONS; i++)
if (IR_GetBtnState(i))
Expand Down
22 changes: 12 additions & 10 deletions src/xrEngine/IInputReceiver.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@
#ifndef IINPUTRECEIVERH
#define IINPUTRECEIVERH
#include "xrCore/_flags.h"
#include "xrGame/xr_level_controller.h"

// fwd. decl.
template <class T> struct _vector2;
template <class T>
struct _vector2;
using Fvector2 = _vector2<float>;
using Ivector2 = _vector2<int>;

Expand All @@ -29,16 +31,16 @@ class ENGINE_API IInputReceiver
virtual void IR_OnDeactivate(void);
virtual void IR_OnActivate(void);

virtual void IR_OnMousePress(int /*btn*/) {};
virtual void IR_OnMouseRelease(int /*btn*/) {};
virtual void IR_OnMouseHold(int /*btn*/) {};
virtual void IR_OnMouseWheel(int /*direction*/) {};
virtual void IR_OnMouseMove(int /*x*/, int /*y*/) {};
virtual void IR_OnMouseStop(int /*x*/, int /*y*/) {};
virtual void IR_OnMousePress(int /*btn*/){};
virtual void IR_OnMouseRelease(int /*btn*/){};
virtual void IR_OnMouseHold(int /*btn*/){};
virtual void IR_OnMouseWheel(int /*direction*/){};
virtual void IR_OnMouseMove(int /*x*/, int /*y*/){};
virtual void IR_OnMouseStop(int /*x*/, int /*y*/){};

virtual void IR_OnKeyboardPress(int /*dik*/) {};
virtual void IR_OnKeyboardRelease(int /*dik*/) {};
virtual void IR_OnKeyboardHold(int /*dik*/) {};
virtual void IR_OnKeyboardPress(int /*dik*/){};
virtual void IR_OnKeyboardRelease(int /*dik*/){};
virtual void IR_OnKeyboardHold(int /*dik*/){};
};

ENGINE_API extern float psMouseSens;
Expand Down
4 changes: 3 additions & 1 deletion src/xrEngine/XR_IOConsole.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -614,6 +614,8 @@ void CConsole::Show()
Device.seqFrame.Add(this);
}

extern CInput* pInput;

void CConsole::Hide()
{
if (!bVisible || g_pGamePersistent && GEnv.isDedicatedServer)
Expand All @@ -622,7 +624,7 @@ void CConsole::Hide()
// if ( g_pGameLevel ||
// ( g_pGamePersistent && g_pGamePersistent->m_pMainMenu && g_pGamePersistent->m_pMainMenu->IsActive() ))

//if (pInput->get_exclusive_mode())
if (pInput->get_exclusive_mode())
{
SetCursorPos(m_mouse_pos.x, m_mouse_pos.y);
}
Expand Down
1 change: 0 additions & 1 deletion src/xrEngine/device.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,6 @@ class ENGINE_API CRenderDevice : public CRenderDeviceBase

public:
SDL_Window* m_sdlWnd;
SDL_Renderer* m_sdlRndr;
LRESULT MsgProc(HWND, UINT, WPARAM, LPARAM);

// u32 dwFrame;
Expand Down
4 changes: 2 additions & 2 deletions src/xrEngine/edit_actions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ void callback_base::on_key_press(line_edit_control* const control)

// -------------------------------------------------------------------------------------------------

type_pair::type_pair(u32 dik, char c, char c_shift, bool b_translate) { init(dik, c, c_shift, b_translate); }
type_pair::type_pair(SDL_Scancode dik, char c, char c_shift, bool b_translate) { init(dik, c, c_shift, b_translate); }
type_pair::~type_pair() {}
void type_pair::init(u32 dik, char c, char c_shift, bool b_translate)
void type_pair::init(SDL_Scancode dik, char c, char c_shift, bool b_translate)
{
m_translate = b_translate;
m_dik = dik;
Expand Down
6 changes: 3 additions & 3 deletions src/xrEngine/edit_actions.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ class callback_base : public base
class type_pair : public base
{
public:
type_pair(u32 dik, char c, char c_shift, bool b_translate);
type_pair(SDL_Scancode dik, char c, char c_shift, bool b_translate);
virtual ~type_pair();
void init(u32 dik, char c, char c_shift, bool b_translate);
void init(SDL_Scancode dik, char c, char c_shift, bool b_translate);
virtual void on_key_press(line_edit_control* const control);

private:
u32 m_dik;
SDL_Scancode m_dik;
bool m_translate;
char m_char;
char m_char_shift;
Expand Down
20 changes: 10 additions & 10 deletions src/xrEngine/line_edit_control.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ line_edit_control::line_edit_control(u32 str_buffer_size)
m_buf2 = nullptr;
m_buf3 = nullptr;

for (u32 i = 0; i < SDL_SCANCODE_COUNT; ++i)
for (u32 i = 0; i < SDL_NUM_SCANCODES; ++i)
m_actions[i] = nullptr;

init(str_buffer_size);
Expand Down Expand Up @@ -191,7 +191,7 @@ void line_edit_control::init(u32 str_buffer_size, init_mode mode)

clear_states();

for (u32 i = 0; i < SDL_SCANCODE_COUNT; ++i)
for (u32 i = 0; i < SDL_NUM_SCANCODES; ++i)
{
xr_delete(m_actions[i]);
m_actions[i] = nullptr;
Expand Down Expand Up @@ -359,7 +359,7 @@ void line_edit_control::assign_char_pairs(init_mode mode)
create_char_pair(SDL_SCANCODE_Z, 'z', 'Z', true);
}

void line_edit_control::create_key_state(u32 const dik, key_state state)
void line_edit_control::create_key_state(SDL_Scancode const dik, key_state state)
{
Base* prev = m_actions[dik];
// if ( m_actions[dik] )
Expand All @@ -369,7 +369,7 @@ void line_edit_control::create_key_state(u32 const dik, key_state state)
m_actions[dik] = new text_editor::key_state_base(state, prev);
}

void line_edit_control::create_char_pair(u32 const dik, char c, char c_shift, bool translate)
void line_edit_control::create_char_pair(SDL_Scancode const dik, char c, char c_shift, bool translate)
{
if (m_actions[dik])
{
Expand All @@ -379,9 +379,9 @@ void line_edit_control::create_char_pair(u32 const dik, char c, char c_shift, bo
m_actions[dik] = new text_editor::type_pair(dik, c, c_shift, translate);
}

void line_edit_control::assign_callback(u32 const dik, key_state state, Callback const& callback)
void line_edit_control::assign_callback(SDL_Scancode const dik, key_state state, Callback const& callback)
{
VERIFY(dik < SDL_SCANCODE_COUNT);
VERIFY(dik < SDL_NUM_SCANCODES);
Base* prev_action = m_actions[dik];
m_actions[dik] = new text_editor::callback_base(callback, state);
m_actions[dik]->on_assign(prev_action);
Expand All @@ -405,9 +405,9 @@ void line_edit_control::set_edit(pcstr str)

// ========================================================

void line_edit_control::on_key_press(int dik)
void line_edit_control::on_key_press(SDL_Scancode dik)
{
if (SDL_SCANCODE_COUNT <= dik)
if (SDL_NUM_SCANCODES <= dik)
{
return;
}
Expand Down Expand Up @@ -451,7 +451,7 @@ void line_edit_control::on_key_press(int dik)

// -------------------------------------------------------------------------------------------------

void line_edit_control::on_key_hold(int dik)
void line_edit_control::on_key_hold(SDL_Scancode dik)
{
update_key_states();
update_bufs();
Expand All @@ -478,7 +478,7 @@ void line_edit_control::on_key_hold(int dik)
}
}

void line_edit_control::on_key_release(int dik)
void line_edit_control::on_key_release(SDL_Scancode dik)
{
m_accel = 1.0f;
m_rep_time = 0.0f;
Expand Down
18 changes: 7 additions & 11 deletions src/xrEngine/line_edit_control.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ class ENGINE_API line_edit_control
~line_edit_control();

void clear_states();
void on_key_press(int dik);
void on_key_hold(int dik);
void on_key_release(int dik);
void on_key_press(SDL_Scancode dik);
void on_key_hold(SDL_Scancode dik);
void on_key_release(SDL_Scancode dik);
void on_frame();

void assign_callback(u32 const dik, key_state state, Callback const& callback);
void assign_callback(SDL_Scancode const dik, key_state state, Callback const& callback);

void insert_character(char c);

Expand Down Expand Up @@ -106,8 +106,8 @@ class ENGINE_API line_edit_control
void xr_stdcall SwitchKL();

void assign_char_pairs(init_mode mode);
void create_key_state(u32 const dik, key_state state);
void create_char_pair(u32 const dik, char c, char c_shift, bool translate = false);
void create_key_state(SDL_Scancode const dik, key_state state);
void create_char_pair(SDL_Scancode const dik, char c, char c_shift, bool translate = false);

void clear_inserted();
bool empty_inserted();
Expand All @@ -119,11 +119,7 @@ class ENGINE_API line_edit_control
void clamp_cur_pos();

private:
enum
{
SDL_SCANCODE_COUNT = 256
};
Base* m_actions[SDL_SCANCODE_COUNT];
Base* m_actions[SDL_NUM_SCANCODES];

char* m_edit_str;
char* m_undo_buf;
Expand Down
6 changes: 3 additions & 3 deletions src/xrEngine/line_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace text_editor
line_editor::line_editor(u32 str_buffer_size) : m_control(str_buffer_size) {}
line_editor::~line_editor() {}
void line_editor::on_frame() { m_control.on_frame(); }
void line_editor::IR_OnKeyboardPress(int dik) { m_control.on_key_press(dik); }
void line_editor::IR_OnKeyboardHold(int dik) { m_control.on_key_hold(dik); }
void line_editor::IR_OnKeyboardRelease(int dik) { m_control.on_key_release(dik); }
void line_editor::IR_OnKeyboardPress(int dik) {m_control.on_key_press((SDL_Scancode)dik); }
void line_editor::IR_OnKeyboardHold(int dik) {m_control.on_key_hold((SDL_Scancode)dik); }
void line_editor::IR_OnKeyboardRelease(int dik) {m_control.on_key_release((SDL_Scancode)dik); }
} // namespace text_editor
10 changes: 5 additions & 5 deletions src/xrEngine/xr_input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,9 @@ void CInput::KeyUpdate(SDL_Event* event)
*/
}

bool CInput::get_key_name(int dik, LPSTR dest_str, int dest_sz)
bool CInput::get_key_name(SDL_Scancode dik, LPSTR dest_str, int dest_sz)
{
const char* keyname = SDL_GetKeyName(dik);
const char* keyname = SDL_GetKeyName(SDL_GetKeyFromScancode(dik));
if (0 == strlen(keyname))
{
Msg("! cant convert dik_name for dik[%d]", dik);
Expand Down Expand Up @@ -194,7 +194,6 @@ void CInput::ClipCursor(bool clip)
if (clip)
{
//::ClipCursor(&Device.m_rcWindowClient);
SDL_RenderSetClipRect(Device.m_sdlRndr, &Device.m_rcWindowClient);
SDL_ShowCursor(SDL_DISABLE);
}
else
Expand Down Expand Up @@ -248,8 +247,9 @@ void CInput::iRelease(IInputReceiver* p)
{
cbStack.back()->IR_OnDeactivate();
cbStack.pop_back();
IInputReceiver* ir = cbStack.back();
ir->IR_OnActivate();

if (!cbStack.empty())
cbStack.back()->IR_OnActivate();
}
else
{
Expand Down
4 changes: 2 additions & 2 deletions src/xrEngine/xr_input.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class ENGINE_API CInput
{
COUNT_MOUSE_BUTTONS = 8,
COUNT_MOUSE_AXIS = 3,
COUNT_KB_BUTTONS = 256
COUNT_KB_BUTTONS = SDL_NUM_SCANCODES
};

struct InputStatistics
Expand Down Expand Up @@ -85,7 +85,7 @@ class ENGINE_API CInput
IC bool get_exclusive_mode();
void unacquire();
void acquire(const bool& exclusive);
bool get_key_name(int dik, LPSTR dest, int dest_sz);
bool get_key_name(SDL_Scancode dik, LPSTR dest, int dest_sz);

void feedback(u16 s1, u16 s2, float time);
};
Expand Down
2 changes: 1 addition & 1 deletion src/xrGame/Actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -943,7 +943,7 @@ void CActor::UpdateCL()
{
if (CurrentGameUI() && NULL == CurrentGameUI()->TopInputReceiver())
{
int dik = get_action_dik(kUSE, 0);
SDL_Scancode dik = get_action_dik(kUSE, 0);
if (dik && pInput->iGetAsyncKeyState(dik))
m_bPickupMode = true;

Expand Down
4 changes: 2 additions & 2 deletions src/xrGame/ActorInput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@ void CActor::OnNextWeaponSlot()
IR_OnKeyboardPress(kARTEFACT);
}
else
IR_OnKeyboardPress(kWPN_1 + i);
IR_OnKeyboardPress((EGameActions) (kWPN_1 + i));
return;
}
}
Expand Down Expand Up @@ -571,7 +571,7 @@ void CActor::OnPrevWeaponSlot()
IR_OnKeyboardPress(kARTEFACT);
}
else
IR_OnKeyboardPress(kWPN_1 + i);
IR_OnKeyboardPress((EGameActions) (kWPN_1 + i));
return;
}
}
Expand Down
Loading

0 comments on commit d82b014

Please sign in to comment.