Basic InputCommon setup
This commit is contained in:
parent
99b1f868a3
commit
82b9dff712
5 changed files with 119 additions and 0 deletions
|
@ -2,6 +2,7 @@
|
|||
include_directories(.)
|
||||
|
||||
add_subdirectory(common)
|
||||
add_subdirectory(input_common)
|
||||
add_subdirectory(core)
|
||||
add_subdirectory(video_core)
|
||||
if (ENABLE_GLFW)
|
||||
|
|
3
src/input_common/CMakeLists.txt
Normal file
3
src/input_common/CMakeLists.txt
Normal file
|
@ -0,0 +1,3 @@
|
|||
set(SRCS input_common.cpp)
|
||||
|
||||
add_library(input_common STATIC ${SRCS})
|
36
src/input_common/controller_state.h
Normal file
36
src/input_common/controller_state.h
Normal file
|
@ -0,0 +1,36 @@
|
|||
// Copyright 2015 Citra Emulator Project
|
||||
// Licensed under GPLv2 or any later version
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "common/common_types.h"
|
||||
|
||||
namespace InputCommon {
|
||||
|
||||
enum ControllerButtons {
|
||||
A = 0,
|
||||
B,
|
||||
X,
|
||||
Y,
|
||||
L,
|
||||
R,
|
||||
ZL,
|
||||
ZR,
|
||||
START,
|
||||
SELECT,
|
||||
HOME,
|
||||
DPAD_LEFT,
|
||||
DPAD_RIGHT,
|
||||
DPAD_UP,
|
||||
DPAD_DOWN
|
||||
};
|
||||
|
||||
struct ControllerState {
|
||||
bool buttons[15];
|
||||
s16 circle_pad_x;
|
||||
s16 circle_pad_y;
|
||||
u16 touch_screen_x;
|
||||
u16 touch_screen_y;
|
||||
};
|
||||
} //namespace
|
32
src/input_common/input_common.cpp
Normal file
32
src/input_common/input_common.cpp
Normal file
|
@ -0,0 +1,32 @@
|
|||
// Copyright 2015 Citra Emulator Project
|
||||
// Licensed under GPLv2 or any later version
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include "input_common/input_common.h"
|
||||
|
||||
namespace InputCommon {
|
||||
|
||||
ControllerBase::ControllerBase() {
|
||||
device_name = "None";
|
||||
|
||||
//Make sure internal 3DS input is in a neutral state before continuing
|
||||
for(int x = 0; x < 15; x++) {
|
||||
controller_state.buttons[x] = false;
|
||||
}
|
||||
|
||||
controller_state.circle_pad_x = 0;
|
||||
controller_state.circle_pad_y = 0;
|
||||
controller_state.touch_screen_x = 0;
|
||||
controller_state.touch_screen_y = 0;
|
||||
}
|
||||
|
||||
std::string ControllerBase::GetDeviceName() const {
|
||||
return device_name;
|
||||
}
|
||||
|
||||
//Set to nullptr until initialized by a backend
|
||||
ControllerBase* g_user_input = nullptr;
|
||||
|
||||
} // namespace
|
||||
|
||||
|
47
src/input_common/input_common.h
Normal file
47
src/input_common/input_common.h
Normal file
|
@ -0,0 +1,47 @@
|
|||
// Copyright 2015 Citra Emulator Project
|
||||
// Licensed under GPLv2 or any later version
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "common/common_types.h"
|
||||
#include "controller_state.h"
|
||||
#include "core/hle/service/hid/hid.h"
|
||||
|
||||
namespace InputCommon {
|
||||
|
||||
class ControllerBase {
|
||||
public:
|
||||
ControllerBase();
|
||||
virtual ~ControllerBase();
|
||||
|
||||
///Initializes input based on specific backends
|
||||
virtual bool Init() = 0;
|
||||
|
||||
///Grabs a list of devices supported by the backend
|
||||
virtual void DiscoverDevices() = 0;
|
||||
|
||||
///Grab and process input
|
||||
virtual void Poll() = 0;
|
||||
|
||||
///Shuts down all backend related data
|
||||
virtual void ShutDown() = 0;
|
||||
|
||||
///Returns internal name of currently selected device. Expose this to the UI
|
||||
std::string GetDeviceName() const;
|
||||
|
||||
private:
|
||||
|
||||
///Internal view this specific object will have of 3DS input states, NOT the same as Service::HID::PadState!
|
||||
ControllerState controller_state;
|
||||
|
||||
///Internal name of currently selected device
|
||||
std::string device_name;
|
||||
};
|
||||
|
||||
|
||||
///InputCommon 'plugin'
|
||||
extern ControllerBase* g_user_input;
|
||||
} // namespace
|
||||
|
||||
|
Loading…
Reference in a new issue