Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
尘离序散
obs-studio
提交
26cf4688
O
obs-studio
项目概览
尘离序散
/
obs-studio
与 Fork 源项目一致
从无法访问的项目Fork
通知
30
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
obs-studio
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
26cf4688
编写于
9月 14, 2014
作者:
K
kc5nra
提交者:
John Bradley
9月 15, 2014
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add interaction support to libobs
上级
2446f621
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
211 addition
and
0 deletion
+211
-0
libobs/CMakeLists.txt
libobs/CMakeLists.txt
+1
-0
libobs/obs-interaction.h
libobs/obs-interaction.h
+56
-0
libobs/obs-source.c
libobs/obs-source.c
+70
-0
libobs/obs-source.h
libobs/obs-source.h
+62
-0
libobs/obs.h
libobs/obs.h
+22
-0
未找到文件。
libobs/CMakeLists.txt
浏览文件 @
26cf4688
...
...
@@ -222,6 +222,7 @@ set(libobs_libobs_HEADERS
obs-ui.h
obs-properties.h
obs-data.h
obs-interaction.h
obs-module.h
obs-scene.h
obs-source.h
...
...
libobs/obs-interaction.h
0 → 100644
浏览文件 @
26cf4688
/******************************************************************************
Copyright (C) 2014 by Hugh Bailey <obs.jim@gmail.com>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
#pragma once
#include "util/c99defs.h"
enum
obs_interaction_flags
{
INTERACT_NONE
=
0
,
INTERACT_CAPS_KEY
=
1
,
INTERACT_SHIFT_KEY
=
1
<<
1
,
INTERACT_CONTROL_KEY
=
1
<<
2
,
INTERACT_ALT_KEY
=
1
<<
3
,
INTERACT_MOUSE_LEFT
=
1
<<
4
,
INTERACT_MOUSE_MIDDLE
=
1
<<
5
,
INTERACT_MOUSE_RIGHT
=
1
<<
6
,
INTERACT_COMMAND_KEY
=
1
<<
7
,
INTERACT_NUMLOCK_KEY
=
1
<<
8
,
INTERACT_IS_KEY_PAD
=
1
<<
9
,
INTERACT_IS_LEFT
=
1
<<
10
,
INTERACT_IS_RIGHT
=
1
<<
11
};
enum
obs_mouse_button_type
{
MOUSE_LEFT
,
MOUSE_MIDDLE
,
MOUSE_RIGHT
};
struct
obs_mouse_event
{
uint32_t
modifiers
;
int32_t
x
;
int32_t
y
;
};
struct
obs_key_event
{
uint32_t
modifiers
;
char
*
text
;
uint32_t
native_modifiers
;
uint32_t
native_scancode
;
uint32_t
native_vkey
;
};
libobs/obs-source.c
浏览文件 @
26cf4688
...
...
@@ -389,6 +389,76 @@ void obs_source_update(obs_source_t source, obs_data_t settings)
}
}
void
obs_source_send_mouse_click
(
obs_source_t
source
,
const
struct
obs_mouse_event
*
event
,
int32_t
type
,
bool
mouse_up
,
uint32_t
click_count
)
{
if
(
!
source
)
return
;
if
(
source
->
info
.
output_flags
&
OBS_SOURCE_INTERACTION
)
{
if
(
source
->
info
.
mouse_click
)
{
source
->
info
.
mouse_click
(
source
->
context
.
data
,
event
,
type
,
mouse_up
,
click_count
);
}
}
}
void
obs_source_send_mouse_move
(
obs_source_t
source
,
const
struct
obs_mouse_event
*
event
,
bool
mouse_leave
)
{
if
(
!
source
)
return
;
if
(
source
->
info
.
output_flags
&
OBS_SOURCE_INTERACTION
)
{
if
(
source
->
info
.
mouse_move
)
{
source
->
info
.
mouse_move
(
source
->
context
.
data
,
event
,
mouse_leave
);
}
}
}
void
obs_source_send_mouse_wheel
(
obs_source_t
source
,
const
struct
obs_mouse_event
*
event
,
int
x_delta
,
int
y_delta
)
{
if
(
!
source
)
return
;
if
(
source
->
info
.
output_flags
&
OBS_SOURCE_INTERACTION
)
{
if
(
source
->
info
.
mouse_wheel
)
{
source
->
info
.
mouse_wheel
(
source
->
context
.
data
,
event
,
x_delta
,
y_delta
);
}
}
}
void
obs_source_send_focus
(
obs_source_t
source
,
bool
focus
)
{
if
(
!
source
)
return
;
if
(
source
->
info
.
output_flags
&
OBS_SOURCE_INTERACTION
)
{
if
(
source
->
info
.
focus
)
{
source
->
info
.
focus
(
source
->
context
.
data
,
focus
);
}
}
}
void
obs_source_send_key_click
(
obs_source_t
source
,
const
struct
obs_key_event
*
event
,
bool
key_up
)
{
if
(
!
source
)
return
;
if
(
source
->
info
.
output_flags
&
OBS_SOURCE_INTERACTION
)
{
if
(
source
->
info
.
key_click
)
{
source
->
info
.
key_click
(
source
->
context
.
data
,
event
,
key_up
);
}
}
}
static
void
activate_source
(
obs_source_t
source
)
{
if
(
source
->
context
.
data
&&
source
->
info
.
activate
)
...
...
libobs/obs-source.h
浏览文件 @
26cf4688
...
...
@@ -88,6 +88,14 @@ enum obs_source_type {
*/
#define OBS_SOURCE_COLOR_MATRIX (1<<4)
/**
* Source supports interaction.
*
* When this is used, the source will receive interaction events
* if they provide the necessary callbacks in the source definition structure.
*/
#define OBS_SOURCE_INTERACTION (1<<5)
/** @} */
typedef
void
(
*
obs_source_enum_proc_t
)(
obs_source_t
parent
,
obs_source_t
child
,
...
...
@@ -283,6 +291,60 @@ struct obs_source_info {
* @param settings Settings
*/
void
(
*
load
)(
void
*
data
,
obs_data_t
settings
);
/**
* Called when interacting with a source and a mouse-down or mouse-up
* occurs.
*
* @param data Source data
* @param event Mouse event properties
* @param type Mouse button pushed
* @param mouse_up Mouse event type (true if mouse-up)
* @param click_count Mouse click count (1 for single click, etc.)
*/
void
(
*
mouse_click
)(
void
*
data
,
const
struct
obs_mouse_event
*
event
,
int32_t
type
,
bool
mouse_up
,
uint32_t
click_count
);
/**
* Called when interacting with a source and a mouse-move occurs.
*
* @param data Source data
* @param event Mouse event properties
* @param mouse_leave Mouse leave state (true if mouse left source)
*/
void
(
*
mouse_move
)(
void
*
data
,
const
struct
obs_mouse_event
*
event
,
bool
mouse_leave
);
/**
* Called when interacting with a source and a mouse-wheel occurs.
*
* @param data Source data
* @param event Mouse event properties
* @param x_delta Movement delta in the horizontal direction
* @param y_delta Movement delta in the vertical direction
*/
void
(
*
mouse_wheel
)(
void
*
data
,
const
struct
obs_mouse_event
*
event
,
int
x_delta
,
int
y_delta
);
/**
* Called when interacting with a source and gain focus/lost focus event
* occurs.
*
* @param data Source data
* @param focus Focus state (true if focus gained)
*/
void
(
*
focus
)(
void
*
data
,
bool
focus
);
/**
* Called when interacting with a source and a key-up or key-down
* occurs.
*
* @param data Source data
* @param event Key event properties
* @param focus Key event type (true if mouse-up)
*/
void
(
*
key_click
)(
void
*
data
,
const
struct
obs_key_event
*
event
,
bool
key_up
);
};
EXPORT
void
obs_register_source_s
(
const
struct
obs_source_info
*
info
,
...
...
libobs/obs.h
浏览文件 @
26cf4688
...
...
@@ -33,6 +33,7 @@
#include "obs-data.h"
#include "obs-ui.h"
#include "obs-properties.h"
#include "obs-interaction.h"
struct
matrix4
;
...
...
@@ -751,6 +752,27 @@ EXPORT void obs_source_add_child(obs_source_t parent, obs_source_t child);
*/
EXPORT
void
obs_source_remove_child
(
obs_source_t
parent
,
obs_source_t
child
);
/** Sends a mouse down/up event to a source */
EXPORT
void
obs_source_send_mouse_click
(
obs_source_t
source
,
const
struct
obs_mouse_event
*
event
,
int32_t
type
,
bool
mouse_up
,
uint32_t
click_count
);
/** Sends a mouse move event to a source. */
EXPORT
void
obs_source_send_mouse_move
(
obs_source_t
source
,
const
struct
obs_mouse_event
*
event
,
bool
mouse_leave
);
/** Sends a mouse wheel event to a source */
EXPORT
void
obs_source_send_mouse_wheel
(
obs_source_t
source
,
const
struct
obs_mouse_event
*
event
,
int
x_delta
,
int
y_delta
);
/** Sends a got-focus or lost-focus event to a source */
EXPORT
void
obs_source_send_focus
(
obs_source_t
source
,
bool
focus
);
/** Sends a key up/down event to a source */
EXPORT
void
obs_source_send_key_click
(
obs_source_t
source
,
const
struct
obs_key_event
*
event
,
bool
key_up
);
/** Begins transition frame. Sets all transitioning volume values to 0.0f. */
EXPORT
void
obs_transition_begin_frame
(
obs_source_t
transition
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录