Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Y
YGOMobile
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
fallenstardust
YGOMobile
Commits
dc0f50aa
Commit
dc0f50aa
authored
Sep 26, 2021
by
fallenstardust
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
revert 点击事件
NDK编译顺序armeabi-v7a
parent
93fa6554
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
188 additions
and
56 deletions
+188
-56
Classes/gframe/game.cpp
Classes/gframe/game.cpp
+12
-1
Classes/gframe/game.h
Classes/gframe/game.h
+22
-1
Classes/gframe/gframe.cpp
Classes/gframe/gframe.cpp
+1
-0
libcore/android/android_tools.cpp
libcore/android/android_tools.cpp
+36
-3
libcore/android/android_tools.h
libcore/android/android_tools.h
+5
-1
libcore/jni/Application.mk
libcore/jni/Application.mk
+2
-2
libcore/jni/cn_garymb_ygomobile_core_IrrlichtBridge.cpp
libcore/jni/cn_garymb_ygomobile_core_IrrlichtBridge.cpp
+8
-0
libcore/src/main/java/cn/garymb/ygomobile/YGOMobileActivity.java
.../src/main/java/cn/garymb/ygomobile/YGOMobileActivity.java
+73
-18
libcore/src/main/java/cn/garymb/ygomobile/controller/InputQueueCompat.java
...java/cn/garymb/ygomobile/controller/InputQueueCompat.java
+6
-0
libcore/src/main/java/cn/garymb/ygomobile/core/GameActivity.java
.../src/main/java/cn/garymb/ygomobile/core/GameActivity.java
+10
-28
libcore/src/main/java/cn/garymb/ygomobile/core/IrrlichtBridge.java
...rc/main/java/cn/garymb/ygomobile/core/IrrlichtBridge.java
+10
-0
mobile/build.gradle
mobile/build.gradle
+3
-2
No files found.
Classes/gframe/game.cpp
View file @
dc0f50aa
...
@@ -27,6 +27,15 @@ namespace ygo {
...
@@ -27,6 +27,15 @@ namespace ygo {
Game
*
mainGame
;
Game
*
mainGame
;
void
Game
::
process
(
irr
::
SEvent
&
event
)
{
if
(
event
.
EventType
==
EET_MOUSE_INPUT_EVENT
)
{
s32
x
=
event
.
MouseInput
.
X
;
s32
y
=
event
.
MouseInput
.
Y
;
event
.
MouseInput
.
X
=
optX
(
x
);
event
.
MouseInput
.
Y
=
optY
(
y
);
}
}
#ifdef _IRR_ANDROID_PLATFORM_
#ifdef _IRR_ANDROID_PLATFORM_
void
Game
::
stopBGM
()
{
void
Game
::
stopBGM
()
{
...
@@ -114,7 +123,9 @@ bool Game::Initialize(ANDROID_APP app, android::InitOptions *options) {
...
@@ -114,7 +123,9 @@ bool Game::Initialize(ANDROID_APP app, android::InitOptions *options) {
if
(
!
android
::
perfromTrick
(
app
))
{
if
(
!
android
::
perfromTrick
(
app
))
{
return
false
;
return
false
;
}
}
android
::
initJavaBridge
(
app
,
device
);
core
::
position2di
appPosition
=
android
::
initJavaBridge
(
app
,
device
);
setPositionFix
(
appPosition
);
device
->
setProcessReceiver
(
this
);
app
->
onInputEvent
=
android
::
handleInput
;
app
->
onInputEvent
=
android
::
handleInput
;
ILogger
*
logger
=
device
->
getLogger
();
ILogger
*
logger
=
device
->
getLogger
();
...
...
Classes/gframe/game.h
View file @
dc0f50aa
...
@@ -129,7 +129,7 @@ struct FadingUnit {
...
@@ -129,7 +129,7 @@ struct FadingUnit {
irr
::
core
::
vector2di
fadingDiff
;
irr
::
core
::
vector2di
fadingDiff
;
};
};
class
Game
{
class
Game
:
IProcessEventReceiver
{
public:
public:
#ifdef _IRR_ANDROID_PLATFORM_
#ifdef _IRR_ANDROID_PLATFORM_
...
@@ -662,6 +662,27 @@ public:
...
@@ -662,6 +662,27 @@ public:
Signal
externalSignal
;
Signal
externalSignal
;
static
void
onHandleAndroidCommand
(
ANDROID_APP
app
,
int32_t
cmd
);
static
void
onHandleAndroidCommand
(
ANDROID_APP
app
,
int32_t
cmd
);
#endif
#endif
void
setPositionFix
(
core
::
position2di
fix
){
InputFix
=
fix
;
}
float
optX
(
float
x
)
{
float
x2
=
x
-
InputFix
.
X
;
if
(
x2
<
0
)
{
return
0
;
}
return
x2
;
}
float
optY
(
float
y
)
{
float
y2
=
y
-
InputFix
.
Y
;
if
(
y2
<
0
)
{
return
0
;
}
return
y2
;
}
void
process
(
irr
::
SEvent
&
event
);
private:
core
::
position2di
InputFix
;
};
};
extern
Game
*
mainGame
;
extern
Game
*
mainGame
;
...
...
Classes/gframe/gframe.cpp
View file @
dc0f50aa
...
@@ -40,6 +40,7 @@ int GetListBoxIndex(IGUIListBox* listbox, const wchar_t * target){
...
@@ -40,6 +40,7 @@ int GetListBoxIndex(IGUIListBox* listbox, const wchar_t * target){
return
-
1
;
return
-
1
;
}
}
void
android_main
(
ANDROID_APP
app
)
{
void
android_main
(
ANDROID_APP
app
)
{
app
->
inputPollSource
.
process
=
android
::
process_input
;
#else
#else
int
main
(
int
argc
,
char
*
argv
[])
{
int
main
(
int
argc
,
char
*
argv
[])
{
#endif
#endif
...
...
libcore/android/android_tools.cpp
View file @
dc0f50aa
...
@@ -749,9 +749,9 @@ void toggleGlobalIME(ANDROID_APP app, bool pShow) {
...
@@ -749,9 +749,9 @@ void toggleGlobalIME(ANDROID_APP app, bool pShow) {
app
->
activity
->
vm
->
DetachCurrentThread
();
app
->
activity
->
vm
->
DetachCurrentThread
();
}
}
void
initJavaBridge
(
ANDROID_APP
app
,
void
*
handle
)
{
core
::
position2di
initJavaBridge
(
ANDROID_APP
app
,
void
*
handle
)
{
if
(
!
app
||
!
app
->
activity
||
!
app
->
activity
->
vm
)
if
(
!
app
||
!
app
->
activity
||
!
app
->
activity
->
vm
)
return
;
return
core
::
position2di
(
0
,
0
)
;
JNIEnv
*
jni
=
nullptr
;
JNIEnv
*
jni
=
nullptr
;
app
->
activity
->
vm
->
AttachCurrentThread
(
&
jni
,
NULL
);
app
->
activity
->
vm
->
AttachCurrentThread
(
&
jni
,
NULL
);
jobject
lNativeActivity
=
app
->
activity
->
clazz
;
jobject
lNativeActivity
=
app
->
activity
->
clazz
;
...
@@ -760,9 +760,18 @@ void initJavaBridge(ANDROID_APP app, void* handle) {
...
@@ -760,9 +760,18 @@ void initJavaBridge(ANDROID_APP app, void* handle) {
"setNativeHandle"
,
"(J)V"
);
"setNativeHandle"
,
"(J)V"
);
jlong
code
=
(
jlong
)
handle
;
jlong
code
=
(
jlong
)
handle
;
jni
->
CallVoidMethod
(
lNativeActivity
,
MethodSetHandle
,
code
);
jni
->
CallVoidMethod
(
lNativeActivity
,
MethodSetHandle
,
code
);
jmethodID
methodX
=
jni
->
GetMethodID
(
ClassNativeActivity
,
"getPositionX"
,
"()I"
);
jint
posX
=
jni
->
CallIntMethod
(
lNativeActivity
,
methodX
);
jmethodID
methodY
=
jni
->
GetMethodID
(
ClassNativeActivity
,
"getPositionY"
,
"()I"
);
jint
posY
=
jni
->
CallIntMethod
(
lNativeActivity
,
methodY
);
jni
->
DeleteLocalRef
(
ClassNativeActivity
);
jni
->
DeleteLocalRef
(
ClassNativeActivity
);
app
->
activity
->
vm
->
DetachCurrentThread
();
app
->
activity
->
vm
->
DetachCurrentThread
();
__android_log_print
(
ANDROID_LOG_INFO
,
"ygo"
,
"Android command initJavaBridge"
);
__android_log_print
(
ANDROID_LOG_INFO
,
"ygo"
,
"Android command initJavaBridge posX=%d, posY=%d"
,
posX
,
posY
);
return
core
::
position2di
((
int
)
posX
,
(
int
)
posY
);
}
}
InitOptions
*
getInitOptions
(
ANDROID_APP
app
)
{
InitOptions
*
getInitOptions
(
ANDROID_APP
app
)
{
...
@@ -860,6 +869,30 @@ void toggleOverlayView(ANDROID_APP app, bool pShow) {
...
@@ -860,6 +869,30 @@ void toggleOverlayView(ANDROID_APP app, bool pShow) {
app
->
activity
->
vm
->
DetachCurrentThread
();
app
->
activity
->
vm
->
DetachCurrentThread
();
}
}
void
process_input
(
ANDROID_APP
app
,
struct
android_poll_source
*
source
)
{
AInputEvent
*
event
=
NULL
;
if
(
AInputQueue_getEvent
(
app
->
inputQueue
,
&
event
)
>=
0
)
{
int
type
=
AInputEvent_getType
(
event
);
bool
skip_predispatch
=
AInputEvent_getType
(
event
)
==
AINPUT_EVENT_TYPE_KEY
&&
AKeyEvent_getKeyCode
(
event
)
==
AKEYCODE_BACK
;
// skip predispatch (all it does is send to the IME)
if
(
!
skip_predispatch
&&
AInputQueue_preDispatchEvent
(
app
->
inputQueue
,
event
))
{
return
;
}
int32_t
handled
=
0
;
if
(
app
->
onInputEvent
!=
NULL
)
handled
=
app
->
onInputEvent
(
app
,
event
);
AInputQueue_finishEvent
(
app
->
inputQueue
,
event
,
handled
);
}
else
{
// LOGE("Failure reading next input event: %s\n", strerror(errno));
}
}
void
onGameExit
(
ANDROID_APP
app
){
void
onGameExit
(
ANDROID_APP
app
){
if
(
!
app
||
!
app
->
activity
||
!
app
->
activity
->
vm
)
if
(
!
app
||
!
app
->
activity
||
!
app
->
activity
->
vm
)
return
;
return
;
...
...
libcore/android/android_tools.h
View file @
dc0f50aa
...
@@ -126,7 +126,7 @@ extern void toggleGlobalIME(ANDROID_APP app, bool pShow);
...
@@ -126,7 +126,7 @@ extern void toggleGlobalIME(ANDROID_APP app, bool pShow);
extern
void
toggleIME
(
ANDROID_APP
app
,
bool
pShow
,
const
char
*
hint
);
extern
void
toggleIME
(
ANDROID_APP
app
,
bool
pShow
,
const
char
*
hint
);
//Init Java Irrlicht world.
//Init Java Irrlicht world.
extern
void
initJavaBridge
(
ANDROID_APP
app
,
void
*
handle
);
extern
core
::
position2di
initJavaBridge
(
ANDROID_APP
app
,
void
*
handle
);
//Cause a haptic feedback.
//Cause a haptic feedback.
extern
void
perfromHapticFeedback
(
ANDROID_APP
app
);
extern
void
perfromHapticFeedback
(
ANDROID_APP
app
);
...
@@ -186,6 +186,10 @@ extern bool getFontAntiAlias(ANDROID_APP app);
...
@@ -186,6 +186,10 @@ extern bool getFontAntiAlias(ANDROID_APP app);
extern
void
showAndroidComboBoxCompat
(
ANDROID_APP
app
,
bool
pShow
,
extern
void
showAndroidComboBoxCompat
(
ANDROID_APP
app
,
bool
pShow
,
char
**
pContents
,
int
count
,
int
mode
=
0
);
char
**
pContents
,
int
count
,
int
mode
=
0
);
/* android event handlers*/
extern
void
process_input
(
ANDROID_APP
app
,
struct
android_poll_source
*
source
);
extern
s32
handleInput
(
ANDROID_APP
app
,
AInputEvent
*
androidEvent
);
extern
s32
handleInput
(
ANDROID_APP
app
,
AInputEvent
*
androidEvent
);
extern
bool
android_deck_delete
(
const
char
*
deck_name
);
extern
bool
android_deck_delete
(
const
char
*
deck_name
);
...
...
libcore/jni/Application.mk
View file @
dc0f50aa
APP_ABI
:=
arm
64-v8a
#armeabi-v7
a x86
APP_ABI
:=
arm
eabi-v7a arm64-v8
a x86
APP_PLATFORM
:=
android-21
APP_PLATFORM
:=
android-21
#APP_MODULES := YGOMobile
#APP_MODULES := YGOMobile
#NDK_TOOLCHAIN_VERSION=4.8
#NDK_TOOLCHAIN_VERSION=4.8
APP_ALLOW_MISSING_DEPS
=
true
#
APP_ALLOW_MISSING_DEPS=true
#APP_STL := gnustl_static
#APP_STL := gnustl_static
APP_STL
:=
c++_static
APP_STL
:=
c++_static
APP_CPPFLAGS
:=
-Wno-error
=
format-security
-std
=
gnu++14
-fpermissive
-D__cplusplus
=
201402L
APP_CPPFLAGS
:=
-Wno-error
=
format-security
-std
=
gnu++14
-fpermissive
-D__cplusplus
=
201402L
...
...
libcore/jni/cn_garymb_ygomobile_core_IrrlichtBridge.cpp
View file @
dc0f50aa
...
@@ -294,6 +294,14 @@ static void* join_game_thread(void* param) {
...
@@ -294,6 +294,14 @@ static void* join_game_thread(void* param) {
}
}
}
}
JNIEXPORT
void
JNICALL
Java_cn_garymb_ygomobile_core_IrrlichtBridge_nativeSetInputFix
(
JNIEnv
*
env
,
jclass
clazz
,
jlong
handle
,
jint
x
,
jint
y
)
{
if
(
ygo
::
mainGame
)
{
ALOGD
(
"setInputFix posX=%d, posY=%d"
,
x
,
y
);
ygo
::
mainGame
->
setPositionFix
(
core
::
position2di
(
x
,
y
));
}
}
static
void
*
cancel_chain_thread
(
void
*
param
)
{
static
void
*
cancel_chain_thread
(
void
*
param
)
{
IrrlichtDevice
*
device
=
(
IrrlichtDevice
*
)
param
;
IrrlichtDevice
*
device
=
(
IrrlichtDevice
*
)
param
;
irr
::
os
::
Printer
::
log
(
"before send cancel chain"
);
irr
::
os
::
Printer
::
log
(
"before send cancel chain"
);
...
...
libcore/src/main/java/cn/garymb/ygomobile/YGOMobileActivity.java
View file @
dc0f50aa
...
@@ -18,8 +18,6 @@ import android.view.HapticFeedbackConstants;
...
@@ -18,8 +18,6 @@ import android.view.HapticFeedbackConstants;
import
android.view.KeyEvent
;
import
android.view.KeyEvent
;
import
android.view.MotionEvent
;
import
android.view.MotionEvent
;
import
android.view.View
;
import
android.view.View
;
import
android.widget.FrameLayout
;
import
android.widget.ImageView
;
import
android.widget.PopupWindow
;
import
android.widget.PopupWindow
;
import
android.widget.TextView
;
import
android.widget.TextView
;
import
android.widget.Toast
;
import
android.widget.Toast
;
...
@@ -51,7 +49,7 @@ public class YGOMobileActivity extends GameActivity implements
...
@@ -51,7 +49,7 @@ public class YGOMobileActivity extends GameActivity implements
TextView
.
OnEditorActionListener
,
TextView
.
OnEditorActionListener
,
OverlayOvalView
.
OnDuelOptionsSelectListener
{
OverlayOvalView
.
OnDuelOptionsSelectListener
{
private
static
final
String
TAG
=
YGOMobileActivity
.
class
.
getSimpleName
();
private
static
final
String
TAG
=
YGOMobileActivity
.
class
.
getSimpleName
();
private
static
final
boolean
DEBUG
=
tru
e
;
private
static
final
boolean
DEBUG
=
fals
e
;
private
static
final
int
CHAIN_CONTROL_PANEL_X_POSITION_LEFT_EDGE
=
205
;
private
static
final
int
CHAIN_CONTROL_PANEL_X_POSITION_LEFT_EDGE
=
205
;
private
static
final
int
CHAIN_CONTROL_PANEL_Y_REVERT_POSITION
=
100
;
private
static
final
int
CHAIN_CONTROL_PANEL_Y_REVERT_POSITION
=
100
;
private
static
final
int
MAX_REFRESH
=
30
*
1000
;
private
static
final
int
MAX_REFRESH
=
30
*
1000
;
...
@@ -70,13 +68,14 @@ public class YGOMobileActivity extends GameActivity implements
...
@@ -70,13 +68,14 @@ public class YGOMobileActivity extends GameActivity implements
private
NetworkController
mNetController
;
private
NetworkController
mNetController
;
private
volatile
boolean
mOverlayShowRequest
=
false
;
private
volatile
boolean
mOverlayShowRequest
=
false
;
private
volatile
int
mCompatGUIMode
;
private
volatile
int
mCompatGUIMode
;
// private static int sChainControlXPostion = -1;
// private static int sChainControlXPostion = -1;
// private static int sChainControlYPostion = -1;
// private static int sChainControlYPostion = -1;
private
GameApplication
mApp
;
private
GameApplication
mApp
;
private
FullScreenUtils
mFullScreenUtils
;
private
FullScreenUtils
mFullScreenUtils
;
private
volatile
int
mPositionX
,
mPositionY
;
private
String
[]
mArgV
;
private
String
[]
mArgV
;
private
boolean
onGameExiting
;
private
boolean
onGameExiting
;
private
static
final
boolean
blockKey
=
false
;
private
GameApplication
app
()
{
private
GameApplication
app
()
{
...
@@ -96,6 +95,8 @@ public class YGOMobileActivity extends GameActivity implements
...
@@ -96,6 +95,8 @@ public class YGOMobileActivity extends GameActivity implements
@Override
@Override
protected
void
initBeforeOnCreate
()
{
protected
void
initBeforeOnCreate
()
{
mPositionX
=
0
;
mPositionY
=
0
;
mFullScreenUtils
=
new
FullScreenUtils
(
this
,
app
().
isImmerSiveMode
());
mFullScreenUtils
=
new
FullScreenUtils
(
this
,
app
().
isImmerSiveMode
());
mFullScreenUtils
.
fullscreen
();
mFullScreenUtils
.
fullscreen
();
mFullScreenUtils
.
onCreate
();
mFullScreenUtils
.
onCreate
();
...
@@ -155,17 +156,6 @@ public class YGOMobileActivity extends GameActivity implements
...
@@ -155,17 +156,6 @@ public class YGOMobileActivity extends GameActivity implements
}
}
}
}
private
void
initPostion
()
{
// final Resources res = getResources();
// sChainControlXPostion = (int) (CHAIN_CONTROL_PANEL_X_POSITION_LEFT_EDGE * app()
// .getXScale());
// sChainControlYPostion = (int) (app().getSmallerSize()
// - CHAIN_CONTROL_PANEL_Y_REVERT_POSITION
// * app().getYScale() - (res
// .getDimensionPixelSize(R.dimen.chain_control_button_height) * 2 + res
// .getDimensionPixelSize(R.dimen.chain_control_margin)));
}
@Override
@Override
protected
void
onNewIntent
(
Intent
intent
)
{
protected
void
onNewIntent
(
Intent
intent
)
{
super
.
onNewIntent
(
intent
);
super
.
onNewIntent
(
intent
);
...
@@ -197,6 +187,9 @@ public class YGOMobileActivity extends GameActivity implements
...
@@ -197,6 +187,9 @@ public class YGOMobileActivity extends GameActivity implements
if
(
app
().
isImmerSiveMode
())
{
if
(
app
().
isImmerSiveMode
())
{
mFullScreenUtils
.
fullscreen
();
mFullScreenUtils
.
fullscreen
();
app
().
attachGame
(
this
);
app
().
attachGame
(
this
);
if
(
USE_SURFACE
)
{
changeGameSize
();
}
}
}
}
}
...
@@ -216,10 +209,25 @@ public class YGOMobileActivity extends GameActivity implements
...
@@ -216,10 +209,25 @@ public class YGOMobileActivity extends GameActivity implements
return
new
Size
(
w
,
h
);
return
new
Size
(
w
,
h
);
}
}
@Override
public
int
getPositionX
()
{
synchronized
(
this
)
{
return
mPositionX
;
}
}
@Override
public
int
getPositionY
()
{
synchronized
(
this
)
{
return
mPositionY
;
}
}
@Override
@Override
public
void
setContentView
(
View
view
)
{
public
void
setContentView
(
View
view
)
{
super
.
setContentView
(
view
);
super
.
setContentView
(
view
);
app
().
attachGame
(
this
);
app
().
attachGame
(
this
);
changeGameSize
();
//可以通过mLayout.addView添加view,增加功能
//可以通过mLayout.addView添加view,增加功能
//test code
//test code
// int size = (int) (getResources().getDisplayMetrics().density * 100);
// int size = (int) (getResources().getDisplayMetrics().density * 100);
...
@@ -236,6 +244,29 @@ public class YGOMobileActivity extends GameActivity implements
...
@@ -236,6 +244,29 @@ public class YGOMobileActivity extends GameActivity implements
// mLayout.addView(imageView, lp);
// mLayout.addView(imageView, lp);
}
}
private
void
changeGameSize
()
{
if
(
USE_MY_INPUT
)
{
return
;
}
//游戏大小
Size
size
=
getGameWindowSize
();
int
w
=
(
int
)
app
().
getScreenHeight
();
int
h
=
(
int
)
app
().
getScreenWidth
();
int
spX
=
(
int
)
((
w
-
size
.
getWidth
())
/
2.0f
);
int
spY
=
(
int
)
((
h
-
size
.
getHeight
())
/
2.0f
);
boolean
update
=
false
;
synchronized
(
this
)
{
if
(
spX
!=
mPositionX
||
spY
!=
mPositionY
)
{
mPositionX
=
spX
;
mPositionY
=
spY
;
update
=
true
;
}
}
if
(
update
)
{
IrrlichtBridge
.
setInputFix
(
mPositionX
,
mPositionY
);
}
}
private
void
initExtraView
()
{
private
void
initExtraView
()
{
mContentView
=
getWindow
().
getDecorView
().
findViewById
(
android
.
R
.
id
.
content
);
mContentView
=
getWindow
().
getDecorView
().
findViewById
(
android
.
R
.
id
.
content
);
mGlobalComboBox
=
new
ComboBoxCompat
(
this
);
mGlobalComboBox
=
new
ComboBoxCompat
(
this
);
...
@@ -439,6 +470,30 @@ public class YGOMobileActivity extends GameActivity implements
...
@@ -439,6 +470,30 @@ public class YGOMobileActivity extends GameActivity implements
private
long
lasttime
;
private
long
lasttime
;
@Override
public
boolean
onKeyDown
(
int
keyCode
,
KeyEvent
event
)
{
if
(
blockKey
&&
USE_MY_INPUT
)
{
if
(
keyCode
!=
KeyEvent
.
KEYCODE_VOLUME_DOWN
&&
keyCode
!=
KeyEvent
.
KEYCODE_VOLUME_UP
)
{
sendInputEvent
(
event
,
false
);
return
true
;
}
}
return
super
.
onKeyDown
(
keyCode
,
event
);
}
@Override
public
boolean
onKeyUp
(
int
keyCode
,
KeyEvent
event
)
{
if
(
blockKey
&&
USE_MY_INPUT
)
{
if
(
keyCode
!=
KeyEvent
.
KEYCODE_VOLUME_DOWN
&&
keyCode
!=
KeyEvent
.
KEYCODE_VOLUME_UP
)
{
sendInputEvent
(
event
,
false
);
return
true
;
}
}
return
super
.
onKeyUp
(
keyCode
,
event
);
}
@Override
@Override
public
void
onBackPressed
()
{
public
void
onBackPressed
()
{
if
(
mGlobalComboBox
!=
null
&&
mGlobalComboBox
.
isShowing
())
{
if
(
mGlobalComboBox
!=
null
&&
mGlobalComboBox
.
isShowing
())
{
...
@@ -451,10 +506,10 @@ public class YGOMobileActivity extends GameActivity implements
...
@@ -451,10 +506,10 @@ public class YGOMobileActivity extends GameActivity implements
}
}
if
(
lasttime
==
0
||
(
System
.
currentTimeMillis
()
-
lasttime
)
>
1000
)
{
if
(
lasttime
==
0
||
(
System
.
currentTimeMillis
()
-
lasttime
)
>
1000
)
{
lasttime
=
System
.
currentTimeMillis
();
lasttime
=
System
.
currentTimeMillis
();
Toast
.
makeText
(
this
,
R
.
string
.
tip_exit_game
,
Toast
.
LENGTH_SHORT
).
show
();
return
;
return
;
}
}
onGameExit
();
// super.onWindowFocusChanged(false);
// onGameExit();
}
}
@Override
@Override
...
...
libcore/src/main/java/cn/garymb/ygomobile/controller/InputQueueCompat.java
View file @
dc0f50aa
...
@@ -107,6 +107,12 @@ public class InputQueueCompat implements InvocationHandler {
...
@@ -107,6 +107,12 @@ public class InputQueueCompat implements InvocationHandler {
return
inputQueue
;
return
inputQueue
;
}
}
/**
*
* @param e
* @param token
* @param predispatch 跳过输入法
*/
public
void
sendInputEvent
(
InputEvent
e
,
Object
token
,
boolean
predispatch
)
{
public
void
sendInputEvent
(
InputEvent
e
,
Object
token
,
boolean
predispatch
)
{
if
(
sendInputEvent_method
==
null
)
{
if
(
sendInputEvent_method
==
null
)
{
...
...
libcore/src/main/java/cn/garymb/ygomobile/core/GameActivity.java
View file @
dc0f50aa
...
@@ -6,6 +6,7 @@ import android.os.Bundle;
...
@@ -6,6 +6,7 @@ import android.os.Bundle;
import
android.util.Log
;
import
android.util.Log
;
import
android.util.Size
;
import
android.util.Size
;
import
android.view.Gravity
;
import
android.view.Gravity
;
import
android.view.InputEvent
;
import
android.view.MotionEvent
;
import
android.view.MotionEvent
;
import
android.view.SurfaceHolder
;
import
android.view.SurfaceHolder
;
import
android.view.SurfaceView
;
import
android.view.SurfaceView
;
...
@@ -19,10 +20,10 @@ public abstract class GameActivity extends NativeActivity {
...
@@ -19,10 +20,10 @@ public abstract class GameActivity extends NativeActivity {
protected
SurfaceView
mSurfaceView
;
protected
SurfaceView
mSurfaceView
;
private
boolean
replaced
=
false
;
private
boolean
replaced
=
false
;
//自定义surface,方便控制窗口大小
//自定义surface,方便控制窗口大小
pr
ivate
static
final
boolean
USE_SURFACE
=
true
;
pr
otected
static
final
boolean
USE_SURFACE
=
true
;
//
精准触摸事件
//
接管系统触摸事件,再次分发给游戏
pr
ivate
static
final
boolean
USE_MY_INPUT
=
true
;
pr
otected
static
final
boolean
USE_MY_INPUT
=
true
;
pr
otected
InputQueueCompat
inputQueueCompat
;
pr
ivate
InputQueueCompat
inputQueueCompat
;
@Override
@Override
protected
final
void
onCreate
(
Bundle
savedInstanceState
)
{
protected
final
void
onCreate
(
Bundle
savedInstanceState
)
{
...
@@ -91,12 +92,15 @@ public abstract class GameActivity extends NativeActivity {
...
@@ -91,12 +92,15 @@ public abstract class GameActivity extends NativeActivity {
}
}
protected
void
onSurfaceTouch
(
View
v
,
MotionEvent
event
){
protected
void
onSurfaceTouch
(
View
v
,
MotionEvent
event
){
sendInputEvent
(
event
,
false
);
}
protected
void
sendInputEvent
(
InputEvent
event
,
boolean
predispatch
){
if
(
inputQueueCompat
!=
null
)
{
if
(
inputQueueCompat
!=
null
)
{
inputQueueCompat
.
sendInputEvent
(
event
,
v
,
true
);
inputQueueCompat
.
sendInputEvent
(
event
,
this
,
predispatch
);
}
}
}
}
@Override
@Override
public
void
surfaceCreated
(
SurfaceHolder
holder
)
{
public
void
surfaceCreated
(
SurfaceHolder
holder
)
{
if
(
USE_SURFACE
)
{
if
(
USE_SURFACE
)
{
...
@@ -136,28 +140,6 @@ public abstract class GameActivity extends NativeActivity {
...
@@ -136,28 +140,6 @@ public abstract class GameActivity extends NativeActivity {
}
}
super
.
surfaceRedrawNeeded
(
holder
);
super
.
surfaceRedrawNeeded
(
holder
);
}
}
//
// @Override
// public boolean onKeyDown(int keyCode, KeyEvent event) {
// if(inputQueueCompat != null) {
// if (keyCode == KeyEvent.KEYCODE_BACK) {
// inputQueueCompat.sendInputEvent(event, this, true);
// return true;
// }
// }
// return super.onKeyDown(keyCode, event);
// }
//
// @Override
// public boolean onKeyUp(int keyCode, KeyEvent event) {
// if(inputQueueCompat != null) {
// if (keyCode == KeyEvent.KEYCODE_BACK) {
// inputQueueCompat.sendInputEvent(event, this, true);
// return true;
// }
// }
// return super.onKeyUp(keyCode, event);
// }
protected
abstract
Size
getGameWindowSize
();
protected
abstract
Size
getGameWindowSize
();
protected
abstract
void
initBeforeOnCreate
();
protected
abstract
void
initBeforeOnCreate
();
...
...
libcore/src/main/java/cn/garymb/ygomobile/core/IrrlichtBridge.java
View file @
dc0f50aa
...
@@ -82,6 +82,8 @@ public final class IrrlichtBridge {
...
@@ -82,6 +82,8 @@ public final class IrrlichtBridge {
private
static
native
void
nativeJoinGame
(
long
handle
,
ByteBuffer
buffer
,
int
length
);
private
static
native
void
nativeJoinGame
(
long
handle
,
ByteBuffer
buffer
,
int
length
);
private
static
native
void
nativeSetInputFix
(
long
handle
,
int
x
,
int
y
);
private
static
final
boolean
DEBUG
=
false
;
private
static
final
boolean
DEBUG
=
false
;
public
static
void
setArgs
(
Intent
intent
,
String
[]
args
)
{
public
static
void
setArgs
(
Intent
intent
,
String
[]
args
)
{
...
@@ -153,6 +155,10 @@ public final class IrrlichtBridge {
...
@@ -153,6 +155,10 @@ public final class IrrlichtBridge {
}
}
}
}
public
static
void
setInputFix
(
int
x
,
int
y
)
{
nativeSetInputFix
(
sNativeHandle
,
x
,
y
);
}
public
static
void
cancelChain
()
{
public
static
void
cancelChain
()
{
nativeCancelChain
(
sNativeHandle
);
nativeCancelChain
(
sNativeHandle
);
}
}
...
@@ -238,6 +244,10 @@ public final class IrrlichtBridge {
...
@@ -238,6 +244,10 @@ public final class IrrlichtBridge {
void
setNativeHandle
(
long
nativeHandle
);
void
setNativeHandle
(
long
nativeHandle
);
int
getPositionX
();
int
getPositionY
();
void
onGameExit
();
void
onGameExit
();
}
}
}
}
mobile/build.gradle
View file @
dc0f50aa
...
@@ -14,7 +14,7 @@ android {
...
@@ -14,7 +14,7 @@ android {
flavorDimensions
"versionCode"
flavorDimensions
"versionCode"
vectorDrawables
.
useSupportLibrary
=
true
vectorDrawables
.
useSupportLibrary
=
true
ndk
{
ndk
{
abiFilters
"arm
64-v8a"
,
"armeabi-v7
a"
,
"x86"
abiFilters
"arm
eabi-v7a"
,
"arm64-v8
a"
,
"x86"
}
}
}
}
compileOptions
{
compileOptions
{
...
@@ -40,6 +40,7 @@ android {
...
@@ -40,6 +40,7 @@ android {
buildTypes
{
buildTypes
{
debug
{
debug
{
debuggable
false
debuggable
false
applicationIdSuffix
".debug"
buildConfigField
'boolean'
,
'DEBUG_MODE'
,
'true'
buildConfigField
'boolean'
,
'DEBUG_MODE'
,
'true'
}
}
release
{
release
{
...
@@ -120,7 +121,7 @@ dependencies {
...
@@ -120,7 +121,7 @@ dependencies {
//Tencent bugly
//Tencent bugly
implementation
'com.tencent.bugly:crashreport_upgrade:latest.release'
implementation
'com.tencent.bugly:crashreport_upgrade:latest.release'
implementation
'com.tencent.bugly:nativecrashreport:latest.release'
implementation
'com.tencent.bugly:nativecrashreport:latest.release'
api
'com.tencent.tbs
.tbssdk:sdk:43939
'
api
'com.tencent.tbs
:tbssdk:44085
'
//http请求库
//http请求库
implementation
'com.squareup.okhttp3:okhttp:3.12.0'
implementation
'com.squareup.okhttp3:okhttp:3.12.0'
implementation
'com.bm.photoview:library:1.4.1'
implementation
'com.bm.photoview:library:1.4.1'
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment