mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-02-21 22:52:52 +00:00
Android satellites info
This commit is contained in:
parent
c824fabd53
commit
2b57d2365f
@ -120,7 +120,7 @@ void GPS::init() {
|
||||
gpsData.bearing = 35.0f;
|
||||
|
||||
satData.satellites_in_view = 6;
|
||||
for (int i = 0; i < satData.satellites_in_view; i++) {
|
||||
for (unsigned char i = 0; i < satData.satellites_in_view; i++) {
|
||||
satData.satInfo[i].id = i + 1; // 1 .. 32
|
||||
satData.satInfo[i].elevation = i * 10;
|
||||
satData.satInfo[i].azimuth = i * 50;
|
||||
@ -131,7 +131,7 @@ void GPS::init() {
|
||||
|
||||
void GPS::setGpsTime(time_t *time) {
|
||||
struct tm *gpsTime;
|
||||
gpsTime = localtime(time);
|
||||
gpsTime = gmtime(time);
|
||||
|
||||
gpsData.year = (short)(gpsTime->tm_year + 1900);
|
||||
gpsData.month = (short)(gpsTime->tm_mon + 1);
|
||||
@ -151,6 +151,15 @@ void GPS::setGpsData(float latitude, float longitude, float altitude, float spee
|
||||
gpsData.bearing = bearing;
|
||||
}
|
||||
|
||||
void GPS::setSatInfo(short index, unsigned char id, unsigned char elevation, short azimuth, unsigned char snr, unsigned char good) {
|
||||
satData.satInfo[index].id = id;
|
||||
satData.satInfo[index].elevation = elevation;
|
||||
satData.satInfo[index].azimuth = azimuth;
|
||||
satData.satInfo[index].snr = snr;
|
||||
satData.satInfo[index].good = good;
|
||||
satData.satellites_in_view = index + 1;
|
||||
}
|
||||
|
||||
GpsData* GPS::getGpsData() {
|
||||
return &gpsData;
|
||||
}
|
||||
|
@ -17,6 +17,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Core/HLE/FunctionWrappers.h"
|
||||
|
||||
void Register_sceUsbGps();
|
||||
|
||||
void __UsbGpsInit();
|
||||
@ -64,6 +66,7 @@ namespace GPS {
|
||||
void init();
|
||||
void setGpsTime(time_t *time);
|
||||
void setGpsData(float latitude, float longitude, float altitude, float speed, float bearing, long long time);
|
||||
void setSatInfo(short index, unsigned char id, unsigned char elevation, short azimuth, unsigned char snr, unsigned char good);
|
||||
GpsData *getGpsData();
|
||||
SatData *getSatData();
|
||||
}
|
||||
|
@ -1357,11 +1357,3 @@ void NativeShutdown() {
|
||||
// Previously we did exit() here on Android but that makes it hard to do things like restart on backend change.
|
||||
// I think we handle most globals correctly or correct-enough now.
|
||||
}
|
||||
|
||||
void SetGpsData(float latitude, float longitude, float altitude, float speed, float bearing, long long time) {
|
||||
GPS::setGpsData(latitude, longitude, altitude, speed, bearing, time);
|
||||
}
|
||||
|
||||
void PushCameraImage(long long length, unsigned char* image) {
|
||||
Camera::pushCameraImage(length, image);
|
||||
}
|
||||
|
@ -46,6 +46,8 @@
|
||||
#include "Core/ConfigValues.h"
|
||||
#include "Core/Loaders.h"
|
||||
#include "Core/System.h"
|
||||
#include "Core/HLE/sceUsbCam.h"
|
||||
#include "Core/HLE/sceUsbGps.h"
|
||||
#include "Common/CPUDetect.h"
|
||||
#include "Common/Log.h"
|
||||
#include "UI/GameInfoCache.h"
|
||||
@ -951,7 +953,12 @@ extern "C" jint Java_org_ppsspp_ppsspp_NativeApp_getSelectedCamera(JNIEnv *, jcl
|
||||
|
||||
extern "C" void JNICALL Java_org_ppsspp_ppsspp_NativeApp_setGpsDataAndroid(JNIEnv *, jclass,
|
||||
jfloat latitude, jfloat longitude, jfloat altitude, jfloat speed, jfloat bearing, jlong time) {
|
||||
SetGpsData(latitude, longitude, altitude, speed, bearing, time);
|
||||
GPS::setGpsData(latitude, longitude, altitude, speed, bearing, time);
|
||||
}
|
||||
|
||||
extern "C" void JNICALL Java_org_ppsspp_ppsspp_NativeApp_setSatInfoAndroid(JNIEnv *, jclass,
|
||||
jshort index, jshort id, jshort elevation, jshort azimuth, jshort snr, jshort good) {
|
||||
GPS::setSatInfo(index, id, elevation, azimuth, snr, good);
|
||||
}
|
||||
|
||||
extern "C" void JNICALL Java_org_ppsspp_ppsspp_NativeApp_pushCameraImageAndroid(JNIEnv *env, jclass,
|
||||
@ -960,7 +967,7 @@ extern "C" void JNICALL Java_org_ppsspp_ppsspp_NativeApp_pushCameraImageAndroid(
|
||||
if (image != NULL) {
|
||||
jlong size = env->GetArrayLength(image);
|
||||
jbyte* buffer = env->GetByteArrayElements(image, NULL);
|
||||
PushCameraImage(size, (unsigned char *)buffer);
|
||||
Camera::pushCameraImage(size, (unsigned char *)buffer);
|
||||
env->ReleaseByteArrayElements(image, buffer, JNI_ABORT);
|
||||
}
|
||||
}
|
||||
|
@ -1,14 +1,19 @@
|
||||
package org.ppsspp.ppsspp;
|
||||
|
||||
|
||||
import android.content.Context;
|
||||
import android.location.GpsSatellite;
|
||||
import android.location.GpsStatus;
|
||||
import android.location.Location;
|
||||
import android.location.LocationListener;
|
||||
import android.location.LocationManager;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
|
||||
class LocationHelper implements LocationListener {
|
||||
private static final String TAG = "LocationHelper";
|
||||
import java.util.Iterator;
|
||||
|
||||
class LocationHelper implements LocationListener, GpsStatus.Listener {
|
||||
private static final String TAG = LocationHelper.class.getSimpleName();
|
||||
private LocationManager mLocationManager;
|
||||
private boolean mLocationEnable;
|
||||
|
||||
@ -27,6 +32,7 @@ class LocationHelper implements LocationListener {
|
||||
isNetworkEnabled = mLocationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER);
|
||||
mLocationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1000, 0, this);
|
||||
mLocationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 1000, 0, this);
|
||||
mLocationManager.addGpsStatusListener(this);
|
||||
mLocationEnable = true;
|
||||
} catch (SecurityException e) {
|
||||
Log.e(TAG, "Cannot start location updates: " + e.toString());
|
||||
@ -70,4 +76,38 @@ class LocationHelper implements LocationListener {
|
||||
@Override
|
||||
public void onProviderDisabled(String provider) {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onGpsStatusChanged(int i) {
|
||||
switch (i) {
|
||||
case GpsStatus.GPS_EVENT_STARTED:
|
||||
case GpsStatus.GPS_EVENT_STOPPED:
|
||||
case GpsStatus.GPS_EVENT_FIRST_FIX:
|
||||
break;
|
||||
case GpsStatus.GPS_EVENT_SATELLITE_STATUS: {
|
||||
try {
|
||||
GpsStatus gpsStatus = mLocationManager.getGpsStatus(null);
|
||||
Iterable<GpsSatellite> satellites = gpsStatus.getSatellites();
|
||||
|
||||
short index = 0;
|
||||
for (Iterator<GpsSatellite> iterator = satellites.iterator(); iterator.hasNext(); ) {
|
||||
GpsSatellite satellite = iterator.next();
|
||||
if (satellite.getPrn() > 37) {
|
||||
continue;
|
||||
}
|
||||
NativeApp.setSatInfoAndroid(index, (short) satellite.getPrn(), (short) satellite.getElevation(),
|
||||
(short) satellite.getAzimuth(), (short) satellite.getSnr(), satellite.usedInFix() ? (short) 1 : (short) 0);
|
||||
index++;
|
||||
if (index == 24) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (SecurityException e) {
|
||||
Log.e(TAG, e.toString());
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -53,5 +53,6 @@ public class NativeApp {
|
||||
|
||||
public static native int getSelectedCamera();
|
||||
public static native void setGpsDataAndroid(float latitude, float longitude, float altitude, float speed, float bearing, long time);
|
||||
public static native void setSatInfoAndroid(short index, short id, short elevation, short azimuth, short snr, short good);
|
||||
public static native void pushCameraImageAndroid(byte[] image);
|
||||
}
|
||||
|
@ -176,5 +176,3 @@ int System_GetPropertyInt(SystemProperty prop);
|
||||
bool System_GetPropertyBool(SystemProperty prop);
|
||||
|
||||
std::vector<std::string> __cameraGetDeviceList();
|
||||
void SetGpsData(float latitude, float longitude, float altitude, float speed, float bearing, long long time);
|
||||
void PushCameraImage(long long length, unsigned char* image);
|
||||
|
@ -27,6 +27,8 @@
|
||||
#include "Core/Config.h"
|
||||
#include "Core/ConfigValues.h"
|
||||
#include "Core/System.h"
|
||||
#include "Core/HLE/sceUsbCam.h"
|
||||
#include "Core/HLE/sceUsbGps.h"
|
||||
#include "Common/GraphicsContext.h"
|
||||
|
||||
#include <sys/types.h>
|
||||
@ -684,7 +686,7 @@ void stopVideo() {
|
||||
}
|
||||
|
||||
-(void) PushCameraImageIOS:(long long)len buffer:(unsigned char*)data {
|
||||
PushCameraImage(len, data);
|
||||
Camera::pushCameraImage(len, data);
|
||||
}
|
||||
|
||||
void startLocation() {
|
||||
@ -697,7 +699,7 @@ void stopLocation() {
|
||||
|
||||
-(void) SetGpsDataIOS:(CLLocation *)newLocation {
|
||||
NSLog(@"SetGpsDataIOS: speed: %f", newLocation.speed); // m/s
|
||||
SetGpsData(newLocation.coordinate.latitude, newLocation.coordinate.longitude,
|
||||
GPS::setGpsData(newLocation.coordinate.latitude, newLocation.coordinate.longitude,
|
||||
newLocation.altitude, 0 /* speed */, 0 /* bearing */,
|
||||
(long long)newLocation.timestamp.timeIntervalSince1970);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user