Skip to content

Commit f7ca946

Browse files
committed
MCinaBox Release v0.1.0
1 parent f97e2b6 commit f7ca946

File tree

221 files changed

+2076
-2807
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

221 files changed

+2076
-2807
lines changed
File renamed without changes.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ android {
1010
buildToolsVersion '28.0.3'
1111
defaultConfig {
1212
minSdkVersion 21
13-
targetSdkVersion 28
13+
targetSdkVersion 21
1414
versionCode 1
1515
versionName "1.0"
1616
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

boat3/src/androidTest/java/cosine/boat/ExampleInstrumentedTest.java renamed to boat/src/androidTest/java/cosine/boat/ExampleInstrumentedTest.java

File renamed without changes.

boat/src/main/AndroidManifest.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2+
package="cosine.boat">
3+
</manifest>

boat2/src/main/java/cosine/boat2/BoatClientActivity.java renamed to boat/src/main/java/cosine/boat/BoatClientActivity.java

Lines changed: 255 additions & 56 deletions
Large diffs are not rendered by default.

boat2/src/main/java/cosine/boat2/BoatInputEventSender.java renamed to boat/src/main/java/cosine/boat/BoatInputEventSender.java

Lines changed: 64 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package cosine.boat2;
1+
package cosine.boat;
22
import java.util.Deque;
33
import java.util.ArrayDeque;
44
import java.util.concurrent.BlockingDeque;
@@ -11,31 +11,31 @@
1111
import java.io.OutputStream;
1212

1313
public class BoatInputEventSender{
14-
14+
1515
public static final int KeyPress = 2;
1616
public static final int KeyRelease = 3;
1717
public static final int ButtonPress = 4;
1818
public static final int ButtonRelease= 5;
1919
public static final int MotionNotify= 6;
20-
20+
2121
private static final int MESSAGE_SIZE = 10;
22-
private static final int CACHE_SIZE = 8 * MESSAGE_SIZE;
23-
24-
25-
private Deque<byte[]> cachedObjs = new ArrayDeque<byte[]>(CACHE_SIZE);
26-
private BlockingDeque<byte[]> deque = new LinkedBlockingDeque<byte[]>();
27-
28-
public ServerSocket serverSock;
29-
public Socket sock;
30-
22+
private static final int CACHE_SIZE = 8 * MESSAGE_SIZE;
23+
24+
25+
private Deque<byte[]> cachedObjs = new ArrayDeque<byte[]>(CACHE_SIZE);
26+
private BlockingDeque<byte[]> deque = new LinkedBlockingDeque<byte[]>();
27+
28+
public ServerSocket serverSock;
29+
public Socket sock;
30+
3131
private OutputStream os;
3232
private InputStream is;
3333
public int port;
3434
public boolean receiving;
3535
public boolean running;
36-
36+
3737
private BoatClientActivity activity;
38-
public void startServer(BoatClientActivity a){
38+
public void startServer(BoatClientActivity a){
3939
activity = a;
4040
running = true;
4141
try{
@@ -45,12 +45,12 @@ public void startServer(BoatClientActivity a){
4545
new Thread(new Receiver()).start();
4646
port = this.serverSock.getLocalPort();
4747
System.out.println("BoatInputEventSender is created!The port is:" + port);
48-
48+
4949
}
5050
catch (IOException e){
5151
e.printStackTrace();
5252
}
53-
}
53+
}
5454

5555
private class Receiver implements Runnable
5656
{
@@ -60,30 +60,30 @@ public void run()
6060
{
6161
// TODO: Implement this method
6262
try {
63-
63+
6464
while(!receiving){
65-
65+
6666
}
6767
byte[] msg = new byte[1];
6868

6969
while (running) {
70-
70+
7171
is.read(msg, 0, 1);
72-
72+
7373
activity.changeGrab(msg[0]);
74-
74+
7575
}
76-
76+
7777
} catch (Exception e) {
7878
e.printStackTrace();
7979
}
80-
81-
80+
81+
8282
}
83-
84-
83+
84+
8585
}
86-
86+
8787
private class Sender implements Runnable
8888
{
8989

@@ -108,54 +108,64 @@ public void run()
108108
}
109109
System.out.println("Exiting input event sender");
110110
}
111-
112-
111+
112+
113113
}
114-
115114

116-
private byte[] obtain() {
117-
byte[] msg = this.cachedObjs.poll();
118-
if (msg == null) {
119-
return new byte[MESSAGE_SIZE];
120-
}
121-
return msg;
122-
}
123115

124-
private void recycle(byte[] msg) {
125-
if (this.cachedObjs.size() < CACHE_SIZE) {
126-
this.cachedObjs.add(msg);
127-
}
128-
}
116+
private byte[] obtain() {
117+
byte[] msg = this.cachedObjs.poll();
118+
if (msg == null) {
119+
return new byte[MESSAGE_SIZE];
120+
}
121+
return msg;
122+
}
123+
124+
private void recycle(byte[] msg) {
125+
if (this.cachedObjs.size() < CACHE_SIZE) {
126+
this.cachedObjs.add(msg);
127+
}
128+
}
129+
129130

130131

131-
132132
public static void writeInt(byte[] src, int offset, int i) {
133133
src[0 + offset] = (byte)( i >> (0 * 8));
134134
src[1 + offset] = (byte)( i >> (1 * 8));
135135
src[2 + offset] = (byte)( i >> (2 * 8));
136136
src[3 + offset] = (byte)( i >> (3 * 8));
137137
}
138-
139-
138+
139+
140140
public void setMouseButton(byte button, boolean press) {
141-
byte[] msg = obtain();
141+
byte[] msg = obtain();
142142
msg[0] = (byte) (press ? ButtonPress : ButtonRelease);
143-
msg[1] = button;
144-
this.deque.add(msg);
145-
}
143+
msg[1] = button;
144+
this.deque.add(msg);
145+
}
146146
public void setPointer(int x, int y) {
147-
byte[] msg = obtain();
147+
byte[] msg = obtain();
148148
msg[0] = (byte) (MotionNotify);
149-
writeInt(msg, 2, x);
149+
writeInt(msg, 2, x);
150150
writeInt(msg, 6, y);
151-
this.deque.add(msg);
152-
}
151+
this.deque.add(msg);
152+
}
153153
public void setKey(int keyCode, boolean press , int keyChar){
154+
//处理鼠标按钮
155+
if(keyCode == 1001){
156+
setMouseButton((byte)1,press);
157+
return;
158+
}else if(keyCode == 1002){
159+
setMouseButton((byte)2,press);
160+
return;
161+
}
162+
163+
154164
byte[] msg = obtain();
155165
msg[0] = (byte) (press ? KeyPress : KeyRelease);
156166
writeInt(msg, 2, keyCode);
157167
writeInt(msg, 6, keyChar);
158-
this.deque.add(msg);
168+
this.deque.add(msg);
159169
}
160170

161171
}

boat2/src/main/java/cosine/boat2/LauncherActivity.java renamed to boat/src/main/java/cosine/boat/LauncherActivity.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
package cosine.boat2;
1+
package cosine.boat;
22

33
import android.app.Activity;
44
import android.os.Bundle;
55
import com.aof.sharedmodule.Model.ArgsModel;
6-
import cosine.boat2.logcat.Logcat;
7-
import cosine.boat2.logcat.LogcatService;
6+
import cosine.boat.logcat.Logcat;
7+
import cosine.boat.logcat.LogcatService;
88
import ru.ivanarh.jndcrash.NDCrashError;
99
import ru.ivanarh.jndcrash.NDCrash;
1010
import ru.ivanarh.jndcrash.NDCrashService;
@@ -22,8 +22,11 @@ public void onCreate(Bundle savedInstance) {
2222
argsModel = (ArgsModel) getIntent().getSerializableExtra("LauncherConfig");
2323

2424
//初始化日志
25+
//【release版暂时不开启】
26+
/*
2527
final String logPath = BOAT_HOME + "/log.txt";
2628
Logcat.initializeOutOfProcess(this, logPath, LogcatService.class);
29+
*/
2730

2831
final String reportPath = BOAT_HOME + "/crash.txt";
2932
System.out.println("Crash report: " + reportPath);
@@ -43,6 +46,7 @@ public void onCreate(Bundle savedInstance) {
4346
Intent intent = new Intent(this, BoatClientActivity.class);
4447
intent.putExtra("LauncherConfig", argsModel);
4548
this.startActivity(intent);
49+
this.finish();
4650

4751
}
4852

0 commit comments

Comments
 (0)