| 1 |
(* |
| 2 |
* Copyright (C) 2010 The Android Open Source Project |
| 3 |
* |
| 4 |
* Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 |
* you may not use this file except in compliance with the License. |
| 6 |
* You may obtain a copy of the License at |
| 7 |
* |
| 8 |
* http://www.apache.org/licenses/LICENSE-2.0 |
| 9 |
* |
| 10 |
* Unless required by applicable law or agreed to in writing, software |
| 11 |
* distributed under the License is distributed on an "AS IS" BASIS, |
| 12 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 |
* See the License for the specific language governing permissions and |
| 14 |
* limitations under the License. |
| 15 |
*) |
| 16 |
|
| 17 |
unit CastleAndroidInternalConfiguration; |
| 18 |
|
| 19 |
{$I castleconf.inc} |
| 20 |
|
| 21 |
interface |
| 22 |
|
| 23 |
uses ctypes, CastleAndroidInternalAssetManager; |
| 24 |
|
| 25 |
const |
| 26 |
LibName = 'libandroid.so'; |
| 27 |
|
| 28 |
type |
| 29 |
PAConfiguration = ^AConfiguration; |
| 30 |
AConfiguration = record end; |
| 31 |
|
| 32 |
const |
| 33 |
ACONFIGURATION_ORIENTATION_ANY = $0000; |
| 34 |
ACONFIGURATION_ORIENTATION_PORT = $0001; |
| 35 |
ACONFIGURATION_ORIENTATION_LAND = $0002; |
| 36 |
ACONFIGURATION_ORIENTATION_SQUARE = $0003; |
| 37 |
ACONFIGURATION_TOUCHSCREEN_ANY = $0000; |
| 38 |
ACONFIGURATION_TOUCHSCREEN_NOTOUCH = $0001; |
| 39 |
ACONFIGURATION_TOUCHSCREEN_STYLUS = $0002; |
| 40 |
ACONFIGURATION_TOUCHSCREEN_FINGER = $0003; |
| 41 |
ACONFIGURATION_DENSITY_DEFAULT = 0; |
| 42 |
ACONFIGURATION_DENSITY_LOW = 120; |
| 43 |
ACONFIGURATION_DENSITY_MEDIUM = 160; |
| 44 |
ACONFIGURATION_DENSITY_HIGH = 240; |
| 45 |
ACONFIGURATION_DENSITY_NONE = $ffff; |
| 46 |
ACONFIGURATION_KEYBOARD_ANY = $0000; |
| 47 |
ACONFIGURATION_KEYBOARD_NOKEYS = $0001; |
| 48 |
ACONFIGURATION_KEYBOARD_QWERTY = $0002; |
| 49 |
ACONFIGURATION_KEYBOARD_12KEY = $0003; |
| 50 |
ACONFIGURATION_NAVIGATION_ANY = $0000; |
| 51 |
ACONFIGURATION_NAVIGATION_NONAV = $0001; |
| 52 |
ACONFIGURATION_NAVIGATION_DPAD = $0002; |
| 53 |
ACONFIGURATION_NAVIGATION_TRACKBALL = $0003; |
| 54 |
ACONFIGURATION_NAVIGATION_WHEEL = $0004; |
| 55 |
ACONFIGURATION_KEYSHIDDEN_ANY = $0000; |
| 56 |
ACONFIGURATION_KEYSHIDDEN_NO = $0001; |
| 57 |
ACONFIGURATION_KEYSHIDDEN_YES = $0002; |
| 58 |
ACONFIGURATION_KEYSHIDDEN_SOFT = $0003; |
| 59 |
ACONFIGURATION_NAVHIDDEN_ANY = $0000; |
| 60 |
ACONFIGURATION_NAVHIDDEN_NO = $0001; |
| 61 |
ACONFIGURATION_NAVHIDDEN_YES = $0002; |
| 62 |
ACONFIGURATION_SCREENSIZE_ANY = $00; |
| 63 |
ACONFIGURATION_SCREENSIZE_SMALL = $01; |
| 64 |
ACONFIGURATION_SCREENSIZE_NORMAL = $02; |
| 65 |
ACONFIGURATION_SCREENSIZE_LARGE = $03; |
| 66 |
ACONFIGURATION_SCREENSIZE_XLARGE = $04; |
| 67 |
ACONFIGURATION_SCREENLONG_ANY = $00; |
| 68 |
ACONFIGURATION_SCREENLONG_NO = $1; |
| 69 |
ACONFIGURATION_SCREENLONG_YES = $2; |
| 70 |
ACONFIGURATION_UI_MODE_TYPE_ANY = $00; |
| 71 |
ACONFIGURATION_UI_MODE_TYPE_NORMAL = $01; |
| 72 |
ACONFIGURATION_UI_MODE_TYPE_DESK = $02; |
| 73 |
ACONFIGURATION_UI_MODE_TYPE_CAR = $03; |
| 74 |
ACONFIGURATION_UI_MODE_NIGHT_ANY = $00; |
| 75 |
ACONFIGURATION_UI_MODE_NIGHT_NO = $1; |
| 76 |
ACONFIGURATION_UI_MODE_NIGHT_YES = $2; |
| 77 |
ACONFIGURATION_MCC = $0001; |
| 78 |
ACONFIGURATION_MNC = $0002; |
| 79 |
ACONFIGURATION_LOCALE = $0004; |
| 80 |
ACONFIGURATION_TOUCHSCREEN = $0008; |
| 81 |
ACONFIGURATION_KEYBOARD = $0010; |
| 82 |
ACONFIGURATION_KEYBOARD_HIDDEN = $0020; |
| 83 |
ACONFIGURATION_NAVIGATION = $0040; |
| 84 |
ACONFIGURATION_ORIENTATION = $0080; |
| 85 |
ACONFIGURATION_DENSITY = $0100; |
| 86 |
ACONFIGURATION_SCREEN_SIZE = $0200; |
| 87 |
ACONFIGURATION_VERSION = $0400; |
| 88 |
ACONFIGURATION_SCREEN_LAYOUT = $0800; |
| 89 |
ACONFIGURATION_UI_MODE = $1000; |
| 90 |
|
| 91 |
(** |
| 92 |
* Create a new AConfiguration, initialized with no values set. |
| 93 |
*) |
| 94 |
function AConfiguration_new: PAConfiguration; cdecl; external LibName; |
| 95 |
|
| 96 |
(** |
| 97 |
* Free an AConfiguration that was previously created with |
| 98 |
* AConfiguration_new(). |
| 99 |
*) |
| 100 |
procedure AConfiguration_delete(config: PAConfiguration); cdecl; external LibName; |
| 101 |
|
| 102 |
(** |
| 103 |
* Create and return a new AConfiguration based on the current configuration in |
| 104 |
* use in the given AssetManager. |
| 105 |
*) |
| 106 |
procedure AConfiguration_fromAssetManager(out_: PAConfiguration; am: PAAssetManager); cdecl; external LibName; |
| 107 |
|
| 108 |
(** |
| 109 |
* Copy the contents of 'src' to 'dest'. |
| 110 |
*) |
| 111 |
procedure AConfiguration_copy(dest, src: PAConfiguration); cdecl; external LibName; |
| 112 |
|
| 113 |
(** |
| 114 |
* Return the current MCC set in the configuration. 0 if not set. |
| 115 |
*) |
| 116 |
function AConfiguration_getMcc(config: PAConfiguration): cint32; cdecl; external LibName; |
| 117 |
|
| 118 |
(** |
| 119 |
* Set the current MCC in the configuration. 0 to clear. |
| 120 |
*) |
| 121 |
procedure AConfiguration_setMcc(config: PAConfiguration; mcc: cint32); cdecl; external LibName; |
| 122 |
|
| 123 |
(** |
| 124 |
* Return the current MNC set in the configuration. 0 if not set. |
| 125 |
*) |
| 126 |
function AConfiguration_getMnc(config: PAConfiguration): cint32; cdecl; external LibName; |
| 127 |
|
| 128 |
(** |
| 129 |
* Set the current MNC in the configuration. 0 to clear. |
| 130 |
*) |
| 131 |
procedure AConfiguration_setMnc(config: PAConfiguration; mnc: cint32); cdecl; external LibName; |
| 132 |
|
| 133 |
(** |
| 134 |
* Return the current language code set in the configuration. The output will |
| 135 |
* be filled with an array of two characters. They are not 0-terminated. If |
| 136 |
* a language is not set, they will be 0. |
| 137 |
*) |
| 138 |
procedure AConfiguration_getLanguage(config: PAConfiguration; outLanguage: Pchar); cdecl; external LibName; |
| 139 |
|
| 140 |
(** |
| 141 |
* Set the current language code in the configuration, from the first two |
| 142 |
* characters in the string. |
| 143 |
*) |
| 144 |
procedure AConfiguration_setLanguage(config: PAConfiguration; language: Pchar); cdecl; external LibName; |
| 145 |
|
| 146 |
(** |
| 147 |
* Return the current country code set in the configuration. The output will |
| 148 |
* be filled with an array of two characters. They are not 0-terminated. If |
| 149 |
* a country is not set, they will be 0. |
| 150 |
*) |
| 151 |
procedure AConfiguration_getCountry(config: PAConfiguration; outCountry: Pchar); cdecl; external LibName; |
| 152 |
|
| 153 |
(** |
| 154 |
* Set the current country code in the configuration, from the first two |
| 155 |
* characters in the string. |
| 156 |
*) |
| 157 |
procedure AConfiguration_setCountry(config: PAConfiguration; country: Pchar); cdecl; external LibName; |
| 158 |
|
| 159 |
(** |
| 160 |
* Return the current ACONFIGURATION_ORIENTATION_* set in the configuration. |
| 161 |
*) |
| 162 |
function AConfiguration_getOrientation(config: PAConfiguration): cint32; cdecl; external LibName; |
| 163 |
|
| 164 |
(** |
| 165 |
* Set the current orientation in the configuration. |
| 166 |
*) |
| 167 |
procedure AConfiguration_setOrientation(config: PAConfiguration; orientation: cint32); cdecl; external LibName; |
| 168 |
|
| 169 |
(** |
| 170 |
* Return the current ACONFIGURATION_TOUCHSCREEN_* set in the configuration. |
| 171 |
*) |
| 172 |
function AConfiguration_getTouchscreen(config: PAConfiguration): cint32; cdecl; external LibName; |
| 173 |
|
| 174 |
(** |
| 175 |
* Set the current touchscreen in the configuration. |
| 176 |
*) |
| 177 |
procedure AConfiguration_setTouchscreen(config: PAConfiguration; touchscreen: cint32); cdecl; external LibName; |
| 178 |
|
| 179 |
(** |
| 180 |
* Return the current ACONFIGURATION_DENSITY_* set in the configuration. |
| 181 |
*) |
| 182 |
function AConfiguration_getDensity(config: PAConfiguration): cint32; cdecl; external LibName; |
| 183 |
|
| 184 |
(** |
| 185 |
* Set the current density in the configuration. |
| 186 |
*) |
| 187 |
procedure AConfiguration_setDensity(config: PAConfiguration; density: cint32); cdecl; external LibName; |
| 188 |
|
| 189 |
(** |
| 190 |
* Return the current ACONFIGURATION_KEYBOARD_* set in the configuration. |
| 191 |
*) |
| 192 |
function AConfiguration_getKeyboard(config: PAConfiguration): cint32; cdecl; external LibName; |
| 193 |
|
| 194 |
(** |
| 195 |
* Set the current keyboard in the configuration. |
| 196 |
*) |
| 197 |
procedure AConfiguration_setKeyboard(config: PAConfiguration; keyboard: cint32); cdecl; external LibName; |
| 198 |
|
| 199 |
(** |
| 200 |
* Return the current ACONFIGURATION_NAVIGATION_* set in the configuration. |
| 201 |
*) |
| 202 |
function AConfiguration_getNavigation(config: PAConfiguration): cint32; cdecl; external LibName; |
| 203 |
|
| 204 |
(** |
| 205 |
* Set the current navigation in the configuration. |
| 206 |
*) |
| 207 |
procedure AConfiguration_setNavigation(config: PAConfiguration; navigation: cint32); cdecl; external LibName; |
| 208 |
|
| 209 |
(** |
| 210 |
* Return the current ACONFIGURATION_KEYSHIDDEN_* set in the configuration. |
| 211 |
*) |
| 212 |
function AConfiguration_getKeysHidden(config: PAConfiguration): cint32; cdecl; external LibName; |
| 213 |
|
| 214 |
(** |
| 215 |
* Set the current keys hidden in the configuration. |
| 216 |
*) |
| 217 |
procedure AConfiguration_setKeysHidden(config: PAConfiguration; keysHidden: cint32); cdecl; external LibName; |
| 218 |
|
| 219 |
(** |
| 220 |
* Return the current ACONFIGURATION_NAVHIDDEN_* set in the configuration. |
| 221 |
*) |
| 222 |
function AConfiguration_getNavHidden(config: PAConfiguration): cint32; cdecl; external LibName; |
| 223 |
|
| 224 |
(** |
| 225 |
* Set the current nav hidden in the configuration. |
| 226 |
*) |
| 227 |
procedure AConfiguration_setNavHidden(config: PAConfiguration; navHidden: cint32); cdecl; external LibName; |
| 228 |
|
| 229 |
(** |
| 230 |
* Return the current SDK (API) version set in the configuration. |
| 231 |
*) |
| 232 |
function AConfiguration_getSdkVersion(config: PAConfiguration): cint32; cdecl; external LibName; |
| 233 |
|
| 234 |
(** |
| 235 |
* Set the current SDK version in the configuration. |
| 236 |
*) |
| 237 |
procedure AConfiguration_setSdkVersion(config: PAConfiguration; sdkVersion: cint32); cdecl; external LibName; |
| 238 |
|
| 239 |
(** |
| 240 |
* Return the current ACONFIGURATION_SCREENSIZE_* set in the configuration. |
| 241 |
*) |
| 242 |
function AConfiguration_getScreenSize(config: PAConfiguration): cint32; cdecl; external LibName; |
| 243 |
|
| 244 |
(** |
| 245 |
* Set the current screen size in the configuration. |
| 246 |
*) |
| 247 |
procedure AConfiguration_setScreenSize(config: PAConfiguration; screenSize: cint32); cdecl; external LibName; |
| 248 |
|
| 249 |
(** |
| 250 |
* Return the current ACONFIGURATION_SCREENLONG_* set in the configuration. |
| 251 |
*) |
| 252 |
function AConfiguration_getScreenLong(config: PAConfiguration): cint32; cdecl; external LibName; |
| 253 |
|
| 254 |
(** |
| 255 |
* Set the current screen long in the configuration. |
| 256 |
*) |
| 257 |
procedure AConfiguration_setScreenLong(config: PAConfiguration; screenLong: cint32); cdecl; external LibName; |
| 258 |
|
| 259 |
(** |
| 260 |
* Return the current ACONFIGURATION_UI_MODE_TYPE_* set in the configuration. |
| 261 |
*) |
| 262 |
function AConfiguration_getUiModeType(config: PAConfiguration): cint32; cdecl; external LibName; |
| 263 |
|
| 264 |
(** |
| 265 |
* Set the current UI mode type in the configuration. |
| 266 |
*) |
| 267 |
procedure AConfiguration_setUiModeType(config: PAConfiguration; uiModeType: cint32); cdecl; external LibName; |
| 268 |
|
| 269 |
(** |
| 270 |
* Return the current ACONFIGURATION_UI_MODE_NIGHT_* set in the configuration. |
| 271 |
*) |
| 272 |
function AConfiguration_getUiModeNight(config: PAConfiguration): cint32; cdecl; external LibName; |
| 273 |
|
| 274 |
(** |
| 275 |
* Set the current UI mode night in the configuration. |
| 276 |
*) |
| 277 |
procedure AConfiguration_setUiModeNight(config: PAConfiguration; uiModeNight: cint32); cdecl; external LibName; |
| 278 |
|
| 279 |
(** |
| 280 |
* Perform a diff between two configurations. Returns a bit mask of |
| 281 |
* ACONFIGURATION_* constants, each bit set meaning that configuration element |
| 282 |
* is different between them. |
| 283 |
*) |
| 284 |
function AConfiguration_diff(config1, config2: PAConfiguration): cint32; cdecl; external LibName; |
| 285 |
|
| 286 |
(** |
| 287 |
* Determine whether 'base' is a valid configuration for use within the |
| 288 |
* environment 'requested'. Returns 0 if there are any values in 'base' |
| 289 |
* that conflict with 'requested'. Returns 1 if it does not conflict. |
| 290 |
*) |
| 291 |
function AConfiguration_match(base, requested: PAConfiguration): cint32; cdecl; external LibName; |
| 292 |
|
| 293 |
(** |
| 294 |
* Determine whether the configuration in 'test' is better than the existing |
| 295 |
* configuration in 'base'. If 'requested' is non-NULL, this decision is based |
| 296 |
* on the overall configuration given there. If it is NULL, this decision is |
| 297 |
* simply based on which configuration is more specific. Returns non-0 if |
| 298 |
* 'test' is better than 'base'. |
| 299 |
* |
| 300 |
* This assumes you have already filtered the configurations with |
| 301 |
* AConfiguration_match(). |
| 302 |
*) |
| 303 |
function AConfiguration_isBetterThan(base, test, requested: PAConfiguration) : cint32; cdecl; external LibName; |
| 304 |
|
| 305 |
implementation |
| 306 |
|
| 307 |
end. |
| 308 |
|