Skip to content

Commit

Permalink
new functions for getting battery level
Browse files Browse the repository at this point in the history
  • Loading branch information
omicronrex committed Dec 9, 2024
1 parent 7f06df9 commit 62ca4e4
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 55 deletions.
128 changes: 73 additions & 55 deletions gm82core.gej
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,17 @@
],
"returntype": 2
},
{
"name": "filename_short",
"extname": "__gm82core_shortfn",
"calltype": 12,
"helpline": "filename_short(fname)",
"hidden": false,
"argtypes": [
1
],
"returntype": 1
},
{
"name": "file_get_timestamp",
"extname": "",
Expand Down Expand Up @@ -331,6 +342,24 @@
],
"returntype": 2
},
{
"name": "get_battery_level",
"extname": "",
"calltype": 12,
"helpline": "get_battery_level()",
"hidden": false,
"argtypes": [],
"returntype": 2
},
{
"name": "get_battery_status",
"extname": "",
"calltype": 12,
"helpline": "get_battery_status()",
"hidden": false,
"argtypes": [],
"returntype": 2
},
{
"name": "get_delta",
"extname": "hrt_delta",
Expand Down Expand Up @@ -385,6 +414,32 @@
"argtypes": [],
"returntype": 2
},
{
"name": "inch",
"extname": "approach",
"calltype": 12,
"helpline": "",
"hidden": true,
"argtypes": [
2,
2,
2
],
"returntype": 2
},
{
"name": "inch_angle",
"extname": "approach_angle",
"calltype": 12,
"helpline": "",
"hidden": true,
"argtypes": [
2,
2,
2
],
"returntype": 2
},
{
"name": "in_range",
"extname": "",
Expand Down Expand Up @@ -503,6 +558,19 @@
],
"returntype": 2
},
{
"name": "perlin_noise",
"extname": "",
"calltype": 12,
"helpline": "perlin_noise(x,y,z)",
"hidden": false,
"argtypes": [
2,
2,
2
],
"returntype": 2
},
{
"name": "pivot_pos_x",
"extname": "",
Expand Down Expand Up @@ -1051,45 +1119,6 @@
],
"returntype": 2
},
{
"name": "__registry_write_dword",
"extname": "",
"calltype": 12,
"helpline": "",
"hidden": true,
"argtypes": [
1,
1,
2
],
"returntype": 2
},
{
"name": "inch",
"extname": "approach",
"calltype": 12,
"helpline": "",
"hidden": true,
"argtypes": [
2,
2,
2
],
"returntype": 2
},
{
"name": "inch_angle",
"extname": "approach_angle",
"calltype": 12,
"helpline": "",
"hidden": true,
"argtypes": [
2,
2,
2
],
"returntype": 2
},
{
"name": "__registry_read_sz",
"extname": "",
Expand All @@ -1103,28 +1132,17 @@
"returntype": 1
},
{
"name": "perlin_noise",
"name": "__registry_write_dword",
"extname": "",
"calltype": 12,
"helpline": "perlin_noise(x,y,z)",
"hidden": false,
"helpline": "",
"hidden": true,
"argtypes": [
2,
2,
1,
1,
2
],
"returntype": 2
},
{
"name": "filename_short",
"extname": "__gm82core_shortfn",
"calltype": 12,
"helpline": "filename_short(fname)",
"hidden": false,
"argtypes": [
1
],
"returntype": 1
}
],
"constants": []
Expand Down
1 change: 1 addition & 0 deletions source/gm82core.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#pragma comment(lib, "GDI32.lib")
#pragma comment(lib, "comctl32.lib")
#pragma comment(lib, "ntdll.lib")
#pragma comment(lib, "Kernel32.lib")

#define GMREAL __declspec(dllexport) double __cdecl
#define GMSTR __declspec(dllexport) char* __cdecl
Expand Down
14 changes: 14 additions & 0 deletions source/windows.c
Original file line number Diff line number Diff line change
Expand Up @@ -383,3 +383,17 @@ GMREAL date_get_current_timezone() {

return -timezone;
}

GMREAL get_battery_level() {
SYSTEM_POWER_STATUS status;
GetSystemPowerStatus(&status);
return status.BatteryLifePercent;
}

GMREAL get_battery_status() {
SYSTEM_POWER_STATUS status;
GetSystemPowerStatus(&status);
if (status.BatteryFlag>=128) return 0;
if (status.ACLineStatus==1) return 2;
return 1;
}

0 comments on commit 62ca4e4

Please sign in to comment.