[Q] 1% battery level increments? - Galaxy 3 General

Hey! Its possible to show battery percentage in 1%? or edit something to get 1% incresements in settings-> about phone -> status.
btw sry for my bad english.

goranek777 said:
Hey! Its possible to show battery percentage in 1%? or edit something to get 1% incresements in settings-> about phone -> status.
btw sry for my bad english.
Click to expand...
Click to collapse
No this would require a change in the firmware.

goranek777 said:
Hey! Its possible to show battery percentage in 1%? or edit something to get 1% incresements in settings-> about phone -> status.
btw sry for my bad english.
Click to expand...
Click to collapse
Am working on that
Editing the framework to include it
Lets see if it works

I think I have found the function that deals with it, I will also look into it
Code:
static int s3c_get_bat_level(struct power_supply *bat_ps)
{
int bat_level = 0;
int bat_vol = s3c_read_bat(bat_ps);
if(bat_vol < 0)
{
printk("%s: Read battery ADC failed!!\n", __func__);
return -1;
}
s3c_bat_info.bat_info.batt_vol_adc_aver = bat_vol;
if(is_over_abs_time()) {
bat_level = 100;
dev_info(dev, "%s: charging time is over\n", __func__);
s3c_set_chg_en(0);
s3c_bat_info.bat_info.batt_is_full = 1;
goto __end__;
}
if(!get_jig_cable_state() && low_batt_power_off) // Low batt interrupt occured
{
bat_level = 0; // Now, phone will be shutdown
dev_info(dev, "%s: power off by low battery\n", __func__);
goto __end__;
}
#if 0 //def __BATTERY_COMPENSATION__
if (s3c_bat_info.bat_info.charging_enabled) {
if (bat_vol > batt_almost - COMPENSATE_TA) {
s3c_bat_set_compesation(0, OFFSET_TA_ATTACHED,
COMPENSATE_TA);
}
}
#endif /* __BATTERY_COMPENSATION__ */
if (bat_vol > batt_full)
{
int temp = (batt_max - batt_full);
if (bat_vol > (batt_full + temp) ||
s3c_bat_info.bat_info.batt_is_full)
bat_level = 100;
else
bat_level = 90;
#ifdef __CHECK_CHG_CURRENT__
if (s3c_bat_info.bat_info.charging_enabled) {
check_chg_current(bat_ps);
if (!s3c_bat_info.bat_info.batt_is_full)
bat_level = 90;
}
#endif /* __CHECK_CHG_CURRENT__ */
dev_dbg(dev, "%s: (full)level = %d\n", __func__, bat_level );
}
else if (batt_full >= bat_vol && bat_vol > batt_almost)
{
int temp = (batt_full - batt_almost) / 2;
if (bat_vol > (batt_almost + 86))
bat_level = 80;
else
bat_level = 70;
dev_dbg(dev, "%s: (almost)level = %d\n", __func__, bat_level);
}
else if (batt_almost >= bat_vol && bat_vol > batt_high)
{
int temp = (batt_almost - batt_high) / 2;
if (bat_vol > (batt_high + 62))
bat_level = 60;
else
bat_level = 50;
dev_dbg(dev, "%s: (high)level = %d\n", __func__, bat_level );
}
else if (batt_high >= bat_vol && bat_vol > batt_medium)
{
int temp = (batt_high - batt_medium) / 2;
if (bat_vol > (batt_medium + 26))
bat_level = 40;
else
bat_level = 30;
dev_dbg(dev, "%s: (med)level = %d\n", __func__, bat_level);
}
else if (batt_medium >= bat_vol && bat_vol > batt_low)
{
int temp = (batt_medium - batt_low) / 2;
if (bat_vol > (batt_low + 50))
bat_level = 20;
else
bat_level = 15;
dev_dbg(dev, "%s: (low)level = %d\n", __func__, bat_level);
}
else if (batt_low >= bat_vol && bat_vol > batt_critical)
{
bat_level = 5;
dev_dbg(dev, "%s: (cri)level = %d, vol = %d\n", __func__,
bat_level, bat_vol);
}
else if (batt_critical >= bat_vol && bat_vol > batt_min)
{
bat_level = 3;
dev_info(dev, "%s: (min)level = %d, vol = %d\n", __func__,
bat_level, bat_vol);
}
else if (batt_min >= bat_vol && bat_vol > batt_off)
{
bat_level = 1;
dev_info(dev, "%s: (off)level = %d, vol = %d\n", __func__,
bat_level, bat_vol);
}
else if (batt_off >= bat_vol)
{
bat_level = 0;
dev_info(dev, "%s: (off)level = %d, vol = %d", __func__,
bat_level, bat_vol);
}
// If current status is full or recharging, then it should be 100% regardless of current real battery level.
if (s3c_bat_info.bat_info.batt_is_full || s3c_bat_info.bat_info.batt_is_recharging)
bat_level = 100;
if( (++p_count % 150) == 0) { // Print debug message every 5 minutes.
p_count = 1;
printk("[BATT] level(%d), is_full(%d), is_recharging(%d), charging_enabled(%d), batt_vol(%d)\n",
bat_level, s3c_bat_info.bat_info.batt_is_full, s3c_bat_info.bat_info.batt_is_recharging,
s3c_bat_info.bat_info.charging_enabled, bat_vol);
}
// If current status is full because of absolute timer, then it should be recharging.
if (s3c_bat_info.bat_info.batt_is_full &&
!s3c_bat_info.bat_info.charging_enabled &&
bat_vol < (batt_max + 45)) { // under 4.15V
dev_info(dev, "%s: recharging(under full)\n", __func__);
s3c_bat_info.bat_info.batt_is_recharging = 1;
s3c_set_chg_en(1);
bat_level = 100;
}
dev_dbg(dev, "%s: level = %d\n", __func__, bat_level);
__end__:
dev_dbg(dev, "%s: bat_vol = %d, level = %d, is_full = %d\n",
__func__, bat_vol, bat_level,
s3c_bat_info.bat_info.batt_is_full);
#ifdef __TEMP_ADC_VALUE__
return 80;
#else
return bat_level;
#endif /* __TEMP_ADC_VALUE__ */
}

cdesai said:
Am working on that
Editing the framework to include it
Lets see if it works
Click to expand...
Click to collapse
How's it progressing?

stubborn_d0nkey said:
I think I have found the function that deals with it, I will also look into it
Code:
static int s3c_get_bat_level(struct power_supply *bat_ps)
{
int bat_level = 0;
int bat_vol = s3c_read_bat(bat_ps);
if(bat_vol < 0)
{
printk("%s: Read battery ADC failed!!\n", __func__);
return -1;
}
s3c_bat_info.bat_info.batt_vol_adc_aver = bat_vol;
if(is_over_abs_time()) {
bat_level = 100;
dev_info(dev, "%s: charging time is over\n", __func__);
s3c_set_chg_en(0);
s3c_bat_info.bat_info.batt_is_full = 1;
goto __end__;
}
if(!get_jig_cable_state() && low_batt_power_off) // Low batt interrupt occured
{
bat_level = 0; // Now, phone will be shutdown
dev_info(dev, "%s: power off by low battery\n", __func__);
goto __end__;
}
#if 0 //def __BATTERY_COMPENSATION__
if (s3c_bat_info.bat_info.charging_enabled) {
if (bat_vol > batt_almost - COMPENSATE_TA) {
s3c_bat_set_compesation(0, OFFSET_TA_ATTACHED,
COMPENSATE_TA);
}
}
#endif /* __BATTERY_COMPENSATION__ */
if (bat_vol > batt_full)
{
int temp = (batt_max - batt_full);
if (bat_vol > (batt_full + temp) ||
s3c_bat_info.bat_info.batt_is_full)
bat_level = 100;
else
bat_level = 90;
#ifdef __CHECK_CHG_CURRENT__
if (s3c_bat_info.bat_info.charging_enabled) {
check_chg_current(bat_ps);
if (!s3c_bat_info.bat_info.batt_is_full)
bat_level = 90;
}
#endif /* __CHECK_CHG_CURRENT__ */
dev_dbg(dev, "%s: (full)level = %d\n", __func__, bat_level );
}
else if (batt_full >= bat_vol && bat_vol > batt_almost)
{
int temp = (batt_full - batt_almost) / 2;
if (bat_vol > (batt_almost + 86))
bat_level = 80;
else
bat_level = 70;
dev_dbg(dev, "%s: (almost)level = %d\n", __func__, bat_level);
}
else if (batt_almost >= bat_vol && bat_vol > batt_high)
{
int temp = (batt_almost - batt_high) / 2;
if (bat_vol > (batt_high + 62))
bat_level = 60;
else
bat_level = 50;
dev_dbg(dev, "%s: (high)level = %d\n", __func__, bat_level );
}
else if (batt_high >= bat_vol && bat_vol > batt_medium)
{
int temp = (batt_high - batt_medium) / 2;
if (bat_vol > (batt_medium + 26))
bat_level = 40;
else
bat_level = 30;
dev_dbg(dev, "%s: (med)level = %d\n", __func__, bat_level);
}
else if (batt_medium >= bat_vol && bat_vol > batt_low)
{
int temp = (batt_medium - batt_low) / 2;
if (bat_vol > (batt_low + 50))
bat_level = 20;
else
bat_level = 15;
dev_dbg(dev, "%s: (low)level = %d\n", __func__, bat_level);
}
else if (batt_low >= bat_vol && bat_vol > batt_critical)
{
bat_level = 5;
dev_dbg(dev, "%s: (cri)level = %d, vol = %d\n", __func__,
bat_level, bat_vol);
}
else if (batt_critical >= bat_vol && bat_vol > batt_min)
{
bat_level = 3;
dev_info(dev, "%s: (min)level = %d, vol = %d\n", __func__,
bat_level, bat_vol);
}
else if (batt_min >= bat_vol && bat_vol > batt_off)
{
bat_level = 1;
dev_info(dev, "%s: (off)level = %d, vol = %d\n", __func__,
bat_level, bat_vol);
}
else if (batt_off >= bat_vol)
{
bat_level = 0;
dev_info(dev, "%s: (off)level = %d, vol = %d", __func__,
bat_level, bat_vol);
}
// If current status is full or recharging, then it should be 100% regardless of current real battery level.
if (s3c_bat_info.bat_info.batt_is_full || s3c_bat_info.bat_info.batt_is_recharging)
bat_level = 100;
if( (++p_count % 150) == 0) { // Print debug message every 5 minutes.
p_count = 1;
printk("[BATT] level(%d), is_full(%d), is_recharging(%d), charging_enabled(%d), batt_vol(%d)\n",
bat_level, s3c_bat_info.bat_info.batt_is_full, s3c_bat_info.bat_info.batt_is_recharging,
s3c_bat_info.bat_info.charging_enabled, bat_vol);
}
// If current status is full because of absolute timer, then it should be recharging.
if (s3c_bat_info.bat_info.batt_is_full &&
!s3c_bat_info.bat_info.charging_enabled &&
bat_vol < (batt_max + 45)) { // under 4.15V
dev_info(dev, "%s: recharging(under full)\n", __func__);
s3c_bat_info.bat_info.batt_is_recharging = 1;
s3c_set_chg_en(1);
bat_level = 100;
}
dev_dbg(dev, "%s: level = %d\n", __func__, bat_level);
__end__:
dev_dbg(dev, "%s: bat_vol = %d, level = %d, is_full = %d\n",
__func__, bat_vol, bat_level,
s3c_bat_info.bat_info.batt_is_full);
#ifdef __TEMP_ADC_VALUE__
return 80;
#else
return bat_level;
#endif /* __TEMP_ADC_VALUE__ */
}
Click to expand...
Click to collapse
where did you find those? in which file?

drivers/power/s5p6442_battery.c

Related

How to create a GPRS connection in eVC?

As IE, MSN, when it launches, it creates a GPRS connection to Internet automaticly.
How can I do such thing in my own program in eVC 4.0 ?
Thanks.
All right.
No one answers my question, so I do it by myself. :evil:
Code:
#include <windows.h>
#include <winsock.h>
#if (WIN32_PLATFORM_PSPC>300 || WIN32_PLATFORM_WFSP )
#include <objbase.h>
#include <initguid.h>
#include <connmgr.h>
typedef HRESULT(*CONNMGRCONNECTIONSTATUS) (HANDLE hConnection,
DWORD * pdwStatus);
typedef HRESULT(*CONNMGRRELEASECONNECTION) (HANDLE hConnection,
LONG lCache);
typedef HRESULT(*CONNMGRESTABLISHCONNECTION) (CONNMGR_CONNECTIONINFO *
pConnInfo,
HANDLE * phConnection,
DWORD dwTimeout,
DWORD * pdwStatus);
#endif
HANDLE phWebConnection;
BOOL EstablishDatacall(TCHAR * IPout);
int WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow)
{
// TODO: Place code here.
TCHAR MyIP[20];
if (EstablishDatacall(MyIP) == TRUE) {
TCHAR Message[255];
wsprintf(Message, L"IP: %s", MyIP);
MessageBox(NULL, Message, L"Success", MB_OK);
} else {
MessageBox(NULL,
L"Data call could not be established or has been established",
L"Information", MB_OK);
}
return 0;
}
BOOL EstablishDatacall(TCHAR * IPout)
{
CHAR szHostname[255];
TCHAR IP[17];
HOSTENT *pHostEnt = NULL;
int nAdapter = 0;
IN_ADDR *tsim = NULL;
BOOL tried2Connect = FALSE;
IP[0] = 0; // Clear the IP Address
if (IPout != NULL) {
IPout[0] = 0;
}
tryagain:
nAdapter = 0;
gethostname(szHostname, sizeof(szHostname));
pHostEnt = gethostbyname(szHostname);
while (pHostEnt != NULL && pHostEnt->h_addr_list[nAdapter]) {
// in case a device has multiple ethernet cards
// i.e. 802.11, Bluetooth, USB-Cradle
// we need to go though all pHostEnt->h_addr_list[nAdapter]
tsim = (IN_ADDR *) pHostEnt->h_addr_list[nAdapter];
if (IPout != NULL) {
wsprintf(IPout, TEXT("%d.%d.%d.%d"),
tsim->S_un.S_un_b.s_b1,
tsim->S_un.S_un_b.s_b2,
tsim->S_un.S_un_b.s_b3, tsim->S_un.S_un_b.s_b4);
}
if (tsim->S_un.S_un_b.s_b1 == 192 ||
tsim->S_un.S_un_b.s_b1 == 169 ||
tsim->S_un.S_un_b.s_b1 == 127 || tsim->S_un.S_un_b.s_b1 == 255) {
// If you want to make sure you have a real Internet
// connection you cannot bet on IpAddresses starting with
// 127 and 255. 192 and 169 are local IP addresses and
// might be routed or proxied
nAdapter++;
} else {
wsprintf(IP, TEXT("%d.%d.%d.%d"),
tsim->S_un.S_un_b.s_b1,
tsim->S_un.S_un_b.s_b2,
tsim->S_un.S_un_b.s_b3, tsim->S_un.S_un_b.s_b4);
break;
}
}
// the next lines only work with Pocket PC Phone
// and Smartphone
#if (WIN32_PLATFORM_PSPC>300 || WIN32_PLATFORM_WFSP )
// Pocket PC Phone Edition has set WIN32_PLATFORM_PSPC to 310
if (IP[0] == 0 && tried2Connect == FALSE) {
CONNMGRCONNECTIONSTATUS g_hConnMgrConnectionStatus = NULL;
CONNMGRESTABLISHCONNECTION g_hConnMgrEstablishConnectionSync =
NULL;
// It is good practice to load the cellcore.dll
// dynamically to be able to compile the code even for
// older platforms
HINSTANCE hcellDll = LoadLibrary(TEXT("cellcore.dll"));
if (hcellDll) {
// We need the Status and a call to establish the
// connection
g_hConnMgrConnectionStatus =
(CONNMGRCONNECTIONSTATUS) GetProcAddress(hcellDll,
TEXT
("ConnMgrConnectionStatus"));
// The next line is just for debugging. You will have
// to decide what you want to do if this call fails
DWORD a = GetLastError();
g_hConnMgrEstablishConnectionSync =
(CONNMGRESTABLISHCONNECTION) GetProcAddress(hcellDll,
TEXT
("ConnMgrEstablishConnectionSync"));
//a = GetLastError();
// Here comes the main code:
// First we check if we might have a connection
DWORD pdwStatus;
(*g_hConnMgrConnectionStatus) (&phWebConnection, &pdwStatus);
if (pdwStatus == CONNMGR_STATUS_CONNECTED) {
//We are already connected!
//This code should never run since we should
//have a valid IP already.
//If you still get here, you probably have
//stale connection.
return TRUE;
} else {
//We are not connected, so lets try:
//The CONNECTIONINFO is the structure that
//tells Connection Manager how we want
//to connect
CONNMGR_CONNECTIONINFO sConInfo;
memset(&sConInfo, 0, sizeof(CONNMGR_CONNECTIONINFO));
sConInfo.cbSize = sizeof(CONNMGR_CONNECTIONINFO);
// We want to use the guidDestNet parameter
sConInfo.dwParams = CONNMGR_PARAM_GUIDDESTNET;
// This is the highest data priority.
sConInfo.dwPriority = CONNMGR_PRIORITY_USERINTERACTIVE;
sConInfo.dwFlags = 0;
// Lets be nice and share the connection with
// other applications
sConInfo.bExclusive = FALSE;
sConInfo.bDisabled = FALSE;
sConInfo.guidDestNet = IID_DestNetInternet;
// We want to wait until the connection was
// established successful but not longer then
// 60 seconds. You can use
// ConnMgrEstablishConnection to establish
// an asynchronous connection.
if ((*g_hConnMgrEstablishConnectionSync)
(&sConInfo, &phWebConnection, 60000,
&pdwStatus) == S_OK) {
//We are successfully connected!
//Now lets try to get the new IP address
tried2Connect = TRUE;
goto tryagain;
} else {
tried2Connect = FALSE;
//Doh! Connection failed!
}
}
}
}
#endif
return tried2Connect;
}

[IDEA] Xbox360 Controller for Android

Possible to make the Xbox360 controller connect to your Android phone ?
there's alot of software for both Mac and Windows letting you connect it to your computer, so without too much research i wondered if there is a possibility to port one of those apps over to android and use the controller for emulators and games.
there must be some open-source apps for win/osx out there i think so if any dev would have a look at it, for me to read those codes would be the same as to try to teach me greek..
just an idea, but if there's anyone that could make something out of this i think there will be alot of people wanting to use it
kinda like the SNES controller the streak's got, only wireless instead.. haha
Xbox 360 controllers aren't bluetooth
Sent from my HTC Droid Incredible. This Droid Does More.
its not just software to allow an Xbox controller to be connected to a PC, unless you're talking about the wired version, you need the reciever.
Like generamerica says, Xbox controllers aren't BT. PS3 ones are, but the bluetooth it uses is slightly different than normal and if i recall there have been issues in the past trying to get it to connect, no idea where that project has gone since then.
The only controller that can work with android from the big 3 atm is the wiimote, and even then you have to be running the stack from AOSP instead of the sense stack.
You got a lot of Bluetooth receivers !
It's possible !
GéVé said:
You got a lot of Bluetooth receivers !
It's possible !
Click to expand...
Click to collapse
!!!!!!! lo voglioooo contropper per android...cosi gioco a game psx gba
why not ps3 controller?
Yeah 360 would be impracticle if not impossible as you would have to either use a wired controller or have a wireless adapter for it to work. All of which means more stuff to lug around with an already large controller.
It would be cool to get the ps3 controller working on android but the controllerr is fairly big to carry with your phone.
Btw, the ps3 controller works great on windows. I use it with my netbook to play games in between classes. It connects to my normal Bluetooth receiver without any issues using a custom driver and software to pair the devices.
The only problem I can see coming from getting a ps3 controller working on android would be that once you pair the controller to the receiver you can no longer use it with any other devices unless you unpaid and uninstall driver to original. This is how it is with the controller on windows and most people use 2 Bluetooth receivers to deal with the problem.
Regardless of how practicle it would be to carry a ps3 or Xbox controller around with your phone it would be sweet to have working especially to get some of the other bluetooth controllers that are out there working. I have seen Asus controllers that are Bluetooth and have all the same buttons as ps3 controllers but they fold up and are a lot smaller and easy to carry around.
And a Bluetooth controller would be great for us who do not have enough hardware keys to play games with - no hardware keyboard.
Sent from my HTC Hero CDMA using XDA App
Its hardly impractical, if you was chilling at work on a break and you and a friend wanted a game of street fighter on Tiger mame or something then i think linking two xbox pads to your phone and having a few round would be superb, I would avoid even bothering with wireless with the xbox pad because it's not bluetooth and the ps3 is problematic for most devices using sense (which means half of them) so it's just the wired xbox pad, a port or a fresh app which can link the onscreen buttons to games or emulators to the digital buttons would be fantastic.
Dev's would pick up on this and would probably develop around them if it became successful enough, I think it's a good idea, the reason i say that is because the onscreen keyboards for the devices out now have some achillies heel's on them, first one is the fact that it's touchscreen and it's just not the same as a pad, the second is there is only ever going to be one player per device the likes of street fighter 2 turbo and king of fighters were ment to be played with two players, not to mention the amount of other game types which would be played better on a pad other than touchscreen.
In an ideal world it would be a cable to your tv and a cable to your pad, run a game on your phone and play it on your tv with your xbox pad wired.
I know it can be done, might look into doing it myself, usb can be split too, analogue could come later, hmmmmm.
There is an actual implementation of Xbox360 controler for the Elocity A7 tablet,
[ROM] Emulator / XBox360 Controller Mod 1-21-2011
But idk if it could be adapted to other android devices since it seems to need an usb port support.
Sine. said:
There is an actual implementation of Xbox360 controler for the Elocity A7 tablet,
[ROM] Emulator / XBox360 Controller Mod 1-21-2011
But idk if it could be adapted to other android devices since it seems to need an usb port support.
Click to expand...
Click to collapse
Yeah, in order to use the wired controller, you would need USB Host mode drivers, which at the moment not a lot of Android phones have (yet). At least, not to my knowledge anyway. Then you would need some sort of adapter to go from Mini/Micro USB (depending on which phone you have) to regular USB.
Sine. said:
There is an actual implementation of Xbox360 controler for the Elocity A7 tablet,
[ROM] Emulator / XBox360 Controller Mod 1-21-2011
But idk if it could be adapted to other android devices since it seems to need an usb port support.
Click to expand...
Click to collapse
abrigham said:
Yeah, in order to use the wired controller, you would need USB Host mode drivers, which at the moment not a lot of Android phones have (yet). At least, not to my knowledge anyway. Then you would need some sort of adapter to go from Mini/Micro USB (depending on which phone you have) to regular USB.
Click to expand...
Click to collapse
well I've seen some articles where people have some sort of adapter that turnes mini/micro usb into a dual input for (mouse / keyboard) so I guess two controllers shouldn't be that much further off... it's a matter of who has the knowledge and can implement it... unfortunately, it isn't me =( heh
But for the devices with usb ports how would one go about getting the required support in their rom?
When you plug the 360 controller in nothing happens.. I would like to know what files I may need to push to my android device that HAS full usb ports.
sent from gv1.5 on g2
Get a micro usb to female usb cable, plug in the wireless adapter. Your device has to be running Android 4.0 to work, but it does work flawlessly. You then have to go to market and download a free app that allows you to configure the buttons on the controller....then you're all set. There are also a few games that are already set in options to run third party controllers as well. I'm planning on doing this as soon as we get some type on ICS love from any direction for the SGS2 SGH-T989, so. I hooked this setting up on a customers Galaxy Tab, so. Awesome...
This doesn't have to do with the xbox controller, but On my old itouch, I could use a wii controller to play games on a nes emulator. If it's possible with ios, then it has to be with android.
Sent from my GT-I9100 using Tapatalk
Well, maybe it's possible to make Android using pads already connected to PC? I have Xbox 360 pad with PC receiver and I am wondering if it's actually possible to connect that controller to Android device (mine is HTC Desire Z).
I'm afraid that there can be some input lag but maybe that can be done?
Plausible and an achievable concept... is it worth it? Lol?
This got me thinking.
I dont know why anyone would want to do this now a days but it is very possible.
Back in 2007 remotejoy came out on the psp-1001 Phat.
Basically the concept is simple you would put a couple of .prx files on the memory stick pro duo in the root directory in a folder named plugins. And set up a windows drivers and a small application I think. I'm not 100% about that but seems logical.
Then interface the psp with the pc via USB but before interfacing, you would have to go into the vsh menu which you would hit a button combo and a text overlay would appear over the xmb in the top left hand corner. You could then select what plugin you wanted to load. Then you would load up the prx's and plug in your controller and USB type B from the psp to the pc. It would detect it though libusb and then you simply execute remotejoy.exe "I think" don't quote me on any of this. It was a long time ago....
Then you would literally be able to play your game on your monitor or on a flat screen like me. Via dvi output from an ant 1600xt graphics card in crossfire. And my 10000 pound Sony professional 42 inch $4000 plasma..... and then thru remotejoy gui you could go to controllers and basically use any analog controller that there were drivers for...... Man things have really changed in 13 years!!!!.... Jeez.
These plugins could add all kinds of extra features. Fps counter, background music player, an ir yeah infrared.... lol irmanager a badass file explorer with every feature you could ever imagine, well there was an irshell .prx, and a psx one called pops before Sony ever even released it.....
Sound familiar? Should, first there was xposed framework, now we have magisk plugins with support for xposed modules....
With that being said this is very possible and a feasible feat. (Not that anyone should take it on).....
It was coded under unix. So same kernel we use on androids..... It could be forked/updated/shimed/referenced/converted/reverse engineer to remotejoy magisk plugin but it's old code.
I think the last time it was updated was in 09 when I graduated high school.... so someone way more talented then me could possibly modify and retrofit or port to android using adb and USB debugging on a rooted android.
But this is not my area of expertise ports aren't my bag, man.
It would be a huge undertaking.
For controller support it would use socks. TCP specifically.
I didn't dig into it too much because well everyone now a days has smart share or screen mirroring and bluetooth xbox one s controllers and 4k TV's......
Just wanted to say it it a very plausible and achievable project.
Sorry to dig up an old thread. I have the original source code somewhere.
Here's an excerpt for controller support and mapping via universal serial ports it's in raw.
/*
* PSPLINK
* -----------------------------------------------------------------------
* Licensed under the BSD license, see LICENSE in PSPLINK root for details.
*
* remotejoy.c - PSPLINK PC remote joystick handler (SDL Version)
*
* Copyright (c) 2006 James F <[email protected]>
*
* $HeadURL: svn://svn.pspdev.org/psp/branches/psplinkusb/tools/remotejoy/pcsdl/remotejoy.c $
* $Id: remotejoy.c 2187 2007-02-20 19:28:00Z tyranid $
*/
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/select.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <netdb.h>
#include <limits.h>
#include <errno.h>
#include <ctype.h>
#include <signal.h>
#include <string.h>
#include <SDL.h>
#include <SDL_thread.h>
#include "../remotejoy.h"
#define DEFAULT_PORT 10004
#define DEFAULT_IP "localhost"
#define MAX_AXES_NUM 32767
#define DIGITAL_TOL 10000
#define PSP_SCREEN_W 480
#define PSP_SCREEN_H 272
#define EVENT_ENABLE_SCREEN 1
#define EVENT_RENDER_FRAME_1 2
#define EVENT_RENDER_FRAME_2 3
#define EVENT_DISABLE_SCREEN 4
#ifndef SOL_TCP
#define SOL_TCP IPPROTO_TCP
#endif
#if defined BUILD_BIGENDIAN || defined _BIG_ENDIAN
uint16_t swap16(uint16_t i)
{
uint8_t *p = (uint8_t *) &i;
uint16_t ret;
ret = (p[1] << 8) | p[0];
return ret;
}
uint32_t swap32(uint32_t i)
{
uint8_t *p = (uint8_t *) &i;
uint32_t ret;
ret = (p[3] << 24) | (p[2] << 16) | (p[1] << 8) | p[0];
return ret;
}
uint64_t swap64(uint64_t i)
{
uint8_t *p = (uint8_t *) &i;
uint64_t ret;
ret = (uint64_t) p[0] | ((uint64_t) p[1] << 8) | ((uint64_t) p[2] << 16) | ((uint64_t) p[3] << 24)
| ((uint64_t) p[4] << 32) | ((uint64_t) p[5] << 40) | ((uint64_t) p[6] << 48) | ((uint64_t) p[7] << 56);
return ret;
}
#define LE16(x) swap16(x)
#define LE32(x) swap32(x)
#define LE64(x) swap64(x)
#else
#define LE16(x) (x)
#define LE32(x) (x)
#define LE64(x) (x)
#endif
enum PspCtrlButtons
{
/** Select button. */
PSP_CTRL_SELECT = 0x000001,
/** Start button. */
PSP_CTRL_START = 0x000008,
/** Up D-Pad button. */
PSP_CTRL_UP = 0x000010,
/** Right D-Pad button. */
PSP_CTRL_RIGHT = 0x000020,
/** Down D-Pad button. */
PSP_CTRL_DOWN = 0x000040,
/** Left D-Pad button. */
PSP_CTRL_LEFT = 0x000080,
/** Left trigger. */
PSP_CTRL_LTRIGGER = 0x000100,
/** Right trigger. */
PSP_CTRL_RTRIGGER = 0x000200,
/** Triangle button. */
PSP_CTRL_TRIANGLE = 0x001000,
/** Circle button. */
PSP_CTRL_CIRCLE = 0x002000,
/** Cross button. */
PSP_CTRL_CROSS = 0x004000,
/** Square button. */
PSP_CTRL_SQUARE = 0x008000,
/** Home button. */
PSP_CTRL_HOME = 0x010000,
/** Music Note button. */
PSP_CTRL_NOTE = 0x800000,
/** Screen button. */
PSP_CTRL_SCREEN = 0x400000,
/** Volume up button. */
PSP_CTRL_VOLUP = 0x100000,
/** Volume down button. */
PSP_CTRL_VOLDOWN = 0x200000,
};
enum PspButtons
{
PSP_BUTTON_CROSS = 0,
PSP_BUTTON_CIRCLE = 1,
PSP_BUTTON_TRIANGLE = 2,
PSP_BUTTON_SQUARE = 3,
PSP_BUTTON_LTRIGGER = 4,
PSP_BUTTON_RTRIGGER = 5,
PSP_BUTTON_START = 6,
PSP_BUTTON_SELECT = 7,
PSP_BUTTON_UP = 8,
PSP_BUTTON_DOWN = 9,
PSP_BUTTON_LEFT = 10,
PSP_BUTTON_RIGHT = 11,
PSP_BUTTON_HOME = 12,
PSP_BUTTON_NOTE = 13,
PSP_BUTTON_SCREEN = 14,
PSP_BUTTON_VOLUP = 15,
PSP_BUTTON_VOLDOWN = 16,
PSP_BUTTON_MAX = 17
};
unsigned int g_bitmap[PSP_BUTTON_MAX] = {
PSP_CTRL_CROSS, PSP_CTRL_CIRCLE, PSP_CTRL_TRIANGLE, PSP_CTRL_SQUARE,
PSP_CTRL_LTRIGGER, PSP_CTRL_RTRIGGER, PSP_CTRL_START, PSP_CTRL_SELECT,
PSP_CTRL_UP, PSP_CTRL_DOWN, PSP_CTRL_LEFT, PSP_CTRL_RIGHT, PSP_CTRL_HOME,
PSP_CTRL_NOTE, PSP_CTRL_SCREEN, PSP_CTRL_VOLUP, PSP_CTRL_VOLDOWN
};
const char *map_names[PSP_BUTTON_MAX] = {
"cross", "circle", "triangle", "square",
"ltrig", "rtrig", "start", "select",
"up", "down", "left", "right", "home",
"note", "screen", "volup", "voldown"
};
/* Maps the buttons on the joystick to the buttons on the PSP controller */
unsigned int *g_buttmap = NULL;
struct Args
{
const char *ip;
unsigned short port;
const char *dev;
const char *mapfile;
int verbose;
int video;
int fullscreen;
int droprate;
int fullcolour;
int halfsize;
int showfps;
};
struct GlobalContext
{
struct Args args;
struct sockaddr_in serv;
char name[128];
unsigned int version;
unsigned char axes;
unsigned char buttons;
int exit;
int digital;
int analog;
int tol;
int scron;
};
struct GlobalContext g_context;
struct ScreenBuffer
{
unsigned char buf[PSP_SCREEN_W * PSP_SCREEN_H * 4];
struct JoyScrHeader head;
/* Mutex? */
};
static struct ScreenBuffer g_buffers[2];
void init_font(void);
void print_text(SDL_Surface *screen, int x, int y, const char *fmt, ...);
/* Should have a mutex on each screen */
#define VERBOSE (g_context.args.verbose)
int fixed_write(int s, const void *buf, int len)
{
int written = 0;
while(written < len)
{
int ret;
ret = write(s, buf+written, len-written);
if(ret < 0)
{
if(errno != EINTR)
{
perror("write");
written = -1;
break;
}
}
else
{
written += ret;
}
}
return written;
}
int parse_args(int argc, char **argv, struct Args *args)
{
memset(args, 0, sizeof(*args));
args->ip = DEFAULT_IP;
args->port = DEFAULT_PORT;
while(1)
{
int ch;
int error = 0;
ch = getopt(argc, argv, "vsfchldp:i:m:r:");
if(ch < 0)
{
break;
}
switch(ch)
{
case 'p': args->port = atoi(optarg);
break;
case 'i': args->ip = optarg;
break;
case 'm': args->mapfile = optarg;
break;
case 'v': args->verbose = 1;
break;
case 'd': args->video = 1;
break;
case 'f': args->fullscreen = 1;
break;
case 'c': args->fullcolour = 1;
break;
case 'l': args->halfsize = 1;
break;
case 's': args->showfps = 1;
break;
case 'r': args->droprate = atoi(optarg);
if((args->droprate < 0) || (args->droprate > 59))
{
fprintf(stderr, "Invalid drop rate (0 <= r < 60)\n");
error = 1;
}
break;
case 'h':
default : error = 1;
break;
};
if(error)
{
return 0;
}
}
argc -= optind;
argv += optind;
return 1;
}
void print_help(void)
{
fprintf(stderr, "Remotejoy Help\n");
fprintf(stderr, "Usage: remotejoy [options]\n");
fprintf(stderr, "Options:\n");
fprintf(stderr, "-p port : Specify the port number\n");
fprintf(stderr, "-i ip : Specify the ip address (default %s)\n", DEFAULT_IP);
fprintf(stderr, "-m mapfile : Specify a file to map joystick buttons to the PSP\n");
fprintf(stderr, "-d : Auto enable display support\n");
fprintf(stderr, "-f : Full screen mode\n");
fprintf(stderr, "-r drop : Frame Skip, 0 (auto), 1 (1/2), 2 (1/3), 3(1/4) etc.\n");
fprintf(stderr, "-c : Full colour mode\n");
fprintf(stderr, "-l : Half size mode (both X and Y)\n");
fprintf(stderr, "-s : Show fps\n");
fprintf(stderr, "-v : Verbose mode\n");
}
int init_sockaddr(struct sockaddr_in *name, const char *ipaddr, unsigned short port)
{
struct hostent *hostinfo;
name->sin_family = AF_INET;
name->sin_port = htons(port);
hostinfo = gethostbyname(ipaddr);
if(hostinfo == NULL)
{
fprintf(stderr, "Unknown host %s\n", ipaddr);
return 0;
}
name->sin_addr = *(struct in_addr *) hostinfo->h_addr;
return 1;
}
int connect_to(const char *ipaddr, unsigned short port)
{
struct sockaddr_in name;
int sock = -1;
int flag = 1;
sock = socket(PF_INET, SOCK_STREAM, 0);
if(sock < 0)
{
perror("socket");
return -1;
}
if(!init_sockaddr(&name, ipaddr, port))
{
printf("Could not initialise socket address\n");
close(sock);
return -1;
}
if(connect(sock, (struct sockaddr *) &name, sizeof(name)) < 0)
{
perror("connect");
close(sock);
return -1;
}
/* Disable NAGLE's algorithm to prevent the packets being joined */
setsockopt(sock, SOL_TCP, TCP_NODELAY, &flag, sizeof(int));
return sock;
}
int get_joyinfo(SDL_Joystick *stick)
{
const char *name;
name = SDL_JoystickName(0);
if(!name)
{
return 0;
}
strcpy(g_context.name, name);
g_context.axes = SDL_JoystickNumAxes(stick);
g_context.buttons = SDL_JoystickNumButtons(stick);
return 1;
}
void remove_wsp(char *buf)
{
int len = strlen(buf);
int i = 0;
while(isspace(buf))
{
i++;
}
if(i > 0)
{
len -= i;
memmove(buf, &buf, len + 1);
}
if(len <= 0)
{
return;
}
i = len-1;
while(isspace(buf))
{
buf[i--] = 0;
}
}
int build_map(const char *mapfile, int buttons)
{
int i;
FILE *fp;
g_context.analog = -1;
g_context.digital = -1;
g_context.tol = DIGITAL_TOL;
g_buttmap = (unsigned int *) malloc(buttons * sizeof(unsigned int));
if(g_buttmap == NULL)
{
return 0;
}
for(i = 0; i < buttons; i++)
{
/* Fill with mappings, repeat if more than 8 buttons */
g_buttmap = i % 8;
}
if(mapfile)
{
char buffer[512];
int line = 0;
fp = fopen(mapfile, "r");
if(fp == NULL)
{
fprintf(stderr, "Could not open mapfile %s\n", mapfile);
return 0;
}
while(fgets(buffer, sizeof(buffer), fp))
{
char *tok, *val;
int butt;
line++;
remove_wsp(buffer);
if((buffer[0] == '#') || (buffer[0] == 0)) /* Comment or empty line */
{
continue;
}
tok = strtok(buffer, ":");
val = strtok(NULL, "");
if((tok == NULL) || (val == NULL))
{
printf("Invalid mapping on line %d\n", line);
continue;
}
butt = atoi(val);
for(i = 0; i < PSP_BUTTON_MAX; i++)
{
if(strcasecmp(map_names, tok) == 0)
{
g_buttmap[butt] = i;
break;
}
}
if(i == PSP_BUTTON_MAX)
{
if(strcasecmp("analog", tok) == 0)
{
g_context.analog = butt;
}
else if(strcasecmp("digital", tok) == 0)
{
g_context.digital = butt;
}
else if(strcasecmp("tol", tok) == 0)
{
g_context.tol = atoi(val);
}
else
{
fprintf(stderr, "Unknown map type %s\n", tok);
}
}
}
fclose(fp);
}
return 1;
}
int send_event(int sock, int type, unsigned int value)
{
struct JoyEvent event;
if(sock < 0)
{
return 0;
}
/* Note, should swap endian */
event.magic = LE32(JOY_MAGIC);
event.type = LE32(type);
event.value = LE32(value);
if(fixed_write(sock, &event, sizeof(event)) != sizeof(event))
{
fprintf(stderr, "Could not write out data to socket\n");
return 0;
}
return 1;
}
void post_event(int no)
{
SDL_Event event;
event.type = SDL_USEREVENT;
event.user.code = no;
event.user.data1 = NULL;
event.user.data2 = NULL;
SDL_PushEvent(&event);
}
int flush_socket(int sock)
{
/* If we encounter some horrible error which means we are desynced
* then send a video off packet to remotejoy, wait around for a second sucking up
* any more data from the socket and then reenable */
return 0;
}
void update_fps(SDL_Surface *screen)
{
#define FRAME_VALUES 32
static Uint32 times[FRAME_VALUES];
static Uint32 lastticks = 0;
static int index = 0;
Uint32 ticks;
int i;
double fps;
ticks = SDL_GetTicks();
times[index] = ticks - lastticks;
index = (index + 1) % FRAME_VALUES;
lastticks = ticks;
fps = 0.0;
for(i = 0; i < FRAME_VALUES; i++)
{
fps += (double) times;
}
fps /= (double) FRAME_VALUES;
/* Fps is now average frame time */
fps = 1000.0 / fps;
/* Now frame frequency in Hz */
print_text(screen, 0, 0, "Fps: %.2f", fps);
}
int read_thread(void *p)
{
int err = 0;
int frame = 0;
fd_set saveset, readset;
int count;
int sock = *(int *) p;
struct JoyScrHeader head;
FD_ZERO(&saveset);
FD_SET(sock, &saveset);
while(!err)
{
readset = saveset;
count = select(FD_SETSIZE, &readset, NULL, NULL, NULL);
if(count > 0)
{
int ret;
int mode;
int size;
if(FD_ISSET(sock, &readset))
{
ret = read(sock, &head, sizeof(head));
if((ret != sizeof(head)) || (LE32(head.magic) != JOY_MAGIC))
{
fprintf(stderr, "Error in socket %d, magic %08X\n", ret, head.magic);
flush_socket(sock);
break;
}
mode = LE32(head.mode);
size = LE32(head.size);
g_buffers[frame].head.mode = mode;
g_buffers[frame].head.size = size;
if(mode < 0)
{
if(g_context.args.video)
{
post_event(EVENT_ENABLE_SCREEN);
}
else
{
g_context.scron = 0;
}
}
else if(mode > 3)
{
/* Flush socket */
flush_socket(sock);
}
else
{
/* Try and read in screen */
/* If we do not get a full frame read and we timeout in quater second or so then
* reset sync as it probably means the rest isn't coming */
int loc = 0;
//fprintf(stderr, "Size %d\n", size);
while(1)
{
readset = saveset;
/* Should have a time out */
count = select(FD_SETSIZE, &readset, NULL, NULL, NULL);
if(count > 0)
{
ret = read(sock, &(g_buffers[frame].buf[loc]), size-loc);
if(ret < 0)
{
if(errno != EINTR)
{
perror("read:");
err = 1;
break;
}
}
else if(ret == 0)
{
fprintf(stderr, "EOF\n");
break;
}
//fprintf(stderr, "Read %d\n", loc);
loc += ret;
if(loc == size)
{
break;
}
}
else if(count < 0)
{
if(errno != EINTR)
{
perror("select:");
err = 1;
break;
}
}
}
if(!err)
{
if(frame)
{
post_event(EVENT_RENDER_FRAME_2);
}
else
{
post_event(EVENT_RENDER_FRAME_1);
}
frame ^= 1;
}
}
}
}
else if(count < 0)
{
if(errno != EINTR)
{
perror("select:");
err = 1;
}
}
}
return 0;
}
SDL_Surface *create_surface(void *buf, int mode)
{
unsigned int rmask, bmask, gmask, amask;
int currw, currh;
int bpp;
currw = PSP_SCREEN_W;
currh = PSP_SCREEN_H;
if(g_context.args.halfsize)
{
currw >>= 1;
currh >>= 1;
}
if(VERBOSE)
{
printf("Mode %d\n", mode);
}
switch(mode)
{
case 3:
rmask = LE32(0x000000FF);
gmask = LE32(0x0000FF00);
bmask = LE32(0x00FF0000);
amask = 0;
bpp = 32;
break;
case 2:
rmask = LE16(0x000F);
gmask = LE16(0x00F0);
bmask = LE16(0x0F00);
amask = 0;
bpp = 16;
break;
case 1:
rmask = LE16(0x1F);
gmask = LE16(0x1F << 5);
bmask = LE16(0x1F << 10);
amask = 0;
bpp = 16;
break;
case 0:
rmask = LE16(0x1F);
gmask = LE16(0x3F << 5);
bmask = LE16(0x1F << 11);
amask = 0;
bpp = 16;
break;
default: return NULL;
};
return SDL_CreateRGBSurfaceFrom(buf, currw, currh, bpp, currw*(bpp/8),
rmask, gmask, bmask, amask);
}
void save_screenshot(SDL_Surface *surface)
{
int i;
char path[PATH_MAX];
struct stat s;
/* If we cant find one in the next 1000 then dont bother */
for(i = 0; i < 1000; i++)
{
snprintf(path, PATH_MAX, "scrshot%03d.bmp", i);
if(stat(path, &s) < 0)
{
break;
}
}
if(i == 1000)
{
return;
}
if(SDL_SaveBMP(surface, path) == 0)
{
printf("Saved screenshot to %s\n", path);
}
else
{
printf("Error saving screenshot\n");
}
}
void mainloop(void)
{
SDL_Joystick *stick = NULL;
SDL_Surface *screen = NULL;
SDL_Surface *buf1 = NULL;
SDL_Surface *buf2 = NULL;
SDL_Thread *thread = NULL;
int currw, currh;
int sdl_init = 0;
int sock = -1;
unsigned int button_state = 0;
int currmode[2] = { 3, 3 };
int flags = SDL_HWSURFACE;
int pspflags = 0;
int showfps = 0;
Hit my limit deleted non essentials to controller mapping and left some display transmission info in.
But no one will probably even read this... I LOVE XDADEVELOPERS!

MENU click NOT working

hi guys
i am in the process of implementing this menu but it is not updating the speed of my sensor
my code snipet is
here are my global variables
Code:
private static final int MENU_SLOW = 0;
private static final int MENU_NORMAL = 1;
private static final int MENU_FAST = 2;
private static final int MENU_EXIT = -1;
int ROTATION_SPEED = 3;
private static SensorManager mySensorManager;
private boolean sersorrunning;
private myCompassView myCompassView;
/** Called when the activity is first created.*/
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
myCompassView = (myCompassView)findViewById(R.id.mycompassview);
mySensorManager = (SensorManager)getSystemService(Context.SENSOR_SERVICE);
List<Sensor> mySensors = mySensorManager.getSensorList(Sensor.TYPE_ORIENTATION);
if(mySensors.size() > 0){
mySensorManager.registerListener(mySensorEventListener, mySensors.get(0), ROTATION_SPEED);
sersorrunning = true;
Toast.makeText(this, "POINT the Needle to N for NORTH", Toast.LENGTH_LONG).show();
}
else{
Toast.makeText(this, "COMPASS not Initilised", Toast.LENGTH_LONG).show();
sersorrunning = false;
finish();
}
}
here is my sensor speed code
Code:
if(mySensors.size() > 0){
mySensorManager.registerListener(mySensorEventListener, mySensors.get(0), ROTATION_SPEED);
sersorrunning = true;
Toast.makeText(this, "POINT the Needle to N for NORTH", Toast.LENGTH_LONG).show();
}
else{
Toast.makeText(this, "COMPASS not Initilised", Toast.LENGTH_LONG).show();
sersorrunning = false;
finish();
}
and here is how i am trying to change the variable ROTATION_SPEED
Code:
public boolean onOptionsItemSelected (MenuItem item){
if (item.getItemId() == MENU_SLOW){
ROTATION_SPEED = SensorManager.SENSOR_DELAY_UI;
Toast.makeText(this, "Speed changed to SystemPreffered", Toast.LENGTH_SHORT).show();
}else if (item.getItemId() == MENU_NORMAL){
ROTATION_SPEED = SensorManager.SENSOR_DELAY_NORMAL;
Toast.makeText(this, "Speed changed to NORMAL", Toast.LENGTH_SHORT).show();
}else if (item.getItemId() == MENU_FAST){
ROTATION_SPEED = SensorManager.SENSOR_DELAY_FASTEST;
Toast.makeText(this, "Speed changed to FAST", Toast.LENGTH_SHORT).show();
}else if (item.getItemId() == MENU_EXIT){
android.os.Process.killProcess(android.os.Process.myPid());
Toast.makeText(this, "Exiting application...", Toast.LENGTH_SHORT).show();
}
return false;
}
ANY HELP WILL BE VERY MUCH APPRECIATED
thanks
shiraz
So I see you're setting the variable ROTATION_SPEED, but where are you ever using that to actually set the speed?
here is im changing the variable value
Code:
public boolean onOptionsItemSelected (MenuItem item){
if (item.getItemId() == MENU_SLOW){
ROTATION_SPEED = SensorManager.SENSOR_DELAY_UI;
Toast.makeText(this, "Speed changed to SystemPreffered", Toast.LENGTH_SHORT).show();
}else if (item.getItemId() == MENU_NORMAL){
ROTATION_SPEED = SensorManager.SENSOR_DELAY_NORMAL;
Toast.makeText(this, "Speed changed to NORMAL", Toast.LENGTH_SHORT).show();
}else if (item.getItemId() == MENU_FAST){
ROTATION_SPEED = SensorManager.SENSOR_DELAY_FASTEST;
Toast.makeText(this, "Speed changed to FAST", Toast.LENGTH_SHORT).show();
}else if (item.getItemId() == MENU_EXIT){
android.os.Process.killProcess(android.os.Process.myPid());
Toast.makeText(this, "Exiting application...", Toast.LENGTH_SHORT).show();
}
return false;
}
You're assigning a new value to ROTATION_SPEED, but never telling the sensor service that it's changed. I'm not familiar with the SensorManager class, but I think you have to re-call registerListener with the new value for the changes to be applied.
thanks dude
thats awesom
sorted this out ::
just aded the sensor manager after every new value given to ROTATION_SPEED
cheers

Radiogroup and radiobutton selection in ExpandableListView

i've an ExpandableListView, where i can select different radiobutton choice in a radiobuttongroup. My problem: not all radiobuttons are selected...the behaviour is random.
this is my code
Code:
void prepareMainList(String data)
{
Document doc;
NodeList nl;
newsNotificationData = new ArrayList<Map<String, String>>(); //set this struct in other case
groupData = new ArrayList<Map<String, String>>();
childData = new ArrayList<List<Map<String, String>>>();
if ((data.compareTo("") != 0) && (data != null) )
{
doc = parser.getDomElement(data); // getting DOM element
nl = doc.getElementsByTagName(KEY_GROUP);
categoryList = new HashSet<CategoryClass>();
// looping through all song nodes <song>
for (int i = 0; i < nl.getLength(); i++)
{
// creating new HashMap
Map<String, String> curGroupMap = new HashMap<String, String>();
Map<String, String> curNewsMap = new HashMap<String, String>();
Element el = (Element) nl.item(i);
CategoryClass myCat = new CategoryClass();
myCat.id = parser.getValue(el, "id");
myCat.name = parser.getValue(el, KEY_NAME);
myCat.subCategory = new HashSet<TournamentClass>();
// adding each child node to HashMap key => value
curGroupMap.put(CATEGORY, parser.getValue(el, KEY_NAME));
Log.d("test", "category id added: " + myCat.id);
// adding HashList to ArrayList
groupData.add(curGroupMap);
//notification
curNewsMap.put("CID_" + myCat.id, getValueFromCategory(myCat.id));
newsNotificationData.add(curNewsMap);
NodeList ls = el.getElementsByTagName("girone");
//Log.d("test", "getDataFromWebService get children count : " + ls.getLength());
List<Map<String, String>> children = new ArrayList<Map<String, String>>();
for (int j = 0; j < ls.getLength(); j++)
{
Element elc = (Element) ls.item(j);
Map<String, String> curChildMap = new HashMap<String, String>();
TournamentClass myTournament = new TournamentClass();
myTournament.id = elc.getAttribute("id");
myTournament.name = parser.getValue(elc, KEY_CHILD_NAME);
curChildMap.put(TOURNAMENT, parser.getValue(elc, KEY_CHILD_NAME));
children.add(curChildMap);
myCat.subCategory.add(myTournament);
//notification
curNewsMap.put("TID_" + myTournament.id, "-1");
newsNotificationData.get(i).put("TID_" + myTournament.id, getValueFromTournament(myTournament.id));
}
childData.add(children);
categoryList.add(myCat);
//newsNotificationData.add(curNewsMap);
}
}
catList = (ExpandableListView) findViewById(R.id.expandableSettings);
catList.setClickable(true);
catList.setOnGroupClickListener(new ExpandableListView.OnGroupClickListener() {
public boolean onGroupClick(ExpandableListView parent, View v,
int groupPosition, long id) {
Log.d("test", "GROUP PRESSED");
return false;
}
});
// Set up our adapter
mAdapter = new SimpleExpandableListAdapter(
this,
groupData,
R.layout.settings_header,
new String[] { CATEGORY, TOURNAMENT },
new int[] { R.id.settingsCatTitle, android.R.id.text2 },
childData,
R.layout.settings_child,
new String[] { CATEGORY, TOURNAMENT },
new int[] { android.R.id.text1, R.id.settingsSubTitle }
){
@Override
public View getGroupView (final int groupPosition, boolean isExpanded, View convertView, ViewGroup parent)
{
//final View v = super.getChildView(groupPosition, childPosition, isLastChild, convertView, parent);
final View v = super.getGroupView(groupPosition, isExpanded, convertView, parent);
//Log.d("test", "get tournament selected");
TextView tv = (TextView)v.findViewById( R.id.settingsCatTitle );
String catSel = tv.getText().toString();
//get objects
String groupName = groupData.get(groupPosition).get("CATEGORY");
final CategoryClass myCat = getCategoryFromName(groupName);
RadioGroup groupNN;
// *** Gestisce l'header della categoria ***
groupNN = (RadioGroup) v.findViewById(R.id.radioGroupNN);
groupNN.setOnCheckedChangeListener(new OnCheckedChangeListener()
{
@Override
public void onCheckedChanged(RadioGroup group, int checkedId)
{
//Log.d("Header chk", "id" + checkedId);
if(!isDataLoaded) return;
for (int i = 0, l = group.getChildCount(); i < l; i++)
{
RadioButton xRadio = (RadioButton) group.getChildAt(i);
xRadio.setBackgroundResource(R.drawable.setting_gradient_off);
xRadio.setTextColor(R.drawable.settings_gradient_on);
}
//-----change data to send
String notifValue = "0";
//get checked value
switch (checkedId)
{
case R.id.button_News:
notifValue = "0";
break;
case R.id.button_Notif:
notifValue = "1";
break;
case R.id.button_All:
notifValue = "2";
break;
case R.id.button_no:
notifValue = "-1";
break;
default:
break;
}
//set graphics on selected radio button
RadioButton radio = (RadioButton) v.findViewById(checkedId);
if (radio != null)
{
//radio.setTextSize(30);
// Marco Moscatelli 28/11/2013 - imposto il check a true
//radio.setChecked(true);
radio.setBackgroundResource(R.drawable.settings_gradient_on);
radio.setTextColor(Color.LTGRAY);
}
updateNewsNotificationCenter(groupPosition, myCat.id, null, notifValue);
isDataLoaded = false;
//Log.d("test", "------END SET CATEGORY------- ");
}
});
//-----data to send changed
isDataLoaded = false;
//set default schema
//String defaultbtnValue = null;
String defaultbtnValue = newsNotificationData.get(groupPosition).get("CID_" + myCat.id);
//Log.d("test", "check current cat id : "+ myCat.id);
RadioButton defNNRadio = null;
//Log.d("test", "defaultbtnValue : "+ defaultbtnValue);
if (defaultbtnValue == null)defaultbtnValue = "-1";
switch(Integer.parseInt(defaultbtnValue))
{
case 0:
defNNRadio = (RadioButton) v.findViewById(R.id.button_News);
break;
case 1:
defNNRadio = (RadioButton) v.findViewById(R.id.button_Notif);
break;
case 2:
defNNRadio = (RadioButton) v.findViewById(R.id.button_All);
break;
case -1:
defNNRadio = (RadioButton) v.findViewById(R.id.button_no);
break;
default:
break;
}
//set default button
for (int i = 0, l = groupNN.getChildCount(); i < l; i++)
{
RadioButton xRadio = (RadioButton) groupNN.getChildAt(i);
xRadio.setChecked(false);
xRadio.setBackgroundResource(R.drawable.setting_gradient_off);
xRadio.setTextColor(R.drawable.settings_gradient_on);
}
if (defNNRadio != null)
{
defNNRadio.setChecked(true);
defNNRadio.setBackgroundResource(R.drawable.settings_gradient_on);
defNNRadio.setTextColor(Color.LTGRAY);
}
return v;
}
@Override
public View getChildView(final int groupPosition, final int childPosition, boolean isLastChild, View convertView, ViewGroup parent) {
final View v = super.getChildView(groupPosition, childPosition, isLastChild, convertView, parent);
Log.d("test", "getChildView");
RadioGroup groupNN;
// *** gestisco i gironi della categoria ***
groupNN = (RadioGroup) v.findViewById(R.id.radioGroupNN_child);
//get objects
String groupName = groupData.get(groupPosition).get("CATEGORY");
final CategoryClass myCat = getCategoryFromName(groupName);
Map<String, String> childName = childData.get(groupPosition).get(childPosition);
final TournamentClass myTournament = getTournamentFromName(groupName, childName.get("TOURNAMENT"));
groupNN.setOnCheckedChangeListener(new OnCheckedChangeListener()
{
@Override
public void onCheckedChanged(RadioGroup group, int checkedId)
{
//Log.d("Item chk", "id" + checkedId);
if(!isDataLoaded) return;
Log.d("test", "------INIT SET TOURNAMENT------- : " + myTournament.id);
for (int i = 0, l = group.getChildCount(); i < l; i++)
{
RadioButton xRadio = (RadioButton) group.getChildAt(i);
xRadio.setBackgroundResource(R.drawable.setting_gradient_off);
xRadio.setTextColor(color.SettingsTextOffColor);
}
//-----change data to send
String notifValue = "0";
//get checked value
switch (checkedId)
{
case R.id.button_News:
notifValue = "0";
break;
case R.id.button_Notif:
notifValue = "1";
break;
case R.id.button_All:
notifValue = "2";
break;
case R.id.button_no:
notifValue = "-1";
break;
default:
break;
}
//Get Tournament and keep id of it...after save notification mode in a struct and send all on POSTS
RadioButton radio = (RadioButton) v.findViewById(checkedId);
if (radio != null)
{
// Marco Moscatelli 28/11/2013 - Imposto il check a true
//radio.setChecked(true);
//group.check(radio.getId());
// end
radio.setBackgroundResource(R.drawable.settings_gradient_on);
radio.setTextColor(Color.LTGRAY);
}
//prepare data
updateNewsNotificationCenter(groupPosition, myCat.id, myTournament.id, notifValue);
Log.d("test", "------END SET TOURNAMENT------- ");
}
//}
});
//set default schema
String defaultbtnValue = newsNotificationData.get(groupPosition).get("TID_" + myTournament.id);
RadioButton defNNRadio = null;
//Log.d("test", "defaultbtnValue : "+ defaultbtnValue);
if (defaultbtnValue == null)defaultbtnValue = "-1";
switch(Integer.parseInt(defaultbtnValue))
{
case 0:
defNNRadio = (RadioButton) v.findViewById(R.id.button_News);
break;
case 1:
defNNRadio = (RadioButton) v.findViewById(R.id.button_Notif);
break;
case 2:
defNNRadio = (RadioButton) v.findViewById(R.id.button_All);
break;
case -1:
defNNRadio = (RadioButton) v.findViewById(R.id.button_no);
break;
}
for (int i = 0, l = groupNN.getChildCount(); i < l; i++)
{
RadioButton xRadio = (RadioButton) groupNN.getChildAt(i);
xRadio.setChecked(false);
xRadio.setBackgroundResource(R.drawable.setting_gradient_off);
xRadio.setTextColor(color.SettingsTextOffColor);
}
//set default schema
if (defNNRadio != null)
{
defNNRadio.setChecked(true);
defNNRadio.setBackgroundResource(R.drawable.settings_gradient_on);
defNNRadio.setTextColor(Color.LTGRAY);
}
//isDataLoaded = true;
return v;
}
thanks in advance

Data Traffic Meter

Hi!
I'm developing an App that register the data speed sended and received. The problem is that the app shows a very similar speed between upload and upload, and the data speed seems to be incorrect.
Could anyone solve my problem?
Sorry form my BAD English [emoji29]
This is my code:
Code:
public class Traffic extends TextView {
private int mDelaytime = 3000;
private Handler mHandler = new Handler();
private int mLastReceive = 0;
private int mLastTransmit = 0;
private int mTxRate = 0;
private int mRxRate = 0;
File traffic = new File("/data/.traffic");
private Runnable task = new Runnable() {
public void run() {
if (!traffic.exists() || mLastReceive == getTotalDataBytes(true) && mLastTransmit == getTotalDataBytes(false)){
mTxRate = (getTotalDataBytes(false) - mLastTransmit);
mRxRate = (getTotalDataBytes(true) - mLastReceive);
mLastReceive = getTotalDataBytes(true);
mLastTransmit = getTotalDataBytes(false);
Traffic.this.setText(formatSize(mTxRate/3) + "\n" + formatSize(mRxRate/3));
} else {
Traffic.this.setText("");
}
mHandler.postDelayed(task, mDelaytime);
}
};
private int getTotalDataBytes(boolean Transmit) {
String readLine;
String[] DataPart;
int line = 0;
int Data = 0;
try {
FileReader fr = new FileReader("/proc/net/dev");
BufferedReader br = new BufferedReader(fr);
while((readLine = br.readLine()) != null) {
line++;
if (line <= 2) continue;
DataPart = readLine.split(":");
DataPart = DataPart[1].split("\\s+");
if (Transmit) {
Data += Integer.parseInt(DataPart[1]);
} else {
Data += Integer.parseInt(DataPart[9]);
}
}
fr.close();
br.close();
} catch (IOException e) {
return -1;
}
return Data;
}
public Traffic(Context context) {
this(context, null);
}
public Traffic(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
public Traffic(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
@Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();
mHandler.postDelayed(task, mDelaytime);
}
@Override
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
mHandler.removeCallbacks(task);
}
private static final String BYTES = "B/s";
private static final String MEGABYTES = "MB/s";
private static final String KILOBYTES = "KB/s";
private static final String GIGABYTES = "GB/s";
private static final long KILO = 1024;
private static final long MEGA = KILO * 1024;
private static final long GIGA = MEGA * 1024;
static String formatSize(final long pBytes) {
if (pBytes < KILO) {
return pBytes + BYTES;
} else if (pBytes < MEGA) {
return (int) (0.5 + (pBytes / (double) KILO)) + KILOBYTES;
} else if (pBytes < GIGA) {
return (int) (0.5 + (pBytes / (double) MEGA)) + MEGABYTES;
} else {
return (int) (0.5 + (pBytes / (double) GIGA)) + GIGABYTES;
}
}
}
Thanks!!
Come on please! :'(
Enviado desde mi GT-S7580 mediante Tapatalk
DannyGM16 said:
Hi!
I'm developing an App that register the data speed sended and received. The problem is that the app shows a very similar speed between upload and upload, and the data speed seems to be incorrect.
Could anyone solve my problem?
Sorry form my BAD English [emoji29]
This is my code:
Code:
public class Traffic extends TextView {
private int mDelaytime = 3000;
private Handler mHandler = new Handler();
private int mLastReceive = 0;
private int mLastTransmit = 0;
private int mTxRate = 0;
private int mRxRate = 0;
File traffic = new File("/data/.traffic");
private Runnable task = new Runnable() {
public void run() {
if (!traffic.exists() || mLastReceive == getTotalDataBytes(true) && mLastTransmit == getTotalDataBytes(false)){
mTxRate = (getTotalDataBytes(false) - mLastTransmit);
mRxRate = (getTotalDataBytes(true) - mLastReceive);
mLastReceive = getTotalDataBytes(true);
mLastTransmit = getTotalDataBytes(false);
Traffic.this.setText(formatSize(mTxRate/3) + "\n" + formatSize(mRxRate/3));
} else {
Traffic.this.setText("");
}
mHandler.postDelayed(task, mDelaytime);
}
};
private int getTotalDataBytes(boolean Transmit) {
String readLine;
String[] DataPart;
int line = 0;
int Data = 0;
try {
FileReader fr = new FileReader("/proc/net/dev");
BufferedReader br = new BufferedReader(fr);
while((readLine = br.readLine()) != null) {
line++;
if (line <= 2) continue;
DataPart = readLine.split(":");
DataPart = DataPart[1].split("\\s+");
if (Transmit) {
Data += Integer.parseInt(DataPart[1]);
} else {
Data += Integer.parseInt(DataPart[9]);
}
}
fr.close();
br.close();
} catch (IOException e) {
return -1;
}
return Data;
}
public Traffic(Context context) {
this(context, null);
}
public Traffic(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
public Traffic(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
@Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();
mHandler.postDelayed(task, mDelaytime);
}
@Override
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
mHandler.removeCallbacks(task);
}
private static final String BYTES = "B/s";
private static final String MEGABYTES = "MB/s";
private static final String KILOBYTES = "KB/s";
private static final String GIGABYTES = "GB/s";
private static final long KILO = 1024;
private static final long MEGA = KILO * 1024;
private static final long GIGA = MEGA * 1024;
static String formatSize(final long pBytes) {
if (pBytes < KILO) {
return pBytes + BYTES;
} else if (pBytes < MEGA) {
return (int) (0.5 + (pBytes / (double) KILO)) + KILOBYTES;
} else if (pBytes < GIGA) {
return (int) (0.5 + (pBytes / (double) MEGA)) + MEGABYTES;
} else {
return (int) (0.5 + (pBytes / (double) GIGA)) + GIGABYTES;
}
}
}
Thanks!!
Click to expand...
Click to collapse
Maybe this help: https://github.com/NetEase/Emmagee
I don't understand Chinese xD
And it doesn't help me... but anyway Thanks!
Any other solution?
Enviado desde mi GT-S7580 mediante Tapatalk
Oh didnt see that, but there are other data traffic apps on github just search with google. Sorry thats all i can do

Categories

Resources